termdock 1.4.306 → 1.4.308

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 (350) hide show
  1. package/dist/client/assets/{App-BziVLy1b.js → App-ggIA_xqR.js} +7 -7
  2. package/dist/client/assets/App-ggIA_xqR.js.br +0 -0
  3. package/dist/client/assets/App-ggIA_xqR.js.gz +0 -0
  4. package/dist/client/assets/{ArchitecturePanel-CARNBEqQ.js → ArchitecturePanel-CoBspW_C.js} +1 -1
  5. package/dist/client/assets/ArchitecturePanel-CoBspW_C.js.br +0 -0
  6. package/dist/client/assets/ArchitecturePanel-CoBspW_C.js.gz +0 -0
  7. package/dist/client/assets/{ChangeWalkthroughPanel-00oa0z6w.js → ChangeWalkthroughPanel-D1Puc7B3.js} +1 -1
  8. package/dist/client/assets/ChangeWalkthroughPanel-D1Puc7B3.js.br +0 -0
  9. package/dist/client/assets/ChangeWalkthroughPanel-D1Puc7B3.js.gz +0 -0
  10. package/dist/client/assets/{CollaborationMainWorkspace-DuEeKQKZ.js → CollaborationMainWorkspace-BPyK5Xs8.js} +1 -1
  11. package/dist/client/assets/CollaborationMainWorkspace-BPyK5Xs8.js.br +0 -0
  12. package/dist/client/assets/CollaborationMainWorkspace-BPyK5Xs8.js.gz +0 -0
  13. package/dist/client/assets/CollaborationTaskContent-CTSJJqze.js +2 -0
  14. package/dist/client/assets/{ComputerControlView-C9v1Ooc9.js → ComputerControlView-D5Lw9sNA.js} +2 -2
  15. package/dist/client/assets/ComputerControlView-D5Lw9sNA.js.br +0 -0
  16. package/dist/client/assets/ComputerControlView-D5Lw9sNA.js.gz +0 -0
  17. package/dist/client/assets/{DagPlayground-DfUpMALj.js → DagPlayground-DYJrGfiG.js} +1 -1
  18. package/dist/client/assets/DagPlayground-DYJrGfiG.js.br +0 -0
  19. package/dist/client/assets/DagPlayground-DYJrGfiG.js.gz +0 -0
  20. package/dist/client/assets/{DiffLab-Cf_URhQt.js → DiffLab-5zdcFW3z.js} +1 -1
  21. package/dist/client/assets/DiffLab-5zdcFW3z.js.br +0 -0
  22. package/dist/client/assets/DiffLab-5zdcFW3z.js.gz +0 -0
  23. package/dist/client/assets/{DiffReview-DjG9vCpH.js → DiffReview-BBBC_NjV.js} +1 -1
  24. package/dist/client/assets/DiffReview-BBBC_NjV.js.br +0 -0
  25. package/dist/client/assets/DiffReview-BBBC_NjV.js.gz +0 -0
  26. package/dist/client/assets/{DiffReviewLab-BKOvHdJY.js → DiffReviewLab-CbhosFSB.js} +1 -1
  27. package/dist/client/assets/DiffReviewLab-CbhosFSB.js.br +0 -0
  28. package/dist/client/assets/DiffReviewLab-CbhosFSB.js.gz +0 -0
  29. package/dist/client/assets/{DiffViewer-6n3tgsdc.js → DiffViewer-BuQwFQ4V.js} +1 -1
  30. package/dist/client/assets/DiffViewer-BuQwFQ4V.js.br +0 -0
  31. package/dist/client/assets/DiffViewer-BuQwFQ4V.js.gz +0 -0
  32. package/dist/client/assets/{ModelPreview-BNs2sRct.js → ModelPreview-nO2VmqdP.js} +1 -1
  33. package/dist/client/assets/ModelPreview-nO2VmqdP.js.br +0 -0
  34. package/dist/client/assets/ModelPreview-nO2VmqdP.js.gz +0 -0
  35. package/dist/client/assets/{RightSidebar-CcMSU1v8.js → RightSidebar-BoNzpS2K.js} +3 -3
  36. package/dist/client/assets/RightSidebar-BoNzpS2K.js.br +0 -0
  37. package/dist/client/assets/RightSidebar-BoNzpS2K.js.gz +0 -0
  38. package/dist/client/assets/{abnfDiagram-VCTEODGH-DogjvRKp.js → abnfDiagram-VCTEODGH-yi0K8GDG.js} +1 -1
  39. package/dist/client/assets/abnfDiagram-VCTEODGH-yi0K8GDG.js.br +0 -0
  40. package/dist/client/assets/abnfDiagram-VCTEODGH-yi0K8GDG.js.gz +0 -0
  41. package/dist/client/assets/{app-D6vN8PW-.js → app-B6FdOF6K.js} +3 -3
  42. package/dist/client/assets/app-B6FdOF6K.js.br +0 -0
  43. package/dist/client/assets/app-B6FdOF6K.js.gz +0 -0
  44. package/dist/client/assets/{arc-Cqel4Ted.js → arc-_nLI_-XZ.js} +1 -1
  45. package/dist/client/assets/arc-_nLI_-XZ.js.br +0 -0
  46. package/dist/client/assets/arc-_nLI_-XZ.js.gz +0 -0
  47. package/dist/client/assets/{architectureDiagram-5GKGNRK7-DgvPtgNb.js → architectureDiagram-5GKGNRK7-CikrA78O.js} +1 -1
  48. package/dist/client/assets/architectureDiagram-5GKGNRK7-CikrA78O.js.br +0 -0
  49. package/dist/client/assets/architectureDiagram-5GKGNRK7-CikrA78O.js.gz +0 -0
  50. package/dist/client/assets/{blockDiagram-I7D4REHJ-BxbWO4x4.js → blockDiagram-I7D4REHJ-CWJq6qJ7.js} +1 -1
  51. package/dist/client/assets/blockDiagram-I7D4REHJ-CWJq6qJ7.js.br +0 -0
  52. package/dist/client/assets/blockDiagram-I7D4REHJ-CWJq6qJ7.js.gz +0 -0
  53. package/dist/client/assets/{c4Diagram-7LVT6UL2-gsA37gjL.js → c4Diagram-7LVT6UL2-gzPzLGvs.js} +1 -1
  54. package/dist/client/assets/c4Diagram-7LVT6UL2-gzPzLGvs.js.br +0 -0
  55. package/dist/client/assets/c4Diagram-7LVT6UL2-gzPzLGvs.js.gz +0 -0
  56. package/dist/client/assets/channel-BYsFmOmF.js +1 -0
  57. package/dist/client/assets/{chunk-2Q5K7J3B-ChC9yYOd.js → chunk-2Q5K7J3B-CfX9l18E.js} +1 -1
  58. package/dist/client/assets/{chunk-5VM5RSS4-Bi4Hc8yL.js → chunk-5VM5RSS4-JSV1yrXM.js} +1 -1
  59. package/dist/client/assets/{chunk-F27PBJKO-DvVWvQEk.js → chunk-F27PBJKO-CQ0LXeap.js} +1 -1
  60. package/dist/client/assets/chunk-F27PBJKO-CQ0LXeap.js.br +0 -0
  61. package/dist/client/assets/chunk-F27PBJKO-CQ0LXeap.js.gz +0 -0
  62. package/dist/client/assets/{chunk-IMKFNOWR-BnwQLR5S.js → chunk-IMKFNOWR-CJOEPkK9.js} +1 -1
  63. package/dist/client/assets/chunk-IMKFNOWR-CJOEPkK9.js.br +0 -0
  64. package/dist/client/assets/chunk-IMKFNOWR-CJOEPkK9.js.gz +0 -0
  65. package/dist/client/assets/{chunk-JWPE2WC7-BkNnaDiR.js → chunk-JWPE2WC7-Dpp7Xu_E.js} +1 -1
  66. package/dist/client/assets/{chunk-POPQ4Y6H-BRzm6Uzi.js → chunk-POPQ4Y6H-9hDa1b8z.js} +1 -1
  67. package/dist/client/assets/{chunk-SVP7TREG-CDYm-dzk.js → chunk-SVP7TREG-BskkG9gg.js} +1 -1
  68. package/dist/client/assets/{chunk-SVP7TREG-CDYm-dzk.js.br → chunk-SVP7TREG-BskkG9gg.js.br} +0 -0
  69. package/dist/client/assets/chunk-SVP7TREG-BskkG9gg.js.gz +0 -0
  70. package/dist/client/assets/{chunk-TICWLB2K-BKaW9Z9i.js → chunk-TICWLB2K-DyzuP-9I.js} +1 -1
  71. package/dist/client/assets/chunk-TICWLB2K-DyzuP-9I.js.br +0 -0
  72. package/dist/client/assets/chunk-TICWLB2K-DyzuP-9I.js.gz +0 -0
  73. package/dist/client/assets/{chunk-XXDRQBXY-DcHZ_FHb.js → chunk-XXDRQBXY-C31_1i6z.js} +1 -1
  74. package/dist/client/assets/classDiagram-ZZMXUADV-BnmZv6Ns.js +1 -0
  75. package/dist/client/assets/classDiagram-v2-VYDZK3BY-BnmZv6Ns.js +1 -0
  76. package/dist/client/assets/{cose-bilkent-JH36ORCC-DCbbTNc6.js → cose-bilkent-JH36ORCC-Bm-ESDOc.js} +1 -1
  77. package/dist/client/assets/cose-bilkent-JH36ORCC-Bm-ESDOc.js.br +0 -0
  78. package/dist/client/assets/cose-bilkent-JH36ORCC-Bm-ESDOc.js.gz +0 -0
  79. package/dist/client/assets/{cynefin-OW5HDTMX-i23hD0Z2.js → cynefin-OW5HDTMX-DbFWAPvX.js} +1 -1
  80. package/dist/client/assets/cynefin-OW5HDTMX-DbFWAPvX.js.br +0 -0
  81. package/dist/client/assets/cynefin-OW5HDTMX-DbFWAPvX.js.gz +0 -0
  82. package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-CbyLYcqc.js → cynefinDiagram-5FMLGOSQ-Ca0IKRdH.js} +1 -1
  83. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-Ca0IKRdH.js.br +0 -0
  84. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-Ca0IKRdH.js.gz +0 -0
  85. package/dist/client/assets/{dagre-GXQ25YYZ-iJ4VKzZm.js → dagre-GXQ25YYZ-D_5uEMjJ.js} +1 -1
  86. package/dist/client/assets/dagre-GXQ25YYZ-D_5uEMjJ.js.br +0 -0
  87. package/dist/client/assets/dagre-GXQ25YYZ-D_5uEMjJ.js.gz +0 -0
  88. package/dist/client/assets/{diagram-S7CK7UJ4-BNVZcdsO.js → diagram-S7CK7UJ4-DWVpndRP.js} +1 -1
  89. package/dist/client/assets/diagram-S7CK7UJ4-DWVpndRP.js.br +0 -0
  90. package/dist/client/assets/diagram-S7CK7UJ4-DWVpndRP.js.gz +0 -0
  91. package/dist/client/assets/{diagram-UQ7AKVKN-1ghTvPiu.js → diagram-UQ7AKVKN-DmYTya3w.js} +1 -1
  92. package/dist/client/assets/diagram-UQ7AKVKN-DmYTya3w.js.br +0 -0
  93. package/dist/client/assets/diagram-UQ7AKVKN-DmYTya3w.js.gz +0 -0
  94. package/dist/client/assets/{diagram-VSXAHHWV-Ce_0nMd3.js → diagram-VSXAHHWV-BEA6kqNj.js} +1 -1
  95. package/dist/client/assets/diagram-VSXAHHWV-BEA6kqNj.js.br +0 -0
  96. package/dist/client/assets/diagram-VSXAHHWV-BEA6kqNj.js.gz +0 -0
  97. package/dist/client/assets/{diagram-VX7I27RA-CLHEkhUt.js → diagram-VX7I27RA-CU9vP0P0.js} +1 -1
  98. package/dist/client/assets/diagram-VX7I27RA-CU9vP0P0.js.br +0 -0
  99. package/dist/client/assets/diagram-VX7I27RA-CU9vP0P0.js.gz +0 -0
  100. package/dist/client/assets/{diagram-Z3DM3KII-iyb5DkP6.js → diagram-Z3DM3KII-B_GvE2g-.js} +1 -1
  101. package/dist/client/assets/diagram-Z3DM3KII-B_GvE2g-.js.br +0 -0
  102. package/dist/client/assets/diagram-Z3DM3KII-B_GvE2g-.js.gz +0 -0
  103. package/dist/client/assets/{ebnfDiagram-PWID7BFC-Dxh2TzXm.js → ebnfDiagram-PWID7BFC-BLrPQuLE.js} +1 -1
  104. package/dist/client/assets/ebnfDiagram-PWID7BFC-BLrPQuLE.js.br +0 -0
  105. package/dist/client/assets/ebnfDiagram-PWID7BFC-BLrPQuLE.js.gz +0 -0
  106. package/dist/client/assets/{erDiagram-RLTQ6QDP-Cr8IkdCC.js → erDiagram-RLTQ6QDP-DlXgoyZ-.js} +1 -1
  107. package/dist/client/assets/{erDiagram-RLTQ6QDP-Cr8IkdCC.js.br → erDiagram-RLTQ6QDP-DlXgoyZ-.js.br} +0 -0
  108. package/dist/client/assets/erDiagram-RLTQ6QDP-DlXgoyZ-.js.gz +0 -0
  109. package/dist/client/assets/{flowDiagram-HODETNUW-B8ZF1bwr.js → flowDiagram-HODETNUW-fPHWxEDZ.js} +1 -1
  110. package/dist/client/assets/flowDiagram-HODETNUW-fPHWxEDZ.js.br +0 -0
  111. package/dist/client/assets/flowDiagram-HODETNUW-fPHWxEDZ.js.gz +0 -0
  112. package/dist/client/assets/{ganttDiagram-EL5Y4UJY-zhdL10eM.js → ganttDiagram-EL5Y4UJY-B8MOv6ug.js} +1 -1
  113. package/dist/client/assets/ganttDiagram-EL5Y4UJY-B8MOv6ug.js.br +0 -0
  114. package/dist/client/assets/ganttDiagram-EL5Y4UJY-B8MOv6ug.js.gz +0 -0
  115. package/dist/client/assets/{gestureArbiter-CXYHfU__.js → gestureArbiter-JW8vcVRm.js} +1 -1
  116. package/dist/client/assets/gestureArbiter-JW8vcVRm.js.br +0 -0
  117. package/dist/client/assets/gestureArbiter-JW8vcVRm.js.gz +0 -0
  118. package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-BQf2fHBo.js → gitGraphDiagram-WWUBYQGX-lH9gSoFx.js} +1 -1
  119. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-lH9gSoFx.js.br +0 -0
  120. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-lH9gSoFx.js.gz +0 -0
  121. package/dist/client/assets/{infoDiagram-27XIBGKW-BT8xey7S.js → infoDiagram-27XIBGKW-CSG29Ty_.js} +1 -1
  122. package/dist/client/assets/{ishikawaDiagram-5VMMS53U-DunPdwW9.js → ishikawaDiagram-5VMMS53U-CcwSE5qV.js} +1 -1
  123. package/dist/client/assets/ishikawaDiagram-5VMMS53U-CcwSE5qV.js.br +0 -0
  124. package/dist/client/assets/ishikawaDiagram-5VMMS53U-CcwSE5qV.js.gz +0 -0
  125. package/dist/client/assets/{journeyDiagram-3NMN7TZE-B0y75iIg.js → journeyDiagram-3NMN7TZE-CXFUeP2c.js} +1 -1
  126. package/dist/client/assets/journeyDiagram-3NMN7TZE-CXFUeP2c.js.br +0 -0
  127. package/dist/client/assets/journeyDiagram-3NMN7TZE-CXFUeP2c.js.gz +0 -0
  128. package/dist/client/assets/{kanban-definition-UXKFOSKX-BfgA5WLo.js → kanban-definition-UXKFOSKX-KEHwljd2.js} +1 -1
  129. package/dist/client/assets/kanban-definition-UXKFOSKX-KEHwljd2.js.br +0 -0
  130. package/dist/client/assets/kanban-definition-UXKFOSKX-KEHwljd2.js.gz +0 -0
  131. package/dist/client/assets/{layout-BvjABLff.js → layout-DqYx0MnO.js} +1 -1
  132. package/dist/client/assets/layout-DqYx0MnO.js.br +0 -0
  133. package/dist/client/assets/layout-DqYx0MnO.js.gz +0 -0
  134. package/dist/client/assets/{linear-DgeFRliF.js → linear-BnG3XaJW.js} +1 -1
  135. package/dist/client/assets/linear-BnG3XaJW.js.br +0 -0
  136. package/dist/client/assets/linear-BnG3XaJW.js.gz +0 -0
  137. package/dist/client/assets/{mermaid.core-DM6Rlal9.js → mermaid.core-Ce00rdM6.js} +5 -5
  138. package/dist/client/assets/mermaid.core-Ce00rdM6.js.br +0 -0
  139. package/dist/client/assets/mermaid.core-Ce00rdM6.js.gz +0 -0
  140. package/dist/client/assets/{mindmap-definition-YA3MSWOX-DhEiABv6.js → mindmap-definition-YA3MSWOX-D0hOW4SY.js} +1 -1
  141. package/dist/client/assets/mindmap-definition-YA3MSWOX-D0hOW4SY.js.br +0 -0
  142. package/dist/client/assets/mindmap-definition-YA3MSWOX-D0hOW4SY.js.gz +0 -0
  143. package/dist/client/assets/{passwordBootstrap-Dxv0I4wM.js → passwordBootstrap-Bncb8qF_.js} +1 -1
  144. package/dist/client/assets/passwordBootstrap-Bncb8qF_.js.br +0 -0
  145. package/dist/client/assets/passwordBootstrap-Bncb8qF_.js.gz +0 -0
  146. package/dist/client/assets/{pegDiagram-XKGWAZYB-LTlVaJfm.js → pegDiagram-XKGWAZYB-UKp9t91x.js} +1 -1
  147. package/dist/client/assets/pegDiagram-XKGWAZYB-UKp9t91x.js.br +0 -0
  148. package/dist/client/assets/pegDiagram-XKGWAZYB-UKp9t91x.js.gz +0 -0
  149. package/dist/client/assets/{pieDiagram-E7YTZNPT-9bnryna3.js → pieDiagram-E7YTZNPT-Dif97wbH.js} +1 -1
  150. package/dist/client/assets/pieDiagram-E7YTZNPT-Dif97wbH.js.br +0 -0
  151. package/dist/client/assets/pieDiagram-E7YTZNPT-Dif97wbH.js.gz +0 -0
  152. package/dist/client/assets/{quadrantDiagram-AXDQQJYC-ZBmgIpsJ.js → quadrantDiagram-AXDQQJYC-BPyHtH91.js} +1 -1
  153. package/dist/client/assets/{quadrantDiagram-AXDQQJYC-ZBmgIpsJ.js.br → quadrantDiagram-AXDQQJYC-BPyHtH91.js.br} +0 -0
  154. package/dist/client/assets/quadrantDiagram-AXDQQJYC-BPyHtH91.js.gz +0 -0
  155. package/dist/client/assets/{railroadDiagram-O6MQD6OU-DTtXvKOu.js → railroadDiagram-O6MQD6OU-Wleq9LmS.js} +1 -1
  156. package/dist/client/assets/railroadDiagram-O6MQD6OU-Wleq9LmS.js.br +0 -0
  157. package/dist/client/assets/railroadDiagram-O6MQD6OU-Wleq9LmS.js.gz +0 -0
  158. package/dist/client/assets/{rdpSession-Ggo3N5s5.js → rdpSession-CobFMSUs.js} +1 -1
  159. package/dist/client/assets/rdpSession-CobFMSUs.js.br +0 -0
  160. package/dist/client/assets/rdpSession-CobFMSUs.js.gz +0 -0
  161. package/dist/client/assets/{referenceLongPress-Df8W2cyP.js → referenceLongPress-bZ0xp-v2.js} +1 -1
  162. package/dist/client/assets/referenceLongPress-bZ0xp-v2.js.br +0 -0
  163. package/dist/client/assets/referenceLongPress-bZ0xp-v2.js.gz +0 -0
  164. package/dist/client/assets/{requirementDiagram-BXWQKSXE-BNia9zI0.js → requirementDiagram-BXWQKSXE-BL4pp0Ta.js} +1 -1
  165. package/dist/client/assets/requirementDiagram-BXWQKSXE-BL4pp0Ta.js.br +0 -0
  166. package/dist/client/assets/requirementDiagram-BXWQKSXE-BL4pp0Ta.js.gz +0 -0
  167. package/dist/client/assets/{sankeyDiagram-P5KCCOFB-uvg5npfK.js → sankeyDiagram-P5KCCOFB-CV1cKx37.js} +1 -1
  168. package/dist/client/assets/sankeyDiagram-P5KCCOFB-CV1cKx37.js.br +0 -0
  169. package/dist/client/assets/sankeyDiagram-P5KCCOFB-CV1cKx37.js.gz +0 -0
  170. package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-DpJNf2MD.js → sequenceDiagram-WJ2MYXX4-BF2InLwV.js} +1 -1
  171. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-BF2InLwV.js.br +0 -0
  172. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-BF2InLwV.js.gz +0 -0
  173. package/dist/client/assets/{sizeCapture-INFHLROL-CkWB2AnF.js → sizeCapture-INFHLROL-CldUyStR.js} +1 -1
  174. package/dist/client/assets/sizeCapture-INFHLROL-CldUyStR.js.br +0 -0
  175. package/dist/client/assets/sizeCapture-INFHLROL-CldUyStR.js.gz +0 -0
  176. package/dist/client/assets/{sparkles-DOuEtn62.js → sparkles-Cg-yPdE2.js} +1 -1
  177. package/dist/client/assets/{stateDiagram-D77RDMKH-CeMzMQq-.js → stateDiagram-D77RDMKH-CByehbEd.js} +1 -1
  178. package/dist/client/assets/stateDiagram-D77RDMKH-CByehbEd.js.br +0 -0
  179. package/dist/client/assets/stateDiagram-D77RDMKH-CByehbEd.js.gz +0 -0
  180. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-CTcrJ-w0.js +1 -0
  181. package/dist/client/assets/{swimlanes-42K2YHIH-Bo9GejWo.js → swimlanes-42K2YHIH--1_7YTL4.js} +1 -1
  182. package/dist/client/assets/swimlanes-42K2YHIH--1_7YTL4.js.br +0 -0
  183. package/dist/client/assets/swimlanes-42K2YHIH--1_7YTL4.js.gz +0 -0
  184. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-RSMV9AhO.js +8 -0
  185. package/dist/client/assets/{timeline-definition-24CTP7MA-cvWXYEZ4.js → timeline-definition-24CTP7MA-CXfXJFK6.js} +1 -1
  186. package/dist/client/assets/timeline-definition-24CTP7MA-CXfXJFK6.js.br +0 -0
  187. package/dist/client/assets/timeline-definition-24CTP7MA-CXfXJFK6.js.gz +0 -0
  188. package/dist/client/assets/{triangle-alert-DzV0gQXz.js → triangle-alert-CbMRJ6sx.js} +1 -1
  189. package/dist/client/assets/{vennDiagram-4TSXK5OY-CzleWcmk.js → vennDiagram-4TSXK5OY-byr6UQpL.js} +1 -1
  190. package/dist/client/assets/vennDiagram-4TSXK5OY-byr6UQpL.js.br +0 -0
  191. package/dist/client/assets/vennDiagram-4TSXK5OY-byr6UQpL.js.gz +0 -0
  192. package/dist/client/assets/{videoCompression-DCnzjEfU.js → videoCompression-ivJAy00d.js} +1 -1
  193. package/dist/client/assets/videoCompression-ivJAy00d.js.br +0 -0
  194. package/dist/client/assets/videoCompression-ivJAy00d.js.gz +0 -0
  195. package/dist/client/assets/{wardleyDiagram-VM6X3IG4-Cir1iutR.js → wardleyDiagram-VM6X3IG4-FJduk-7s.js} +1 -1
  196. package/dist/client/assets/wardleyDiagram-VM6X3IG4-FJduk-7s.js.br +0 -0
  197. package/dist/client/assets/wardleyDiagram-VM6X3IG4-FJduk-7s.js.gz +0 -0
  198. package/dist/client/assets/{xychartDiagram-S5SC5T6Z-pNPcVJ1C.js → xychartDiagram-S5SC5T6Z-Ct1fBPFS.js} +1 -1
  199. package/dist/client/assets/xychartDiagram-S5SC5T6Z-Ct1fBPFS.js.br +0 -0
  200. package/dist/client/assets/xychartDiagram-S5SC5T6Z-Ct1fBPFS.js.gz +0 -0
  201. package/dist/client/index.html +1 -1
  202. package/dist/client/index.html.br +0 -0
  203. package/dist/client/index.html.gz +0 -0
  204. package/dist/client/sw.js +1 -1
  205. package/dist/client/sw.js.br +0 -0
  206. package/dist/client/sw.js.gz +0 -0
  207. package/dist/server/agent/collaborationCli.js +62 -16
  208. package/dist/server/agent/collaborationPrompt.js +3 -1
  209. package/dist/server/agent/collaborationProtocol.js +1 -1
  210. package/dist/server/agent/collaborationRoutes.js +8 -1
  211. package/dist/server/agent/collaborationStore.js +81 -11
  212. package/dist/server/agent/collaborationTaskCli.js +25 -7
  213. package/dist/server/agent/collaborationTaskPurpose.js +20 -0
  214. package/dist/server/agent/collaborationTaskRoutes.js +1 -1
  215. package/dist/server/agent/collaborationTaskService.js +15 -6
  216. package/dist/server/agent/collaborationTaskStore.js +35 -6
  217. package/dist/server/agent/integrationCli.js +15 -4
  218. package/dist/server/agent/integrationServer.js +92 -14
  219. package/dist/server/agent/integrationStore.js +1 -1
  220. package/dist/server/cli.js +1 -1
  221. package/docs/integrations.md +177 -5
  222. package/package.json +1 -1
  223. package/runtime-manifest.json +3 -3
  224. package/dist/client/assets/App-BziVLy1b.js.br +0 -0
  225. package/dist/client/assets/App-BziVLy1b.js.gz +0 -0
  226. package/dist/client/assets/ArchitecturePanel-CARNBEqQ.js.br +0 -0
  227. package/dist/client/assets/ArchitecturePanel-CARNBEqQ.js.gz +0 -0
  228. package/dist/client/assets/ChangeWalkthroughPanel-00oa0z6w.js.br +0 -0
  229. package/dist/client/assets/ChangeWalkthroughPanel-00oa0z6w.js.gz +0 -0
  230. package/dist/client/assets/CollaborationMainWorkspace-DuEeKQKZ.js.br +0 -0
  231. package/dist/client/assets/CollaborationMainWorkspace-DuEeKQKZ.js.gz +0 -0
  232. package/dist/client/assets/CollaborationTaskContent-B_mzpNuw.js +0 -2
  233. package/dist/client/assets/ComputerControlView-C9v1Ooc9.js.br +0 -0
  234. package/dist/client/assets/ComputerControlView-C9v1Ooc9.js.gz +0 -0
  235. package/dist/client/assets/DagPlayground-DfUpMALj.js.br +0 -0
  236. package/dist/client/assets/DagPlayground-DfUpMALj.js.gz +0 -0
  237. package/dist/client/assets/DiffLab-Cf_URhQt.js.br +0 -0
  238. package/dist/client/assets/DiffLab-Cf_URhQt.js.gz +0 -0
  239. package/dist/client/assets/DiffReview-DjG9vCpH.js.br +0 -0
  240. package/dist/client/assets/DiffReview-DjG9vCpH.js.gz +0 -0
  241. package/dist/client/assets/DiffReviewLab-BKOvHdJY.js.br +0 -0
  242. package/dist/client/assets/DiffReviewLab-BKOvHdJY.js.gz +0 -0
  243. package/dist/client/assets/DiffViewer-6n3tgsdc.js.br +0 -0
  244. package/dist/client/assets/DiffViewer-6n3tgsdc.js.gz +0 -0
  245. package/dist/client/assets/ModelPreview-BNs2sRct.js.br +0 -0
  246. package/dist/client/assets/ModelPreview-BNs2sRct.js.gz +0 -0
  247. package/dist/client/assets/RightSidebar-CcMSU1v8.js.br +0 -0
  248. package/dist/client/assets/RightSidebar-CcMSU1v8.js.gz +0 -0
  249. package/dist/client/assets/abnfDiagram-VCTEODGH-DogjvRKp.js.br +0 -0
  250. package/dist/client/assets/abnfDiagram-VCTEODGH-DogjvRKp.js.gz +0 -0
  251. package/dist/client/assets/app-D6vN8PW-.js.br +0 -0
  252. package/dist/client/assets/app-D6vN8PW-.js.gz +0 -0
  253. package/dist/client/assets/arc-Cqel4Ted.js.br +0 -0
  254. package/dist/client/assets/arc-Cqel4Ted.js.gz +0 -0
  255. package/dist/client/assets/architectureDiagram-5GKGNRK7-DgvPtgNb.js.br +0 -0
  256. package/dist/client/assets/architectureDiagram-5GKGNRK7-DgvPtgNb.js.gz +0 -0
  257. package/dist/client/assets/blockDiagram-I7D4REHJ-BxbWO4x4.js.br +0 -0
  258. package/dist/client/assets/blockDiagram-I7D4REHJ-BxbWO4x4.js.gz +0 -0
  259. package/dist/client/assets/c4Diagram-7LVT6UL2-gsA37gjL.js.br +0 -0
  260. package/dist/client/assets/c4Diagram-7LVT6UL2-gsA37gjL.js.gz +0 -0
  261. package/dist/client/assets/channel-CBc8-n7y.js +0 -1
  262. package/dist/client/assets/chunk-F27PBJKO-DvVWvQEk.js.br +0 -0
  263. package/dist/client/assets/chunk-F27PBJKO-DvVWvQEk.js.gz +0 -0
  264. package/dist/client/assets/chunk-IMKFNOWR-BnwQLR5S.js.br +0 -0
  265. package/dist/client/assets/chunk-IMKFNOWR-BnwQLR5S.js.gz +0 -0
  266. package/dist/client/assets/chunk-SVP7TREG-CDYm-dzk.js.gz +0 -0
  267. package/dist/client/assets/chunk-TICWLB2K-BKaW9Z9i.js.br +0 -0
  268. package/dist/client/assets/chunk-TICWLB2K-BKaW9Z9i.js.gz +0 -0
  269. package/dist/client/assets/classDiagram-ZZMXUADV-CNFc2dOc.js +0 -1
  270. package/dist/client/assets/classDiagram-v2-VYDZK3BY-CNFc2dOc.js +0 -1
  271. package/dist/client/assets/cose-bilkent-JH36ORCC-DCbbTNc6.js.br +0 -0
  272. package/dist/client/assets/cose-bilkent-JH36ORCC-DCbbTNc6.js.gz +0 -0
  273. package/dist/client/assets/cynefin-OW5HDTMX-i23hD0Z2.js.br +0 -0
  274. package/dist/client/assets/cynefin-OW5HDTMX-i23hD0Z2.js.gz +0 -0
  275. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-CbyLYcqc.js.br +0 -0
  276. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-CbyLYcqc.js.gz +0 -0
  277. package/dist/client/assets/dagre-GXQ25YYZ-iJ4VKzZm.js.br +0 -0
  278. package/dist/client/assets/dagre-GXQ25YYZ-iJ4VKzZm.js.gz +0 -0
  279. package/dist/client/assets/diagram-S7CK7UJ4-BNVZcdsO.js.br +0 -0
  280. package/dist/client/assets/diagram-S7CK7UJ4-BNVZcdsO.js.gz +0 -0
  281. package/dist/client/assets/diagram-UQ7AKVKN-1ghTvPiu.js.br +0 -0
  282. package/dist/client/assets/diagram-UQ7AKVKN-1ghTvPiu.js.gz +0 -0
  283. package/dist/client/assets/diagram-VSXAHHWV-Ce_0nMd3.js.br +0 -0
  284. package/dist/client/assets/diagram-VSXAHHWV-Ce_0nMd3.js.gz +0 -0
  285. package/dist/client/assets/diagram-VX7I27RA-CLHEkhUt.js.br +0 -0
  286. package/dist/client/assets/diagram-VX7I27RA-CLHEkhUt.js.gz +0 -0
  287. package/dist/client/assets/diagram-Z3DM3KII-iyb5DkP6.js.br +0 -0
  288. package/dist/client/assets/diagram-Z3DM3KII-iyb5DkP6.js.gz +0 -0
  289. package/dist/client/assets/ebnfDiagram-PWID7BFC-Dxh2TzXm.js.br +0 -0
  290. package/dist/client/assets/ebnfDiagram-PWID7BFC-Dxh2TzXm.js.gz +0 -0
  291. package/dist/client/assets/erDiagram-RLTQ6QDP-Cr8IkdCC.js.gz +0 -0
  292. package/dist/client/assets/flowDiagram-HODETNUW-B8ZF1bwr.js.br +0 -0
  293. package/dist/client/assets/flowDiagram-HODETNUW-B8ZF1bwr.js.gz +0 -0
  294. package/dist/client/assets/ganttDiagram-EL5Y4UJY-zhdL10eM.js.br +0 -0
  295. package/dist/client/assets/ganttDiagram-EL5Y4UJY-zhdL10eM.js.gz +0 -0
  296. package/dist/client/assets/gestureArbiter-CXYHfU__.js.br +0 -0
  297. package/dist/client/assets/gestureArbiter-CXYHfU__.js.gz +0 -0
  298. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-BQf2fHBo.js.br +0 -0
  299. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-BQf2fHBo.js.gz +0 -0
  300. package/dist/client/assets/ishikawaDiagram-5VMMS53U-DunPdwW9.js.br +0 -0
  301. package/dist/client/assets/ishikawaDiagram-5VMMS53U-DunPdwW9.js.gz +0 -0
  302. package/dist/client/assets/journeyDiagram-3NMN7TZE-B0y75iIg.js.br +0 -0
  303. package/dist/client/assets/journeyDiagram-3NMN7TZE-B0y75iIg.js.gz +0 -0
  304. package/dist/client/assets/kanban-definition-UXKFOSKX-BfgA5WLo.js.br +0 -0
  305. package/dist/client/assets/kanban-definition-UXKFOSKX-BfgA5WLo.js.gz +0 -0
  306. package/dist/client/assets/layout-BvjABLff.js.br +0 -0
  307. package/dist/client/assets/layout-BvjABLff.js.gz +0 -0
  308. package/dist/client/assets/linear-DgeFRliF.js.br +0 -0
  309. package/dist/client/assets/linear-DgeFRliF.js.gz +0 -0
  310. package/dist/client/assets/mermaid.core-DM6Rlal9.js.br +0 -0
  311. package/dist/client/assets/mermaid.core-DM6Rlal9.js.gz +0 -0
  312. package/dist/client/assets/mindmap-definition-YA3MSWOX-DhEiABv6.js.br +0 -0
  313. package/dist/client/assets/mindmap-definition-YA3MSWOX-DhEiABv6.js.gz +0 -0
  314. package/dist/client/assets/passwordBootstrap-Dxv0I4wM.js.br +0 -0
  315. package/dist/client/assets/passwordBootstrap-Dxv0I4wM.js.gz +0 -0
  316. package/dist/client/assets/pegDiagram-XKGWAZYB-LTlVaJfm.js.br +0 -0
  317. package/dist/client/assets/pegDiagram-XKGWAZYB-LTlVaJfm.js.gz +0 -0
  318. package/dist/client/assets/pieDiagram-E7YTZNPT-9bnryna3.js.br +0 -0
  319. package/dist/client/assets/pieDiagram-E7YTZNPT-9bnryna3.js.gz +0 -0
  320. package/dist/client/assets/quadrantDiagram-AXDQQJYC-ZBmgIpsJ.js.gz +0 -0
  321. package/dist/client/assets/railroadDiagram-O6MQD6OU-DTtXvKOu.js.br +0 -0
  322. package/dist/client/assets/railroadDiagram-O6MQD6OU-DTtXvKOu.js.gz +0 -0
  323. package/dist/client/assets/rdpSession-Ggo3N5s5.js.br +0 -0
  324. package/dist/client/assets/rdpSession-Ggo3N5s5.js.gz +0 -0
  325. package/dist/client/assets/referenceLongPress-Df8W2cyP.js.br +0 -0
  326. package/dist/client/assets/referenceLongPress-Df8W2cyP.js.gz +0 -0
  327. package/dist/client/assets/requirementDiagram-BXWQKSXE-BNia9zI0.js.br +0 -0
  328. package/dist/client/assets/requirementDiagram-BXWQKSXE-BNia9zI0.js.gz +0 -0
  329. package/dist/client/assets/sankeyDiagram-P5KCCOFB-uvg5npfK.js.br +0 -0
  330. package/dist/client/assets/sankeyDiagram-P5KCCOFB-uvg5npfK.js.gz +0 -0
  331. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-DpJNf2MD.js.br +0 -0
  332. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-DpJNf2MD.js.gz +0 -0
  333. package/dist/client/assets/sizeCapture-INFHLROL-CkWB2AnF.js.br +0 -0
  334. package/dist/client/assets/sizeCapture-INFHLROL-CkWB2AnF.js.gz +0 -0
  335. package/dist/client/assets/stateDiagram-D77RDMKH-CeMzMQq-.js.br +0 -0
  336. package/dist/client/assets/stateDiagram-D77RDMKH-CeMzMQq-.js.gz +0 -0
  337. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-CNYUpLxt.js +0 -1
  338. package/dist/client/assets/swimlanes-42K2YHIH-Bo9GejWo.js.br +0 -0
  339. package/dist/client/assets/swimlanes-42K2YHIH-Bo9GejWo.js.gz +0 -0
  340. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-EB7zBRFR.js +0 -8
  341. package/dist/client/assets/timeline-definition-24CTP7MA-cvWXYEZ4.js.br +0 -0
  342. package/dist/client/assets/timeline-definition-24CTP7MA-cvWXYEZ4.js.gz +0 -0
  343. package/dist/client/assets/vennDiagram-4TSXK5OY-CzleWcmk.js.br +0 -0
  344. package/dist/client/assets/vennDiagram-4TSXK5OY-CzleWcmk.js.gz +0 -0
  345. package/dist/client/assets/videoCompression-DCnzjEfU.js.br +0 -0
  346. package/dist/client/assets/videoCompression-DCnzjEfU.js.gz +0 -0
  347. package/dist/client/assets/wardleyDiagram-VM6X3IG4-Cir1iutR.js.br +0 -0
  348. package/dist/client/assets/wardleyDiagram-VM6X3IG4-Cir1iutR.js.gz +0 -0
  349. package/dist/client/assets/xychartDiagram-S5SC5T6Z-pNPcVJ1C.js.br +0 -0
  350. package/dist/client/assets/xychartDiagram-S5SC5T6Z-pNPcVJ1C.js.gz +0 -0
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/videoCompression-DCnzjEfU.js","assets/app-D6vN8PW-.js","assets/react-XDCjal2T.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/index-CNY7CTVa.css","assets/CollaborationTaskContent-B_mzpNuw.js","assets/RightSidebar-CcMSU1v8.js","assets/gestureArbiter-CXYHfU__.js","assets/gestureArbiter-C2J0D0kV.css","assets/DiffReview-DjG9vCpH.js","assets/sparkles-DOuEtn62.js","assets/DiffViewer-6n3tgsdc.js","assets/referenceLongPress-Df8W2cyP.js","assets/DiffViewer-T3uj2-aP.css","assets/triangle-alert-DzV0gQXz.js","assets/ChangeWalkthroughPanel-00oa0z6w.js","assets/RightSidebar-DW-JEgm2.css","assets/CollaborationMainWorkspace-DuEeKQKZ.js"])))=>i.map(i=>d[i]);
2
- import{ae as $t,aK as Pu,bv as s,aa as rc,d6 as zr,G as M8,df as nl,d2 as wa,d4 as ns,a_ as nc,a5 as Hd,ax as r3,bm as T1,cJ as j8,d3 as vd,cu as rd,b3 as lo,j as nd,ad as _u,ck as up,cR as D8,aq as Tc,bu as hu,g as B8,cE as Lh,Y as Q8,b8 as _m,bF as km,cA as P8,av as O8,cd as F8,a3 as n3,cb as $8,cy as s3,a8 as U8,af as z8,L as In,C as di,X as Qn,f as H8,d as ul,bd as W8,aZ as Lm,d8 as G8,dd as Yr,bD as C1,dc as Gt,aB as V8,dk as q8,v as Y8,bK as Z8,bY as K8,bO as X8,cw as Ug,cx as zg,cz as Hg,W as Wg,bX as J8,cK as ew,t as W0,bl as S1,d1 as tw,_ as kc,b6 as rw,i as nw,aX as sl,T as Bo,d7 as wd,db as sw,ce as iw,al as aw,aV as ow,bV as lw,bW as cw,P as i3,V as Gg,bL as Vg,bx as a3,n as Us,Z as Ih,cS as dp,bE as uw,cg as dw,bC as o3,da as hw,bc as ol,dh as fw,B as Jl,e as hi,u as pw,ai as mw,K as Im,cr as gw,h as Qo,bq as xw,br as bw,an as l3,az as c3,a4 as gu,m as G0,co as Zl,b_ as u3,au as V0,c as Em,d5 as d3,aH as yw,S as Vh,bj as qh,a as h3,ap as vw,ac as ww,c$ as Aw,b$ as ku,a6 as ec,bB as qg,cv as Tw,c3 as Cw,cO as Sw,cQ as f3,by as _w,bA as _1,cC as kw,cD as Lw,c0 as Iw,cB as Ew,cl as Nw,ci as Rw,cf as Mw,c2 as jw,cs as Dw,bN as Bw,bM as p3,cn as Qw,bz as Yg,aF as Pw,aY as Ow,D as Fw,aE as Zg,bH as $w,q as Uw,p as zw,bJ as Hw,z as Ww,c1 as Gw,l as Vw,ct as qw,r as Yw,bZ as Zw,as as Kw,ay as Xw,aA as Jw,b7 as e0,bh as e9,cY as t9,bi as r9,am as n9,c_ as s9,O as i9,ah as a9,ab as o9,A as l9,b5 as c9,ao as u9,M as d9,de as h9,bP as fc,b2 as f9,a$ as p9,b0 as m9,b1 as g9,aT as hp,bQ as x9,c7 as b9,ch as y9,b4 as v9,aW as w9,cP as Kg,ak as A9,a7 as T9,R as C9,cW as S9,di as Un,cM as _9,aS as k9,b9 as Xg,c6 as L9,cI as Wd,cV as t0,cZ as I9,c8 as E9,cN as N9,cF as R9,cU as fp,cG as M9,cH as j9,d9 as D9,aj as B9,cq as r0,bG as Q9,bt as Gd,bs as P9,c4 as Jg,c9 as O9,c5 as Xc,ca as F9,a2 as $9,a9 as U9,s as z9}from"./app-D6vN8PW-.js";import{b,R as _,r as Li,a as H9}from"./dnd-BCFAPC0L.js";import{b as W9,c as G9,F as jc,S as V9,e as q9,h as Y9,r as Z9,y as K9,d as X9,u as J9}from"./gestureArbiter-CXYHfU__.js";import{L as eA,l as tA}from"./terminal-C7X98Amf.js";import{T as k1,L as Lu,C as Iu,M as rA,G as nA}from"./triangle-alert-DzV0gQXz.js";import{r as sA}from"./react-XDCjal2T.js";import{u as L1,G as iA}from"./referenceLongPress-Df8W2cyP.js";const aA=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],m3=$t("archive",aA);const oA=[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]],lA=$t("arrow-down-a-z",oA);const cA=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],uA=$t("arrow-down",cA);const dA=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],g3=$t("arrow-up",dA);const hA=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],x3=$t("bell",hA);const fA=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Ad=$t("bot",fA);const pA=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],mA=$t("box",pA);const gA=[["path",{d:"M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z",key:"trhst0"}],["path",{d:"M17 21v-2",key:"ds4u3f"}],["path",{d:"M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10",key:"1mo9zo"}],["path",{d:"M21 21v-2",key:"eo0ou"}],["path",{d:"M3 5V3",key:"1k5hjh"}],["path",{d:"M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z",key:"1dd30t"}],["path",{d:"M7 5V3",key:"1t1388"}]],xA=$t("cable",gA);const bA=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],yA=$t("calendar-clock",bA);const vA=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],wA=$t("camera",vA);const AA=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 16h8",key:"srdodz"}],["path",{d:"M7 11h12",key:"127s9w"}],["path",{d:"M7 6h3",key:"w9rmul"}]],TA=$t("chart-bar",AA);const CA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],SA=$t("circle-dot",CA);const _A=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Yh=$t("circle-question-mark",_A);const kA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Eu=$t("circle",kA);const LA=[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]],IA=$t("clipboard-paste",LA);const EA=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]],b3=$t("clipboard",EA);const NA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6h4",key:"135r8i"}]],sd=$t("clock-3",NA);const RA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],MA=$t("clock",RA);const jA=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],DA=$t("code",jA);const BA=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],_l=$t("columns-2",BA);const QA=[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]],PA=$t("corner-down-left",QA);const OA=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],id=$t("download",OA);const FA=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Lc=$t("external-link",FA);const $A=[["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 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],UA=$t("file-code",$A);const zA=[["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:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]],HA=$t("file-up",zA);const WA=[["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"}]],y3=$t("file",WA);const GA=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],wu=$t("folder-open",GA);const VA=[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]],I1=$t("folder-search",VA);const qA=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],YA=$t("folder-tree",qA);const ZA=[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 12h18",key:"1i2n21"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]],e2=$t("grid-2x2",ZA);const KA=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],If=$t("grip-vertical",KA);const XA=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],JA=$t("hash",XA);const eT=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Sc=$t("history",eT);const tT=[["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"}]],rT=$t("house",tT);const nT=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],v3=$t("keyboard",nT);const sT=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],w3=$t("layers",sT);const iT=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],aT=$t("layout-dashboard",iT);const oT=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],Nu=$t("layout-grid",oT);const lT=[["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"}]],cT=$t("maximize",lT);const uT=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],Td=$t("message-circle",uT);const dT=[["path",{d:"M5 12h14",key:"1ays0h"}]],A3=$t("minus",dT);const hT=[["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"}]],fT=$t("minimize",hT);const pT=[["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"}]],mT=$t("monitor-smartphone",pT);const gT=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],xT=$t("moon",gT);const bT=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]],yT=$t("move",bT);const vT=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],wT=$t("network",vT);const AT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],TT=$t("panel-right-close",AT);const CT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],ST=$t("panel-left",CT);const _T=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],kT=$t("panel-right-open",_T);const LT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],T3=$t("panel-right",LT);const IT=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],ET=$t("paperclip",IT);const NT=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],RT=$t("pause",NT);const MT=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],jT=$t("pen-line",MT);const DT=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],BT=$t("pencil-line",DT);const QT=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],ad=$t("pin",QT);const PT=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]],od=$t("pin-off",PT);const OT=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],Zh=$t("play",OT);const FT=[["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"}]],$T=$t("plug",FT);const UT=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],zT=$t("power",UT);const HT=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],yn=$t("refresh-cw",HT);const WT=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],C3=$t("rotate-ccw",WT);const GT=[["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"}]],VT=$t("rotate-cw",GT);const qT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]],t2=$t("rows-2",qT);const YT=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],El=$t("search",YT);const ZT=[["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"}]],q0=$t("send",ZT);const KT=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],XT=$t("settings",KT);const JT=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],eC=$t("shield-alert",JT);const tC=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],rC=$t("shield-check",tC);const nC=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],Nm=$t("sliders-horizontal",nC);const sC=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],S3=$t("square",sC);const iC=[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]],aC=$t("stethoscope",iC);const oC=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],lC=$t("sun",oC);const cC=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],zs=$t("trash-2",cC);const uC=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],dC=$t("type",uC);const hC=[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]],fC=$t("unlink",hC);const pC=[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]],_3=$t("unplug",pC);const mC=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],k3=$t("video",mC);const gC=[["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"}]],xC=$t("volume-1",gC);const bC=[["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"}]],yC=$t("volume-2",bC);const vC=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],wC=$t("wand-sparkles",vC);const AC=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],Vd=$t("workflow",AC);function TC(e,t){return e==="webgl"&&t}function L3(e,t,r){const n=[],a=new Map;for(const c of e){const l=t(c),h=l&&l.trim().length>0?l:"";let p=a.get(h);p||(p={key:h,label:h?Pu(h)??h:r,sessions:[]},a.set(h,p),n.push(p)),p.sessions.push(c)}return n.sort((c,l)=>(c.key===""?1:0)-(l.key===""?1:0))}function CC(e){return e&&e.trim().length>0?e:""}function I3(e,t,r){const n=[...e],[a]=n.splice(t,1);return a?(n.splice(r,0,a),n.flatMap(c=>c.sessions.map(l=>l.id))):e.flatMap(c=>c.sessions.map(l=>l.id))}function E3(e,t){const r=new Set;return e.flatMap(n=>{const a=[...new Set(n.sessionIds)].filter(c=>t.has(c)&&!r.has(c));return!n.federated&&n.sessionIds.length>0&&a.length===0?[]:(a.forEach(c=>r.add(c)),[{...n,sessionIds:a}])})}function Kh(e,t,r,n,a=[],c=[]){const l=new Map(e.map(k=>[k.id,k])),h=E3(c,new Set(l.keys())),p=new Map,m=new Map,x=a.filter(k=>k.sessionIds.length>=2&&k.sessionIds.every(L=>l.has(L))),y=(k,L)=>{const E=l.get(L);k.forEach(R=>{p.set(R,k),m.set(R,E)})};for(const k of h){const L=new Set(k.sessionIds),E=new Map;for(const W of x)W.sessionIds.every(F=>L.has(F))&&W.sessionIds.forEach(F=>E.set(F,W.sessionIds));const R=new Set,B=k.sessionIds.flatMap(W=>{if(R.has(W))return[];const F=E.get(W)??[W];return F.forEach(U=>R.add(U)),F});y(B,k.sessionIds[0])}for(const k of x)k.sessionIds.some(L=>p.has(L))||y(k.sessionIds,k.sessionIds[0]);const w=k=>{const L=new Set;return k.flatMap(E=>{if(L.has(E.id))return[];const R=p.get(E.id)??[E.id];return R.forEach(B=>L.add(B)),R.map(B=>l.get(B))})};if(!r)return{arranged:w(e),groups:[]};const v=L3(e,k=>t(m.get(k.id)??k),n).map(k=>({...k,sessions:w(k.sessions)}));return{arranged:v.flatMap(k=>k.sessions),groups:v}}function SC(e){return e.isActive&&e.viewportFocused&&e.documentVisible&&e.windowFocused&&e.streamReady}function _C(e){return e.isActive&&e.documentVisible&&e.streamReady&&(!e.isDesktop||e.windowFocused)}function kC(e){return e.isActive&&!e.isMobile&&e.documentVisible&&!e.activeElementIsEditable}function LC(e,t){return!e&&t}function IC(e){const t=e instanceof Error?e.message:"";return/directory does not exist|not a directory/i.test(t)?"directoryUnavailable":/EACCES|permission denied|outside.*allowed|not allowed/i.test(t)?"permissionDenied":e instanceof TypeError||/network|failed to fetch|connection|timed? ?out|timeout|aborted/i.test(t)?"connection":"unknown"}const Rm=e=>({directoryUnavailable:"sidebar.sessionCreateDirectoryUnavailable",permissionDenied:"sidebar.sessionCreatePermissionDenied",connection:"sidebar.sessionCreateConnectionFailed",unknown:"sidebar.sessionCreateFailed"})[e];function EC({workspace:e,children:t,rightInset:r=0}){const n=!!e;return s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:a=>{a&&(a.inert=n)},"aria-hidden":n?!0:void 0,style:{visibility:n?"hidden":void 0},className:"relative flex h-full w-full min-h-0 flex-col overflow-visible app-chrome-bg",children:t}),n&&s.jsx("div",{"data-collaboration-workspace-frame":!0,className:"absolute inset-y-0 left-0",style:{right:r},children:e})]})}const na=rc(e=>({drafts:{},setDraft:(t,r)=>e(n=>({drafts:{...n.drafts,[t]:r}})),groupId:null,view:"tasks",open:(t,r="tasks")=>e({groupId:t,view:r}),terminal:()=>e({groupId:null})}));function NC({state:e,onCopy:t,copied:r}){const{t:n}=zr(),[a,c]=b.useState(null),l=e.caAvailable&&e.onboardingUrl?new URL("/ca",e.onboardingUrl).href:null;return b.useEffect(()=>{let h=!1;return c(null),l&&M8.toDataURL(l,{width:180,margin:2,errorCorrectionLevel:"M"}).then(p=>{h||c(p)}).catch(()=>{}),()=>{h=!0}},[l]),s.jsxs("div",{className:"space-y-3 text-xs leading-relaxed text-muted-foreground",children:[s.jsx("p",{children:n("settings.mobileSetupIntro")}),e.httpsEnabled&&s.jsxs("section",{className:"space-y-3 rounded-xl bg-surface-2 p-3",children:[s.jsx("h3",{className:"font-medium text-foreground",children:n("settings.mobileSetupDownload")}),l?s.jsxs(s.Fragment,{children:[a&&s.jsx("img",{src:a,alt:n("settings.mobileSetupDownload"),className:"h-44 w-44 rounded-lg"}),s.jsxs("button",{type:"button",onClick:()=>t(l),className:"flex w-full items-center justify-between gap-3 rounded-lg bg-surface p-2 text-left",children:[s.jsx("span",{className:"break-all",children:l}),s.jsx("span",{className:"shrink-0 text-primary",children:n(r?"rightSidebar.copied":"common.copy")})]})]}):s.jsx("p",{children:n("settings.caMissing")}),s.jsx("p",{children:n("settings.mobileSetupIos")}),s.jsx("p",{children:n("settings.mobileSetupAndroid")})]}),s.jsx("h3",{className:"font-medium text-foreground",children:e.httpsEnabled?n("settings.mobileSetupConnect"):n("settings.localAccess")}),s.jsx("p",{children:n("settings.mobileSetupConnectHint")})]})}const Xh=rc(e=>({collaborationGroups:[],setCollaborationGroups:t=>e(r=>({collaborationGroups:typeof t=="function"?t(r.collaborationGroups):t}))}));function r2(){const e=nl(),t=e.visualViewport,r=document.documentElement.style,n=m=>m===void 0?"?":Math.round(m),a=m=>r.getPropertyValue(m)||"?";let c=document.activeElement?.parentElement,l=null;for(;c&&!l;)l=c.querySelector('[data-mobile-keyboard="true"]'),c=c.parentElement;const h=l?.getBoundingClientRect(),p=document.getElementById("root")?.getBoundingClientRect();return[`VVP ${n(t?.height)} off ${n(t?.offsetTop)} win ${e.innerHeight}`,`base ${a("--app-base-vh")} kb ${a("--kb-height")} move ${a("--kb-translate-y")}`,`bar ${n(h?.top)}…${n(h?.bottom)} h ${n(h?.height)} root ${n(p?.bottom)}`,`safe ${a("--safe-top-inset")}/${a("--safe-bottom-inset")} frame ${e!==window?"child":"root"} focus ${document.activeElement?.tagName??"?"}`].join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/videoCompression-ivJAy00d.js","assets/app-B6FdOF6K.js","assets/react-XDCjal2T.js","assets/dnd-BCFAPC0L.js","assets/terminal-C7X98Amf.js","assets/index-CNY7CTVa.css","assets/CollaborationTaskContent-CTSJJqze.js","assets/RightSidebar-BoNzpS2K.js","assets/gestureArbiter-JW8vcVRm.js","assets/gestureArbiter-C2J0D0kV.css","assets/DiffReview-BBBC_NjV.js","assets/sparkles-Cg-yPdE2.js","assets/DiffViewer-BuQwFQ4V.js","assets/referenceLongPress-bZ0xp-v2.js","assets/DiffViewer-T3uj2-aP.css","assets/triangle-alert-CbMRJ6sx.js","assets/ChangeWalkthroughPanel-D1Puc7B3.js","assets/RightSidebar-DW-JEgm2.css","assets/CollaborationMainWorkspace-BPyK5Xs8.js"])))=>i.map(i=>d[i]);
2
+ import{ae as $t,aK as Pu,bv as s,aa as rc,d6 as zr,G as M8,df as nl,d2 as wa,d4 as ns,a_ as nc,a5 as Hd,ax as r3,bm as T1,cJ as j8,d3 as vd,cu as rd,b3 as lo,j as nd,ad as _u,ck as up,cR as D8,aq as Tc,bu as hu,g as B8,cE as Lh,Y as Q8,b8 as _m,bF as km,cA as P8,av as O8,cd as F8,a3 as n3,cb as $8,cy as s3,a8 as U8,af as z8,L as In,C as di,X as Qn,f as H8,d as ul,bd as W8,aZ as Lm,d8 as G8,dd as Yr,bD as C1,dc as Gt,aB as V8,dk as q8,v as Y8,bK as Z8,bY as K8,bO as X8,cw as Ug,cx as zg,cz as Hg,W as Wg,bX as J8,cK as ew,t as W0,bl as S1,d1 as tw,_ as kc,b6 as rw,i as nw,aX as sl,T as Bo,d7 as wd,db as sw,ce as iw,al as aw,aV as ow,bV as lw,bW as cw,P as i3,V as Gg,bL as Vg,bx as a3,n as Us,Z as Ih,cS as dp,bE as uw,cg as dw,bC as o3,da as hw,bc as ol,dh as fw,B as Jl,e as hi,u as pw,ai as mw,K as Im,cr as gw,h as Qo,bq as xw,br as bw,an as l3,az as c3,a4 as gu,m as G0,co as Zl,b_ as u3,au as V0,c as Em,d5 as d3,aH as yw,S as Vh,bj as qh,a as h3,ap as vw,ac as ww,c$ as Aw,b$ as ku,a6 as ec,bB as qg,cv as Tw,c3 as Cw,cO as Sw,cQ as f3,by as _w,bA as _1,cC as kw,cD as Lw,c0 as Iw,cB as Ew,cl as Nw,ci as Rw,cf as Mw,c2 as jw,cs as Dw,bN as Bw,bM as p3,cn as Qw,bz as Yg,aF as Pw,aY as Ow,D as Fw,aE as Zg,bH as $w,q as Uw,p as zw,bJ as Hw,z as Ww,c1 as Gw,l as Vw,ct as qw,r as Yw,bZ as Zw,as as Kw,ay as Xw,aA as Jw,b7 as e0,bh as e9,cY as t9,bi as r9,am as n9,c_ as s9,O as i9,ah as a9,ab as o9,A as l9,b5 as c9,ao as u9,M as d9,de as h9,bP as fc,b2 as f9,a$ as p9,b0 as m9,b1 as g9,aT as hp,bQ as x9,c7 as b9,ch as y9,b4 as v9,aW as w9,cP as Kg,ak as A9,a7 as T9,R as C9,cW as S9,di as Un,cM as _9,aS as k9,b9 as Xg,c6 as L9,cI as Wd,cV as t0,cZ as I9,c8 as E9,cN as N9,cF as R9,cU as fp,cG as M9,cH as j9,d9 as D9,aj as B9,cq as r0,bG as Q9,bt as Gd,bs as P9,c4 as Jg,c9 as O9,c5 as Xc,ca as F9,a2 as $9,a9 as U9,s as z9}from"./app-B6FdOF6K.js";import{b,R as _,r as Li,a as H9}from"./dnd-BCFAPC0L.js";import{b as W9,c as G9,F as jc,S as V9,e as q9,h as Y9,r as Z9,y as K9,d as X9,u as J9}from"./gestureArbiter-JW8vcVRm.js";import{L as eA,l as tA}from"./terminal-C7X98Amf.js";import{T as k1,L as Lu,C as Iu,M as rA,G as nA}from"./triangle-alert-CbMRJ6sx.js";import{r as sA}from"./react-XDCjal2T.js";import{u as L1,G as iA}from"./referenceLongPress-bZ0xp-v2.js";const aA=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],m3=$t("archive",aA);const oA=[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]],lA=$t("arrow-down-a-z",oA);const cA=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],uA=$t("arrow-down",cA);const dA=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],g3=$t("arrow-up",dA);const hA=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],x3=$t("bell",hA);const fA=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Ad=$t("bot",fA);const pA=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],mA=$t("box",pA);const gA=[["path",{d:"M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z",key:"trhst0"}],["path",{d:"M17 21v-2",key:"ds4u3f"}],["path",{d:"M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10",key:"1mo9zo"}],["path",{d:"M21 21v-2",key:"eo0ou"}],["path",{d:"M3 5V3",key:"1k5hjh"}],["path",{d:"M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z",key:"1dd30t"}],["path",{d:"M7 5V3",key:"1t1388"}]],xA=$t("cable",gA);const bA=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],yA=$t("calendar-clock",bA);const vA=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],wA=$t("camera",vA);const AA=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 16h8",key:"srdodz"}],["path",{d:"M7 11h12",key:"127s9w"}],["path",{d:"M7 6h3",key:"w9rmul"}]],TA=$t("chart-bar",AA);const CA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],SA=$t("circle-dot",CA);const _A=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Yh=$t("circle-question-mark",_A);const kA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Eu=$t("circle",kA);const LA=[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]],IA=$t("clipboard-paste",LA);const EA=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]],b3=$t("clipboard",EA);const NA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6h4",key:"135r8i"}]],sd=$t("clock-3",NA);const RA=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],MA=$t("clock",RA);const jA=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],DA=$t("code",jA);const BA=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],_l=$t("columns-2",BA);const QA=[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]],PA=$t("corner-down-left",QA);const OA=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],id=$t("download",OA);const FA=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Lc=$t("external-link",FA);const $A=[["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 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],UA=$t("file-code",$A);const zA=[["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:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]],HA=$t("file-up",zA);const WA=[["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"}]],y3=$t("file",WA);const GA=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],wu=$t("folder-open",GA);const VA=[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]],I1=$t("folder-search",VA);const qA=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],YA=$t("folder-tree",qA);const ZA=[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 12h18",key:"1i2n21"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]],e2=$t("grid-2x2",ZA);const KA=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],If=$t("grip-vertical",KA);const XA=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],JA=$t("hash",XA);const eT=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Sc=$t("history",eT);const tT=[["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"}]],rT=$t("house",tT);const nT=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],v3=$t("keyboard",nT);const sT=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],w3=$t("layers",sT);const iT=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],aT=$t("layout-dashboard",iT);const oT=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],Nu=$t("layout-grid",oT);const lT=[["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"}]],cT=$t("maximize",lT);const uT=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],Td=$t("message-circle",uT);const dT=[["path",{d:"M5 12h14",key:"1ays0h"}]],A3=$t("minus",dT);const hT=[["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"}]],fT=$t("minimize",hT);const pT=[["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"}]],mT=$t("monitor-smartphone",pT);const gT=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],xT=$t("moon",gT);const bT=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]],yT=$t("move",bT);const vT=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],wT=$t("network",vT);const AT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],TT=$t("panel-right-close",AT);const CT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],ST=$t("panel-left",CT);const _T=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],kT=$t("panel-right-open",_T);const LT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],T3=$t("panel-right",LT);const IT=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],ET=$t("paperclip",IT);const NT=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],RT=$t("pause",NT);const MT=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],jT=$t("pen-line",MT);const DT=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],BT=$t("pencil-line",DT);const QT=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],ad=$t("pin",QT);const PT=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]],od=$t("pin-off",PT);const OT=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],Zh=$t("play",OT);const FT=[["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"}]],$T=$t("plug",FT);const UT=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],zT=$t("power",UT);const HT=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],yn=$t("refresh-cw",HT);const WT=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],C3=$t("rotate-ccw",WT);const GT=[["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"}]],VT=$t("rotate-cw",GT);const qT=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]],t2=$t("rows-2",qT);const YT=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],El=$t("search",YT);const ZT=[["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"}]],q0=$t("send",ZT);const KT=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],XT=$t("settings",KT);const JT=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],eC=$t("shield-alert",JT);const tC=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],rC=$t("shield-check",tC);const nC=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],Nm=$t("sliders-horizontal",nC);const sC=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],S3=$t("square",sC);const iC=[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]],aC=$t("stethoscope",iC);const oC=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],lC=$t("sun",oC);const cC=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],zs=$t("trash-2",cC);const uC=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],dC=$t("type",uC);const hC=[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]],fC=$t("unlink",hC);const pC=[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]],_3=$t("unplug",pC);const mC=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],k3=$t("video",mC);const gC=[["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"}]],xC=$t("volume-1",gC);const bC=[["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"}]],yC=$t("volume-2",bC);const vC=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],wC=$t("wand-sparkles",vC);const AC=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],Vd=$t("workflow",AC);function TC(e,t){return e==="webgl"&&t}function L3(e,t,r){const n=[],a=new Map;for(const c of e){const l=t(c),h=l&&l.trim().length>0?l:"";let p=a.get(h);p||(p={key:h,label:h?Pu(h)??h:r,sessions:[]},a.set(h,p),n.push(p)),p.sessions.push(c)}return n.sort((c,l)=>(c.key===""?1:0)-(l.key===""?1:0))}function CC(e){return e&&e.trim().length>0?e:""}function I3(e,t,r){const n=[...e],[a]=n.splice(t,1);return a?(n.splice(r,0,a),n.flatMap(c=>c.sessions.map(l=>l.id))):e.flatMap(c=>c.sessions.map(l=>l.id))}function E3(e,t){const r=new Set;return e.flatMap(n=>{const a=[...new Set(n.sessionIds)].filter(c=>t.has(c)&&!r.has(c));return!n.federated&&n.sessionIds.length>0&&a.length===0?[]:(a.forEach(c=>r.add(c)),[{...n,sessionIds:a}])})}function Kh(e,t,r,n,a=[],c=[]){const l=new Map(e.map(k=>[k.id,k])),h=E3(c,new Set(l.keys())),p=new Map,m=new Map,x=a.filter(k=>k.sessionIds.length>=2&&k.sessionIds.every(L=>l.has(L))),y=(k,L)=>{const E=l.get(L);k.forEach(R=>{p.set(R,k),m.set(R,E)})};for(const k of h){const L=new Set(k.sessionIds),E=new Map;for(const W of x)W.sessionIds.every(F=>L.has(F))&&W.sessionIds.forEach(F=>E.set(F,W.sessionIds));const R=new Set,B=k.sessionIds.flatMap(W=>{if(R.has(W))return[];const F=E.get(W)??[W];return F.forEach(U=>R.add(U)),F});y(B,k.sessionIds[0])}for(const k of x)k.sessionIds.some(L=>p.has(L))||y(k.sessionIds,k.sessionIds[0]);const w=k=>{const L=new Set;return k.flatMap(E=>{if(L.has(E.id))return[];const R=p.get(E.id)??[E.id];return R.forEach(B=>L.add(B)),R.map(B=>l.get(B))})};if(!r)return{arranged:w(e),groups:[]};const v=L3(e,k=>t(m.get(k.id)??k),n).map(k=>({...k,sessions:w(k.sessions)}));return{arranged:v.flatMap(k=>k.sessions),groups:v}}function SC(e){return e.isActive&&e.viewportFocused&&e.documentVisible&&e.windowFocused&&e.streamReady}function _C(e){return e.isActive&&e.documentVisible&&e.streamReady&&(!e.isDesktop||e.windowFocused)}function kC(e){return e.isActive&&!e.isMobile&&e.documentVisible&&!e.activeElementIsEditable}function LC(e,t){return!e&&t}function IC(e){const t=e instanceof Error?e.message:"";return/directory does not exist|not a directory/i.test(t)?"directoryUnavailable":/EACCES|permission denied|outside.*allowed|not allowed/i.test(t)?"permissionDenied":e instanceof TypeError||/network|failed to fetch|connection|timed? ?out|timeout|aborted/i.test(t)?"connection":"unknown"}const Rm=e=>({directoryUnavailable:"sidebar.sessionCreateDirectoryUnavailable",permissionDenied:"sidebar.sessionCreatePermissionDenied",connection:"sidebar.sessionCreateConnectionFailed",unknown:"sidebar.sessionCreateFailed"})[e];function EC({workspace:e,children:t,rightInset:r=0}){const n=!!e;return s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:a=>{a&&(a.inert=n)},"aria-hidden":n?!0:void 0,style:{visibility:n?"hidden":void 0},className:"relative flex h-full w-full min-h-0 flex-col overflow-visible app-chrome-bg",children:t}),n&&s.jsx("div",{"data-collaboration-workspace-frame":!0,className:"absolute inset-y-0 left-0",style:{right:r},children:e})]})}const na=rc(e=>({drafts:{},setDraft:(t,r)=>e(n=>({drafts:{...n.drafts,[t]:r}})),groupId:null,view:"tasks",open:(t,r="tasks")=>e({groupId:t,view:r}),terminal:()=>e({groupId:null})}));function NC({state:e,onCopy:t,copied:r}){const{t:n}=zr(),[a,c]=b.useState(null),l=e.caAvailable&&e.onboardingUrl?new URL("/ca",e.onboardingUrl).href:null;return b.useEffect(()=>{let h=!1;return c(null),l&&M8.toDataURL(l,{width:180,margin:2,errorCorrectionLevel:"M"}).then(p=>{h||c(p)}).catch(()=>{}),()=>{h=!0}},[l]),s.jsxs("div",{className:"space-y-3 text-xs leading-relaxed text-muted-foreground",children:[s.jsx("p",{children:n("settings.mobileSetupIntro")}),e.httpsEnabled&&s.jsxs("section",{className:"space-y-3 rounded-xl bg-surface-2 p-3",children:[s.jsx("h3",{className:"font-medium text-foreground",children:n("settings.mobileSetupDownload")}),l?s.jsxs(s.Fragment,{children:[a&&s.jsx("img",{src:a,alt:n("settings.mobileSetupDownload"),className:"h-44 w-44 rounded-lg"}),s.jsxs("button",{type:"button",onClick:()=>t(l),className:"flex w-full items-center justify-between gap-3 rounded-lg bg-surface p-2 text-left",children:[s.jsx("span",{className:"break-all",children:l}),s.jsx("span",{className:"shrink-0 text-primary",children:n(r?"rightSidebar.copied":"common.copy")})]})]}):s.jsx("p",{children:n("settings.caMissing")}),s.jsx("p",{children:n("settings.mobileSetupIos")}),s.jsx("p",{children:n("settings.mobileSetupAndroid")})]}),s.jsx("h3",{className:"font-medium text-foreground",children:e.httpsEnabled?n("settings.mobileSetupConnect"):n("settings.localAccess")}),s.jsx("p",{children:n("settings.mobileSetupConnectHint")})]})}const Xh=rc(e=>({collaborationGroups:[],setCollaborationGroups:t=>e(r=>({collaborationGroups:typeof t=="function"?t(r.collaborationGroups):t}))}));function r2(){const e=nl(),t=e.visualViewport,r=document.documentElement.style,n=m=>m===void 0?"?":Math.round(m),a=m=>r.getPropertyValue(m)||"?";let c=document.activeElement?.parentElement,l=null;for(;c&&!l;)l=c.querySelector('[data-mobile-keyboard="true"]'),c=c.parentElement;const h=l?.getBoundingClientRect(),p=document.getElementById("root")?.getBoundingClientRect();return[`VVP ${n(t?.height)} off ${n(t?.offsetTop)} win ${e.innerHeight}`,`base ${a("--app-base-vh")} kb ${a("--kb-height")} move ${a("--kb-translate-y")}`,`bar ${n(h?.top)}…${n(h?.bottom)} h ${n(h?.height)} root ${n(p?.bottom)}`,`safe ${a("--safe-top-inset")}/${a("--safe-bottom-inset")} frame ${e!==window?"child":"root"} focus ${document.activeElement?.tagName??"?"}`].join(`
3
3
  `)}function RC({onClose:e}){const[t,r]=_.useState(r2);return _.useEffect(()=>{const n=window.setInterval(()=>r(r2()),200);return()=>window.clearInterval(n)},[]),s.jsxs("div",{className:"pointer-events-none fixed inset-x-2 z-toast rounded-lg border border-border/15 bg-surface p-2 text-foreground md:hidden",style:{top:"calc(var(--safe-top-inset, 0px) + 40px)"},children:[s.jsx("button",{type:"button",className:"pointer-events-auto absolute right-1 top-1 px-2 py-1 text-xs",onPointerDown:n=>n.preventDefault(),onClick:e,"aria-label":"关闭布局诊断",children:"×"}),s.jsx("pre",{className:"pr-5 font-mono text-[10px] leading-tight",children:t})]})}const MC={x:0,y:0,width:1,height:1};function Ic(e){return"id"in e?[e.id]:[...Ic(e.first),...Ic(e.second)]}function Mm(e,t=0,r=new Set){if(!e||typeof e!="object"||t>24)return null;const n=e;if(typeof n.id=="string"&&n.id&&!r.has(n.id))return r.add(n.id),{id:n.id};if(!["x","y"].includes(String(n.axis))||!Number.isFinite(n.ratio))return null;const a=Mm(n.first,t+1,r),c=Mm(n.second,t+1,r);return a&&c?{axis:n.axis,ratio:Math.max(.02,Math.min(.98,Number(n.ratio))),first:a,second:c}:a??c}function ld(e,t){if("id"in e)return t.has(e.id)?e:null;const r=ld(e.first,t),n=ld(e.second,t);return r&&n?{...e,first:r,second:n}:r??n}function Jh(e,t,r,n){return"id"in e?e.id===t?{axis:n==="left"||n==="right"?"x":"y",ratio:.5,first:n==="left"||n==="top"?{id:r}:e,second:n==="left"||n==="top"?e:{id:r}}:e:{...e,first:Jh(e.first,t,r,n),second:Jh(e.second,t,r,n)}}function jC(e,t,r,n){if(t===r||!Ic(e).includes(t)||!Ic(e).includes(r))return e;if(n==="center"){const a=c=>"id"in c?{id:c.id===t?r:c.id===r?t:c.id}:{...c,first:a(c.first),second:a(c.second)};return a(e)}return Jh(ld(e,new Set(Ic(e).filter(a=>a!==t))),r,t,n)}function Au(e,t){if(e.length===1)return{id:e[0]};if(t==="grid"&&e.length>2){const r=Math.ceil(e.length/2);return{axis:"y",ratio:.5,first:Au(e.slice(0,r),"horizontal"),second:Au(e.slice(r),"horizontal")}}return{axis:t==="vertical"?"y":"x",ratio:1/e.length,first:{id:e[0]},second:Au(e.slice(1),t)}}function jm(e,t=MC,r=""){if("id"in e)return{panes:[{id:e.id,rect:t}],dividers:[]};const n={...t},a={...t};e.axis==="x"?(n.width*=e.ratio,a.x+=n.width,a.width-=n.width):(n.height*=e.ratio,a.y+=n.height,a.height-=n.height);const c=jm(e.first,n,r+"0"),l=jm(e.second,a,r+"1");return{panes:[...c.panes,...l.panes],dividers:[{path:r,node:e,rect:t},...c.dividers,...l.dividers]}}function Y0(e,t,r){return"id"in e?e:t?t[0]==="0"?{...e,first:Y0(e.first,t.slice(1),r)}:{...e,second:Y0(e.second,t.slice(1),r)}:{...e,ratio:r}}function N3(e){return"id"in e||"id"in e.first||"id"in e.second||e.first.axis===e.axis||e.second.axis===e.axis||!("id"in e.first.first)||!("id"in e.first.second)||!("id"in e.second.first)||!("id"in e.second.second)?null:e.axis==="y"?{ids:[e.first.first.id,e.first.second.id,e.second.first.id,e.second.second.id],top:e.first.ratio,bottom:e.second.ratio,left:e.ratio,right:e.ratio}:{ids:[e.first.first.id,e.second.first.id,e.first.second.id,e.second.second.id],top:e.ratio,bottom:e.ratio,left:e.first.ratio,right:e.second.ratio}}function pp(e,t,r){const n=N3(e);if(!n)return e;const[a,c,l,h]=n.ids.map(p=>({id:p}));return t==="top"||t==="bottom"?{axis:"y",ratio:(n.left+n.right)/2,first:{axis:"x",ratio:t==="top"?r:n.top,first:a,second:c},second:{axis:"x",ratio:t==="bottom"?r:n.bottom,first:l,second:h}}:{axis:"x",ratio:(n.top+n.bottom)/2,first:{axis:"y",ratio:t==="left"?r:n.left,first:a,second:l},second:{axis:"y",ratio:t==="right"?r:n.right,first:c,second:h}}}function DC(e,t,r,n,a){const c=(p,m,x)=>{if(p.length===1)return p[0];const y=x?.length===p.length&&x.every(w=>Number.isFinite(w)&&w>0)?x:p.map(()=>1);return{axis:m,ratio:y[0]/y.reduce((w,v)=>w+v,0),first:p[0],second:c(p.slice(1),m,y.slice(1))}};if(t!=="grid")return c(e.map(p=>({id:p})),t==="vertical"?"y":"x",r);const l=Math.ceil(Math.sqrt(e.length)),h=[];for(let p=0;p<e.length;p+=l){const m=e.slice(p,p+l).map(y=>({id:y})),x=n?.length===l?n.slice(0,m.length):void 0;x&&m.length<l&&(x[x.length-1]+=n.slice(m.length).reduce((y,w)=>y+w,0)),h.push(c(m,"x",x))}return c(h,"y",a)}let BC;function Ef(){try{const e="termdock-collaboration-panel-client",t=localStorage.getItem(e);if(t)return t;const r=crypto.randomUUID();return localStorage.setItem(e,r),r}catch{return BC??=crypto.randomUUID()}}let n2=Promise.resolve();function co(e,t){t&&(e={groups:{[t]:e}});const r=Ef(),n=n2.catch(()=>{}).then(()=>wa({collaborationPanel:{clientId:r,state:e}}));return n2=n,n.then(()=>{})}function s2(e,t,r,n,a,c){return{x:a>0?Math.max(0,Math.min(1,(e-r)/a)):.5,y:c>0?Math.max(0,Math.min(1,(t-n)/c)):.5}}function R3(e,t){return t?{...{...e?.floatingGroupId===t?e:{},...e?.groups?.[t]},drafts:e?.drafts}:{drafts:e?.drafts}}function M3(e){const t=Object.entries(e?.groups??{}).filter(([,r])=>r.floatingGroupId).map(([r])=>r);return e?.floatingGroupId&&!e.groups?.[e.floatingGroupId]&&t.push(e.floatingGroupId),t}async function QC(e,t){const r=na.getState(),n=r.groupId;r.drafts[e]&&await co({drafts:{[e]:r.drafts[e]}});const a={sessionId:t,side:window.innerWidth<640?"bottom":"right"};if(await co({floatingGroupId:e,mode:"docked",dock:a},e),na.getState().groupId!==n)throw new Error("布局已保存;页面已切换,请重新打开成员消息");window.dispatchEvent(new CustomEvent("termdock:open-collaboration-messages",{detail:{groupId:e,dock:a}}))}const PC=e=>e.startsWith("@collaboration:"),i2=e=>({left:`${e.x*100}%`,top:`${e.y*100}%`,width:`${e.width*100}%`,height:`${e.height*100}%`});function OC({groupId:e}){const t=ns(a=>a.setHost),r=b.useRef(null),n=b.useCallback(a=>{(a||ns.getState().hosts[e]===r.current)&&t(e,a),r.current=a},[e,t]);return s.jsx("div",{ref:n,className:"h-full min-h-0 min-w-0 bg-surface"})}function a2({layoutId:e,panes:t,preset:r="grid",initialTree:n,focusId:a,mobile:c=!1}){const l=ns(re=>re.docks),h=JSON.stringify(t.map(re=>re.id)),p=Object.entries(l).filter(([,re])=>t.some(Pe=>Pe.id===re.sessionId)),m=JSON.stringify(p),x=b.useRef(null),[y,w]=b.useState(()=>n??Au(t.map(re=>re.id),c?"vertical":r)),v=b.useRef(y);v.current=y;const[k,L]=b.useState(!1),E=ns(re=>re.activePaneId),[R,B]=b.useState(null),[W,F]=b.useState(null),[U,V]=b.useState(null),Z=b.useRef(r),le=b.useRef(t.map(re=>re.id)),xe=b.useRef({}),fe=b.useRef(!1),te=()=>{fe.current&&(fe.current=!1,co({layouts:{[e]:v.current}}).catch(()=>{fe.current=!0,B("布局保存失败,调整后重试")}))};b.useEffect(()=>{let re=!1;return nc().then(Pe=>{if(re)return;const Se=Pe.collaborationPanels?.[Ef()];for(const Be of M3(Se)){const Ne=R3(Se,Be);Ne.mode==="docked"&&Ne.dock&&t.some(oe=>oe.id===Ne.dock.sessionId)&&!ns.getState().docks[Be]&&ns.getState().setDock(Be,Ne.dock)}let Ee=Mm(Se?.layouts?.[e]);if(Ee&&Se?.floatingGroupId){const Be=Ne=>"id"in Ne?{id:Ne.id==="@collaboration"?Hd(Se.floatingGroupId):Ne.id}:{...Ne,first:Be(Ne.first),second:Be(Ne.second)};Ee=Be(Ee)}Ee&&w(Ee),L(!0)}).catch(()=>{re||B("布局加载失败,请刷新重试")}),()=>{re=!0}},[e]);const ke=re=>{fe.current=!0,v.current=re,w(re)};b.useLayoutEffect(()=>{if(!k)return;const re=JSON.parse(h),Pe=Z.current!==r;Z.current=r;let Se=Pe?Au(re,r):v.current;const Ee=le.current;if(!Pe&&Ee.length===re.length&&Ee.every(oe=>re.includes(oe))&&Ee.some((oe,He)=>oe!==re[He])){const oe=new Map(Ee.map((rt,mt)=>[rt,re[mt]])),He=rt=>"id"in rt?{id:oe.get(rt.id)??rt.id}:{...rt,first:He(rt.first),second:He(rt.second)};Se=He(Se)}le.current=re;const Be=new Set([...re,...p.map(([oe])=>Hd(oe))]);Se=ld(Se,Be)??Au(re,r);for(const oe of re)Ic(Se).includes(oe)||(Se={axis:"x",ratio:.5,first:Se,second:{id:oe}});const Ne={};for(const[oe,He]of p){const rt=Hd(oe),mt=`${He.sessionId}:${He.side}`;if(Ne[oe]=mt,(!Ic(Se).includes(rt)||xe.current[oe]&&xe.current[oe]!==mt)&&(Se=ld(Se,new Set([...Be].filter(de=>de!==rt))),Se=Jh(Se,He.sessionId,rt,He.side)),He.preferredWidth&&(He.side==="left"||He.side==="right")){const de=(Ye,st)=>{if("id"in Ye)return Ye;const Ie="id"in Ye.first&&Ye.first.id===rt,We="id"in Ye.second&&Ye.second.id===rt;if(Ye.axis==="x"&&(Ie||We)&&Ye.ratio===.5){const ae=(x.current?.clientWidth||window.innerWidth)*st.width,be=Math.max(.1,Math.min(.45,He.preferredWidth/Math.max(1,ae)));return{...Ye,ratio:Ie?be:1-be}}const Te={...st},H={...st};return Ye.axis==="x"?(Te.width*=Ye.ratio,H.x+=Te.width,H.width-=Te.width):(Te.height*=Ye.ratio,H.y+=Te.height,H.height-=Te.height),{...Ye,first:de(Ye.first,Te),second:de(Ye.second,H)}};Se=de(Se,{x:0,y:0,width:1,height:1})}}xe.current=Ne,JSON.stringify(Se)!==JSON.stringify(v.current)&&(ke(Se),te())},[k,h,r,m]),b.useEffect(()=>{const re=()=>te();return window.addEventListener("pagehide",re),()=>{window.removeEventListener("pagehide",re),document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})),re()}},[e]);const $e=jm(y),Y=N3(y),Ae=[...t,...p.map(([re])=>({id:Hd(re),content:s.jsx(OC,{groupId:re})}))],lt=b.useRef(null),Ce=b.useRef(U);Ce.current=U;const ye=b.useRef(null);b.useEffect(()=>{const re=x.current;if(!re||!k)return;const Pe=Ee=>{if(Ee.button!==0||!(Ee.target instanceof Element))return;const Be=Ee.target.closest("[data-split-pane-title], [data-panel-drag-title]"),Ne=Ee.target.closest("button, a, input, textarea, select, summary");if(!Be||Ne&&Ne!==Be)return;const oe=Be.closest("[data-layout-pane]");if(!oe||!re.contains(oe))return;document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!0}}));const He=oe.getBoundingClientRect();lt.current={id:oe.dataset.layoutPane,x:Ee.clientX,y:Ee.clientY,moved:!1,originX:Ee.clientX-He.left,originY:Ee.clientY-He.top,scale:Math.min(.8,480/Math.max(1,He.width),320/Math.max(1,He.height))},re.setPointerCapture?.(Ee.pointerId)},Se=Ee=>{const Be=Ee.target;if(!(Be instanceof Element))return;const Ne=Be.closest("[data-layout-pane]");if(!(!Ne||!re.contains(Ne))){if(Ee.type==="pointerdown"&&ns.getState().activePaneId!==Ne.dataset.layoutPane){const oe=document.activeElement;oe instanceof HTMLElement&&oe.closest("[data-layout-pane]")&&!Ne.contains(oe)&&oe.blur();const He=window.getSelection();He?.anchorNode&&!Ne.contains(He.anchorNode)&&He.removeAllRanges()}ns.getState().setActivePane(Ne.dataset.layoutPane)}};return re.addEventListener("pointerdown",Se,!0),re.addEventListener("focusin",Se,!0),re.addEventListener("pointerdown",Pe,!0),()=>{re.removeEventListener("pointerdown",Pe,!0),re.removeEventListener("pointerdown",Se,!0),re.removeEventListener("focusin",Se,!0)}},[k]);const _e=(re,Pe)=>{const Se=x.current?.getBoundingClientRect(),Ee=ye.current;if(!Se||!Ee)return;const Be=Ee.axis==="x"?Se.width*Ee.rect.width:Se.height*Ee.rect.height,Ne=Ee.axis==="x"?Se.left+Se.width*Ee.rect.x:Se.top+Se.height*Ee.rect.y,oe=Math.min(.45,(c?48:120)/Math.max(1,Be)),He=Math.max(oe,Math.min(1-oe,((Ee.axis==="x"?re:Pe)-Ne)/Math.max(1,Be)));ke(Ee.side?pp(v.current,Ee.side,He):Y0(v.current,Ee.path,He))},je=Y?[{key:"top",side:"top",axis:"x",x:Y.top,y:0,length:(Y.left+Y.right)/2},{key:"bottom",side:"bottom",axis:"x",x:Y.bottom,y:(Y.left+Y.right)/2,length:1-(Y.left+Y.right)/2},{key:"left",side:"left",axis:"y",x:0,y:Y.left,length:(Y.top+Y.bottom)/2},{key:"right",side:"right",axis:"y",x:(Y.top+Y.bottom)/2,y:Y.right,length:1-(Y.top+Y.bottom)/2}].map(re=>({...re,rect:{x:0,y:0,width:1,height:1},path:void 0})):$e.dividers.map(re=>({key:re.path,path:re.path,side:void 0,axis:re.node.axis,rect:re.rect,x:re.rect.x+(re.node.axis==="x"?re.rect.width*re.node.ratio:0),y:re.rect.y+(re.node.axis==="y"?re.rect.height*re.node.ratio:0),length:re.node.axis==="x"?re.rect.height:re.rect.width}));return s.jsxs("div",{ref:x,"data-split-container":"true",className:"relative h-full min-h-0 min-w-0 flex-1 overflow-hidden bg-border [&_[data-split-pane-title]]:touch-none [&_[data-panel-drag-title]]:touch-none",onPointerMove:re=>{if(ye.current){re.preventDefault(),_e(re.clientX,re.clientY);return}const Pe=lt.current,Se=x.current?.getBoundingClientRect();if(!Pe||!Se||!Pe.moved&&Math.hypot(re.clientX-Pe.x,re.clientY-Pe.y)<6)return;Pe.moved=!0,F({id:Pe.id,dx:re.clientX-Pe.x,dy:re.clientY-Pe.y,originX:Pe.originX,originY:Pe.originY,scale:Pe.scale});const Ee=(re.clientX-Se.left)/Se.width,Be=(re.clientY-Se.top)/Se.height,Ne=$e.panes.find(de=>Ee>=de.rect.x&&Ee<=de.rect.x+de.rect.width&&Be>=de.rect.y&&Be<=de.rect.y+de.rect.height);if(!Ne||Ne.id===Pe.id){Ce.current=null,V(null);return}const oe=(Ee-Ne.rect.x)/Ne.rect.width,He=(Be-Ne.rect.y)/Ne.rect.height,rt=Math.min(oe,1-oe,He,1-He)>.25?"center":oe<1-oe&&oe<=He&&oe<=1-He?"left":1-oe<=He&&1-oe<=1-He?"right":He<1-He?"top":"bottom",mt={id:Ne.id,side:rt};Ce.current=mt,V(mt)},onPointerUp:re=>{ye.current&&(ye.current=null,te()),lt.current?.moved&&Ce.current&&(ke(jC(v.current,lt.current.id,Ce.current.id,Ce.current.side)),te()),lt.current=null,Ce.current=null,V(null),F(null),document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})),re.currentTarget.hasPointerCapture?.(re.pointerId)&&re.currentTarget.releasePointerCapture(re.pointerId)},onLostPointerCapture:()=>{document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})),ye.current=null,lt.current=null,Ce.current=null,V(null),F(null),te()},onKeyDownCapture:re=>{re.key==="Escape"&&(lt.current=null,Ce.current=null,V(null),F(null),document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})))},onPointerCancel:()=>{document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!1}})),ye.current=null,lt.current=null,Ce.current=null,V(null),F(null),te()},children:[W&&s.jsx("div",{"aria-hidden":"true","data-drag-placeholder":"true",className:"pointer-events-none absolute border-2 border-dashed border-primary/30 bg-primary/5",style:i2($e.panes.find(re=>re.id===W.id)?.rect??{x:0,y:0,width:0,height:0})}),Ae.map(re=>{const Pe=$e.panes.find(Ee=>Ee.id===re.id)?.rect,Se=!Pe||!!a&&re.id!==a;return s.jsxs("div",{"data-layout-pane":re.id,"data-pane-active":E===re.id,className:`${E===re.id?"[&_[data-pane-titlebar]]:bg-surface":""} absolute min-h-0 min-w-0 overflow-hidden bg-[var(--chrome-bg)] ${W?.id===re.id?"pointer-events-none z-30 rounded-lg ring-1 ring-primary/60 opacity-90 shadow-xl":""}`,style:{...i2(a===re.id?{x:0,y:0,width:1,height:1}:Pe??{x:0,y:0,width:0,height:0}),padding:Ae.length>1?"0.5px":0,transition:"none",visibility:Se?"hidden":void 0,...W?.id===re.id?{transform:`translate(${W.dx}px, ${W.dy}px) scale(${W.scale})`,transformOrigin:`${W.originX}px ${W.originY}px`}:{}},onDragStart:Ee=>{Ee.target.closest("[data-split-pane-title], [data-panel-drag-title]")&&Ee.preventDefault()},children:[re.content,c&&Ae.length>1&&!PC(re.id)&&s.jsx("button",{type:"button","data-panel-drag-title":"true","aria-label":"拖动面板到其他区域",className:"swiper-no-swiping absolute right-1 top-1 z-20 rounded bg-surface p-1 text-muted-foreground",children:s.jsx(If,{size:14})}),U?.id===re.id&&s.jsx("div",{className:"pointer-events-none absolute z-30 border-2 border-primary bg-primary/20",style:{top:U.side==="bottom"?"50%":0,bottom:U.side==="top"?"50%":0,left:U.side==="right"?"50%":0,right:U.side==="left"?"50%":0}})]},re.id)}),!a&&je.map(re=>s.jsx("button",{type:"button",role:"separator","aria-label":re.side?`调整${{top:"上",bottom:"下",left:"左",right:"右"}[re.side]}半段分隔线`:"调整分屏大小","aria-orientation":re.axis==="x"?"vertical":"horizontal",disabled:!k,className:`swiper-no-swiping absolute z-10 touch-none bg-border hover:bg-primary focus-visible:bg-primary ${re.axis==="x"?"w-px cursor-col-resize":"h-px cursor-row-resize"}`,style:{left:`${re.x*100}%`,top:`${re.y*100}%`,...re.axis==="x"?{height:`${re.length*100}%`}:{width:`${re.length*100}%`}},onPointerDown:Pe=>{Pe.preventDefault(),Pe.stopPropagation(),document.dispatchEvent(new CustomEvent("termdock:gesture-lock",{detail:{locked:!0}})),ye.current=re,x.current?.setPointerCapture?.(Pe.pointerId)},onDoubleClick:()=>{ke(re.side?pp(v.current,re.side,.5):Y0(v.current,re.path,.5)),te()},onKeyDown:Pe=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(Pe.key))return;Pe.preventDefault();const Se=re.side?Y[re.side]:$e.dividers.find(Be=>Be.path===re.path).node.ratio,Ee=Math.max(.05,Math.min(.95,Se+(["ArrowRight","ArrowDown"].includes(Pe.key)?.03:-.03)));ke(re.side?pp(v.current,re.side,Ee):Y0(v.current,re.path,Ee)),te()},children:s.jsx("span",{"aria-hidden":"true",className:`absolute ${re.axis==="x"?"inset-y-0 -inset-x-1":"inset-x-0 -inset-y-1"}`})},re.key)),R&&s.jsx("div",{role:"alert",className:"absolute bottom-1 left-1 z-20 rounded bg-surface px-2 py-1 text-[10px] text-destructive",children:R})]})}let Dm=0,o2=!1,xu=0;function FC(){if(o2||typeof window>"u")return;o2=!0;const e=()=>{Dm=performance.now()};window.addEventListener("pointerdown",()=>{xu+=1,e()},{passive:!0,capture:!0});for(const t of["pointerup","pointercancel"])window.addEventListener(t,()=>{xu=Math.max(0,xu-1),e()},{passive:!0,capture:!0});for(const t of["pointermove","wheel","keydown"])window.addEventListener(t,e,{passive:!0,capture:!0});window.addEventListener("blur",()=>{xu=0,e()})}function E1(e,t=500){FC();let r=!1,n,a;const c=()=>{if(r)return;if(xu>0||performance.now()-Dm<400){a=setTimeout(c,100);return}const l=()=>{if(!r){if(xu>0||performance.now()-Dm<400){a=setTimeout(c,100);return}e()}};"requestIdleCallback"in window?n=window.requestIdleCallback(l):a=setTimeout(l,16)};return a=setTimeout(c,t),()=>{r=!0,clearTimeout(a),n!==void 0&&window.cancelIdleCallback(n)}}function $C(e){const[t,r]=b.useState(e);return b.useEffect(()=>E1(()=>r(e),0),[e]),t}function UC(e,t){if(t||e.defaultPrevented||e.isComposing||e.keyCode===229)return!1;const n=(e.target instanceof Element?e.target:null)?.closest('input, textarea, select, [contenteditable]:not([contenteditable="false"]), [role="textbox"]');return!n||n.matches("textarea[data-terminal-input-anchor], textarea.xterm-helper-textarea")&&!!n.closest(".terminal-viewport-container")}function Bm(e,t){const r=e.replace(/\r?\n/g,"\r");return`\x1B[200~${(t&&r.endsWith("\r")?r.slice(0,-1):r).replace(/\x1b/g,"␛")}\x1B[201~${t?"\r":""}`}function zC(e,t,r){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n+=1;let a=0;const c=e.length-n,l=t.length-n;for(;a<c&&a<l&&e[e.length-1-a]===t[t.length-1-a];)a+=1;const h=t.slice(n,t.length-a);return h&&(r==="insertFromPaste"||r==="insertFromPasteAsQuotation"||/[\r\n]/.test(h))?h:null}const Cd=new Map;function HC(e,t,r){if(!r||!t||!T1(e))return null;const n=`owned-paste-${crypto.randomUUID()}`;return Cd.set(n,{source:e,layer:r3(),sessionId:t,text:r,token:{nonce:n}}),{nonce:n,text:r,sessionId:t,paste:!0,submitAfterPaste:!1,focus:!1,ownedPaste:!0}}function WC(e){Cd.delete(e)}function N1(e){return e.layer===r3()&&T1(e.source)}function GC(e,t){const r=e.nonce?Cd.get(e.nonce):void 0;return r&&N1(r)&&e.ownedPaste===!0&&e.paste===!0&&e.submitAfterPaste===!1&&r.sessionId===t&&e.sessionId===t&&e.text===r.text?r.token:null}function VC(e,t,r){const n=Cd.get(e.nonce);return!n||n.token!==e||n.consumed?!1:(n.consumed=!0,N1(n)&&n.sessionId===t&&r===Bm(n.text,!1))}function qC(e,t){const r=Cd.get(e.nonce);return!!r&&r.token===e&&r.sessionId===t&&N1(r)}function YC(e,t,r){b.useEffect(()=>{e&&j8(e,!0)},[e,r])}const Ci=[];for(let e=0;e<256;++e)Ci.push((e+256).toString(16).slice(1));function ZC(e,t=0){return(Ci[e[t+0]]+Ci[e[t+1]]+Ci[e[t+2]]+Ci[e[t+3]]+"-"+Ci[e[t+4]]+Ci[e[t+5]]+"-"+Ci[e[t+6]]+Ci[e[t+7]]+"-"+Ci[e[t+8]]+Ci[e[t+9]]+"-"+Ci[e[t+10]]+Ci[e[t+11]]+Ci[e[t+12]]+Ci[e[t+13]]+Ci[e[t+14]]+Ci[e[t+15]]).toLowerCase()}let mp;const KC=new Uint8Array(16);function XC(){if(!mp){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");mp=crypto.getRandomValues.bind(crypto)}return mp(KC)}const JC=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),l2={randomUUID:JC};function eS(e,t,r){e=e||{};const n=e.random??e.rng?.()??XC();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,ZC(n)}function j3(e,t,r){return l2.randomUUID&&!e?l2.randomUUID():eS(e)}const D3="\x1B[?2026h",tS="\x1B[?2026l",B3="\x1Bc";function rS(e){return e.replace(/(?:\x1b\]|\x9d)[\s\S]*?(?:\x07|\x1b\\|\x9c|$)|(?:\x1b[P_X^]|[\x90\x98\x9e\x9f])[\s\S]*?(?:\x1b\\|\x9c|$)|(?:\x1b\[|\x9b)\?([\d;]+)([hl])|(?:\x1b\[|\x9b)[\d;]*!p|\x1bc/g,(t,r,n)=>{if(t===B3||t.endsWith("!p"))return t+D3;if(r===void 0)return t;const a=r.split(";").filter(c=>Number(c)!==2026);return a.length?`\x1B[?${a.join(";")}${n}`:""})}function nS(e){const t=e.filter(n=>n.length>0).join("");if(!t)return[];const r=rS(t.replace(/^(?:\x1bc)+/,""));return[`${B3}${D3}${r}${tS}`]}function sS(e){return[`\x1B[!p\x1B[?2026h\x1B[H\x1B[2J\x1B[3J${e.join("")}\x1B[?2026l`]}function iS(e){return[["10",e.foreground],["11",e.background]].map(([t,r])=>{const n=/^#([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i.exec(r);if(!n)return"";const a=n.slice(1).map(c=>c.repeat(2)).join("/");return`\x1B]${t};rgb:${a}\x1B\\`}).join("")}const aS={ArrowUp:"A",ArrowDown:"B",ArrowRight:"C",ArrowLeft:"D",Home:"H",End:"F"},oS={F1:"P",F2:"Q",F3:"R",F4:"S"},lS={Insert:2,Delete:3,PageUp:5,PageDown:6,F5:15,F6:17,F7:18,F8:19,F9:20,F10:21,F11:23,F12:24};function cS(e,t=!1){if(e.metaKey||e.isComposing||e.keyCode===229||e.getModifierState?.("AltGraph"))return null;const{key:r,shiftKey:n,altKey:a,ctrlKey:c}=e,l=1+Number(n)+2*Number(a)+4*Number(c),h=l===1?"":`;${l}`,p=aS[r];if(p)return l!==1?`\x1B[1${h}${p}`:`\x1B${t?"O":"["}${p}`;const m=oS[r];if(m)return l!==1?`\x1B[1${h}${m}`:`\x1BO${m}`;if(r==="Insert"&&!a&&(n||c))return null;const x=lS[r];if(x)return`\x1B[${x}${h}~`;if(r==="Tab")return a?`\x1B${n?"\x1B[Z":" "}`:n?"\x1B[Z":" ";if(r==="Escape")return a?"\x1B\x1B":"\x1B";if(r==="Enter")return a?"\x1B\r":null;if(r==="Backspace")return c||a?`${a?"\x1B":""}${c?"\b":""}`:null;if(r.length!==1)return null;if(c){const y=r.toUpperCase();let w;return/^[A-Z]$/.test(y)?w=y.charCodeAt(0)-64:r===" "||r==="@"||r==="2"?w=0:"[\\]^_".includes(r)?w=r.charCodeAt(0)-64:/^[3-7]$/.test(r)?w=Number(r)+24:r==="?"||r==="8"?w=127:r==="/"&&(w=31),w===void 0?null:`${a?"\x1B":""}${String.fromCharCode(w)}`}return a?`\x1B${r}`:null}class Z0 extends Error{}async function Q3(e){if(!e.type.startsWith("image/")||e.size===0)throw new Error("Clipboard image is empty");const t=e.type==="image/jpeg"?"jpg":e.type.split("/")[1].replace(/[^a-z0-9]/gi,"")||"png",r=new File([e],`termdock-clipboard-${Date.now()}-${crypto.randomUUID()}.${t}`,{type:e.type}),{files:n}=await vd("/tmp",[r]);if(!n[0]?.path)throw new Error("Upload did not return an image path");return n[0].path}async function ef(e){const t=lo();if(t?.readClipboardImage){const r=await t.readClipboardImage();return r?.byteLength?new File([r],"clipboard.png",{type:"image/png"}):null}if(typeof e?.read!="function")return null;for(const r of await e.read()){const n=r.types.find(l=>l.startsWith("image/"));if(!n)continue;const a=await r.getType(n),c=n==="image/jpeg"?"jpg":n.split("/")[1].replace(/[^a-z0-9]/gi,"")||"png";return new File([a],`termdock-clipboard-${Date.now()}.${c}`,{type:n})}return null}async function P3(e){if(typeof e?.read!="function")return[];const t=[],r={"video/mp4":"mp4","video/quicktime":"mov","video/x-m4v":"m4v","video/webm":"webm","video/ogg":"ogv","video/mpeg":"mpeg","video/x-msvideo":"avi","video/x-matroska":"mkv","video/3gpp":"3gp","video/3gpp2":"3g2"};for(const n of await e.read()){const a=n.types.find(p=>p.startsWith("video/"));if(!a)continue;const c=await n.getType(a);if(!c.size)throw new Error("Clipboard video is empty");const l=a.split(";")[0].toLowerCase(),h=r[l]||l.slice(6).replace(/[^a-z0-9]/g,"")||"mp4";t.push(new File([c],`termdock-clipboard-${Date.now()}-${crypto.randomUUID()}.${h}`,{type:a}))}return t}async function O3(){const e=rd()?.targetPeerId;let t;try{t=await lo()?.readClipboardFiles?.({localServiceId:e})}catch(a){const c=a instanceof Error?a.message:String(a),l="TERMDOCK_CLIPBOARD_VIDEO_ERROR:",h=c.indexOf(l);if(h!==-1)throw new Z0(c.slice(h+l.length).trim());const p=c.match(/execution error: Error: (复制来源未提供可读取的视频数据[^\r\n]*|无法读取剪贴板视频)(?:\s*\(-\d+\))?\s*$/);throw p?new Z0(p[1]):a}if(rd()?.targetPeerId!==e)throw new Error("目标服务已切换,请重新粘贴");const r=[],n=[];for(const a of t??[])if(a.path&&e)n.push(a.path);else if(a.bytes){if(a.type?.startsWith("video/")&&a.bytes.byteLength===0)throw new Z0("复制来源未提供可读取的视频数据,请重新复制视频或选择文件上传");r.push(new File([a.bytes],a.name,{type:a.type||"application/octet-stream"}))}else throw new Error("剪贴板未提供可读取的文件");return{files:r,paths:n}}async function F3(e){if(!e.length)return[];const{files:t}=await vd("/tmp",e);if(t.length!==e.length||t.some(r=>!r.path))throw new Error("Upload did not return every file path");return t.map(r=>r.path)}function Zs(e){return{dispose:e}}function uS(e){if(!e)return e;if(Array.isArray(e)){for(let t of e)t.dispose();return[]}return e.dispose(),e}function dS(...e){return Zs(()=>uS(e))}var $3=class{constructor(){this._disposables=new Set,this._isDisposed=!1}get isDisposed(){return this._isDisposed}add(e){return this._isDisposed?e.dispose():this._disposables.add(e),e}dispose(){if(!this._isDisposed){this._isDisposed=!0;for(let e of this._disposables)e.dispose();this._disposables.clear()}}clear(){for(let e of this._disposables)e.dispose();this._disposables.clear()}},Pc=class{constructor(){this._store=new $3}dispose(){this._store.dispose()}_register(t){return this._store.add(t)}};Pc.None=Object.freeze({dispose(){}});var n0=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,this._value?.dispose(),this._value=void 0}},U3=!!(typeof process<"u"&&"title"in process&&(typeof navigator>"u"||navigator.userAgent.startsWith("Node.js/"))),Sd=U3?"node":navigator.userAgent,hS=U3?"node":navigator.platform,fS=Sd.includes("Firefox");Sd.includes("Chrome");var pS=Sd.includes("Edge"),z3=/^((?!chrome|android).)*safari/i.test(Sd);function mS(){if(!z3)return 0;let e=Sd.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1],10)}hS.indexOf("Linux")>=0;var ii=0,ai=0,oi=0,Ss=0,so={css:"#00000000",rgba:0},sa;(e=>{function t(a,c,l,h){return h!==void 0?`#${pc(a)}${pc(c)}${pc(l)}${pc(h)}`:`#${pc(a)}${pc(c)}${pc(l)}`}e.toCss=t;function r(a,c,l,h=255){return(a<<24|c<<16|l<<8|h)>>>0}e.toRgba=r;function n(a,c,l,h){return{css:e.toCss(a,c,l,h),rgba:e.toRgba(a,c,l,h)}}e.toColor=n})(sa||={});var O0;(e=>{function t(p,m){if(Ss=(m.rgba&255)/255,Ss===1)return{css:m.css,rgba:m.rgba};let x=m.rgba>>24&255,y=m.rgba>>16&255,w=m.rgba>>8&255,v=p.rgba>>24&255,k=p.rgba>>16&255,L=p.rgba>>8&255;ii=v+Math.round((x-v)*Ss),ai=k+Math.round((y-k)*Ss),oi=L+Math.round((w-L)*Ss);let E=sa.toCss(ii,ai,oi),R=sa.toRgba(ii,ai,oi);return{css:E,rgba:R}}e.blend=t;function r(p){return(p.rgba&255)===255}e.isOpaque=r;function n(p,m,x){let y=Ec.ensureContrastRatio(p.rgba,m.rgba,x);if(y)return sa.toColor(y>>24&255,y>>16&255,y>>8&255)}e.ensureContrastRatio=n;function a(p){let m=(p.rgba|255)>>>0;return[ii,ai,oi]=Ec.toChannels(m),{css:sa.toCss(ii,ai,oi),rgba:m}}e.opaque=a;function c(p,m){return Ss=Math.round(m*255),[ii,ai,oi]=Ec.toChannels(p.rgba),{css:sa.toCss(ii,ai,oi,Ss),rgba:sa.toRgba(ii,ai,oi,Ss)}}e.opacity=c;function l(p,m){return Ss=p.rgba&255,c(p,Ss*m/255)}e.multiplyOpacity=l;function h(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=h})(O0||={});var gS;(e=>{let t,r;try{let a=document.createElement("canvas");a.width=1,a.height=1;let c=a.getContext("2d",{willReadFrequently:!0});c&&(t=c,t.globalCompositeOperation="copy",r=t.createLinearGradient(0,0,1,1))}catch{}function n(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return ii=parseInt(a.slice(1,2).repeat(2),16),ai=parseInt(a.slice(2,3).repeat(2),16),oi=parseInt(a.slice(3,4).repeat(2),16),sa.toColor(ii,ai,oi);case 5:return ii=parseInt(a.slice(1,2).repeat(2),16),ai=parseInt(a.slice(2,3).repeat(2),16),oi=parseInt(a.slice(3,4).repeat(2),16),Ss=parseInt(a.slice(4,5).repeat(2),16),sa.toColor(ii,ai,oi,Ss);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let c=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(c)return ii=parseInt(c[1],10),ai=parseInt(c[2],10),oi=parseInt(c[3],10),Ss=Math.round((c[5]===void 0?1:parseFloat(c[5]))*255),sa.toColor(ii,ai,oi,Ss);if(a==="transparent")return{css:"transparent",rgba:0};if(!t||!r)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=r,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[ii,ai,oi,Ss]=t.getImageData(0,0,1,1).data,Ss!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:sa.toRgba(ii,ai,oi,Ss),css:a}}e.toColor=n})(gS||={});var Ji;(e=>{function t(n){return r(n>>16&255,n>>8&255,n&255)}e.relativeLuminance=t;function r(n,a,c){let l=n/255,h=a/255,p=c/255,m=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),x=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),y=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return m*.2126+x*.7152+y*.0722}e.relativeLuminance2=r})(Ji||={});var Ec;(e=>{function t(l,h){if(Ss=(h&255)/255,Ss===1)return h;let p=h>>24&255,m=h>>16&255,x=h>>8&255,y=l>>24&255,w=l>>16&255,v=l>>8&255;return ii=y+Math.round((p-y)*Ss),ai=w+Math.round((m-w)*Ss),oi=v+Math.round((x-v)*Ss),sa.toRgba(ii,ai,oi)}e.blend=t;function r(l,h,p){let m=Ji.relativeLuminance(l>>8),x=Ji.relativeLuminance(h>>8);if(xl(m,x)<p){if(x<m){let v=n(l,h,p),k=xl(m,Ji.relativeLuminance(v>>8));if(k<p){let L=a(l,h,p),E=xl(m,Ji.relativeLuminance(L>>8));return k>E?v:L}return v}let y=a(l,h,p),w=xl(m,Ji.relativeLuminance(y>>8));if(w<p){let v=n(l,h,p),k=xl(m,Ji.relativeLuminance(v>>8));return w>k?y:v}return y}}e.ensureContrastRatio=r;function n(l,h,p){let m=l>>24&255,x=l>>16&255,y=l>>8&255,w=h>>24&255,v=h>>16&255,k=h>>8&255,L=xl(Ji.relativeLuminance2(w,v,k),Ji.relativeLuminance2(m,x,y));for(;L<p&&(w>0||v>0||k>0);)w-=Math.max(0,Math.ceil(w*.1)),v-=Math.max(0,Math.ceil(v*.1)),k-=Math.max(0,Math.ceil(k*.1)),L=xl(Ji.relativeLuminance2(w,v,k),Ji.relativeLuminance2(m,x,y));return(w<<24|v<<16|k<<8|255)>>>0}e.reduceLuminance=n;function a(l,h,p){let m=l>>24&255,x=l>>16&255,y=l>>8&255,w=h>>24&255,v=h>>16&255,k=h>>8&255,L=xl(Ji.relativeLuminance2(w,v,k),Ji.relativeLuminance2(m,x,y));for(;L<p&&(w<255||v<255||k<255);)w=Math.min(255,w+Math.ceil((255-w)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),k=Math.min(255,k+Math.ceil((255-k)*.1)),L=xl(Ji.relativeLuminance2(w,v,k),Ji.relativeLuminance2(m,x,y));return(w<<24|v<<16|k<<8|255)>>>0}e.increaseLuminance=a;function c(l){return[l>>24&255,l>>16&255,l>>8&255,l&255]}e.toChannels=c})(Ec||={});function pc(e){let t=e.toString(16);return t.length<2?"0"+t:t}function xl(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}function Os(e){if(!e)throw new Error("value must not be falsy");return e}function R1(e){return 57508<=e&&e<=57558}function xS(e){return 57520<=e&&e<=57527}function bS(e){return 57344<=e&&e<=63743}function yS(e){return 9472<=e&&e<=9631}function vS(e){return e>=128512&&e<=128591||e>=127744&&e<=128511||e>=128640&&e<=128767||e>=9728&&e<=9983||e>=9984&&e<=10175||e>=65024&&e<=65039||e>=129280&&e<=129535||e>=127462&&e<=127487}function wS(e,t,r,n){return t===1&&r>Math.ceil(n*1.5)&&e!==void 0&&e>255&&!vS(e)&&!R1(e)&&!bS(e)}function H3(e){return R1(e)||yS(e)}function AS(){return{css:{canvas:qd(),cell:qd()},device:{canvas:qd(),cell:qd(),char:{width:0,height:0,left:0,top:0}}}}function qd(){return{width:0,height:0}}function TS(e,t,r=0){return(e-(Math.round(t)*2-r))%(Math.round(t)*2)}var Fe;(e=>(e.LINE_H=Object.freeze({type:2,data:"M0,.5 L1,.5",strokeWidth:1}),e.LINE_V=Object.freeze({type:2,data:"M.5,0 L.5,1",strokeWidth:1}),e.FADE_RIGHT=Object.freeze({type:2,data:"M0,.5 L.28,.5 M.32,.5 L.52,.5 M.60,.5 L.72,.5 M.84,.5 L.90,.5",strokeWidth:1}),e.FADE_LEFT=Object.freeze({type:2,data:"M.10,.5 L.16,.5 M.28,.5 L.40,.5 M.48,.5 L.68,.5 M.72,.5 L1,.5",strokeWidth:1}),e.FADE_DOWN=Object.freeze({type:2,data:"M.5,0 L.5,.28 M.5,.32 L.5,.52 M.5,.60 L.5,.72 M.5,.84 L.5,.90",strokeWidth:1}),e.FADE_UP=Object.freeze({type:2,data:"M.5,.10 L.5,.16 M.5,.28 L.5,.40 M.5,.48 L.5,.68 M.5,.72 L.5,1",strokeWidth:1}),e.CURVE_DOWN_RIGHT=Object.freeze({type:2,data:(t,r)=>`M.5,1 L.5,${.5+r/.15*.5} C.5,${.5+r/.15*.5},.5,.5,1,.5`,strokeWidth:1}),e.CURVE_DOWN_LEFT=Object.freeze({type:2,data:(t,r)=>`M.5,1 L.5,${.5+r/.15*.5} C.5,${.5+r/.15*.5},.5,.5,0,.5`,strokeWidth:1}),e.CURVE_UP_RIGHT=Object.freeze({type:2,data:(t,r)=>`M.5,0 L.5,${.5-r/.15*.5} C.5,${.5-r/.15*.5},.5,.5,1,.5`,strokeWidth:1}),e.CURVE_UP_LEFT=Object.freeze({type:2,data:(t,r)=>`M.5,0 L.5,${.5-r/.15*.5} C.5,${.5-r/.15*.5},.5,.5,0,.5`,strokeWidth:1}),e.NODE_FILL=Object.freeze({type:3,data:"M.85,.5 A.35,.175,0,1,1,.15,.5 A.35,.175,0,1,1,.85,.5"}),e.NODE_STROKE=Object.freeze({type:3,data:"M.85,.5 A.35,.175,0,1,1,.15,.5 A.35,.175,0,1,1,.85,.5",strokeWidth:1}),e.NODE_LINE_RIGHT=Object.freeze({type:3,data:"M1,.5 L.85,.5",strokeWidth:1}),e.NODE_LINE_LEFT=Object.freeze({type:3,data:"M0,.5 L.15,.5",strokeWidth:1}),e.NODE_LINE_DOWN=Object.freeze({type:3,data:"M.5,1 L.5,.7",strokeWidth:1}),e.NODE_LINE_UP=Object.freeze({type:3,data:"M.5,0 L.5,.3",strokeWidth:1})))(Fe||={});var CS={"─":{type:2,data:"M0,.5 L1,.5",strokeWidth:1},"━":{type:2,data:"M0,.5 L1,.5",strokeWidth:3},"│":{type:2,data:"M.5,0 L.5,1",strokeWidth:1},"┃":{type:2,data:"M.5,0 L.5,1",strokeWidth:3},"┄":{type:2,data:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5",strokeWidth:1},"┅":{type:2,data:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5",strokeWidth:3},"┆":{type:2,data:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333",strokeWidth:1},"┇":{type:2,data:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333",strokeWidth:3},"┈":{type:2,data:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5",strokeWidth:1},"┉":{type:2,data:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5",strokeWidth:3},"┊":{type:2,data:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95",strokeWidth:1},"┋":{type:2,data:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95",strokeWidth:3},"┌":{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:1},"┍":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"┎":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"┏":{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:3},"┐":{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:1},"┑":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"┒":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"┓":{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:3},"└":{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:1},"┕":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"┖":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"┗":{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:3},"┘":{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:1},"┙":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"┚":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"┛":{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:3},"├":{type:2,data:"M.5,0 L.5,1 M.5,.5 L1,.5",strokeWidth:1},"┝":[{type:2,data:"M.5,0 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"┞":[{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"┟":[{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"┠":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,1",strokeWidth:3}],"┡":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:3}],"┢":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:3}],"┣":{type:2,data:"M.5,0 L.5,1 M.5,.5 L1,.5",strokeWidth:3},"┤":{type:2,data:"M.5,0 L.5,1 M.5,.5 L0,.5",strokeWidth:1},"┥":[{type:2,data:"M.5,0 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"┦":[{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"┧":[{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"┨":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,1",strokeWidth:3}],"┩":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:3}],"┪":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:3}],"┫":{type:2,data:"M.5,0 L.5,1 M.5,.5 L0,.5",strokeWidth:3},"┬":{type:2,data:"M0,.5 L1,.5 M.5,.5 L.5,1",strokeWidth:1},"┭":[{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"┮":[{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"┯":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M0,.5 L1,.5",strokeWidth:3}],"┰":[{type:2,data:"M0,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"┱":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:3}],"┲":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:3}],"┳":{type:2,data:"M0,.5 L1,.5 M.5,.5 L.5,1",strokeWidth:3},"┴":{type:2,data:"M0,.5 L1,.5 M.5,.5 L.5,0",strokeWidth:1},"┵":[{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"┶":[{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"┷":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M0,.5 L1,.5",strokeWidth:3}],"┸":[{type:2,data:"M0,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"┹":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:3}],"┺":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:3}],"┻":{type:2,data:"M0,.5 L1,.5 M.5,.5 L.5,0",strokeWidth:3},"┼":{type:2,data:"M0,.5 L1,.5 M.5,0 L.5,1",strokeWidth:1},"┽":[{type:2,data:"M.5,0 L.5,1 M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"┾":[{type:2,data:"M.5,0 L.5,1 M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"┿":[{type:2,data:"M.5,0 L.5,1",strokeWidth:1},{type:2,data:"M0,.5 L1,.5",strokeWidth:3}],"╀":[{type:2,data:"M0,.5 L1,.5 M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"╁":[{type:2,data:"M.5,.5 L.5,0 M0,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"╂":[{type:2,data:"M0,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,1",strokeWidth:3}],"╃":[{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:3}],"╄":[{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:3}],"╅":[{type:2,data:"M.5,0 L.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M0,.5 L.5,.5 L.5,1",strokeWidth:3}],"╆":[{type:2,data:"M.5,0 L.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M0.5,1 L.5,.5 L1,.5",strokeWidth:3}],"╇":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0 M0,.5 L1,.5",strokeWidth:3}],"╈":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M0,.5 L1,.5 M.5,.5 L.5,1",strokeWidth:3}],"╉":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,1 M.5,.5 L0,.5",strokeWidth:3}],"╊":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,0 L.5,1 M.5,.5 L1,.5",strokeWidth:3}],"╋":{type:2,data:"M0,.5 L1,.5 M.5,0 L.5,1",strokeWidth:3},"╌":{type:2,data:"M.1,.5 L.4,.5 M.6,.5 L.9,.5",strokeWidth:1},"╍":{type:2,data:"M.1,.5 L.4,.5 M.6,.5 L.9,.5",strokeWidth:3},"╎":{type:2,data:"M.5,.1 L.5,.4 M.5,.6 L.5,.9",strokeWidth:1},"╏":{type:2,data:"M.5,.1 L.5,.4 M.5,.6 L.5,.9",strokeWidth:3},"═":{type:2,data:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`,strokeWidth:1},"║":{type:2,data:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`,strokeWidth:1},"╒":{type:2,data:(e,t)=>`M.5,1 L.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`,strokeWidth:1},"╓":{type:2,data:(e,t)=>`M${.5-e},1 L${.5-e},.5 L1,.5 M${.5+e},.5 L${.5+e},1`,strokeWidth:1},"╔":{type:2,data:(e,t)=>`M1,${.5-t} L${.5-e},${.5-t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`,strokeWidth:1},"╕":{type:2,data:(e,t)=>`M0,${.5-t} L.5,${.5-t} L.5,1 M0,${.5+t} L.5,${.5+t}`,strokeWidth:1},"╖":{type:2,data:(e,t)=>`M${.5+e},1 L${.5+e},.5 L0,.5 M${.5-e},.5 L${.5-e},1`,strokeWidth:1},"╗":{type:2,data:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5+e},${.5-t} L${.5+e},1`,strokeWidth:1},"╘":{type:2,data:(e,t)=>`M.5,0 L.5,${.5+t} L1,${.5+t} M.5,${.5-t} L1,${.5-t}`,strokeWidth:1},"╙":{type:2,data:(e,t)=>`M1,.5 L${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`,strokeWidth:1},"╚":{type:2,data:(e,t)=>`M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0 M1,${.5+t} L${.5-e},${.5+t} L${.5-e},0`,strokeWidth:1},"╛":{type:2,data:(e,t)=>`M0,${.5+t} L.5,${.5+t} L.5,0 M0,${.5-t} L.5,${.5-t}`,strokeWidth:1},"╜":{type:2,data:(e,t)=>`M0,.5 L${.5+e},.5 L${.5+e},0 M${.5-e},.5 L${.5-e},0`,strokeWidth:1},"╝":{type:2,data:(e,t)=>`M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M0,${.5+t} L${.5+e},${.5+t} L${.5+e},0`,strokeWidth:1},"╞":{type:2,data:(e,t)=>`M.5,0 L.5,1 M.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`,strokeWidth:1},"╟":{type:2,data:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1 M${.5+e},.5 L1,.5`,strokeWidth:1},"╠":{type:2,data:(e,t)=>`M${.5-e},0 L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`,strokeWidth:1},"╡":{type:2,data:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L.5,${.5-t} M0,${.5+t} L.5,${.5+t}`,strokeWidth:1},"╢":{type:2,data:(e,t)=>`M0,.5 L${.5-e},.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`,strokeWidth:1},"╣":{type:2,data:(e,t)=>`M${.5+e},0 L${.5+e},1 M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0`,strokeWidth:1},"╤":{type:2,data:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t} M.5,${.5+t} L.5,1`,strokeWidth:1},"╥":{type:2,data:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},1 M${.5+e},.5 L${.5+e},1`,strokeWidth:1},"╦":{type:2,data:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`,strokeWidth:1},"╧":{type:2,data:(e,t)=>`M.5,0 L.5,${.5-t} M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`,strokeWidth:1},"╨":{type:2,data:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`,strokeWidth:1},"╩":{type:2,data:(e,t)=>`M0,${.5+t} L1,${.5+t} M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`,strokeWidth:1},"╪":{type:2,data:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`,strokeWidth:1},"╫":{type:2,data:(e,t)=>`M0,.5 L1,.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`,strokeWidth:1},"╬":{type:2,data:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`,strokeWidth:1},"╭":{type:2,data:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,1,.5`,strokeWidth:1},"╮":{type:2,data:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,0,.5`,strokeWidth:1},"╯":{type:2,data:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,0,.5`,strokeWidth:1},"╰":{type:2,data:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,1,.5`,strokeWidth:1},"╱":{type:2,data:"M1,0 L0,1",strokeWidth:1},"╲":{type:2,data:"M0,0 L1,1",strokeWidth:1},"╳":{type:2,data:"M1,0 L0,1 M0,0 L1,1",strokeWidth:1},"╴":{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},"╵":{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},"╶":{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},"╷":{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},"╸":{type:2,data:"M.5,.5 L0,.5",strokeWidth:3},"╹":{type:2,data:"M.5,.5 L.5,0",strokeWidth:3},"╺":{type:2,data:"M.5,.5 L1,.5",strokeWidth:3},"╻":{type:2,data:"M.5,.5 L.5,1",strokeWidth:3},"╼":[{type:2,data:"M.5,.5 L0,.5",strokeWidth:1},{type:2,data:"M.5,.5 L1,.5",strokeWidth:3}],"╽":[{type:2,data:"M.5,.5 L.5,0",strokeWidth:1},{type:2,data:"M.5,.5 L.5,1",strokeWidth:3}],"╾":[{type:2,data:"M.5,.5 L1,.5",strokeWidth:1},{type:2,data:"M.5,.5 L0,.5",strokeWidth:3}],"╿":[{type:2,data:"M.5,.5 L.5,1",strokeWidth:1},{type:2,data:"M.5,.5 L.5,0",strokeWidth:3}],"▀":{type:0,data:[{x:0,y:0,w:8,h:4}]},"▁":{type:0,data:[{x:0,y:7,w:8,h:1}]},"▂":{type:0,data:[{x:0,y:6,w:8,h:2}]},"▃":{type:0,data:[{x:0,y:5,w:8,h:3}]},"▄":{type:0,data:[{x:0,y:4,w:8,h:4}]},"▅":{type:0,data:[{x:0,y:3,w:8,h:5}]},"▆":{type:0,data:[{x:0,y:2,w:8,h:6}]},"▇":{type:0,data:[{x:0,y:1,w:8,h:7}]},"█":{type:0,data:[{x:0,y:0,w:8,h:8}]},"▉":{type:0,data:[{x:0,y:0,w:7,h:8}]},"▊":{type:0,data:[{x:0,y:0,w:6,h:8}]},"▋":{type:0,data:[{x:0,y:0,w:5,h:8}]},"▌":{type:0,data:[{x:0,y:0,w:4,h:8}]},"▍":{type:0,data:[{x:0,y:0,w:3,h:8}]},"▎":{type:0,data:[{x:0,y:0,w:2,h:8}]},"▏":{type:0,data:[{x:0,y:0,w:1,h:8}]},"▐":{type:0,data:[{x:4,y:0,w:4,h:8}]},"░":{type:1,data:[[1,0],[0,0]]},"▒":{type:1,data:[[1,0],[0,1]]},"▓":{type:1,data:[[1,1],[1,0]]},"▔":{type:0,data:[{x:0,y:0,w:8,h:1}]},"▕":{type:0,data:[{x:7,y:0,w:1,h:8}]},"▖":{type:0,data:[{x:0,y:4,w:4,h:4}]},"▗":{type:0,data:[{x:4,y:4,w:4,h:4}]},"▘":{type:0,data:[{x:0,y:0,w:4,h:4}]},"▙":{type:0,data:[{x:0,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}]},"▚":{type:0,data:[{x:0,y:0,w:4,h:4},{x:4,y:4,w:4,h:4}]},"▛":{type:0,data:[{x:0,y:0,w:4,h:8},{x:4,y:0,w:4,h:4}]},"▜":{type:0,data:[{x:0,y:0,w:8,h:4},{x:4,y:0,w:4,h:8}]},"▝":{type:0,data:[{x:4,y:0,w:4,h:4}]},"▞":{type:0,data:[{x:4,y:0,w:4,h:4},{x:0,y:4,w:4,h:4}]},"▟":{type:0,data:[{x:4,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}]},"":{type:5,data:{d:"M.3,1 L.03,1 L.03,.88 C.03,.82,.06,.78,.11,.73 C.15,.7,.2,.68,.28,.65 L.43,.6 C.49,.58,.53,.56,.56,.53 C.59,.5,.6,.47,.6,.43 L.6,.27 L.4,.27 L.69,.1 L.98,.27 L.78,.27 L.78,.46 C.78,.52,.76,.56,.72,.61 C.68,.66,.63,.67,.56,.7 L.48,.72 C.42,.74,.38,.76,.35,.78 C.32,.8,.31,.84,.31,.88 L.31,1 M.3,.5 L.03,.59 L.03,.09 L.3,.09 L.3,.655",type:0}},"":{type:5,data:{d:"M.7,.4 L.7,.47 L.2,.47 L.2,.03 L.355,.03 L.355,.4 L.705,.4 M.7,.5 L.86,.5 L.86,.95 L.69,.95 L.44,.66 L.46,.86 L.46,.95 L.3,.95 L.3,.49 L.46,.49 L.71,.78 L.69,.565 L.69,.5",type:0}},"":{type:5,data:{d:"M.25,.94 C.16,.94,.11,.92,.11,.87 L.11,.53 C.11,.48,.15,.455,.23,.45 L.23,.3 C.23,.25,.26,.22,.31,.19 C.36,.16,.43,.15,.51,.15 C.59,.15,.66,.16,.71,.19 C.77,.22,.79,.26,.79,.3 L.79,.45 C.87,.45,.91,.48,.91,.53 L.91,.87 C.91,.92,.86,.94,.77,.94 L.24,.94 M.53,.2 C.49,.2,.45,.21,.42,.23 C.39,.25,.38,.27,.38,.3 L.38,.45 L.68,.45 L.68,.3 C.68,.27,.67,.25,.64,.23 C.61,.21,.58,.2,.53,.2 M.58,.82 L.58,.66 C.63,.65,.65,.63,.65,.6 C.65,.58,.64,.57,.61,.56 C.58,.55,.56,.54,.52,.54 C.48,.54,.46,.55,.43,.56 C.4,.57,.39,.59,.39,.6 C.39,.63,.41,.64,.46,.66 L.46,.82 L.57,.82",type:0}},"":{type:5,data:{d:"M.7,.4 L.7,.47 L.2,.47 L.2,.03 L.7,.03 L.7,.1 L.355,.1 L.355,.4 L.705,.4 M.7,.5 L.86,.5 L.86,.95 L.69,.95 L.44,.66 L.46,.86 L.46,.95 L.3,.95 L.3,.49 L.46,.49 L.71,.78 L.69,.565 L.69,.5",type:0}},"":{type:5,data:{d:"M0,0 L1,.5 L0,1",type:0,rightPadding:2}},"":{type:5,data:{d:"M-1,-.5 L1,.5 L-1,1.5",type:1,leftPadding:1,rightPadding:1}},"":{type:5,data:{d:"M1,0 L0,.5 L1,1",type:0,leftPadding:2}},"":{type:5,data:{d:"M2,-.5 L0,.5 L2,1.5",type:1,leftPadding:1,rightPadding:1}},"":{type:5,data:{d:"M0,0 L0,1 C0.552,1,1,0.776,1,.5 C1,0.224,0.552,0,0,0",type:0,rightPadding:1}},"":{type:5,data:{d:"M.2,1 C.422,1,.8,.826,.78,.5 C.8,.174,0.422,0,.2,0",type:1,rightPadding:1}},"":{type:5,data:{d:"M1,0 L1,1 C0.448,1,0,0.776,0,.5 C0,0.224,0.448,0,1,0",type:0,leftPadding:1}},"":{type:5,data:{d:"M.8,1 C0.578,1,0.2,.826,.22,.5 C0.2,0.174,0.578,0,0.8,0",type:1,leftPadding:1}},"":{type:5,data:{d:"M-.5,-.5 L1.5,1.5 L-.5,1.5",type:0}},"":{type:5,data:{d:"M-.5,-.5 L1.5,1.5",type:1,leftPadding:1,rightPadding:1}},"":{type:5,data:{d:"M1.5,-.5 L-.5,1.5 L1.5,1.5",type:0}},"":{type:5,data:{d:"M1.5,-.5 L-.5,1.5",type:1,leftPadding:1,rightPadding:1}},"":{type:5,data:{d:"M1.5,-.5 L-.5,1.5 L-.5,-.5",type:0}},"":{type:5,data:{d:"M1.5,-.5 L-.5,1.5",type:1,leftPadding:1,rightPadding:1}},"":{type:5,data:{d:"M-.5,-.5 L1.5,1.5 L1.5,-.5",type:0}},"":{type:5,data:{d:"M-.5,-.5 L1.5,1.5",type:1,leftPadding:1,rightPadding:1}},"":{type:5,data:{d:"M0.8069,0.6075 Q0.7991,0.612,0.7815,0.6218 T0.7542,0.6369 T0.7282,0.6508 T0.7016,0.6644 T0.6778,0.6758 T0.6551,0.6854 T0.637,0.6911 T0.622,0.6936 Q0.6186,0.6936,0.6128,0.6942 T0.6018,0.6952 T0.5894,0.6956 T0.5757,0.6952 T0.561,0.693 T0.5451,0.6879 Q0.5342,0.6834,0.5193,0.6756 T0.4925,0.6614 T0.4673,0.6485 T0.4436,0.6389 T0.4239,0.6363 T0.4089,0.6422 Q0.4045,0.6467,0.3958,0.6554 T0.3843,0.6669 T0.3748,0.6746 T0.3613,0.683 T0.3442,0.6903 L0.3499,0.6956 Q0.3584,0.7042,0.3679,0.7177 T0.3836,0.7403 T0.4019,0.7583 T0.4295,0.7703 Q0.4688,0.7785,0.5203,0.7605 Q0.4902,0.7817,0.449,0.7911 T0.3696,0.8001 Q0.3567,0.7997,0.341,0.7942 T0.3111,0.7813 T0.2805,0.766 T0.2493,0.753 T0.218,0.7472 T0.187,0.754 Q0.1762,0.7589,0.1653,0.7681 T0.1453,0.7895 T0.1308,0.818 T0.1264,0.8507 L0.1264,0.858 Q0.1453,0.8462,0.1607,0.8433 T0.1899,0.8452 T0.2226,0.8625 Q0.2344,0.8707,0.2485,0.8752 T0.2813,0.8831 T0.3089,0.889 Q0.2981,0.8915,0.2846,0.8956 T0.2603,0.9037 T0.2368,0.9115 T0.2129,0.9174 T0.1894,0.9194 T0.1653,0.9155 Q0.1504,0.9115,0.1328,0.9196 T0.0986,0.9421 T0.0655,0.9708 T0.0317,0.9943 T0,1 Q0.001,0.94,0.0017,0.6508 T0.0024,0.2322 Q0.002,0.2109,0.0007,0.1379 T0,0.0249 Q0.0058,0.0253,0.009,0.0257 T0.0156,0.0288 T0.0203,0.0333 T0.0264,0.0422 T0.0349,0.0539 Q0.044,0.0657,0.0542,0.072 T0.0752,0.0789 T0.096,0.0775 T0.1175,0.0694 T0.1379,0.0573 T0.1579,0.0432 Q0.2141,0,0.2673,0.0318 Q0.2588,0.0318,0.2517,0.033 T0.239,0.0361 T0.2276,0.0424 T0.218,0.0504 T0.2085,0.0612 T0.1997,0.0732 T0.1899,0.0875 T0.1795,0.1028 Q0.1748,0.1093,0.1507,0.1234 T0.1186,0.1448 Q0.0999,0.1612,0.1108,0.1783 Q0.1162,0.1877,0.1238,0.1928 T0.1404,0.1979 T0.158,0.1967 T0.1775,0.1895 T0.1963,0.1791 T0.2151,0.1663 T0.2314,0.1534 T0.2458,0.141 T0.2561,0.1322 Q0.2815,0.1106,0.3017,0.101 T0.344,0.0926 T0.3919,0.1077 Q0.4099,0.1175,0.4265,0.1206 T0.4588,0.1202 T0.488,0.1098 T0.5176,0.0914 Q0.5071,0.1032,0.4963,0.1122 T0.4722,0.1285 T0.4497,0.1401 T0.4223,0.1518 T0.3943,0.1636 Q0.374,0.1726,0.3623,0.1863 T0.3482,0.2162 Q0.3445,0.2403,0.3608,0.2605 T0.4072,0.2876 Q0.4194,0.2909,0.4326,0.2899 T0.457,0.2856 T0.4805,0.2764 T0.5032,0.264 T0.5256,0.2497 T0.5478,0.2352 T0.5698,0.2222 T0.5921,0.2118 Q0.6982,0.173,0.81,0.2436 Q0.833,0.2583,0.8496,0.2674 T0.887,0.2846 T0.925,0.294 T0.9617,0.2911 T1,0.2746 Q0.9817,0.2946,0.96,0.3056 T0.9175,0.3191 T0.8731,0.3209 T0.8277,0.3164 T0.7818,0.3109 T0.7359,0.3101 T0.6907,0.3197 T0.647,0.3448 Q0.6443,0.3472,0.6333,0.3562 T0.6194,0.3674 T0.6076,0.3766 T0.594,0.386 T0.5815,0.3931 T0.5661,0.4007 T0.5501,0.4064 L0.5556,0.4121 Q0.5627,0.4198,0.5722,0.4251 T0.5926,0.4337 T0.6131,0.439 T0.6343,0.4431 T0.6521,0.4468 Q0.6762,0.4529,0.7056,0.4463 Q0.6772,0.4623,0.6543,0.471 T0.604,0.4814 Q0.5962,0.4818,0.5815,0.4825 T0.5591,0.4835 T0.5393,0.4857 T0.519,0.4908 T0.5007,0.4996 T0.4812,0.5141 T0.4627,0.5353 L0.4549,0.5451 L0.4661,0.543 Q0.4759,0.541,0.4909,0.55 T0.5315,0.5796 T0.5684,0.6083 Q0.5799,0.6161,0.5915,0.6212 T0.6181,0.6308 L0.6331,0.6353 Q0.6514,0.6418,0.7004,0.633 T0.8069,0.6075 Z",type:0}},"":{type:5,data:{d:"M0.011,0.0469 Q0.0152,0.0412,0.02,0.0361 T0.0292,0.0281 T0.0365,0.0253 Q0.0426,0.0257,0.0461,0.0263 T0.0534,0.03 T0.0582,0.0345 T0.0645,0.0434 T0.0723,0.0546 Q0.0807,0.0653,0.0897,0.0712 T0.1081,0.0775 T0.1255,0.0765 T0.1438,0.0695 T0.1605,0.0593 T0.1772,0.0473 Q0.2388,0,0.2927,0.0326 L0.2614,0.0767 L0.2581,0.0767 Q0.2494,0.0767,0.2444,0.0773 T0.2359,0.0789 T0.2291,0.0842 T0.2233,0.0922 T0.2146,0.1054 T0.2026,0.1236 Q0.1943,0.1354,0.1843,0.1444 T0.1675,0.1574 T0.1526,0.1654 T0.1429,0.1701 Q0.1436,0.1717,0.1446,0.1733 Q0.1504,0.1823,0.1581,0.1866 T0.1733,0.1915 T0.1909,0.1884 T0.2085,0.1809 T0.2265,0.169 T0.2427,0.1564 T0.2575,0.1436 T0.2688,0.1338 Q0.2969,0.1101,0.3195,0.0995 T0.3643,0.0901 T0.4114,0.1048 Q0.4279,0.1138,0.4426,0.1168 T0.4705,0.117 T0.4945,0.1089 T0.5186,0.0942 L0.5211,0.0926 L0.5289,0.0922 Q0.5411,0.095,0.5189,0.1203 Q0.505,0.1358,0.4913,0.1474 T0.4634,0.167 T0.4389,0.1796 T0.4121,0.1909 T0.3866,0.2011 Q0.3782,0.2047,0.3727,0.2092 Q0.3717,0.2117,0.3714,0.2141 Q0.3695,0.2263,0.3751,0.2388 T0.394,0.2616 T0.4253,0.2761 Q0.4398,0.2785,0.4513,0.2779 T0.4756,0.2724 T0.4987,0.2616 T0.5216,0.2476 T0.5453,0.2321 T0.5703,0.217 T0.5976,0.2043 Q0.7015,0.166,0.8099,0.2345 Q0.8361,0.2512,0.8572,0.2616 T0.9006,0.2779 T0.9432,0.281 T0.9819,0.2663 L0.9887,0.2671 Q1,0.272,0.9768,0.2969 Q0.9558,0.3193,0.9319,0.333 T0.8858,0.3513 T0.8391,0.3569 T0.793,0.3546 T0.7485,0.3497 T0.7065,0.3473 T0.6681,0.3522 T0.6344,0.3699 Q0.5963,0.4005,0.5847,0.4082 Q0.595,0.4139,0.6079,0.4174 T0.6367,0.4237 T0.6586,0.4278 Q0.6793,0.4331,0.7044,0.4278 Q0.7057,0.4278,0.707,0.4274 Q0.7067,0.429,0.7062,0.4313 T0.7036,0.4398 T0.6993,0.4513 T0.6931,0.4619 T0.6851,0.4698 Q0.6573,0.4857,0.6336,0.4947 T0.5831,0.5053 Q0.577,0.5057,0.5615,0.5065 T0.5394,0.508 T0.5221,0.51 T0.5042,0.5139 T0.4905,0.5204 Q0.5008,0.5232,0.515,0.5328 T0.549,0.5585 T0.5799,0.5824 Q0.5905,0.5897,0.6013,0.5946 T0.6262,0.6036 T0.6409,0.6081 Q0.6567,0.6134,0.7035,0.605 T0.8028,0.5816 L0.7974,0.5922 T0.7867,0.6134 L0.7812,0.624 Q0.7799,0.6248,0.7786,0.6252 Q0.7709,0.6297,0.7573,0.6372 T0.7346,0.6499 T0.7123,0.6621 T0.6897,0.6741 T0.6686,0.6847 T0.648,0.6941 T0.6297,0.7013 T0.6129,0.7062 T0.5995,0.7076 Q0.5992,0.7076,0.5831,0.7092 T0.5529,0.7092 T0.525,0.7019 Q0.5105,0.6958,0.4824,0.6811 T0.4356,0.6586 T0.4079,0.6533 Q0.3872,0.6741,0.3827,0.6782 Q0.3872,0.6835,0.3934,0.6929 T0.4037,0.7078 T0.4142,0.7198 T0.4284,0.7304 T0.4466,0.7365 Q0.4824,0.7443,0.5292,0.728 L0.5292,0.7294 T0.529,0.7333 T0.5284,0.7392 T0.5266,0.7463 T0.5236,0.7539 T0.5186,0.7612 T0.5111,0.7679 Q0.5086,0.77,0.5056,0.7716 Q0.4466,0.8104,0.3591,0.8091 Q0.344,0.8091,0.3246,0.802 T0.2893,0.7863 T0.2543,0.77 T0.2206,0.76 T0.1894,0.7643 Q0.1804,0.7684,0.1733,0.7753 Q0.1591,0.7892,0.1601,0.8169 Q0.1784,0.8067,0.1938,0.8053 T0.2212,0.8087 T0.2507,0.825 Q0.2614,0.8324,0.2744,0.8365 T0.3053,0.844 T0.332,0.8499 L0.303,0.894 L0.2998,0.8948 Q0.2904,0.8968,0.278,0.9009 T0.2554,0.9086 T0.233,0.9158 T0.2099,0.9213 T0.1868,0.9229 T0.1633,0.9192 Q0.1517,0.916,0.1367,0.9241 T0.1065,0.9462 T0.0753,0.9737 T0.041,0.9955 T0.0061,1 Q0,0.9984,0.0068,0.9845 Q0.009,0.9804,0.0123,0.9755 Q0.0187,0.9666,0.0261,0.9606 T0.0374,0.9555 Q0.0481,0.958,0.0629,0.949 T0.0931,0.9262 T0.1247,0.8987 T0.1597,0.8777 T0.1949,0.8752 Q0.213,0.8805,0.2343,0.8772 Q0.2249,0.8736,0.2172,0.8683 Q0.1914,0.8511,0.1738,0.8497 T0.1349,0.8617 Q0.1304,0.865,0.1273,0.8646 T0.1242,0.8605 L0.1239,0.8536 Q0.1226,0.8295,0.1354,0.8016 T0.1723,0.7496 Q0.1914,0.7308,0.2104,0.7219 Q0.2259,0.7145,0.2425,0.7141 T0.273,0.7182 T0.3022,0.7296 T0.3301,0.7439 T0.3569,0.7571 T0.3821,0.7643 Q0.373,0.7561,0.3598,0.7367 T0.3382,0.7088 L0.3327,0.7035 Q0.3282,0.699,0.3353,0.6884 T0.3517,0.6692 L0.3611,0.6607 Q0.3711,0.657,0.3751,0.6554 T0.3837,0.6507 T0.3898,0.6458 T0.3979,0.637 T0.4111,0.6236 Q0.4172,0.6175,0.4234,0.6138 Q0.4327,0.6081,0.4439,0.6077 T0.4655,0.6105 T0.4884,0.6201 T0.5113,0.633 T0.5347,0.6468 T0.5573,0.6578 Q0.5705,0.6635,0.5833,0.665 T0.6112,0.665 T0.6286,0.6635 Q0.6421,0.6631,0.6718,0.6501 Q0.626,0.6578,0.6089,0.6517 Q0.6063,0.6509,0.6002,0.6491 T0.5884,0.6454 T0.5757,0.6409 T0.561,0.6344 T0.5466,0.6256 Q0.536,0.6183,0.5108,0.5989 T0.4722,0.5712 T0.4527,0.564 L0.4418,0.5661 Q0.4308,0.5681,0.4366,0.5563 Q0.4401,0.5485,0.4476,0.5392 L0.455,0.5298 Q0.4631,0.5188,0.4714,0.51 T0.4866,0.4947 T0.5021,0.4831 T0.516,0.4749 T0.53,0.4694 T0.5428,0.4657 T0.5558,0.4637 T0.5674,0.4629 T0.5795,0.4625 Q0.5489,0.4543,0.534,0.4384 L0.5286,0.4327 Q0.5244,0.4282,0.5318,0.4174 T0.5486,0.398 L0.5579,0.3899 Q0.567,0.387,0.5749,0.3834 T0.5878,0.3772 T0.6012,0.3687 T0.6126,0.3603 T0.6268,0.3487 T0.6421,0.3361 Q0.6567,0.3242,0.6712,0.3159 T0.7009,0.3034 T0.7277,0.2973 T0.7556,0.2961 T0.7809,0.2977 T0.8074,0.301 Q0.8096,0.3014,0.8109,0.3016 T0.8143,0.302 T0.818,0.3026 Q0.8012,0.2936,0.7767,0.2781 Q0.6718,0.2117,0.5744,0.2476 Q0.5637,0.2516,0.5492,0.2604 T0.5218,0.2779 T0.4923,0.2965 T0.461,0.3124 T0.4282,0.3216 T0.394,0.3206 Q0.3637,0.3136,0.3474,0.2936 T0.3353,0.2459 Q0.3385,0.2247,0.355,0.2023 Q0.3646,0.1892,0.3763,0.179 Q0.3898,0.1672,0.4063,0.1595 Q0.3927,0.1562,0.3785,0.1485 Q0.3604,0.1387,0.3453,0.1354 T0.3161,0.1354 T0.2899,0.1458 T0.2627,0.166 Q0.262,0.1664,0.254,0.1733 T0.2414,0.1841 T0.2267,0.196 T0.2094,0.2086 T0.1915,0.2196 T0.1725,0.2288 T0.1546,0.2337 T0.1373,0.2343 T0.1223,0.228 T0.1097,0.2145 Q0.0962,0.1929,0.1258,0.1582 Q0.131,0.1517,0.1371,0.1464 Q0.1462,0.1387,0.156,0.1321 T0.1752,0.1205 T0.1878,0.1134 Q0.1891,0.1117,0.1947,0.103 T0.2035,0.0899 T0.2125,0.0781 T0.2243,0.064 Q0.1949,0.0616,0.1672,0.0828 Q0.153,0.0934,0.1412,0.1009 T0.1146,0.1146 T0.0873,0.1213 T0.0616,0.116 T0.0374,0.0962 Q0.0339,0.0909,0.0295,0.0846 T0.024,0.0767 T0.0202,0.0728 T0.0148,0.0704 T0.0068,0.0697 Q0.0003,0.0693,0.0058,0.0567 Q0.0077,0.0522,0.011,0.0469 Z",type:0}},"":{type:5,data:{d:"M0.1934,0.6075 Q0.2012,0.612,0.2188,0.6218 T0.2459,0.6369 T0.2718,0.6508 T0.2983,0.6644 T0.322,0.6758 T0.3447,0.6854 T0.363,0.6911 T0.3783,0.6936 Q0.3796,0.6936,0.396,0.6952 T0.4265,0.6952 T0.4548,0.6879 Q0.4656,0.6834,0.4805,0.6756 T0.5073,0.6614 T0.5327,0.6485 T0.5564,0.6389 T0.5759,0.6363 T0.5909,0.6422 Q0.5953,0.6467,0.604,0.6554 T0.6155,0.6669 T0.6251,0.6746 T0.6387,0.683 T0.6556,0.6903 L0.6498,0.6956 Q0.6414,0.7042,0.6319,0.7177 T0.6162,0.7403 T0.5979,0.7583 T0.5703,0.7703 Q0.5313,0.7785,0.4799,0.7605 Q0.5097,0.7817,0.5508,0.7911 T0.6302,0.8001 Q0.6431,0.7997,0.659,0.7942 T0.6888,0.7813 T0.7194,0.766 T0.7506,0.753 T0.7819,0.7472 T0.8131,0.754 Q0.8239,0.7589,0.8346,0.7681 T0.8544,0.7895 T0.8689,0.818 T0.8737,0.8507 L0.8733,0.858 Q0.8591,0.849,0.8474,0.845 T0.8242,0.8421 T0.8021,0.8482 T0.7772,0.8625 Q0.7653,0.8707,0.7513,0.8752 T0.7184,0.8831 T0.6908,0.889 Q0.7017,0.8915,0.7152,0.8956 T0.7396,0.9037 T0.7633,0.9115 T0.7872,0.9174 T0.8107,0.9194 T0.8347,0.9155 Q0.8493,0.9115,0.8671,0.9196 T0.9015,0.9421 T0.9345,0.9708 T0.9682,0.9943 T0.9997,1 Q0.999,0.94,0.9983,0.6508 T0.9976,0.2322 Q0.9976,0.2109,0.9992,0.1379 T1,0.0249 Q0.9949,0.0249,0.9917,0.0257 T0.9863,0.0273 T0.9817,0.0308 T0.9776,0.0357 T0.9721,0.0437 T0.9651,0.0539 Q0.956,0.0657,0.9456,0.072 T0.9247,0.0789 T0.904,0.0775 T0.8823,0.0694 T0.862,0.0573 T0.8422,0.0432 Q0.7856,0,0.7328,0.0318 Q0.7392,0.0318,0.7452,0.0324 T0.756,0.0345 T0.7657,0.0386 T0.7741,0.0437 T0.7821,0.0506 T0.7894,0.0588 T0.7966,0.0683 T0.8039,0.0787 T0.8119,0.0904 T0.8202,0.1028 Q0.8249,0.1093,0.849,0.1234 T0.8811,0.1448 Q0.8998,0.1612,0.8893,0.1783 Q0.8835,0.1877,0.8759,0.1928 T0.8593,0.1979 T0.8417,0.1967 T0.8222,0.1895 T0.8034,0.1791 T0.7848,0.1663 T0.7687,0.1534 T0.7543,0.141 T0.744,0.1322 Q0.7186,0.1106,0.6984,0.101 T0.6559,0.0926 T0.6082,0.1077 Q0.5899,0.1175,0.5733,0.1206 T0.5411,0.1202 T0.5122,0.1098 T0.4822,0.0914 Q0.4927,0.1032,0.5036,0.1122 T0.5276,0.1285 T0.5503,0.1401 T0.5777,0.1518 T0.6055,0.1636 Q0.6258,0.1726,0.6375,0.1863 T0.6519,0.2162 Q0.6556,0.2403,0.6392,0.2605 T0.5926,0.2876 Q0.5804,0.2909,0.5672,0.2899 T0.5428,0.2856 T0.5193,0.2764 T0.4966,0.264 T0.4744,0.2497 T0.4523,0.2352 T0.4301,0.2222 T0.4077,0.2118 Q0.3021,0.173,0.1903,0.2436 Q0.1669,0.2583,0.1504,0.2674 T0.1129,0.2846 T0.075,0.294 T0.0384,0.2911 T0,0.2746 Q0.021,0.297,0.0459,0.3082 T0.0953,0.3207 T0.146,0.3193 T0.1988,0.3131 T0.2508,0.3095 T0.3029,0.3176 T0.3529,0.3448 Q0.3566,0.348,0.3652,0.355 T0.3771,0.3645 T0.3877,0.3731 T0.3993,0.3815 T0.4103,0.3884 T0.4226,0.3953 T0.4352,0.4009 T0.4497,0.4064 L0.4443,0.4121 Q0.4372,0.4198,0.4277,0.4251 T0.4072,0.4337 T0.3867,0.439 T0.3656,0.4431 T0.3481,0.4468 Q0.3241,0.4529,0.2943,0.4463 Q0.3227,0.4623,0.3458,0.471 T0.3959,0.4814 Q0.404,0.4818,0.4187,0.4825 T0.4409,0.4835 T0.4605,0.4857 T0.4809,0.4908 T0.4992,0.4996 T0.5186,0.5141 T0.5371,0.5353 L0.5449,0.5451 L0.5337,0.543 Q0.5242,0.541,0.5091,0.55 T0.4683,0.5796 T0.4314,0.6083 Q0.4203,0.6161,0.4086,0.6212 T0.382,0.6308 T0.3667,0.6353 Q0.3485,0.6418,0.2995,0.633 T0.1934,0.6075 Z",type:0}},"":{type:5,data:{d:"M0.989,0.0469 Q0.9829,0.0379,0.9753,0.0316 T0.9635,0.0253 Q0.9574,0.0257,0.9539,0.0263 T0.9466,0.03 T0.9418,0.0345 T0.9355,0.0434 T0.9277,0.0546 Q0.9193,0.0653,0.9103,0.0712 T0.8919,0.0775 T0.8745,0.0765 T0.8564,0.0695 T0.8396,0.0593 T0.8228,0.0473 Q0.7612,0,0.7073,0.0326 L0.7386,0.0767 L0.7419,0.0767 Q0.7506,0.0767,0.7556,0.0773 T0.7641,0.0789 T0.7709,0.0842 T0.7767,0.0922 T0.7854,0.1054 T0.7974,0.1236 Q0.8057,0.1354,0.8157,0.1444 T0.8325,0.1574 T0.8474,0.1654 T0.8571,0.1701 Q0.8564,0.1717,0.8554,0.1733 Q0.8503,0.1815,0.844,0.186 T0.8301,0.1909 T0.8153,0.1903 T0.7993,0.1845 T0.7836,0.1758 T0.768,0.1648 T0.754,0.1535 T0.741,0.1425 T0.7312,0.1338 Q0.7031,0.1101,0.6805,0.0995 T0.6357,0.0901 T0.5886,0.1048 Q0.5721,0.1138,0.5574,0.1168 T0.5295,0.117 T0.5055,0.1089 T0.4814,0.0942 L0.4789,0.0926 L0.4711,0.0922 Q0.4589,0.095,0.4811,0.1203 Q0.495,0.1358,0.5087,0.1474 T0.5366,0.167 T0.5611,0.1796 T0.5879,0.1909 T0.6134,0.2011 Q0.6218,0.2047,0.6273,0.2092 Q0.6283,0.2117,0.6286,0.2141 Q0.6305,0.2263,0.6249,0.2388 T0.606,0.2616 T0.5747,0.2761 Q0.5602,0.2785,0.5487,0.2779 T0.5245,0.2724 T0.5015,0.2616 T0.4784,0.2476 T0.4547,0.2321 T0.4297,0.217 T0.4024,0.2043 Q0.2985,0.166,0.1901,0.2345 Q0.1694,0.248,0.1523,0.2569 T0.1165,0.2726 T0.0818,0.2812 T0.0494,0.2796 T0.0181,0.2663 L0.0116,0.2671 Q0,0.272,0.0232,0.2969 Q0.0468,0.3222,0.0742,0.3365 T0.1278,0.3542 T0.1807,0.3564 T0.233,0.352 T0.2815,0.3473 T0.3269,0.3509 T0.3656,0.3699 Q0.4037,0.4005,0.4153,0.4082 Q0.405,0.4139,0.3921,0.4174 T0.3633,0.4237 T0.3414,0.4278 Q0.3207,0.4331,0.2956,0.4278 Q0.2943,0.4278,0.293,0.4274 Q0.2933,0.429,0.2938,0.4313 T0.2964,0.4398 T0.3007,0.4513 T0.3069,0.4619 T0.3149,0.4698 Q0.3427,0.4857,0.3664,0.4947 T0.4169,0.5053 Q0.423,0.5057,0.4385,0.5065 T0.4606,0.508 T0.4779,0.51 T0.4958,0.5139 T0.5095,0.5204 Q0.4992,0.5232,0.485,0.5328 T0.451,0.5585 T0.4201,0.5824 Q0.4095,0.5897,0.3987,0.5946 T0.3738,0.6036 T0.3591,0.6081 Q0.3433,0.6134,0.2965,0.605 T0.1972,0.5816 L0.2026,0.5922 T0.2133,0.6134 L0.2188,0.624 Q0.2201,0.6248,0.2214,0.6252 Q0.2291,0.6297,0.2486,0.6405 T0.2786,0.657 T0.3066,0.6721 T0.3353,0.6866 T0.3598,0.6972 T0.383,0.7051 T0.4005,0.7076 Q0.4008,0.7076,0.4169,0.7092 T0.4471,0.7092 T0.475,0.7019 Q0.4895,0.6958,0.5176,0.6811 T0.5644,0.6586 T0.5921,0.6533 Q0.6128,0.6741,0.6173,0.6782 Q0.6131,0.6835,0.6068,0.6929 T0.5963,0.7078 T0.5858,0.7198 T0.5716,0.7304 T0.5534,0.7365 Q0.5179,0.7443,0.4708,0.728 L0.4708,0.7294 T0.471,0.7333 T0.4716,0.7392 T0.4734,0.7463 T0.4764,0.7539 T0.4814,0.7612 T0.4889,0.7679 Q0.4914,0.77,0.4944,0.7716 Q0.5534,0.8104,0.6409,0.8091 Q0.6521,0.8091,0.6654,0.8053 T0.6907,0.7959 T0.7157,0.7838 T0.741,0.772 T0.7652,0.7631 T0.7888,0.7594 T0.8106,0.7643 Q0.8196,0.7684,0.8267,0.7753 Q0.8409,0.7892,0.8399,0.8169 Q0.8216,0.8067,0.8062,0.8053 T0.7788,0.8087 T0.7493,0.825 Q0.7386,0.8324,0.7256,0.8365 T0.6947,0.844 T0.668,0.8499 L0.697,0.894 L0.7002,0.8948 Q0.7099,0.8968,0.7222,0.9009 T0.7446,0.9086 T0.767,0.9158 T0.7901,0.9213 T0.8132,0.9229 T0.8367,0.9192 Q0.8483,0.916,0.8633,0.9241 T0.8937,0.9462 T0.9248,0.9737 T0.959,0.9955 T0.9939,1 Q1,0.9984,0.9932,0.9845 Q0.991,0.9804,0.9877,0.9755 Q0.9813,0.9666,0.9739,0.9606 T0.9626,0.9555 Q0.9519,0.958,0.9372,0.949 T0.9071,0.9262 T0.8753,0.8987 T0.8403,0.8777 T0.8051,0.8752 Q0.787,0.8805,0.7657,0.8772 Q0.7751,0.8736,0.7828,0.8683 Q0.8086,0.8511,0.8262,0.8497 T0.8651,0.8617 Q0.8696,0.865,0.8727,0.8646 T0.8758,0.8605 L0.8761,0.8536 Q0.8774,0.8295,0.8646,0.8016 T0.8277,0.7496 Q0.8086,0.7308,0.7896,0.7219 Q0.7741,0.7145,0.7575,0.7141 T0.727,0.7182 T0.6978,0.7296 T0.6699,0.7439 T0.6433,0.7571 T0.6179,0.7643 Q0.627,0.7561,0.6402,0.7367 T0.6618,0.7088 L0.6673,0.7035 Q0.6718,0.699,0.6647,0.6884 T0.6483,0.6692 L0.6389,0.6607 Q0.6289,0.657,0.6249,0.6554 T0.6163,0.6507 T0.6102,0.6458 T0.6021,0.637 T0.5889,0.6236 Q0.5828,0.6175,0.5766,0.6138 Q0.5673,0.6081,0.5561,0.6077 T0.5345,0.6105 T0.5116,0.6201 T0.4887,0.633 T0.4653,0.6468 T0.4427,0.6578 Q0.4295,0.6635,0.4167,0.665 T0.3888,0.665 T0.3714,0.6635 Q0.3579,0.6631,0.3282,0.6501 Q0.374,0.6578,0.3911,0.6517 Q0.3937,0.6509,0.4024,0.6482 T0.4179,0.6434 T0.4348,0.6364 T0.4534,0.6256 Q0.464,0.6183,0.4892,0.5989 T0.5278,0.5712 T0.5476,0.564 L0.5582,0.5661 Q0.5692,0.5681,0.5634,0.5563 Q0.5599,0.5485,0.5524,0.5392 L0.545,0.5298 Q0.5369,0.5188,0.5286,0.51 T0.5134,0.4947 T0.4979,0.4831 T0.484,0.4749 T0.47,0.4694 T0.4572,0.4657 T0.4442,0.4637 T0.4326,0.4629 T0.4205,0.4625 Q0.4511,0.4543,0.466,0.4384 L0.4714,0.4327 Q0.4795,0.4237,0.4469,0.394 L0.4421,0.3899 Q0.433,0.387,0.4251,0.3834 T0.4122,0.3772 T0.3988,0.3687 T0.3874,0.3603 T0.3732,0.3487 T0.3579,0.3361 Q0.3433,0.3242,0.3288,0.3159 T0.2993,0.3034 T0.2725,0.2973 T0.2446,0.2961 T0.2193,0.2977 T0.1926,0.301 Q0.1855,0.3022,0.182,0.3026 Q0.1991,0.2936,0.2233,0.2781 Q0.3282,0.2117,0.4256,0.2476 Q0.4363,0.2516,0.451,0.2604 T0.4784,0.2779 T0.5077,0.2965 T0.539,0.3124 T0.5718,0.3216 T0.606,0.3206 Q0.6363,0.3136,0.6526,0.2936 T0.6647,0.2459 Q0.6615,0.2247,0.645,0.2023 Q0.6354,0.1892,0.6237,0.179 Q0.6102,0.1672,0.5937,0.1595 Q0.6073,0.1562,0.6215,0.1485 Q0.6396,0.1387,0.6547,0.1354 T0.6839,0.1354 T0.7101,0.1458 T0.7373,0.166 Q0.738,0.1664,0.746,0.1733 T0.7586,0.1841 T0.7733,0.196 T0.7907,0.2086 T0.8086,0.2196 T0.8275,0.2288 T0.8454,0.2337 T0.8627,0.2343 T0.8777,0.228 T0.8903,0.2145 Q0.9038,0.1929,0.8742,0.1582 Q0.869,0.1517,0.8629,0.1464 Q0.8538,0.1387,0.844,0.1321 T0.8248,0.1205 T0.8122,0.1134 Q0.8109,0.1117,0.8053,0.103 T0.7965,0.0899 T0.7875,0.0781 T0.7757,0.064 Q0.8051,0.0616,0.8328,0.0828 Q0.847,0.0934,0.8588,0.1009 T0.8854,0.1146 T0.9127,0.1213 T0.9384,0.116 T0.9626,0.0962 Q0.9664,0.0909,0.9706,0.0846 T0.976,0.0767 T0.9798,0.0728 T0.9852,0.0704 T0.9932,0.0697 Q0.9997,0.0693,0.9942,0.0567 Q0.9923,0.0522,0.989,0.0469 Z",type:0}},"":{type:5,data:{d:"M0.4116,0.0126 L0.4116,0.0776 L0.4871,0.0776 L0.4871,0.0126 L0.4116,0.0126 Z M0.4043,0 L0.4944,0 Q0.4973,0,0.4995,0.0021 T0.5017,0.0063 L0.5017,0.0839 Q0.5017,0.0864,0.4993,0.0883 T0.4944,0.0902 L0.4043,0.0902 Q0.4014,0.0902,0.3992,0.0881 T0.397,0.0839 L0.397,0.0063 Q0.397,0.0038,0.3994,0.0019 T0.4043,0 Z M0.4116,0.0126 L0.4116,0.0776 L0.4871,0.0776 L0.4871,0.0126 L0.4116,0.0126 Z M0.4043,0 L0.4944,0 Q0.4973,0,0.4995,0.0021 T0.5017,0.0063 L0.5017,0.0839 Q0.5017,0.0864,0.4993,0.0883 T0.4944,0.0902 L0.4043,0.0902 Q0.4014,0.0902,0.3992,0.0881 T0.397,0.0839 L0.397,0.0063 Q0.397,0.0038,0.3994,0.0019 T0.4043,0 Z M0.4116,0.0126 L0.4116,0.0776 L0.4871,0.0776 L0.4871,0.0126 L0.4116,0.0126 Z M0.4043,0 L0.4944,0 Q0.4973,0,0.4995,0.0021 T0.5017,0.0063 L0.5017,0.0839 Q0.5017,0.0864,0.4993,0.0883 T0.4944,0.0902 L0.4043,0.0902 Q0.4014,0.0902,0.3992,0.0881 T0.397,0.0839 L0.397,0.0063 Q0.397,0.0038,0.3994,0.0019 T0.4043,0 Z M0.9099,0.0084 L0.9099,0.0818 L0.9951,0.0818 L0.9951,0.0084 L0.9099,0.0084 Z M0.9075,0.0042 L0.9976,0.0042 Q1,0.0042,1,0.0063 L1,0.0839 Q1,0.086,0.9976,0.086 L0.9075,0.086 Q0.905,0.086,0.905,0.0839 L0.905,0.0063 Q0.905,0.0042,0.9075,0.0042 Z M0.9099,0.0084 L0.9099,0.0818 L0.9951,0.0818 L0.9951,0.0084 L0.9099,0.0084 Z M0.9075,0.0042 L0.9976,0.0042 Q1,0.0042,1,0.0063 L1,0.0839 Q1,0.086,0.9976,0.086 L0.9075,0.086 Q0.905,0.086,0.905,0.0839 L0.905,0.0063 Q0.905,0.0042,0.9075,0.0042 Z M0.9099,0.0084 L0.9099,0.0818 L0.9951,0.0818 L0.9951,0.0084 L0.9099,0.0084 Z M0.9075,0.0042 L0.9976,0.0042 Q1,0.0042,1,0.0063 L1,0.0839 Q1,0.086,0.9976,0.086 L0.9075,0.086 Q0.905,0.086,0.905,0.0839 L0.905,0.0063 Q0.905,0.0042,0.9075,0.0042 Z M0.66,0.0063 L0.7501,0.0063 L0.7501,0.0839 L0.66,0.0839 L0.66,0.0063 Z M0.66,0.0063 L0.7501,0.0063 L0.7501,0.0839 L0.66,0.0839 L0.66,0.0063 Z M0.66,0.0063 L0.7501,0.0063 L0.7501,0.0839 L0.66,0.0839 L0.66,0.0063 Z M0.5309,0.0063 L0.621,0.0063 L0.621,0.0839 L0.5309,0.0839 L0.5309,0.0063 Z M0.5309,0.0063 L0.621,0.0063 L0.621,0.0839 L0.5309,0.0839 L0.5309,0.0063 Z M0.5309,0.0063 L0.621,0.0063 L0.621,0.0839 L0.5309,0.0839 L0.5309,0.0063 Z M0.2689,0.0063 L0.359,0.0063 L0.359,0.0839 L0.2689,0.0839 L0.2689,0.0063 Z M0.2689,0.0063 L0.359,0.0063 L0.359,0.0839 L0.2689,0.0839 L0.2689,0.0063 Z M0.2689,0.0063 L0.359,0.0063 L0.359,0.0839 L0.2689,0.0839 L0.2689,0.0063 Z M0.1374,0.0063 L0.2275,0.0063 L0.2275,0.0839 L0.1374,0.0839 L0.1374,0.0063 Z M0.1374,0.0063 L0.2275,0.0063 L0.2275,0.0839 L0.1374,0.0839 L0.1374,0.0063 Z M0.1374,0.0063 L0.2275,0.0063 L0.2275,0.0839 L0.1374,0.0839 L0.1374,0.0063 Z M0,0.0063 L0.0901,0.0063 L0.0901,0.0839 L0,0.0839 L0,0.0063 Z M0,0.0063 L0.0901,0.0063 L0.0901,0.0839 L0,0.0839 L0,0.0063 Z M0,0.0063 L0.0901,0.0063 L0.0901,0.0839 L0,0.0839 L0,0.0063 Z M0.4087,0.9224 L0.4087,0.9958 L0.4939,0.9958 L0.4939,0.9224 L0.4087,0.9224 Z M0.4062,0.9182 L0.4963,0.9182 Q0.4988,0.9182,0.4988,0.9203 L0.4988,0.9979 Q0.4988,1,0.4963,1 L0.4062,1 Q0.4038,1,0.4038,0.9979 L0.4038,0.9203 Q0.4038,0.9182,0.4062,0.9182 Z M0.4087,0.9224 L0.4087,0.9958 L0.4939,0.9958 L0.4939,0.9224 L0.4087,0.9224 Z M0.4062,0.9182 L0.4963,0.9182 Q0.4988,0.9182,0.4988,0.9203 L0.4988,0.9979 Q0.4988,1,0.4963,1 L0.4062,1 Q0.4038,1,0.4038,0.9979 L0.4038,0.9203 Q0.4038,0.9182,0.4062,0.9182 Z M0.4087,0.9224 L0.4087,0.9958 L0.4939,0.9958 L0.4939,0.9224 L0.4087,0.9224 Z M0.4062,0.9182 L0.4963,0.9182 Q0.4988,0.9182,0.4988,0.9203 L0.4988,0.9979 Q0.4988,1,0.4963,1 L0.4062,1 Q0.4038,1,0.4038,0.9979 L0.4038,0.9203 Q0.4038,0.9182,0.4062,0.9182 Z M0.1374,0.9203 L0.2275,0.9203 L0.2275,0.9979 L0.1374,0.9979 L0.1374,0.9203 Z M0.1374,0.9203 L0.2275,0.9203 L0.2275,0.9979 L0.1374,0.9979 L0.1374,0.9203 Z M0.1374,0.9203 L0.2275,0.9203 L0.2275,0.9979 L0.1374,0.9979 L0.1374,0.9203 Z M0,0.9203 L0.0901,0.9203 L0.0901,0.9979 L0,0.9979 L0,0.9203 Z M0,0.9203 L0.0901,0.9203 L0.0901,0.9979 L0,0.9979 L0,0.9203 Z M0,0.9203 L0.0901,0.9203 L0.0901,0.9979 L0,0.9979 L0,0.9203 Z M0.9099,0.1158 L0.9099,0.1888 L0.9951,0.1888 L0.9951,0.1158 L0.9099,0.1158 Z M0.9075,0.1116 L0.9976,0.1116 Q1,0.1116,1,0.1137 L1,0.1909 Q1,0.193,0.9976,0.193 L0.9075,0.193 Q0.905,0.193,0.905,0.1909 L0.905,0.1137 Q0.905,0.1116,0.9075,0.1116 Z M0.7852,0.6086 L0.7852,0.682 L0.8704,0.682 L0.8704,0.6086 L0.7852,0.6086 Z M0.7828,0.6044 L0.8729,0.6044 Q0.8753,0.6044,0.8753,0.6065 L0.8753,0.6841 Q0.8753,0.6862,0.8729,0.6862 L0.7828,0.6862 Q0.7803,0.6862,0.7803,0.6841 L0.7803,0.6065 Q0.7803,0.6044,0.7828,0.6044 Z M0.66,0.1137 L0.7501,0.1137 L0.7501,0.1909 L0.66,0.1909 L0.66,0.1137 Z M0.6624,0.4102 L0.6624,0.4836 L0.7477,0.4836 L0.7477,0.4102 L0.6624,0.4102 Z M0.66,0.406 L0.7501,0.406 Q0.7526,0.406,0.7526,0.4081 L0.7526,0.4857 Q0.7526,0.4878,0.7501,0.4878 L0.66,0.4878 Q0.6576,0.4878,0.6576,0.4857 L0.6576,0.4081 Q0.6576,0.406,0.66,0.406 Z M0.6624,0.7131 L0.6624,0.7865 L0.7477,0.7865 L0.7477,0.7131 L0.6624,0.7131 Z M0.66,0.7089 L0.7501,0.7089 Q0.7526,0.7089,0.7526,0.711 L0.7526,0.7886 Q0.7526,0.7907,0.7501,0.7907 L0.66,0.7907 Q0.6576,0.7907,0.6576,0.7886 L0.6576,0.711 Q0.6576,0.7089,0.66,0.7089 Z M0.5407,0.2227 L0.5407,0.2836 L0.6113,0.2836 L0.6113,0.2227 L0.5407,0.2227 Z M0.5309,0.206 L0.621,0.206 Q0.623,0.206,0.6249,0.2068 T0.6281,0.2089 T0.6301,0.2116 T0.6308,0.2143 L0.6308,0.2919 Q0.6308,0.2957,0.6276,0.298 T0.621,0.3003 L0.5309,0.3003 Q0.5265,0.3003,0.5239,0.2976 T0.5212,0.2919 L0.5212,0.2143 Q0.5212,0.211,0.5244,0.2085 T0.5309,0.206 Z M0.5407,0.3184 L0.5407,0.3792 L0.6113,0.3792 L0.6113,0.3184 L0.5407,0.3184 Z M0.5309,0.3016 L0.621,0.3016 Q0.6254,0.3016,0.6281,0.3043 T0.6308,0.31 L0.6308,0.3876 Q0.6308,0.3914,0.6276,0.3937 T0.621,0.396 L0.5309,0.396 Q0.5265,0.396,0.5239,0.3932 T0.5212,0.3876 L0.5212,0.31 Q0.5212,0.3062,0.5244,0.3039 T0.5309,0.3016 Z M0.5309,0.4081 L0.621,0.4081 L0.621,0.4857 L0.5309,0.4857 L0.5309,0.4081 Z M0.5309,0.5059 L0.621,0.5059 L0.621,0.5835 L0.5309,0.5835 L0.5309,0.5059 Z M0.5407,0.6149 L0.5407,0.6758 L0.6113,0.6758 L0.6113,0.6149 L0.5407,0.6149 Z M0.5309,0.5982 L0.621,0.5982 Q0.6254,0.5982,0.6281,0.6009 T0.6308,0.6065 L0.6308,0.6841 Q0.6308,0.6879,0.6276,0.6902 T0.621,0.6925 L0.5309,0.6925 Q0.5265,0.6925,0.5239,0.6898 T0.5212,0.6841 L0.5212,0.6065 Q0.5212,0.6028,0.5244,0.6005 T0.5309,0.5982 Z M0.4062,0.1137 L0.4963,0.1137 L0.4963,0.1909 L0.4062,0.1909 L0.4062,0.1137 Z M0.4062,0.2143 L0.4963,0.2143 L0.4963,0.2919 L0.4062,0.2919 L0.4062,0.2143 Z M0.4184,0.4186 L0.4184,0.4753 L0.4842,0.4753 L0.4842,0.4186 L0.4184,0.4186 Z M0.4062,0.3977 L0.4963,0.3977 Q0.5017,0.3977,0.5051,0.401 T0.5085,0.4081 L0.5085,0.4857 Q0.5085,0.4904,0.5046,0.4933 T0.4963,0.4962 L0.4062,0.4962 Q0.4009,0.4962,0.3975,0.4929 T0.3941,0.4857 L0.3941,0.4081 Q0.3941,0.4035,0.398,0.4006 T0.4062,0.3977 Z M0.4062,0.5059 L0.4963,0.5059 L0.4963,0.5835 L0.4062,0.5835 L0.4062,0.5059 Z M0.4087,0.7131 L0.4087,0.7865 L0.4939,0.7865 L0.4939,0.7131 L0.4087,0.7131 Z M0.4062,0.7089 L0.4963,0.7089 Q0.4988,0.7089,0.4988,0.711 L0.4988,0.7886 Q0.4988,0.7907,0.4963,0.7907 L0.4062,0.7907 Q0.4038,0.7907,0.4038,0.7886 L0.4038,0.711 Q0.4038,0.7089,0.4062,0.7089 Z M0.2689,0.1137 L0.359,0.1137 L0.359,0.1909 L0.2689,0.1909 L0.2689,0.1137 Z M0.2689,0.2143 L0.359,0.2143 L0.359,0.2919 L0.2689,0.2919 L0.2689,0.2143 Z M0.2689,0.8154 L0.359,0.8154 L0.359,0.8926 L0.2689,0.8926 L0.2689,0.8154 Z M0.2689,0.31 L0.359,0.31 L0.359,0.3876 L0.2689,0.3876 L0.2689,0.31 Z M0.2689,0.8154 L0.359,0.8154 L0.359,0.8926 L0.2689,0.8926 L0.2689,0.8154 Z M0.2689,0.4081 L0.359,0.4081 L0.359,0.4857 L0.2689,0.4857 L0.2689,0.4081 Z M0.2689,0.5059 L0.359,0.5059 L0.359,0.5835 L0.2689,0.5835 L0.2689,0.5059 Z M0.2689,0.711 L0.359,0.711 L0.359,0.7886 L0.2689,0.7886 L0.2689,0.711 Z M0.2689,0.8154 L0.359,0.8154 L0.359,0.8926 L0.2689,0.8926 L0.2689,0.8154 Z M0.1374,0.1137 L0.2275,0.1137 L0.2275,0.1909 L0.1374,0.1909 L0.1374,0.1137 Z M0.1374,0.2143 L0.2275,0.2143 L0.2275,0.2919 L0.1374,0.2919 L0.1374,0.2143 Z M0.1374,0.8154 L0.2275,0.8154 L0.2275,0.8926 L0.1374,0.8926 L0.1374,0.8154 Z M0.1374,0.31 L0.2275,0.31 L0.2275,0.3876 L0.1374,0.3876 L0.1374,0.31 Z M0.1374,0.8154 L0.2275,0.8154 L0.2275,0.8926 L0.1374,0.8926 L0.1374,0.8154 Z M0.1374,0.4081 L0.2275,0.4081 L0.2275,0.4857 L0.1374,0.4857 L0.1374,0.4081 Z M0.1374,0.5059 L0.2275,0.5059 L0.2275,0.5835 L0.1374,0.5835 L0.1374,0.5059 Z M0.1374,0.6065 L0.2275,0.6065 L0.2275,0.6841 L0.1374,0.6841 L0.1374,0.6065 Z M0.1374,0.711 L0.2275,0.711 L0.2275,0.7886 L0.1374,0.7886 L0.1374,0.711 Z M0.1374,0.8154 L0.2275,0.8154 L0.2275,0.8926 L0.1374,0.8926 L0.1374,0.8154 Z M0,0.1137 L0.0901,0.1137 L0.0901,0.1909 L0,0.1909 L0,0.1137 Z M0,0.2143 L0.0901,0.2143 L0.0901,0.2919 L0,0.2919 L0,0.2143 Z M0,0.8154 L0.0901,0.8154 L0.0901,0.8926 L0,0.8926 L0,0.8154 Z M0,0.31 L0.0901,0.31 L0.0901,0.3876 L0,0.3876 L0,0.31 Z M0,0.8154 L0.0901,0.8154 L0.0901,0.8926 L0,0.8926 L0,0.8154 Z M0,0.4081 L0.0901,0.4081 L0.0901,0.4857 L0,0.4857 L0,0.4081 Z M0,0.5059 L0.0901,0.5059 L0.0901,0.5835 L0,0.5835 L0,0.5059 Z M0,0.6065 L0.0901,0.6065 L0.0901,0.6841 L0,0.6841 L0,0.6065 Z M0,0.711 L0.0901,0.711 L0.0901,0.7886 L0,0.7886 L0,0.711 Z M0,0.8154 L0.0901,0.8154 L0.0901,0.8926 L0,0.8926 L0,0.8154 Z",type:0}},"":{type:5,data:{d:"M0.5884,0.0126 L0.5884,0.0776 L0.5129,0.0776 L0.5129,0.0126 L0.5884,0.0126 Z M0.5957,0 L0.5056,0 Q0.5027,0,0.5005,0.0021 T0.4983,0.0063 L0.4983,0.0839 Q0.4983,0.0864,0.5007,0.0883 T0.5056,0.0902 L0.5957,0.0902 Q0.5986,0.0902,0.6008,0.0881 T0.603,0.0839 L0.603,0.0063 Q0.603,0.0038,0.6006,0.0019 T0.5957,0 Z M0.5884,0.0126 L0.5884,0.0776 L0.5129,0.0776 L0.5129,0.0126 L0.5884,0.0126 Z M0.5957,0 L0.5056,0 Q0.5027,0,0.5005,0.0021 T0.4983,0.0063 L0.4983,0.0839 Q0.4983,0.0864,0.5007,0.0883 T0.5056,0.0902 L0.5957,0.0902 Q0.5986,0.0902,0.6008,0.0881 T0.603,0.0839 L0.603,0.0063 Q0.603,0.0038,0.6006,0.0019 T0.5957,0 Z M0.5884,0.0126 L0.5884,0.0776 L0.5129,0.0776 L0.5129,0.0126 L0.5884,0.0126 Z M0.5957,0 L0.5056,0 Q0.5027,0,0.5005,0.0021 T0.4983,0.0063 L0.4983,0.0839 Q0.4983,0.0864,0.5007,0.0883 T0.5056,0.0902 L0.5957,0.0902 Q0.5986,0.0902,0.6008,0.0881 T0.603,0.0839 L0.603,0.0063 Q0.603,0.0038,0.6006,0.0019 T0.5957,0 Z M0.0901,0.0084 L0.0901,0.0818 L0.0049,0.0818 L0.0049,0.0084 L0.0901,0.0084 Z M0.0925,0.0042 L0.0024,0.0042 Q0,0.0042,0,0.0063 L0,0.0839 Q0,0.086,0.0024,0.086 L0.0925,0.086 Q0.095,0.086,0.095,0.0839 L0.095,0.0063 Q0.095,0.0042,0.0925,0.0042 Z M0.0901,0.0084 L0.0901,0.0818 L0.0049,0.0818 L0.0049,0.0084 L0.0901,0.0084 Z M0.0925,0.0042 L0.0024,0.0042 Q0,0.0042,0,0.0063 L0,0.0839 Q0,0.086,0.0024,0.086 L0.0925,0.086 Q0.095,0.086,0.095,0.0839 L0.095,0.0063 Q0.095,0.0042,0.0925,0.0042 Z M0.0901,0.0084 L0.0901,0.0818 L0.0049,0.0818 L0.0049,0.0084 L0.0901,0.0084 Z M0.0925,0.0042 L0.0024,0.0042 Q0,0.0042,0,0.0063 L0,0.0839 Q0,0.086,0.0024,0.086 L0.0925,0.086 Q0.095,0.086,0.095,0.0839 L0.095,0.0063 Q0.095,0.0042,0.0925,0.0042 Z M0.34,0.0063 L0.2499,0.0063 L0.2499,0.0839 L0.34,0.0839 L0.34,0.0063 Z M0.34,0.0063 L0.2499,0.0063 L0.2499,0.0839 L0.34,0.0839 L0.34,0.0063 Z M0.34,0.0063 L0.2499,0.0063 L0.2499,0.0839 L0.34,0.0839 L0.34,0.0063 Z M0.4691,0.0063 L0.379,0.0063 L0.379,0.0839 L0.4691,0.0839 L0.4691,0.0063 Z M0.4691,0.0063 L0.379,0.0063 L0.379,0.0839 L0.4691,0.0839 L0.4691,0.0063 Z M0.4691,0.0063 L0.379,0.0063 L0.379,0.0839 L0.4691,0.0839 L0.4691,0.0063 Z M0.7311,0.0063 L0.641,0.0063 L0.641,0.0839 L0.7311,0.0839 L0.7311,0.0063 Z M0.7311,0.0063 L0.641,0.0063 L0.641,0.0839 L0.7311,0.0839 L0.7311,0.0063 Z M0.7311,0.0063 L0.641,0.0063 L0.641,0.0839 L0.7311,0.0839 L0.7311,0.0063 Z M0.8626,0.0063 L0.7725,0.0063 L0.7725,0.0839 L0.8626,0.0839 L0.8626,0.0063 Z M0.8626,0.0063 L0.7725,0.0063 L0.7725,0.0839 L0.8626,0.0839 L0.8626,0.0063 Z M0.8626,0.0063 L0.7725,0.0063 L0.7725,0.0839 L0.8626,0.0839 L0.8626,0.0063 Z M1,0.0063 L0.9099,0.0063 L0.9099,0.0839 L1,0.0839 L1,0.0063 Z M1,0.0063 L0.9099,0.0063 L0.9099,0.0839 L1,0.0839 L1,0.0063 Z M1,0.0063 L0.9099,0.0063 L0.9099,0.0839 L1,0.0839 L1,0.0063 Z M0.5913,0.9224 L0.5913,0.9958 L0.5061,0.9958 L0.5061,0.9224 L0.5913,0.9224 Z M0.5938,0.9182 L0.5037,0.9182 Q0.5012,0.9182,0.5012,0.9203 L0.5012,0.9979 Q0.5012,1,0.5037,1 L0.5938,1 Q0.5962,1,0.5962,0.9979 L0.5962,0.9203 Q0.5962,0.9182,0.5938,0.9182 Z M0.5913,0.9224 L0.5913,0.9958 L0.5061,0.9958 L0.5061,0.9224 L0.5913,0.9224 Z M0.5938,0.9182 L0.5037,0.9182 Q0.5012,0.9182,0.5012,0.9203 L0.5012,0.9979 Q0.5012,1,0.5037,1 L0.5938,1 Q0.5962,1,0.5962,0.9979 L0.5962,0.9203 Q0.5962,0.9182,0.5938,0.9182 Z M0.5913,0.9224 L0.5913,0.9958 L0.5061,0.9958 L0.5061,0.9224 L0.5913,0.9224 Z M0.5938,0.9182 L0.5037,0.9182 Q0.5012,0.9182,0.5012,0.9203 L0.5012,0.9979 Q0.5012,1,0.5037,1 L0.5938,1 Q0.5962,1,0.5962,0.9979 L0.5962,0.9203 Q0.5962,0.9182,0.5938,0.9182 Z M0.8626,0.9203 L0.7725,0.9203 L0.7725,0.9979 L0.8626,0.9979 L0.8626,0.9203 Z M0.8626,0.9203 L0.7725,0.9203 L0.7725,0.9979 L0.8626,0.9979 L0.8626,0.9203 Z M0.8626,0.9203 L0.7725,0.9203 L0.7725,0.9979 L0.8626,0.9979 L0.8626,0.9203 Z M1,0.9203 L0.9099,0.9203 L0.9099,0.9979 L1,0.9979 L1,0.9203 Z M1,0.9203 L0.9099,0.9203 L0.9099,0.9979 L1,0.9979 L1,0.9203 Z M1,0.9203 L0.9099,0.9203 L0.9099,0.9979 L1,0.9979 L1,0.9203 Z M0.0901,0.1158 L0.0901,0.1888 L0.0049,0.1888 L0.0049,0.1158 L0.0901,0.1158 Z M0.0925,0.1116 L0.0024,0.1116 Q0,0.1116,0,0.1137 L0,0.1909 Q0,0.193,0.0024,0.193 L0.0925,0.193 Q0.095,0.193,0.095,0.1909 L0.095,0.1137 Q0.095,0.1116,0.0925,0.1116 Z M0.2148,0.6086 L0.2148,0.682 L0.1296,0.682 L0.1296,0.6086 L0.2148,0.6086 Z M0.2172,0.6044 L0.1271,0.6044 Q0.1247,0.6044,0.1247,0.6065 L0.1247,0.6841 Q0.1247,0.6862,0.1271,0.6862 L0.2172,0.6862 Q0.2197,0.6862,0.2197,0.6841 L0.2197,0.6065 Q0.2197,0.6044,0.2172,0.6044 Z M0.34,0.1137 L0.2499,0.1137 L0.2499,0.1909 L0.34,0.1909 L0.34,0.1137 Z M0.3376,0.4102 L0.3376,0.4836 L0.2523,0.4836 L0.2523,0.4102 L0.3376,0.4102 Z M0.34,0.406 L0.2499,0.406 Q0.2474,0.406,0.2474,0.4081 L0.2474,0.4857 Q0.2474,0.4878,0.2499,0.4878 L0.34,0.4878 Q0.3424,0.4878,0.3424,0.4857 L0.3424,0.4081 Q0.3424,0.406,0.34,0.406 Z M0.3376,0.7131 L0.3376,0.7865 L0.2523,0.7865 L0.2523,0.7131 L0.3376,0.7131 Z M0.34,0.7089 L0.2499,0.7089 Q0.2474,0.7089,0.2474,0.711 L0.2474,0.7886 Q0.2474,0.7907,0.2499,0.7907 L0.34,0.7907 Q0.3424,0.7907,0.3424,0.7886 L0.3424,0.711 Q0.3424,0.7089,0.34,0.7089 Z M0.4593,0.2227 L0.4593,0.2836 L0.3887,0.2836 L0.3887,0.2227 L0.4593,0.2227 Z M0.4691,0.206 L0.379,0.206 Q0.3746,0.206,0.3719,0.2087 T0.3692,0.2143 L0.3692,0.2919 Q0.3692,0.2957,0.3724,0.298 T0.379,0.3003 L0.4691,0.3003 Q0.4735,0.3003,0.4761,0.2976 T0.4788,0.2919 L0.4788,0.2143 Q0.4788,0.211,0.4756,0.2085 T0.4691,0.206 Z M0.4593,0.3184 L0.4593,0.3792 L0.3887,0.3792 L0.3887,0.3184 L0.4593,0.3184 Z M0.4691,0.3016 L0.379,0.3016 Q0.3746,0.3016,0.3719,0.3043 T0.3692,0.31 L0.3692,0.3876 Q0.3692,0.3914,0.3724,0.3937 T0.379,0.396 L0.4691,0.396 Q0.4735,0.396,0.4761,0.3932 T0.4788,0.3876 L0.4788,0.31 Q0.4788,0.3062,0.4756,0.3039 T0.4691,0.3016 Z M0.4691,0.4081 L0.379,0.4081 L0.379,0.4857 L0.4691,0.4857 L0.4691,0.4081 Z M0.4691,0.5059 L0.379,0.5059 L0.379,0.5835 L0.4691,0.5835 L0.4691,0.5059 Z M0.4593,0.6149 L0.4593,0.6758 L0.3887,0.6758 L0.3887,0.6149 L0.4593,0.6149 Z M0.4691,0.5982 L0.379,0.5982 Q0.3746,0.5982,0.3719,0.6009 T0.3692,0.6065 L0.3692,0.6841 Q0.3692,0.6879,0.3724,0.6902 T0.379,0.6925 L0.4691,0.6925 Q0.4735,0.6925,0.4761,0.6898 T0.4788,0.6841 L0.4788,0.6065 Q0.4788,0.6028,0.4756,0.6005 T0.4691,0.5982 Z M0.5938,0.1137 L0.5037,0.1137 L0.5037,0.1909 L0.5938,0.1909 L0.5938,0.1137 Z M0.5938,0.2143 L0.5037,0.2143 L0.5037,0.2919 L0.5938,0.2919 L0.5938,0.2143 Z M0.5816,0.4186 L0.5816,0.4753 L0.5158,0.4753 L0.5158,0.4186 L0.5816,0.4186 Z M0.5938,0.3977 L0.5037,0.3977 Q0.4983,0.3977,0.4949,0.401 T0.4915,0.4081 L0.4915,0.4857 Q0.4915,0.4904,0.4954,0.4933 T0.5037,0.4962 L0.5938,0.4962 Q0.5991,0.4962,0.6025,0.4929 T0.6059,0.4857 L0.6059,0.4081 Q0.6059,0.4035,0.602,0.4006 T0.5938,0.3977 Z M0.5938,0.5059 L0.5037,0.5059 L0.5037,0.5835 L0.5938,0.5835 L0.5938,0.5059 Z M0.5913,0.7131 L0.5913,0.7865 L0.5061,0.7865 L0.5061,0.7131 L0.5913,0.7131 Z M0.5938,0.7089 L0.5037,0.7089 Q0.5012,0.7089,0.5012,0.711 L0.5012,0.7886 Q0.5012,0.7907,0.5037,0.7907 L0.5938,0.7907 Q0.5962,0.7907,0.5962,0.7886 L0.5962,0.711 Q0.5962,0.7089,0.5938,0.7089 Z M0.7311,0.1137 L0.641,0.1137 L0.641,0.1909 L0.7311,0.1909 L0.7311,0.1137 Z M0.7311,0.2143 L0.641,0.2143 L0.641,0.2919 L0.7311,0.2919 L0.7311,0.2143 Z M0.7311,0.8154 L0.641,0.8154 L0.641,0.8926 L0.7311,0.8926 L0.7311,0.8154 Z M0.7311,0.31 L0.641,0.31 L0.641,0.3876 L0.7311,0.3876 L0.7311,0.31 Z M0.7311,0.8154 L0.641,0.8154 L0.641,0.8926 L0.7311,0.8926 L0.7311,0.8154 Z M0.7311,0.4081 L0.641,0.4081 L0.641,0.4857 L0.7311,0.4857 L0.7311,0.4081 Z M0.7311,0.5059 L0.641,0.5059 L0.641,0.5835 L0.7311,0.5835 L0.7311,0.5059 Z M0.7311,0.711 L0.641,0.711 L0.641,0.7886 L0.7311,0.7886 L0.7311,0.711 Z M0.7311,0.8154 L0.641,0.8154 L0.641,0.8926 L0.7311,0.8926 L0.7311,0.8154 Z M0.8626,0.1137 L0.7725,0.1137 L0.7725,0.1909 L0.8626,0.1909 L0.8626,0.1137 Z M0.8626,0.2143 L0.7725,0.2143 L0.7725,0.2919 L0.8626,0.2919 L0.8626,0.2143 Z M0.8626,0.8154 L0.7725,0.8154 L0.7725,0.8926 L0.8626,0.8926 L0.8626,0.8154 Z M0.8626,0.31 L0.7725,0.31 L0.7725,0.3876 L0.8626,0.3876 L0.8626,0.31 Z M0.8626,0.8154 L0.7725,0.8154 L0.7725,0.8926 L0.8626,0.8926 L0.8626,0.8154 Z M0.8626,0.4081 L0.7725,0.4081 L0.7725,0.4857 L0.8626,0.4857 L0.8626,0.4081 Z M0.8626,0.5059 L0.7725,0.5059 L0.7725,0.5835 L0.8626,0.5835 L0.8626,0.5059 Z M0.8626,0.6065 L0.7725,0.6065 L0.7725,0.6841 L0.8626,0.6841 L0.8626,0.6065 Z M0.8626,0.711 L0.7725,0.711 L0.7725,0.7886 L0.8626,0.7886 L0.8626,0.711 Z M0.8626,0.8154 L0.7725,0.8154 L0.7725,0.8926 L0.8626,0.8926 L0.8626,0.8154 Z M1,0.1137 L0.9099,0.1137 L0.9099,0.1909 L1,0.1909 L1,0.1137 Z M1,0.2143 L0.9099,0.2143 L0.9099,0.2919 L1,0.2919 L1,0.2143 Z M1,0.8154 L0.9099,0.8154 L0.9099,0.8926 L1,0.8926 L1,0.8154 Z M1,0.31 L0.9099,0.31 L0.9099,0.3876 L1,0.3876 L1,0.31 Z M1,0.8154 L0.9099,0.8154 L0.9099,0.8926 L1,0.8926 L1,0.8154 Z M1,0.4081 L0.9099,0.4081 L0.9099,0.4857 L1,0.4857 L1,0.4081 Z M1,0.5059 L0.9099,0.5059 L0.9099,0.5835 L1,0.5835 L1,0.5059 Z M1,0.6065 L0.9099,0.6065 L0.9099,0.6841 L1,0.6841 L1,0.6065 Z M1,0.711 L0.9099,0.711 L0.9099,0.7886 L1,0.7886 L1,0.711 Z M1,0.8154 L0.9099,0.8154 L0.9099,0.8926 L1,0.8926 L1,0.8154 Z",type:0}},"":{type:5,data:{d:"M0.6529,0.018 L0.6529,0.112 L0.7724,0.112 L0.7724,0.018 L0.6529,0.018 Z M0.6411,0 L0.7837,0 Q0.7873,0,0.7902,0.0015 T0.7943,0.005 T0.7956,0.0092 L0.7956,0.1208 Q0.7956,0.125,0.7917,0.1275 T0.7837,0.13 L0.6411,0.13 Q0.6359,0.13,0.6326,0.1271 T0.6292,0.1208 L0.6292,0.0092 Q0.6292,0.005,0.6331,0.0025 T0.6411,0 Z M0.6529,0.018 L0.6529,0.112 L0.7724,0.112 L0.7724,0.018 L0.6529,0.018 Z M0.6411,0 L0.7837,0 Q0.7873,0,0.7902,0.0015 T0.7943,0.005 T0.7956,0.0092 L0.7956,0.1208 Q0.7956,0.125,0.7917,0.1275 T0.7837,0.13 L0.6411,0.13 Q0.6359,0.13,0.6326,0.1271 T0.6292,0.1208 L0.6292,0.0092 Q0.6292,0.005,0.6331,0.0025 T0.6411,0 Z M0.6529,0.018 L0.6529,0.112 L0.7724,0.112 L0.7724,0.018 L0.6529,0.018 Z M0.6411,0 L0.7837,0 Q0.7873,0,0.7902,0.0015 T0.7943,0.005 T0.7956,0.0092 L0.7956,0.1208 Q0.7956,0.125,0.7917,0.1275 T0.7837,0.13 L0.6411,0.13 Q0.6359,0.13,0.6326,0.1271 T0.6292,0.1208 L0.6292,0.0092 Q0.6292,0.005,0.6331,0.0025 T0.6411,0 Z M0.4325,0.0143 L0.4325,0.1158 L0.5628,0.1158 L0.5628,0.0143 L0.4325,0.0143 Z M0.4264,0.0042 L0.5695,0.0042 Q0.5721,0.0042,0.5739,0.0057 T0.5757,0.0092 L0.5757,0.1208 Q0.5757,0.1221,0.5752,0.1231 T0.5736,0.1248 T0.5716,0.1256 T0.5695,0.1258 L0.4264,0.1258 Q0.4238,0.1258,0.422,0.1244 T0.4202,0.1208 L0.4202,0.0092 Q0.4202,0.008,0.4207,0.0069 T0.4222,0.0052 T0.4243,0.0044 T0.4264,0.0042 Z M0.4325,0.0143 L0.4325,0.1158 L0.5628,0.1158 L0.5628,0.0143 L0.4325,0.0143 Z M0.4264,0.0042 L0.5695,0.0042 Q0.5721,0.0042,0.5739,0.0057 T0.5757,0.0092 L0.5757,0.1208 Q0.5757,0.1221,0.5752,0.1231 T0.5736,0.1248 T0.5716,0.1256 T0.5695,0.1258 L0.4264,0.1258 Q0.4238,0.1258,0.422,0.1244 T0.4202,0.1208 L0.4202,0.0092 Q0.4202,0.008,0.4207,0.0069 T0.4222,0.0052 T0.4243,0.0044 T0.4264,0.0042 Z M0.4325,0.0143 L0.4325,0.1158 L0.5628,0.1158 L0.5628,0.0143 L0.4325,0.0143 Z M0.4264,0.0042 L0.5695,0.0042 Q0.5721,0.0042,0.5739,0.0057 T0.5757,0.0092 L0.5757,0.1208 Q0.5757,0.1221,0.5752,0.1231 T0.5736,0.1248 T0.5716,0.1256 T0.5695,0.1258 L0.4264,0.1258 Q0.4238,0.1258,0.422,0.1244 T0.4202,0.1208 L0.4202,0.0092 Q0.4202,0.008,0.4207,0.0069 T0.4222,0.0052 T0.4243,0.0044 T0.4264,0.0042 Z M0.2178,0.0092 L0.3605,0.0092 L0.3605,0.1208 L0.2178,0.1208 L0.2178,0.0092 Z M0.2178,0.0092 L0.3605,0.0092 L0.3605,0.1208 L0.2178,0.1208 L0.2178,0.0092 Z M0.2178,0.0092 L0.3605,0.0092 L0.3605,0.1208 L0.2178,0.1208 L0.2178,0.0092 Z M0,0.0092 L0.1432,0.0092 L0.1432,0.1208 L0,0.1208 L0,0.0092 Z M0,0.0092 L0.1432,0.0092 L0.1432,0.1208 L0,0.1208 L0,0.0092 Z M0,0.0092 L0.1432,0.0092 L0.1432,0.1208 L0,0.1208 L0,0.0092 Z M0.8574,0.3217 L0.8574,0.4098 L0.9691,0.4098 L0.9691,0.3217 L0.8574,0.3217 Z M0.8419,0.2978 L0.9846,0.2978 Q0.9892,0.2978,0.9928,0.2997 T0.9982,0.3043 T1,0.31 L1,0.4216 Q1,0.427,0.9951,0.4304 T0.9846,0.4337 L0.8419,0.4337 Q0.8352,0.4337,0.8308,0.4299 T0.8265,0.4216 L0.8265,0.31 Q0.8265,0.3062,0.829,0.3035 T0.835,0.2993 T0.8419,0.2978 Z M0.8574,0.888 L0.8574,0.9757 L0.9691,0.9757 L0.9691,0.888 L0.8574,0.888 Z M0.8419,0.8637 L0.9846,0.8637 Q0.9892,0.8637,0.9928,0.8658 T0.9982,0.8706 T1,0.8758 L1,0.9878 Q1,0.9929,0.9951,0.9964 T0.9846,1 L0.8419,1 Q0.8352,1,0.8308,0.996 T0.8265,0.9878 L0.8265,0.8758 Q0.8265,0.8708,0.8314,0.8672 T0.8419,0.8637 Z M0.6509,0.169 L0.6509,0.2706 L0.7806,0.2706 L0.7806,0.169 L0.6509,0.169 Z M0.6442,0.159 L0.7868,0.159 Q0.7899,0.159,0.7917,0.1604 T0.7935,0.164 L0.7935,0.2756 Q0.7935,0.2781,0.7915,0.2796 T0.7868,0.281 L0.6442,0.281 Q0.6416,0.281,0.6395,0.2794 T0.6375,0.2756 L0.6375,0.164 Q0.6375,0.1619,0.6398,0.1604 T0.6442,0.159 Z M0.6632,0.6044 L0.6632,0.6858 L0.7678,0.6858 L0.7678,0.6044 L0.6632,0.6044 Z M0.6442,0.5742 L0.7868,0.5742 Q0.7951,0.5742,0.8007,0.5791 T0.8064,0.5893 L0.8064,0.7013 Q0.8064,0.7076,0.8002,0.712 T0.7868,0.7164 L0.6442,0.7164 Q0.6359,0.7164,0.6305,0.7114 T0.6251,0.7013 L0.6251,0.5893 Q0.6251,0.5847,0.6282,0.5812 T0.6357,0.5759 T0.6442,0.5742 Z M0.4264,0.164 L0.5695,0.164 L0.5695,0.2756 L0.4264,0.2756 L0.4264,0.164 Z M0.4325,0.315 L0.4325,0.4165 L0.5628,0.4165 L0.5628,0.315 L0.4325,0.315 Z M0.4264,0.3049 L0.5695,0.3049 Q0.5721,0.3049,0.5739,0.3064 T0.5757,0.31 L0.5757,0.4216 Q0.5757,0.4237,0.5736,0.4251 T0.5695,0.4266 L0.4264,0.4266 Q0.4238,0.4266,0.422,0.4251 T0.4202,0.4216 L0.4202,0.31 Q0.4202,0.3087,0.4207,0.3077 T0.4222,0.306 T0.4243,0.3052 T0.4264,0.3049 Z M0.4264,0.4476 L0.5695,0.4476 L0.5695,0.5596 L0.4264,0.5596 L0.4264,0.4476 Z M0.4392,0.7408 L0.4392,0.8326 L0.5561,0.8326 L0.5561,0.7408 L0.4392,0.7408 Z M0.4264,0.7206 L0.5695,0.7206 Q0.5747,0.7206,0.5783,0.724 T0.5819,0.7307 L0.5819,0.8427 Q0.5819,0.8469,0.5778,0.8498 T0.5695,0.8528 L0.4264,0.8528 Q0.4207,0.8528,0.4171,0.8496 T0.4135,0.8427 L0.4135,0.7307 Q0.4135,0.7265,0.4176,0.7236 T0.4264,0.7206 Z M0.2178,0.164 L0.3605,0.164 L0.3605,0.2756 L0.2178,0.2756 L0.2178,0.164 Z M0.2178,0.31 L0.3605,0.31 L0.3605,0.4216 L0.2178,0.4216 L0.2178,0.31 Z M0.2178,0.5893 L0.3605,0.5893 L0.3605,0.7013 L0.2178,0.7013 L0.2178,0.5893 Z M0.2178,0.7307 L0.3605,0.7307 L0.3605,0.8427 L0.2178,0.8427 L0.2178,0.7307 Z M0.2178,0.8758 L0.3605,0.8758 L0.3605,0.9878 L0.2178,0.9878 L0.2178,0.8758 Z M0,0.164 L0.1432,0.164 L0.1432,0.2756 L0,0.2756 L0,0.164 Z M0,0.31 L0.1432,0.31 L0.1432,0.4216 L0,0.4216 L0,0.31 Z M0,0.4476 L0.1432,0.4476 L0.1432,0.5596 L0,0.5596 L0,0.4476 Z M0,0.5893 L0.1432,0.5893 L0.1432,0.7013 L0,0.7013 L0,0.5893 Z M0,0.7307 L0.1432,0.7307 L0.1432,0.8427 L0,0.8427 L0,0.7307 Z M0,0.8758 L0.1432,0.8758 L0.1432,0.9878 L0,0.9878 L0,0.8758 Z",type:0}},"":{type:5,data:{d:"M0.3476,0.018 L0.3476,0.112 L0.2276,0.112 L0.2276,0.018 L0.3476,0.018 Z M0.3594,0 L0.2163,0 Q0.2132,0,0.2104,0.0015 T0.2062,0.005 T0.2049,0.0092 L0.2049,0.1208 Q0.2049,0.1237,0.2067,0.1258 T0.2111,0.129 T0.2163,0.13 L0.3594,0.13 Q0.3641,0.13,0.3674,0.1271 T0.3708,0.1208 L0.3708,0.0092 Q0.3708,0.005,0.3669,0.0025 T0.3594,0 Z M0.3476,0.018 L0.3476,0.112 L0.2276,0.112 L0.2276,0.018 L0.3476,0.018 Z M0.3594,0 L0.2163,0 Q0.2132,0,0.2104,0.0015 T0.2062,0.005 T0.2049,0.0092 L0.2049,0.1208 Q0.2049,0.1237,0.2067,0.1258 T0.2111,0.129 T0.2163,0.13 L0.3594,0.13 Q0.3641,0.13,0.3674,0.1271 T0.3708,0.1208 L0.3708,0.0092 Q0.3708,0.005,0.3669,0.0025 T0.3594,0 Z M0.3476,0.018 L0.3476,0.112 L0.2276,0.112 L0.2276,0.018 L0.3476,0.018 Z M0.3594,0 L0.2163,0 Q0.2132,0,0.2104,0.0015 T0.2062,0.005 T0.2049,0.0092 L0.2049,0.1208 Q0.2049,0.1237,0.2067,0.1258 T0.2111,0.129 T0.2163,0.13 L0.3594,0.13 Q0.3641,0.13,0.3674,0.1271 T0.3708,0.1208 L0.3708,0.0092 Q0.3708,0.005,0.3669,0.0025 T0.3594,0 Z M0.5675,0.0143 L0.5675,0.1158 L0.4377,0.1158 L0.4377,0.0143 L0.5675,0.0143 Z M0.5736,0.0042 L0.431,0.0042 Q0.4284,0.0042,0.4264,0.0057 T0.4243,0.0092 L0.4243,0.1208 Q0.4243,0.1221,0.4251,0.1231 T0.4269,0.1248 T0.4289,0.1256 T0.431,0.1258 L0.5736,0.1258 Q0.5767,0.1258,0.5785,0.1244 T0.5803,0.1208 L0.5803,0.0092 Q0.5803,0.008,0.5798,0.0069 T0.5783,0.0052 T0.5762,0.0044 T0.5736,0.0042 Z M0.5675,0.0143 L0.5675,0.1158 L0.4377,0.1158 L0.4377,0.0143 L0.5675,0.0143 Z M0.5736,0.0042 L0.431,0.0042 Q0.4284,0.0042,0.4264,0.0057 T0.4243,0.0092 L0.4243,0.1208 Q0.4243,0.1221,0.4251,0.1231 T0.4269,0.1248 T0.4289,0.1256 T0.431,0.1258 L0.5736,0.1258 Q0.5767,0.1258,0.5785,0.1244 T0.5803,0.1208 L0.5803,0.0092 Q0.5803,0.008,0.5798,0.0069 T0.5783,0.0052 T0.5762,0.0044 T0.5736,0.0042 Z M0.5675,0.0143 L0.5675,0.1158 L0.4377,0.1158 L0.4377,0.0143 L0.5675,0.0143 Z M0.5736,0.0042 L0.431,0.0042 Q0.4284,0.0042,0.4264,0.0057 T0.4243,0.0092 L0.4243,0.1208 Q0.4243,0.1221,0.4251,0.1231 T0.4269,0.1248 T0.4289,0.1256 T0.431,0.1258 L0.5736,0.1258 Q0.5767,0.1258,0.5785,0.1244 T0.5803,0.1208 L0.5803,0.0092 Q0.5803,0.008,0.5798,0.0069 T0.5783,0.0052 T0.5762,0.0044 T0.5736,0.0042 Z M0.7827,0.0092 L0.6395,0.0092 L0.6395,0.1208 L0.7827,0.1208 L0.7827,0.0092 Z M0.7827,0.0092 L0.6395,0.0092 L0.6395,0.1208 L0.7827,0.1208 L0.7827,0.0092 Z M0.7827,0.0092 L0.6395,0.0092 L0.6395,0.1208 L0.7827,0.1208 L0.7827,0.0092 Z M1,0.0092 L0.8574,0.0092 L0.8574,0.1208 L1,0.1208 L1,0.0092 Z M1,0.0092 L0.8574,0.0092 L0.8574,0.1208 L1,0.1208 L1,0.0092 Z M1,0.0092 L0.8574,0.0092 L0.8574,0.1208 L1,0.1208 L1,0.0092 Z M0.1432,0.3217 L0.1432,0.4098 L0.0309,0.4098 L0.0309,0.3217 L0.1432,0.3217 Z M0.1586,0.2978 L0.0154,0.2978 Q0.0088,0.2978,0.0044,0.3016 T0,0.31 L0,0.4216 Q0,0.427,0.0049,0.4304 T0.0154,0.4337 L0.1586,0.4337 Q0.1648,0.4337,0.1694,0.4299 T0.174,0.4216 L0.174,0.31 Q0.174,0.3062,0.1715,0.3035 T0.1653,0.2993 T0.1586,0.2978 Z M0.1432,0.888 L0.1432,0.9757 L0.0309,0.9757 L0.0309,0.888 L0.1432,0.888 Z M0.1586,0.8637 L0.0154,0.8637 Q0.0108,0.8637,0.0072,0.8658 T0.0018,0.8706 T0,0.8758 L0,0.9878 Q0,0.9929,0.0049,0.9964 T0.0154,1 L0.1586,1 Q0.1648,1,0.1694,0.996 T0.174,0.9878 L0.174,0.8758 Q0.174,0.8725,0.1715,0.8695 T0.1653,0.8651 T0.1586,0.8637 Z M0.3496,0.169 L0.3496,0.2706 L0.2194,0.2706 L0.2194,0.169 L0.3496,0.169 Z M0.3563,0.159 L0.2132,0.159 Q0.2106,0.159,0.2088,0.1604 T0.207,0.164 L0.207,0.2756 Q0.207,0.2781,0.2091,0.2796 T0.2132,0.281 L0.3563,0.281 Q0.3589,0.281,0.3607,0.2794 T0.3625,0.2756 L0.3625,0.164 Q0.3625,0.1619,0.3605,0.1604 T0.3563,0.159 Z M0.3368,0.6044 L0.3368,0.6858 L0.2327,0.6858 L0.2327,0.6044 L0.3368,0.6044 Z M0.3563,0.5742 L0.2132,0.5742 Q0.2049,0.5742,0.1993,0.5791 T0.1936,0.5893 L0.1936,0.7013 Q0.1936,0.7076,0.2001,0.712 T0.2132,0.7164 L0.3563,0.7164 Q0.3641,0.7164,0.3697,0.7114 T0.3754,0.7013 L0.3754,0.5893 Q0.3754,0.5847,0.3723,0.5812 T0.3648,0.5759 T0.3563,0.5742 Z M0.5736,0.164 L0.431,0.164 L0.431,0.2756 L0.5736,0.2756 L0.5736,0.164 Z M0.5675,0.315 L0.5675,0.4165 L0.4377,0.4165 L0.4377,0.315 L0.5675,0.315 Z M0.5736,0.3049 L0.431,0.3049 Q0.4284,0.3049,0.4264,0.3064 T0.4243,0.31 L0.4243,0.4216 Q0.4243,0.4237,0.4266,0.4251 T0.431,0.4266 L0.5736,0.4266 Q0.5767,0.4266,0.5785,0.4251 T0.5803,0.4216 L0.5803,0.31 Q0.5803,0.3087,0.5798,0.3077 T0.5783,0.306 T0.5762,0.3052 T0.5736,0.3049 Z M0.5736,0.4476 L0.431,0.4476 L0.431,0.5596 L0.5736,0.5596 L0.5736,0.4476 Z M0.5613,0.7408 L0.5613,0.8326 L0.4439,0.8326 L0.4439,0.7408 L0.5613,0.7408 Z M0.5736,0.7206 L0.431,0.7206 Q0.4253,0.7206,0.4217,0.724 T0.4181,0.7307 L0.4181,0.8427 Q0.4181,0.8469,0.4222,0.8498 T0.431,0.8528 L0.5736,0.8528 Q0.5778,0.8528,0.5808,0.8511 T0.5855,0.8471 T0.587,0.8427 L0.587,0.7307 Q0.587,0.7265,0.5826,0.7236 T0.5736,0.7206 Z M0.7827,0.164 L0.6395,0.164 L0.6395,0.2756 L0.7827,0.2756 L0.7827,0.164 Z M0.7827,0.31 L0.6395,0.31 L0.6395,0.4216 L0.7827,0.4216 L0.7827,0.31 Z M0.7827,0.5893 L0.6395,0.5893 L0.6395,0.7013 L0.7827,0.7013 L0.7827,0.5893 Z M0.7827,0.7307 L0.6395,0.7307 L0.6395,0.8427 L0.7827,0.8427 L0.7827,0.7307 Z M0.7827,0.8758 L0.6395,0.8758 L0.6395,0.9878 L0.7827,0.9878 L0.7827,0.8758 Z M1,0.164 L0.8574,0.164 L0.8574,0.2756 L1,0.2756 L1,0.164 Z M1,0.31 L0.8574,0.31 L0.8574,0.4216 L1,0.4216 L1,0.31 Z M1,0.4476 L0.8574,0.4476 L0.8574,0.5596 L1,0.5596 L1,0.4476 Z M1,0.5893 L0.8574,0.5893 L0.8574,0.7013 L1,0.7013 L1,0.5893 Z M1,0.7307 L0.8574,0.7307 L0.8574,0.8427 L1,0.8427 L1,0.7307 Z M1,0.8758 L0.8574,0.8758 L0.8574,0.9878 L1,0.9878 L1,0.8758 Z",type:0}},"":{type:5,data:{d:"M0.0008,0.9979 Q0.0008,1,0.0032,1 Q0.0482,1,0.0602,0.9975 Q0.0667,0.9963,0.0847,0.9917 T0.1084,0.9859 Q0.1124,0.9851,0.1221,0.9851 L0.1253,0.9851 L0.1285,0.9851 Q0.1518,0.9851,0.1655,0.9809 Q0.1695,0.9801,0.1731,0.9788 T0.1791,0.9766 T0.1839,0.9747 T0.1888,0.9732 L0.1936,0.972 T0.1988,0.9712 T0.2048,0.971 L0.2096,0.971 Q0.2201,0.9714,0.2233,0.9714 T0.2345,0.9693 Q0.2386,0.9685,0.2502,0.9674 T0.2715,0.966 L0.2811,0.9656 Q0.2916,0.9647,0.2916,0.9573 Q0.2916,0.954,0.2892,0.9515 T0.2819,0.9486 Q0.2755,0.9482,0.2683,0.9482 Q0.2643,0.9482,0.2582,0.9484 T0.2498,0.9486 Q0.2426,0.9486,0.2402,0.9473 Q0.2386,0.9469,0.2317,0.943 T0.2161,0.937 Q0.2104,0.9357,0.1992,0.933 T0.1831,0.9291 Q0.1807,0.9287,0.1783,0.9285 T0.1739,0.928 T0.1703,0.9276 T0.1675,0.9272 T0.1655,0.9266 T0.1639,0.9253 Q0.1598,0.9216,0.1462,0.9216 L0.143,0.9216 L0.1398,0.9216 L0.1365,0.9216 Q0.1197,0.9195,0.1197,0.9154 L0.1197,0.9154 Q0.1205,0.9121,0.1373,0.9088 T0.1703,0.9054 Q0.1791,0.9054,0.1863,0.904 T0.1984,0.9011 T0.2064,0.8992 Q0.2402,0.8967,0.2506,0.8934 Q0.2538,0.8926,0.2602,0.8899 T0.2707,0.8872 Q0.2715,0.8872,0.2731,0.8876 Q0.2795,0.8884,0.2884,0.8884 Q0.3068,0.8884,0.3092,0.8826 L0.3092,0.8797 Q0.3092,0.8772,0.3076,0.8747 T0.3044,0.8706 T0.3028,0.8681 Q0.3076,0.8656,0.3237,0.8656 Q0.3317,0.8656,0.3622,0.8623 Q0.3655,0.8623,0.3867,0.8617 T0.4217,0.8602 Q0.4241,0.8598,0.4289,0.8598 L0.4345,0.8598 L0.441,0.8598 Q0.4578,0.8598,0.4667,0.8586 Q0.4739,0.8573,0.4851,0.8567 T0.5004,0.8552 Q0.5012,0.8552,0.5108,0.855 T0.5269,0.853 T0.5333,0.8461 Q0.5333,0.8445,0.5325,0.8432 T0.5309,0.8409 T0.5289,0.8391 T0.5261,0.8378 L0.5229,0.837 T0.5185,0.8362 T0.5133,0.8355 T0.5076,0.8349 T0.502,0.8341 Q0.4932,0.8324,0.4859,0.8324 Q0.4827,0.8324,0.4787,0.8328 T0.4731,0.8333 Q0.4707,0.8333,0.4683,0.8324 Q0.4482,0.825,0.4394,0.825 Q0.4369,0.825,0.4345,0.8254 Q0.4225,0.827,0.4153,0.827 Q0.4088,0.827,0.4064,0.8258 Q0.3976,0.8204,0.3751,0.8204 Q0.3703,0.8204,0.3667,0.8214 T0.3622,0.8225 Q0.3598,0.8225,0.3558,0.82 Q0.351,0.8175,0.3402,0.8167 T0.3177,0.8156 T0.3028,0.8146 L0.2956,0.8121 T0.2871,0.8094 T0.2771,0.8073 T0.2635,0.8063 Q0.261,0.8063,0.2586,0.8067 Q0.2378,0.8071,0.2273,0.8071 Q0.2072,0.8071,0.2024,0.8051 Q0.1976,0.8034,0.1932,0.8026 T0.1867,0.8013 T0.1847,0.8001 L0.1847,0.7993 Q0.1855,0.7984,0.1855,0.7978 T0.1859,0.7966 T0.1867,0.7959 T0.188,0.7955 T0.1896,0.7951 T0.1916,0.7949 T0.1944,0.7945 T0.1984,0.7941 T0.2032,0.7939 Q0.212,0.7926,0.2325,0.7918 T0.2562,0.7905 Q0.2691,0.7893,0.2787,0.7847 Q0.2835,0.7827,0.2968,0.7791 T0.3149,0.7756 Q0.3189,0.7756,0.3305,0.7733 T0.3446,0.771 L0.3454,0.771 Q0.3462,0.771,0.3498,0.7721 T0.3574,0.774 T0.3655,0.7748 Q0.3703,0.7748,0.3743,0.7731 T0.3823,0.7708 T0.3916,0.77 T0.3992,0.7694 Q0.4008,0.7694,0.4076,0.7688 T0.4205,0.7675 L0.4305,0.7665 Q0.4345,0.7657,0.4402,0.7617 T0.4458,0.7545 Q0.4458,0.7503,0.4353,0.7487 Q0.4297,0.7478,0.4209,0.7462 T0.4044,0.7433 T0.3904,0.7416 L0.3847,0.7416 Q0.3807,0.7416,0.3747,0.7422 T0.3663,0.7428 T0.3606,0.7424 Q0.3582,0.742,0.3562,0.7418 T0.3522,0.7412 T0.3482,0.7406 T0.3446,0.7401 T0.341,0.7397 T0.3373,0.7393 T0.3341,0.7391 L0.3293,0.7391 Q0.3277,0.7395,0.3253,0.7395 Q0.3205,0.7395,0.3052,0.7387 T0.2835,0.7379 Q0.2755,0.7379,0.253,0.7325 Q0.2506,0.7316,0.2462,0.731 T0.2382,0.7296 T0.2305,0.7271 T0.2181,0.7234 T0.2048,0.7196 T0.2,0.7155 Q0.2,0.7142,0.2016,0.713 Q0.208,0.7059,0.2285,0.6978 T0.2618,0.6898 Q0.2739,0.6898,0.2831,0.6848 T0.2956,0.6794 Q0.3028,0.6786,0.3289,0.6765 T0.3566,0.674 Q0.3582,0.674,0.3855,0.6723 T0.4406,0.6688 T0.4755,0.6653 Q0.5004,0.6607,0.5124,0.6599 L0.5165,0.6599 Q0.5213,0.6599,0.5277,0.6605 T0.5373,0.6611 Q0.543,0.6611,0.5494,0.6599 Q0.592,0.6524,0.6,0.6524 Q0.6064,0.6524,0.61,0.6499 T0.6161,0.6474 Q0.6177,0.6474,0.6261,0.6495 T0.6418,0.6516 L0.6482,0.6516 Q0.653,0.6512,0.6651,0.6506 T0.6876,0.6493 T0.7084,0.6477 T0.7229,0.645 Q0.7269,0.6437,0.7333,0.6437 Q0.7373,0.6437,0.7458,0.6443 T0.7574,0.645 Q0.7614,0.645,0.7631,0.6445 T0.7655,0.6441 Q0.7671,0.6441,0.7723,0.6448 T0.7823,0.6454 Q0.788,0.6454,0.7952,0.6445 Q0.8233,0.6408,0.8723,0.6367 Q0.9012,0.6342,0.9092,0.6342 L0.9165,0.6342 L0.9205,0.6342 Q0.9277,0.6342,0.9382,0.6323 T0.9526,0.6304 Q0.9534,0.6304,0.9594,0.6307 T0.9695,0.6309 Q0.9976,0.6309,0.9992,0.6234 Q1,0.6201,1,0.618 Q1,0.6089,0.9775,0.608 Q0.9703,0.6076,0.9582,0.6076 Q0.9518,0.6076,0.9394,0.6078 T0.9213,0.608 Q0.9036,0.608,0.8972,0.6072 Q0.894,0.6068,0.8871,0.6058 T0.8751,0.6039 T0.8627,0.6024 T0.8506,0.6018 L0.8474,0.6018 Q0.841,0.6022,0.8281,0.6041 T0.8112,0.606 Q0.8096,0.606,0.808,0.6056 Q0.7783,0.6002,0.7647,0.6002 Q0.7598,0.6002,0.7454,0.6006 T0.7261,0.601 Q0.7221,0.601,0.7145,0.6022 T0.7036,0.6035 Q0.6996,0.6035,0.6964,0.6022 Q0.6723,0.5902,0.6442,0.5902 Q0.6426,0.5902,0.6386,0.5904 T0.6337,0.5906 Q0.6273,0.5906,0.6249,0.5894 L0.6177,0.5856 T0.6116,0.5838 T0.6016,0.5825 T0.5855,0.5823 Q0.5719,0.5823,0.5574,0.5798 T0.5373,0.5774 L0.5341,0.5774 Q0.5293,0.5778,0.5213,0.5786 T0.51,0.5794 Q0.5036,0.5794,0.4988,0.5769 Q0.4932,0.574,0.4771,0.574 Q0.4723,0.574,0.4631,0.5745 T0.4498,0.5749 Q0.4418,0.5749,0.4394,0.5736 Q0.4353,0.5724,0.4305,0.5715 T0.4225,0.5707 T0.4145,0.5705 T0.4056,0.5699 Q0.4008,0.5691,0.398,0.5689 T0.394,0.5689 T0.3908,0.5686 T0.3855,0.5674 Q0.3831,0.567,0.3811,0.5662 T0.3779,0.5645 T0.3743,0.563 T0.3695,0.5624 Q0.3655,0.5624,0.3594,0.5635 T0.3494,0.5645 T0.3406,0.5635 T0.3325,0.5624 Q0.3309,0.5624,0.3301,0.5628 L0.3141,0.5628 Q0.2635,0.5628,0.2506,0.5612 Q0.2474,0.5608,0.2434,0.5608 Q0.2402,0.5608,0.2349,0.561 T0.2273,0.5612 Q0.2209,0.5612,0.2177,0.5595 Q0.2145,0.557,0.2145,0.5558 Q0.2169,0.5537,0.2345,0.5521 Q0.2876,0.5475,0.3028,0.5425 Q0.3068,0.5413,0.3149,0.5396 T0.3309,0.5367 T0.3478,0.5338 T0.3606,0.5309 Q0.3631,0.5305,0.3755,0.5259 T0.3968,0.5214 Q0.3992,0.5214,0.4024,0.5218 T0.4096,0.5222 Q0.4161,0.5222,0.4213,0.5209 T0.4313,0.5185 T0.4402,0.5172 Q0.4418,0.5168,0.447,0.5168 L0.4558,0.5168 T0.4639,0.5162 T0.4707,0.5141 T0.4731,0.5102 Q0.4731,0.5089,0.4723,0.5081 Q0.4699,0.5019,0.4627,0.4994 T0.4369,0.4965 Q0.4273,0.4961,0.4193,0.4946 T0.4048,0.4915 T0.3952,0.4894 Q0.392,0.4886,0.388,0.4886 Q0.3847,0.4886,0.3775,0.4892 T0.3647,0.4898 Q0.3598,0.4898,0.355,0.4894 Q0.3165,0.4861,0.3141,0.4853 Q0.2779,0.4774,0.2715,0.4774 Q0.2699,0.4774,0.2683,0.4776 T0.2627,0.4778 Q0.2498,0.4778,0.2281,0.4762 Q0.2241,0.4749,0.2233,0.4737 Q0.2249,0.472,0.2321,0.4708 Q0.2402,0.4695,0.2554,0.4695 L0.2675,0.4695 L0.2795,0.4695 Q0.294,0.4695,0.2996,0.4679 Q0.3141,0.4629,0.3373,0.4616 Q0.3414,0.4612,0.3466,0.4606 T0.3582,0.4589 T0.3687,0.4562 T0.3727,0.4525 Q0.3727,0.4509,0.3703,0.4492 Q0.3639,0.4455,0.3474,0.4419 T0.3213,0.4384 L0.3157,0.4384 L0.31,0.4384 Q0.294,0.4384,0.2859,0.4363 Q0.2795,0.4347,0.2691,0.4347 L0.2618,0.4347 L0.2546,0.4347 Q0.2458,0.4347,0.2394,0.4338 Q0.2257,0.4318,0.2193,0.4303 T0.2092,0.4266 T0.2052,0.4224 T0.2024,0.4154 T0.196,0.4052 Q0.1912,0.3994,0.1867,0.3949 T0.1807,0.3884 T0.1791,0.3849 Q0.1791,0.3824,0.1839,0.3745 Q0.1871,0.3687,0.1944,0.3637 T0.2072,0.3561 T0.2221,0.3501 T0.2321,0.3463 Q0.2353,0.3455,0.241,0.3445 T0.2522,0.3428 T0.2639,0.3411 T0.2731,0.3384 T0.2956,0.3351 T0.3197,0.3326 Q0.3213,0.3322,0.3237,0.3322 T0.3325,0.3331 T0.3414,0.3339 Q0.3478,0.3339,0.3518,0.3314 Q0.3606,0.3264,0.3703,0.3264 Q0.3775,0.3264,0.3847,0.3293 Q0.3888,0.331,0.396,0.331 Q0.4024,0.331,0.4116,0.3295 T0.4265,0.3266 T0.4414,0.3227 T0.4514,0.3202 Q0.4578,0.3181,0.4839,0.3152 T0.5112,0.3123 T0.5177,0.3119 T0.5285,0.3111 T0.5398,0.3096 T0.549,0.3065 T0.5526,0.3015 Q0.5526,0.2999,0.5518,0.2982 Q0.547,0.2903,0.5386,0.2883 T0.5165,0.2862 Q0.5116,0.2862,0.5056,0.2866 T0.4972,0.287 Q0.4884,0.287,0.4787,0.2833 Q0.4594,0.2758,0.4265,0.2758 Q0.4169,0.2758,0.4129,0.2766 Q0.4112,0.2771,0.4104,0.2771 Q0.4088,0.2771,0.4056,0.2748 T0.3968,0.2721 Q0.3695,0.2696,0.359,0.2659 Q0.355,0.2646,0.351,0.2646 T0.3426,0.2661 T0.3365,0.2675 T0.3333,0.2659 Q0.3277,0.2605,0.3116,0.2553 T0.2859,0.2501 L0.2843,0.2501 L0.2819,0.2501 Q0.2779,0.2501,0.2723,0.2493 T0.2586,0.2472 T0.2474,0.2455 Q0.1799,0.236,0.1719,0.236 Q0.1663,0.236,0.1606,0.235 T0.1502,0.2316 T0.1454,0.2265 Q0.1454,0.2223,0.1558,0.2173 Q0.1679,0.2115,0.1859,0.2092 T0.2185,0.207 T0.2353,0.2057 Q0.2369,0.2049,0.2502,0.2041 T0.2799,0.2022 T0.302,0.2007 Q0.3084,0.1999,0.3245,0.1954 T0.347,0.1908 Q0.3502,0.1908,0.3534,0.1916 Q0.3663,0.197,0.388,0.197 Q0.404,0.197,0.4088,0.1929 Q0.4096,0.192,0.4108,0.192 T0.4177,0.1945 T0.4277,0.197 T0.4369,0.1949 Q0.4442,0.1908,0.4843,0.1875 Q0.4892,0.1871,0.4968,0.1839 T0.5084,0.1808 L0.5108,0.1808 Q0.5213,0.1825,0.5454,0.1825 Q0.5823,0.1825,0.5992,0.1779 Q0.6096,0.1746,0.6217,0.1746 Q0.6249,0.1746,0.6309,0.1748 T0.6394,0.175 Q0.6434,0.175,0.6466,0.1746 Q0.6474,0.1746,0.6594,0.1738 T0.6787,0.1713 T0.6892,0.1659 Q0.6924,0.1634,0.6924,0.1593 Q0.6924,0.1547,0.6888,0.151 T0.6795,0.1472 Q0.6779,0.1472,0.6763,0.1477 Q0.6699,0.1493,0.6667,0.1493 Q0.661,0.1493,0.6506,0.1456 Q0.6329,0.1394,0.6129,0.1394 Q0.6048,0.1394,0.5992,0.1377 T0.5888,0.136 T0.5803,0.1377 T0.5751,0.1394 Q0.5711,0.1394,0.5639,0.1369 Q0.5365,0.1273,0.5116,0.1273 Q0.4876,0.1273,0.4667,0.1253 Q0.4627,0.1248,0.4542,0.1211 T0.4337,0.1174 L0.4305,0.1174 Q0.4217,0.1178,0.4153,0.119 T0.408,0.1203 Q0.4056,0.1203,0.4,0.117 Q0.3976,0.1153,0.396,0.1136 T0.3932,0.1112 T0.39,0.1099 T0.3847,0.1095 Q0.3799,0.1095,0.3687,0.1103 Q0.355,0.1112,0.3434,0.1141 T0.3301,0.117 Q0.3261,0.117,0.3229,0.1145 Q0.3181,0.1116,0.3052,0.1087 T0.2787,0.1043 T0.2546,0.1029 Q0.2506,0.1029,0.2474,0.1033 Q0.2418,0.1037,0.2349,0.1054 T0.2249,0.107 Q0.2225,0.107,0.2193,0.1066 Q0.2024,0.1024,0.1863,0.1024 Q0.1823,0.1024,0.1562,0.0971 T0.1269,0.0917 T0.1161,0.0896 T0.106,0.0854 Q0.1076,0.0846,0.11,0.0842 Q0.1173,0.0821,0.1261,0.0821 Q0.1301,0.0821,0.1369,0.0825 T0.1462,0.083 Q0.1494,0.083,0.151,0.0825 T0.1831,0.0813 T0.2201,0.0784 T0.243,0.074 T0.2667,0.0718 Q0.2707,0.0718,0.2755,0.0724 T0.2843,0.073 T0.2936,0.0724 T0.3024,0.0705 T0.3072,0.068 T0.3092,0.0657 T0.3108,0.0647 Q0.3116,0.0643,0.3133,0.0643 L0.3157,0.0643 L0.3181,0.0643 Q0.3446,0.0643,0.3446,0.0556 T0.3205,0.0469 L0.3189,0.0469 Q0.3157,0.0469,0.3157,0.0465 Q0.3084,0.0427,0.2835,0.0386 Q0.2739,0.0369,0.2675,0.0342 T0.2538,0.0299 Q0.249,0.029,0.245,0.029 T0.2378,0.0303 T0.2321,0.0315 Q0.2305,0.0315,0.2273,0.0307 Q0.2201,0.0286,0.2004,0.0272 T0.1775,0.0245 Q0.1735,0.0228,0.1663,0.0226 T0.1522,0.0197 T0.1345,0.0145 T0.1124,0.0079 Q0.0996,0.0033,0.0671,0.0044 T0.0297,0.0041 Q0.0169,0,0.0024,0.0017 Q0,0.0021,0,0.0037 Z M0.0064,0.9954 L0.0056,0.0058 Q0.0177,0.005,0.0281,0.0083 Q0.0345,0.01,0.0675,0.0089 T0.1108,0.012 Q0.1221,0.0162,0.1329,0.0187 T0.1498,0.0236 T0.1606,0.0268 T0.1691,0.0274 T0.1759,0.0286 Q0.1807,0.0303,0.2,0.0315 T0.2257,0.0348 Q0.2305,0.0361,0.2337,0.0361 Q0.2361,0.0361,0.2398,0.0348 T0.2466,0.0336 Q0.249,0.0336,0.2522,0.034 Q0.2586,0.0353,0.2655,0.0382 T0.2827,0.0427 Q0.3068,0.0469,0.3124,0.0502 Q0.3157,0.0523,0.3237,0.0523 L0.3277,0.0523 L0.3309,0.0523 Q0.3398,0.0523,0.3398,0.0556 Q0.3398,0.0581,0.3341,0.0587 T0.3205,0.0593 T0.3092,0.0603 T0.3036,0.0643 T0.2932,0.068 Q0.2884,0.0684,0.2843,0.0684 Q0.2811,0.0684,0.2763,0.0678 T0.2667,0.0672 Q0.2586,0.0672,0.2422,0.0697 T0.2177,0.0747 Q0.2137,0.0759,0.1831,0.0767 T0.1494,0.0784 L0.1474,0.0784 T0.1398,0.078 T0.1285,0.0776 Q0.1173,0.0776,0.1084,0.08 Q0.1004,0.0817,0.1004,0.0846 Q0.1004,0.0867,0.104,0.0888 T0.1124,0.0923 T0.1213,0.0948 T0.1269,0.0958 T0.155,0.1014 T0.1863,0.107 Q0.2016,0.107,0.2185,0.1107 Q0.2217,0.1116,0.2257,0.1116 Q0.2289,0.1116,0.2365,0.1099 T0.2482,0.1074 L0.2538,0.1074 Q0.2683,0.1074,0.2912,0.1107 T0.3197,0.1182 Q0.3245,0.1215,0.3301,0.1215 Q0.3333,0.1215,0.3454,0.1184 T0.3687,0.1145 Q0.3735,0.1141,0.3779,0.1139 T0.3843,0.1134 T0.3871,0.1132 Q0.3896,0.1132,0.39,0.1136 T0.392,0.1161 T0.3968,0.1203 Q0.404,0.1248,0.408,0.1248 Q0.4096,0.1248,0.4165,0.1234 T0.4305,0.1215 L0.4337,0.1215 Q0.4442,0.1215,0.4518,0.1251 T0.4659,0.1294 Q0.4876,0.1319,0.5116,0.1319 T0.5622,0.141 Q0.5703,0.1439,0.5751,0.1439 Q0.5791,0.1439,0.5831,0.1423 T0.5888,0.1406 Q0.592,0.1406,0.5944,0.1412 T0.6012,0.1427 T0.6129,0.1435 Q0.6313,0.1435,0.649,0.1497 Q0.6602,0.1535,0.6667,0.1535 Q0.6715,0.1535,0.6779,0.1522 Q0.6787,0.1518,0.6795,0.1518 Q0.6827,0.1518,0.6847,0.1541 T0.6867,0.1593 Q0.6867,0.1618,0.6851,0.1634 Q0.6835,0.1655,0.6775,0.1667 T0.6598,0.169 T0.6458,0.1705 T0.6402,0.1709 Q0.6378,0.1709,0.6321,0.1705 T0.6225,0.1701 Q0.6096,0.1701,0.5968,0.1738 Q0.5823,0.1779,0.5446,0.1779 Q0.5205,0.1779,0.5116,0.1767 Q0.51,0.1763,0.5084,0.1763 Q0.5028,0.1763,0.4944,0.1796 T0.4835,0.1829 L0.4771,0.1833 T0.4659,0.1844 L0.4546,0.1858 T0.443,0.1881 T0.4337,0.1912 Q0.4321,0.1916,0.4305,0.1916 Q0.4273,0.1916,0.4209,0.1895 T0.412,0.1875 Q0.408,0.1875,0.4056,0.19 Q0.4024,0.1925,0.388,0.1925 Q0.3663,0.1925,0.3558,0.1879 Q0.3518,0.1862,0.3462,0.1862 Q0.3373,0.1862,0.3213,0.191 T0.3012,0.1962 Q0.2964,0.1966,0.2799,0.1976 T0.2494,0.1997 T0.2313,0.2024 L0.2313,0.2024 L0.2293,0.2024 L0.2261,0.2024 L0.2217,0.2024 Q0.204,0.2024,0.1851,0.2047 T0.1526,0.2136 Q0.1406,0.2198,0.1406,0.226 Q0.1406,0.2319,0.1518,0.2362 T0.1719,0.2406 Q0.1791,0.2406,0.2466,0.2497 Q0.2498,0.2501,0.2574,0.2516 T0.2711,0.2538 T0.2819,0.2547 L0.2851,0.2547 Q0.2851,0.2543,0.2859,0.2543 Q0.294,0.2543,0.3096,0.2592 T0.3285,0.2684 Q0.3317,0.2721,0.3373,0.2721 Q0.3406,0.2721,0.3462,0.2708 T0.3542,0.2696 Q0.3558,0.2696,0.3574,0.27 Q0.3679,0.2737,0.3968,0.2762 Q0.3984,0.2766,0.4004,0.2779 L0.4044,0.2804 T0.4096,0.2816 Q0.412,0.2816,0.4145,0.2808 Q0.4177,0.2804,0.4249,0.2804 Q0.4586,0.2804,0.4763,0.287 Q0.4867,0.2912,0.4972,0.2912 Q0.5004,0.2912,0.5064,0.2908 T0.5165,0.2903 Q0.5293,0.2903,0.5361,0.2922 T0.547,0.3003 L0.547,0.3011 Q0.547,0.3036,0.5414,0.3049 T0.5249,0.3067 T0.51,0.3082 Q0.5092,0.3082,0.4831,0.3111 T0.4498,0.3161 Q0.408,0.3264,0.3952,0.3264 Q0.3896,0.3264,0.3863,0.3252 Q0.3783,0.3223,0.3703,0.3223 Q0.359,0.3223,0.3494,0.3277 Q0.347,0.3293,0.343,0.3293 Q0.3414,0.3293,0.3353,0.3285 T0.3253,0.3277 T0.3181,0.3285 Q0.3149,0.3289,0.2952,0.3306 T0.2699,0.3347 Q0.2675,0.3364,0.2598,0.3372 T0.2434,0.3395 T0.2297,0.3426 L0.2205,0.3461 T0.2048,0.3523 T0.1908,0.3606 T0.1791,0.3725 Q0.1743,0.3803,0.1743,0.3845 Q0.1743,0.3874,0.1763,0.3901 T0.1827,0.3976 T0.1912,0.4073 T0.198,0.4189 T0.2032,0.4276 T0.2137,0.4326 T0.2386,0.438 Q0.2458,0.4392,0.2562,0.4392 L0.2639,0.4392 L0.2699,0.4392 Q0.2795,0.4392,0.2843,0.4405 Q0.2932,0.443,0.3092,0.443 L0.3157,0.443 L0.3213,0.443 Q0.3293,0.443,0.3458,0.4463 T0.3671,0.4525 Q0.3598,0.4558,0.3373,0.4571 Q0.3124,0.4587,0.298,0.4637 Q0.294,0.465,0.2811,0.465 L0.2703,0.465 L0.2586,0.465 Q0.241,0.465,0.2305,0.4666 Q0.2185,0.4687,0.2185,0.4728 Q0.2185,0.4745,0.2205,0.4764 T0.2241,0.4791 L0.2265,0.4803 L0.2273,0.4803 Q0.2506,0.4824,0.261,0.4824 Q0.2675,0.4824,0.2699,0.482 Q0.2699,0.4815,0.2707,0.4815 Q0.2771,0.4815,0.3124,0.4898 Q0.3173,0.4907,0.3229,0.4913 T0.3386,0.4925 T0.3542,0.4936 T0.3663,0.494 Q0.3711,0.494,0.3787,0.4936 T0.3888,0.4932 Q0.392,0.4932,0.3944,0.4936 T0.4032,0.4959 T0.4181,0.499 T0.4369,0.5006 Q0.449,0.501,0.455,0.5021 T0.4639,0.5048 T0.4675,0.5093 L0.4675,0.5097 Q0.4675,0.5106,0.4663,0.511 T0.4622,0.5116 L0.4566,0.512 T0.4486,0.5124 T0.4402,0.5127 Q0.4345,0.5131,0.4257,0.5153 T0.4096,0.5176 Q0.4064,0.5176,0.4024,0.5172 L0.3968,0.5172 Q0.3863,0.5172,0.3731,0.522 T0.359,0.5268 Q0.355,0.528,0.3317,0.5321 T0.3004,0.5388 Q0.2867,0.5433,0.2337,0.5479 Q0.2096,0.55,0.2096,0.5562 Q0.2096,0.5591,0.2145,0.5628 Q0.2193,0.5662,0.2289,0.5662 Q0.2313,0.5662,0.2373,0.5657 T0.2458,0.5653 L0.2498,0.5653 Q0.2635,0.5674,0.3124,0.5674 Q0.3261,0.5674,0.3301,0.567 L0.3317,0.567 Q0.3341,0.567,0.3394,0.568 T0.3486,0.5691 Q0.3542,0.5691,0.3606,0.5678 T0.3699,0.5666 T0.3759,0.5686 T0.3839,0.5718 T0.3908,0.573 T0.3964,0.5734 T0.4048,0.5742 T0.4165,0.5751 T0.4277,0.5757 T0.4369,0.5778 Q0.4426,0.5794,0.4538,0.5794 Q0.4586,0.5794,0.4679,0.5792 T0.4811,0.579 Q0.4924,0.579,0.4956,0.5807 Q0.502,0.584,0.5108,0.584 L0.5137,0.584 T0.5173,0.5838 L0.5205,0.5834 L0.5237,0.583 L0.5269,0.5825 T0.5305,0.5821 T0.5341,0.5819 L0.5365,0.5819 Q0.5414,0.5819,0.5562,0.5842 T0.5855,0.5865 Q0.5912,0.5865,0.5948,0.5867 T0.6012,0.5869 T0.6064,0.5873 T0.61,0.5877 T0.6133,0.5886 T0.6157,0.5896 L0.6185,0.591 T0.6217,0.5931 Q0.6265,0.5952,0.6369,0.5952 L0.6418,0.5952 L0.6466,0.5952 Q0.6723,0.5952,0.6932,0.606 Q0.698,0.608,0.7044,0.608 Q0.7084,0.608,0.7161,0.6068 T0.7261,0.6056 Q0.7309,0.6056,0.7454,0.6051 T0.7647,0.6047 Q0.7775,0.6047,0.8072,0.6101 Q0.8096,0.6105,0.812,0.6105 Q0.8177,0.6105,0.8297,0.6085 T0.8474,0.606 L0.8506,0.606 Q0.8562,0.606,0.8647,0.607 T0.8831,0.6095 T0.8964,0.6118 Q0.9036,0.6122,0.9221,0.6122 L0.9406,0.6122 L0.959,0.6122 L0.9767,0.6122 Q0.9952,0.613,0.9952,0.6172 Q0.9952,0.6176,0.9944,0.6221 Q0.9936,0.6259,0.9574,0.6259 L0.955,0.6259 L0.9526,0.6259 Q0.9478,0.6259,0.9373,0.628 T0.9205,0.63 L0.9173,0.63 Q0.9133,0.6296,0.9084,0.6296 Q0.9004,0.6296,0.8715,0.6321 Q0.8233,0.6367,0.7944,0.64 Q0.7888,0.6408,0.7839,0.6408 T0.7739,0.6402 T0.7671,0.6396 Q0.7639,0.6396,0.7622,0.64 Q0.7614,0.6404,0.759,0.6404 Q0.7574,0.6404,0.749,0.6398 T0.7357,0.6392 Q0.7261,0.6392,0.7213,0.6412 Q0.7173,0.6425,0.7032,0.6437 T0.6711,0.6458 T0.6474,0.647 Q0.645,0.6474,0.6418,0.6474 Q0.6353,0.6474,0.6277,0.6454 T0.6161,0.6433 Q0.6104,0.6433,0.6072,0.6456 T0.6,0.6479 Q0.5912,0.6479,0.5486,0.6557 Q0.5422,0.657,0.5373,0.657 Q0.5349,0.657,0.5289,0.6564 T0.5173,0.6557 L0.5124,0.6557 Q0.4996,0.6562,0.4739,0.6611 Q0.4675,0.6624,0.4398,0.6645 T0.3851,0.668 T0.3558,0.6698 Q0.355,0.6698,0.3285,0.6721 T0.2948,0.6752 Q0.2892,0.6761,0.2843,0.6786 T0.2747,0.6831 T0.2618,0.6852 Q0.253,0.6852,0.2394,0.6893 T0.2141,0.6993 T0.1968,0.7105 Q0.1944,0.713,0.1944,0.7155 Q0.1944,0.7196,0.2012,0.7229 T0.2177,0.7285 T0.2281,0.7308 Q0.2321,0.7329,0.2365,0.7339 T0.245,0.7356 T0.2514,0.7366 Q0.2522,0.737,0.2554,0.7379 T0.2614,0.7393 T0.2679,0.7406 T0.2755,0.7416 T0.2835,0.742 Q0.29,0.742,0.3048,0.7428 T0.3253,0.7437 L0.3301,0.7437 L0.3333,0.7437 Q0.3341,0.7437,0.3598,0.7466 Q0.3639,0.7474,0.3671,0.7474 T0.3759,0.7466 T0.3855,0.7457 Q0.388,0.7457,0.3904,0.7462 Q0.3984,0.7466,0.4137,0.7495 T0.4349,0.7532 T0.441,0.7557 Q0.441,0.7599,0.4289,0.7619 Q0.4257,0.7628,0.4197,0.7634 T0.4072,0.7644 T0.3984,0.7652 Q0.3968,0.7652,0.3912,0.7655 T0.3811,0.7665 T0.3719,0.7694 Q0.3695,0.7702,0.3655,0.7702 T0.3546,0.7686 T0.3462,0.7665 L0.3446,0.7665 Q0.3406,0.7665,0.3293,0.769 T0.3149,0.7715 Q0.3084,0.7715,0.2952,0.7748 T0.2763,0.781 Q0.2675,0.7847,0.2554,0.7864 Q0.253,0.7864,0.2325,0.7874 T0.2024,0.7893 Q0.2008,0.7893,0.1984,0.7897 T0.1948,0.7901 T0.1916,0.7903 T0.1888,0.7908 T0.1867,0.7914 T0.1847,0.7922 L0.1831,0.793 T0.1819,0.7943 L0.1811,0.7959 T0.1799,0.7976 Q0.1791,0.7993,0.1791,0.8001 Q0.1791,0.8034,0.1831,0.8051 T0.1932,0.8078 T0.2,0.8092 Q0.2072,0.8117,0.2257,0.8117 Q0.2337,0.8117,0.2586,0.8109 L0.2635,0.8109 Q0.2707,0.8109,0.2767,0.8117 T0.2859,0.8136 T0.2936,0.8163 T0.3012,0.8187 Q0.3068,0.82,0.3277,0.8206 T0.3526,0.8237 Q0.3582,0.8266,0.3622,0.8266 Q0.3647,0.8266,0.3687,0.8258 T0.3751,0.825 Q0.396,0.825,0.404,0.8291 Q0.408,0.8316,0.4161,0.8316 Q0.4217,0.8316,0.4353,0.8295 L0.4394,0.8295 Q0.4466,0.8295,0.4659,0.8366 Q0.4699,0.8378,0.4747,0.8378 Q0.4763,0.8378,0.4807,0.8374 T0.4884,0.837 Q0.494,0.837,0.5004,0.8382 Q0.5052,0.8391,0.5124,0.8399 Q0.5221,0.8411,0.5249,0.8422 T0.5277,0.8461 Q0.5277,0.8482,0.5233,0.849 T0.5112,0.8501 T0.4996,0.8511 Q0.4964,0.8519,0.4851,0.8523 T0.4659,0.8544 Q0.4578,0.8557,0.4402,0.8557 L0.4349,0.8557 L0.4297,0.8557 L0.4209,0.8557 Q0.408,0.8565,0.3867,0.8571 T0.3614,0.8582 Q0.3317,0.8611,0.3237,0.8611 L0.3225,0.8611 L0.3213,0.8611 Q0.2972,0.8611,0.2972,0.8681 Q0.2972,0.8714,0.3008,0.8747 T0.3044,0.8805 Q0.3044,0.881,0.3036,0.8814 Q0.3012,0.8839,0.2851,0.8839 Q0.2779,0.8839,0.2739,0.883 Q0.2723,0.8826,0.2699,0.8826 T0.2643,0.8835 T0.259,0.8853 T0.2542,0.8876 T0.249,0.8893 Q0.2386,0.8922,0.2056,0.8946 Q0.2016,0.8951,0.1916,0.898 T0.1703,0.9009 Q0.1518,0.9009,0.1337,0.9044 T0.1149,0.9146 L0.1149,0.9158 Q0.1149,0.9175,0.1157,0.9187 T0.1173,0.921 T0.1201,0.9226 T0.1233,0.9237 T0.1269,0.9245 L0.1305,0.9251 T0.1337,0.9255 L0.1357,0.9258 Q0.139,0.9262,0.1446,0.9262 T0.1542,0.9266 T0.1598,0.9282 Q0.1614,0.9303,0.1647,0.9314 T0.1739,0.9328 T0.1815,0.9336 Q0.1863,0.9345,0.1976,0.9372 T0.2145,0.9415 Q0.2225,0.9432,0.2285,0.9467 T0.2378,0.9515 Q0.2426,0.9531,0.2514,0.9531 Q0.2538,0.9531,0.2602,0.9529 T0.2707,0.9527 Q0.2763,0.9527,0.2815,0.9531 T0.2867,0.9569 T0.2811,0.9614 Q0.2434,0.9627,0.2329,0.9652 Q0.2249,0.9672,0.2241,0.9672 L0.2096,0.9668 L0.2056,0.9668 Q0.2,0.9668,0.196,0.9672 T0.1884,0.9687 T0.1815,0.9708 T0.1731,0.9737 T0.1639,0.9772 Q0.1518,0.9805,0.1285,0.9805 L0.1253,0.9805 Q0.1124,0.9805,0.1076,0.9818 Q0.1012,0.983,0.0831,0.9876 T0.0594,0.9934 Q0.049,0.9954,0.0064,0.9954 Z M0.0032,0.9979 L0.0024,0.0037 Q0.0161,0.0021,0.0289,0.0062 Q0.0337,0.0075,0.0671,0.0066 T0.1116,0.01 T0.1337,0.0166 T0.151,0.022 Q0.1582,0.0249,0.1659,0.0251 T0.1767,0.0265 Q0.1807,0.0278,0.2,0.0292 T0.2265,0.0328 Q0.2305,0.034,0.2329,0.034 T0.239,0.0326 T0.2458,0.0311 T0.253,0.0319 Q0.2578,0.0332,0.2614,0.0342 T0.2667,0.0363 T0.2723,0.0384 T0.2827,0.0406 Q0.3084,0.0448,0.3141,0.0485 Q0.3149,0.0494,0.3225,0.0494 T0.3361,0.0504 T0.3422,0.0554 T0.3357,0.0606 T0.3205,0.0618 T0.31,0.0626 Q0.3092,0.0626,0.3056,0.0659 T0.2932,0.0701 Q0.2884,0.0709,0.2843,0.0709 Q0.2811,0.0709,0.2759,0.0701 T0.2667,0.0693 Q0.2586,0.0693,0.2422,0.0718 T0.2193,0.0763 Q0.2137,0.0784,0.1831,0.079 T0.1502,0.0805 Q0.1494,0.0809,0.147,0.0809 Q0.1454,0.0809,0.1386,0.0803 T0.1277,0.0796 Q0.1173,0.0796,0.1092,0.0821 Q0.1036,0.0834,0.1036,0.0854 Q0.1036,0.0879,0.1129,0.0908 T0.1269,0.0937 Q0.1293,0.0937,0.1558,0.0991 T0.1863,0.1045 Q0.2016,0.1045,0.2193,0.1087 Q0.2225,0.1091,0.2249,0.1091 Q0.2289,0.1091,0.2357,0.1076 T0.2482,0.1054 Q0.2506,0.1049,0.2546,0.1049 Q0.2699,0.1049,0.2924,0.1085 T0.3213,0.1165 Q0.3253,0.119,0.3301,0.119 Q0.3325,0.119,0.3446,0.1161 T0.3687,0.1124 Q0.3831,0.1112,0.3863,0.1112 T0.3908,0.1118 T0.3936,0.1145 T0.3984,0.1186 Q0.4048,0.1228,0.408,0.1228 Q0.4096,0.1228,0.4161,0.1213 T0.4305,0.1195 L0.4337,0.1195 Q0.4426,0.1195,0.4474,0.1211 T0.4566,0.1246 T0.4667,0.1273 Q0.4876,0.1298,0.5116,0.1298 Q0.5365,0.1298,0.5631,0.1389 Q0.5703,0.1414,0.5751,0.1414 Q0.5783,0.1414,0.5819,0.1398 T0.5888,0.1381 Q0.5928,0.1381,0.5984,0.1398 T0.6129,0.1414 Q0.6321,0.1414,0.6498,0.1477 Q0.661,0.1514,0.6667,0.1514 Q0.6707,0.1514,0.6771,0.1501 Q0.6787,0.1497,0.6795,0.1497 Q0.6835,0.1497,0.6863,0.1526 T0.6892,0.1593 Q0.6892,0.1626,0.6876,0.1647 Q0.6851,0.1672,0.6799,0.1686 T0.6695,0.1705 T0.6566,0.1715 T0.6458,0.1725 Q0.6434,0.173,0.6402,0.173 Q0.6378,0.173,0.6317,0.1727 T0.6225,0.1725 Q0.6096,0.1725,0.5984,0.1759 Q0.5823,0.1804,0.5454,0.1804 Q0.5205,0.1804,0.5116,0.1788 L0.5084,0.1788 Q0.5036,0.1788,0.4956,0.1819 T0.4843,0.185 Q0.4434,0.1887,0.4353,0.1929 Q0.4321,0.1945,0.4289,0.1945 T0.4197,0.1922 T0.4112,0.19 T0.4072,0.1912 Q0.4032,0.1949,0.388,0.1949 Q0.3663,0.1949,0.3542,0.19 Q0.351,0.1883,0.3462,0.1883 Q0.3406,0.1883,0.3321,0.1906 T0.3153,0.1954 T0.302,0.1983 Q0.2972,0.1991,0.2859,0.1997 T0.2643,0.201 T0.245,0.2024 T0.2337,0.2041 Q0.2321,0.2045,0.2181,0.2045 T0.1851,0.207 T0.1542,0.2157 Q0.143,0.2211,0.143,0.226 Q0.143,0.2314,0.153,0.2348 T0.1719,0.2381 Q0.1791,0.2381,0.2474,0.2476 Q0.2506,0.248,0.2558,0.2489 T0.2651,0.2505 T0.2739,0.252 T0.2819,0.2526 Q0.2835,0.2526,0.2851,0.2522 L0.2859,0.2522 Q0.2948,0.2522,0.3104,0.2574 T0.3309,0.2671 Q0.3333,0.2696,0.3365,0.2696 Q0.339,0.2696,0.3442,0.2684 T0.3526,0.2671 T0.3582,0.2679 Q0.3687,0.2717,0.3968,0.2742 Q0.4,0.2746,0.4036,0.2771 T0.4096,0.2796 Q0.4112,0.2796,0.4137,0.2787 Q0.4169,0.2779,0.4257,0.2779 Q0.4594,0.2779,0.4779,0.2849 Q0.4876,0.2891,0.4972,0.2891 Q0.4996,0.2891,0.506,0.2887 T0.5165,0.2883 Q0.5253,0.2883,0.5305,0.2889 T0.541,0.292 T0.5494,0.299 L0.5494,0.3015 Q0.5494,0.3036,0.5466,0.3051 T0.5386,0.3073 T0.5285,0.3086 T0.5181,0.3094 T0.5108,0.3102 Q0.5068,0.3107,0.494,0.3121 L0.4683,0.315 T0.4506,0.3181 Q0.449,0.3181,0.4426,0.32 T0.4313,0.3229 T0.4197,0.3256 T0.4064,0.3281 T0.3952,0.3289 Q0.3888,0.3289,0.3855,0.3273 Q0.3783,0.3243,0.3703,0.3243 Q0.3598,0.3243,0.351,0.3297 Q0.3478,0.3314,0.3422,0.3314 Q0.3398,0.3314,0.3337,0.3306 T0.3245,0.3297 T0.3189,0.3306 Q0.3149,0.3314,0.2956,0.3328 T0.2715,0.3368 Q0.2691,0.338,0.2635,0.3391 T0.2522,0.3407 T0.2406,0.3424 T0.2313,0.3447 Q0.2305,0.3447,0.2213,0.348 T0.206,0.354 T0.1924,0.3621 T0.1815,0.3733 Q0.1767,0.3816,0.1767,0.3849 Q0.1767,0.387,0.1783,0.3893 T0.1847,0.3961 T0.1936,0.4063 T0.2004,0.4181 T0.2052,0.4264 T0.2145,0.4309 T0.2386,0.4359 Q0.2458,0.4372,0.2554,0.4372 Q0.2578,0.4372,0.2627,0.437 T0.2699,0.4367 Q0.2795,0.4367,0.2851,0.4384 Q0.294,0.4409,0.3092,0.4409 Q0.3116,0.4409,0.3157,0.4407 T0.3213,0.4405 Q0.3301,0.4405,0.3466,0.444 T0.3687,0.4509 Q0.3703,0.4517,0.3703,0.4525 Q0.3703,0.4575,0.3373,0.4596 Q0.3133,0.4608,0.2988,0.4658 Q0.294,0.4674,0.2803,0.4674 Q0.2763,0.4674,0.2687,0.4672 T0.257,0.467 Q0.2402,0.467,0.2313,0.4687 Q0.2209,0.4708,0.2209,0.4737 Q0.2209,0.4741,0.2213,0.4749 T0.2229,0.4764 L0.2249,0.4774 T0.2265,0.4778 L0.2273,0.4782 Q0.2498,0.4803,0.2618,0.4803 Q0.2667,0.4803,0.2691,0.4799 Q0.2699,0.4795,0.2715,0.4795 Q0.2779,0.4795,0.3133,0.4873 Q0.3181,0.4886,0.3233,0.4892 T0.3386,0.4905 T0.3542,0.4915 T0.3655,0.4919 Q0.3703,0.4919,0.3779,0.4915 T0.3888,0.4911 T0.3952,0.4915 Q0.3976,0.4919,0.4008,0.4927 L0.4072,0.4944 T0.4149,0.4961 T0.4249,0.4975 T0.4369,0.4985 Q0.449,0.499,0.4554,0.5 T0.4651,0.5031 T0.4699,0.5085 Q0.4707,0.5093,0.4707,0.5097 Q0.4707,0.5114,0.4687,0.5124 T0.4631,0.5139 T0.4562,0.5145 T0.4478,0.5147 L0.4402,0.5147 Q0.4353,0.5151,0.4265,0.5174 T0.4096,0.5197 L0.4024,0.5197 Q0.4,0.5193,0.3968,0.5193 Q0.3896,0.5193,0.3831,0.5209 T0.3703,0.5253 T0.3598,0.5288 Q0.3558,0.5301,0.3321,0.5342 T0.302,0.5409 Q0.2876,0.5454,0.2337,0.55 Q0.2112,0.5521,0.2112,0.5558 Q0.2112,0.5574,0.2161,0.5612 Q0.2201,0.5637,0.2281,0.5637 Q0.2305,0.5637,0.2361,0.5633 T0.2442,0.5628 Q0.2474,0.5628,0.2498,0.5633 Q0.2635,0.5653,0.3133,0.5653 Q0.3261,0.5653,0.3301,0.5649 L0.3325,0.5649 Q0.3349,0.5649,0.3402,0.5657 T0.3494,0.5666 Q0.3542,0.5666,0.3598,0.5657 Q0.3663,0.5645,0.3695,0.5645 Q0.3735,0.5645,0.3775,0.5666 T0.3847,0.5695 Q0.3888,0.5707,0.3912,0.5709 T0.3968,0.5711 T0.4048,0.572 Q0.4096,0.5724,0.4165,0.5726 T0.4281,0.5734 T0.4378,0.5757 Q0.4418,0.5774,0.4522,0.5774 Q0.4562,0.5774,0.4655,0.5769 T0.4795,0.5765 Q0.4932,0.5765,0.4972,0.579 Q0.5028,0.5819,0.51,0.5819 Q0.5141,0.5819,0.5221,0.5809 T0.5341,0.5798 L0.5373,0.5798 Q0.5422,0.5798,0.557,0.5821 T0.5855,0.5844 L0.5936,0.5844 L0.5992,0.5844 T0.604,0.5848 T0.6076,0.5852 T0.6108,0.5859 T0.6137,0.5865 T0.6161,0.5873 T0.6181,0.5881 T0.6209,0.5896 L0.6233,0.591 Q0.6265,0.5927,0.6353,0.5927 L0.6402,0.5927 L0.645,0.5927 Q0.6723,0.5927,0.6948,0.6039 Q0.6988,0.606,0.7036,0.606 Q0.7076,0.606,0.7153,0.6045 T0.7261,0.6031 Q0.7309,0.6031,0.7454,0.6027 T0.7647,0.6022 Q0.7783,0.6022,0.808,0.608 L0.812,0.608 Q0.8169,0.608,0.8293,0.6062 T0.8474,0.6039 L0.8506,0.6039 Q0.857,0.6039,0.8655,0.6049 T0.8835,0.6074 T0.8972,0.6093 Q0.9036,0.6101,0.9213,0.6101 L0.9398,0.6101 L0.959,0.6101 L0.9767,0.6101 Q0.9976,0.6109,0.9976,0.6176 Q0.9976,0.6188,0.9968,0.6226 Q0.9952,0.6284,0.9671,0.6284 L0.959,0.6284 L0.9526,0.6284 Q0.9486,0.6284,0.9382,0.6302 T0.9205,0.6321 L0.9173,0.6321 Q0.9133,0.6317,0.9092,0.6317 Q0.9012,0.6317,0.8715,0.6346 Q0.8233,0.6387,0.7944,0.6421 Q0.7888,0.6429,0.7831,0.6429 Q0.7783,0.6429,0.7731,0.6425 T0.7663,0.6421 L0.7622,0.6421 Q0.7614,0.6425,0.7586,0.6425 T0.7474,0.6421 T0.7349,0.6416 Q0.7261,0.6416,0.7221,0.6429 Q0.7173,0.645,0.7032,0.646 T0.6711,0.6479 T0.6482,0.6491 Q0.645,0.6495,0.6418,0.6495 Q0.6353,0.6495,0.6273,0.6474 T0.6161,0.6454 Q0.612,0.6454,0.6088,0.6477 T0.6,0.6499 Q0.5912,0.6499,0.5494,0.6578 Q0.5422,0.6591,0.5373,0.6591 Q0.5341,0.6591,0.5281,0.6584 T0.5173,0.6578 L0.5124,0.6578 Q0.5004,0.6582,0.4747,0.6632 Q0.4675,0.6649,0.4398,0.6667 T0.3851,0.6703 T0.3566,0.6719 Q0.3534,0.6723,0.3406,0.6734 T0.3141,0.6757 T0.2948,0.6773 Q0.2908,0.6781,0.2819,0.6829 T0.2618,0.6877 Q0.2482,0.6877,0.2273,0.6958 T0.1992,0.7117 Q0.1976,0.7138,0.1976,0.7155 Q0.1976,0.7188,0.2032,0.7213 T0.2181,0.7258 T0.2289,0.7292 Q0.2337,0.7308,0.2378,0.7316 L0.2458,0.7333 T0.2522,0.7345 Q0.2747,0.7399,0.2835,0.7399 Q0.29,0.7399,0.3048,0.7408 T0.3253,0.7416 Q0.3277,0.7416,0.3297,0.7414 T0.3341,0.7412 L0.3598,0.7445 Q0.3639,0.7449,0.3663,0.7449 Q0.3695,0.7449,0.3751,0.7443 T0.3855,0.7437 L0.3904,0.7437 Q0.3984,0.7441,0.4141,0.7472 T0.4353,0.7507 Q0.4434,0.752,0.4434,0.7553 Q0.4434,0.7578,0.439,0.7605 T0.4297,0.764 Q0.4257,0.7648,0.4201,0.7655 T0.4076,0.7665 T0.3984,0.7673 Q0.3968,0.7673,0.3912,0.7677 T0.3815,0.7688 T0.3735,0.771 T0.3655,0.7727 Q0.3606,0.7727,0.3534,0.7708 T0.3458,0.769 L0.3446,0.769 Q0.3414,0.769,0.3297,0.7713 T0.3149,0.7735 Q0.3092,0.7735,0.296,0.7771 T0.2771,0.7831 Q0.2683,0.7872,0.2554,0.7885 Q0.253,0.7889,0.2325,0.7897 T0.2032,0.7914 Q0.2008,0.7918,0.198,0.792 T0.194,0.7924 T0.1912,0.7928 T0.1888,0.793 T0.1867,0.7934 T0.1851,0.7943 T0.1843,0.7953 T0.1835,0.7968 T0.1823,0.7984 T0.1815,0.8001 Q0.1815,0.8022,0.1847,0.8032 T0.1932,0.8053 T0.2008,0.8071 Q0.2072,0.8092,0.2265,0.8092 Q0.2361,0.8092,0.2586,0.8088 L0.2635,0.8088 Q0.2731,0.8088,0.2795,0.8098 T0.2928,0.8134 T0.302,0.8167 Q0.306,0.8179,0.3277,0.8183 T0.3542,0.8221 Q0.359,0.8246,0.3622,0.8246 Q0.3639,0.8246,0.3675,0.8237 T0.3751,0.8229 Q0.3968,0.8229,0.4048,0.8275 Q0.4088,0.8291,0.4161,0.8291 Q0.4225,0.8291,0.4353,0.8275 Q0.4369,0.827,0.4394,0.827 Q0.4474,0.827,0.4675,0.8345 Q0.4707,0.8358,0.4739,0.8358 Q0.4755,0.8358,0.4799,0.8353 T0.4876,0.8349 Q0.494,0.8349,0.5012,0.8362 L0.5076,0.837 T0.5133,0.8376 T0.5181,0.8382 T0.5221,0.8391 L0.5253,0.8399 T0.5277,0.8409 L0.5293,0.8422 T0.5301,0.8438 L0.5301,0.8461 Q0.5301,0.8499,0.5249,0.8511 T0.5112,0.8526 T0.5004,0.8532 Q0.4964,0.854,0.4851,0.8546 T0.4667,0.8565 Q0.4578,0.8577,0.441,0.8577 L0.4345,0.8577 L0.4289,0.8577 L0.4209,0.8577 Q0.4153,0.8582,0.4088,0.8586 T0.3968,0.8592 T0.3855,0.8594 T0.3755,0.8596 T0.3675,0.86 T0.3622,0.8602 Q0.3317,0.8635,0.3237,0.8635 Q0.2996,0.8635,0.2996,0.8681 Q0.2996,0.8698,0.3032,0.8733 T0.3068,0.8797 L0.3068,0.8822 Q0.3052,0.8859,0.2859,0.8859 Q0.2787,0.8859,0.2739,0.8851 L0.2699,0.8851 Q0.2659,0.8851,0.259,0.888 T0.2498,0.8913 Q0.2394,0.8946,0.2056,0.8971 Q0.2032,0.8971,0.1928,0.9002 T0.1703,0.9034 Q0.1526,0.9034,0.1353,0.9067 T0.1173,0.915 L0.1173,0.9158 Q0.1173,0.9166,0.1177,0.9175 T0.1189,0.9191 T0.1205,0.9204 T0.1229,0.9212 T0.1257,0.922 T0.1285,0.9226 T0.1309,0.9231 T0.1337,0.9235 T0.1365,0.9237 L0.1446,0.9237 T0.1554,0.9243 T0.1614,0.9268 T0.1659,0.9293 T0.1743,0.9303 T0.1823,0.9316 Q0.1863,0.932,0.1912,0.9332 T0.2028,0.9361 T0.2153,0.939 Q0.2233,0.9411,0.2297,0.9448 T0.2386,0.9494 Q0.2426,0.9506,0.2506,0.9506 Q0.253,0.9506,0.2594,0.9504 T0.2699,0.9502 Q0.2763,0.9502,0.2819,0.9511 Q0.2851,0.9511,0.2871,0.9529 T0.2892,0.9573 Q0.2892,0.9627,0.2811,0.9635 Q0.2434,0.9652,0.2337,0.9672 Q0.2257,0.9693,0.2241,0.9693 Q0.2217,0.9693,0.2096,0.9689 L0.2056,0.9689 Q0.1976,0.9689,0.1924,0.9699 T0.1787,0.9741 L0.1647,0.9793 Q0.1518,0.983,0.1285,0.983 L0.1261,0.983 L0.1237,0.983 Q0.1124,0.983,0.1076,0.9838 Q0.102,0.9851,0.0839,0.9896 T0.0602,0.9954 T0.0406,0.9971 T0.0153,0.9979 L0.0032,0.9979 Z",type:0}},"":{type:5,data:{d:"M0.9992,0.998 Q0.9992,1,0.9968,1 Q0.9521,1,0.9392,0.998 Q0.9335,0.997,0.9152,0.9921 T0.8913,0.9862 Q0.8873,0.9852,0.8783,0.9852 L0.8747,0.9852 L0.871,0.9852 Q0.8483,0.9852,0.8345,0.9812 Q0.8289,0.9792,0.8228,0.9773 T0.8135,0.9743 T0.8054,0.9723 T0.7948,0.9713 L0.7908,0.9713 L0.777,0.9713 T0.7656,0.9693 Q0.7616,0.9683,0.7498,0.9674 T0.7283,0.9664 L0.7186,0.9654 Q0.708,0.9644,0.708,0.9575 Q0.708,0.9545,0.7109,0.952 T0.7178,0.9486 L0.7315,0.9486 L0.7417,0.9486 L0.7502,0.9486 Q0.7575,0.9486,0.7599,0.9476 Q0.7616,0.9466,0.7685,0.9426 T0.7843,0.9377 Q0.7899,0.9357,0.8009,0.9332 T0.8175,0.9298 Q0.82,0.9288,0.8228,0.9283 T0.8277,0.9278 T0.8313,0.9273 T0.8341,0.9263 T0.8362,0.9258 Q0.8402,0.9219,0.854,0.9219 L0.8569,0.9219 L0.8597,0.9219 L0.8637,0.9219 Q0.88,0.9199,0.88,0.9159 L0.88,0.9149 Q0.88,0.913,0.8719,0.911 T0.852,0.9075 T0.8297,0.906 Q0.8224,0.906,0.8167,0.905 T0.8074,0.9031 T0.8001,0.9006 T0.794,0.8991 Q0.7599,0.8971,0.7494,0.8942 Q0.7461,0.8932,0.7397,0.8902 T0.7299,0.8872 L0.7267,0.8872 Q0.721,0.8882,0.7121,0.8882 Q0.6926,0.8882,0.691,0.8833 L0.691,0.8803 Q0.691,0.8773,0.6922,0.8749 T0.6955,0.8704 L0.6975,0.8684 Q0.6926,0.8655,0.6764,0.8655 Q0.6683,0.8655,0.6375,0.8625 Q0.6358,0.8625,0.629,0.862 T0.6148,0.8615 T0.5973,0.861 T0.5791,0.8605 L0.5718,0.8605 L0.5661,0.8605 L0.5596,0.8605 Q0.5426,0.8605,0.5337,0.8586 Q0.5264,0.8576,0.515,0.8571 T0.4996,0.8556 Q0.498,0.8556,0.4947,0.8551 T0.4882,0.8546 T0.4809,0.8541 T0.474,0.8531 T0.4692,0.8506 T0.4672,0.8467 Q0.4672,0.8437,0.468,0.8422 T0.4704,0.8398 T0.4736,0.8383 T0.4781,0.8368 T0.4838,0.8358 T0.4911,0.8353 T0.4988,0.8338 Q0.5069,0.8328,0.5142,0.8328 Q0.5174,0.8328,0.5215,0.8333 T0.5264,0.8338 Q0.5296,0.8338,0.532,0.8328 Q0.5523,0.8249,0.5604,0.8249 L0.5653,0.8249 Q0.5775,0.8269,0.5848,0.8269 Q0.5912,0.8269,0.5937,0.8259 Q0.6026,0.821,0.6253,0.821 Q0.6294,0.821,0.6334,0.822 T0.6383,0.8229 Q0.6399,0.8229,0.644,0.82 Q0.6504,0.817,0.6723,0.816 T0.6975,0.814 Q0.6999,0.814,0.7048,0.8121 T0.7129,0.8091 T0.7226,0.8071 T0.7372,0.8061 L0.7421,0.8061 Q0.7624,0.8071,0.7721,0.8071 Q0.7924,0.8071,0.7981,0.8051 Q0.8021,0.8032,0.807,0.8027 T0.8135,0.8017 T0.8151,0.8002 L0.8151,0.7992 Q0.8143,0.7962,0.8127,0.7957 T0.8045,0.7943 Q0.7997,0.7943,0.7964,0.7933 Q0.7883,0.7933,0.7676,0.7923 T0.7437,0.7903 Q0.7307,0.7893,0.7218,0.7844 Q0.7194,0.7834,0.7141,0.7819 L0.7036,0.7789 T0.693,0.7765 T0.6853,0.7755 Q0.6805,0.7755,0.6691,0.773 T0.6553,0.7705 Q0.6545,0.7705,0.6545,0.7715 Q0.6537,0.7715,0.65,0.7725 T0.6423,0.774 T0.635,0.7745 Q0.6294,0.7745,0.6257,0.773 T0.618,0.771 T0.6083,0.77 T0.601,0.7695 Q0.5985,0.7695,0.5921,0.769 T0.5795,0.7676 T0.5702,0.7666 Q0.5653,0.7656,0.5596,0.7616 T0.5539,0.7547 Q0.5539,0.7498,0.5645,0.7488 Q0.5693,0.7478,0.5852,0.7448 T0.6099,0.7418 L0.6148,0.7418 Q0.6196,0.7418,0.6253,0.7423 T0.6338,0.7428 L0.6399,0.7428 Q0.6431,0.7418,0.6488,0.7409 T0.6586,0.7394 T0.6659,0.7389 L0.6707,0.7389 Q0.6723,0.7399,0.6748,0.7399 Q0.6796,0.7399,0.6946,0.7389 T0.7161,0.7379 Q0.7251,0.7379,0.7478,0.7319 Q0.7494,0.7319,0.7539,0.7315 T0.762,0.73 T0.7697,0.727 T0.7818,0.723 T0.7948,0.7196 T0.7997,0.7151 Q0.7997,0.7141,0.7989,0.7132 Q0.7924,0.7062,0.7717,0.6978 T0.738,0.6894 Q0.7267,0.6894,0.717,0.6845 T0.7048,0.6795 Q0.6975,0.6785,0.6711,0.6766 T0.6431,0.6746 Q0.6415,0.6736,0.6144,0.6721 T0.5596,0.6686 T0.5247,0.6657 Q0.4996,0.6607,0.4874,0.6597 L0.4834,0.6597 Q0.4785,0.6597,0.4724,0.6607 T0.4631,0.6617 Q0.4574,0.6617,0.4501,0.6597 Q0.4088,0.6518,0.4006,0.6518 Q0.3933,0.6518,0.3901,0.6499 T0.3844,0.6479 T0.3739,0.6499 T0.3585,0.6518 L0.352,0.6518 Q0.3471,0.6508,0.335,0.6503 T0.3122,0.6494 T0.2912,0.6479 T0.2766,0.6449 Q0.2733,0.6439,0.2668,0.6439 Q0.2628,0.6439,0.2543,0.6444 T0.2425,0.6449 T0.2368,0.6439 L0.2344,0.6439 Q0.2336,0.6439,0.2283,0.6444 T0.2182,0.6449 Q0.2117,0.6449,0.2052,0.6439 Q0.1768,0.6409,0.1281,0.637 Q0.0989,0.634,0.0916,0.634 L0.0835,0.634 L0.0795,0.634 Q0.0722,0.634,0.0616,0.632 T0.0479,0.6301 Q0.0462,0.6301,0.0406,0.6306 T0.0308,0.6311 Q0.0032,0.6311,0.0008,0.6231 Q0,0.6202,0,0.6182 Q0,0.6083,0.0227,0.6083 Q0.03,0.6073,0.0422,0.6073 Q0.0487,0.6073,0.0608,0.6078 T0.0787,0.6083 Q0.0973,0.6083,0.103,0.6073 Q0.1062,0.6063,0.1131,0.6053 T0.1253,0.6039 T0.1375,0.6024 T0.1492,0.6014 L0.1533,0.6014 Q0.1598,0.6024,0.1723,0.6044 T0.189,0.6063 Q0.1906,0.6063,0.1922,0.6053 Q0.2214,0.6004,0.236,0.6004 Q0.2409,0.6004,0.2551,0.6009 T0.2741,0.6014 Q0.2782,0.6014,0.2859,0.6024 T0.2968,0.6034 Q0.3009,0.6034,0.3041,0.6024 Q0.3277,0.5905,0.356,0.5905 L0.3613,0.5905 L0.3666,0.5905 Q0.3731,0.5905,0.3755,0.5895 Q0.382,0.5856,0.3844,0.5846 T0.3938,0.5831 T0.4144,0.5826 T0.4428,0.5801 T0.4631,0.5776 L0.4663,0.5776 Q0.4704,0.5776,0.4785,0.5786 T0.4899,0.5796 Q0.4964,0.5796,0.5012,0.5767 Q0.5069,0.5737,0.5223,0.5737 Q0.5272,0.5737,0.5369,0.5742 T0.5499,0.5747 Q0.558,0.5747,0.5612,0.5737 Q0.5661,0.5717,0.5714,0.5712 T0.5835,0.5702 T0.5945,0.5692 T0.6018,0.5687 L0.6062,0.5687 T0.6095,0.5682 T0.6148,0.5678 Q0.6172,0.5668,0.6196,0.5653 T0.6245,0.5633 T0.631,0.5628 T0.6407,0.5638 T0.6504,0.5648 T0.6594,0.5638 T0.6675,0.5628 L0.6707,0.5628 L0.6861,0.5628 Q0.7364,0.5628,0.7494,0.5608 L0.7567,0.5608 L0.7652,0.5608 L0.7729,0.5608 Q0.7794,0.5608,0.7818,0.5589 Q0.7851,0.5569,0.7859,0.5559 Q0.7835,0.5539,0.7656,0.5519 Q0.7121,0.547,0.6975,0.543 Q0.6934,0.541,0.6853,0.5396 L0.6691,0.5366 T0.6525,0.5336 T0.6391,0.5312 Q0.6367,0.5302,0.6245,0.5257 T0.6034,0.5213 L0.5977,0.5213 Q0.5945,0.5223,0.5904,0.5223 Q0.5839,0.5223,0.5787,0.5208 T0.5685,0.5183 T0.5596,0.5173 Q0.558,0.5173,0.5552,0.5168 T0.5495,0.5163 L0.5434,0.5163 T0.5373,0.5158 T0.532,0.5148 T0.5284,0.5129 T0.5272,0.5104 L0.5272,0.5074 Q0.5304,0.5015,0.5377,0.499 T0.5629,0.4965 Q0.5734,0.4955,0.5811,0.4946 T0.5953,0.4916 T0.605,0.4896 Q0.6083,0.4886,0.6123,0.4886 Q0.6148,0.4886,0.6225,0.4891 T0.635,0.4896 L0.6456,0.4896 Q0.6837,0.4857,0.6861,0.4857 Q0.7226,0.4768,0.7283,0.4768 Q0.7307,0.4768,0.732,0.4773 T0.7372,0.4777 Q0.7502,0.4777,0.7721,0.4758 Q0.7753,0.4748,0.777,0.4738 Q0.7745,0.4718,0.768,0.4708 Q0.7599,0.4688,0.7445,0.4688 Q0.7405,0.4688,0.7324,0.4693 T0.721,0.4698 Q0.7056,0.4698,0.6999,0.4679 Q0.6861,0.4629,0.6626,0.4619 Q0.6586,0.4609,0.6533,0.4604 T0.6419,0.459 T0.6314,0.456 T0.6269,0.452 Q0.6269,0.451,0.6302,0.4491 Q0.6358,0.4451,0.6525,0.4416 T0.6788,0.4382 L0.6845,0.4382 L0.6902,0.4382 Q0.7064,0.4382,0.7145,0.4362 Q0.7202,0.4342,0.7307,0.4342 L0.7356,0.4342 L0.7409,0.4342 L0.7453,0.4342 Q0.7543,0.4342,0.7607,0.4332 Q0.7778,0.4313,0.7847,0.4288 T0.7932,0.4248 T0.7972,0.4169 T0.8045,0.4045 L0.8094,0.3986 T0.8135,0.3942 L0.8167,0.3912 T0.8191,0.3887 T0.8204,0.3867 T0.8208,0.3848 Q0.8208,0.3818,0.8167,0.3739 Q0.8127,0.3689,0.8054,0.3635 T0.7924,0.3556 T0.7778,0.3497 T0.768,0.3462 Q0.764,0.3442,0.7478,0.3427 T0.7267,0.3383 Q0.7234,0.3363,0.7044,0.3348 T0.6805,0.3323 L0.6764,0.3323 T0.6679,0.3328 T0.6586,0.3333 Q0.6521,0.3333,0.648,0.3314 Q0.6391,0.3264,0.6294,0.3264 Q0.6229,0.3264,0.6156,0.3294 Q0.6115,0.3304,0.6042,0.3304 Q0.5977,0.3304,0.5888,0.3289 T0.5738,0.3264 T0.5584,0.3225 L0.5491,0.3195 Q0.5418,0.3185,0.5162,0.3155 T0.4895,0.3121 T0.4826,0.3116 T0.4716,0.3111 T0.4607,0.3096 T0.4513,0.3066 T0.4477,0.3017 Q0.4477,0.2997,0.4485,0.2977 Q0.4526,0.2898,0.4611,0.2878 T0.4842,0.2859 Q0.4882,0.2859,0.4943,0.2864 T0.5028,0.2868 Q0.5118,0.2868,0.5215,0.2829 Q0.5401,0.276,0.5734,0.276 Q0.5831,0.276,0.5872,0.277 L0.5904,0.277 T0.5949,0.2745 T0.6034,0.272 Q0.631,0.269,0.6407,0.2661 Q0.6448,0.2641,0.6488,0.2641 T0.6573,0.2656 T0.6634,0.2671 Q0.6659,0.2671,0.6675,0.2651 Q0.6723,0.2601,0.6886,0.2552 T0.7137,0.2502 L0.7153,0.2502 L0.7178,0.2502 Q0.7218,0.2502,0.7279,0.2493 T0.7417,0.2468 T0.7526,0.2453 Q0.8208,0.2354,0.8281,0.2354 Q0.8337,0.2354,0.8394,0.2344 T0.8496,0.2315 T0.854,0.2265 Q0.854,0.2216,0.8443,0.2176 Q0.8354,0.2127,0.8216,0.2102 T0.7972,0.2072 T0.777,0.2067 T0.7648,0.2057 Q0.7632,0.2047,0.7498,0.2038 T0.7202,0.2018 T0.6983,0.1998 Q0.6918,0.1998,0.676,0.1949 T0.6537,0.1899 Q0.6496,0.1899,0.6472,0.1919 Q0.6342,0.1968,0.6123,0.1968 Q0.5961,0.1968,0.5912,0.1929 Q0.5904,0.1919,0.5892,0.1919 T0.5823,0.1944 T0.5722,0.1968 T0.5637,0.1949 Q0.5556,0.1909,0.5158,0.1869 Q0.5109,0.1869,0.5032,0.1835 T0.4915,0.18 Q0.4907,0.18,0.4891,0.181 Q0.4793,0.182,0.455,0.182 Q0.4177,0.182,0.4015,0.1771 Q0.3901,0.1741,0.3779,0.1741 Q0.3747,0.1741,0.369,0.1746 T0.3609,0.1751 Q0.3569,0.1751,0.3536,0.1741 Q0.3512,0.1741,0.3459,0.1736 T0.3358,0.1726 T0.3256,0.1716 T0.3167,0.1696 T0.3106,0.1662 Q0.3082,0.1632,0.3082,0.1592 Q0.3082,0.1543,0.3114,0.1508 T0.3204,0.1474 L0.3236,0.1474 Q0.3301,0.1494,0.3333,0.1494 Q0.339,0.1494,0.3496,0.1454 Q0.3674,0.1385,0.3869,0.1385 Q0.395,0.1385,0.4011,0.137 T0.4116,0.1355 T0.4197,0.1375 T0.425,0.1395 Q0.429,0.1395,0.4355,0.1365 Q0.4631,0.1266,0.4882,0.1266 Q0.5126,0.1266,0.5337,0.1246 Q0.5369,0.1246,0.5458,0.1207 T0.5661,0.1167 L0.5693,0.1167 Q0.5791,0.1177,0.5852,0.1187 T0.5921,0.1197 Q0.5945,0.1197,0.6002,0.1167 Q0.6026,0.1147,0.605,0.1123 T0.6091,0.1093 T0.6156,0.1088 T0.6318,0.1098 Q0.6456,0.1108,0.6569,0.1137 T0.6707,0.1167 Q0.674,0.1167,0.6772,0.1147 Q0.6821,0.1108,0.6946,0.1083 T0.721,0.1044 T0.7453,0.1029 L0.7526,0.1029 Q0.7583,0.1039,0.7652,0.1053 T0.7753,0.1068 Q0.7778,0.1068,0.7802,0.1058 Q0.7981,0.1019,0.8143,0.1019 Q0.8175,0.1019,0.8439,0.0964 T0.8735,0.091 Q0.8759,0.091,0.8836,0.089 T0.8938,0.0851 Q0.8929,0.0841,0.8905,0.0841 Q0.8832,0.0821,0.8735,0.0821 Q0.8694,0.0821,0.8629,0.0826 T0.854,0.0831 Q0.8508,0.0831,0.8491,0.0821 Q0.8475,0.0821,0.8171,0.0811 T0.7802,0.0781 T0.7571,0.0737 T0.7332,0.0712 Q0.7299,0.0712,0.7247,0.0717 T0.7161,0.0722 L0.7064,0.0722 Q0.7032,0.0712,0.7003,0.0707 T0.6959,0.0692 T0.693,0.0678 T0.6914,0.0663 T0.6902,0.0648 T0.689,0.0643 L0.6869,0.0643 L0.6845,0.0643 L0.6821,0.0643 Q0.6553,0.0643,0.6553,0.0554 T0.6796,0.0465 L0.6813,0.0465 L0.6845,0.0465 Q0.6918,0.0425,0.717,0.0376 Q0.7226,0.0366,0.7267,0.0356 T0.7324,0.0336 T0.7376,0.0317 T0.747,0.0297 Q0.7518,0.0287,0.7551,0.0287 T0.762,0.0297 T0.768,0.0307 L0.7729,0.0307 Q0.7802,0.0277,0.7997,0.0267 T0.8224,0.0237 Q0.8273,0.0227,0.8341,0.0223 T0.8475,0.0193 T0.8654,0.0143 T0.8873,0.0079 Q0.9002,0.003,0.9331,0.004 T0.97,0.004 Q0.9838,0,0.9976,0.001 Q1,0.001,1,0.003 Z M0.9935,0.996 L0.9951,0.0049 Q0.9822,0.0049,0.9716,0.0079 Q0.9659,0.0099,0.9327,0.0089 T0.8897,0.0119 Q0.8775,0.0158,0.8666,0.0183 T0.85,0.0237 Q0.8418,0.0267,0.8341,0.0272 T0.8248,0.0277 Q0.82,0.0297,0.8001,0.0312 T0.7745,0.0346 Q0.7697,0.0356,0.7664,0.0356 Q0.764,0.0356,0.7603,0.0341 T0.7534,0.0326 Q0.751,0.0326,0.7478,0.0336 Q0.7429,0.0346,0.7397,0.0356 T0.7344,0.0376 T0.7283,0.0401 T0.7178,0.0425 Q0.6926,0.0465,0.6878,0.0495 Q0.6845,0.0514,0.6764,0.0514 L0.6723,0.0514 L0.6691,0.0514 Q0.6602,0.0514,0.6602,0.0554 Q0.6602,0.0574,0.6659,0.0579 T0.6796,0.0589 T0.691,0.0603 T0.6967,0.0643 T0.7072,0.0673 Q0.7121,0.0682,0.7153,0.0682 T0.7238,0.0678 T0.7332,0.0673 Q0.7413,0.0673,0.7579,0.0692 T0.7818,0.0742 Q0.7867,0.0752,0.8171,0.0762 T0.8508,0.0781 L0.852,0.0781 T0.8601,0.0776 T0.8719,0.0772 Q0.8832,0.0772,0.8921,0.0791 Q0.8994,0.0811,0.8994,0.0841 T0.8933,0.0895 T0.8812,0.094 T0.8735,0.0959 T0.8451,0.1014 T0.8143,0.1068 Q0.7989,0.1068,0.7818,0.1098 Q0.7778,0.1108,0.7745,0.1108 T0.768,0.1103 T0.7603,0.1088 T0.7518,0.1068 L0.7461,0.1068 Q0.7315,0.1068,0.7088,0.1103 T0.6805,0.1177 Q0.6756,0.1207,0.6699,0.1207 Q0.6667,0.1207,0.6545,0.1177 T0.631,0.1147 Q0.6269,0.1137,0.6225,0.1133 T0.616,0.1128 L0.6123,0.1128 T0.6103,0.1133 L0.6083,0.1157 T0.6034,0.1197 Q0.5961,0.1246,0.5921,0.1246 Q0.5904,0.1246,0.5835,0.1231 T0.5693,0.1217 L0.5661,0.1217 Q0.558,0.1217,0.5535,0.1231 T0.5446,0.1266 T0.5345,0.1296 Q0.5126,0.1316,0.4882,0.1316 T0.438,0.1405 Q0.4298,0.1434,0.425,0.1434 Q0.4209,0.1434,0.4173,0.1419 T0.4112,0.1405 T0.4027,0.1419 T0.3869,0.1434 Q0.3682,0.1434,0.3512,0.1494 Q0.3398,0.1533,0.3333,0.1533 Q0.3285,0.1533,0.3228,0.1513 L0.3212,0.1513 Q0.3179,0.1513,0.3155,0.1538 T0.3131,0.1592 Q0.3131,0.1612,0.3147,0.1632 Q0.3171,0.1652,0.3232,0.1667 T0.3406,0.1691 T0.3544,0.1701 L0.3601,0.1701 L0.3678,0.1701 L0.3771,0.1701 Q0.3909,0.1701,0.4031,0.1731 Q0.4177,0.178,0.4558,0.178 Q0.4793,0.178,0.4882,0.1761 L0.4915,0.1761 Q0.498,0.1761,0.5061,0.179 T0.5158,0.183 Q0.5166,0.183,0.5231,0.1835 T0.5341,0.1845 T0.545,0.1855 T0.5572,0.1874 T0.5661,0.1909 Q0.5677,0.1919,0.5702,0.1919 T0.5791,0.1894 T0.588,0.1869 Q0.5921,0.1869,0.5945,0.1899 Q0.5977,0.1919,0.6123,0.1919 Q0.6334,0.1919,0.6448,0.1879 Q0.6488,0.186,0.6537,0.186 Q0.6626,0.186,0.6784,0.1909 T0.6983,0.1958 Q0.704,0.1968,0.7206,0.1973 T0.7506,0.1993 T0.7689,0.2018 L0.7705,0.2018 L0.7741,0.2018 L0.7786,0.2018 Q0.8248,0.2018,0.8475,0.2136 Q0.8597,0.2196,0.8597,0.2255 T0.8483,0.2359 T0.8281,0.2404 Q0.8208,0.2404,0.7534,0.2493 Q0.7502,0.2502,0.7425,0.2512 T0.7287,0.2532 T0.7178,0.2542 L0.7153,0.2542 L0.7137,0.2542 Q0.7064,0.2542,0.6906,0.2591 T0.6715,0.2681 T0.6626,0.272 Q0.6594,0.272,0.6541,0.2705 T0.6464,0.269 T0.6431,0.27 Q0.6318,0.273,0.6034,0.276 Q0.6018,0.276,0.5998,0.2774 T0.5957,0.2799 T0.5904,0.2809 L0.5856,0.2809 Q0.5823,0.2799,0.575,0.2799 Q0.541,0.2799,0.5239,0.2868 Q0.5134,0.2908,0.5028,0.2908 Q0.4996,0.2908,0.4935,0.2903 T0.4842,0.2898 Q0.4704,0.2898,0.4635,0.2918 T0.4534,0.2997 L0.4534,0.3007 Q0.4534,0.3037,0.459,0.3046 T0.4753,0.3066 T0.4899,0.3076 Q0.4907,0.3076,0.5166,0.3106 T0.5507,0.3155 Q0.5921,0.3264,0.605,0.3264 Q0.6107,0.3264,0.6131,0.3254 Q0.6212,0.3225,0.6294,0.3225 Q0.6407,0.3225,0.6513,0.3274 Q0.6529,0.3294,0.6569,0.3294 Q0.6594,0.3294,0.665,0.3284 T0.6748,0.3274 T0.6821,0.3284 Q0.6861,0.3294,0.6967,0.3299 T0.7165,0.3314 T0.7299,0.3343 Q0.7324,0.3363,0.7486,0.3383 T0.7697,0.3422 Q0.7713,0.3432,0.7774,0.3452 T0.7887,0.3492 T0.8005,0.3546 T0.8127,0.3625 T0.8208,0.3719 Q0.8256,0.3798,0.8256,0.3848 Q0.8256,0.3877,0.8236,0.3902 T0.8171,0.3976 T0.809,0.4075 T0.8021,0.4189 T0.7968,0.4273 T0.7867,0.4322 T0.7616,0.4382 Q0.7543,0.4392,0.7437,0.4392 L0.7364,0.4392 L0.7299,0.4392 Q0.7202,0.4392,0.7161,0.4402 Q0.7072,0.4431,0.691,0.4431 L0.6845,0.4431 L0.6788,0.4431 Q0.6707,0.4431,0.6545,0.4461 T0.6334,0.452 Q0.6399,0.456,0.6626,0.457 Q0.6878,0.458,0.7024,0.4639 Q0.7064,0.4649,0.7186,0.4649 L0.7295,0.4649 L0.7413,0.4649 Q0.7591,0.4649,0.7697,0.4669 Q0.7818,0.4688,0.7818,0.4728 Q0.7818,0.4748,0.7798,0.4763 T0.7753,0.4787 L0.7737,0.4797 L0.7729,0.4797 Q0.7494,0.4827,0.7388,0.4827 Q0.7332,0.4827,0.7307,0.4817 L0.7291,0.4817 Q0.7226,0.4817,0.6878,0.4896 Q0.6829,0.4906,0.6772,0.4911 T0.6618,0.4921 T0.646,0.4931 T0.6342,0.4936 T0.6212,0.4931 T0.6115,0.4926 Q0.6083,0.4926,0.6058,0.4931 T0.5969,0.4955 T0.5819,0.499 T0.5629,0.5005 Q0.5572,0.5005,0.5527,0.501 T0.545,0.502 T0.5397,0.503 T0.5361,0.5045 T0.5337,0.5064 T0.5328,0.5094 L0.532,0.5094 Q0.532,0.5104,0.5337,0.5109 T0.5381,0.5114 T0.5438,0.5119 T0.5515,0.5124 L0.5604,0.5124 Q0.5661,0.5134,0.5746,0.5153 T0.5912,0.5173 L0.5977,0.5173 L0.6026,0.5173 Q0.6139,0.5173,0.6273,0.5218 T0.6407,0.5272 Q0.6448,0.5282,0.6683,0.5321 T0.6991,0.5381 Q0.7137,0.543,0.7664,0.548 Q0.7908,0.55,0.7908,0.5559 Q0.7908,0.5589,0.7859,0.5628 Q0.781,0.5658,0.7713,0.5658 Q0.7689,0.5658,0.7628,0.5653 T0.7543,0.5648 T0.7502,0.5658 Q0.7364,0.5678,0.6878,0.5678 Q0.674,0.5678,0.6699,0.5668 L0.6683,0.5668 Q0.6659,0.5668,0.6606,0.5678 T0.6513,0.5687 Q0.6464,0.5687,0.6391,0.5678 Q0.6334,0.5668,0.6302,0.5668 T0.6241,0.5687 T0.6164,0.5717 Q0.6123,0.5727,0.6099,0.5727 L0.6062,0.5727 T0.6022,0.5732 T0.5953,0.5737 Q0.5904,0.5747,0.5839,0.5747 T0.5726,0.5752 T0.5629,0.5776 T0.5458,0.5796 Q0.5418,0.5796,0.5324,0.5791 T0.5191,0.5786 Q0.5077,0.5786,0.5045,0.5806 Q0.498,0.5836,0.4899,0.5836 Q0.4858,0.5836,0.4777,0.5826 T0.4655,0.5816 L0.4631,0.5816 Q0.4582,0.5816,0.4436,0.5841 T0.4144,0.5865 L0.4051,0.5865 L0.3986,0.5865 T0.3933,0.587 T0.3897,0.5875 T0.3869,0.5885 T0.3844,0.5895 T0.3812,0.591 T0.3779,0.5925 Q0.3739,0.5955,0.3633,0.5955 L0.3585,0.5955 L0.3536,0.5955 Q0.3277,0.5955,0.3066,0.6053 Q0.3017,0.6083,0.296,0.6083 Q0.2912,0.6083,0.2839,0.6068 T0.2741,0.6053 Q0.2693,0.6053,0.2547,0.6048 T0.236,0.6044 Q0.2222,0.6044,0.193,0.6103 L0.1882,0.6103 Q0.1825,0.6103,0.1703,0.6083 T0.1525,0.6063 L0.15,0.6063 Q0.1436,0.6063,0.135,0.6073 T0.1168,0.6098 T0.1038,0.6113 Q0.0973,0.6123,0.0787,0.6123 L0.06,0.6123 L0.0414,0.6123 L0.0235,0.6123 Q0.0049,0.6133,0.0049,0.6172 L0.0057,0.6222 Q0.0073,0.6261,0.043,0.6261 L0.0454,0.6261 L0.0479,0.6261 Q0.0527,0.6261,0.0633,0.6281 T0.0803,0.6301 L0.0835,0.6301 L0.0916,0.6301 Q0.0998,0.6301,0.129,0.632 Q0.1768,0.636,0.206,0.64 Q0.2117,0.6409,0.2165,0.6409 Q0.2206,0.6409,0.2263,0.6405 T0.2336,0.64 L0.2384,0.64 L0.2409,0.64 T0.251,0.6395 T0.2644,0.639 Q0.2741,0.639,0.279,0.6409 Q0.283,0.6429,0.2972,0.6439 T0.3293,0.6459 T0.3528,0.6469 L0.3577,0.6469 Q0.3642,0.6469,0.3723,0.6449 T0.3844,0.6429 Q0.3901,0.6429,0.3933,0.6454 T0.4006,0.6479 Q0.4088,0.6479,0.4517,0.6558 Q0.4582,0.6568,0.4623,0.6568 Q0.4655,0.6568,0.4716,0.6563 T0.4826,0.6558 L0.4882,0.6558 Q0.5004,0.6558,0.5255,0.6607 Q0.5328,0.6627,0.5604,0.6647 T0.6152,0.6682 T0.644,0.6696 T0.6719,0.6721 T0.7056,0.6756 Q0.7113,0.6756,0.7198,0.6805 T0.738,0.6855 Q0.7453,0.6855,0.7551,0.6879 T0.7741,0.6939 T0.7912,0.7018 T0.8029,0.7102 Q0.8054,0.7132,0.8054,0.7151 Q0.8054,0.7191,0.8009,0.7216 T0.7908,0.7255 T0.779,0.7285 T0.7721,0.731 Q0.7672,0.7329,0.7632,0.7339 T0.7551,0.7354 T0.7486,0.7369 Q0.7478,0.7369,0.7445,0.7379 T0.7388,0.7394 T0.7324,0.7404 L0.7242,0.7413 T0.7161,0.7418 Q0.7105,0.7418,0.6955,0.7428 T0.6748,0.7438 L0.6699,0.7438 L0.6667,0.7438 Q0.6659,0.7438,0.6407,0.7468 Q0.6367,0.7478,0.6334,0.7478 T0.6245,0.7468 T0.6148,0.7458 L0.6099,0.7458 Q0.6018,0.7468,0.5864,0.7498 T0.5653,0.7532 T0.5596,0.7557 Q0.5596,0.7596,0.571,0.7616 Q0.5742,0.7626,0.5803,0.7631 T0.5929,0.7641 T0.6018,0.7656 L0.6087,0.7656 T0.6192,0.7666 T0.6277,0.7695 Q0.631,0.7705,0.6342,0.7705 Q0.6383,0.7705,0.6452,0.7685 T0.6537,0.7666 L0.6553,0.7666 Q0.6602,0.7666,0.6711,0.769 T0.6853,0.7715 Q0.691,0.7715,0.7048,0.775 T0.7242,0.7814 Q0.7324,0.7854,0.7445,0.7864 Q0.7478,0.7864,0.768,0.7873 T0.7972,0.7893 Q0.7989,0.7893,0.8017,0.7898 T0.8054,0.7903 L0.8082,0.7903 T0.811,0.7908 T0.8131,0.7913 T0.8151,0.7918 L0.8167,0.7928 T0.8179,0.7943 T0.8191,0.7957 T0.8204,0.7977 T0.8208,0.8002 Q0.8208,0.8032,0.8171,0.8051 T0.8074,0.8081 T0.7997,0.8091 Q0.7932,0.8121,0.7737,0.8121 Q0.7664,0.8121,0.7413,0.8111 L0.7364,0.8111 Q0.7275,0.8111,0.7214,0.8121 T0.7084,0.8155 T0.6991,0.819 Q0.6934,0.82,0.6723,0.8205 T0.6472,0.8239 Q0.6423,0.8269,0.6375,0.8269 Q0.6358,0.8269,0.6338,0.8264 T0.6294,0.8254 T0.6253,0.8249 Q0.6042,0.8249,0.5961,0.8289 Q0.5921,0.8318,0.5839,0.8318 Q0.5783,0.8318,0.5645,0.8299 L0.5604,0.8299 Q0.5531,0.8299,0.5337,0.8368 Q0.5296,0.8378,0.5255,0.8378 Q0.5239,0.8378,0.5195,0.8373 T0.5118,0.8368 Q0.5061,0.8368,0.4996,0.8388 Q0.4947,0.8388,0.4882,0.8398 Q0.4777,0.8417,0.4753,0.8427 T0.4728,0.8467 Q0.4728,0.8487,0.4769,0.8492 T0.4886,0.8501 T0.5004,0.8516 Q0.5036,0.8516,0.515,0.8521 T0.5345,0.8546 Q0.5426,0.8556,0.5596,0.8556 L0.5649,0.8556 L0.5702,0.8556 L0.5791,0.8556 Q0.5921,0.8566,0.6135,0.8571 T0.6383,0.8586 Q0.6683,0.8615,0.6764,0.8615 L0.6776,0.8615 L0.6788,0.8615 Q0.7032,0.8615,0.7032,0.8684 Q0.7032,0.8714,0.6995,0.8749 T0.6959,0.8803 L0.6959,0.8813 Q0.6991,0.8843,0.7153,0.8843 Q0.7218,0.8843,0.7259,0.8833 L0.7299,0.8833 Q0.7324,0.8833,0.7348,0.8838 T0.7393,0.8848 T0.7433,0.8863 L0.7474,0.8882 T0.751,0.8892 Q0.7616,0.8922,0.7948,0.8952 Q0.7981,0.8952,0.8082,0.8981 T0.8297,0.9011 T0.8528,0.9026 T0.8747,0.907 T0.8856,0.9149 L0.8856,0.9159 Q0.8856,0.9179,0.8848,0.9189 T0.8828,0.9209 T0.88,0.9228 T0.8767,0.9243 T0.8731,0.9248 T0.8698,0.9253 T0.8666,0.9258 L0.8646,0.9258 Q0.8621,0.9258,0.8577,0.9263 T0.85,0.9268 T0.8439,0.9273 T0.8402,0.9278 Q0.8386,0.9298,0.8358,0.9308 T0.8305,0.9322 T0.8244,0.9332 T0.8183,0.9337 Q0.8135,0.9347,0.8025,0.9372 T0.7859,0.9416 Q0.7778,0.9436,0.7717,0.9471 T0.7624,0.9515 Q0.7575,0.9535,0.7486,0.9535 Q0.7461,0.9535,0.7397,0.953 T0.7291,0.9525 Q0.7234,0.9525,0.7186,0.953 T0.7137,0.957 T0.7194,0.9614 Q0.7567,0.9634,0.7664,0.9654 Q0.7745,0.9674,0.7762,0.9674 L0.7908,0.9674 Q0.7924,0.9664,0.7948,0.9664 Q0.8029,0.9664,0.8082,0.9679 T0.8224,0.9723 T0.8362,0.9773 Q0.8483,0.9812,0.871,0.9812 L0.8751,0.9812 Q0.8873,0.9812,0.8929,0.9822 T0.9165,0.9876 T0.9408,0.9931 Q0.9513,0.996,0.9935,0.996 Z M0.9968,0.998 L0.9976,0.003 Q0.9838,0.002,0.9708,0.0059 Q0.9659,0.0069,0.9327,0.0059 T0.8881,0.0099 Q0.8767,0.0138,0.8658,0.0163 T0.8491,0.0218 Q0.8418,0.0247,0.8341,0.0247 T0.8232,0.0257 Q0.8191,0.0277,0.7997,0.0292 T0.7737,0.0326 Q0.7697,0.0336,0.7672,0.0336 T0.7612,0.0321 T0.7543,0.0307 T0.747,0.0317 Q0.7397,0.0326,0.7336,0.0356 T0.717,0.0406 Q0.6918,0.0445,0.6861,0.0475 Q0.6845,0.0485,0.6772,0.0485 T0.6638,0.05 T0.6577,0.0549 T0.6642,0.0598 T0.6796,0.0613 T0.6902,0.0623 Q0.691,0.0623,0.6946,0.0658 T0.7064,0.0702 L0.7161,0.0702 Q0.7194,0.0702,0.7242,0.0697 T0.7332,0.0692 Q0.7413,0.0692,0.7579,0.0717 T0.781,0.0762 Q0.7867,0.0781,0.8171,0.0786 T0.85,0.0801 L0.8532,0.0801 Q0.8548,0.0801,0.8613,0.0796 T0.8727,0.0791 Q0.8832,0.0791,0.8913,0.0811 Q0.897,0.0831,0.897,0.0851 Q0.897,0.088,0.8873,0.0905 T0.8735,0.093 Q0.871,0.093,0.8447,0.0984 T0.8143,0.1039 Q0.7981,0.1039,0.781,0.1078 Q0.7778,0.1088,0.7745,0.1088 T0.7644,0.1073 T0.7518,0.1048 L0.7453,0.1048 Q0.7299,0.1048,0.7076,0.1083 T0.6788,0.1157 Q0.6748,0.1187,0.6699,0.1187 Q0.6675,0.1187,0.6557,0.1157 T0.6318,0.1118 Q0.6164,0.1108,0.6135,0.1108 T0.6095,0.1113 T0.6067,0.1142 T0.6018,0.1187 Q0.5953,0.1227,0.5921,0.1227 Q0.5904,0.1227,0.5839,0.1212 T0.5693,0.1187 L0.5661,0.1187 Q0.558,0.1187,0.5527,0.1207 T0.5434,0.1246 T0.5337,0.1266 Q0.5126,0.1296,0.4882,0.1296 T0.4371,0.1385 Q0.4298,0.1414,0.425,0.1414 Q0.4225,0.1414,0.4189,0.1395 T0.4112,0.1375 Q0.4079,0.1375,0.4019,0.1395 T0.3869,0.1414 Q0.3682,0.1414,0.3504,0.1474 Q0.3398,0.1513,0.3333,0.1513 Q0.3293,0.1513,0.3228,0.1494 L0.3204,0.1494 Q0.3179,0.1494,0.3155,0.1508 T0.3118,0.1543 T0.3106,0.1592 T0.3127,0.1642 T0.32,0.1677 T0.3305,0.1701 T0.3435,0.1716 T0.3544,0.1721 Q0.3569,0.1731,0.3601,0.1731 Q0.3625,0.1731,0.3686,0.1726 T0.3779,0.1721 Q0.3901,0.1721,0.4023,0.1751 Q0.4177,0.18,0.455,0.18 Q0.4793,0.18,0.4882,0.178 L0.4915,0.178 Q0.4964,0.178,0.5045,0.1815 T0.5158,0.185 Q0.5564,0.1889,0.5645,0.1929 Q0.5677,0.1939,0.571,0.1939 Q0.575,0.1939,0.5807,0.1919 T0.5888,0.1899 T0.5929,0.1909 Q0.5969,0.1949,0.6123,0.1949 Q0.6334,0.1949,0.6456,0.1899 Q0.6488,0.1879,0.6537,0.1879 Q0.661,0.1879,0.6772,0.1929 T0.6983,0.1978 Q0.704,0.1988,0.7206,0.1998 T0.7502,0.2018 T0.7664,0.2038 Q0.7672,0.2038,0.7818,0.2043 T0.8151,0.2067 T0.8459,0.2156 Q0.8573,0.2206,0.8573,0.2255 Q0.8573,0.2295,0.8516,0.2324 T0.8394,0.2369 T0.8281,0.2384 Q0.8208,0.2384,0.7526,0.2473 Q0.7494,0.2483,0.7421,0.2493 T0.7287,0.2512 T0.7178,0.2522 L0.7153,0.2522 L0.7137,0.2522 Q0.7056,0.2522,0.6898,0.2572 T0.6691,0.2671 Q0.6667,0.269,0.6634,0.269 Q0.661,0.269,0.6557,0.2681 T0.6472,0.2671 Q0.6448,0.2671,0.6415,0.2681 Q0.631,0.271,0.6034,0.274 Q0.5994,0.274,0.5961,0.2765 T0.5904,0.2789 L0.5864,0.2789 Q0.5831,0.2779,0.5742,0.2779 Q0.541,0.2779,0.5223,0.2849 Q0.5126,0.2888,0.5028,0.2888 Q0.5004,0.2888,0.4943,0.2883 T0.4842,0.2878 Q0.4704,0.2878,0.4627,0.2898 T0.4509,0.2987 Q0.4501,0.2997,0.4501,0.3007 Q0.4501,0.3046,0.4574,0.3066 T0.4765,0.3091 T0.4899,0.3096 Q0.4931,0.3106,0.5061,0.3121 T0.5316,0.315 T0.5499,0.3175 Q0.5507,0.3175,0.5572,0.3195 T0.5685,0.3225 T0.5803,0.3254 T0.5933,0.3279 T0.605,0.3284 T0.6148,0.3274 Q0.6221,0.3244,0.6294,0.3244 Q0.6399,0.3244,0.6496,0.3294 Q0.6529,0.3314,0.6577,0.3314 Q0.6602,0.3314,0.6663,0.3304 T0.6756,0.3294 T0.6813,0.3304 Q0.6837,0.3304,0.6873,0.3309 L0.6946,0.3318 T0.7024,0.3323 T0.7105,0.3328 T0.7178,0.3338 T0.7238,0.3348 T0.7283,0.3363 Q0.7324,0.3383,0.7482,0.3403 T0.7689,0.3442 Q0.7697,0.3442,0.779,0.3477 T0.794,0.3536 T0.8074,0.3615 T0.8183,0.3729 Q0.8232,0.3808,0.8232,0.3848 Q0.8232,0.3867,0.8216,0.3892 T0.8151,0.3961 T0.8062,0.406 T0.7997,0.4179 T0.7952,0.4263 T0.7855,0.4308 T0.7616,0.4362 Q0.7543,0.4372,0.7445,0.4372 L0.7372,0.4372 L0.7307,0.4372 Q0.7202,0.4372,0.7153,0.4382 Q0.7064,0.4402,0.691,0.4402 L0.6845,0.4402 L0.6788,0.4402 Q0.6699,0.4402,0.6533,0.4436 T0.6318,0.451 Q0.6302,0.451,0.6302,0.452 Q0.6302,0.457,0.6626,0.459 Q0.6869,0.4609,0.7015,0.4659 Q0.7064,0.4669,0.7202,0.4669 L0.7311,0.4669 L0.7429,0.4669 Q0.7599,0.4669,0.7689,0.4688 Q0.7794,0.4708,0.7794,0.4738 L0.7786,0.4748 T0.777,0.4763 T0.7749,0.4773 L0.7737,0.4777 L0.7729,0.4777 Q0.7502,0.4797,0.738,0.4797 L0.7315,0.4797 L0.7291,0.4797 Q0.7226,0.4797,0.6869,0.4876 Q0.6821,0.4886,0.6768,0.4891 T0.6614,0.4901 T0.6456,0.4916 L0.6342,0.4916 Q0.6294,0.4916,0.6217,0.4911 T0.6115,0.4906 Q0.6083,0.4906,0.6054,0.4911 T0.5961,0.4936 T0.5815,0.4965 T0.5629,0.4985 Q0.5507,0.4985,0.5442,0.4995 T0.5345,0.5025 T0.5304,0.5084 L0.5296,0.5094 Q0.5296,0.5114,0.5316,0.5124 T0.5373,0.5138 T0.5442,0.5143 L0.5523,0.5143 L0.5604,0.5143 Q0.5637,0.5153,0.5677,0.5158 T0.5742,0.5173 T0.5811,0.5188 T0.5904,0.5193 L0.5977,0.5193 L0.6026,0.5193 Q0.6107,0.5193,0.6168,0.5208 T0.6294,0.5252 T0.6399,0.5292 Q0.6448,0.5302,0.6679,0.5341 T0.6983,0.541 Q0.7129,0.545,0.7664,0.55 Q0.7883,0.5519,0.7883,0.5559 Q0.7883,0.5579,0.7843,0.5608 T0.7721,0.5638 Q0.7697,0.5638,0.764,0.5633 T0.7559,0.5628 L0.7502,0.5628 Q0.7364,0.5648,0.6869,0.5648 L0.6699,0.5648 L0.6675,0.5648 Q0.665,0.5648,0.6602,0.5658 T0.6513,0.5668 Q0.6464,0.5668,0.6399,0.5658 Q0.6342,0.5648,0.6302,0.5648 T0.6225,0.5668 T0.6156,0.5697 Q0.6107,0.5707,0.6087,0.5707 T0.6034,0.5712 T0.5953,0.5717 Q0.5904,0.5727,0.5835,0.5727 T0.5718,0.5732 T0.562,0.5757 Q0.558,0.5767,0.5483,0.5767 L0.5349,0.5767 L0.5207,0.5767 Q0.5069,0.5767,0.5028,0.5786 Q0.4972,0.5816,0.4899,0.5816 Q0.4858,0.5816,0.4781,0.5806 T0.4663,0.5796 L0.4631,0.5796 Q0.4582,0.5796,0.4432,0.5821 T0.4144,0.5846 L0.4071,0.5846 L0.4011,0.5846 T0.3958,0.5851 T0.3921,0.5856 T0.3889,0.5861 T0.3865,0.5865 T0.384,0.5875 L0.382,0.5885 L0.3796,0.5895 L0.3771,0.5905 Q0.3731,0.5925,0.365,0.5925 L0.3601,0.5925 L0.3552,0.5925 Q0.3277,0.5925,0.3049,0.6044 Q0.3017,0.6053,0.296,0.6053 Q0.292,0.6053,0.2847,0.6044 T0.2741,0.6034 Q0.2693,0.6034,0.2547,0.6029 T0.236,0.6024 Q0.2222,0.6024,0.1922,0.6073 Q0.1906,0.6083,0.1882,0.6083 Q0.1833,0.6083,0.1711,0.6063 T0.1533,0.6044 Q0.1517,0.6034,0.1492,0.6034 Q0.1436,0.6034,0.135,0.6048 T0.1168,0.6078 T0.103,0.6093 Q0.0973,0.6103,0.0787,0.6103 L0.0604,0.6103 L0.0414,0.6103 L0.0235,0.6103 Q0.0024,0.6113,0.0024,0.6172 Q0.0024,0.6192,0.0032,0.6231 Q0.0049,0.6281,0.0333,0.6281 L0.0414,0.6281 L0.0479,0.6281 Q0.0519,0.6281,0.0624,0.6301 T0.0803,0.632 L0.0835,0.632 L0.0916,0.632 Q0.0989,0.632,0.1281,0.634 L0.206,0.6419 Q0.2117,0.6429,0.2174,0.6429 Q0.2214,0.6429,0.2271,0.6424 T0.2344,0.6419 L0.2376,0.6419 Q0.2393,0.6429,0.2417,0.6429 T0.2526,0.6419 T0.2652,0.6409 Q0.2741,0.6409,0.2782,0.6429 T0.2968,0.6459 T0.3293,0.6479 T0.352,0.6489 Q0.3552,0.6499,0.3585,0.6499 Q0.365,0.6499,0.3731,0.6474 T0.3844,0.6449 Q0.3885,0.6449,0.3917,0.6474 T0.4006,0.6499 Q0.4088,0.6499,0.4509,0.6578 Q0.4574,0.6588,0.4631,0.6588 Q0.4655,0.6588,0.4716,0.6583 T0.4834,0.6578 L0.4874,0.6578 Q0.5004,0.6588,0.5255,0.6637 Q0.532,0.6647,0.56,0.6667 T0.6148,0.6701 T0.644,0.6716 Q0.6464,0.6726,0.6594,0.6736 T0.6861,0.6756 T0.7048,0.6775 Q0.7097,0.6775,0.7186,0.6825 T0.738,0.6874 Q0.7518,0.6874,0.7729,0.6958 T0.8005,0.7122 Q0.8029,0.7141,0.8029,0.7151 Q0.8029,0.7191,0.7968,0.7216 T0.7818,0.726 T0.7705,0.729 L0.764,0.731 T0.7583,0.7324 T0.753,0.7334 T0.7486,0.7349 Q0.7251,0.7399,0.7161,0.7399 Q0.7097,0.7399,0.6951,0.7409 T0.6748,0.7418 L0.6703,0.7418 L0.6667,0.7418 Q0.6659,0.7418,0.6399,0.7448 L0.6334,0.7448 Q0.631,0.7448,0.6249,0.7443 T0.6148,0.7438 L0.6099,0.7438 Q0.601,0.7448,0.5856,0.7473 T0.5645,0.7507 Q0.5572,0.7517,0.5572,0.7547 T0.5616,0.7606 T0.5702,0.7646 Q0.5734,0.7646,0.5779,0.7651 T0.5864,0.7661 T0.5949,0.7671 T0.6018,0.7676 L0.6071,0.7676 T0.6135,0.7681 T0.62,0.769 T0.6269,0.771 T0.6342,0.7725 Q0.6391,0.7725,0.6464,0.7705 T0.6541,0.7685 L0.6553,0.7685 Q0.6586,0.7685,0.6699,0.771 T0.6853,0.7735 Q0.6902,0.7735,0.704,0.777 T0.7226,0.7834 Q0.7315,0.7873,0.7445,0.7883 Q0.747,0.7883,0.7676,0.7893 T0.7972,0.7913 Q0.7989,0.7913,0.8017,0.7918 T0.8058,0.7923 T0.809,0.7928 T0.8114,0.7933 T0.8131,0.7938 T0.8147,0.7943 T0.8159,0.7953 L0.8171,0.7967 T0.8175,0.7982 Q0.8183,0.7992,0.8183,0.8002 Q0.8183,0.8022,0.8155,0.8032 T0.807,0.8051 T0.7989,0.8071 Q0.7932,0.8091,0.7737,0.8091 L0.7413,0.8091 L0.7372,0.8091 Q0.7275,0.8091,0.721,0.8101 T0.7072,0.8136 T0.6983,0.817 Q0.6942,0.818,0.6825,0.818 T0.6602,0.819 T0.6456,0.822 Q0.6415,0.8249,0.6375,0.8249 Q0.6367,0.8249,0.6326,0.8239 T0.6253,0.8229 Q0.6034,0.8229,0.5953,0.8279 Q0.5912,0.8289,0.5848,0.8289 Q0.5775,0.8289,0.5645,0.8279 Q0.5629,0.8269,0.5604,0.8269 Q0.5523,0.8269,0.5328,0.8348 Q0.5296,0.8358,0.5264,0.8358 Q0.5247,0.8358,0.5203,0.8353 T0.5126,0.8348 Q0.5061,0.8348,0.4988,0.8358 Q0.4947,0.8368,0.4882,0.8378 Q0.4826,0.8388,0.4797,0.8388 T0.474,0.8398 T0.4704,0.8422 T0.4696,0.8462 T0.472,0.8501 T0.4781,0.8521 T0.4854,0.8526 L0.4935,0.8526 T0.4996,0.8536 Q0.5036,0.8536,0.515,0.8546 T0.5337,0.8566 Q0.5426,0.8576,0.5596,0.8576 L0.5657,0.8576 L0.571,0.8576 L0.5791,0.8576 Q0.5921,0.8586,0.6135,0.8591 T0.6383,0.8605 Q0.6683,0.8635,0.6764,0.8635 Q0.6999,0.8635,0.6999,0.8684 Q0.6999,0.8694,0.6967,0.8734 T0.6934,0.8803 L0.6934,0.8823 Q0.6951,0.8863,0.7137,0.8863 Q0.7218,0.8863,0.7267,0.8853 L0.7299,0.8853 Q0.734,0.8853,0.7409,0.8882 T0.7502,0.8912 Q0.7607,0.8942,0.794,0.8971 Q0.7972,0.8971,0.8078,0.9001 T0.8297,0.9031 Q0.8475,0.9031,0.8646,0.9065 T0.8824,0.9149 L0.8824,0.9159 Q0.8824,0.9169,0.882,0.9179 T0.8808,0.9194 L0.8792,0.9204 T0.8767,0.9214 T0.8743,0.9224 T0.8715,0.9228 L0.8686,0.9228 T0.8662,0.9233 T0.8637,0.9238 L0.8556,0.9238 T0.8447,0.9243 T0.8386,0.9268 Q0.837,0.9278,0.835,0.9288 T0.8305,0.9303 T0.8244,0.9308 T0.8175,0.9318 Q0.8127,0.9327,0.8017,0.9352 T0.7851,0.9397 Q0.777,0.9416,0.7705,0.9451 T0.7616,0.9496 Q0.7575,0.9505,0.7494,0.9505 L0.7405,0.9505 L0.7307,0.9505 Q0.7234,0.9505,0.7178,0.9515 Q0.7145,0.9515,0.7125,0.9535 T0.7105,0.9575 Q0.7105,0.9624,0.7194,0.9634 Q0.7567,0.9654,0.7664,0.9674 Q0.7745,0.9693,0.7762,0.9693 L0.7908,0.9693 L0.7948,0.9693 Q0.8005,0.9693,0.8058,0.9698 T0.8143,0.9718 T0.824,0.9753 T0.8354,0.9792 Q0.8483,0.9832,0.871,0.9832 L0.8739,0.9832 L0.8767,0.9832 Q0.8873,0.9832,0.8921,0.9842 Q0.8978,0.9852,0.9157,0.9896 T0.94,0.996 Q0.9424,0.996,0.9469,0.9965 T0.9566,0.997 T0.9676,0.9975 T0.9781,0.998 L0.9874,0.998 L0.9943,0.998 L0.9968,0.998 Z",type:0}},"":{type:5,data:{d:"M1,0.5071 L0.8623,0.7102 L0.5865,0.7102 L0.4489,0.5071 L0.5865,0.3045 L0.8623,0.3045 Z M0.4135,0.7974 L0.2758,1 L0,1 L0,0.5944 L0.2758,0.5944 Z M0.4135,0.2026 L0.2758,0.4056 L0,0.4056 L0,0 L0.2758,0 Z",type:0}},"":{type:5,data:{d:"M0.9726,0.5071 L0.8451,0.3184 L0.59,0.3184 L0.4624,0.5071 L0.59,0.6955 L0.8451,0.6955 Z M1,0.5071 L0.8588,0.716 L0.5768,0.716 L0.4355,0.5071 L0.5768,0.2982 L0.8588,0.2982 Z M0.401,0.7911 L0.2735,0.6028 L0.0236,0.6028 L0.0236,0.9799 L0.2735,0.9799 Z M0.4284,0.7911 L0.2872,1 L0,1 L0,0.5826 L0.2872,0.5826 Z M0.401,0.2089 L0.2735,0.0201 L0.0236,0.0201 L0.0236,0.3972 L0.2735,0.3972 Z M0.4284,0.2089 L0.2872,0.4174 L0,0.4174 L0,0 L0.2872,0 Z",type:0}},"":{type:5,data:{d:"M1,0.4996 Q1,0.5365,0.9924,0.568 T0.9718,0.6177 T0.9433,0.6363 L0.9425,0.6367 Q0.9355,0.6367,0.9285,0.6326 L0.9308,0.6326 Q0.9129,0.6195,0.9013,0.587 T0.8871,0.5164 T0.8943,0.4373 T0.9254,0.3687 L0.9254,0.3691 Q0.9339,0.3628,0.9425,0.3628 Q0.9584,0.3628,0.9716,0.3811 T0.9924,0.431 T1,0.4996 Z M0.9234,0.6321 L0.8776,0.7169 Q0.8791,0.732,0.8791,0.7441 Q0.8791,0.781,0.8716,0.8123 T0.8508,0.862 T0.8224,0.8809 L0.8216,0.8809 Q0.8154,0.8809,0.8092,0.8775 L0.8088,0.8775 Q0.7905,0.8633,0.7792,0.8297 T0.766,0.7571 T0.775,0.6768 T0.8088,0.6086 L0.7431,0.6065 Q0.719,0.6313,0.7072,0.6705 T0.6965,0.7487 T0.7097,0.823 T0.7423,0.8763 L0.7913,0.8775 L0.7314,0.9895 L0.4648,0.5038 L0.7299,0.0176 L0.7882,0.1229 L0.7404,0.1212 Q0.7244,0.138,0.7136,0.1617 T0.6982,0.2108 T0.6943,0.2632 T0.7003,0.3144 T0.7159,0.3586 T0.7396,0.3909 L0.8072,0.3926 Q0.7894,0.3796,0.7777,0.3479 T0.7635,0.2789 T0.7697,0.2011 T0.7987,0.1326 Q0.8092,0.1225,0.8204,0.1225 Q0.8321,0.1225,0.8426,0.1332 T0.8609,0.1623 T0.8731,0.2062 T0.8776,0.2592 Q0.8776,0.268,0.8768,0.2815 L0.9219,0.3628 L0.8644,0.3612 Q0.8403,0.3855,0.8284,0.4247 T0.8177,0.5029 T0.8309,0.5772 T0.8632,0.6305 Z M0.6759,0.6384 Q0.6576,0.625,0.6457,0.5914 T0.6319,0.5185 T0.6407,0.4375 T0.6751,0.3691 L0.609,0.367 Q0.5849,0.3918,0.5731,0.431 T0.5626,0.509 T0.5758,0.5833 T0.6082,0.6367 Z M0.6459,0.0025 L0.391,0.4551 L0.0035,0.4551 L0.246,0 Z M0.6553,1 L0.2421,1 L0,0.5449 L0.3875,0.5449 Z",type:0}},"":{type:5,data:{d:"M0.4996,0 Q0.5562,0,0.5961,0.0166 T0.6364,0.0566 L0.6368,0.0575 Q0.6368,0.0646,0.6324,0.0713 L0.6324,0.0692 Q0.6196,0.0868,0.5872,0.0986 T0.5166,0.1128 T0.4373,0.1057 T0.3689,0.0747 L0.3694,0.0747 Q0.3627,0.0663,0.3627,0.0575 Q0.3627,0.0336,0.4028,0.0168 T0.4996,0 Z M0.6324,0.0768 L0.717,0.1225 Q0.7321,0.1212,0.744,0.1212 Q0.8007,0.1212,0.8406,0.1378 T0.8809,0.1779 L0.8813,0.1783 Q0.8813,0.1846,0.8778,0.1909 Q0.8636,0.2093,0.8299,0.2208 T0.7573,0.2343 T0.6769,0.2253 T0.6089,0.1913 L0.6067,0.2567 Q0.6315,0.281,0.6707,0.2928 T0.7489,0.3035 T0.8231,0.2903 T0.8764,0.258 L0.8778,0.2085 L0.9898,0.2685 L0.504,0.5352 L0.0177,0.2701 L0.1227,0.2118 L0.1213,0.2596 Q0.1457,0.2836,0.1851,0.2955 T0.2635,0.3062 T0.3377,0.293 T0.3911,0.2605 L0.3928,0.193 Q0.38,0.2106,0.3483,0.2221 T0.2792,0.2364 T0.2013,0.2303 T0.1324,0.2013 Q0.1222,0.1909,0.1222,0.1795 Q0.1222,0.156,0.1623,0.1393 T0.2591,0.1225 Q0.2679,0.1225,0.2817,0.1233 L0.3627,0.078 L0.3609,0.1359 Q0.3857,0.1598,0.4249,0.1718 T0.5031,0.1825 T0.5773,0.1693 T0.6306,0.1367 Z M0.6386,0.3242 Q0.6253,0.3427,0.5917,0.3544 T0.5186,0.3683 T0.4376,0.3595 T0.3689,0.3251 L0.3671,0.3909 Q0.3915,0.4148,0.4309,0.4268 T0.5093,0.4375 T0.5835,0.4243 T0.6368,0.3918 Z M0.0027,0.354 L0.4553,0.6091 L0.4553,0.9962 L0,0.7542 Z M1,0.3448 L1,0.7576 L0.5447,1 L0.5447,0.6128 Z",type:0}},"":{type:5,data:{d:"M0,0.7699 Q0,0.7172,0.0277,0.6731 T0.103,0.6032 T0.2066,0.5774 Q0.2487,0.5774,0.2865,0.5922 T0.3526,0.6339 L0.3935,0.6715 Q0.4218,0.6984,0.438,0.7336 T0.4541,0.8075 Q0.4541,0.8602,0.4264,0.9046 T0.3511,0.9745 T0.2475,1 Q0.2054,1,0.1676,0.9852 T0.1016,0.9435 L0.0606,0.9059 Q0.0317,0.879,0.0159,0.8438 T0,0.7699 Z M0.5459,0.7699 Q0.5459,0.7172,0.5736,0.6731 T0.6489,0.6032 T0.7525,0.5774 Q0.7946,0.5774,0.8324,0.5922 T0.8984,0.6339 L0.9394,0.6715 Q0.9579,0.6892,0.9714,0.7105 T0.9925,0.7567 T1,0.8075 Q1,0.8602,0.9723,0.9046 T0.897,0.9745 T0.7934,1 Q0.7513,1,0.7135,0.9852 T0.6474,0.9435 L0.6065,0.9059 Q0.5776,0.879,0.5617,0.8438 T0.5459,0.7699 Z M0,0.1925 Q0,0.1398,0.0277,0.0957 T0.103,0.0258 T0.2066,0 Q0.2487,0,0.2865,0.0148 T0.3526,0.0565 L0.3935,0.0941 Q0.4218,0.121,0.438,0.1562 T0.4541,0.2301 Q0.4541,0.2828,0.4264,0.3269 T0.3511,0.3968 T0.2475,0.4226 Q0.2054,0.4226,0.1676,0.4078 T0.1016,0.3661 L0.0606,0.3285 Q0.0317,0.3016,0.0159,0.2664 T0,0.1925 Z M0.5459,0.1925 Q0.5459,0.1398,0.5736,0.0957 T0.6489,0.0258 T0.7525,0 Q0.7946,0,0.8324,0.0148 T0.8984,0.0565 L0.9394,0.0941 Q0.9677,0.121,0.9838,0.1562 T1,0.2301 Q1,0.2828,0.9723,0.3269 T0.897,0.3968 T0.7934,0.4226 Q0.7513,0.4226,0.7135,0.4078 T0.6474,0.3661 L0.6065,0.3285 Q0.5874,0.3108,0.5741,0.2895 T0.5534,0.2433 T0.5459,0.1925 Z M0.3301,0.6403 Q0.3306,0.6403,0.3312,0.6409 L0.3272,0.6371 L0.3272,0.6371 Z M0.8759,0.6403 Q0.8765,0.6403,0.8771,0.6409 Q0.8748,0.6387,0.8725,0.6371 L0.8731,0.6371 Z M0.3301,0.0629 Q0.3306,0.0629,0.3312,0.0634 L0.3272,0.0597 L0.3272,0.0602 Z M0.8759,0.0629 Q0.8765,0.0629,0.8771,0.0634 Q0.8748,0.0613,0.8725,0.0597 Q0.8731,0.0597,0.8731,0.0602 Z M0.779,0.4113 L0.7501,0.3849 Q0.7046,0.3844,0.6636,0.3661 Q0.7132,0.407,0.779,0.4113 Z M0.7957,0.4118 Q0.8477,0.4113,0.8918,0.3874 T0.9619,0.3223 T0.9885,0.2323 L0.9585,0.2048 Q0.9538,0.2769,0.8987,0.3282 T0.7657,0.3844 Z M0.9879,0.2167 Q0.9827,0.1554,0.9388,0.1097 Q0.9585,0.1478,0.959,0.1898 Z M0.2331,0.4113 L0.2043,0.3849 Q0.1587,0.3844,0.1177,0.3661 Q0.1673,0.407,0.2331,0.4113 Z M0.2499,0.4118 Q0.2885,0.4118,0.324,0.3973 T0.3852,0.3589 T0.4264,0.3019 T0.4426,0.2323 L0.4126,0.2048 Q0.408,0.2769,0.3529,0.3282 T0.2198,0.3844 Z M0.442,0.2167 Q0.4368,0.1554,0.393,0.1097 Q0.4126,0.1478,0.4132,0.1903 Z M0.779,0.9887 L0.7501,0.9624 Q0.7046,0.9618,0.6636,0.9435 Q0.7132,0.9844,0.779,0.9887 Z M0.7957,0.9892 Q0.8477,0.9887,0.8918,0.9648 T0.9619,0.8997 T0.9885,0.8097 L0.9585,0.7823 Q0.9538,0.8543,0.8987,0.9056 T0.7657,0.9618 Z M0.9879,0.7941 Q0.9827,0.7328,0.9388,0.6871 Q0.9585,0.7253,0.959,0.7672 Z M0.2331,0.9887 L0.2043,0.9624 Q0.1587,0.9618,0.1177,0.9435 Q0.1673,0.9844,0.2331,0.9887 Z M0.2499,0.9892 Q0.3018,0.9887,0.3459,0.9648 T0.416,0.8997 T0.4426,0.8102 L0.4126,0.7823 Q0.408,0.8543,0.3529,0.9056 T0.2198,0.9618 Z M0.442,0.7941 Q0.4368,0.7328,0.393,0.6871 Q0.4126,0.7253,0.4132,0.7672 Z M0.3191,0.6452 Q0.2943,0.622,0.2643,0.6091 T0.2066,0.5962 Q0.1795,0.5962,0.1497,0.6091 T0.0949,0.6441 T0.0537,0.6995 T0.0375,0.7699 Q0.0375,0.8419,0.0941,0.8941 Q0.1189,0.9172,0.1489,0.9304 T0.2066,0.9435 Q0.2337,0.9435,0.2634,0.9304 T0.3182,0.8952 T0.3595,0.8398 T0.3756,0.7699 Q0.3756,0.6978,0.3191,0.6452 Z M0.026,0.7731 L0.026,0.7699 Q0.026,0.6935,0.0854,0.6376 Q0.0658,0.6538,0.0514,0.6739 T0.0289,0.718 T0.0202,0.7677 Z M0.0271,0.7892 L0.0208,0.7833 Q0.0254,0.8419,0.0681,0.886 Q0.0664,0.8828,0.0646,0.879 Q0.0329,0.8382,0.0271,0.7892 Z M0.3866,0.7823 Q0.382,0.8511,0.3278,0.9016 Q0.3843,0.8565,0.3918,0.7871 Z M0.3872,0.7677 L0.393,0.7726 L0.393,0.7699 Q0.393,0.7349,0.3791,0.7038 Q0.3739,0.6973,0.3681,0.6914 Q0.3866,0.7274,0.3872,0.7677 Z M0.865,0.6452 Q0.8402,0.622,0.8102,0.6091 T0.7525,0.5962 Q0.7305,0.5962,0.7072,0.6043 T0.6619,0.628 T0.6223,0.6642 T0.5941,0.7124 T0.5834,0.7699 Q0.5834,0.8419,0.6399,0.8941 Q0.6561,0.9097,0.6757,0.9207 T0.7149,0.9376 T0.7525,0.9435 Q0.7796,0.9435,0.8093,0.9304 T0.8641,0.8952 T0.9054,0.8398 T0.9215,0.7699 Q0.9215,0.6978,0.865,0.6452 Z M0.5718,0.7731 L0.5718,0.7699 Q0.5718,0.6935,0.6313,0.6376 Q0.6013,0.6618,0.584,0.6954 T0.5661,0.7677 Z M0.573,0.7892 L0.5666,0.7833 Q0.5713,0.8419,0.614,0.886 Q0.6122,0.8828,0.6105,0.879 Q0.5788,0.8382,0.573,0.7892 Z M0.9325,0.7823 Q0.9279,0.8511,0.8736,0.9016 Q0.9308,0.8565,0.9377,0.7871 Z M0.9331,0.7672 L0.9388,0.7726 L0.9388,0.7699 Q0.9388,0.7349,0.925,0.7038 Q0.9198,0.6973,0.914,0.6914 Q0.9325,0.7274,0.9331,0.7672 Z M0.3191,0.0677 Q0.2943,0.0446,0.2643,0.0317 T0.2066,0.0188 Q0.1795,0.0188,0.1497,0.0317 T0.0949,0.0667 T0.0537,0.122 T0.0375,0.1925 Q0.0375,0.2645,0.0941,0.3167 Q0.1189,0.3398,0.1489,0.353 T0.2066,0.3661 Q0.2337,0.3661,0.2634,0.353 T0.3182,0.3177 T0.3595,0.2624 T0.3756,0.1925 Q0.3756,0.1204,0.3191,0.0677 Z M0.026,0.1957 L0.026,0.1925 Q0.026,0.1161,0.0854,0.0602 Q0.0554,0.0844,0.0381,0.118 T0.0202,0.1903 Z M0.0271,0.2118 L0.0208,0.2059 Q0.0254,0.2645,0.0681,0.3086 Q0.0664,0.3054,0.0646,0.3016 Q0.0329,0.2608,0.0271,0.2118 Z M0.3866,0.2048 Q0.382,0.2737,0.3278,0.3242 Q0.3849,0.279,0.3918,0.2097 Z M0.3872,0.1903 L0.393,0.1952 L0.393,0.1925 Q0.393,0.1581,0.3791,0.1263 Q0.3739,0.1199,0.3681,0.114 Q0.3866,0.15,0.3872,0.1903 Z M0.865,0.0677 Q0.8402,0.0446,0.8102,0.0317 T0.7525,0.0188 Q0.7253,0.0188,0.6956,0.0317 T0.6408,0.0667 T0.5995,0.122 T0.5834,0.1925 Q0.5834,0.2645,0.6399,0.3167 Q0.6647,0.3398,0.6947,0.353 T0.7525,0.3661 Q0.7796,0.3661,0.8093,0.353 T0.8641,0.3177 T0.9054,0.2624 T0.9215,0.1925 Q0.9215,0.1204,0.865,0.0677 Z M0.5718,0.1957 L0.5718,0.1925 Q0.5718,0.1161,0.6313,0.0602 Q0.6013,0.0844,0.584,0.118 T0.5661,0.1903 Z M0.573,0.2118 L0.5666,0.2059 Q0.5713,0.2645,0.614,0.3086 Q0.6122,0.3054,0.6105,0.3016 Q0.5788,0.2608,0.573,0.2118 Z M0.9325,0.2048 Q0.9279,0.2737,0.8736,0.3242 Q0.9308,0.279,0.9377,0.2097 Z M0.9331,0.1898 L0.9388,0.1952 L0.9388,0.1925 Q0.9388,0.1575,0.925,0.1263 Q0.9198,0.1199,0.914,0.114 Q0.9325,0.15,0.9331,0.1898 Z",type:0}},"":{type:5,data:{d:"M0.7639,0.1974 L0.9593,0.1974 L0.9593,0.1443 L0.7639,0.1443 L0.7639,0.1974 Z M0.7586,0.109 L0.9727,0.109 Q0.9839,0.109,0.992,0.1153 T1,0.1291 L1,0.382 Q1,0.3906,0.9912,0.3964 T0.9727,0.4021 L0.7586,0.4021 Q0.7468,0.4021,0.739,0.3956 T0.7313,0.382 L0.7313,0.1291 Q0.7313,0.1246,0.7339,0.1207 T0.7406,0.1143 T0.7495,0.1104 T0.7586,0.109 Z M0.7639,0.6575 L0.9593,0.6575 L0.9593,0.6044 L0.7639,0.6044 L0.7639,0.6575 Z M0.7313,0.8347 L0.7313,0.5843 Q0.7313,0.5757,0.7401,0.5699 T0.7586,0.5641 L0.9706,0.5641 Q0.9818,0.5641,0.9898,0.5705 T0.9979,0.5843 L0.9979,0.8347 Q0.9979,0.8433,0.989,0.8491 T0.9706,0.8549 L0.7586,0.8549 Q0.7468,0.8549,0.739,0.8483 T0.7313,0.8347 Z M0,1 L0,0 L0.7607,0 L0.7607,1 L0,1 Z",type:0}},"":{type:5,data:{d:"M0.9764,0.0029 L0.3179,0.4552 L0,0.4552 L0,0 Z M1,1 L0,1 L0,0.5448 L0.3091,0.5448 Z",type:0}},"":{type:5,data:{d:"M0.0236,0.0029 L0.6824,0.4552 L1,0.4552 L1,0 Z M0,1 L1,1 L1,0.5448 L0.6912,0.5448 Z",type:0}},"":{type:3,data:"M0,0 L1,0 L1,.05 L.1,.05 L.1,.95 L1,.95 L1,1 L0,1 Z"},"":{type:3,data:"M0,0 L1,0 L1,.05 L0,.05 Z M0,.95 L1,.95 L1,1 L0,1 Z"},"":{type:3,data:"M1,0 L0,0 L0,.05 L.9,.05 L.9,.95 L0,.95 L0,1 L1,1 Z"},"":{type:3,data:"M0,0 L1,0 L1,.05 L.1,.05 L.1,.95 L1,.95 L1,1 L0,1 Z M.25,.15 L1,.15 L1,.85 L.25,.85 Z"},"":{type:3,data:"M0,0 L1,0 L1,.05 L0,.05 Z M0,.95 L1,.95 L1,1 L0,1 Z M0,.15 L1,.15 L1,.85 L0,.85 Z"},"":{type:3,data:"M1,0 L0,0 L0,.05 L.9,.05 L.9,.95 L0,.95 L0,1 L1,1 Z M0,.15 L.75,.15 L.75,.85 L0,.85 Z"},"":{type:5,data:{d:"M0.6574,0.303 Q0.623,0.291,0.5852,0.285 T0.5082,0.279 T0.4311,0.285 T0.359,0.303 L0.3082,0.248 Q0.3525,0.232,0.4041,0.2235 T0.5082,0.215 T0.6123,0.2235 T0.7082,0.248 Z",type:0},scaleType:1},"":{type:5,data:{d:"M0.8557,0.582 L0.7656,0.551 Q0.7852,0.53,0.7951,0.507 T0.8049,0.46 Q0.8049,0.424,0.782,0.3905 T0.718,0.332 T0.6221,0.293 T0.5082,0.279 L0.5082,0.215 Q0.5607,0.215,0.6123,0.2235 T0.709,0.248 T0.7918,0.287 T0.8557,0.3375 T0.8959,0.3965 T0.9098,0.46 T0.8959,0.5235 T0.8557,0.582 Z",type:0},scaleType:1},"":{type:5,data:{d:"M0.5082,0.705 Q0.482,0.705,0.4557,0.703 T0.4049,0.697 L0.4311,0.635 Q0.4508,0.638,0.4697,0.6395 T0.5082,0.641 Q0.5672,0.641,0.6221,0.627 T0.718,0.588 T0.782,0.5295 T0.8049,0.46 Q0.8049,0.436,0.7951,0.413 T0.7656,0.369 L0.8557,0.338 Q0.882,0.365,0.8959,0.3965 T0.9098,0.46 T0.8959,0.5235 T0.8557,0.5825 T0.7918,0.633 T0.709,0.672 T0.6123,0.6965 T0.5082,0.705 Z",type:0},scaleType:1},"":{type:5,data:{d:"M0.5082,0.705 Q0.4557,0.705,0.4041,0.6965 T0.3074,0.672 T0.2246,0.633 T0.1607,0.5825 T0.1205,0.5235 T0.1066,0.46 L0.2115,0.46 Q0.2115,0.496,0.2344,0.5295 T0.2984,0.588 T0.3943,0.627 T0.5082,0.641 T0.6221,0.627 T0.718,0.588 T0.782,0.5295 T0.8049,0.46 L0.9098,0.46 Q0.9098,0.492,0.8959,0.5235 T0.8557,0.5825 T0.7918,0.633 T0.709,0.672 T0.6123,0.6965 T0.5082,0.705 Z",type:0},scaleType:1},"":{type:5,data:{d:"M0.5082,0.705 Q0.4557,0.705,0.4041,0.6965 T0.3074,0.672 T0.2246,0.633 T0.1607,0.5825 T0.1205,0.5235 T0.1066,0.46 T0.1205,0.3965 T0.1607,0.338 L0.2508,0.369 Q0.2311,0.39,0.2213,0.413 T0.2115,0.46 Q0.2115,0.496,0.2344,0.5295 T0.2984,0.588 T0.3943,0.627 T0.5082,0.641 Q0.5279,0.641,0.5467,0.6395 T0.5852,0.635 L0.6115,0.697 Q0.5869,0.701,0.5607,0.703 T0.5082,0.705 Z",type:0},scaleType:1},"":{type:5,data:{d:"M0.1607,0.582 Q0.1344,0.555,0.1205,0.5235 T0.1066,0.46 T0.1205,0.3965 T0.1607,0.3375 T0.2246,0.287 T0.3074,0.248 T0.4041,0.2235 T0.5082,0.215 L0.5082,0.279 Q0.4492,0.279,0.3943,0.293 T0.2984,0.332 T0.2344,0.3905 T0.2115,0.46 Q0.2115,0.484,0.2213,0.507 T0.2508,0.551 Z",type:0},scaleType:1},"":Fe.LINE_H,"":Fe.LINE_V,"":Fe.FADE_RIGHT,"":Fe.FADE_LEFT,"":Fe.FADE_DOWN,"":Fe.FADE_UP,"":Fe.CURVE_DOWN_RIGHT,"":Fe.CURVE_DOWN_LEFT,"":Fe.CURVE_UP_RIGHT,"":Fe.CURVE_UP_LEFT,"":[Fe.LINE_V,Fe.CURVE_UP_RIGHT],"":[Fe.LINE_V,Fe.CURVE_DOWN_RIGHT],"":[Fe.CURVE_DOWN_RIGHT,Fe.CURVE_UP_RIGHT],"":[Fe.LINE_V,Fe.CURVE_UP_LEFT],"":[Fe.LINE_V,Fe.CURVE_DOWN_LEFT],"":[Fe.CURVE_DOWN_LEFT,Fe.CURVE_UP_LEFT],"":[Fe.LINE_H,Fe.CURVE_DOWN_LEFT],"":[Fe.LINE_H,Fe.CURVE_DOWN_RIGHT],"":[Fe.CURVE_DOWN_LEFT,Fe.CURVE_DOWN_RIGHT],"":[Fe.LINE_H,Fe.CURVE_UP_LEFT],"":[Fe.LINE_H,Fe.CURVE_UP_RIGHT],"":[Fe.CURVE_UP_LEFT,Fe.CURVE_UP_RIGHT],"":[Fe.LINE_V,Fe.CURVE_UP_LEFT,Fe.CURVE_UP_RIGHT],"":[Fe.LINE_V,Fe.CURVE_DOWN_LEFT,Fe.CURVE_DOWN_RIGHT],"":[Fe.LINE_H,Fe.CURVE_DOWN_LEFT,Fe.CURVE_UP_LEFT],"":[Fe.LINE_H,Fe.CURVE_DOWN_RIGHT,Fe.CURVE_UP_RIGHT],"":[Fe.LINE_V,Fe.CURVE_DOWN_RIGHT,Fe.CURVE_UP_LEFT],"":[Fe.LINE_V,Fe.CURVE_DOWN_LEFT,Fe.CURVE_UP_RIGHT],"":[Fe.LINE_H,Fe.CURVE_DOWN_RIGHT,Fe.CURVE_UP_LEFT],"":[Fe.LINE_H,Fe.CURVE_DOWN_LEFT,Fe.CURVE_UP_RIGHT],"":[Fe.NODE_FILL,Fe.NODE_STROKE],"":Fe.NODE_STROKE,"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_STROKE,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_LEFT],"":[Fe.NODE_STROKE,Fe.NODE_LINE_LEFT],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_LEFT,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_STROKE,Fe.NODE_LINE_LEFT,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_DOWN],"":[Fe.NODE_STROKE,Fe.NODE_LINE_DOWN],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_UP],"":[Fe.NODE_STROKE,Fe.NODE_LINE_UP],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_UP],"":[Fe.NODE_STROKE,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_UP],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_STROKE,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_LEFT],"":[Fe.NODE_STROKE,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_LEFT],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_UP,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_STROKE,Fe.NODE_LINE_UP,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_UP,Fe.NODE_LINE_LEFT],"":[Fe.NODE_STROKE,Fe.NODE_LINE_UP,Fe.NODE_LINE_LEFT],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_UP,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_STROKE,Fe.NODE_LINE_UP,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_UP,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_LEFT],"":[Fe.NODE_STROKE,Fe.NODE_LINE_UP,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_LEFT],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_LEFT,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_STROKE,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_LEFT,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_UP,Fe.NODE_LINE_LEFT,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_STROKE,Fe.NODE_LINE_UP,Fe.NODE_LINE_LEFT,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_FILL,Fe.NODE_STROKE,Fe.NODE_LINE_UP,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_LEFT,Fe.NODE_LINE_RIGHT],"":[Fe.NODE_STROKE,Fe.NODE_LINE_UP,Fe.NODE_LINE_DOWN,Fe.NODE_LINE_LEFT,Fe.NODE_LINE_RIGHT],"🬀":vr(1),"🬁":vr(2),"🬂":vr(3),"🬃":vr(4),"🬄":vr(5),"🬅":vr(6),"🬆":vr(7),"🬇":vr(8),"🬈":vr(9),"🬉":vr(10),"🬊":vr(11),"🬋":vr(12),"🬌":vr(13),"🬍":vr(14),"🬎":vr(15),"🬏":vr(16),"🬐":vr(17),"🬑":vr(18),"🬒":vr(19),"🬓":vr(20),"🬔":vr(22),"🬕":vr(23),"🬖":vr(24),"🬗":vr(25),"🬘":vr(26),"🬙":vr(27),"🬚":vr(28),"🬛":vr(29),"🬜":vr(30),"🬝":vr(31),"🬞":vr(32),"🬟":vr(33),"🬠":vr(34),"🬡":vr(35),"🬢":vr(36),"🬣":vr(37),"🬤":vr(38),"🬥":vr(39),"🬦":vr(40),"🬧":vr(41),"🬨":vr(43),"🬩":vr(44),"🬪":vr(45),"🬫":vr(46),"🬬":vr(47),"🬭":vr(48),"🬮":vr(49),"🬯":vr(50),"🬰":vr(51),"🬱":vr(52),"🬲":vr(53),"🬳":vr(54),"🬴":vr(55),"🬵":vr(56),"🬶":vr(57),"🬷":vr(58),"🬸":vr(59),"🬹":vr(60),"🬺":vr(61),"🬻":vr(62),"🬼":{type:3,data:"M0,0.6667 L0,1 L0.5,1 Z"},"🬽":{type:3,data:"M0,0.6667 L0,1 L1,1 Z"},"🬾":{type:3,data:"M0,0.3333 L0,1 L0.5,1 Z"},"🬿":{type:3,data:"M0,0.3333 L0,1 L1,1 Z"},"🭀":{type:3,data:"M0,0 L0,1 L0.5,1 Z"},"🭁":{type:3,data:"M0,0.3333 L0.5,0 L1,0 L1,1 L0,1 Z"},"🭂":{type:3,data:"M0,0.3333 L1,0 L1,1 L0,1 Z"},"🭃":{type:3,data:"M0,0.6667 L0.5,0 L1,0 L1,1 L0,1 Z"},"🭄":{type:3,data:"M0,0.6667 L1,0 L1,1 L0,1 Z"},"🭅":{type:3,data:"M0,1 L0.5,0 L1,0 L1,1 Z"},"🭆":{type:3,data:"M0,0.6667 L1,0.3333 L1,1 L0,1 Z"},"🭇":{type:3,data:"M0.5,1 L1,0.6667 L1,1 Z"},"🭈":{type:3,data:"M0,1 L1,0.6667 L1,1 Z"},"🭉":{type:3,data:"M0.5,1 L1,0.3333 L1,1 Z"},"🭊":{type:3,data:"M0,1 L1,0.3333 L1,1 Z"},"🭋":{type:3,data:"M0.5,1 L1,0 L1,1 Z"},"🭌":{type:3,data:"M0.5,0 L0,0 L0,1 L1,1 L1,0.3333 Z"},"🭍":{type:3,data:"M0,0 L0,1 L1,1 L1,0.3333 Z"},"🭎":{type:3,data:"M0.5,0 L0,0 L0,1 L1,1 L1,0.6667 Z"},"🭏":{type:3,data:"M0,0 L0,1 L1,1 L1,0.6667 Z"},"🭐":{type:3,data:"M0.5,0 L0,0 L0,1 L1,1 Z"},"🭑":{type:3,data:"M0,0.3333 L0,1 L1,1 L1,0.6667 Z"},"🭒":{type:3,data:"M0,0.6667 L0.5,1 L1,1 L1,0 L0,0 Z"},"🭓":{type:3,data:"M0,0.6667 L1,1 L1,0 L0,0 Z"},"🭔":{type:3,data:"M0,0.3333 L0.5,1 L1,1 L1,0 L0,0 Z"},"🭕":{type:3,data:"M0,0.3333 L1,1 L1,0 L0,0 Z"},"🭖":{type:3,data:"M0,0 L0.5,1 L1,1 L1,0 Z"},"🭗":{type:3,data:"M0,0.3333 L0,0 L0.5,0 Z"},"🭘":{type:3,data:"M0,0.3333 L0,0 L1,0 Z"},"🭙":{type:3,data:"M0,0.6667 L0,0 L0.5,0 Z"},"🭚":{type:3,data:"M0,0.6667 L0,0 L1,0 Z"},"🭛":{type:3,data:"M0,1 L0,0 L0.5,0 Z"},"🭜":{type:3,data:"M0,0.6667 L0,0 L1,0 L1,0.3333 Z"},"🭝":{type:3,data:"M0.5,1 L0,1 L0,0 L1,0 L1,0.6667 Z"},"🭞":{type:3,data:"M0,1 L0,0 L1,0 L1,0.6667 Z"},"🭟":{type:3,data:"M0.5,1 L0,1 L0,0 L1,0 L1,0.3333 Z"},"🭠":{type:3,data:"M0,1 L0,0 L1,0 L1,0.3333 Z"},"🭡":{type:3,data:"M0.5,1 L0,1 L0,0 L1,0 Z"},"🭢":{type:3,data:"M0.5,0 L1,0 L1,0.3333 Z"},"🭣":{type:3,data:"M0,0 L1,0 L1,0.3333 Z"},"🭤":{type:3,data:"M0.5,0 L1,0 L1,0.6667 Z"},"🭥":{type:3,data:"M0,0 L1,0 L1,0.6667 Z"},"🭦":{type:3,data:"M0.5,0 L1,0 L1,1 Z"},"🭧":{type:3,data:"M0,0.3333 L1,0.6667 L1,0 L0,0 Z"},"🭨":{type:3,data:"M0,0 L1,0 L1,1 L0,1 L0.5,0.5 Z"},"🭩":{type:3,data:"M0,0 L0.5,0.5 L1,0 L1,1 L0,1 Z"},"🭪":{type:3,data:"M0,0 L1,0 L0.5,0.5 L1,1 L0,1 Z"},"🭫":{type:3,data:"M0,0 L1,0 L1,1 L0.5,0.5 L0,1 Z"},"🭬":{type:3,data:"M0,0 L0.5,0.5 L0,1 Z"},"🭭":{type:3,data:"M0,0 L1,0 L0.5,0.5 Z"},"🭮":{type:3,data:"M1,0 L1,1 L0.5,0.5 Z"},"🭯":{type:3,data:"M0,1 L1,1 L0.5,0.5 Z"},"🭰":{type:0,data:[{x:1,y:0,w:1,h:8}]},"🭱":{type:0,data:[{x:2,y:0,w:1,h:8}]},"🭲":{type:0,data:[{x:3,y:0,w:1,h:8}]},"🭳":{type:0,data:[{x:4,y:0,w:1,h:8}]},"🭴":{type:0,data:[{x:5,y:0,w:1,h:8}]},"🭵":{type:0,data:[{x:6,y:0,w:1,h:8}]},"🭶":{type:0,data:[{x:0,y:1,w:8,h:1}]},"🭷":{type:0,data:[{x:0,y:2,w:8,h:1}]},"🭸":{type:0,data:[{x:0,y:3,w:8,h:1}]},"🭹":{type:0,data:[{x:0,y:4,w:8,h:1}]},"🭺":{type:0,data:[{x:0,y:5,w:8,h:1}]},"🭻":{type:0,data:[{x:0,y:6,w:8,h:1}]},"🭼":{type:0,data:[{x:0,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}]},"🭽":{type:0,data:[{x:0,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}]},"🭾":{type:0,data:[{x:7,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}]},"🭿":{type:0,data:[{x:7,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}]},"🮀":{type:0,data:[{x:0,y:0,w:8,h:1},{x:0,y:7,w:8,h:1}]},"🮁":{type:0,data:[{x:0,y:0,w:8,h:1},{x:0,y:2,w:8,h:1},{x:0,y:4,w:8,h:1},{x:0,y:7,w:8,h:1}]},"🮂":{type:0,data:[{x:0,y:0,w:8,h:2}]},"🮃":{type:0,data:[{x:0,y:0,w:8,h:3}]},"🮄":{type:0,data:[{x:0,y:0,w:8,h:5}]},"🮅":{type:0,data:[{x:0,y:0,w:8,h:6}]},"🮆":{type:0,data:[{x:0,y:0,w:8,h:7}]},"🮇":{type:0,data:[{x:6,y:0,w:2,h:8}]},"🮈":{type:0,data:[{x:5,y:0,w:3,h:8}]},"🮉":{type:0,data:[{x:3,y:0,w:5,h:8}]},"🮊":{type:0,data:[{x:2,y:0,w:6,h:8}]},"🮋":{type:0,data:[{x:1,y:0,w:7,h:8}]},"🮌":{type:1,data:[[1,0],[0,1]],clipPath:"M0,0 L0.5,0 L0.5,1 L0,1 Z"},"🮍":{type:1,data:[[1,0],[0,1]],clipPath:"M0.5,0 L1,0 L1,1 L0.5,1 Z"},"🮎":{type:1,data:[[1,0],[0,1]],clipPath:"M0,0 L1,0 L1,0.5 L0,0.5 Z"},"🮏":{type:1,data:[[1,0],[0,1]],clipPath:"M0,0.5 L1,0.5 L1,1 L0,1 Z"},"🮐":{type:1,data:[[0,1],[1,0]]},"🮑":[{type:1,data:[[0,1],[1,0]],clipPath:"M0,0.5 L1,0.5 L1,1 L0,1 Z"},{type:0,data:[{x:0,y:0,w:8,h:4}]}],"🮒":[{type:1,data:[[0,1],[1,0]],clipPath:"M0,0 L1,0 L1,0.5 L0,0.5 Z"},{type:0,data:[{x:0,y:4,w:8,h:4}]}],"🮔":[{type:1,data:[[0,1],[1,0]],clipPath:"M0,0 L0.5,0 L0.5,1 L0,1 Z"},{type:0,data:[{x:4,y:0,w:4,h:8}]}],"🮕":{type:0,data:[{x:0,y:0,w:2,h:2},{x:4,y:0,w:2,h:2},{x:2,y:2,w:2,h:2},{x:6,y:2,w:2,h:2},{x:0,y:4,w:2,h:2},{x:4,y:4,w:2,h:2},{x:2,y:6,w:2,h:2},{x:6,y:6,w:2,h:2}]},"🮖":{type:0,data:[{x:2,y:0,w:2,h:2},{x:6,y:0,w:2,h:2},{x:0,y:2,w:2,h:2},{x:4,y:2,w:2,h:2},{x:2,y:4,w:2,h:2},{x:6,y:4,w:2,h:2},{x:0,y:6,w:2,h:2},{x:4,y:6,w:2,h:2}]},"🮗":{type:0,data:[{x:0,y:2,w:8,h:2},{x:0,y:6,w:8,h:2}]},"🮘":{type:2,data:"M-0.25,-0.25 L1.25,1.25 M-0.25,0 L1,1.25 M-0.25,0.25 L0.75,1.25 M-0.25,0.5 L0.5,1.25 M0,-0.25 L1.25,1 M0.25,-0.25 L1.25,0.75 M0.5,-0.25 L1.25,0.5 M-0.25,0.75 L0.25,1.25 M0.75,-0.25 L1.25,0.25",strokeWidth:1},"🮙":{type:2,data:"M-0.25,0.5 L0.5,-0.25 M-0.25,0.75 L0.75,-0.25 M-0.25,1 L1,-0.25 M-0.25,1.25 L1.25,-0.25 M0,1.25 L1.25,0 M0.25,1.25 L1.25,0.25 M0.5,1.25 L1.25,0.5 M-0.25,0.25 L0.25,-0.25 M0.75,1.25 L1.25,0.75",strokeWidth:1},"🮚":{type:5,data:{d:"M0,0 L.5,.5 L0,1 L1,1 L.5,.5 L1,0",type:0}},"🮛":{type:5,data:{d:"M0,0 L.5,.5 L1,0 L1,1 L.5,.5 L0,1",type:0}},"🮜":{type:1,data:[[1,0],[0,1]],clipPath:"M0,0 L1,0 L0,1 Z"},"🮝":{type:1,data:[[1,0],[0,1]],clipPath:"M0,0 L1,0 L1,1 Z"},"🮞":{type:1,data:[[1,0],[0,1]],clipPath:"M1,0 L1,1 L0,1 Z"},"🮟":{type:1,data:[[1,0],[0,1]],clipPath:"M0,0 L1,1 L0,1 Z"},"🮠":{type:2,data:"M.5,0 L0,.5",strokeWidth:1},"🮡":{type:2,data:"M.5,0 L1,.5",strokeWidth:1},"🮢":{type:2,data:"M0,.5 L.5,1",strokeWidth:1},"🮣":{type:2,data:"M1,.5 L.5,1",strokeWidth:1},"🮤":{type:2,data:"M.5,0 L0,.5 L.5,1",strokeWidth:1},"🮥":{type:2,data:"M.5,0 L1,.5 L.5,1",strokeWidth:1},"🮦":{type:2,data:"M0,.5 L.5,1 L1,.5",strokeWidth:1},"🮧":{type:2,data:"M0,.5 L.5,0 L1,.5",strokeWidth:1},"🮨":{type:2,data:"M.5,0 L0,.5 M1,.5 L.5,1",strokeWidth:1},"🮩":{type:2,data:"M.5,0 L1,.5 M0,.5 L.5,1",strokeWidth:1},"🮪":{type:2,data:"M.5,0 L1,.5 L.5,1 L0,.5",strokeWidth:1},"🮫":{type:2,data:"M.5,0 L0,.5 L.5,1 L1,.5",strokeWidth:1},"🮬":{type:2,data:"M0,.5 L.5,0 L1,.5 L.5,1",strokeWidth:1},"🮭":{type:2,data:"M1,.5 L.5,0 L0,.5 L.5,1",strokeWidth:1},"🮮":{type:2,data:"M.5,0 L1,.5 L.5,1 L0,.5 Z",strokeWidth:1},"🮯":{type:2,data:"M0,.5 L1,.5 M.5,.35 L.5,.65",strokeWidth:1},"🮰":{type:3,data:"M0.1,0.2 L0.1,.8 L.4,.6 L.9,0.6 Z",scaleType:1},"🮱":{type:4,data:{d:"M.1,.525 L.35,.675 L.9,.35",type:1},scaleType:1},"🮲":{type:3,data:"M.29,.27 L0.13,.56 L.22,.59 L.35,0.35 L.67,.35 L.57,.57 L.71,.76 L.22,.76 L.42,1 L.53,.98 L.43,.86 L.9,.86 L.71,.6 L1,.6 L1,.52 L.83,.52 L.92,.36 L1,.36 L1,.27Z M.99,.13 A.12,.12,0,1,1,.75,.13 A.12,.12,0,1,1,.99,.13"},"🮳":{type:3,data:"M0,.27 L.3,.27 L.55,.12 L.63,.18 L.33,.36 L0,.36 M0,.52 L.33,.52 L.59,.89 L.73,.89 L.73,.98 L.53,.98 L.28,.6 L0,.6"},"🮴":{type:4,data:{d:"M.15,.55 L.5,.4 L.5,.45 L.65,.45 L.65,.35 L.85,.35 L.85,.625 L.5,.625 L.5,.7 Z",type:0},scaleType:1},"🮵":[{type:5,data:{d:"M0,0 L1,0 L1,.0625 L0,.0625 Z M0,.9375 L1,.9375 L1,1 L0,1 Z",type:0}},{type:5,data:{d:"M.15,.5 L.5,.35 L.5,.425 L.85,.425 L.85,.575 L.5,.575 L.5,.65 Z",type:0},scaleType:1}],"🮶":[{type:5,data:{d:"M0,0 L1,0 L1,.0625 L0,.0625 Z M0,.9375 L1,.9375 L1,1 L0,1 Z",type:0}},{type:5,data:{d:"M.85,.5 L.5,.35 L.5,.425 L.15,.425 L.15,.575 L.5,.575 L.5,.65 Z",type:0},scaleType:1}],"🮷":[{type:5,data:{d:"M.875,0 L1,0 L1,1 L.875,1 Z",type:0}},{type:5,data:{d:"M.5,.675 L.2,.5 L.35,.5 L.35,.325 L.65,.325 L.65,.5 L.8,.5 Z",type:0},scaleType:1}],"🮸":[{type:5,data:{d:"M.875,0 L1,0 L1,1 L.875,1 Z",type:0}},{type:5,data:{d:"M.5,.325 L.2,.5 L.35,.5 L.35,.675 L.65,.675 L.65,.5 L.8,.5 Z",type:0},scaleType:1}],"🮹":{type:5,data:{d:"M1,.89 L.11,.89 L.11,.37 L.36,.12 L.74,.12 L.96,.34 L1,.34 L1,.405 L.92,.405 L.69,.185 L.41,.185 L.21,.42 L.21,.825 L1,.825 Z",type:0}},"🮺":{type:5,data:{d:"M0,.89 L0,.825 L.78,.825 L.78,.53 L.7,.415 L0,.415 L0,.35 L.75,.35 L.88,.48 L.88,.89 Z",type:0}},"🮻":{type:5,data:{d:"M.31,.275 L.44,.275 L.44,.47 L.05,.47 L.05,.405 L.31,.405 Z M.56,.275 L.69,.275 L.69,.405 L.95,.405 L.95,.47 L.56,.47 Z M.05,.53 L.44,.53 L.44,.725 L.31,.725 L.31,.595 L.05,.595 Z M.56,.53 L.95,.53 L.95,.595 L.69,.595 L.69,.725 L.56,.725 Z",type:0},scaleType:1},"🮼":[{type:3,data:"M0,0 L1,0 L1,1 L0,1 L0,.935 L.885,.935 L.885,.065 L0,.065 Z"},{type:3,data:"M.67,.5 A.17,.085,0,1,1,.33,.5 A.17,.085,0,1,1,.67,.5",scaleType:1}],"🮽":{type:4,data:{d:"M0,0 L.5,.5 L1,0 L1,1 L.5,.5 L0,1 Z",type:1}},"🮾":{type:4,data:{d:"M1,.5 L.5,1",type:1}},"🮿":{type:4,data:{d:"M.5,0 L1,.5 L.5,1 L0,.5 Z",type:1}},"🯀":{type:3,data:"M.16,.445 A.02,.01,0,0,1,.39,.33 L.5,.375 L.61,.33 A.02,.01,0,0,1,.84,.445 L.75,.5 L.84,.555 A.02,.01,0,0,1,.61,.67 L.5,.625 L.39,.67 A.02,.01,0,0,1,.16,.555 L.25,.5 Z M.24,.41 L.39,.5 L.24,.59 L.32,.63 L.5,.555 L.68,.63 L.76,.59 L.61,.5 L.76,.41 L.68,.37 L.5,.445 L.32,.37 Z",scaleType:1},"🯁":{type:3,data:"M0.142308,0.924 Q0.130770,0.924,0.120193,0.922 T0.101924,0.916 T0.089424,0.9065 T0.084616,0.895 V0.025 Q0.084616,0.019,0.089424,0.0135 T0.101924,0.004 T0.120193,-0.002 T0.142308,-0.004 Q0.150000,-0.004,0.157693,-0.003 T0.173078,0.000 L0.430770,0.085 Q0.451924,0.059,0.494232,0.041 T0.587501,0.013 T0.692309,-0.0005 T0.800001,-0.004 H1 V0.055 H0.800001 Q0.771155,0.055,0.742309,0.056 T0.685578,0.060 T0.630770,0.0685 T0.580770,0.0825 T0.543270,0.1045 T0.528847,0.133 V0.647 H0.530770 Q0.596155,0.645,0.659616,0.638 T0.782693,0.6165 T0.893270,0.5805 T1,0.531 V0.623 Q0.934616,0.644,0.880770,0.6595 T0.769232,0.685 T0.650963,0.700 T0.528847,0.707 V0.787 Q0.528847,0.802,0.543270,0.8155 T0.580770,0.8375 T0.630770,0.8515 T0.685578,0.860 T0.742309,0.864 T0.800001,0.865 H1 V0.924 H0.800001 Q0.746155,0.924,0.692309,0.9205 T0.587501,0.907 T0.494232,0.879 T0.430770,0.835 L0.173078,0.920 Q0.165386,0.922,0.157693,0.923 T0.142308,0.924 Z M0.2,0.841 L0.415385,0.770 V0.150 L0.2,0.079 V0.841 Z M1,0.698 Q0.973077,0.694,0.969231,0.6885 T0.965385,0.677 Q0.965385,0.672,0.969231,0.6665 T1,0.657 V0.698 Z"},"🯂":{type:3,data:"M0,0.623 V0.531 Q0.044231,0.512,0.0625,0.4905 T0.092308,0.4465 T0.108654,0.4005 T0.113462,0.354 V0.351 Q0.113462,0.345,0.117308,0.3395 T0.129808,0.3305 T0.148846,0.3245 T0.171154,0.323 H0.501923 Q0.532692,0.323,0.563462,0.3185 T0.617308,0.303 T0.651923,0.2765 T0.663462,0.2435 V0.241 Q0.663462,0.219,0.657692,0.197 T0.639423,0.1545 T0.604808,0.115 T0.549615,0.082 T0.475577,0.0615 T0.392308,0.055 H0 V-0.004 H1 V0.055 H0.667308 Q0.694231,0.071,0.713462,0.09 T0.746154,0.129 T0.766346,0.1705 T0.775,0.213 H1 V0.316 Q0.971154,0.305,0.955769,0.2965 T0.920192,0.2825 T0.876923,0.2745 T0.830769,0.272 H0.773077 Q0.767308,0.297,0.743269,0.319 T0.680769,0.355 T0.595192,0.375 T0.501923,0.381 H0.227308 Q0.223462,0.415,0.211,0.4485 T0.172692,0.5135 T0.108269,0.573 T0,0.623 Z M0.611538,0.924 H0 V0.865 H0.611538 Q0.642308,0.865,0.673077,0.8605 T0.727885,0.845 T0.762308,0.8185 T0.773077,0.787 V0.785 Q0.773077,0.769,0.762308,0.7535 T0.727885,0.727 T0.673077,0.7115 T0.611538,0.707 H0.059615 Q0.048077,0.707,0.037115,0.7045 T0,0.694 V0.653 Q0.026923,0.648,0.037115,0.646 T0.059615,0.644 H0.722692 Q0.753462,0.644,0.784231,0.6395 T0.839038,0.624 T0.873846,0.5975 T0.884615,0.566 V0.564 Q0.884615,0.548,0.873846,0.532 T0.839038,0.5055 T0.784231,0.49 T0.722692,0.4855 H0.392308 Q0.380769,0.4855,0.370192,0.483 T0.351923,0.4765 T0.339423,0.467 T0.334615,0.4555 T0.339423,0.444 T0.351923,0.4345 T0.370192,0.428 T0.392308,0.4255 H0.832692 Q0.855769,0.4255,0.878846,0.4235 T0.922115,0.416 T0.957692,0.4015 T1,0.3815 V0.4685 Q0.975,0.4705,0.966346,0.4725 T0.95,0.4765 Q0.961538,0.4835,0.969231,0.4915 T1,0.5075 V0.6205 Q0.965385,0.6455,0.926923,0.665 T0.84,0.6935 Q0.866923,0.7115,0.877596,0.7345 T0.894231,0.7855 V0.787 Q0.894231,0.815,0.876923,0.8425 T0.820192,0.8895 T0.726923,0.916 T0.611538,0.924 Z"},"🯃":{type:3,data:"M0,0.473 V0.386 Q0.025490,0.378,0.028431,0.3695 T0.031373,0.352 V0.35 Q0.031373,0.342,0.028431,0.333 T0,0.316 V0.213 H0.652941 Q0.684314,0.213,0.715686,0.2085 T0.770588,0.193 T0.804902,0.1665 T0.815686,0.135 V0.133 Q0.815686,0.117,0.804902,0.101 T0.770588,0.0745 T0.715686,0.0595 T0.652941,0.055 H0 V-0.004 H0.652941 Q0.707843,-0.004,0.761765,0.004 T0.856863,0.031 T0.915686,0.0775 T0.933333,0.133 V0.135 Q0.933333,0.163,0.915686,0.1905 T0.856863,0.237 T0.761765,0.264 T0.652941,0.272 H0.109804 Q0.131373,0.29,0.140196,0.31 T0.149020,0.35 V0.352 Q0.149020,0.37,0.142157,0.388 T0.118627,0.4225 T0.076471,0.452 T0,0.473 Z M0,0.625 V0.513 Q0.029412,0.526,0.032353,0.54 T0.035294,0.568 V0.57 Q0.035294,0.584,0.032353,0.598 T0,0.625 Z"},"🯄":{type:3,data:"M0.019231,1.085 V-0.165 H0.980769 V1.085 H0.019231 Z M0.446154,0.527 H0.553846 Q0.553846,0.511,0.5625,0.495 T0.591346,0.466 T0.631731,0.4405 T0.666346,0.4135 T0.688462,0.3825 T0.696154,0.35 Q0.696154,0.33,0.682692,0.311 T0.641346,0.2785 T0.575,0.259 T0.498077,0.253 T0.421154,0.259 T0.356731,0.279 T0.315385,0.3125 T0.301923,0.352 V0.357 H0.409615 V0.354 Q0.409615,0.345,0.414423,0.335 T0.431731,0.318 T0.4625,0.3075 T0.498077,0.304 Q0.517308,0.304,0.534615,0.307 T0.564423,0.3165 T0.582692,0.332 T0.588462,0.35 Q0.588462,0.366,0.572115,0.3805 T0.535577,0.4075 T0.496154,0.4335 T0.465385,0.4625 T0.45,0.4945 T0.446154,0.527 Z M0.5,0.667 Q0.519231,0.667,0.5375,0.664 T0.569231,0.654 T0.588462,0.637 T0.594231,0.617 T0.588462,0.5975 T0.569231,0.581 T0.5375,0.571 T0.5,0.568 T0.4625,0.571 T0.430769,0.581 T0.411538,0.5975 T0.405769,0.617 T0.411538,0.637 T0.430769,0.654 T0.4625,0.664 T0.5,0.667 Z",scaleType:1},"🯅":{type:5,data:{d:"M.44,.425 L.44,.51 L.44,.56 L.19,.685 L.26,.72 L.5,.605 L.74,.72 L.81,.685 L.56,.56 L.56,.51 L.56,.425 Z M.17,.46 L.17,.51 L.83,.51 L.83,.46 Z M.67,.35 C.67,.303,.594,.265,.5,.265 C.406,.265,.33,.303,.33,.35 C.33,.397,.406,.435,.5,.435 C.594,.435,.67,.397,.67,.35 Z M.56,.35 C.56,.3665,.533,.38,.5,.38 C.467,.38,.44,.3665,.44,.35 C.44,.3335,.467,.32,.5,.32 C.533,.32,.56,.3335,.56,.35 Z",type:0},scaleType:1},"🯆":{type:5,data:{d:"M.44,.425 L.44,.46 L.23,.385 L.19,.43 L.44,.51 L.44,.56 L.29,.71 L.38,.735 L.5,.605 L.61,.735 L.7,.71 L.56,.56 L.56,.51 L.81,.43 L.77,.385 L.56,.46 L.56,.425 Z M.67,.35 C.67,.303,.594,.265,.5,.265 C.406,.265,.33,.303,.33,.35 C.33,.397,.406,.435,.5,.435 C.594,.435,.67,.397,.67,.35 Z M.56,.35 C.56,.3665,.533,.38,.5,.38 C.467,.38,.44,.3665,.44,.35 C.44,.3335,.467,.32,.5,.32 C.533,.32,.56,.3335,.56,.35 Z",type:0},scaleType:1},"🯇":{type:5,data:{d:"M.44,.425 L.44,.56 L.29,.71 L.38,.735 L.5,.605 L.74,.72 L.81,.685 L.56,.56 L.56,.425 Z M.18,.53 L.23,.575 L.81,.43 L.77,.385 Z M.67,.35 C.67,.303,.594,.265,.5,.265 C.406,.265,.33,.303,.33,.35 C.33,.397,.406,.435,.5,.435 C.594,.435,.67,.397,.67,.35 Z M.56,.35 C.56,.3665,.533,.38,.5,.38 C.467,.38,.44,.3665,.44,.35 C.44,.3335,.467,.32,.5,.32 C.533,.32,.56,.3335,.56,.35 Z",type:0},scaleType:1},"🯈":{type:5,data:{d:"M.44,.425 L.44,.56 L.19,.685 L.26,.72 L.5,.605 L.62,.735 L.71,.71 L.56,.56 L.56,.425 Z M.23,.385 L.18,.43 L.77,.575 L.81,.53 Z M.67,.35 C.67,.303,.594,.265,.5,.265 C.406,.265,.33,.303,.33,.35 C.33,.397,.406,.435,.5,.435 C.594,.435,.67,.397,.67,.35 Z M.56,.35 C.56,.3665,.533,.38,.5,.38 C.467,.38,.44,.3665,.44,.35 C.44,.3335,.467,.32,.5,.32 C.533,.32,.56,.3335,.56,.35 Z",type:0},scaleType:1},"🯉":{type:5,data:{d:"M.44,.425 L.45,.495 L.15,.645 L.34,.645 L.34,.7 L.44,.7 L.44,.645 L.56,.645 L.56,.7 L.66,.7 L.66,.645 L.84,.645 L.54,.495 L.56,.425 Z M.39,.6 L.5,.55 L.60,.6 Z M.17,.46 L.17,.51 L.83,.51 L.83,.46 Z M.67,.35 C.67,.303,.594,.265,.5,.265 C.406,.265,.33,.303,.33,.35 C.33,.397,.406,.435,.5,.435 C.594,.435,.67,.397,.67,.35 Z M.56,.35 C.56,.3665,.533,.38,.5,.38 C.467,.38,.44,.3665,.44,.35 C.44,.3335,.467,.32,.5,.32 C.533,.32,.56,.3335,.56,.35 Z",type:0},scaleType:1},"🯊":{type:5,data:{d:"M.26,.375 L.5,.255 L.74,.375 L.74,.665 L.5,.55 L.26,.665 Z M.37,.395 L.37,.54 L.5,.475 L.63,.54 L.63,.395 L.5,.33 Z",type:0},scaleType:1},"🯋":{type:5,data:{d:"M.09,.41 L.32,.295 L.5,.375 L.68,.295 L.91,.41 L.75,.5 L.91,.59 L.68,.705 L.5,.625 L.32,.705 L.09,.59 L.25,.5 Z M.24,.41 L.39,.5 L.24,.59 L.32,.63 L.5,.555 L.68,.63 L.76,.59 L.61,.5 L.76,.41 L.68,.37 L.5,.445 L.32,.37 Z",type:0},scaleType:1},"🯌":{type:5,data:{d:"M.55,.305 L.88,.305 L.88,.355 L.65,.355 L.65,.47 L.88,.47 L.88,.52 L.55,.52 Z",type:0},scaleType:1},"🯍":{type:5,data:{d:"M.38,.39 L.5,.33 L.62,.39 L.62,.53 L.5,.47 L.38,.53 Z",type:0},scaleType:1},"🯎":{type:3,data:"M0,0 L0.6667,0 L0.6667,1 L0,1 Z"},"🯏":{type:3,data:"M0,0 L0.3333,0 L0.3333,1 L0,1 Z"},"🯐":{type:2,data:"M1,.5 L0,1",strokeWidth:1},"🯑":{type:2,data:"M1,0 L0,.5",strokeWidth:1},"🯒":{type:2,data:"M0,0 L1,.5",strokeWidth:1},"🯓":{type:2,data:"M0,.5 L1,1",strokeWidth:1},"🯔":{type:2,data:"M0,0 L.5,1",strokeWidth:1},"🯕":{type:2,data:"M.5,0 L1,1",strokeWidth:1},"🯖":{type:2,data:"M1,0 L.5,1",strokeWidth:1},"🯗":{type:2,data:"M.5,0 L0,1",strokeWidth:1},"🯘":{type:2,data:"M0,0 L.5,.5 L1,0",strokeWidth:1},"🯙":{type:2,data:"M1,0 L.5,.5 L1,1",strokeWidth:1},"🯚":{type:2,data:"M0,1 L.5,.5 L1,1",strokeWidth:1},"🯛":{type:2,data:"M0,0 L.5,.5 L0,1",strokeWidth:1},"🯜":{type:2,data:"M0,0 L.5,1 L1,0",strokeWidth:1},"🯝":{type:2,data:"M1,0 L0,.5 L1,1",strokeWidth:1},"🯞":{type:2,data:"M0,1 L.5,0 L1,1",strokeWidth:1},"🯟":{type:2,data:"M0,0 L1,.5 L0,1",strokeWidth:1},"🯠":{type:5,data:{d:"M0,0 C0,.276,.224,.5,.5,.5 C.776,.5,1,.276,1,0",type:1}},"🯡":{type:5,data:{d:"M1,0 C.724,0,.5,.224,.5,.5 C.5,.776,.724,1,1,1",type:1}},"🯢":{type:5,data:{d:"M0,1 C0,.724,.224,.5,.5,.5 C.776,.5,1,.724,1,1",type:1}},"🯣":{type:5,data:{d:"M0,0 C.276,0,.5,.224,.5,.5 C.5,.776,.276,1,0,1",type:1}},"🯤":{type:0,data:[{x:2,y:0,w:4,h:4}]},"🯥":{type:0,data:[{x:2,y:4,w:4,h:4}]},"🯦":{type:0,data:[{x:0,y:2,w:4,h:4}]},"🯧":{type:0,data:[{x:4,y:2,w:4,h:4}]},"🯨":{type:5,data:{d:"M0,0 C0,.276,.224,.5,.5,.5 C.776,.5,1,.276,1,0 Z",type:0}},"🯩":{type:5,data:{d:"M1,0 C.724,0,.5,.224,.5,.5 C.5,.776,.724,1,1,1 Z",type:0}},"🯪":{type:5,data:{d:"M0,1 C0,.724,.224,.5,.5,.5 C.776,.5,1,.724,1,1 Z",type:0}},"🯫":{type:5,data:{d:"M0,0 C.276,0,.5,.224,.5,.5 C.5,.776,.276,1,0,1 Z",type:0}},"🯬":{type:5,data:{d:"M1,0 L.5,0 C.5,.276,.724,.5,1,.5 Z",type:0}},"🯭":{type:5,data:{d:"M0,1 L.5,1 C.5,.724,.276,.5,0,.5 Z",type:0}},"🯮":{type:5,data:{d:"M1,1 L1,.5 C.724,.5,.5,.724,.5,1 Z",type:0}},"🯯":{type:5,data:{d:"M0,0 L0,.5 C.276,.5,.5,.276,.5,0 Z",type:0}},"🯰":{type:5,data:{d:qo(126),type:0},scaleType:1},"🯱":{type:5,data:{d:qo(48),type:0},scaleType:1},"🯲":{type:5,data:{d:qo(109),type:0},scaleType:1},"🯳":{type:5,data:{d:qo(121),type:0},scaleType:1},"🯴":{type:5,data:{d:qo(51),type:0},scaleType:1},"🯵":{type:5,data:{d:qo(91),type:0},scaleType:1},"🯶":{type:5,data:{d:qo(95),type:0},scaleType:1},"🯷":{type:5,data:{d:qo(114),type:0},scaleType:1},"🯸":{type:5,data:{d:qo(127),type:0},scaleType:1},"🯹":{type:5,data:{d:qo(123),type:0},scaleType:1},"🯺":{type:5,data:{d:"M.5,.175 C.2,.175,.15,.305,.15,.435 L.05,.63 L.35,.63 C.35,.682,.42,.76,.5,.76 C.58,.76,.65,.682,.65,.63 L.95,.63 L.85,.435 C.85,.305,.8,.175,.5,.175 Z",type:0},scaleType:1},...Object.fromEntries(Array.from({length:256},(e,t)=>[String.fromCodePoint(10240+t),{type:6,data:t}]))},SS=new Set([9617,9618,9619,129932,129933,129934,129935,129936,129937,129938,129940,129948,129949,129950,129951]);function vr(e){return{type:2,data:()=>{let t=[],r=[.375,.25,.375],n=[0,3/8,5/8];for(let a=0;a<3;a++){let c=e>>a*2&1,l=e>>a*2+1&1;c&&l?t.push(`M0,${n[a]} L1,${n[a]} L1,${n[a]+r[a]} L0,${n[a]+r[a]} Z`):c?t.push(`M0,${n[a]} L${.5},${n[a]} L${.5},${n[a]+r[a]} L0,${n[a]+r[a]} Z`):l&&t.push(`M${.5},${n[a]} L1,${n[a]} L1,${n[a]+r[a]} L${.5},${n[a]+r[a]} Z`)}return t.join(" ")}}}function qo(e){let t=[];if(e&64){let r=.21500000000000002,n=.95-.15-.015;t.push(`M${r},${.2125} L${r+.075},${.175} L${n-.075},${.175} L${n},${.2125} L${n-.075},${.25} L${r+.075},${.25} Z`)}if(e&32){let r=.7999999999999999,n=.95-.15/2,a=.95,c=.175+.075+.015,l=.5-.015;t.push(`M${n},${c} L${a},${c+.0375} L${a},${l-.0375} L${n},${l} L${r},${l-.0375} L${r},${c+.0375} Z`)}if(e&16){let r=.7999999999999999,n=.95-.15/2,a=.95,c=.5+.015,l=.825-.075-.015;t.push(`M${n},${c} L${a},${c+.0375} L${a},${l-.0375} L${n},${l} L${r},${l-.0375} L${r},${c+.0375} Z`)}if(e&8){let r=.21500000000000002,n=.95-.15-.015;t.push(`M${r},${.7875} L${r+.075},${.75} L${n-.075},${.75} L${n},${.7875} L${n-.075},${.825} L${r+.075},${.825} Z`)}if(e&4&&t.push(`M${.125},${.515} L${.2},${.515+.0375} L${.2},${.735-.0375} L${.125},${.735} L${.05},${.735-.0375} L${.05},${.515+.0375} Z`),e&2&&t.push(`M${.125},${.265} L${.2},${.265+.0375} L${.2},${.485-.0375} L${.125},${.485} L${.05},${.485-.0375} L${.05},${.265+.0375} Z`),e&1){let r=.21500000000000002,n=.95-.15-.015;t.push(`M${r},${.5} L${r+.075},${.4625} L${n-.075},${.4625} L${n},${.5} L${n-.075},${.5375} L${r+.075},${.5375} Z`)}return t.join(" ")}var wi=0,ri=0,Yo=!1,bl=!1,Yd=!1,pa,s0=0,_S=class{constructor(e,t,r,n,a,c){this._terminal=e,this._optionService=t,this._selectionRenderModel=r,this._decorationService=n,this._coreBrowserService=a,this._themeService=c,this.result={fg:0,bg:0,ext:0}}resolve(e,t,r,n,a){this.result.bg=e.bg,this.result.fg=e.fg,this.result.ext=e.bg&268435456?e.extended.ext:0,ri=0,wi=0,bl=!1,Yo=!1,Yd=!1,pa=this._themeService.colors,s0=0;let c=e.getCode();if(c!==0&&e.extended.underlineStyle===4){let l=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));s0=t*n%(Math.round(l)*2)}if(s0===0&&SS.has(c)&&(s0=t*n%2*2+r*a%2),this._decorationService.forEachDecorationAtCell(t,r,"bottom",l=>{l.backgroundColorRGB&&(ri=l.backgroundColorRGB.rgba>>8&16777215,bl=!0),l.foregroundColorRGB&&(wi=l.foregroundColorRGB.rgba>>8&16777215,Yo=!0)}),Yd=this._selectionRenderModel.isCellSelected(this._terminal,t,r),Yd){if(this.result.fg&67108864||(this.result.bg&50331648)!==0){if(this.result.fg&67108864)switch(this.result.fg&50331648){case 16777216:case 33554432:ri=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:ri=(this.result.fg&16777215)<<8|255;break;default:ri=this._themeService.colors.foreground.rgba}else switch(this.result.bg&50331648){case 16777216:case 33554432:ri=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:ri=(this.result.bg&16777215)<<8|255;break}ri=Ec.blend(ri,(this._coreBrowserService.isFocused?pa.selectionBackgroundOpaque:pa.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else ri=(this._coreBrowserService.isFocused?pa.selectionBackgroundOpaque:pa.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(bl=!0,pa.selectionForeground&&(wi=pa.selectionForeground.rgba>>8&16777215,Yo=!0),H3(e.getCode())){if(this.result.fg&67108864&&(this.result.bg&50331648)===0)wi=(this._coreBrowserService.isFocused?pa.selectionBackgroundOpaque:pa.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:wi=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:wi=(this.result.bg&16777215)<<8|255;break}else switch(this.result.fg&50331648){case 16777216:case 33554432:wi=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:wi=(this.result.fg&16777215)<<8|255;break;default:wi=this._themeService.colors.foreground.rgba}wi=Ec.blend(wi,(this._coreBrowserService.isFocused?pa.selectionBackgroundOpaque:pa.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}Yo=!0}}this._decorationService.forEachDecorationAtCell(t,r,"top",l=>{l.backgroundColorRGB&&(ri=l.backgroundColorRGB.rgba>>8&16777215,bl=!0),l.foregroundColorRGB&&(wi=l.foregroundColorRGB.rgba>>8&16777215,Yo=!0)}),bl&&(Yd?ri=e.bg&-16777216&-134217729|ri|50331648:ri=e.bg&-16777216|ri|50331648),Yo&&(wi=e.fg&-16777216&-67108865|wi|50331648),this.result.fg&67108864&&(bl&&!Yo&&((this.result.bg&50331648)===0?wi=this.result.fg&-134217728|pa.background.rgba>>8&16777215&16777215|50331648:wi=this.result.fg&-134217728|this.result.bg&67108863,Yo=!0),!bl&&Yo&&((this.result.fg&50331648)===0?ri=this.result.bg&-67108864|pa.foreground.rgba>>8&16777215&16777215|50331648:ri=this.result.bg&-67108864|this.result.fg&67108863,bl=!0)),pa=void 0,this.result.bg=bl?ri:this.result.bg,this.result.fg=Yo?wi:this.result.fg,this.result.ext&=536870911,this.result.ext|=s0<<29&3758096384}},kS=.5,W3=fS||pS?"bottom":"ideographic";function LS(e,t,r,n,a,c,l,h,p,m,x,y,w=0){let v=CS[t];if(v){let k=Array.isArray(v)?v:[v];for(let L of k)IS(e,L,r,n,a,c,l,h,p,m,x,y,w);return!0}return!1}function IS(e,t,r,n,a,c,l,h,p,m,x,y,w=0){let v=a,k=c,L=r,E=n;switch(t.scaleType===1&&(v=l,k=h,L=r+(a-l)/2,E=n+(c-h)/2),t.clipPath&&(e.save(),QS(e,t.clipPath,L,E,v,k)),t.type){case 0:ES(e,t.data,L,E,v,k);break;case 1:DS(e,t.data,L,E,v,k,w);break;case 2:BS(e,t.data,L,E,v,k,m,x,t.strokeWidth);break;case 3:RS(e,t.data,L,E,v,k,m,t.strokeWidth);break;case 4:jS(e,t.data,L,E,v,k,m,y);break;case 5:PS(e,t.data,L,E,v,k,p,m,x);break;case 6:NS(e,t.data,L,E,v,k);break}t.clipPath&&e.restore()}function ES(e,t,r,n,a,c){for(let l=0;l<t.length;l++){let h=t[l],p=a/8,m=c/8;e.fillRect(r+h.x*p,n+h.y*m,h.w*p,h.h*m)}}var c2=new Uint8Array([1,0,1,2,1,4,5,0,5,2,5,4,1,6,5,6]);function NS(e,t,r,n,a,c){let l=a/8,h=c*.1,p=c*.8/8,m=Math.min(l,p);for(let x=0;x<8;x++)if(t&1<<x){let y=c2[x*2],w=c2[x*2+1],v=r+(y+1)*l,k=n+h+(w+1)*p;e.beginPath(),e.arc(v,k,m,0,Math.PI*2),e.fill()}}function RS(e,t,r,n,a,c,l,h){let p=typeof t=="string"?t:t(0,0);e.beginPath();let m=0,x=0,y=0,w=0,v="";for(let k of p.split(" ")){let L=k[0],E=k.substring(1).split(",");if(L==="Z"){e.closePath(),v=L;continue}if(L==="V"){let B=n+parseFloat(E[0])*c;e.lineTo(m,B),x=B,y=m,w=x,v=L;continue}if(L==="H"){let B=r+parseFloat(E[0])*a;e.lineTo(B,x),m=B,y=m,w=x,v=L;continue}if(!E[0]||!E[1])continue;if(L==="A"){let B=parseFloat(E[0])*a,W=parseFloat(E[1])*c,F=parseFloat(E[2])*Math.PI/180,U=parseInt(E[3],10),V=parseInt(E[4],10),Z=r+parseFloat(E[5])*a,le=n+parseFloat(E[6])*c;MS(e,m,x,B,W,F,U,V,Z,le),m=Z,x=le;continue}let R=E.map((B,W)=>{let F=parseFloat(B);return W%2===0?r+F*a:n+F*c});if(L==="M")e.moveTo(R[0],R[1]),m=R[0],x=R[1],y=m,w=x;else if(L==="L")e.lineTo(R[0],R[1]),m=R[0],x=R[1],y=m,w=x;else if(L==="Q")e.quadraticCurveTo(R[0],R[1],R[2],R[3]),y=R[0],w=R[1],m=R[2],x=R[3];else if(L==="T"){let B,W;v==="Q"||v==="T"?(B=2*m-y,W=2*x-w):(B=m,W=x),e.quadraticCurveTo(B,W,R[0],R[1]),y=B,w=W,m=R[0],x=R[1]}else L==="C"&&(e.bezierCurveTo(R[0],R[1],R[2],R[3],R[4],R[5]),y=R[2],w=R[3],m=R[4],x=R[5]);v=L}h!==void 0?(e.strokeStyle=e.fillStyle,e.lineWidth=l*h,e.stroke()):e.fill()}function MS(e,t,r,n,a,c,l,h,p,m){if(n===0||a===0){e.lineTo(p,m);return}n=Math.abs(n),a=Math.abs(a);let x=Math.cos(c),y=Math.sin(c),w=(t-p)/2,v=(r-m)/2,k=x*w+y*v,L=-y*w+x*v,E=n*n,R=a*a,B=k*k,W=L*L,F=B/E+W/R;if(F>1){let ye=Math.sqrt(F);n*=ye,a*=ye,E=n*n,R=a*a}let U=(E*R-E*W-R*B)/(E*W+R*B);U<0&&(U=0);let V=(l===h?-1:1)*Math.sqrt(U),Z=V*(n*L/a),le=V*-(a*k/n),xe=x*Z-y*le+(t+p)/2,fe=y*Z+x*le+(r+m)/2,te=(k-Z)/n,ke=(L-le)/a,$e=(-k-Z)/n,Y=(-L-le)/a,Ae=Math.atan2(ke,te),lt=Math.atan2(Y,$e)-Ae;h===0&&lt>0?lt-=2*Math.PI:h===1&&lt<0&&(lt+=2*Math.PI);let Ce=Ae+lt;e.ellipse(xe,fe,n,a,c,Ae,Ce,h===0)}function jS(e,t,r,n,a,c,l,h){e.save(),e.fillRect(r,n,a,c),h&&(e.fillStyle=h,e.strokeStyle=h),e.lineWidth=l,e.lineCap="square",e.beginPath();for(let p of t.d.split(" ")){let m=p[0],x=p.substring(1).split(",");if(!x[0]||!x[1]){m==="Z"&&e.closePath();continue}let y=x.map((w,v)=>{let k=parseFloat(w);return v%2===0?r+k*a:n+k*c});m==="M"?e.moveTo(y[0],y[1]):m==="L"&&e.lineTo(y[0],y[1])}t.type===1?e.stroke():e.fill(),e.restore()}var u2=new Map;function DS(e,t,r,n,a,c,l=0){let h=u2.get(t);h||(h=new Map,u2.set(t,h));let p=e.fillStyle;if(typeof p!="string")throw new Error(`Unexpected fillStyle type "${p}"`);let m=h.get(p);if(!m){let w=t[0].length,v=t.length,k=e.canvas.ownerDocument.createElement("canvas");k.width=w,k.height=v;let L=Os(k.getContext("2d")),E=new ImageData(w,v),R,B,W,F;if(p.startsWith("#"))R=parseInt(p.slice(1,3),16),B=parseInt(p.slice(3,5),16),W=parseInt(p.slice(5,7),16),F=p.length>7&&parseInt(p.slice(7,9),16)||1;else if(p.startsWith("rgba"))[R,B,W,F]=p.substring(5,p.length-1).split(",").map(U=>parseFloat(U));else throw new Error(`Unexpected fillStyle color format "${p}" when drawing pattern glyph`);for(let U=0;U<v;U++)for(let V=0;V<w;V++)E.data[(U*w+V)*4]=R,E.data[(U*w+V)*4+1]=B,E.data[(U*w+V)*4+2]=W,E.data[(U*w+V)*4+3]=t[U][V]*(F*255);L.putImageData(E,0,0),m=Os(e.createPattern(k,null)),h.set(p,m)}let x=l>>1&1,y=l&1;x!==0||y!==0?m.setTransform(new DOMMatrix().translateSelf(-x,-y)):m.setTransform(new DOMMatrix),e.fillStyle=m,e.fillRect(r,n,a,c)}function BS(e,t,r,n,a,c,l,h,p){e.save(),e.beginPath(),e.rect(r,n,a,c),e.clip(),e.beginPath();let m;if(typeof t=="function"){let y=.15/c*a;m=t(.15,y)}else m=t;let x={currentX:0,currentY:0,lastControlX:0,lastControlY:0,lastCommand:""};for(let y of m.split(" ")){let w=y[0];if(w==="Z"){e.closePath(),x.lastCommand=w;continue}let v=G3[w];if(!v){h.error(`Could not find drawing instructions for "${w}"`);continue}let k=y.substring(1).split(",");!k[0]||!k[1]||(v(e,V3(k,a,c,r,n,!0,l,0,0,!1),x),x.lastCommand=w)}p!==void 0?(e.strokeStyle=e.fillStyle,e.lineWidth=l*p,e.stroke()):e.fill(),e.closePath(),e.restore()}function QS(e,t,r,n,a,c){e.beginPath();for(let l of t.split(" ")){let h=l[0];if(h==="Z"){e.closePath();continue}let p=l.substring(1).split(",");if(!p[0]||!p[1])continue;let m=r+parseFloat(p[0])*a,x=n+parseFloat(p[1])*c;h==="M"?e.moveTo(m,x):h==="L"&&e.lineTo(m,x)}e.clip()}function PS(e,t,r,n,a,c,l,h,p){let m=new Path2D;m.rect(r,n,a,c),e.clip(m),e.beginPath();let x=l/12;e.lineWidth=h*x;let y={currentX:0,currentY:0,lastControlX:0,lastControlY:0,lastCommand:""};for(let w of t.d.split(" ")){let v=w[0];if(v==="Z"){e.closePath(),y.lastCommand=v;continue}let k=G3[v];if(!k){p.error(`Could not find drawing instructions for "${v}"`);continue}let L=w.substring(1).split(",");!L[0]||!L[1]||(k(e,V3(L,a,c,r,n,!1,h,(t.leftPadding??0)*(x/2),(t.rightPadding??0)*(x/2)),y),y.lastCommand=v)}t.type===1?(e.strokeStyle=e.fillStyle,e.stroke()):e.fill(),e.closePath()}function d2(e,t,r=0){return Math.max(Math.min(e,t),r)}var G3={C:(e,t,r)=>{e.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5]),r.lastControlX=t[2],r.lastControlY=t[3],r.currentX=t[4],r.currentY=t[5]},L:(e,t,r)=>{e.lineTo(t[0],t[1]),r.lastControlX=r.currentX=t[0],r.lastControlY=r.currentY=t[1]},M:(e,t,r)=>{e.moveTo(t[0],t[1]),r.lastControlX=r.currentX=t[0],r.lastControlY=r.currentY=t[1]},Q:(e,t,r)=>{e.quadraticCurveTo(t[0],t[1],t[2],t[3]),r.lastControlX=t[0],r.lastControlY=t[1],r.currentX=t[2],r.currentY=t[3]},T:(e,t,r)=>{let n,a;r.lastCommand==="Q"||r.lastCommand==="T"?(n=2*r.currentX-r.lastControlX,a=2*r.currentY-r.lastControlY):(n=r.currentX,a=r.currentY),e.quadraticCurveTo(n,a,t[0],t[1]),r.lastControlX=n,r.lastControlY=a,r.currentX=t[0],r.currentY=t[1]}};function V3(e,t,r,n,a,c,l,h=0,p=0,m=!0){let x=e.map(y=>parseFloat(y)||parseInt(y));if(x.length<2)throw new Error("Too few arguments for instruction");for(let y=0;y<x.length;y+=2){if(x[y]*=t-h*l-p*l,c&&x[y]!==0){let w=Math.round(x[y]+.5)-.5;x[y]=m?d2(w,t,0):w}x[y]+=n+h*l}for(let y=1;y<x.length;y+=2){if(x[y]*=r,c&&x[y]!==0){let w=Math.round(x[y]+.5)-.5;x[y]=m?d2(w,r,0):w}x[y]+=a}return x}var h2=class{constructor(){this._data={}}set(e,t,r){this._data[e]||(this._data[e]={}),this._data[e][t]=r}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},f2=class{constructor(){this._data=new h2}set(e,t,r,n,a){this._data.get(e,t)||this._data.set(e,t,new h2),this._data.get(e,t).set(r,n,a)}get(e,t,r,n){return this._data.get(e,t)?.get(r,n)}clear(){this._data.clear()}},q3=class{constructor(e){this._tasks=[],this._i=0,this._logService=e}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t,r=0,n=e.timeRemaining(),a;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),r=Math.max(t,r),a=e.timeRemaining(),r*1.5>a){n-t<-20&&this._logService.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(n-t))}ms`),this._start();return}n=a}this.clear()}},OS=class extends q3{_requestCallback(t){return setTimeout(()=>t(this._createDeadline(16)))}_cancelCallback(t){clearTimeout(t)}_createDeadline(t){let r=performance.now()+t;return{timeRemaining:()=>Math.max(0,r-performance.now())}}},FS=class extends q3{_requestCallback(t){return requestIdleCallback(t)}_cancelCallback(t){cancelIdleCallback(t)}},$S="requestIdleCallback"in globalThis?FS:OS,bu=class Y3{constructor(){this.fg=0,this.bg=0,this.extended=new Z3}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new Y3;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Z3=class K3{constructor(t=0,r=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=r}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new K3(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},jo=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event?this._event:(this._event=(t,r,n)=>{if(this._disposed)return Zs(()=>{});let a={fn:t,thisArgs:r};this._listeners.push(a);let c=Zs(()=>{let l=this._listeners.indexOf(a);l!==-1&&this._listeners.splice(l,1)});return n&&(Array.isArray(n)?n.push(c):n.add(c)),c},this._event)}fire(t){if(!this._disposed)switch(this._listeners.length){case 0:return;case 1:{let{fn:r,thisArgs:n}=this._listeners[0];r.call(n,t);return}default:{let r=this._listeners.slice();for(let{fn:n,thisArgs:a}of r)n.call(a,t)}}}dispose(){this._disposed||(this._disposed=!0,this._listeners.length=0)}},_c;(e=>{function t(c,l){return c(h=>l.fire(h))}e.forward=t;function r(c,l){return(h,p,m)=>c(x=>h.call(p,l(x)),void 0,m)}e.map=r;function n(...c){return(l,h,p)=>{let m=new $3;for(let x of c)m.add(x(y=>l.call(h,y)));return p&&(Array.isArray(p)?p.push(m):p.add(m)),m}}e.any=n;function a(c,l,h){return l(h),c(p=>l(p))}e.runAndSubscribe=a})(_c||={});var p2={texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},offset:{x:0,y:0},size:{x:0,y:0},sizeClipSpace:{x:0,y:0}},i0=2,a0,Gl=class fu{constructor(t,r,n,a){this._document=t,this._config=r,this._unicodeService=n,this._logService=a,this._didWarmUp=!1,this._cacheMap=new f2,this._cacheMapCombined=new f2,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new bu,this._textureSize=512,this._onAddTextureAtlasCanvas=new jo,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new jo,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=J3(t,this._config.deviceCellWidth*4+i0*2,this._config.deviceCellHeight+i0*2),this._tmpCtx=Os(this._tmpCanvas.getContext("2d",{alpha:this._config.allowTransparency,willReadFrequently:!0}))}get pages(){return this._pages}dispose(){this._tmpCanvas.remove();for(let t of this.pages)t.canvas.remove();this._onAddTextureAtlasCanvas.dispose(),this._onRemoveTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)}_doWarmUp(){let t=new $S(this._logService);for(let r=33;r<126;r++)t.enqueue(()=>{if(!this._cacheMap.get(r,0,0,0)){let n=this._drawToCache(r,0,0,0,!1,void 0);this._cacheMap.set(r,0,0,0,n)}})}beginFrame(){let t=this._requestClearModel;return this._requestClearModel=!1,t}clearTexture(){if(!(this._pages[0].currentRow.x===0&&this._pages[0].currentRow.y===0)){for(let t of this._pages)t.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(fu.maxAtlasPages&&this._pages.length>=Math.max(4,fu.maxAtlasPages)){let r=this._pages.filter(m=>m.canvas.width*2<=(fu.maxTextureSize||4096)).sort((m,x)=>x.canvas.width!==m.canvas.width?x.canvas.width-m.canvas.width:x.percentageUsed-m.percentageUsed),n=-1,a=0;for(let m=0;m<r.length;m++)if(r[m].canvas.width!==a)n=m,a=r[m].canvas.width;else if(m-n===3)break;let c=r.slice(n,n+4);if(c.length<4||c.some(m=>m.canvas.width!==c[0].canvas.width)){let m=new mc(this._document,this._textureSize);return this._pages.push(m),this._activePages.push(m),this._onAddTextureAtlasCanvas.fire(m.canvas),m}let l=c.map(m=>m.glyphs[0].texturePage).sort((m,x)=>m-x),h=this.pages.length-c.length,p=this._mergePages(c,h);p.version=++mc.nextVersion;for(let m=l.length-1;m>=0;m--)this._deletePage(l[m]);this.pages.push(p),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(p.canvas)}let t=new mc(this._document,this._textureSize);return this._pages.push(t),this._activePages.push(t),this._onAddTextureAtlasCanvas.fire(t.canvas),t}_mergePages(t,r){let n=t[0].canvas.width*2,a=new mc(this._document,n,t);for(let[c,l]of t.entries()){let h=c*l.canvas.width%n,p=Math.floor(c/2)*l.canvas.height;a.ctx.drawImage(l.canvas,h,p);for(let x of l.glyphs)x.texturePage=r,x.sizeClipSpace.x=x.size.x/n,x.sizeClipSpace.y=x.size.y/n,x.texturePosition.x+=h,x.texturePosition.y+=p,x.texturePositionClipSpace.x=x.texturePosition.x/n,x.texturePositionClipSpace.y=x.texturePosition.y/n;this._onRemoveTextureAtlasCanvas.fire(l.canvas);let m=this._activePages.indexOf(l);m!==-1&&this._activePages.splice(m,1)}return a}_deletePage(t){this._pages.splice(t,1);for(let r=t;r<this._pages.length;r++){let n=this._pages[r];for(let a of n.glyphs)a.texturePage--;n.version=++mc.nextVersion}}getRasterizedGlyphCombinedChar(t,r,n,a,c,l){return this._getFromCacheMap(this._cacheMapCombined,t,r,n,a,c,l)}getRasterizedGlyph(t,r,n,a,c,l){return this._getFromCacheMap(this._cacheMap,t,r,n,a,c,l)}_getFromCacheMap(t,r,n,a,c,l,h){return a0=t.get(r,n,a,c),a0||(a0=this._drawToCache(r,n,a,c,l,h),t.set(r,n,a,c,a0)),a0}_getColorFromAnsiIndex(t){if(t>=this._config.colors.ansi.length)throw new Error("No color found for idx "+t);return this._config.colors.ansi[t]}_getBackgroundColor(t,r,n,a){if(this._config.allowTransparency)return so;let c;switch(t){case 16777216:case 33554432:c=this._getColorFromAnsiIndex(r);break;case 50331648:let l=bu.toColorRGB(r);c=sa.toColor(l[0],l[1],l[2]);break;default:n?c=O0.opaque(this._config.colors.foreground):c=this._config.colors.background;break}return this._config.allowTransparency||(c=O0.opaque(c)),c}_getForegroundColor(t,r,n,a,c,l,h,p,m,x){let y=this._getMinimumContrastColor(t,r,n,a,c,l,h,m,p,x);if(y)return y;let w;switch(c){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&m&&l<8&&(l+=8),w=this._getColorFromAnsiIndex(l);break;case 50331648:let v=bu.toColorRGB(l);w=sa.toColor(v[0],v[1],v[2]);break;default:h?w=this._config.colors.background:w=this._config.colors.foreground}return this._config.allowTransparency&&(w=O0.opaque(w)),p&&(w=O0.multiplyOpacity(w,kS)),w}_resolveBackgroundRgba(t,r,n){switch(t){case 16777216:case 33554432:return this._getColorFromAnsiIndex(r).rgba;case 50331648:return r<<8;default:return n?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(t,r,n,a){switch(t){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&a&&r<8&&(r+=8),this._getColorFromAnsiIndex(r).rgba;case 50331648:return r<<8;default:return n?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(t,r,n,a,c,l,h,p,m,x){if(this._config.minimumContrastRatio===1||x)return;let y=this._getContrastCache(m),w=y.getColor(t,a);if(w!==void 0)return w??void 0;let v=this._resolveBackgroundRgba(r,n,h),k=this._resolveForegroundRgba(c,l,h,p),L=Ec.ensureContrastRatio(v,k,this._config.minimumContrastRatio/(m?2:1));if(!L){y.setColor(t,a,null);return}let E=sa.toColor(L>>24&255,L>>16&255,L>>8&255);return y.setColor(t,a,E),E}_getContrastCache(t){return t?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(t,r,n,a,c,l){let h=typeof t=="number"?String.fromCharCode(t):t;l&&this._tmpCanvas.parentElement!==l&&(this._tmpCanvas.style.display="none",l.append(this._tmpCanvas));let p=Math.min(this._config.deviceCellWidth*Math.max(h.length,2)+i0*2,this._config.deviceMaxTextureSize);this._tmpCanvas.width<p&&(this._tmpCanvas.width=p);let m=Math.min(this._config.deviceCellHeight+i0*4,this._textureSize);if(this._tmpCanvas.height<m&&(this._tmpCanvas.height=m),this._tmpCtx.save(),this._workAttributeData.fg=n,this._workAttributeData.bg=r,this._workAttributeData.extended.ext=a,!!this._workAttributeData.isInvisible())return p2;let x=!!this._workAttributeData.isBold(),y=!!this._workAttributeData.isInverse(),w=!!this._workAttributeData.isDim(),v=!!this._workAttributeData.isItalic(),k=!!this._workAttributeData.isUnderline(),L=!!this._workAttributeData.isStrikethrough(),E=!!this._workAttributeData.isOverline(),R=this._workAttributeData.getFgColor(),B=this._workAttributeData.getFgColorMode(),W=this._workAttributeData.getBgColor(),F=this._workAttributeData.getBgColorMode();if(y){let je=R;R=W,W=je;let re=B;B=F,F=re}let U=this._getBackgroundColor(F,W,y,w);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=U.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over";let V=x?this._config.fontWeightBold:this._config.fontWeight,Z=v?"italic":"";this._tmpCtx.font=`${Z} ${V} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=W3;let le=h.length===1&&R1(h.charCodeAt(0)),xe=h.length===1&&xS(h.charCodeAt(0)),fe=this._getForegroundColor(r,F,W,n,B,R,y,w,x,H3(h.charCodeAt(0)));this._tmpCtx.fillStyle=fe.css;let te=xe?0:i0*2,ke=!1;if(this._config.customGlyphs!==!1){let je=this._workAttributeData.getUnderlineVariantOffset();ke=LS(this._tmpCtx,h,te,te,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.deviceCharWidth,this._config.deviceCharHeight,this._config.fontSize,this._config.devicePixelRatio,this._logService,U.css,je)}let $e=!le,Y;if(typeof t=="number"?Y=this._unicodeService.wcwidth(t):Y=this._unicodeService.getStringCellWidth(t),k){this._tmpCtx.save();let je=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),re=je%2===1?.5:0;if(this._tmpCtx.lineWidth=je,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())$e=!1,this._tmpCtx.strokeStyle=`rgb(${bu.toColorRGB(this._workAttributeData.getUnderlineColor()).join(",")})`;else{$e=!1;let He=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&He<8&&(He+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(He).css}this._tmpCtx.fillStyle=this._tmpCtx.strokeStyle,this._tmpCtx.beginPath();let Pe=te,Se=Math.ceil(te+this._config.deviceCharHeight)-re-(c?je*2:0),Ee=Se+je*2,Be=this._workAttributeData.getUnderlineVariantOffset(),Ne=0,oe=0;for(let He=0;He<Y;He++){let rt=!1;this._tmpCtx.save(),Ne=Se,oe=Ee;let mt=Pe+He*this._config.deviceCellWidth,de=Pe+(He+1)*this._config.deviceCellWidth;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(mt,Se),this._tmpCtx.lineTo(de,Se),this._tmpCtx.moveTo(mt,Ee),this._tmpCtx.lineTo(de,Ee);break;case 3:Ne=this._config.deviceCharHeight+1,oe=Ne+3*this._config.devicePixelRatio;let Ye=new Path2D;Ye.rect(mt,Ne,this._config.deviceCellWidth,oe-Ne),this._tmpCtx.clip(Ye);let st=this._config.deviceCellWidth,Ie=oe-Ne,We=st/6,Te=Ie/3,H=[[0,2,1,3,2.4,3,0,.6],[5.5,0,2.5,3,1.1,3,4.1,0],[4,0,6,2,6,.6,5.4,0]];for(let vt of H){this._tmpCtx.beginPath();for(let Yt=0;Yt<vt.length;Yt+=2){let Qt=mt+vt[Yt]*We,Xt=oe-vt[Yt+1]*Te;Yt===0?this._tmpCtx.moveTo(Qt,Xt):this._tmpCtx.lineTo(Qt,Xt)}this._tmpCtx.closePath(),this._tmpCtx.fill()}rt=!0;break;case 4:let ae=Be===0?0:Be>=je?je*2-Be:je-Be;Be>=je||ae===0?(this._tmpCtx.setLineDash([Math.round(je),Math.round(je)]),this._tmpCtx.moveTo(mt+ae,Se),this._tmpCtx.lineTo(de,Se)):(this._tmpCtx.setLineDash([Math.round(je),Math.round(je)]),this._tmpCtx.moveTo(mt,Se),this._tmpCtx.lineTo(mt+ae,Se),this._tmpCtx.moveTo(mt+ae+je,Se),this._tmpCtx.lineTo(de,Se)),Be=TS(de-mt,je,Be);break;case 5:let be=.6,Ze=.3,Je=de-mt,Tt=Math.floor(be*Je),Wt=Math.floor(Ze*Je),Mt=Je-Tt-Wt;this._tmpCtx.setLineDash([Tt,Wt,Mt]),this._tmpCtx.moveTo(mt,Se),this._tmpCtx.lineTo(de,Se);break;default:this._tmpCtx.moveTo(mt,Se),this._tmpCtx.lineTo(de,Se);break}rt||this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!ke&&this._config.fontSize>=12&&!this._config.allowTransparency&&h!==" "){this._tmpCtx.save(),this._tmpCtx.textBaseline="alphabetic";let He=this._tmpCtx.measureText(h);if(this._tmpCtx.restore(),"actualBoundingBoxDescent"in He&&He.actualBoundingBoxDescent>0){this._tmpCtx.save();let rt=new Path2D;rt.rect(Pe,Ne-Math.ceil(je/2),this._config.deviceCellWidth*Y,oe-Ne+Math.ceil(je/2)),this._tmpCtx.clip(rt),this._tmpCtx.lineWidth=this._config.devicePixelRatio*3,this._tmpCtx.strokeStyle=U.css,this._tmpCtx.strokeText(h,te,te+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(E){let je=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),re=je%2===1?.5:0;this._tmpCtx.lineWidth=je,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(te,te+re),this._tmpCtx.lineTo(te+this._config.deviceCharWidth*Y,te+re),this._tmpCtx.stroke()}if(ke||this._tmpCtx.fillText(h,te,te+this._config.deviceCharHeight),h==="_"&&!this._config.allowTransparency){let je=gp(this._tmpCtx.getImageData(te,te,this._config.deviceCellWidth,this._config.deviceCellHeight),U,fe,$e);if(je)for(let re=1;re<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=U.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(h,te,te+this._config.deviceCharHeight-re),je=gp(this._tmpCtx.getImageData(te,te,this._config.deviceCellWidth,this._config.deviceCellHeight),U,fe,$e),!!je);re++);}if(L){let je=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),re=this._tmpCtx.lineWidth%2===1?.5:0;this._tmpCtx.lineWidth=je,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(te,te+Math.floor(this._config.deviceCharHeight/2)-re),this._tmpCtx.lineTo(te+this._config.deviceCharWidth*Y,te+Math.floor(this._config.deviceCharHeight/2)-re),this._tmpCtx.stroke()}this._tmpCtx.restore();let Ae=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),lt;if(this._config.allowTransparency?lt=US(Ae):lt=gp(Ae,U,fe,$e),lt)return p2;let Ce=this._findGlyphBoundingBox(Ae,this._workBoundingBox,p,xe,ke,te),ye,_e;for(;;){if(this._activePages.length===0){let je=this._createNewPage();ye=je,_e=je.currentRow,_e.height=Ce.size.y;break}ye=this._activePages[this._activePages.length-1],_e=ye.currentRow;for(let je of this._activePages)Ce.size.y<=je.currentRow.height&&(ye=je,_e=je.currentRow);for(let je=this._activePages.length-1;je>=0;je--)for(let re of this._activePages[je].fixedRows)re.height<=_e.height&&Ce.size.y<=re.height&&(ye=this._activePages[je],_e=re);if(Ce.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new mc(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),ye=this._overflowSizePage,_e=this._overflowSizePage.currentRow,_e.x+Ce.size.x>=ye.canvas.width&&(_e.x=0,_e.y+=_e.height,_e.height=0);break}if(_e.y+Ce.size.y>=ye.canvas.height||_e.height>Ce.size.y+2){let je=!1;if(ye.currentRow.y+ye.currentRow.height+Ce.size.y>=ye.canvas.height){let re;for(let Pe of this._activePages)if(Pe.currentRow.y+Pe.currentRow.height+Ce.size.y<Pe.canvas.height){re=Pe;break}if(re)ye=re;else if(fu.maxAtlasPages&&this._pages.length>=fu.maxAtlasPages&&_e.y+Ce.size.y<=ye.canvas.height&&_e.height>=Ce.size.y&&_e.x+Ce.size.x<=ye.canvas.width)je=!0;else{let Pe=this._createNewPage();ye=Pe,_e=Pe.currentRow,_e.height=Ce.size.y,je=!0}}je||(ye.currentRow.height>0&&ye.fixedRows.push(ye.currentRow),_e={x:0,y:ye.currentRow.y+ye.currentRow.height,height:Ce.size.y},ye.fixedRows.push(_e),ye.currentRow={x:0,y:_e.y+_e.height,height:0})}if(_e.x+Ce.size.x<=ye.canvas.width)break;_e===ye.currentRow?(_e.x=0,_e.y+=_e.height,_e.height=0):ye.fixedRows.splice(ye.fixedRows.indexOf(_e),1)}return Ce.texturePage=this._pages.indexOf(ye),Ce.texturePosition.x=_e.x,Ce.texturePosition.y=_e.y,Ce.texturePositionClipSpace.x=_e.x/ye.canvas.width,Ce.texturePositionClipSpace.y=_e.y/ye.canvas.height,Ce.sizeClipSpace.x/=ye.canvas.width,Ce.sizeClipSpace.y/=ye.canvas.height,_e.height=Math.max(_e.height,Ce.size.y),_e.x+=Ce.size.x,ye.ctx.putImageData(Ae,Ce.texturePosition.x-this._workBoundingBox.left,Ce.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,Ce.size.x,Ce.size.y),ye.addGlyph(Ce),ye.version=++mc.nextVersion,Ce}_findGlyphBoundingBox(t,r,n,a,c,l){r.top=0;let h=a?this._config.deviceCellHeight:this._tmpCanvas.height,p=a?this._config.deviceCellWidth:n,m=!1;for(let x=0;x<h;x++){for(let y=0;y<p;y++){let w=x*this._tmpCanvas.width*4+y*4+3;if(t.data[w]!==0){r.top=x,m=!0;break}}if(m)break}r.left=0,m=!1;for(let x=0;x<l+p;x++){for(let y=0;y<h;y++){let w=y*this._tmpCanvas.width*4+x*4+3;if(t.data[w]!==0){r.left=x,m=!0;break}}if(m)break}r.right=p,m=!1;for(let x=l+p-1;x>=l;x--){for(let y=0;y<h;y++){let w=y*this._tmpCanvas.width*4+x*4+3;if(t.data[w]!==0){r.right=x,m=!0;break}}if(m)break}r.bottom=h,m=!1;for(let x=h-1;x>=0;x--){for(let y=0;y<p;y++){let w=x*this._tmpCanvas.width*4+y*4+3;if(t.data[w]!==0){r.bottom=x,m=!0;break}}if(m)break}return{texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:r.right-r.left+1,y:r.bottom-r.top+1},sizeClipSpace:{x:r.right-r.left+1,y:r.bottom-r.top+1},offset:{x:-r.left+l+(a||c?Math.floor((this._config.deviceCellWidth-this._config.deviceCharWidth)/2):0),y:-r.top+l+(a||c?this._config.lineHeight===1?0:Math.round((this._config.deviceCellHeight-this._config.deviceCharHeight)/2):0)}}}},X3=class Qm{constructor(t,r,n){if(this._usedPixels=0,this._glyphs=[],this.version=++Qm.nextVersion,this.currentRow={x:0,y:0,height:0},this.fixedRows=[],this.canvas=J3(t,r,r),this.ctx=Os(this.canvas.getContext("2d",{alpha:!0})),n)if(n.length===4)this._glyphs=this._glyphs.concat(n[0].glyphs,n[1].glyphs,n[2].glyphs,n[3].glyphs),this._usedPixels=n[0]._usedPixels+n[1]._usedPixels+n[2]._usedPixels+n[3]._usedPixels;else for(let a=0;a<n.length;++a)this._glyphs=this._glyphs.concat(n[a].glyphs),this._usedPixels+=n[a]._usedPixels}get percentageUsed(){return this._usedPixels/(this.canvas.width*this.canvas.height)}get glyphs(){return this._glyphs}addGlyph(t){this._glyphs.push(t),this._usedPixels+=t.size.x*t.size.y}clear(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.currentRow.x=0,this.currentRow.y=0,this.currentRow.height=0,this.fixedRows.length=0,this.version=++Qm.nextVersion}};X3.nextVersion=0;var mc=X3;function gp(e,t,r,n){let a=t.rgba>>>24,c=t.rgba>>>16&255,l=t.rgba>>>8&255,h=r.rgba>>>24,p=r.rgba>>>16&255,m=r.rgba>>>8&255,x=Math.floor((Math.abs(a-h)+Math.abs(c-p)+Math.abs(l-m))/12),y=!0;for(let w=0;w<e.data.length;w+=4)e.data[w]===a&&e.data[w+1]===c&&e.data[w+2]===l||n&&Math.abs(e.data[w]-a)+Math.abs(e.data[w+1]-c)+Math.abs(e.data[w+2]-l)<x?e.data[w+3]=0:y=!1;return y}function US(e){for(let t=0;t<e.data.length;t+=4)if(e.data[t+3]>0)return!1;return!0}function J3(e,t,r){let n=e.createElement("canvas");return n.width=t,n.height=r,n}function zS(e,t,r,n,a,c,l,h,p=!0){let m={foreground:c.foreground,background:c.background,cursor:so,cursorAccent:so,selectionForeground:so,selectionBackgroundTransparent:so,selectionBackgroundOpaque:so,selectionInactiveBackgroundTransparent:so,selectionInactiveBackgroundOpaque:so,overviewRulerBorder:so,scrollbarSliderBackground:so,scrollbarSliderHoverBackground:so,scrollbarSliderActiveBackground:so,ansi:c.ansi.slice(),contrastCache:c.contrastCache,halfContrastCache:c.halfContrastCache};return{customGlyphs:p,devicePixelRatio:l,deviceMaxTextureSize:h,letterSpacing:a.letterSpacing,lineHeight:a.lineHeight,deviceCellWidth:e,deviceCellHeight:t,deviceCharWidth:r,deviceCharHeight:n,fontFamily:a.fontFamily,fontSize:a.fontSize,fontWeight:a.fontWeight,fontWeightBold:a.fontWeightBold,allowTransparency:a.allowTransparency,drawBoldTextInBrightColors:a.drawBoldTextInBrightColors,minimumContrastRatio:a.minimumContrastRatio,colors:m}}function m2(e,t){for(let r=0;r<e.colors.ansi.length;r++)if(e.colors.ansi[r].rgba!==t.colors.ansi[r].rgba)return!1;return e.devicePixelRatio===t.devicePixelRatio&&e.deviceMaxTextureSize===t.deviceMaxTextureSize&&e.customGlyphs===t.customGlyphs&&e.lineHeight===t.lineHeight&&e.letterSpacing===t.letterSpacing&&e.fontFamily===t.fontFamily&&e.fontSize===t.fontSize&&e.fontWeight===t.fontWeight&&e.fontWeightBold===t.fontWeightBold&&e.allowTransparency===t.allowTransparency&&e.deviceCellWidth===t.deviceCellWidth&&e.deviceCellHeight===t.deviceCellHeight&&e.deviceCharWidth===t.deviceCharWidth&&e.deviceCharHeight===t.deviceCharHeight&&e.drawBoldTextInBrightColors===t.drawBoldTextInBrightColors&&e.minimumContrastRatio===t.minimumContrastRatio&&e.colors.foreground.rgba===t.colors.foreground.rgba&&e.colors.background.rgba===t.colors.background.rgba}function HS(e){return(e&50331648)===16777216||(e&50331648)===33554432}var ao=[];function ey(e,t,r,n,a,c,l,h,p,m=!0){let x=zS(n,a,c,l,t,r,h,p,m);for(let k=0;k<ao.length;k++){let L=ao[k],E=L.ownedBy.indexOf(e);if(E>=0){if(m2(L.config,x))return L.atlas;L.ownedBy.length===1?(L.atlas.dispose(),ao.splice(k,1)):L.ownedBy.splice(E,1);break}}for(let k=0;k<ao.length;k++){let L=ao[k];if(m2(L.config,x))return L.ownedBy.push(e),L.atlas}let y=e._core,w=y._logService,v={atlas:new Gl(document,x,y.unicodeService,w),config:x,ownedBy:[e]};return ao.push(v),v.atlas}function g2(e){for(let t=0;t<ao.length;t++){let r=ao[t].ownedBy.indexOf(e);if(r!==-1){ao[t].ownedBy.length===1?(ao[t].atlas.dispose(),ao.splice(t,1)):ao[t].ownedBy.splice(r,1);break}}}var WS=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._isIdlePaused=!1,this.isCursorVisible=!0,this._coreBrowserService.isFocused&&(this._restartInterval(),this._resetIdleTimer())}get isPaused(){return!(this._blinkStartTimeout||this._blinkInterval)}dispose(){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0),this._idleTimeout&&(this._coreBrowserService.window.clearTimeout(this._idleTimeout),this._idleTimeout=void 0)}restartBlinkAnimation(){this._isIdlePaused&&this._resetIdleTimer(),!this.isPaused&&(this._animationTimeRestarted=Date.now(),this.isCursorVisible=!0,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})))}_restartInterval(e=600){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let t=600-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,t>0){this._restartInterval(t);return}}this.isCursorVisible=!1,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0}),this._blinkInterval=this._coreBrowserService.window.setInterval(()=>{if(this._animationTimeRestarted){let t=600-(Date.now()-this._animationTimeRestarted);this._animationTimeRestarted=void 0,this._restartInterval(t);return}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},600)},e)}pause(){this.isCursorVisible=!0,this._isIdlePaused=!1,this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0),this._idleTimeout&&(this._coreBrowserService.window.clearTimeout(this._idleTimeout),this._idleTimeout=void 0)}resume(){this.pause(),this._animationTimeRestarted=void 0,this._restartInterval(),this._resetIdleTimer(),this.restartBlinkAnimation()}_resetIdleTimer(){this._isIdlePaused=!1,this._idleTimeout&&this._coreBrowserService.window.clearTimeout(this._idleTimeout),this._idleTimeout=this._coreBrowserService.window.setTimeout(()=>{this._stopBlinkingDueToIdle()},3e5)}_stopBlinkingDueToIdle(){this.isCursorVisible=!0,this._isIdlePaused=!0,this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0),this._coreBrowserService.window.clearTimeout(this._idleTimeout),this._idleTimeout=void 0,this._renderCallback()}};function x2(e,t,r){let n=new t.ResizeObserver(a=>{let c=a.find(p=>p.target===e);if(!c)return;if(!("devicePixelContentBoxSize"in c)){n?.disconnect(),n=void 0;return}let l=c.devicePixelContentBoxSize[0].inlineSize,h=c.devicePixelContentBoxSize[0].blockSize;l>0&&h>0&&r(l,h)});try{n.observe(e,{box:["device-pixel-content-box"]})}catch{n.disconnect(),n=void 0}return Zs(()=>n?.disconnect())}function GS(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}var VS=class ty extends bu{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Z3,this.combinedData=""}static fromCharData(t){let r=new ty;return r.setFromCharData(t),r}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?GS(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let r=!1;if(t[1].length>2)r=!0;else if(t[1].length===2){let n=t[1].charCodeAt(0);if(55296<=n&&n<=56319){let a=t[1].charCodeAt(1);56320<=a&&a<=57343?this.content=(n-55296)*1024+a-56320+65536|t[2]<<22:r=!0}else r=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;r&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}attributesEquals(t){if(this.getFgColorMode()!==t.getFgColorMode()||this.getFgColor()!==t.getFgColor()||this.getBgColorMode()!==t.getBgColorMode()||this.getBgColor()!==t.getBgColor()||this.isInverse()!==t.isInverse()||this.isBold()!==t.isBold()||this.isUnderline()!==t.isUnderline())return!1;if(this.isUnderline()){if(this.getUnderlineStyle()!==t.getUnderlineStyle())return!1;let r=this.isUnderlineColorDefault(),n=t.isUnderlineColorDefault();if(!(r&&n)&&(r!==n||this.getUnderlineColor()!==t.getUnderlineColor()||this.getUnderlineColorMode()!==t.getUnderlineColorMode()))return!1}return!(this.isOverline()!==t.isOverline()||this.isBlink()!==t.isBlink()||this.isInvisible()!==t.isInvisible()||this.isItalic()!==t.isItalic()||this.isDim()!==t.isDim()||this.isStrikethrough()!==t.isStrikethrough())}},qS=class extends Pc{constructor(e,t,r){super(),this._renderCallback=e,this._coreBrowserService=t,this._optionsService=r,this._intervalDuration=0,this._blinkOn=!0,this._needsBlinkInViewport=!1,this._isViewportVisible=!0,this._register(this._optionsService.onSpecificOptionChange("blinkIntervalDuration",n=>{this.setIntervalDuration(n)})),this.setIntervalDuration(this._optionsService.rawOptions.blinkIntervalDuration),this._register(Zs(()=>this._clearInterval()))}get isBlinkOn(){return this._blinkOn}get isEnabled(){return this._intervalDuration>0}setNeedsBlinkInViewport(e){this._needsBlinkInViewport!==e&&(this._needsBlinkInViewport=e,this._updateIntervalState())}setViewportVisible(e){this._isViewportVisible!==e&&(this._isViewportVisible=e,this._updateIntervalState())}setIntervalDuration(e){e!==this._intervalDuration&&(this._intervalDuration=e,this._clearInterval(),this._updateIntervalState())}_updateIntervalState(){if(this._intervalDuration>0&&this._needsBlinkInViewport&&this._isViewportVisible){if(this._interval!==void 0)return;let e=this._blinkOn;this._blinkOn=!0,this._interval=this._coreBrowserService.window.setInterval(()=>{this._blinkOn=!this._blinkOn,this._renderCallback()},this._intervalDuration),e||this._renderCallback();return}this._clearInterval(),this._blinkOn||(this._blinkOn=!0,this._renderCallback())}_clearInterval(){this._interval!==void 0&&(this._coreBrowserService.window.clearInterval(this._interval),this._interval=void 0)}},ry=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function ny(e,t,r,n){let a=Os(e.createProgram());if(e.attachShader(a,Os(b2(e,e.VERTEX_SHADER,t,n))),e.attachShader(a,Os(b2(e,e.FRAGMENT_SHADER,r,n))),e.linkProgram(a),e.getProgramParameter(a,e.LINK_STATUS))return a;n.error(e.getProgramInfoLog(a)),e.deleteProgram(a)}function b2(e,t,r,n){let a=Os(e.createShader(t));if(e.shaderSource(a,r),e.compileShader(a),e.getShaderParameter(a,e.COMPILE_STATUS))return a;n.error(e.getShaderInfoLog(a)),e.deleteShader(a)}function YS(e,t){let r=Math.min(e.length*2,t),n=new Float32Array(r);for(let a=0;a<e.length;a++)n[a]=e[a];return n}var ZS=class{constructor(t){this.texture=t,this.version=-1}},KS=`#version 300 es
4
4
  layout (location = 0) in vec2 a_unitquad;
5
5
  layout (location = 1) in vec2 a_cellpos;
@@ -67,7 +67,7 @@ void main() {
67
67
  `).replace(/\\t/g," ")}const Ax="||",HI=120;function WI(e){return e.includes(Ax)?e.split(Ax).filter(t=>t.length>0):[e]}function yu(e){const t=new Set,r=e.map((a,c)=>{const l=typeof a.id=="string"&&a.id.trim().length>0?a.id.trim().toLowerCase().replace(/[^a-z0-9_-]/g,"-"):`preset-${c+1}`,h=t.has(l)?`${l}-${c+1}`:l;return t.add(h),{id:h,label:typeof a.label=="string"&&a.label.trim().length>0?a.label.trim():"Preset",programs:Array.isArray(a.programs)?a.programs.map(p=>Iy(p)).filter(p=>!!p):[],includeAlt:typeof a.includeAlt=="boolean"?!!a.includeAlt:!1,rowLayout:$1(a.rowLayout),showOnDesktop:typeof a.showOnDesktop=="boolean"?!!a.showOnDesktop:!1,actions:Array.isArray(a.actions)?a.actions.map((p,m)=>{const x={id:typeof p.id=="string"&&p.id.trim().length>0?p.id:`${h}-action-${m+1}`,label:typeof p.label=="string"?p.label:`Key ${m+1}`,sequence:typeof p.sequence=="string"?p.sequence:""};return typeof p.doubleTapSequence=="string"&&(x.doubleTapSequence=p.doubleTapSequence),x}):[]}}).filter(a=>a.id!=="auto"),n=ud()[0];return n&&!r.some(a=>a.id==="default")&&r.unshift(n),r}function GI(e,t){const r=Ly(e);if(!r)return"default";for(const n of t)if(n.id!=="default")for(const a of n.programs){const c=of(a);if(c){if(c.test(r))return n.id}else if(r.includes(a))return n.id}return"default"}function Tx(e,t){return e.find(r=>r.id===t)??e.find(r=>r.id==="default")??ud()[0]}function VI(e){return[{id:"auto",label:"Auto"},...e.map(t=>({id:t.id,label:t.label}))]}function qI(e){return[{id:"auto",label:"Auto"},...e.filter(t=>t.id==="default"||t.showOnDesktop===!0).map(t=>({id:t.id,label:t.label}))]}function Ey(e,t){const r=$1(t),n=[];let a=0,c=0;for(;a<e.length;){const l=r[Math.min(c,r.length-1)]??3;n.push({columns:l,items:e.slice(a,a+l)}),a+=l,c+=1}return n}const Ny=28,Ry=({mode:e,presetLabel:t,title:r,ariaLabel:n,disabled:a,onPointerDown:c,buttonRef:l})=>s.jsx("button",{ref:l,type:"button",onPointerDown:c,tabIndex:-1,disabled:a,className:"h-7 w-7 rounded-full bg-surface-2 shadow-sm text-[11px] font-medium active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 flex items-center justify-center",title:r,"aria-label":n??r,children:e==="auto"?s.jsx(wC,{size:14}):(t.charAt(0)||"?").toUpperCase()}),YI={esc:"\x1B",enter:"\r",home:"\x1B[H",end:"\x1B[F","ctrl-c":"","ctrl-d":"","ctrl-w":"","ctrl-u":""},v0=8;function ZI(e,t){return YI[e]??null}const KI=({visible:e,interactive:t=!0,presentation:r="mobile",activeModifier:n,lockedModifier:a,disabled:c,defaultShowExtended:l=!1,presetLabel:h,presetModeLabel:p,presetMode:m,presetOptions:x,includeAlt:y,presetRowLayout:w,extraActions:v,onKeyPress:k,onTextPress:L,onPastePress:E,onFilePress:R,onFileLongPress:B,fileUploadState:W="idle",fileUploadProgress:F=0,longPressMode:U="arrows",copyFeedback:V="idle",onLongPressModeToggle:Z,onModifierToggle:le,onPresetSelect:xe,onExpandedChange:fe})=>{const{t:te}=zr(),[ke,$e]=_.useState(l),[Y,Ae]=_.useState(!1),lt=_.useRef(null),Ce=r==="desktop-actions",ye=Ce||ke,[_e,je]=_.useState(!1),[re,Pe]=_.useState(null),Se=c||!e||!t,Ee=c||!e,Be=_.useRef(null),Ne=_.useRef(null),oe=_.useRef(null),He=_.useRef(null),rt=_.useRef(null),mt=_.useRef(V),de=_.useRef(null),Ye=_.useRef(0),st=_.useRef(null),Ie=_.useRef(!1),We=_.useCallback(et=>{if(Se)return;const Ct=et.target;if(!(Ct instanceof Element))return;const Nt=Ct.closest("button"),gt=Nt?.hasAttribute("data-mobile-native-action")===!0;Nt&&!gt?(et.preventDefault(),io(v0)):Nt&&io(v0)},[Se]),Te=_.useCallback(et=>{et.preventDefault()},[]),H=_.useCallback(et=>{const Ct=et.target;Se||Ct instanceof HTMLElement&&Ct.closest("button")&&Ct.blur()},[Se]);_.useEffect(()=>{$e(l)},[l]),_.useEffect(()=>{Ce||fe?.(ke)},[Ce,fe,ke]),_.useEffect(()=>{Se&&(de.current!==null&&(window.clearTimeout(de.current.timer),de.current=null),je(!1),Pe(null))},[Se]),_.useEffect(()=>{e||(je(!1),Pe(null))},[e]),_.useEffect(()=>{if(!_e)return;const et=()=>{const Ct=Be.current?.getBoundingClientRect();Ct&&Pe({left:Math.max(8,Ct.left),top:Math.max(8,Ct.top-8)})};return et(),window.addEventListener("resize",et),window.addEventListener("scroll",et,!0),()=>{window.removeEventListener("resize",et),window.removeEventListener("scroll",et,!0)}},[_e]),_.useEffect(()=>{const et=mt.current;if(mt.current=V,V==="idle"||V===et)return;if(rt.current!==null&&window.clearTimeout(rt.current),!(typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches))if(V==="copied"){Ne.current?.animate?.([{transform:"scale(1)"},{transform:"scale(1.16)",offset:.28},{transform:"scale(0.96)",offset:.62},{transform:"scale(1)"}],{duration:720,easing:"cubic-bezier(0.16, 1, 0.3, 1)"});const Nt=[{opacity:0,transform:"scale(0.65)"},{opacity:.75,transform:"scale(0.9)",offset:.18},{opacity:0,transform:"scale(1.65)"}];oe.current?.animate?.(Nt,{duration:760,easing:"ease-out"}),He.current?.animate?.(Nt,{duration:760,delay:130,easing:"ease-out"})}else Ne.current?.animate?.([{transform:"translateX(0)"},{transform:"translateX(-2px)"},{transform:"translateX(2px)"},{transform:"translateX(0)"}],{duration:280,easing:"ease-out"});io(v0),V==="copied"&&(rt.current=window.setTimeout(()=>{io(v0),rt.current=null},90),U==="copy"&&Z?.())},[V,U,Z]),_.useEffect(()=>()=>{rt.current!==null&&window.clearTimeout(rt.current)},[]);const ae=_.useCallback((et,Ct)=>{Se||(et.preventDefault(),k(Ct))},[k,Se]),be=_.useCallback((et,Ct)=>{Se||(et.preventDefault(),le(Ct))},[le,Se]),Ze=_.useCallback(et=>{Se||(et.preventDefault(),$e(Ct=>{const Nt=!Ct;return Nt&&(Ae(!0),lt.current!==null&&window.clearTimeout(lt.current),lt.current=window.setTimeout(()=>{Ae(!1),lt.current=null},350)),Nt}))},[Se]),Je=_.useCallback(()=>{const et=typeof performance<"u"?performance.now():Date.now();et-Ye.current<350||(Ye.current=et,E?.())},[E]),Tt=_.useCallback(et=>{Se||(et.stopPropagation(),et.pointerType!=="touch"&&(et.preventDefault(),Je()))},[Se,Je]),Wt=_.useCallback(et=>{Se||(et.preventDefault(),et.stopPropagation(),Je())},[Se,Je]),Mt=_.useCallback(et=>{Se||W==="uploading"||!R||(et.preventDefault(),et.stopPropagation(),Ie.current||R(),Ie.current=!1)},[W,R,Se]),vt=_.useCallback(()=>{st.current!==null&&window.clearTimeout(st.current),st.current=null},[]),Yt=_.useCallback(et=>{et.stopPropagation(),!(Se||W==="uploading"||!B)&&(Ie.current=!1,st.current=window.setTimeout(()=>{st.current=null,Ie.current=!0,io(v0),B()},500))},[W,B,Se]);_.useEffect(()=>()=>vt(),[vt]);const Qt=_.useCallback(et=>{Se||et.stopPropagation()},[Se]),Xt=250,Ut=_.useCallback(()=>{de.current!==null&&(window.clearTimeout(de.current.timer),de.current=null)},[]);_.useEffect(()=>()=>{Ut(),lt.current!==null&&(window.clearTimeout(lt.current),lt.current=null)},[Ut]);const Lt=_.useCallback((et,Ct)=>{if(Se)return;if(et.preventDefault(),!Ct.doubleTapSequence){L(Ct.sequence);return}const Nt=de.current;if(Nt!==null&&Nt.actionId===Ct.id){window.clearTimeout(Nt.timer),de.current=null,L(Ct.doubleTapSequence);return}Ut();const gt=window.setTimeout(()=>{de.current=null,L(Ct.sequence)},Xt);de.current={actionId:Ct.id,timer:gt}},[Ut,L,Se]),pe=_.useCallback(et=>{Se||(et.preventDefault(),et.stopPropagation(),Z?.())},[Z,Se]),Ge=_.useCallback(et=>{Se||et.stopPropagation()},[Se]),ft=_.useCallback(et=>{if(Se)return;et.preventDefault();const Ct=et.currentTarget.getBoundingClientRect();Pe({left:Math.max(8,Ct.left),top:Math.max(8,Ct.top-8)}),je(Nt=>!Nt)},[Se]),q=_.useCallback((et,Ct)=>{Se||(et.preventDefault(),je(!1),Pe(null),xe(Ct))},[xe,Se]),at=v.length>0,Vt=_.useMemo(()=>{const et=[{id:"preset",kind:"preset"}];if(!Ce&&y&&et.push({id:"alt",kind:"alt"}),at){const Ct=v.map(Nt=>({id:Nt.id,kind:"text",action:Nt}));return et.concat(Ct)}return Ce?et.concat([{id:"esc",kind:"key",keyName:"esc"},{id:"ctrl-c",kind:"key",keyName:"ctrl-c"},{id:"ctrl-d",kind:"key",keyName:"ctrl-d"},{id:"home",kind:"key",keyName:"home"},{id:"end",kind:"key",keyName:"end"}]):et.concat([{id:"home",kind:"key",keyName:"home"},{id:"end",kind:"key",keyName:"end"},{id:"ctrl-d",kind:"key",keyName:"ctrl-d"}])},[v,at,y,Ce]),Ve=_.useMemo(()=>Ey(Vt,Ce&&!at?[6]:w),[Vt,at,Ce,w]),De=`${Ce?"space-y-1":"mt-1 space-y-1"}${Y?" pointer-events-none":""}`,er=_e&&re?Li.createPortal(s.jsx("div",{className:"fixed z-popover min-w-28 -translate-y-full rounded-2xl bg-surface-elevated p-1.5 shadow-xl border border-border/15",style:{left:re.left,top:re.top},children:s.jsx("div",{className:"grid gap-1",children:x.map(et=>s.jsx("button",{type:"button",onPointerDown:Ct=>q(Ct,et.id),tabIndex:-1,disabled:Ee,className:`h-7 rounded-full px-3 text-left text-xs font-medium transition-colors disabled:opacity-50 ${et.id===m?"bg-primary text-primary-foreground":"bg-surface-2 hover:bg-surface-elevated text-muted-foreground hover:text-foreground"}`,children:et.label},et.id))})}),document.body):null;return s.jsxs(s.Fragment,{children:[er,s.jsx("div",{"data-mobile-keyboard":"true",className:`z-chrome select-none overflow-hidden app-chrome-bg transition-all duration-150 ease-out px-1 py-0 ${e?Ce?"max-h-24":"max-h-40":"max-h-0"} ${e?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none"} ${t?"":"[&_button]:pointer-events-none"}`,onMouseDownCapture:We,onPointerDownCapture:We,onContextMenuCapture:Te,onFocusCapture:H,children:s.jsxs("div",{className:"rounded-2xl bg-surface-elevated p-0.5 space-y-0.5",children:[!Ce&&s.jsxs("div",{"data-mobile-keyboard-primary-row":"true",className:"grid grid-cols-10 gap-1",children:[s.jsx("button",{type:"button",onPointerDown:et=>ae(et,"esc"),tabIndex:-1,disabled:Ee,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50",children:"Esc"}),s.jsx("button",{type:"button",onPointerDown:et=>be(et,"ctrl"),tabIndex:-1,disabled:Ee,className:`h-7 w-full rounded-full shadow-sm text-xs disabled:opacity-50 flex items-center justify-center transition-all ${n==="ctrl"?"bg-primary text-primary-foreground scale-105 shadow-md shadow-primary/40":"bg-surface-2"} ${a==="ctrl"?"ring-2 ring-accent":""}`,children:s.jsx("span",{className:"font-medium",children:a==="ctrl"?"Ctrl*":"Ctrl"})}),s.jsx("button",{type:"button",onPointerDown:et=>ae(et,"ctrl-c"),tabIndex:-1,disabled:Ee,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50",children:"C-C"}),s.jsx("button",{type:"button",onPointerDown:et=>ae(et,"ctrl-u"),tabIndex:-1,disabled:Ee,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50",children:"C-U"}),s.jsxs("button",{type:"button",onPointerDown:Yt,onPointerUp:vt,onPointerCancel:vt,onClick:Mt,tabIndex:-1,disabled:Ee||!R||W==="uploading",title:W==="uploading"?`${te("rightSidebar.uploading")} ${Math.round(F)}%`:te(W==="inserted"?"rightSidebar.inserted":W==="failed"?"rightSidebar.uploadFailed":"rightSidebar.insertLocalFile"),"aria-label":te("rightSidebar.insertLocalFile"),className:`relative h-7 w-full overflow-hidden rounded-full shadow-sm active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 flex items-center justify-center ${W==="inserted"?"bg-primary/15 text-primary":W==="failed"?"bg-destructive/15 text-destructive":"bg-surface-2"}`,children:[W==="uploading"&&s.jsx("span",{"aria-hidden":"true","data-file-upload-progress":"true",className:"absolute inset-y-0 left-0 bg-primary/25 transition-[width] duration-150 ease-out",style:{width:`${Math.max(0,Math.min(100,F))}%`}}),s.jsx("span",{className:"relative z-10 flex items-center justify-center",children:W==="uploading"?s.jsx(In,{size:15,className:"animate-spin"}):W==="inserted"?s.jsx(di,{size:15}):W==="failed"?s.jsx(Qn,{size:15}):s.jsx(HA,{size:15})}),W!=="idle"&&s.jsx("span",{className:"sr-only",role:"status","aria-live":"polite",children:W==="uploading"?`${te("rightSidebar.uploading")} ${Math.round(F)}%`:te(W==="inserted"?"rightSidebar.inserted":"rightSidebar.uploadFailed")})]}),s.jsx("button",{type:"button",onPointerDown:()=>L("/"),tabIndex:-1,disabled:Ee,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50",children:"/"}),s.jsx("button",{type:"button",onPointerDown:et=>ae(et,"enter"),tabIndex:-1,disabled:Ee,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 flex items-center justify-center",children:s.jsx(PA,{size:16})}),s.jsxs("button",{ref:Ne,type:"button","data-mobile-copy-button":"true","data-mobile-native-action":"true",onPointerDown:Ge,onTouchStart:Ge,onClick:pe,tabIndex:-1,disabled:Ee,title:te(V==="copied"?"terminal.copied":V==="failed"?"terminal.copyFailed":U==="copy"?"terminal.longPressSelectsText":"terminal.longPressSendsArrows"),"aria-label":te(U==="copy"?"terminal.switchLongPressToArrows":"terminal.switchLongPressToCopy"),className:`relative isolate h-7 w-full overflow-visible rounded-full shadow-sm active:bg-accent active:text-accent-foreground transition-colors keyboard-button-active disabled:opacity-50 flex items-center justify-center ${V==="copied"?"bg-primary/15 text-primary":V==="failed"?"bg-destructive/15 text-destructive":U==="copy"?"bg-primary/15 text-primary":"bg-surface-2"}`,children:[s.jsx("span",{ref:oe,"aria-hidden":"true",className:"pointer-events-none absolute inset-0 z-0 rounded-full border border-primary/70 opacity-0"}),s.jsx("span",{ref:He,"aria-hidden":"true",className:"pointer-events-none absolute inset-0 z-0 rounded-full border border-primary/40 opacity-0"}),s.jsxs("span",{className:"relative z-10 h-4 w-4","aria-hidden":"true",children:[s.jsx(di,{size:16,className:`absolute inset-0 transition-[opacity,transform] duration-300 ease-out motion-reduce:transition-none ${V==="copied"?"scale-100 rotate-0 opacity-100":"scale-50 -rotate-45 opacity-0"}`}),s.jsx(Qn,{size:16,className:`absolute inset-0 transition-[opacity,transform] duration-200 ease-out motion-reduce:transition-none ${V==="failed"?"scale-100 opacity-100":"scale-50 opacity-0"}`}),s.jsx(b3,{size:15,className:`absolute inset-0 transition-[opacity,transform] duration-300 ease-out motion-reduce:transition-none ${V==="idle"&&U==="copy"?"scale-100 opacity-100":"scale-50 opacity-0"}`}),s.jsx(yT,{size:15,className:`absolute inset-0 transition-[opacity,transform] duration-300 ease-out motion-reduce:transition-none ${V==="idle"&&U==="arrows"?"scale-100 rotate-0 opacity-100":"scale-50 rotate-45 opacity-0"}`})]}),V!=="idle"&&s.jsx("span",{className:"sr-only",role:"status","aria-live":"polite",children:V==="copied"?`${te("terminal.copied")} · ${te("terminal.longPressSendsArrows")}`:`${te("terminal.copyFailed")} · ${te("terminal.longPressSelectsText")}`})]}),s.jsx("button",{type:"button","data-mobile-copy-button":"true","data-mobile-native-action":"true",onPointerDown:Tt,onPointerUp:Qt,onTouchStart:Qt,onTouchEnd:Qt,onClick:Wt,tabIndex:-1,disabled:Ee,title:te("terminal.paste"),"aria-label":te("terminal.paste"),className:"h-7 w-full rounded-full bg-surface-2 shadow-sm active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 flex items-center justify-center",children:s.jsx(IA,{size:15})}),s.jsx("button",{type:"button",onPointerDown:Ze,tabIndex:-1,disabled:Ee,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 flex items-center justify-center",children:ke?s.jsx(H8,{size:16}):s.jsx(ul,{size:16})})]}),ye&&s.jsx("div",{className:De,children:Ve.map((et,Ct)=>{const Nt=et.items[0]?.kind==="preset",gt=Math.max(2,et.columns),bt=Nt?`${Ny}px repeat(${Math.max(1,gt-1)}, minmax(0, 1fr))`:`repeat(${gt}, minmax(0, 1fr))`;return s.jsx("div",{className:"relative grid gap-1",style:{gridTemplateColumns:bt},children:et.items.map(It=>It.kind==="preset"?s.jsx(Ry,{buttonRef:It.id==="preset"?Be:void 0,mode:m,presetLabel:h,title:p,disabled:Ee,onPointerDown:ft},It.id):It.kind==="alt"?s.jsx("button",{type:"button",onPointerDown:yt=>be(yt,"alt"),tabIndex:-1,disabled:Ee,className:`h-7 w-full rounded-full shadow-sm text-xs disabled:opacity-50 flex items-center justify-center transition-all ${n==="alt"?"bg-primary text-primary-foreground scale-105 shadow-md shadow-primary/40":"bg-surface-2"} ${a==="alt"?"ring-2 ring-accent":""}`,children:s.jsx("span",{className:"font-medium",children:a==="alt"?"Alt*":"Alt"})},It.id):It.kind==="text"?s.jsxs("button",{type:"button",onPointerDown:yt=>Lt(yt,It.action),tabIndex:-1,disabled:Ee,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm px-1 text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50 relative",children:[It.action.label,It.action.doubleTapSequence&&s.jsx("span",{className:"absolute top-0.5 right-1.5 h-1 w-1 rounded-full bg-accent/60"})]},It.id):s.jsx("button",{type:"button",onPointerDown:yt=>ae(yt,It.keyName),tabIndex:-1,disabled:Ee,className:"h-7 w-full rounded-full bg-surface-2 shadow-sm text-xs active:bg-accent active:text-accent-foreground transition-all keyboard-button-active disabled:opacity-50",children:It.keyName==="esc"?"Esc":It.keyName==="ctrl-c"?"Ctrl-C":It.keyName==="ctrl-d"?"Ctrl-D":It.keyName==="home"?"Home":"End"},It.id))},`row-${Ct}`)})})]})})]})},XI=({isMobile:e,isInputFocused:t,isIOS:r,isConnecting:n,connectionError:a,terminalSessionId:c})=>{if(typeof window>"u")return null;const l=window.visualViewport?Math.max(0,Math.round(window.innerHeight-window.visualViewport.height-window.visualViewport.offsetTop)):0;return s.jsxs("div",{className:"px-3 py-2 bg-surface text-foreground text-xs border-b border-border/15",children:[s.jsx("div",{className:"font-bold mb-2",children:"Debug Info"}),s.jsxs("div",{className:"grid grid-cols-2 gap-1 font-mono",children:[s.jsxs("div",{children:["isMobile: ",s.jsx("span",{className:e?"text-accent":"text-destructive",children:String(e)})]}),s.jsxs("div",{children:["touchPoints: ",navigator.maxTouchPoints]}),s.jsxs("div",{children:["innerWidth: ",window.innerWidth]}),s.jsxs("div",{children:["innerHeight: ",window.innerHeight]}),s.jsxs("div",{children:["viewportH:"," ",window.visualViewport?Math.round(window.visualViewport.height):"N/A"]}),s.jsxs("div",{children:["inputFocused: ",String(t)]}),s.jsxs("div",{children:["keyboard~: ",l,"px"]}),s.jsxs("div",{children:["connecting:"," ",s.jsx("span",{className:n?"text-muted-foreground":"text-accent",children:String(n)})]}),s.jsxs("div",{children:["sessionId:"," ",s.jsx("span",{className:c?"text-accent":"text-destructive",children:c?"✓":"✗"})]}),s.jsxs("div",{children:["error:"," ",s.jsx("span",{className:a?"text-destructive":"text-accent",children:a?"Yes":"No"})]}),s.jsxs("div",{children:["isIOS:"," ",s.jsx("span",{className:r?"text-muted-foreground":"text-accent",children:String(r)})]})]}),s.jsx("div",{className:"mt-2 pt-2 border-t border-border/15",children:s.jsx("div",{children:"Tip: Tap the status bar 3 times to toggle debug panel"})})]})},JI=/^Reconnecting/i,eE=({connectionError:e,isFatalError:t,isRestarting:r,isConnecting:n,onHardRestart:a})=>{const{t:c}=zr(),l=!!e&&JI.test(e),h=!!(n&&!e||l),[p,m]=_.useState(!1);return _.useEffect(()=>{if(!h){m(!1);return}const x=setTimeout(()=>m(!0),1500);return()=>clearTimeout(x)},[h]),h?p?s.jsx("div",{className:"absolute inset-x-0 bottom-0 flex items-end justify-center pb-2 pointer-events-none",children:s.jsx(nd,{dots:!0,label:c("connection.reconnecting"),className:"rounded-full bg-surface-2 px-3 py-1 text-[11px]"})}):null:e?s.jsx("div",{className:"absolute inset-x-0 bottom-0 flex items-end justify-center pb-2",children:s.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-destructive/70",children:[s.jsx("span",{children:e}),t&&s.jsx("button",{type:"button",onClick:a,disabled:r,className:"text-[11px] text-destructive/90 hover:text-destructive underline underline-offset-2 transition-colors disabled:opacity-40",children:c("common.retry")})]})}):null};let U0=[],Up=!1;function va(e,t,r={}){typeof window>"u"||(U0.push(JSON.stringify({level:e,message:t,data:{ts:Date.now(),...r}})),tE())}async function tE(){if(!Up){Up=!0;try{for(;U0.length>0;){const e=U0[0];try{await fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:e,keepalive:!0}),U0.shift()}catch{U0=[];break}}}finally{Up=!1}}}const rE=120,nE=80,sE=400;function Cx(){if(typeof window>"u"||document.visibilityState!=="visible"||!W8())return 0;const e=Number.parseFloat(document.documentElement.style.getPropertyValue("--kb-height")||"0");if(Number.isFinite(e)&&e>0)return Math.round(e);const t=nl().visualViewport;if(!t)return 0;const r=Number.parseFloat(document.documentElement.style.getPropertyValue("--app-base-vh")||"0")||window.innerHeight,n=Number.parseFloat(document.documentElement.style.getPropertyValue("--safe-bottom-inset")||"0")||0,a=t.height+t.offsetTop;return Math.max(0,Math.round(r-a-n))}function My(e){const{enabled:t,openThresholdPx:r=rE,closeThresholdPx:n=nE,settleDelayMs:a=sE}=e,c=_.useMemo(()=>_u("keyboard"),[]),l=_.useRef(!1),h=_.useRef(null),p=_.useRef(0),[m,x]=_.useState({isOpen:!1,isSettled:!1,keyboardHeight:0});return _.useEffect(()=>{if(typeof window>"u"||!t){l.current=!1,h.current!==null&&(clearTimeout(h.current),h.current=null),x(V=>!V.isOpen&&!V.isSettled&&V.keyboardHeight===0?V:{isOpen:!1,isSettled:!1,keyboardHeight:0});return}let y=null;const w=()=>{y=null;const V=Cx();let Z=l.current;if(V>=r?Z=!0:V<=n&&(Z=!1),l.current=Z,Z){const le=Math.abs(V-p.current);p.current=V,le>10&&(h.current!==null&&clearTimeout(h.current),h.current=setTimeout(()=>{h.current=null,x(xe=>xe.isSettled?xe:{...xe,isSettled:!0})},a))}else h.current!==null&&(clearTimeout(h.current),h.current=null);x(le=>{const xe=Z?le.isSettled:!1;return le.isOpen===Z&&le.keyboardHeight===V&&le.isSettled===xe?le:(c("sync",{keyboardHeight:V,isOpen:Z,isSettled:xe,visualViewport:nl().visualViewport?{width:Math.round(nl().visualViewport.width),height:Math.round(nl().visualViewport.height),offsetTop:Math.round(nl().visualViewport.offsetTop)}:null}),{isOpen:Z,isSettled:xe,keyboardHeight:V})})},v=(V="event")=>{(V.includes("visibilitychange")||V.includes("pageshow"))&&c("schedule",{source:V}),y===null&&(y=window.requestAnimationFrame(w))};v("mount");const k=()=>v("resize"),L=()=>v("orientationchange"),E=()=>v("visualViewport.resize"),R=()=>v("visualViewport.scroll"),B=()=>v("viewport-keyboard-change");window.addEventListener("resize",k),window.addEventListener("orientationchange",L),nl().visualViewport?.addEventListener("resize",E),nl().visualViewport?.addEventListener("scroll",R),document.addEventListener("termdock:viewport-keyboard-change",B);const W=V=>{c("resume",{source:V,keyboardHeight:Cx(),hidden:document.hidden}),v(`${V}:now`),window.setTimeout(()=>v(`${V}:50ms`),50),window.setTimeout(()=>v(`${V}:200ms`),200)},F=()=>{document.hidden||W("visibilitychange")},U=()=>W("pageshow");return document.addEventListener("visibilitychange",F),window.addEventListener("pageshow",U),()=>{window.removeEventListener("resize",k),window.removeEventListener("orientationchange",L),nl().visualViewport?.removeEventListener("resize",E),nl().visualViewport?.removeEventListener("scroll",R),document.removeEventListener("termdock:viewport-keyboard-change",B),document.removeEventListener("visibilitychange",F),window.removeEventListener("pageshow",U),y!==null&&window.cancelAnimationFrame(y),h.current!==null&&(clearTimeout(h.current),h.current=null)}},[c,t,r,n,a]),m}const Qh=300,iE=120,aE=2e3,oE=250,lE=6e4;function cE(e){const t=new Set(e.slides.flat()),r=new Set([...e.visibleSessionIds].filter(l=>t.has(l)));e.foregroundSessionId&&t.has(e.foregroundSessionId)&&r.add(e.foregroundSessionId);const n=e.slides.findIndex(l=>l.some(h=>r.has(h)));if(n<0)return r;const a=e.slides[n-1]??[],c=e.slides[n+1]??[];for(let l=0;l<Math.max(a.length,c.length)&&r.size<3;l+=1)for(const h of[a[l],c[l]])h&&r.size<3&&r.add(h);return r}function zp(e,t){return t?e.find(r=>r.id===t||r.backendSessionId===t)?.id??null:null}function ch(e){return e.prioritySessionId??e.activeSessionId??e.persistedActiveSessionId??e.firstSessionId}function uE(e){return e.foregroundSessionId===null||e.isVisible===!0||e.sessionId===e.foregroundSessionId||e.foregroundReady}function dE(e){return e.sessionId===e.foregroundSessionId||e.visibleSessionIds.has(e.sessionId)||e.deferredViewportSessionIds.has(e.sessionId)}function hE(e){return e.isMobile&&(!e.viewportReady||!e.streamReady||!e.contentReady)}function fE(e){return e.writtenChunkId!==null&&e.initialTargetChunkId!==null&&e.writtenChunkId>=e.initialTargetChunkId}function pE(e){return!e.initialConnectionPending}function mE(e){return!e}function gE(e){return e.requestToken===0||e.isVisible===!0||e.foregroundSessionId===null||e.isVisible===void 0&&e.sessionId===e.foregroundSessionId||e.foregroundCompletedToken===e.requestToken}function xE(e,t){return[...e].every(r=>t.has(r))}function bE(e,t){return e===null||t-e>=oE}function yE(e){return!1}function vE(e){return!e.isActive||e.isStreamReady||e.reconnectStartedAt===null?null:Math.max(0,lE-(e.now-e.reconnectStartedAt))}function wE(e,t){const r=new Map;let n=0;for(const a of e)if(!r.has(a)){if(t.has(a)){r.set(a,0);continue}r.set(a,Qh+n*iE),n+=1}return r}const AE="Session not found on server",Ph="Terminal session not found",TE="STALE_SESSION_RESTORE_REJECTED";function Sx(e){return Km(e)?!1:e?.message===AE||e?.status===404&&e.message===Ph}function Km(e){return e?.code===TE}function CE(e,t){if(!e||e.startsWith("/"))return e;const r=e.replace(/^\.\//,"");return t?`${t.replace(/\/+$/,"")}/${r}`:r}function jy(e,t){return CE(e,t).replace(/ /g,"\\ ")}function Xm(e,t){return`${jy(e,t)} `}function _x(e,t){return jy(e,t)}function eU(e,t,r){if(!r)return _x(e,t);const n=r.start===r.end?`${r.start}`:`${r.start}-${r.end}`;return`${_x(e,t)}:${n}`}const SE="/tmp";async function _E(e,t,r){const a=(await t(SE,[e])).files[0];if(!a?.path)throw new Error("Upload did not return a file path");let c;try{c=await r(a.path)}catch{throw new lf(a)}if(!c)throw new lf(a);return a}class lf extends Error{constructor(t){super("File uploaded, but its reference was not accepted"),this.uploaded=t,this.name="UploadedReferenceRejectedError"}uploaded}function kx(e,t,r,n,a){if(!e||!t||!r())return Promise.resolve(!1);const c=n?HC(n,t,e):null;if(n&&!c)return Promise.resolve(!1);const l=c?.nonce??`reference-${crypto.randomUUID()}`;return new Promise(h=>{let p=!1;const m=w=>{p||(p=!0,window.clearTimeout(y),window.removeEventListener("termdock-insert-reference-ack",x),c&&WC(l),h(w&&r()))},x=w=>{const v=w.detail;v?.nonce===l&&m(v.ok===!0)},y=window.setTimeout(()=>m(!1),1500);window.addEventListener("termdock-insert-reference-ack",x),window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:c??{text:e,sessionId:t,nonce:l,focus:!1,paste:!0,submitAfterPaste:!1,...a}}))})}const Dy=[640,960,1280,1600,2048,2560,3072,4096],By=[240,360,480,540,720,1080,1440,2160],K0={min:.1,max:1,step:.01},X0={min:25e4,max:2e7,step:25e4},z1="termdock:mobile-media-compression-v1",ou={showResultToast:!0,imageEnabled:!1,imageMaxDimension:2048,imageQuality:.8,videoEnabled:!1,videoMaxHeight:720,videoBitrate:25e5};function Qy(){try{const e=JSON.parse(localStorage.getItem(z1)||"null");return!e||typeof e!="object"?ou:{showResultToast:e.showResultToast!==!1,imageEnabled:e.imageEnabled===!0,imageMaxDimension:Dy.includes(e.imageMaxDimension)?e.imageMaxDimension:ou.imageMaxDimension,imageQuality:typeof e.imageQuality=="number"&&e.imageQuality>=K0.min&&e.imageQuality<=K0.max?e.imageQuality:ou.imageQuality,videoEnabled:e.videoEnabled===!0,videoMaxHeight:By.includes(e.videoMaxHeight)?e.videoMaxHeight:ou.videoMaxHeight,videoBitrate:typeof e.videoBitrate=="number"&&e.videoBitrate>=X0.min&&e.videoBitrate<=X0.max?e.videoBitrate:ou.videoBitrate}}catch{return ou}}const H1=rc((e,t)=>({preferences:Qy(),saveFailed:!1,update:r=>{const n={...t().preferences,...r};let a=!1;try{localStorage.setItem(z1,JSON.stringify(n))}catch{a=!0}e({preferences:n,saveFailed:a})}}));typeof window<"u"&&window.addEventListener("storage",e=>{(e.key===z1||e.key===null)&&H1.setState({preferences:Qy(),saveFailed:!1})});function uh(e){if(e<1024)return`${e} B`;const t=["B","KB","MB","GB","TB"],r=Math.min(t.length-1,Math.floor(Math.log(e)/Math.log(1024)));return`${Number((e/1024**r).toFixed(1))} ${t[r]}`}function kE({result:e,message:t,onClose:r}){const{locale:n}=zr(),a=n==="zh",c=b.useRef(null),[l,h]=b.useState(null),[p,m]=b.useState(!1);return b.useEffect(()=>{const x=URL.createObjectURL(e.file);return h(x),m(!1),()=>URL.revokeObjectURL(x)},[e.file]),b.useEffect(()=>{const x=c.current;return x?.showModal(),()=>x?.close()},[]),s.jsx("dialog",{ref:c,"aria-label":a?"上传结果预览":"Uploaded media preview",onCancel:x=>{x.preventDefault(),r()},onClick:x=>{x.target===x.currentTarget&&r()},onKeyDown:x=>x.stopPropagation(),onKeyUp:x=>x.stopPropagation(),className:"fixed inset-0 z-modal-panel m-0 h-[100dvh] max-h-none w-screen max-w-none bg-transparent p-3 text-foreground backdrop:bg-[var(--app-backdrop)] open:flex open:items-center open:justify-center",children:s.jsxs("section",{className:"flex max-h-[calc(100dvh-env(safe-area-inset-top,0px)-env(safe-area-inset-bottom,0px)-1.5rem)] w-full max-w-3xl flex-col overflow-hidden rounded-2xl border border-border/15 bg-surface shadow-xl",children:[s.jsxs("header",{className:"flex shrink-0 items-start gap-3 border-b border-border/15 p-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{className:"text-sm font-semibold",children:a?"上传结果预览":"Uploaded media preview"}),s.jsx("p",{className:"mt-1 break-words text-xs text-muted-foreground",children:t}),s.jsx("p",{className:"mt-1 truncate text-[11px] text-muted-foreground",children:e.file.name})]}),s.jsx("button",{type:"button",autoFocus:!0,onClick:r,"aria-label":a?"关闭预览":"Close preview",className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-lg bg-surface-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",children:s.jsx(Qn,{size:18})})]}),s.jsx("div",{className:"min-h-0 overflow-auto p-2",children:p?s.jsx("p",{role:"alert",className:"p-4 text-sm text-muted-foreground",children:a?"文件已上传,但当前浏览器无法预览此格式。":"File uploaded, but this browser cannot preview this format."}):l&&(e.kind==="image"?s.jsx("img",{src:l,alt:e.file.name,onError:()=>m(!0),className:"mx-auto block max-h-[65dvh] max-w-full object-contain"}):s.jsx("video",{src:l,controls:!0,playsInline:!0,preload:"metadata",onError:()=>m(!0),className:"mx-auto block max-h-[65dvh] w-full"}))})]})})}function LE({result:e,onDismiss:t}){const{locale:r}=zr(),n=r==="zh",a=H1(E=>E.preferences.showResultToast),c=a?e:null,[l,h]=b.useState(null);b.useEffect(()=>{if(!e)return;if(!a){t();return}const E=window.setTimeout(t,2e3);return()=>window.clearTimeout(E)},[e,a,t]);const p=c??l?.result;if(!p)return null;const m=p.originalSize-p.uploadedSize,x=p.originalSize>0?Math.abs(m)/p.originalSize*100:0,y=x<1?"<1%":`${Math.floor(x)}%`,w=p.kind==="image"?n?"图片":"Image":n?"视频":"Video",v=m>0?n?"已压缩上传":"Compressed upload":n?"已处理上传":"Processed upload",k=m>0?n?`省 ${y}`:`${y} saved`:m<0?`+${y}`:n?"体积未变":"Size unchanged",L=p.originalRetained?n?`已尝试压缩 · 保留原图 ${uh(p.uploadedSize)},已上传`:`Compression tried · original ${uh(p.uploadedSize)} uploaded`:`${v} · ${uh(p.originalSize)} → ${uh(p.uploadedSize)} · ${k}`;return s.jsxs(s.Fragment,{children:[c&&s.jsx("div",{role:"status","aria-live":"polite","aria-atomic":"true",className:"pointer-events-none absolute left-1/2 top-1/2 z-30 w-max max-w-[calc(100%-1.5rem)] -translate-x-1/2 -translate-y-1/2 motion-safe:animate-[fade-in_0.15s_ease-out]",children:s.jsxs("button",{type:"button","aria-label":`${w}:${L} · ${n?"点击预览":"Preview"}`,onClick:()=>{h({result:c,message:L}),t()},className:"pointer-events-auto flex max-w-full select-none items-center gap-1.5 rounded-full border border-border/15 bg-surface-elevated px-3 py-2 text-[11px] leading-4 text-foreground shadow-md focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",children:[s.jsx(di,{size:13,strokeWidth:2.5,className:"shrink-0 text-primary","aria-hidden":"true"}),s.jsx("span",{className:"truncate tabular-nums",children:L}),s.jsx("span",{className:"shrink-0 text-muted-foreground",children:n?"预览 ›":"Preview ›"})]})}),l&&Li.createPortal(s.jsx(kE,{result:l.result,message:l.message,onClose:()=>h(null)}),document.body)]})}const IE=320,Lx="termdock:mobile-keyboard-expanded",Ix="termdock:mobile-keyboard-preset-mode",Ex="termdock:mobile-long-press-mode",EE=80;function NE(e){return/\.(?:jpe?g|png|heic|heif)$/i.test(e.name)||/^(?:image\/jpeg|image\/png|image\/heic|image\/heif)$/i.test(e.type)}function Nx(e){const t=(e instanceof Error?e.message:String(e)).slice(0,3e3);return/importing a module script failed|dynamically imported module|loading chunk/i.test(t)?`压缩模块加载失败,可能是页面版本过旧或网络中断。请更新页面后重试,无需清除转码器缓存。
68
68
  ${t}`:t}function RE(e){switch(e?.phase){case"loading":return`正在加载转码器… ${e.progress??0}%(优先使用浏览器缓存)`;case"saving":return"加载完成,正在保存到本机…";case"initializing":return e.source==="local"?"已找到本机缓存,正在初始化转码器…":"正在初始化本地转码器…";case"ready":return e.source==="local"?"已从本机缓存加载,转码器已就绪。":e.saved?"转码器已就绪,已保存到本机供下次使用。":"转码器已就绪。";default:return"正在检查本机转码器缓存…"}}function Hp(){return typeof window>"u"?!1:(navigator.maxTouchPoints>0||"ontouchstart"in window)&&window.innerWidth<768}const ME={retry:{maxRetries:60,initialDelayMs:1e3,maxDelayMs:2e4},connectionTimeoutMs:15e3},jE=({sessionId:e,mode:t,tmuxSessionName:r=null,terminalSettings:n=F1(),colorTheme:a="dark",toolbarPresets:c=[],isActive:l=!0,focusSuspended:h=!1,deferCursorUntilPositioned:p=!1,isLayoutVisible:m=!0,focusRequestToken:x=0,resumeRequestToken:y=0,resumeRequestReason:w="visibility",resumeRequestDelayMs:v=0,forceResumeReconnect:k=!1,initialConnectDelayMs:L=0,initialConnectEnabled:E=!0,resumeRequestEnabled:R=!0,onStreamReadyChange:B,onStreamConnected:W,onViewportReadyChange:F,onContentReadyChange:U,onKeyboardVisibilityChange:V,suppressKeyboard:Z=!1,keyboardPortalTarget:le=null,sharedMobileKeyboardLayout:xe=!1,suppressPageFlipRefresh:fe=!1,showDebug:te,onStatusChange:ke})=>{const{t:$e}=zr(),[Y]=_.useState(e||j3()),[Ae,lt]=_.useState(()=>(e?Lm(e):null)??n.fontSize),Ce=_.useMemo(()=>BI(),[]),ye=_.useMemo(()=>_u("session"),[]),_e=_.useMemo(()=>_u("keyboard"),[]),je=_.useRef(null),re=_.useRef(null);_.useEffect(()=>{Lm(Y)===null&&lt(n.fontSize)},[n.fontSize,Y]);const Pe=_.useMemo(()=>({...n,fontSize:Ae}),[n,Ae]),Se=G8(),Ee=h||Se,[Be,Ne]=_.useState(Hp),[oe,He]=_.useState(!1),[rt,mt]=_.useState(!1),[de,Ye]=_.useState(!1),[st,Ie]=_.useState(()=>typeof document>"u"?!0:!document.hidden&&hu()),[We,Te]=_.useState(()=>typeof document>"u"?!0:document.hasFocus()),[H,ae]=_.useState(!1),be=_.useRef(H);be.current=H;const[Ze,Je]=_.useState(!1),[Tt,Wt]=_.useState(!1),[Mt,vt]=_.useState(!1),[Yt,Qt]=_.useState(!0),{isOpen:Xt,keyboardHeight:Ut}=My({enabled:Be&&l}),[Lt,pe]=_.useState(null),[Ge,ft]=_.useState(null),[q,at]=_.useState(()=>typeof window>"u"?!1:window.localStorage.getItem(Lx)==="true"),[Vt,Ve]=_.useState(()=>{if(typeof window>"u")return"auto";const ce=window.localStorage.getItem(Ix);return ce&&ce.length>0?ce:"auto"}),[De,er]=_.useState(()=>typeof window>"u"?"arrows":window.localStorage.getItem(Ex)==="copy"?"copy":"arrows"),[et,Ct]=_.useState("idle"),[Nt,gt]=_.useState("idle"),[bt,It]=_.useState(0),[yt,pr]=_.useState(null),[nr,_r]=_.useState(null),[un,Ir]=_.useState(null),me=_.useCallback(()=>Ir(null),[]),{preferences:Gr,update:it,saveFailed:dt}=H1(),{videoEnabled:sr,videoMaxHeight:An,videoBitrate:on,imageEnabled:Me,imageMaxDimension:nt,imageQuality:wt}=Gr,[Mr,rn]=_.useState(!1),[Er,ne]=_.useState(null),[ht,zt]=_.useState(null),Pt=Yr(ce=>ce.sessions.get(Y)),{setTerminalSession:Cr,setConnecting:gr,appendToBuffer:Hr,replaceBuffer:En,clearTerminalSession:dr,removeTerminalSession:Tn,clearBuffer:hn,setSessionActiveProgram:Sn,setSessionCwd:ir,setSessionCopyMode:mn,setSessionAgentStatus:Qr,setSessionShellTitle:Vr,setSessionPromptState:Wr,clearAgentNeedsReview:fs}=Yr.getState(),Dr=_.useMemo(()=>`wt-${Y.replace(/[^a-zA-Z0-9_-]/g,"").slice(0,12)}`,[Y]),Pn=Pt?.terminalSessionId??null,Sr=Pt?.mode??"shell",Kr=Pt?.activeProgram??null,nn=_.useMemo(()=>yu(c),[c]),Or=Sr==="tmux",ks=Pt?.bufferChunks??[],Pr=Pt?.isConnecting??!1,Xr=Pn,fn=_.useCallback(async(ce,T)=>{const j=sI(ce,Pt?.cwd||Pt?.directory);if(!j)return;let Q=j,O="directory";try{Q=(await C1(j)).path}catch(ge){if(!(ge instanceof Error)||ge.message!=="Path is not a directory")return;O="file"}try{const ge=Gt.getState();ge.setRightTab("files"),ge.openRight(),window.dispatchEvent(new CustomEvent(XL,{detail:{path:Q,kind:O,line:T}}))}catch{}},[Pt?.cwd,Pt?.directory]),K=t??Pt?.mode??"shell",Ue=K==="tmux"?r??Pt?.tmuxSessionName??null:null,[Et,kt]=_.useState(null),tr=_.useRef(!1),[Br,cr]=_.useState(!1),[_n,Ls]=_.useState(!1),[Zn,sn]=_.useState(null),[ln,kr]=_.useState(0),[$r,Gn]=_.useState(null),Vn=te!==void 0?te:!1,dn=_.useRef(null),Kn=_.useRef(null),Lr=_.useRef(null),Nr=_.useRef(null),xr=_.useRef(null),os=_.useRef(!1),Hn=_.useRef(null),Nn=_.useRef([]),Rn=_.useRef(0),ps=_.useRef(!1),G=_.useRef(null),Le=_.useRef(null),Ke=_.useRef(-1),ct=_.useRef(null),qe=_.useRef(0),At=_.useRef(null),Rt=_.useRef(null),Dt=_.useRef(0),ot=_.useRef(0),Ot=_.useRef(!1),hr=_.useRef(null),Zt=_.useRef(null),z=_.useRef(!1),N=_.useRef(0),$=_.useRef(!1),ee=_.useRef(!1),se=_.useRef(!1),Qe=_.useRef(null),ze=_.useRef(null),xt=_.useRef(null),_t=_.useRef(l);_t.current=l;const Fr=_.useRef(Ee);Fr.current=Ee;const jt=_.useRef(h);jt.current=h;const qr=_.useRef(Be),pn=_.useRef(null),Xn=_.useRef(null),vn=_.useRef(null),kn=_.useRef(null),ar=_.useRef(null),qt=_.useRef(null),cn=_.useRef(null),an=_.useCallback(()=>{const ce=++N.current,T=()=>{ce===N.current&&Je(!0)};if(typeof window>"u"){T();return}window.requestAnimationFrame(()=>window.requestAnimationFrame(T))},[]),Hs=_.useCallback(ce=>{if($.current){if(ze.current!==null&&(window.clearTimeout(ze.current),ze.current=null),ce.x===0&&ce.y>=ce.rows-1){Qt(!1);return}ze.current=window.setTimeout(()=>{ze.current=null,Qt(!0)},EE)}},[]),Is=_.useRef(null);_.useEffect(()=>()=>{Is.current?.()},[]);const Ks=_.useCallback(()=>{Is.current||(Is.current=E1(()=>{Is.current=null;const ce=Yr.getState(),T=Lr.current,j=ce.getTerminalSession(Y);if(!T||j?.mode!=="shell"||ce.hasPendingBufferWrites(Y))return;const Q=V8(T),O=xr.current?.getDimensions();if(!Q||!O)return;const ge=xr.current?.serializeSnapshot();ge&&q8({id:T,version:1,...Q,...O,data:ge,savedAt:Date.now()})},2e3))},[Y]),Po=_.useCallback(ce=>{const T=Yr.getState(),j=T.getTerminalSession(Y)?.bufferChunks.at(-1)?.id;if(Lr.current&&j!==void 0&&j<=ce&&!T.hasPendingBufferWrites(Y)&&(Y8(Lr.current),Ks()),!Ot.current||!fE({writtenChunkId:ce,initialTargetChunkId:hr.current}))return;const Q=Zt.current;Zt.current=null,Q!==null&&xr.current?.notifyScreenSynchronized(Q),Ot.current=!1,hr.current=null,an()},[an,Ks,Y]),Aa=_.useCallback(ce=>{if(!$.current)return;const T=Qe.current;T&&T.x===ce.x&&T.y===ce.y&&T.rows===ce.rows||(Qe.current=ce,ze.current!==null&&(window.clearTimeout(ze.current),ze.current=null),ce.x===0&&ce.y>=ce.rows-1&&Qt(!1))},[]);_.useEffect(()=>{if(!p){ee.current=!1;return}ee.current||(ee.current=!0,se.current=!1,$.current=!0,Qe.current=null,Qt(!1),ze.current!==null&&(window.clearTimeout(ze.current),ze.current=null),xt.current!==null&&window.clearTimeout(xt.current),xt.current=window.setTimeout(()=>{xt.current=null,ze.current!==null&&typeof window<"u"&&window.clearTimeout(ze.current),ze.current=null,$.current=!1,Qt(!0)},15e3))},[p]);const Ln=_.useCallback(()=>{kn.current=null;const ce=vn.current;vn.current=null,ce&&Vr(ce.sessionId,ce.title)},[Vr]),ia=_.useCallback((ce,T)=>{if(vn.current={sessionId:ce,title:T},kn.current===null){if(typeof window>"u"){Ln();return}kn.current=window.requestAnimationFrame(Ln)}},[Ln]),fo=_.useCallback(()=>{kn.current!==null&&typeof window<"u"&&window.cancelAnimationFrame(kn.current),kn.current=null,vn.current=null},[]),Ba=_.useCallback(async()=>{const ce=K;return(await Z8({preferredFrontendSessionId:Y,mode:ce,tmuxSessionName:ce==="tmux"?Ue||Dr:void 0,termType:"xterm-256color",requireExisting:!0})).terminalSession},[K,Ue,Dr,Y]),Ei=_.useRef(l);_.useEffect(()=>{if(!l){xr.current?.blur(),Ei.current=!1;return}if(Ei.current)return;Ei.current=!0;const ce=bL(Be,fe);if(ce==="single"){xr.current?.requestRefresh("focus",{skipResizePush:!0,skipScrollToBottom:!0});return}ce!=="none"&&xr.current?.requestRefresh("page-flip",{reconcileServerSize:!0,skipScrollToBottom:!0})},[l,Be,fe,Xr]),_.useEffect(()=>{qr.current=Be},[Be]);const ws=_.useCallback(()=>{!_t.current||Fr.current||xr.current?.focus()},[]);_.useLayoutEffect(()=>{Ee&&xr.current?.blur()},[Ee]),_.useEffect(()=>{if(!l||Ee||Yt||se.current)return;se.current=!0;const ce=window.requestAnimationFrame(()=>{xr.current?.requestPtyRedraw()});return()=>window.cancelAnimationFrame(ce)},[Ee,l,Yt]);const Qa=_.useCallback(ce=>{typeof window>"u"||typeof document>"u"||!_t.current||Fr.current||qr.current||document.hidden||!hu()||(pn.current!==null&&window.clearTimeout(pn.current),pn.current=window.setTimeout(()=>{if(pn.current=null,!_t.current||Fr.current||qr.current||document.hidden||!hu())return;const T=document.activeElement,j=T?.getAttribute("data-terminal-input-anchor")==="true";if((T instanceof HTMLInputElement||T instanceof HTMLTextAreaElement||T instanceof HTMLSelectElement||T?.isContentEditable===!0)&&!j){_e("desktop resume focus skipped: editable active",{reason:ce});return}_e("desktop resume focus",{reason:ce}),xr.current?.requestRefresh("focus",{force:!0,forceRedraw:!0,skipResizePush:!0,skipScrollToBottom:!0}),xr.current?.focus()},50))},[_e]);_.useEffect(()=>()=>{pn.current!==null&&typeof window<"u"&&window.clearTimeout(pn.current),pn.current=null,Xn.current!==null&&typeof window<"u"&&window.clearTimeout(Xn.current),Xn.current=null,ar.current!==null&&typeof window<"u"&&window.clearTimeout(ar.current),ar.current=null,qt.current!==null&&typeof window<"u"&&window.clearTimeout(qt.current),qt.current=null,xt.current!==null&&typeof window<"u"&&window.clearTimeout(xt.current),xt.current=null,ze.current!==null&&typeof window<"u"&&window.clearTimeout(ze.current),ze.current=null},[]),_.useEffect(()=>{if(typeof document>"u"||typeof window>"u")return;const ce=()=>{Xn.current!==null&&window.clearTimeout(Xn.current),Xn.current=window.setTimeout(()=>{Xn.current=null;const T=document.activeElement,Q=!(T?.getAttribute("data-terminal-input-anchor")==="true")&&!!(T&&(T instanceof HTMLInputElement||T instanceof HTMLTextAreaElement||T instanceof HTMLSelectElement||T.isContentEditable));kC({isActive:_t.current&&!Fr.current,isMobile:qr.current,documentVisible:!document.hidden,activeElementIsEditable:Q})&&ws()},0)};return document.addEventListener("pointerup",ce),()=>{document.removeEventListener("pointerup",ce),Xn.current!==null&&(window.clearTimeout(Xn.current),Xn.current=null)}},[ws]);const Es=_.useCallback(()=>{Ri.current=!1,kr(ce=>ce+1)},[]),po=_.useCallback((ce,T,j)=>{const Q=Lr.current,O=Date.now();if(Q&&T&&K8(Q)){re.current={startedAt:O,strategy:"reconnect",reason:ce},va("info","PWA_RESUME terminal-start",{frontendSessionId:Y,backendSessionId:Q,strategy:"reconnect",reason:ce,active:_t.current});return}if(Q&&X8(Q,()=>{const ge=re.current;va("info","PWA_RESUME terminal-responsive",{frontendSessionId:Y,backendSessionId:Q,durationMs:ge?Date.now()-ge.startedAt:null,strategy:ge?.strategy??"probe",reason:ge?.reason??ce}),re.current=null,W?.(Y)},{visible:j})){re.current={startedAt:O,strategy:"probe",reason:ce},va("info","PWA_RESUME terminal-start",{frontendSessionId:Y,backendSessionId:Q,strategy:"probe",reason:ce,active:_t.current}),ye("[Terminal] resume probe sent",{reason:ce,backendSessionId:Q,active:_t.current});return}if(ye("[Terminal] resume probe missing connection, restarting ensureSession",{reason:ce,backendSessionId:Q,active:_t.current}),!pE({initialConnectionPending:z.current})){ye("[Terminal] resume probe deferred during initial websocket handshake",{reason:ce,backendSessionId:Q});return}Es()},[ye,W,Es,Y]),Ws=_.useCallback((ce,T)=>{const j=Lr.current;j&&Hn.current!==ce&&(Hn.current=ce,Ug(j,ce,T),ye("[Terminal] flow-control state sent",{backendSessionId:j,paused:ce,reason:T}))},[ye]),Xs=_.useCallback((ce,T)=>{const j=Lr.current;j&&At.current!==ce&&(At.current=ce,zg(j,ce,T),ye("[Terminal] focus state sent",{backendSessionId:j,focused:ce,reason:T}))},[ye]),ms=_.useCallback((ce,T)=>{const j=Lr.current;j&&Rt.current!==ce&&(Rt.current=ce,Hg(j,ce,T),ye("[Terminal] viewing state sent",{backendSessionId:j,viewing:ce,reason:T}))},[ye]),mo=SC({isActive:l&&!Ee,viewportFocused:de,documentVisible:st,windowFocused:We,streamReady:H}),Ns=_C({isActive:l,documentVisible:st,windowFocused:We,streamReady:H,isDesktop:lo()!==null}),Oo=_.useRef(mo),aa=_.useRef(Ns);_.useEffect(()=>{Oo.current=mo,Xs(mo,"logical-focus-change")},[mo,Xs,Xr]),_.useEffect(()=>{aa.current=Ns,ms(Ns,"logical-viewing-change")},[Ns,ms,Xr]),YC(Xr,st,H),_.useEffect(()=>{const ce=T=>{const j=T.detail;!j||j.sessionId!==Y||lt(j.fontSize??n.fontSize)};return window.addEventListener("termfontchange",ce),()=>window.removeEventListener("termfontchange",ce)},[Y,n.fontSize]),_.useEffect(()=>{const ce=()=>{const O=!document.hidden&&hu();Ie(O),O&&l&&Qa("visibility")},T=O=>{l&&Qa(O.persisted?"bfcache":"pageshow")},j=()=>{Te(!0),Qa("window-focus")},Q=()=>Te(!1);return document.addEventListener("visibilitychange",ce),window.addEventListener(Wg,ce),window.addEventListener("pageshow",T),window.addEventListener("focus",j),window.addEventListener("blur",Q),()=>{document.removeEventListener("visibilitychange",ce),window.removeEventListener(Wg,ce),window.removeEventListener("pageshow",T),window.removeEventListener("focus",j),window.removeEventListener("blur",Q)}},[l,Qa]),_.useEffect(()=>{if(!y||!R||!Pa.current)return;const ce=v,T=ce<=0,j=je.current;if(j?.token===y&&(j.visible||!T))return;const Q=()=>{je.current={token:y,visible:T},xr.current?.requestRefresh(w,{skipScrollToBottom:!0}),po(ce>0?"global-resume-background":"global-resume-visible",ce<=0&&k,T)};if(ce<=0){Q();return}const O=window.setTimeout(Q,ce);return()=>window.clearTimeout(O)},[y,w,R,v,k,po]);const go=_.useRef(0);_.useEffect(()=>{if(H){go.current=0;return}if(!Br||Et==="Authentication required"||Et===Ph)return;const ce=go.current,T=Math.min(2e3*Math.pow(2,Math.min(ce,4)),3e4),j=setTimeout(()=>{go.current+=1,ye("[Terminal] fatal self-heal: auto restarting ensureSession",{attempt:go.current,backendSessionId:Lr.current}),kt("Reconnecting..."),cr(!1),Es()},T);return()=>clearTimeout(j)},[Et,Br,H,ln,ye,Es]),_.useEffect(()=>{if(typeof window>"u"){He(!1);return}const ce=/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1;He(ce)},[]),_.useEffect(()=>{(!l||!Be)&&mt(!1),l||Ye(!1)},[l,Be]),_.useEffect(()=>{Lr.current=Xr,Ke.current=-1,Zt.current=null,At.current=null,Rt.current=null,Hn.current=null},[Xr]),_.useEffect(()=>{B?.(Y,H)},[H,B,Y]),_.useEffect(()=>{U?.(Y,H&&Ze&&Tt)},[Ze,Tt,H,U,Y]),_.useEffect(()=>{Or||(ps.current=!1,G.current=null,Le.current&&(clearTimeout(Le.current),Le.current=null))},[Or]),_.useEffect(()=>{Xr&&xr.current?.requestRefresh("session-key-change",{force:!0})},[Xr]),_.useEffect(()=>{const ce=l&&Be&&Xt;_e("visibility signal",{sessionId:Y,isActive:l,isMobile:Be,isInputFocused:rt,isViewportKeyboardOpen:Xt,viewportKeyboardHeight:Ut,visible:ce}),V?.(Y,ce)},[V,Y,l,Be,Xt,Ut,_e]),_.useEffect(()=>{l&&x&&x!==qe.current&&(qe.current=x,ws())},[x,ws,l]),_.useEffect(()=>{Nr.current=Y},[Y]),_.useEffect(()=>{!Be&&(Lt!==null||Ge!==null)&&(pe(null),ft(null),ct.current=null)},[Be,Lt,Ge]),_.useEffect(()=>{!Xr&&(Lt!==null||Ge!==null)&&(pe(null),ft(null),ct.current=null)},[Xr,Lt,Ge]),_.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(Lx,q?"true":"false")},[q]),_.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(Ix,Vt)},[Vt]),_.useEffect(()=>{typeof window>"u"||window.localStorage.setItem(Ex,De)},[De]),_.useEffect(()=>{Ne(Hp());const ce=()=>{Ne(Hp())};return window.addEventListener("resize",ce),()=>window.removeEventListener("resize",ce)},[]);const On=_.useCallback(()=>{Dt.current+=1,ot.current+=1,Ln(),fo();const ce=dn.current;dn.current=null,Kn.current=null,z.current=!1,be.current=!1,ae(!1),xr.current?.setSessionReady(!1);const T=Lr.current;T&&Ug(T,!1,"stream-disconnect"),os.current=!1,Hn.current=null,Nn.current=[],ce?.()},[fo,Ln]),Ni=_.useCallback(async ce=>{if(Kn.current===ce){ye(`[startStream] Skipping - already connected to ${ce}`);return}ye(`[startStream] Starting stream for frontendSessionId=${Y} backendSessionId=${ce}`),sn(null),N.current+=1,Ot.current=!1,hr.current=null,Je(!1),Wt(!1),On();const T=Dt.current+1;Dt.current=T,z.current=!0;const j=Yr.getState().getTerminalSession(Y);if(j?.mode==="shell"&&!j.bufferChunks.length){const O=await Promise.race([J8(ce),new Promise(ge=>window.setTimeout(()=>ge(null),75))]);if(Dt.current!==T||Nr.current!==Y)return;if(O&&!Yr.getState().getTerminalSession(Y)?.bufferChunks.length){Yr.getState().replaceBuffer(Y,[O.data]);const ge=xr.current?.getDimensions();ge?.cols===O.cols&&ge.rows===O.rows&&ew(ce,O.seq,O.epoch)}}const Q=Ce.connect(ce,{onEvent:O=>{if(Dt.current!==T)return;const ge=Y;if(ge)switch(O.type){case"connected":{ot.current+=1,z.current=!1;const ve=re.current;ve&&(va("info","PWA_RESUME terminal-connected",{frontendSessionId:ge,backendSessionId:Lr.current,durationMs:Date.now()-ve.startedAt,strategy:ve.strategy,reason:ve.reason}),re.current=null),W?.(ge),(O.runtime||O.ptyBackend)&&ye(`[Terminal] connected frontendSessionId=${ge} backendSessionId=${Lr.current} runtime=${O.runtime??"unknown"} pty=${O.ptyBackend??"unknown"} cwd=${O.cwd??"unknown"}`),gr(ge,!1),kt(null),cr(!1),sn(null),be.current=!0,ae(!0),Lr.current&&(zg(Lr.current,Oo.current,"stream-connected"),Hg(Lr.current,aa.current,"stream-connected")),xr.current?.setSessionReady(!0),Hn.current=null,Ws(os.current,"stream-connected"),O.tuiProgress!==void 0&&Yr.getState().setSessionTuiProgress(ge,O.tuiProgress??null),O.shellTitle!==void 0&&Yr.getState().setSessionShellTitle(ge,O.shellTitle??null),O.promptState!==void 0&&O.promptState!==null&&Yr.getState().setSessionPromptState(ge,O.promptState);const Oe=Yr.getState().getTerminalSession(ge);if(Oe?.terminalSessionId&&O.mode&&Yr.getState().setTerminalSession(ge,{sessionId:Oe.terminalSessionId,cols:80,rows:24,mode:O.mode,tmuxSessionName:O.tmuxSessionName??null,cwd:O.cwd??null}),O.activeProgram!==void 0&&Sn(ge,O.activeProgram??null,O.activeProgramSource??null,O.activeProgramRaw??null),xr.current?.requestRefresh("connected",{force:!0,reconcileServerSize:_t.current}),O.mode!=="tmux"&&(Gn(null),mn(ge,!1)),ye("[Terminal] Connected event received:",{frontendSessionId:ge,backendSessionId:Lr.current,storeHasState:!!Oe,storeTerminalId:Oe?.terminalSessionId,hasHistoryInStore:!!Oe?.history?.length,historyLength:Oe?.history?.length??0}),Oe?.history&&Oe.history.length>0){ye(`[Terminal] Restoring ${Oe.history.length} history chunks to frontend session ${ge}`);const Jt=Oe.history.reduce((Ur,Jr)=>Ur+Jr.length,0),fr=Math.max(300,Math.min(2e3,Math.ceil(Jt/200)));Rn.current=Date.now()+fr,Oe.history.forEach(Ur=>{Hr(ge,Ur,{markActivity:!1})}),Yr.getState().setSessionHistory(ge,[]),ye(`[Terminal] History restoration complete for ${ge}`)}else ye(`[Terminal] No history to restore for ${ge}`);const Xe=O.replayChunks,pt=!!Oe?.history?.length||!!Xe?.length;if(pt?Ot.current=!0:an(),Xe&&Xe.length>0){let Jt=null;if(O.replayOutOfWindow)ye(`[Terminal] Replay out-of-window, atomically replacing buffer (${Xe.length} chunks)`),Jt=En(ge,nS(Xe));else{ye(`[Terminal] Replay incremental: ${Xe.length} chunks`);for(const Jr of Xe)Hr(ge,Jr)}const fr=Xe.reduce((Jr,Fn)=>Jr+Fn.length,0),Ur=Math.max(200,Math.min(1500,Math.ceil(fr/200)));Rn.current=Math.max(Rn.current,Date.now()+Ur),hr.current=Jt}pt&&hr.current===null&&(hr.current=Yr.getState().flushPendingBufferWrites(ge),hr.current===null&&(Ot.current=!1,an()));break}case"reconnecting":{be.current=!1,ae(!1),sn(ve=>ve??Date.now()),kt("Reconnecting..."),cr(!1);break}case"data":{O.data&&(os.current?Nn.current.push(O.data):Hr(ge,O.data));break}case"tmux-layout":{Gn(O.layout??null),O.layout&&mn(ge,O.layout.inCopyMode);break}case"tmux-screen-sync":{const ve=O.generation??0;if(ve<Ke.current)break;Ke.current=ve,N.current+=1,Ot.current=!0,Je(!1),Nn.current=[],xr.current?.prepareScreenReplacement(),Zt.current=ve,hr.current=En(ge,sS(O.chunks??[])),hr.current===null&&(Zt.current=null,xr.current?.notifyScreenSynchronized(ve),Ot.current=!1,an()),typeof O.cols=="number"&&typeof O.rows=="number"&&xr.current?.notifyServerSize(O.cols,O.rows,"tmux-screen-sync");break}case"active-program":{Sn(ge,O.activeProgram??null,O.activeProgramSource??null,O.activeProgramRaw??null);break}case"cwd":{ir(ge,O.cwd??null);break}case"agent-status":{Qr(ge,{agentStatus:O.agentStatus??null,agentIndicator:O.agentIndicator??null,agentStatusDetail:O.agentStatusDetail??null,agent:O.agent??null,agentMessage:O.agentMessage??null,agentNativeSessionId:O.agentNativeSessionId??null,agentResumeRecovered:O.agentResumeRecovered===!0,agentRich:O.agentRich===!0,agentActivity:O.agentActivity??0,agentCwd:O.agentCwd??null,reviewed:O.reviewed??null});break}case"git-status":{Yr.getState().setSessionGitStatus(ge,O.gitStatus??null);break}case"focus-mode":{ye("[Terminal] focus tracking mode",{backendSessionId:Lr.current,requested:O.focusTrackingRequested===!0});break}case"resize-ack":{xr.current?.acknowledgeResize({seq:O.seq,ok:O.ok!==!1,cols:O.cols,rows:O.rows,screenSyncPending:O.screenSyncPending,screenSyncGeneration:O.screenSyncGeneration});break}case"pty-size":{typeof O.cols=="number"&&typeof O.rows=="number"&&xr.current?.notifyServerSize(O.cols,O.rows,O.source);break}case"shell-title":{ia(ge,O.title??null);break}case"prompt-state":{Wr(ge,O.state??"idle",O.exitCode??null);break}case"tui-progress":{Yr.getState().setSessionTuiProgress(ge,O.tuiProgress??null);break}case"exit":{const ve=typeof O.exitCode=="number"?O.exitCode:null,Oe=typeof O.signal=="number"?O.signal:null;Hr(ge,`\r
69
69
  [Process exited${ve!==null?` with code ${ve}`:""}${Oe!==null?` (signal ${Oe})`:""}]\r
70
- `),dr(ge),gr(ge,!1),kt("Terminal session ended"),ae(!1),cr(!1),sn(null),Gn(null),mn(ge,!1),On();break}}},onError:(O,ge)=>{if(Dt.current!==T)return;const ve=Y;if(!ve)return;z.current=!1,be.current=!1,ae(!1);const Oe=ge&&O.message==="Authentication required",Xe=Sx(O),pt=Oe?O.message:Xe||ge?"Reconnecting...":O.message||"Terminal stream connection error";console.error(`[Terminal] Stream error (fatal=${ge}):`,pt),Xe&&console.warn("[Terminal] SESSION_NOT_FOUND_DETECTED",{terminalIdAtError:Lr.current,frontendSessionId:ve,isActive:l,isMobile:Be,fatal:ge,stack:new Error().stack}),kt(pt),cr(!!ge),ge&&(sn(null),gr(ve,!1),On(),Xe&&(ye("[onError] Session lost, auto-recreating"),kt("Reconnecting..."),cr(!1),dr(ve),hn(ve),Lr.current=null,Ri.current=!1,Es()))}},{...ME,getDimensions:()=>xr.current?.getDimensions()??null});dn.current=()=>{Q.close(),Dt.current===T&&(Kn.current=null)},Kn.current=ce},[Hr,hn,dr,ye,On,an,W,Ws,Es,ia,gr,Sn,Qr,mn,ir,Wr,Ce,Y]);_.useEffect(()=>{const ce=vE({isActive:l,isStreamReady:H,reconnectStartedAt:Zn,now:Date.now()});if(ce===null)return;const T=window.setTimeout(()=>{ye("[Terminal] visible reconnect watchdog expired",{backendSessionId:Lr.current,reconnectStartedAt:Zn}),On(),gr(Y,!1),kt("Reconnecting..."),cr(!1),sn(Date.now()),Es()},ce);return()=>window.clearTimeout(T)},[ye,On,l,H,Zn,Es,Y,gr]);const Ri=_.useRef(!1),Pa=_.useRef(!1),mi=_.useRef(0);_.useEffect(()=>()=>{mi.current+=1,Ri.current=!1,On()},[On]);const dl=_.useRef(K),Js=_.useRef(Ue);_.useEffect(()=>{const ce=dl.current,T=Js.current;dl.current=K,Js.current=Ue,Nr.current===Y&&(ce===K&&T===Ue||(Ri.current=!1,On(),kr(j=>j+1)))},[K,Ue,On,Y]),_.useEffect(()=>{if(Nr.current!==Y&&(ye(`[useEffect] sessionId changed from ${Nr.current} to ${Y}, allowing reinitialization`),Ri.current=!1,Pa.current=!1),Ri.current&&Nr.current===Y){ye(`[useEffect] Already initialized for sessionId=${Y}, skipping`);return}if(!Mt)return;const ce=async ge=>{if(ye(`[ensureSession] Starting for sessionId=${Y}, runId=${ge}`),!Nr.current||Nr.current!==Y){ye(`[ensureSession] SessionId mismatch or stale run (current=${Nr.current}, target=${Y}), skipping`);return}if(ge!==mi.current){ye(`[ensureSession] Stale run detected (runId=${ge}, currentRunId=${mi.current}), skipping`);return}const ve=Yr.getState(),Oe=ve.getTerminalSession(Y),Xe=Oe?.mode??K;ye("[ensureSession] Current state from store:",{terminalSessionId:Oe?.terminalSessionId,mode:Oe?.mode,tmuxSessionName:Oe?.tmuxSessionName,isConnecting:Oe?.isConnecting});let pt=Oe?.terminalSessionId??null,Jt=!pt;if(pt&&Xe!==K?(ye(`[ensureSession] Store mode mismatch for ${pt}: current=${Xe} desired=${K}, will create new session`),Jt=!0,ve.clearTerminalSession(Y),pt=null):pt&&K==="tmux"&&Ue&&Oe?.tmuxSessionName!==Ue&&(ye(`[ensureSession] Store tmux name mismatch for ${pt}: current=${Oe?.tmuxSessionName} desired=${Ue}, will create new session`),Jt=!0,ve.clearTerminalSession(Y),pt=null),pt&&Ce.checkHealth&&!_t.current){ye(`[ensureSession] Checking health of existing session ${pt}`);try{const fr=await Ce.checkHealth(pt);if(ye("[ensureSession] Health check result:",fr),!fr.healthy)ye(`[ensureSession] Session ${pt} is NOT healthy (healthy=${fr.healthy}), will create new session`),ye("[ensureSession] Health check details:",fr),Jt=!0,fr.mode&&Oe?.terminalSessionId&&ve.setTerminalSession(Y,{sessionId:Oe.terminalSessionId,cols:80,rows:24,mode:fr.mode,tmuxSessionName:fr.tmuxSessionName??null}),ve.clearTerminalSession(Y),ye("[ensureSession] Cleared unhealthy session from store");else{ye(`[ensureSession] Session ${pt} is healthy, reusing it, cwd=${fr.cwd}, clients=${fr.clients}, lastActivity=${Date.now()-(fr.lastActivity||0)}ms ago`),fr.mode&&Oe?.terminalSessionId&&ve.setTerminalSession(Y,{sessionId:Oe.terminalSessionId,cols:80,rows:24,mode:fr.mode,tmuxSessionName:fr.tmuxSessionName??null}),ye(`[ensureSession] Setting terminalIdRef to ${pt} and starting stream`),Lr.current=pt,Ni(pt),ye(`[ensureSession] Successfully reused healthy session ${pt}, returning early`);return}}catch(fr){ye(`[ensureSession] Failed to check health of session ${pt}:`,fr),ye("[ensureSession] Health check API call failed, proceeding as if session might be unhealthy")}}if(ye(`[ensureSession] Decision: shouldCreateNewSession=${Jt}, terminalId=${pt}`),Jt){ye(`[ensureSession] Creating new session, shouldCreateNewSession=${Jt}, runId=${ge}`),kt(null),cr(!1),ve.setConnecting(Y,!0);const Ur=Yr.getState().getTerminalSession(Y),Fn=(Ur?.mode??K)===K&&(K!=="tmux"||!Ue||Ur?.tmuxSessionName===Ue);if(Ur?.terminalSessionId&&Fn)ye(`[ensureSession] Race condition avoided: another instance already created session ${Ur.terminalSessionId}`),ve.setConnecting(Y,!1),pt=Ur.terminalSessionId,Jt=!1;else try{const mr=await Ba();if(ye(`[ensureSession] Opened managed backend session ${mr.sessionId}`),ge!==mi.current){ye(`[ensureSession] Stale run after session creation (runId=${ge}, currentRunId=${mi.current}), leaving ${mr.sessionId} for sibling`);return}ve.setTerminalSession(Y,mr),ye(`[ensureSession] Updated store with new session ${mr.sessionId}`),pt=mr.sessionId}catch(mr){if(ge!==mi.current){ye("[ensureSession] Stale run after session creation failed, skipping error handling");return}if(mr instanceof W0&&Km(mr)){ye("[ensureSession] Confirmed missing persisted session:",{sessionId:Y,error:mr.message}),ve.clearTerminalSession(Y),kt(Ph),cr(!0),ve.setConnecting(Y,!1);return}kt("Reconnecting..."),cr(!0),ve.setConnecting(Y,!1);return}}if(ge!==mi.current){ye(`[ensureSession] Stale run before starting stream (runId=${ge}, currentRunId=${mi.current}), skipping`);return}if(!pt){ye(`[ensureSession] No terminalId, terminalId=${pt}`);return}ye(`[ensureSession] Starting stream for session ${pt}`),Lr.current=pt,Ni(pt),ye(`[ensureSession] ensureSession completed for sessionId=${Y}, terminalId=${pt}`)};let T=null,j=null;const Q=()=>{j=null,!(Ri.current&&Nr.current===Y)&&(ye(`[useEffect] Running ensureSession for sessionId=${Y}, hasInitialized=${Ri.current}`),Ri.current=!0,Pa.current=!0,T=++mi.current,ce(T))};if(!E&&!Pa.current){ye(`[useEffect] Holding background connection until the selected session is ready: ${Y}`);return}const O=Pa.current?0:Math.max(0,L);return O>0?(ye(`[useEffect] Delaying initial connection for sessionId=${Y} by ${O}ms`),j=window.setTimeout(Q,O)):Q(),()=>{j!==null&&window.clearTimeout(j),ye(`[useEffect] Cleanup for sessionId=${Y}, runId=${T??"pending"}`)}},[Y,ln,Ni,On,Ce,ye,K,Ue,Dr,L,E,Mt]);const Fo=_.useCallback(async()=>{if(Y&&!_n){Ls(!0),kt(null),cr(!1),sn(null),On();try{Ce.forceKill&&await Ce.forceKill({sessionId:Y})}catch{}Tn(Y),hn(Y),xr.current?.clear(),await new Promise(ce=>setTimeout(ce,100));try{gr(Y,!0);const ce=await Ba();Cr(Y,ce),Lr.current=ce.sessionId,Ni(ce.sessionId)}catch(ce){kt(ce instanceof W0&&Km(ce)?Ph:"Reconnecting..."),cr(!0),gr(Y,!1)}finally{Ls(!1)}}},[Y,_n,On,Ce,Tn,hn,gr,Cr,Ni,Ba]),oa=_.useCallback((ce,T,j,Q)=>{if(!(Lr.current!==T||ot.current!==j)){if(ce instanceof W0&&Sx(ce)){ye("[Terminal] operation backend missing, recovering",{terminalId:T,sessionId:Y}),kt("Reconnecting..."),cr(!1),On(),dr(Y),Lr.current=null,gr(Y,!0),Es();return}kt(ce instanceof Error?ce.message:Q)}},[dr,ye,On,Es,Y,gr]),xo=_.useCallback((ce,T)=>{const j=T?.ownedPaste?VC(T.ownedPaste,Y,ce):!1;if(T?.ownedPaste&&!j||jt.current||(Fr.current||S1())&&!j)return Promise.resolve(!1);const Q=()=>!!T?.ownedPaste&&qC(T.ownedPaste,Y)&&_t.current&&!jt.current&&be.current&&!tr.current&&!document.hidden&&navigator.onLine!==!1&&hu();if(j&&!Q())return Promise.resolve(!1);if(!_t.current&&!T?.targeted||!ce)return;const O=$I(ce),ge=/^(\x1b\[<6[45];[0-9]+;[0-9]+M)+$/.test(ce);if(Or&&ge&&(ps.current=!0),Date.now()<Rn.current)return;let ve=ce,Oe=T?.consumeModifier??!1;if(!T?.skipModifierTransform&&Lt&&ce.length>0){const Ur=ce[0];if(Ur.length===1&&/[a-zA-Z]/.test(Ur)){const Jr=Ur.toUpperCase();Lt==="ctrl"?(ve=String.fromCharCode(Jr.charCodeAt(0)&31),Oe=!0):Lt==="alt"&&(ve=`\x1B${ce}`,Oe=!0)}Oe||(Lt==="alt"&&(ve=`\x1B${ce}`),Oe=!0)}const Xe=Lr.current;if(!Xe)return;const pt=ot.current,fr=(async()=>{try{if(Or&&!O&&ps.current&&Ce.tmuxAction){ps.current=!1;try{await Ce.tmuxAction(Xe,{action:"copy-mode",enabled:!1})}catch{}if(Lr.current!==Xe||ot.current!==pt)return!1;if(UI(ve))return!0}return j&&(!Q()||Lr.current!==Xe||ot.current!==pt)||(await Ce.sendInput(Xe,ve),j&&(!Q()||Lr.current!==Xe||ot.current!==pt))?!1:(fs(Y),!0)}catch(Ur){return oa(Ur,Xe,pt,"Failed to send input"),!1}})();return Oe&&(Ge||pe(null),ws()),fr},[Lt,fs,ws,oa,Or,Ge,Y,Ce]);_.useEffect(()=>{const ce=T=>{const j=T,Q=j.detail?.sessionId;if(Q?Q!==Y:!_t.current)return;const O=j.detail?.text;if(!O)return;const ge=j.detail?.nonce;if(tr.current||!xr.current){ge&&window.dispatchEvent(new CustomEvent("termdock-insert-reference-ack",{detail:{nonce:ge,ok:!1}}));return}const ve=GC(j.detail,Y),Oe=j.detail?.ownedPaste&&!ve?Promise.resolve(!1):xr.current.sendSequence(O,{paste:j.detail?.paste,submitAfterPaste:j.detail?.submitAfterPaste,targeted:!!Q,ownedPaste:ve??void 0});ge&&Promise.resolve(Oe).then(Xe=>{window.dispatchEvent(new CustomEvent("termdock-insert-reference-ack",{detail:{nonce:ge,ok:Xe===!0}}))},()=>{window.dispatchEvent(new CustomEvent("termdock-insert-reference-ack",{detail:{nonce:ge,ok:!1}}))}),LC(qr.current,j.detail?.focus!==!1)&&ws()};return window.addEventListener("termdock-insert-reference",ce),()=>window.removeEventListener("termdock-insert-reference",ce)},[ws,Y]);const Ta=_.useCallback((ce,T,j)=>{const Q=Lr.current;if(!Q){_e("xterm resize push skipped: no terminalId",{cols:ce,rows:T});return}_e("xterm resize push",{cols:ce,rows:T}),Ce.resize({sessionId:Q,cols:ce,rows:T,seq:j}).catch(O=>{xr.current?.acknowledgeResize({seq:j,ok:!1}),O&&/session not found/i.test(String(O.message||O))&&console.warn("[Terminal] resize 404 session not found",{sessionId:Q,cols:ce,rows:T,stack:new Error().stack})})},[Ce,_e]),ls=_.useCallback(async ce=>{const T=Lr.current;if(!T||!Ce.tmuxAction)return;const j=ot.current;try{const Q=await Ce.tmuxAction(T,ce);if(Lr.current!==T||ot.current!==j)return;Q.layout&&(Gn(Q.layout),ce.action==="switch-session"&&(Cr(Y,{sessionId:T,cols:80,rows:24,mode:"tmux",tmuxSessionName:Q.layout.sessionName}),tw(Y,{tmuxSessionName:Q.layout.sessionName}).catch(O=>{console.warn("[Terminal] failed to update inventory after tmux switch",O)})))}catch(Q){oa(Q,T,j,"Failed to execute tmux action")}},[oa,Y,Cr,Ce]);_.useEffect(()=>{if(!$r||!Xr)return;const T=$r.windows.find(j=>j.id===$r.activeWindowId)?.panes.find(j=>j.id===$r.activePaneId);T&&xr.current?.requestRefresh("tmux-layout",{skipScrollToBottom:!0,dedupeKey:`${Xr}:${$r.sessionId}:${T.id}:${T.width}x${T.height}`})},[$r,Xr]);const gi=_.useCallback((ce,T=5)=>{const j=Math.max(1,Math.min(Math.floor(T)||1,40));ps.current=!0;const Q=G.current;if(Q&&Q.direction===ce){Q.lines+=j;return}Q&&ls({action:"scroll",direction:Q.direction,lines:Q.lines}).finally(()=>{ws()}),G.current={direction:ce,lines:j},Le.current&&clearTimeout(Le.current),Le.current=setTimeout(()=>{const O=G.current;O&&(G.current=null,ls({action:"scroll",direction:O.direction,lines:O.lines}).finally(()=>{ws()}))},0)},[ws,ls]),bo=_.useCallback(ce=>{const T=Date.now(),j=ct.current,Q=j!==null&&j.modifier===ce&&T-j.timestamp<=IE;if(ct.current={modifier:ce,timestamp:T},Ge===ce){ft(null),pe(null);return}if(Q){ft(ce),pe(ce);return}Ge!==null&&Ge!==ce&&ft(null),pe(O=>O===ce?null:ce)},[Ge]),hl=_.useCallback(ce=>{if(Ye(ce&&_t.current),_e("input focus changed",{focused:ce,isActive:_t.current,isMobile:qr.current}),!qr.current||!_t.current){mt(!1);return}mt(T=>T===ce?T:ce)},[_e]),$o=_.useCallback(ce=>{if(os.current=ce,Ws(ce,"viewport-watermark"),!ce&&Nn.current.length>0){const T=Y;if(T){const j=Nn.current;Nn.current=[];for(const Q of j)Hr(T,Q)}}},[Hr,Ws,Y]),gs=_.useCallback(ce=>{_t.current&&xr.current?.ensureSizeMatches(ce)},[]),la=_.useRef(null);_.useEffect(()=>{if(!l)return;const ce=la.current;if(!ce)return;const T=()=>gs("pointerdown"),j=()=>gs("keydown"),Q=()=>gs("touchstart"),O=()=>gs("wheel");return ce.addEventListener("pointerdown",T),ce.addEventListener("keydown",j),ce.addEventListener("touchstart",Q,{passive:!0}),ce.addEventListener("wheel",O,{passive:!0}),()=>{ce.removeEventListener("pointerdown",T),ce.removeEventListener("keydown",j),ce.removeEventListener("touchstart",Q),ce.removeEventListener("wheel",O)}},[l,gs]);const Nl=_.useCallback(ce=>{xr.current=ce},[]),Jn=_.useCallback(ce=>{vt(ce),F?.(Y,ce)},[F,Y]),xi=_.useCallback(ce=>{const T=ZI(ce);if(!T)return;const j=Lt!==null;xr.current?.sendSequence(T,{consumeModifier:j})},[Lt]),ss=_.useCallback(ce=>{const T=WI(ce);if(T.length===0)return;const j=Lt!==null;xr.current?.sendSequence(wx(T[0]),{consumeModifier:j});for(let Q=1;Q<T.length;Q+=1){const O=T[Q];window.setTimeout(()=>{xr.current?.sendSequence(wx(O))},HI*Q)}},[Lt]),Oa=_.useCallback(()=>{xr.current?.pasteClipboardText()},[]),ys=_.useCallback(ce=>{qt.current!==null&&(window.clearTimeout(qt.current),qt.current=null),gt(ce),(ce==="inserted"||ce==="failed")&&(qt.current=window.setTimeout(()=>{qt.current=null,gt("idle")},1400))},[]),Uo=_.useCallback(()=>{ys("idle"),It(0),cn.current?.click()},[ys]),Gs=_.useCallback(()=>{rn(!0)},[]),Ui=_.useCallback(ce=>{const T=ce.currentTarget.files?.[0];if(ce.currentTarget.value="",!T)return;const j=Y;_r(null),pr(null),Ir(null),It(0),ys("uploading");const Q=sr&&T.type.startsWith("video/")?{maxHeight:An,videoBitrate:on,onProgress:It}:null,O=Me&&NE(T)?{maxDimension:nt,quality:wt}:null;let ge=Q?"视频压缩":O?"图片压缩":"文件上传";(async()=>{const ve=Q?await(await kc(async()=>{const{compressVideoLocally:Oe}=await import("./videoCompression-DCnzjEfU.js");return{compressVideoLocally:Oe}},__vite__mapDeps([0,1,2,3,4,5]))).compressVideoLocally(T,Q):O?await(await kc(async()=>{const{compressImageLocally:Oe}=await import("./imageCompression-DaUBNTq-.js");return{compressImageLocally:Oe}},[])).compressImageLocally(T,O):T;ge="文件上传",await _E(ve,(Oe,Xe)=>vd(Oe,Xe,void 0,It),Oe=>(ge="插入终端",kx(Xm(Oe,null),j,()=>_t.current&&!tr.current&&Nr.current===j&&Yr.getState().activeSessionId===j))),(Q||O)&&Ir({file:ve,kind:Q?"video":"image",originalSize:T.size,uploadedSize:ve.size,originalRetained:ve===T})})().then(()=>ys("inserted"),ve=>{ve instanceof lf&&_r({path:ve.uploaded.path,sessionId:j});const Oe=ve instanceof lf?ve.uploaded.path:Nx(ve);pr({stage:ge,detail:Oe}),rn(!0),ys("failed"),va("warn","MOBILE_MEDIA_UPLOAD failed",{stage:ge,detail:Oe})})},[on,sr,An,Me,nt,wt,Y,ys]),ca=_.useCallback(async()=>{const ce=nr;if(!ce||ce.sessionId!==Y)return;rn(!1),await new Promise(j=>window.requestAnimationFrame(()=>j())),ys("uploading"),await kx(Xm(ce.path,null),ce.sessionId,()=>_t.current&&!tr.current&&Nr.current===ce.sessionId&&Yr.getState().activeSessionId===ce.sessionId)?(_r(null),pr(null),ys("inserted")):(rn(!0),ys("failed"))},[nr,Y,ys]);_.useEffect(()=>{if(!Mr||!sr)return;let ce=!0;return zt(null),ne({phase:"checking-cache"}),kc(async()=>{const{prepareLocalVideoCompression:T}=await import("./videoCompression-DCnzjEfU.js");return{prepareLocalVideoCompression:T}},__vite__mapDeps([0,1,2,3,4,5])).then(({prepareLocalVideoCompression:T})=>{if(ce)return T(j=>{ce&&ne(j)})}).catch(T=>{ce&&zt(Nx(T))}),()=>{ce=!1}},[Mr,sr]);const jn=Pr||Et!==null;tr.current=jn;const bi=_.useRef(Kr);jn||(bi.current=Kr);const Mi=jn?bi.current:Kr,Ca=_.useMemo(()=>GI(Mi,nn),[Mi,nn]),zi=_.useMemo(()=>Tx(nn,Vt),[Vt,nn]),yi=!Be&&Vt!=="auto"&&zi.id!=="default"&&zi.showOnDesktop!==!0?"auto":Vt,ei=yi==="auto"?Ca:yi,Rs=_.useMemo(()=>Tx(nn,ei),[ei,nn]),js=_.useMemo(()=>Rs.actions.filter(ce=>ce.sequence.trim().length>0).map((ce,T)=>({...ce,label:Zm(ce,T)})),[Rs.actions]),ti=_.useMemo(()=>Ly(Kr),[Kr]),Fa=Rs.label,ji=_.useMemo(()=>yi!=="auto"?`Manual preset: ${Rs.label}`:ti?`Auto preset · ${Rs.label} (${ti})`:"Auto preset",[ti,yi,Rs.label]),es=_.useCallback(ce=>{Ve(ce)},[]),ua=_.useCallback(()=>{er(ce=>ce==="copy"?"arrows":"copy"),Ct("idle")},[]),yo=_.useCallback(()=>{typeof window>"u"||(ar.current!==null&&window.clearTimeout(ar.current),ar.current=window.setTimeout(()=>{ar.current=null,Ct("idle")},1200))},[]),Sa=_.useCallback(ce=>{ar.current!==null&&typeof window<"u"&&(window.clearTimeout(ar.current),ar.current=null),Ct(ce?"copied":"failed"),yo()},[yo]),zo=_.useCallback(ce=>{at(ce)},[]),Ho=_.useMemo(()=>Be?VI(nn):qI(nn),[Be,nn]),Hi=_.useMemo(()=>rw(a),[a]);_.useEffect(()=>{if(!Or||!H||!Mt||!Xr)return;const ce=iS(Hi);ce&&Ce.sendInput(Xr,ce).catch(T=>{console.warn("[Terminal] Failed to synchronize tmux default colors:",T)})},[Or,H,Mt,Xr,Ce,Hi]);const vo=_.useMemo(()=>`terminal::${Y}`,[Y]);_.useEffect(()=>{ke?.({isConnecting:Pr,isRestarting:_n,hasError:!!Et,sessionId:Xr})},[Pr,_n,Et,Xr,ke]);const da=!Xr||Pr||_n,$a=_.useCallback((ce,T)=>{if(da)return;const j=Math.max(1,Math.min(Math.floor(T)||1,40));gi(ce,j)},[gi,da]);_.useEffect(()=>{if(!l||!Be)return;xr.current?.requestRefresh("resize",{skipScrollToBottom:!Xt,force:!0})},[l,Be,Xt,Ut,Y]),_.useEffect(()=>{if(!l||!Be)return;const ce=T=>{const j=T.detail;xr.current?.requestRefresh("resize",{skipScrollToBottom:j?.isOpen!==!0,force:!0})};return document.addEventListener("termdock:viewport-keyboard-change",ce),()=>{document.removeEventListener("termdock:viewport-keyboard-change",ce)}},[l,Be,Y]);const wo=!Z&&(Be||Rs.id==="default"||Rs.showOnDesktop===!0),ha=l,As=Be&&!xe?{transform:"translateY(var(--kb-translate-y, 0px))",transition:"none"}:void 0,Di=Be&&!xe?{marginTop:"var(--kb-margin-top, 0px)",transition:"none"}:void 0,xs=s.jsx(KI,{visible:wo,interactive:ha,presentation:Be?"mobile":"desktop-actions",activeModifier:Lt,lockedModifier:Ge,disabled:da,defaultShowExtended:q,presetLabel:Fa,presetModeLabel:ji,presetMode:yi,presetOptions:Ho,includeAlt:Rs.includeAlt,presetRowLayout:Rs.rowLayout,extraActions:js,onKeyPress:xi,onTextPress:ss,onPastePress:Be?Oa:void 0,onFilePress:Be?Uo:void 0,onFileLongPress:Be?Gs:void 0,fileUploadState:Nt,fileUploadProgress:bt,longPressMode:De,copyFeedback:et,onLongPressModeToggle:ua,onModifierToggle:bo,onPresetSelect:es,onExpandedChange:zo}),Rl=typeof window<"u"&&(navigator.maxTouchPoints>0||"ontouchstart"in window);return s.jsxs("div",{className:"relative flex h-full min-h-0 flex-col overflow-hidden",style:As,children:[s.jsx("input",{ref:cn,type:"file",className:"hidden",onChange:Ui}),Mr&&Li.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop cursor-default bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>rn(!1),"aria-label":$e("common.close")}),s.jsxs("section",{role:"dialog","aria-modal":"true","aria-labelledby":"mobile-video-compression-title",className:"fixed bottom-[max(0.75rem,env(safe-area-inset-bottom,0px))] left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] z-modal-panel max-h-[calc(100dvh-1.5rem)] overflow-y-auto rounded-2xl border border-border/15 bg-surface p-4 shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)] sm:left-1/2 sm:right-auto sm:w-[min(28rem,calc(100vw-2rem))] sm:-translate-x-1/2",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h2",{id:"mobile-video-compression-title",className:"text-sm font-semibold text-foreground",children:"本地媒体压缩"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"按文件类型选择压缩方式,处理完成后才上传。"})]}),s.jsx("button",{type:"button",className:"min-h-10 rounded-lg bg-surface-2 px-3 text-xs",onClick:()=>rn(!1),children:$e("common.close")})]}),yt&&s.jsxs("div",{role:"alert",className:"mt-3 rounded-lg bg-destructive/10 p-3 text-xs text-destructive",children:[s.jsxs("p",{children:[yt.stage,"失败。",yt.stage.endsWith("压缩")?"原文件未上传。":yt.stage==="插入终端"?"文件已上传,路径见详情。":""]}),s.jsxs("details",{className:"mt-2",children:[s.jsx("summary",{className:"cursor-pointer",children:"错误详情"}),s.jsx("p",{className:"mt-2 max-h-40 overflow-auto whitespace-pre-wrap break-words",children:yt.detail})]}),nr&&s.jsx("button",{type:"button",onClick:()=>{ca()},disabled:Nt==="uploading"||nr.sessionId!==Y,className:"mt-2 rounded-lg bg-surface-2 px-3 py-2 text-foreground disabled:opacity-50",children:$e("common.retry")})]}),dt&&s.jsx("p",{className:"mt-2 text-[11px] text-destructive",children:"本机未能保存设置,重新打开后可能恢复默认值。"}),s.jsxs("label",{className:"mt-4 flex min-h-11 items-center justify-between rounded-xl bg-surface-elevated px-3 text-sm",children:[s.jsx("span",{children:"显示压缩结果提示"}),s.jsx("input",{type:"checkbox",checked:Gr.showResultToast,onChange:ce=>it({showResultToast:ce.target.checked}),className:"h-4 w-4 accent-primary"})]}),s.jsxs("label",{className:"mt-4 flex min-h-11 items-center justify-between rounded-xl bg-surface-elevated px-3 text-sm",children:[s.jsx("span",{children:"压缩图片后上传"}),s.jsx("input",{type:"checkbox",checked:Me,onChange:ce=>it({imageEnabled:ce.target.checked}),className:"h-4 w-4 accent-primary"})]}),Me&&s.jsxs("div",{className:"mt-3 space-y-3",children:[s.jsxs("label",{className:"block text-xs text-muted-foreground",children:["图片最长边",s.jsx("select",{value:nt,onChange:ce=>it({imageMaxDimension:Number(ce.target.value)}),className:"mt-1 block min-h-10 w-full rounded-lg bg-surface-2 px-3 text-sm text-foreground",children:Dy.map(ce=>s.jsxs("option",{value:ce,children:[ce," px",ce===640?" · 最省流量":ce===2048?" · 推荐":ce===4096?" · 保留更多细节":""]},ce))})]}),s.jsxs("label",{className:"block text-xs text-muted-foreground",children:["图片画质:",Math.round(wt*100),"%",s.jsx("input",{type:"range",min:K0.min,max:K0.max,step:K0.step,value:wt,onChange:ce=>it({imageQuality:Number(ce.target.value)}),className:"mt-2 h-1 w-full accent-primary"})]}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:"支持 JPEG、PNG、HEIC 照片;GIF、SVG 等保持原文件。压缩后未变小也会保留原图。"})]}),s.jsx("div",{className:"mt-4 border-t border-border/15 pt-1"}),s.jsxs("label",{className:"mt-4 flex min-h-11 items-center justify-between rounded-xl bg-surface-elevated px-3 text-sm",children:[s.jsx("span",{children:"压缩视频后上传"}),s.jsx("input",{type:"checkbox",checked:sr,onChange:ce=>it({videoEnabled:ce.target.checked}),className:"h-4 w-4 accent-primary"})]}),sr&&s.jsxs("div",{className:"mt-4 space-y-4",children:[s.jsxs("label",{className:"block text-xs text-muted-foreground",children:["视频最长边(像素)",s.jsx("select",{value:An,onChange:ce=>it({videoMaxHeight:Number(ce.target.value)}),className:"mt-1 block min-h-10 w-full rounded-lg bg-surface-2 px-3 text-sm text-foreground",children:By.map(ce=>s.jsxs("option",{value:ce,children:[ce," px",ce===240?" · 最省流量":ce===720?" · 推荐":ce>=1440?" · 手机处理较慢":""]},ce))})]}),s.jsxs("label",{className:"block text-xs text-muted-foreground",children:["目标视频码率:",on/1e6," Mbps",s.jsx("input",{type:"range",min:X0.min,max:X0.max,step:X0.step,value:on,onChange:ce=>it({videoBitrate:Number(ce.target.value)}),className:"mt-2 h-1 w-full accent-primary"})]}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:"保持比例,不放大原视频。尺寸越小通常处理越快;码率越低体积通常越小,过高可能比原片更大。"}),s.jsx("p",{className:"text-[11px] text-muted-foreground",role:"status","aria-live":"polite",children:ht?"本地转码器准备失败,请关闭开关后重试。":RE(Er)}),Er?.saved===!1&&s.jsx("p",{className:"text-[11px] text-destructive",children:"本机未能保存转码器,重新打开后可能需要重新下载。"}),ht&&s.jsx("p",{className:"text-[11px] text-destructive",children:ht})]})]})]}),document.body),Vn&&s.jsx(XI,{isMobile:Be,isInputFocused:rt,isIOS:oe,isConnecting:Pr,connectionError:Et,terminalSessionId:Xr}),s.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden",style:{backgroundColor:Hi.background,...Di},children:[s.jsx("div",{ref:la,className:"h-full w-full box-border",children:s.jsx(nw,{fallback:s.jsx("div",{className:"flex h-full items-center justify-center bg-background",children:s.jsxs("div",{className:"flex flex-col items-center gap-3 text-center rounded-2xl bg-surface-2 px-6 py-5 shadow-sm",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-destructive/15 flex items-center justify-center",children:s.jsx("svg",{className:"w-5 h-5 text-destructive",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),s.jsx("span",{className:"text-sm text-muted-foreground",children:$e("terminal.componentFailed")})]})}),children:s.jsx(jI,{ref:Nl,sessionKey:vo,sessionId:Y,isLayoutVisible:m,chunks:ks,onInput:xo,onResize:Ta,onFlowControl:$o,onTmuxScroll:Or?$a:void 0,tmuxScrollSensitivity:.38,onDoubleTap:Be?()=>{xr.current?.sendSequence(" ")}:void 0,onInputFocusChange:hl,onMobileLongPressCopyResult:Sa,onReadyChange:Jn,onSizeSynchronizedChange:Wt,onWritesSettled:Hs,onWriteProgress:Po,onCursorPositionChange:Aa,onDirectoryLinkActivate:fn,terminalSettings:Pe,theme:Hi,enableTouchScroll:Be,mobileLongPressMode:De,autoFocus:!Ee&&!Be&&!Rl,cursorVisible:!Ee&&Yt,suppressSmoothScroll:!Ze||!Tt,className:Ee||!Yt?"terminal-focus-suspended":void 0},vo)})}),s.jsx(LE,{result:un,onDismiss:me}),s.jsx(eE,{connectionError:Et,isFatalError:Br,isRestarting:_n,isConnecting:Pr,onHardRestart:Fo})]}),le?Z?null:Li.createPortal(xs,le):xs]})};function DE({session:e,active:t,onActivate:r,onToggleRightSidebar:n}){const{t:a}=zr(),c=Yr(l=>{const h=l.sessions.get(e.id);return sl(e,h?.activeProgram??null,h?.cwd??null,void 0,h?.shellTitle??null,h?.promptState??null).primary});return s.jsxs("div",{"data-pane-titlebar":"true",className:"swiper-no-swiping flex h-6 min-h-6 shrink-0 items-center border-b border-border app-chrome-bg",children:[s.jsxs("button",{type:"button","data-split-pane-title":e.id,draggable:!1,onDragStart:l=>l.preventDefault(),"aria-pressed":t,title:`${c} · 拖动标题移动,边缘拆分,中央交换`,onClick:r,className:"split-pane-drag-handle flex h-full min-w-0 cursor-grab active:cursor-grabbing flex-1 items-center gap-1.5 overflow-hidden px-2 text-left text-[12px] font-medium leading-none text-foreground hover:bg-surface focus-visible:outline focus-visible:outline-1 focus-visible:outline-primary focus-visible:-outline-offset-1",children:[s.jsx(Bo,{size:11,className:`shrink-0 ${t?"text-primary":"text-muted-foreground"}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:c}),s.jsx(If,{size:12,"aria-hidden":"true",className:"shrink-0 text-muted-foreground"}),t&&s.jsx("span",{"aria-hidden":"true",className:"h-1 w-1 shrink-0 rounded-full bg-primary"})]}),n&&s.jsx("button",{type:"button",onClick:n,"aria-label":a("tab.explorerTitle"),title:a("tab.explorerTitle"),className:"inline-flex h-full w-7 shrink-0 items-center justify-center text-muted-foreground hover:bg-surface hover:text-foreground focus-visible:outline focus-visible:outline-1 focus-visible:outline-primary focus-visible:-outline-offset-1",children:s.jsx(T3,{size:14})})]})}const BE="termdock:startup:";function vu(e){if(typeof performance>"u"||typeof performance.mark!="function")return;const t=`${BE}${e}`;performance.getEntriesByName(t,"mark").length>0||performance.mark(t)}function Rx(e,t){e||Li.flushSync(t)}const Jm="horizontal";function Cu(e){return e<=0?[]:Array.from({length:e},()=>1/e)}function Oh(e,t){if(!Array.isArray(e)||e.length!==t)return Cu(t);const r=e.map(Number);if(r.some(a=>!Number.isFinite(a)||a<=0))return Cu(t);const n=r.reduce((a,c)=>a+c,0);return n<=0?Cu(t):r.map(a=>a/n)}function QE(e){const t=Math.max(1,Math.ceil(Math.sqrt(Math.max(1,e))));return{columns:t,rows:Math.max(1,Math.ceil(Math.max(1,e)/t))}}function PE(e){return e==="horizontal"||e==="vertical"||e==="grid"}function OE(e){if(!Array.isArray(e))return[];const t=new Set,r=new Set,n=[];for(const a of e){if(!a||typeof a!="object")continue;const c=a;if(typeof c.id!="string"||!c.id||r.has(c.id))continue;const l=Array.isArray(c.sessionIds)?c.sessionIds.filter(m=>typeof m=="string"&&!!m&&!t.has(m)):[],h=[...new Set(l)];if(h.length<2)continue;const p=QE(h.length);h.forEach(m=>t.add(m)),r.add(c.id),n.push({id:c.id,...typeof c.name=="string"&&c.name.trim()?{name:c.name.trim().slice(0,80)}:{},sessionIds:h,layout:PE(c.layout)?c.layout:Jm,ratios:Oh(c.ratios,h.length),...c.gridColumnRatios!==void 0?{gridColumnRatios:Oh(c.gridColumnRatios,p.columns)}:{},...c.gridRowRatios!==void 0?{gridRowRatios:Oh(c.gridRowRatios,p.rows)}:{}})}return n}function FE(e,t){const r=new Set(t);return e.flatMap(n=>{const a=n.sessionIds.filter(c=>r.has(c));return a.length<2?[]:[{...n,sessionIds:a,ratios:a.length===n.sessionIds.length?Oh(n.ratios,a.length):Cu(a.length)}]})}function dd(e,t){if(t)return e.find(r=>r.sessionIds.includes(t))}function Wp(e,t,r){if(!t||!r||t===r)return e;const n=dd(e,t),a=dd(e,r);if(n&&n.id===a?.id)return e;const c=[...n?.sessionIds??[t],...a?.sessionIds??[r]],l=[...new Set(c)],h={id:n?.id??`split:${t}`,...n?.name?{name:n.name}:{},sessionIds:l,layout:l.length>2&&(!n||n.layout===Jm)?"grid":n?.layout??Jm,ratios:Cu(l.length)},p=new Set([n?.id,a?.id].filter(Boolean)),m=e.filter(y=>!p.has(y.id)),x=n?Math.max(0,e.findIndex(y=>y.id===n.id)):m.length;return m.splice(Math.min(x,m.length),0,h),m}function $E(e,t){const r=dd(e,t);if(!r||!t)return e;if(r.sessionIds.length<=2)return e.filter(a=>a.id!==r.id);const n=r.sessionIds.filter(a=>a!==t);return e.map(a=>a.id===r.id?{...a,sessionIds:n,ratios:Cu(n.length)}:a)}function UE(e,t){const r=dd(e,t);return r?e.filter(n=>n.id!==r.id):e}function zE(e,t,r){return e.map(n=>{if(n.id!==t)return n;const a=[...new Set(r)],c=new Set(n.sessionIds);return a.length===n.sessionIds.length&&a.every(h=>c.has(h))?{...n,sessionIds:a}:n})}function HE(e,t,r){const n=r.trim().slice(0,80);return e.map(a=>a.id===t?{...a,...n?{name:n}:{name:void 0}}:a)}const e1=320,Py=1,WE=e1+120,t1="termdock:split-workspaces:v2",Oy="termdock:split-workspace:v1",GE=.1,VE=.9;function Gp(){if(typeof window>"u")return{mobile:!1,landscape:!1};const t=(navigator.maxTouchPoints>0||"ontouchstart"in window)&&Math.min(window.innerWidth,window.innerHeight)<768;return{mobile:t,landscape:t&&window.innerWidth>window.innerHeight}}function qE(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem(t1);if(e)return OE(JSON.parse(e));const t=JSON.parse(window.localStorage.getItem(Oy)||"null");if(t&&typeof t.primaryId=="string"&&typeof t.secondaryId=="string"&&t.primaryId!==t.secondaryId){const r=Math.min(VE,Math.max(GE,typeof t.ratio=="number"?t.ratio:.5));return[{id:`split:${t.primaryId}`,sessionIds:[t.primaryId,t.secondaryId],layout:t.direction==="vertical"?"vertical":"horizontal",ratios:[r,1-r]}]}}catch{}return[]}function YE(e,t){const r=new Map(e.map(l=>[l.id,l])),n=new Map;t.forEach(l=>l.sessionIds.forEach(h=>n.set(h,l)));const a=new Set,c=[];for(const l of e){const h=n.get(l.id);if(!h){c.push({key:l.id,sessions:[l]});continue}if(a.has(h.id))continue;a.add(h.id);const p=h.sessionIds.flatMap(m=>{const x=r.get(m);return x?[x]:[]});p.length>=2&&c.push({key:h.id,sessions:p,workspace:h})}return c}function Mx(e){const t=e.wrapperEl;if(t)try{t.getAnimations().forEach(r=>r.cancel())}catch{}}function dh(e,t){const r=cf(e,t);if(r===null)return;const n=e.wrapperEl;Mx(e),n&&(n.style.transitionDuration="0ms");try{const a=e;a.setTransition?.(0),a.setTranslate?.(r),Mx(e),n&&(n.style.transitionDuration="0ms",n.style.transform=`translate3d(${r}px, 0px, 0px)`)}catch{n&&(n.style.transitionDuration="0ms",n.style.transform=`translate3d(${r}px, 0px, 0px)`)}}function r1(e){try{const t=typeof e.getTranslate=="function"?e.getTranslate():e.translate;return typeof t=="number"&&Number.isFinite(t)?t:null}catch{return typeof e.translate=="number"&&Number.isFinite(e.translate)?e.translate:null}}function cf(e,t){const r=e.snapGrid,n=Array.isArray(r)?r[t]:void 0;return typeof n!="number"||!Number.isFinite(n)?null:-n}function ZE(e,t){const r=r1(e),n=cf(e,t);return r!==null&&n!==null&&Math.abs(r-n)<=Py}function KE(e){const t=[],r=new Map,n=new Map,a=new Map;for(const c of e){const l=r.get(c.id)??[];if(l.push(c.id),r.set(c.id,l),c.sessionId){const h=n.get(c.sessionId)??[];h.push(c.id),n.set(c.sessionId,h)}if(c.mode==="tmux"&&c.tmuxSessionName){const h=a.get(c.tmuxSessionName)??[];h.push(c.id),a.set(c.tmuxSessionName,h)}}for(const[c,l]of r)l.length>1&&t.push({kind:"frontend",key:c,sessionIds:l});for(const[c,l]of n)l.length>1&&t.push({kind:"backend",key:c,sessionIds:l});for(const[c,l]of a)l.length>1&&t.push({kind:"tmux",key:c,sessionIds:l});return t}function Fy(e){const t=new Map;for(const r of e)t.set(r.id,r);return Array.from(t.values())}function $y(e){return{id:e.sessionId,name:e.name,customName:e.customName===!0,sessionId:e.backendSessionId,mode:e.mode==="tmux"||e.mode==="shell"?e.mode:"shell",tmuxSessionName:e.tmuxSessionName??null}}function XE(e,t){const r=Fy(e),n=r.findIndex(a=>a.id===t.id);if(n>=0){const a=[...r];return a[n]=t,a}return[...r,t]}function jx(e,t){const r=new Map(e.map(n=>[n.id,n]));return t.map(n=>{const a=r.get(n.sessionId);return{...$y(n),history:a?.history}})}function Dx(e,t){return e.length===0?null:t&&e.some(r=>r.sessionId===t)?t:e[0]?.sessionId??null}function Bx(e){if(!e||typeof e!="object")return"unknown";const t=e;if(typeof t.pointerType=="string"&&t.pointerType)return t.pointerType;if(typeof t.type=="string"){if(t.type.startsWith("touch"))return"touch";if(t.type.startsWith("mouse"))return"mouse";if(t.type.startsWith("pointer"))return"pointer"}return"unknown"}function Qx(e){const t=new Map;for(const[r,n]of e)t.set(r,n.cwd??null);return t}function JE(e,t){if(e.size!==t.size)return!1;for(const[r,n]of t)if(e.get(r)!==n)return!1;return!0}function eN(e){const t="".toLowerCase().replace(/[^a-z0-9_-]/g,"").slice(0,12);if(t)return`wt-${t}`;const r=Date.now().toString(36),n=Math.random().toString(36).slice(2,8);return`wt-${r}${n}`}const tN=({terminalSettings:e=F1(),colorTheme:t="dark",toolbarPresets:r=[],showDebug:n,terminalFocusAvailable:a=!0,defaultSessionMode:c="shell",defaultTmuxSessionName:l="",connectionPrioritySessionId:h=null,connectionPriorityReady:p=!0,desktopRightSidebarEnabled:m=!1,onToggleRightSidebar:x,desktopFloatingTitle:y=!1,desktopPinnedLeftSidebarWidth:w=0,desktopViewportWidth:v=0,onStatusChange:k,onSessionDataUpdate:L,onInitialViewportReady:E,onInitialRecoveryRequired:R})=>{const{t:B}=zr(),W=b.useMemo(()=>_u("session"),[]),F=b.useMemo(()=>_u("terminal"),[]),[U,V]=b.useState([]),[Z,le]=b.useState(null),xe=b.useRef(0),fe=b.useRef(0),te=ns(z=>z.activePaneId);b.useEffect(()=>{ns.getState().setActivePane(Z)},[Z]);const[ke,$e]=b.useState(null),[Y,Ae]=b.useState(!0),[lt,Ce]=b.useState({token:0,reason:"visibility",forceForegroundReconnect:!1}),[ye,_e]=b.useState(()=>new Set),[je,re]=b.useState(()=>({token:0,completed:new Set})),[Pe,Se]=b.useState(0),[Ee,Be]=b.useState(()=>new Set),[Ne,oe]=b.useState(()=>new Set),He=b.useRef(new Map),[rt,mt]=b.useState(()=>new Set),de=b.useRef(!1),Ye=b.useRef(null),st=b.useRef({}),[Ie,We]=b.useState(null),[Te,H]=b.useState(()=>qE()),[ae,be]=b.useState(!1),Ze=b.useCallback(z=>{xe.current+=1,be(z)},[]),Je=b.useRef(null),Tt=b.useRef(ae);Tt.current=ae,wd(Je,ae&&!!Z,()=>Ze(!1));const[Wt,Mt]=b.useState(null),[vt,Yt]=b.useState(null),Qt=b.useRef(new Set),[Xt,Ut]=b.useState(null),[Lt,pe]=b.useState(null),[Ge,ft]=b.useState(!1),[q,at]=b.useState(()=>Gp().mobile),[Vt,Ve]=b.useState(()=>Gp().landscape),[De,er]=b.useState(null),[et,Ct]=b.useState(null),Nt=b.useRef(a),gt=b.useRef(!1),bt=b.useRef(!1),It=b.useRef(null),yt=b.useRef(null),pr=b.useRef(q),nr=b.useRef(null),_r=b.useCallback(z=>{z!==nr.current&&(xe.current+=1),nr.current=z,le(z)},[]);b.useEffect(()=>Gt.subscribe((z,N)=>{(z.rightOpen!==N.rightOpen||z.rightTab!==N.rightTab)&&(xe.current+=1)}),[]);const un=b.useRef(0),Ir=b.useRef([]),me=b.useRef(0),Gr=b.useRef(null),it=b.useRef(!1),dt=b.useRef(!0),sr=b.useRef(null),An=b.useRef(""),on=b.useRef(0);b.useEffect(()=>{if(typeof window>"u")return;const z=()=>{const N=Gp();pr.current=N.mobile,at(N.mobile),Ve(N.landscape)};return z(),window.addEventListener("resize",z),()=>window.removeEventListener("resize",z)},[]);const{sessions:Me,inventory:nt,activeSessionId:wt,isLoading:Mr,openSession:rn,setActiveSession:Er,removeSession:ne,renameSession:ht,resetSessionCustomName:zt,reorderSessions:Pt,restoreSessions:Cr}=sw(),gr=nt?.tmuxRecovery??null;b.useEffect(()=>{gr&&R?.()},[gr,R]),b.useEffect(()=>{pe(null),Ut(null)},[gr?.id]);const Hr=b.useCallback(async()=>{Ut("restore"),pe(null);try{const z=await iw();await Cr(),z.failed>0&&pe(B("tab.tmuxRecoveryPartial",{restored:z.restored,failed:z.failed}))}catch{pe(B("tab.tmuxRecoveryFailed"))}finally{Ut(null)}},[Cr,B]),En=b.useCallback(async()=>{Ut("dismiss"),pe(null);try{await aw(),await Cr()}catch{pe(B("tab.tmuxRecoveryDismissFailed"))}finally{Ut(null)}},[Cr,B]),dr=Gt(z=>z.groupByFolder),Tn=Xh(z=>z.collaborationGroups),hn=Gt(z=>z.leftOpen||z.rightOpen),Sn=Gt(z=>z.rightSidebarWidthContextKey),ir=Gt(z=>z.rightSidebarWidth),mn=Gt(z=>z.rightPinned),[Qr,Vr]=b.useState(()=>Qx(Yr.getState().sessions));b.useEffect(()=>Yr.subscribe(z=>{const N=Qx(z.sessions);Vr($=>JE($,N)?$:N)}),[]);const{arranged:Wr}=b.useMemo(()=>Kh(U,z=>Qr.get(z.id)??null,dr,"",Te,Tn),[U,Qr,dr,Te,Tn]),fs=b.useRef(Wr);fs.current=Wr;const Dr=b.useMemo(()=>YE(Wr,Te),[Wr,Te]),Pn=b.useRef(Dr);Pn.current=Dr;const Sr=b.useMemo(()=>dd(Te,Z),[Z,Te]),Kr=b.useMemo(()=>{const z=Dr.find(N=>N.sessions.some($=>$.id===Z));return new Set(z?.sessions.map(N=>N.id)??[])},[Z,Dr]),nn=b.useMemo(()=>{const z=new Map;if(!m||v<=0)return z;for(const N of Dr){const $=N.sessions[0];if(!$)continue;const ee=ow($.id,Qr.get($.id)??null,N.workspace?.id??null);if(!(ee===Sn?mn:lw($.id,Qr.get($.id)??null,N.workspace?.id??null)))continue;const Qe=ee===Sn?ir:cw($.id,Qr.get($.id)??null,N.workspace?.id??null),ze=Ih(Qe,v,w);z.set(N.key,ze+i3)}return z},[Qr,w,m,mn,Sn,ir,v,Dr]),Or=b.useMemo(()=>zp(U.map(z=>({id:z.id,backendSessionId:z.sessionId})),h),[h,U]),ks=b.useMemo(()=>Dx(Me,wt),[wt,Me]),Pr=ch({prioritySessionId:Or,activeSessionId:ke??Z,persistedActiveSessionId:ks,firstSessionId:U[0]?.id??null}),Xr=b.useMemo(()=>wE(Dr.flatMap(z=>z.sessions.map(N=>N.id)),Kr),[Kr,Dr]),fn=Pr!==null&&ye.has(Pr),K=b.useMemo(()=>{const z=new Set(Kr);return ke&&z.add(ke),!z.size&&Pr&&z.add(Pr),z},[Kr,ke,Pr]),Ue=je.token===lt.token&&xE(K,je.completed),Et=Ue||Pe===lt.token?lt.token:-1;b.useEffect(()=>{if(!lt.token||Ue)return;const z=window.setTimeout(()=>Se(lt.token),aE);return()=>window.clearTimeout(z)},[lt.token,Ue]);const kt=b.useCallback((z,N)=>{_e($=>{if($.has(z)===N)return $;const se=new Set($);return N?se.add(z):se.delete(z),se})},[]),tr=b.useCallback(z=>{const N=un.current;re(ee=>{if(ee.token===N&&ee.completed.has(z))return ee;const se=new Set(ee.token===N?ee.completed:[]);return se.add(z),{token:N,completed:se}});const $=Or??ke??nr.current;z===$&&vu("foreground-stream-connected")},[ke,Or]),Br=b.useCallback((z,N)=>{Be($=>{if($.has(z)===N)return $;const ee=new Set($);return N?ee.add(z):ee.delete(z),ee})},[]),cr=b.useCallback((z,N)=>{oe($=>{if($.has(z)===N)return $;const ee=new Set($);return N?ee.add(z):ee.delete(z),ee})},[]);b.useEffect(()=>{for(const[z,N]of He.current){const $=U.find(ee=>ee.id===z);if(!$||$.sessionId!==N.backendSessionId){He.current.delete(z);continue}!ye.has(z)||!Ee.has(z)||!Ne.has(z)||(He.current.delete(z),s3(N.backendSessionId,`${N.command}\r`).catch(ee=>{console.error("[Session] Failed to send startup command:",ee)}))}},[U,ye,Ee,Ne]);const _n=Pr!==null&&Ee.has(Pr),Ls=Pr!==null&&Ne.has(Pr);b.useEffect(()=>{_n&&vu("foreground-viewport-ready")},[_n]),b.useEffect(()=>{Ls&&vu("foreground-content-ready")},[Ls]),b.useEffect(()=>{if(!E)return;if(!Y&&U.length===0){E();return}if(!_n||!fn||!Ls)return;const z=[...Kr].every(Qe=>Ee.has(Qe)&&ye.has(Qe)&&Ne.has(Qe));let N=0,$=0;const ee=()=>{N=requestAnimationFrame(()=>{$=requestAnimationFrame(()=>{vu("initial-viewport-presented"),E()})})};z&&ee();const se=z?void 0:window.setTimeout(ee,8e3);return()=>{cancelAnimationFrame(N),cancelAnimationFrame($),clearTimeout(se)}},[fn,Ls,_n,Y,E,U.length,Kr,Ee,ye,Ne]);const Zn=b.useMemo(()=>q?cE({slides:Dr.map(z=>z.sessions.map(N=>N.id)),visibleSessionIds:Kr,foregroundSessionId:Pr}):rt,[q,Dr,Kr,Pr,rt]);b.useEffect(()=>{if(q||Kr.size===0)return;const z=new Set(Kr),N=Dr.findIndex($=>$.sessions.some(ee=>Kr.has(ee.id)));for(let $=-2;$<=2;$+=1)$!==0&&Dr[N+$]?.sessions.forEach(ee=>z.add(ee.id));mt($=>{let ee=!1;const se=new Set($);for(const Qe of z)se.has(Qe)||(se.add(Qe),ee=!0);return ee?se:$})},[q,Kr,Dr]);const sn=$C(Zn);b.useEffect(()=>{if(!ke)return;if(!U.some(N=>N.id===ke)){$e(null);return}if(!Ee.has(ke)||!ye.has(ke)||!Ne.has(ke))return;const z=window.setTimeout(()=>{$e(N=>N===ke?null:N),Nt.current&&!pr.current&&We({sessionId:ke,token:Date.now()})},80);return()=>window.clearTimeout(z)},[Ne,ke,ye,U,Ee]),b.useEffect(()=>{typeof window>"u"||(Te.length>0?(window.localStorage.setItem(t1,JSON.stringify(Te)),window.localStorage.removeItem(Oy)):window.localStorage.removeItem(t1))},[Te]),b.useEffect(()=>{Mr||Y||Te.length===0||H(z=>FE(z,U.map(N=>N.id)))},[Mr,Y,U,Te.length]),b.useEffect(()=>{if(!Wt)return;const z=window.setTimeout(()=>Mt(null),3200);return()=>window.clearTimeout(z)},[Wt]),nr.current=Z,un.current=lt.token,Ir.current=U,Gr.current=wt,it.current=Mr,dt.current=Y,Nt.current=a;const ln=b.useCallback((z=Ye.current)=>{const N=me.current,$=typeof window<"u"?window.visualViewport:null,ee=z?r1(z):null,se=z?cf(z,N):null;return{sessionsLength:Ir.current.length,workspaceSlidesLength:Pn.current.length,sessionIds:Ir.current.map(Qe=>Qe.id),activeSessionId:nr.current,activeSessionIndex:N,persistedActiveId:Gr.current,isLoading:it.current,isRestoring:dt.current,activeIndex:z?.activeIndex??null,previousIndex:z?.previousIndex??null,animating:z?.animating??null,allowTouchMove:z?.allowTouchMove??null,width:z?.width??null,translate:ee,targetTranslate:se,translateDelta:ee!==null&&se!==null?ee-se:null,snapGridLength:z?.snapGrid?.length??null,targetSnap:z?.snapGrid?.[N]??null,visualViewport:$?{width:Math.round($.width),height:Math.round($.height),offsetTop:Math.round($.offsetTop)}:null}},[]),kr=b.useCallback((z,N)=>{W(z,{...ln(),...N})},[W,ln]);b.useEffect(()=>{Mr||Y||Z!==wt&&Er(Z)},[Z,Mr,Y,wt,Er]);const $r=b.useMemo(()=>{if(Wr.length===0||!Z)return 0;const z=Dr.findIndex(N=>N.sessions.some($=>$.id===Z));return z>=0?z:0},[Dr,Z]);me.current=$r;const Gn=b.useCallback(()=>{It.current&&(clearTimeout(It.current),It.current=null)},[]),Vn=b.useCallback(z=>{Gn(),It.current=setTimeout(()=>{It.current=null,gt.current=!1,kr("[swiper:touch-guard-clear]",{reason:z})},WE)},[Gn,kr]),dn=b.useCallback((z,N={})=>{const $=Ye.current,ee=me.current,se=Pn.current;if(!$||se.length===0||ee<0||ee>=se.length)return;if(gt.current){kr("[swiper:sync-skip-touch]",{reason:z});return}if($.animating){kr("[swiper:sync-skip-animating]",{reason:z});return}const Qe=r1($),ze=cf($,ee),xt=Qe!==null&&ze!==null&&Math.abs(Qe-ze)<=Py,_t=$.activeIndex===ee;if(kr("[swiper:sync-check]",{reason:z,activeIndexAligned:_t,translateAligned:xt,immediate:N.immediate===!0}),!(_t&&xt)){if(_t){dh($,ee),kr("[swiper:sync-forced-active]",{reason:z,translateAligned:xt,immediate:N.immediate===!0});return}N.immediate?(dh($,ee),$.slideTo(ee,0,!1),dh($,ee)):$.slideTo(ee,e1,!1),kr("[swiper:sync-applied]",{reason:z,activeIndexAligned:_t,translateAligned:xt,immediate:N.immediate===!0})}},[kr]);b.useEffect(()=>{const z=N=>{const $=N;Ye.current&&(Ye.current.allowTouchMove=!$.detail.locked),kr("[swiper:gesture-lock]",{locked:$.detail.locked})};return document.addEventListener("termdock:gesture-lock",z),()=>document.removeEventListener("termdock:gesture-lock",z)},[kr]),b.useEffect(()=>{if(U.length===0){Z!==null&&_r(null);return}if(!Z){if(!p)return;_r(ch({prioritySessionId:Or,activeSessionId:null,persistedActiveSessionId:ks,firstSessionId:U[0]?.id??null}));return}U.some(N=>N.id===Z)||_r(U[0].id)},[U,Z,p,Or,ks]);const Kn=b.useCallback((z,N)=>{if(N&&Date.now()<on.current){st.current[z]=!1;return}st.current[z]=N,Ct($=>N?z:$===z?null:$)},[]),Lr=b.useCallback(z=>{if(!gt.current&&z.activeIndex!==me.current){kr("[swiper:slide-change-ignored-layout]",{instanceActiveIndex:z.activeIndex,expectedActiveIndex:me.current}),requestAnimationFrame(()=>dn("ignored-layout-slide-change",{immediate:!0}));return}const N=Pn.current[z.activeIndex],$=N?.sessions.some(Qe=>Qe.id===Z)?Z:N?.sessions[0]?.id;if(kr("[swiper:slide-change]",{nextSessionId:$??null,instanceActiveIndex:z.activeIndex}),!$||$===Z)return;const ee=!!Z&&st.current[Z]===!0,se=Nt.current&&(!pr.current||ee);if(yt.current=$,_r($),se){We({sessionId:$,token:Date.now()});return}We(null)},[U,Z,kr,dn]);b.useLayoutEffect(()=>{if(yt.current===Z){kr("[swiper:sync-skip-swiper-driven]",{activeSessionId:Z}),yt.current=null;return}dn("active-session-index",{immediate:!0})},[Z,$r,U.length,dn,kr]),b.useEffect(()=>{const z=Ye.current;if(!z)return;const N=Dr.length>1&&!hn&&!ae;z.allowTouchMove!==N&&(z.allowTouchMove=N,kr("[swiper:allow-touch-sync]",{nextAllow:N,sidebarOverlayOpen:hn}))},[Dr.length,kr,hn,ae]);const Nr=b.useCallback(z=>{const N=Ye.current;if(!N)return;const $=N.el;if(kr("[swiper:layout-before]",{reason:z,scrollLeft:$?.scrollLeft??null}),$&&($.scrollLeft=0),N.updateSize(),N.updateSlides(),N.updateProgress(),N.updateSlidesClasses(),$&&($.scrollLeft=0),kr("[swiper:layout-after]",{reason:z,scrollLeft:$?.scrollLeft??null}),gt.current||N.animating){kr("[swiper:layout-skip-sync-motion]",{reason:z});return}dn(`layout:${z}`,{immediate:!0}),requestAnimationFrame(()=>{const ee=Ye.current;ee&&(gt.current||ee.animating||dh(ee,me.current))})},[kr,dn]);b.useEffect(()=>()=>Gn(),[Gn]);const xr=Dr.map(z=>z.key).join("\0");b.useEffect(()=>{requestAnimationFrame(()=>Nr("group-change"))},[dr,xr,Nr]),b.useEffect(()=>{let z=null,N="mount";const $=xt=>{N=xt,z===null&&(z=requestAnimationFrame(()=>{z=null,Nr(`viewport-change:${N}`)}))},ee=()=>$("window-resize"),se=()=>$("visual-viewport-resize"),Qe=()=>$("visual-viewport-scroll"),ze=xt=>{$(`measured:${xt.detail?.source??"unknown"}`)};return window.addEventListener("resize",ee),window.visualViewport?.addEventListener("resize",se),window.visualViewport?.addEventListener("scroll",Qe),document.addEventListener(Gg,ze),$("mount"),()=>{window.removeEventListener("resize",ee),window.visualViewport?.removeEventListener("resize",se),window.visualViewport?.removeEventListener("scroll",Qe),document.removeEventListener(Gg,ze),z!==null&&cancelAnimationFrame(z)}},[Nr]),b.useEffect(()=>{if(typeof document>"u")return;let z=null,N=null;const $=_t=>{if(_t!=="online"&&document.hidden)return;const Fr=performance.now();if(!bE(N,Fr))return;N=Fr;const jt=_t==="bfcache"||_t==="online"?_t:"visibility",qr=yE();dp(),va("info","PWA_RESUME scheduled",{source:_t,forceForegroundReconnect:qr,activeSessionId:nr.current}),Ce(pn=>({token:pn.token+1,reason:jt,forceForegroundReconnect:qr})),requestAnimationFrame(()=>Nr(`resume:${_t}:raf`)),z&&clearTimeout(z),z=setTimeout(()=>{z=null,Nr(`resume:${_t}:settled`)},320)},ee=()=>{if(document.hidden){dp();return}$("visibility")},se=()=>{dp()},Qe=_t=>{$(_t.persisted?"bfcache":"pageshow")},ze=()=>$("online"),xt=()=>$("focus");return document.addEventListener("visibilitychange",ee),window.addEventListener("pagehide",se),window.addEventListener("pageshow",Qe),window.addEventListener("online",ze),window.addEventListener("focus",xt),()=>{document.removeEventListener("visibilitychange",ee),window.removeEventListener("pagehide",se),window.removeEventListener("pageshow",Qe),window.removeEventListener("online",ze),window.removeEventListener("focus",xt),z&&clearTimeout(z)}},[Nr]),b.useLayoutEffect(()=>{if(!mE(Y))return;const z=KE(U),N=JSON.stringify(z);z.length>0&&N!==An.current?(An.current=N,console.warn("[session-invariant] duplicate mapping detected",z)):z.length===0&&An.current&&(An.current=""),L?.({sessions:U.map($=>({id:$.id,name:$.name,customName:$.customName,mode:$.mode,tmuxSessionName:$.tmuxSessionName})),activeSessionId:Z,splitWorkspaces:Te.map(({id:$,name:ee,sessionIds:se,layout:Qe})=>({id:$,...ee?{name:ee}:{},sessionIds:se,layout:Qe}))})},[U,Z,Te,L,Y]),b.useEffect(()=>{if(Mr||de.current)return;de.current=!0;const z=zp(Me.map(Qe=>({id:Qe.sessionId,backendSessionId:Qe.backendSessionId??null})),h),N=Dx(Me,wt),$=ch({prioritySessionId:p?z:null,activeSessionId:null,persistedActiveSessionId:N,firstSessionId:Me[0]?.sessionId??null}),ee=Fy(Me.map($y));if(W("[Session] Restoring",ee.length,"persisted sessions (one-shot)"),kr("[swiper:restore-start]",{persistedSessionIds:Me.map(Qe=>Qe.sessionId),nextActiveSessionId:$}),ee.length>0){const Qe=Yr.getState();ee.forEach(xt=>{xt.sessionId&&Qe.setTerminalSession(xt.id,{sessionId:xt.sessionId,cols:80,rows:24,mode:xt.mode,tmuxSessionName:xt.tmuxSessionName,history:xt.history})}),Me.forEach(xt=>{xt.agent!==void 0&&Qe.setSessionAgentIdentity(xt.sessionId,xt.agent),xt.activeProgram!=null&&Qe.setSessionActiveProgram(xt.sessionId,xt.activeProgram),xt.cwd!=null&&Qe.setSessionCwd(xt.sessionId,xt.cwd),xt.shellTitle!=null&&Qe.setSessionShellTitle(xt.sessionId,xt.shellTitle)}),V(ee);const ze=$||ee[0]?.id||null;_r(ze),kr("[swiper:restore-complete]",{restoredSessionIds:ee.map(xt=>xt.id),nextActiveSessionId:ze})}(async()=>(ee.length===0&&await sr.current?.({createIfEmpty:!0}),Ae(!1),requestAnimationFrame(()=>dn("restore-finished",{immediate:!0}))))()},[Mr,Me,wt,W,kr,dn,p,h]),b.useEffect(()=>{if(!p||Y||U.length===0)return;const z=zp(U.map($=>({id:$.id,backendSessionId:$.sessionId})),h),N=ch({prioritySessionId:z,activeSessionId:nr.current,persistedActiveSessionId:ks,firstSessionId:U[0]?.id??null});N&&N!==nr.current&&_r(N)},[p,h,Y,ks,U]);const os=b.useRef([]),Hn=b.useRef(!1);nr.current=Z,b.useEffect(()=>{if(Y)return;const z=os.current,N=Me,$=new Map(z.map(jt=>[jt.sessionId,jt])),ee=Yr.getState();for(const jt of N){const qr=$.get(jt.sessionId),pn=Yr.getState().sessions.get(jt.sessionId);jt.agent!==void 0&&JSON.stringify(jt.agent)!==JSON.stringify(pn?.agent)&&(pn?.agent==null||JSON.stringify(jt.agent)!==JSON.stringify(qr?.agent))&&ee.setSessionAgentIdentity(jt.sessionId,jt.agent),jt.activeProgram!=null&&jt.activeProgram!==pn?.activeProgram&&(pn?.activeProgram==null||jt.activeProgram!==qr?.activeProgram)&&ee.setSessionActiveProgram(jt.sessionId,jt.activeProgram),jt.cwd!=null&&jt.cwd!==pn?.cwd&&(pn?.cwd==null||jt.cwd!==qr?.cwd)&&ee.setSessionCwd(jt.sessionId,jt.cwd),jt.shellTitle!=null&&jt.shellTitle!==pn?.shellTitle&&(pn?.shellTitle==null||jt.shellTitle!==qr?.shellTitle)&&ee.setSessionShellTitle(jt.sessionId,jt.shellTitle)}if(!Hn.current){V(jt=>jx(jt,N)),os.current=N,Hn.current=!0;return}const se=new Set(z.map(jt=>jt.sessionId)),Qe=new Set(N.map(jt=>jt.sessionId)),ze=new Map(z.map(jt=>[jt.sessionId,jt.name]));os.current=N,V(jt=>{const qr=jx(jt,N);return(!nr.current||!qr.some(pn=>pn.id===nr.current))&&_r(qr[0]?.id??null),qr});const xt=N.filter(jt=>!se.has(jt.sessionId)),_t=[...se].filter(jt=>!Qe.has(jt)),Fr=N.filter(jt=>se.has(jt.sessionId)&&ze.get(jt.sessionId)!==jt.name);(xt.length>0||_t.length>0||Fr.length>0)&&W("[Session] Synced persisted sessions:",{newSessionIds:xt.map(jt=>jt.sessionId),removedSessionIds:_t,renamedSessionIds:Fr.map(jt=>jt.sessionId),currentSessionIds:N.map(jt=>jt.sessionId)});for(const jt of N){if(!jt.backendSessionId)continue;Yr.getState().setTerminalSession(jt.sessionId,{sessionId:jt.backendSessionId,cols:80,rows:24,mode:jt.mode,tmuxSessionName:jt.tmuxSessionName})}},[Me,Y,W]);const Nn=b.useCallback(async z=>{const N=++fe.current,$=xe.current,ee=()=>N===fe.current&&$===xe.current&&(z?.shouldActivate?.()??!0);try{const se=Gt.getState(),Qe=Z?{rightOpen:se.rightOpen,rightPinned:se.rightPinned,rightSidebarWidth:se.rightSidebarWidth,rightTab:se.rightTab}:null,ze=z?.mode==="tmux"||z?.mode==="shell"?z.mode:c,xt=(z?.tmuxSessionName||"").trim(),_t=l.trim(),Fr=ze==="tmux"?xt||_t||eN():null,jt=typeof z?.cwd=="string"?z.cwd:null,qr=Z?Yr.getState().sessions.get(Z)?.cwd??null:null,pn=typeof jt=="string"&&jt.trim().length>0?jt:typeof qr=="string"&&qr.trim().length>0?qr:void 0,Xn=await rn({preferredFrontendSessionId:z?.preferredFrontendSessionId,requireExisting:z?.requireExisting===!0,mode:ze,tmuxSessionName:Fr,cwd:pn,termType:"xterm-256color",createIfEmpty:z?.createIfEmpty===!0},{shouldActivate:ee});if(Xn.discarded)return z?.onResult?.({ok:!1,error:"unknown"}),null;const vn=Xn.session,kn=Xn.terminalSession;!Xn.reused&&Qe&&Gt.getState().initializeRightSidebarForSession(vn.sessionId,kn.cwd??pn??null,Qe);const ar={id:vn.sessionId,name:vn.name,customName:vn.customName===!0,sessionId:kn.sessionId,mode:kn.mode??vn.mode,tmuxSessionName:kn.tmuxSessionName??vn.tmuxSessionName},qt=z?.command?.trim();return qt&&He.current.set(ar.id,{backendSessionId:kn.sessionId,command:qt}),V(an=>XE(an,ar)),ee()&&_r(ar.id),Yr.getState().setTerminalSession(ar.id,{sessionId:kn.sessionId,cols:80,rows:24,mode:ar.mode,tmuxSessionName:ar.tmuxSessionName,activeProgram:kn.activeProgram,activeProgramRaw:kn.activeProgramRaw,activeProgramSource:kn.activeProgramSource,cwd:kn.cwd}),W("[Session] Inventory opened session:",{frontendSessionId:ar.id,backendSessionId:kn.sessionId,reused:Xn.reused,mode:ar.mode,tmuxSessionName:ar.tmuxSessionName}),z?.onResult?.({ok:!0,sessionId:ar.id}),ar.id}catch(se){return console.error("[Session] Failed to create new session:",se),z?.onResult?.({ok:!1,error:IC(se)}),null}},[c,l,Z,rn,W]);sr.current=Nn;const Rn=b.useCallback((z,N={})=>{xe.current+=1,ns.getState().setActivePane(z);const $=nr.current,ee=!!$&&st.current[$]===!0;if(_r(z),pr.current&&N.preserveMobileKeyboard===!1){on.current=Date.now()+600,$&&(st.current[$]=!1),Ct(null),We(null);const se=document.activeElement;se instanceof HTMLTextAreaElement&&se.closest(".terminal-viewport-container")&&se.blur();return}ee&&pr.current&&Ct(z),Nt.current&&(!pr.current||ee)&&We({sessionId:z,token:Date.now()})},[]),ps=b.useCallback(z=>{_r(z),Ze(!0),Mt(null)},[]),G=b.useCallback(z=>{const N=nr.current;!N||N===z||(H($=>Wp($,N,z)),Ze(!1),Rn(N,{preserveMobileKeyboard:!1}))},[Rn]),Le=b.useCallback(async()=>{const z=nr.current;if(!z||Ge)return;const N=xe.current;ft(!0);const $=Yr.getState().sessions.get(z)?.cwd??void 0,ee=await Nn({cwd:$||void 0,mode:c,shouldActivate:()=>!1});if(ft(!1),!ee){Mt(B("common.error"));return}!Tt.current||N!==xe.current||!Ir.current.some(se=>se.id===z)||(H(se=>Wp(se,z,ee)),Ze(!1),Rn(z,{preserveMobileKeyboard:!1}))},[Rn,c,Nn,Ge,B]),Ke=b.useCallback(z=>{H(N=>UE(N,z)),z&&Rn(z,{preserveMobileKeyboard:!1})},[Rn]),ct=b.useCallback(z=>{H(N=>$E(N,z)),Rn(z,{preserveMobileKeyboard:!1})},[Rn]),qe=b.useCallback(z=>{if(U.find($=>$.id===z)){if(xe.current+=1,ns.getState().setActivePane(z),z===nr.current)return;if(_r(z),!hE({isMobile:pr.current,viewportReady:Ee.has(z),streamReady:ye.has(z),contentReady:Ne.has(z)})){$e(null),Nt.current&&We({sessionId:z,token:Date.now()}),W("[Session] Switched to session:",z);return}mt(ee=>{if(ee.has(z))return ee;const se=new Set(ee);return se.add(z),se}),$e(z),W("[Session] Switched to session:",z)}},[Ne,W,ye,U,Ee]),At=b.useCallback((z,N)=>{N.trim()&&(V($=>$.map(ee=>ee.id===z?{...ee,name:N.trim(),customName:!0}:ee)),ht(z,N.trim()))},[ht]),Rt=b.useCallback(z=>{V(N=>N.map($=>$.id===z?{...$,customName:!1}:$)),zt(z)},[zt]),Dt=b.useCallback(z=>{V(N=>{const $=new Map(N.map(ze=>[ze.id,ze])),ee=z.map(ze=>$.get(ze)).filter(ze=>ze!==void 0),se=new Set(z),Qe=N.filter(ze=>!se.has(ze.id));return[...ee,...Qe]}),Pt(z),W("[Session] Reordered sessions:",z),requestAnimationFrame(()=>{Ye.current?.update()})},[Pt,W]),ot=b.useCallback(async z=>{const N=typeof z=="string"?z:z.sessionId,$=typeof z=="string"?"auto":z.closeMode??"auto",ee=U.find(xt=>xt.id===N);if(!ee||Qt.current.has(N))return;Qt.current.add(N),xe.current+=1;const se=Vg(Wr,N,xt=>xt.id);try{$==="destroy"&&ee.mode==="tmux"&&ee.tmuxSessionName?(await a3(ee.tmuxSessionName),W("[Session] Destroyed tmux session:",{frontendSessionId:ee.id,tmuxSessionName:ee.tmuxSessionName})):ee.sessionId&&(await n3(ee.sessionId),W("[Session] Closed backend terminal:",ee.sessionId))}catch(xt){console.error("[Session] Failed to close backend terminal:",xt),Yt({sessionId:N,closeMode:$});return}finally{Qt.current.delete(N)}Yt(xt=>xt?.sessionId===N?null:xt);const ze=Ir.current.filter(xt=>xt.id!==N).some(xt=>xt.id===se)?se:Vg(Ir.current,N,xt=>xt.id);nr.current===N&&_r(ze),V(xt=>xt.filter(_t=>_t.id!==N)),ne(N,ze),delete st.current[N],W("[Session] Closed session:",{sessionId:N,closeMode:$})},[U,Wr,ne,W]),Ot=b.useCallback(z=>{if(!z)return;const N=U.filter($=>$.sessionId===z);if(N.length!==0){N.length>1&&console.warn("[session-invariant] backend matched multiple frontend sessions during cleanup",{backendSessionId:z,frontendSessionIds:N.map($=>$.id)}),V($=>{const ee=$.filter(se=>se.sessionId!==z);return ee.length!==$.length&&!ee.some(Qe=>Qe.id===Z)&&_r(ee.length>0?ee[0].id:null),ee});for(const $ of N)ne($.id),delete st.current[$.id];W("[Session] Backend gone, dropped local session(s):",N.map($=>$.id))}},[U,Z,ne,W]);b.useEffect(()=>{const z=ar=>{Nn(ar.detail)},N=ar=>{qe(ar.detail)},$=()=>{const ar=nr.current;!ar||pr.current||We({sessionId:ar,token:Date.now()})},ee=ar=>{const qt=ar;qt.detail&&ps(qt.detail)},se=ar=>{const qt=ar.detail;Ke(qt??nr.current??void 0)},Qe=ar=>{const qt=ar.detail;qt&&ct(qt)},ze=ar=>{const qt=ar.detail,cn=typeof qt=="string"?qt:qt?.layout,an=typeof qt=="string"?nr.current:qt?.sessionId;cn!=="horizontal"&&cn!=="vertical"&&cn!=="grid"||H(Hs=>Hs.map(Is=>Is.sessionIds.includes(an??"")?{...Is,layout:cn}:Is))},xt=ar=>{const cn=ar.detail?.direction;if(cn!=="prev"&&cn!=="next")return;const an=fs.current;if(an.length<=1)return;const Hs=nr.current,Is=Hs?an.findIndex(ia=>ia.id===Hs):-1,Aa=((Is>=0?Is:0)+(cn==="next"?1:-1)+an.length)%an.length,Ln=an[Aa]?.id;Ln&&Ln!==Hs&&qe(Ln)},_t=ar=>{ot(ar.detail)},Fr=ar=>{Ot(ar.detail)},jt=ar=>{const qt=ar;!qt.detail?.sessionId||!qt.detail?.name||At(qt.detail.sessionId,qt.detail.name)},qr=ar=>{const qt=ar;qt.detail?.sessionId&&Rt(qt.detail.sessionId)},pn=ar=>{const qt=ar;qt.detail?.sessionIds&&Dt(qt.detail.sessionIds)},Xn=ar=>{const qt=ar.detail;!qt?.workspaceId||!Array.isArray(qt.sessionIds)||H(cn=>zE(cn,qt.workspaceId,qt.sessionIds))},vn=ar=>{const qt=ar.detail;!qt?.workspaceId||typeof qt.name!="string"||H(cn=>HE(cn,qt.workspaceId,qt.name))},kn=ar=>{const qt=ar.detail;!qt?.primaryId||!qt.secondaryId||qt.primaryId===qt.secondaryId||(H(cn=>Wp(cn,qt.primaryId,qt.secondaryId)),Rn(qt.primaryId,{preserveMobileKeyboard:!1}))};return window.addEventListener("new-terminal-session",z),window.addEventListener("switch-terminal-session",N),window.addEventListener("focus-active-terminal-session",$),window.addEventListener("open-terminal-split-chooser",ee),window.addEventListener("close-terminal-split",se),window.addEventListener("remove-terminal-split-pane",Qe),window.addEventListener("set-terminal-split-direction",ze),window.addEventListener("cycle-terminal-session",xt),window.addEventListener("close-terminal-session",_t),window.addEventListener("close-terminal-session-by-backend",Fr),window.addEventListener("rename-terminal-session",jt),window.addEventListener("reset-terminal-session-name",qr),window.addEventListener("reorder-terminal-session",pn),window.addEventListener("reorder-terminal-split-workspace",Xn),window.addEventListener("rename-terminal-split-workspace",vn),window.addEventListener("combine-terminal-split-sessions",kn),()=>{window.removeEventListener("new-terminal-session",z),window.removeEventListener("switch-terminal-session",N),window.removeEventListener("focus-active-terminal-session",$),window.removeEventListener("open-terminal-split-chooser",ee),window.removeEventListener("close-terminal-split",se),window.removeEventListener("remove-terminal-split-pane",Qe),window.removeEventListener("set-terminal-split-direction",ze),window.removeEventListener("cycle-terminal-session",xt),window.removeEventListener("close-terminal-session",_t),window.removeEventListener("close-terminal-session-by-backend",Fr),window.removeEventListener("rename-terminal-session",jt),window.removeEventListener("reset-terminal-session-name",qr),window.removeEventListener("reorder-terminal-session",pn),window.removeEventListener("reorder-terminal-split-workspace",Xn),window.removeEventListener("rename-terminal-split-workspace",vn),window.removeEventListener("combine-terminal-split-sessions",kn)}},[Rn,Nn,qe,ps,Ke,ct,ot,Ot,At,Rt,Dt]),b.useEffect(()=>{if(!Sr||q)return;const z=N=>{if(!UC(N,S1())||!(N.ctrlKey||N.metaKey)||!N.shiftKey)return;if(Sr.layout==="horizontal"?N.key==="ArrowLeft"||N.key==="ArrowRight":Sr.layout==="vertical"?N.key==="ArrowUp"||N.key==="ArrowDown":N.key.startsWith("Arrow")){N.preventDefault(),N.stopPropagation();const ee=Sr.sessionIds.indexOf(nr.current??""),se=N.key==="ArrowLeft"||N.key==="ArrowUp"?-1:1,Qe=(Math.max(0,ee)+se+Sr.sessionIds.length)%Sr.sessionIds.length,ze=Sr.sessionIds[Qe];if(!ze)return;Rn(ze);return}N.key==="Backspace"&&(N.preventDefault(),N.stopPropagation(),Ke(nr.current??void 0))};return window.addEventListener("keydown",z,!0),()=>window.removeEventListener("keydown",z,!0)},[Rn,Sr,Ke,q]);const hr=z=>{const N=Yr.getState().sessions.get(z.id);return sl(z,N?.activeProgram??null,N?.cwd??null,void 0,N?.shellTitle??null,N?.promptState??null)},Zt=(z,N={})=>{const $=z.id===Z&&!te?.startsWith("@collaboration:"),ee=Kr.has(z.id)&&!N.hidden,se=p&&dE({sessionId:z.id,foregroundSessionId:Pr,visibleSessionIds:Kr,deferredViewportSessionIds:q?sn:Zn}),Qe=uE({sessionId:z.id,foregroundSessionId:Pr,foregroundReady:fn,isVisible:ee})&&p,ze=gE({sessionId:z.id,foregroundSessionId:Pr,requestToken:lt.token,foregroundCompletedToken:Et,isVisible:K.has(z.id)})&&p,xt=ee||z.id===Pr||Zn.has(z.id)?0:Xr.get(z.id)??Qh;return s.jsxs("div",{className:`relative flex h-full min-h-0 min-w-0 flex-col overflow-hidden ${N.hidden?"invisible pointer-events-none":""}`,style:N.containerStyle,"aria-hidden":N.hidden||void 0,onPointerDownCapture:()=>{ee&&Rx($,()=>Rn(z.id))},onWheelCapture:()=>{Rx($,()=>Rn(z.id))},children:[N.showPaneTitle&&s.jsx(DE,{session:z,active:$,onActivate:()=>Rn(z.id),onToggleRightSidebar:$?x:void 0}),s.jsx("div",{className:"min-h-0 flex-1 app-chrome-bg",children:se&&s.jsx(jE,{sessionId:z.id,mode:z.mode,tmuxSessionName:z.tmuxSessionName,terminalSettings:e,colorTheme:t,toolbarPresets:r,isActive:$,focusSuspended:ke!==null,deferCursorUntilPositioned:ke===z.id||z.mode==="tmux"&&!Ne.has(z.id),isLayoutVisible:ee,initialConnectEnabled:Qe&&ze,resumeRequestEnabled:ze,suppressKeyboard:N.suppressKeyboard,keyboardPortalTarget:N.keyboardPortalTarget,sharedMobileKeyboardLayout:N.sharedMobileKeyboardLayout,suppressPageFlipRefresh:N.suppressPageFlipRefresh,focusRequestToken:Ie?.sessionId===z.id?Ie.token:0,resumeRequestToken:lt.token,resumeRequestReason:lt.reason,forceResumeReconnect:lt.forceForegroundReconnect&&K.has(z.id),resumeRequestDelayMs:K.has(z.id)?0:N.hidden?Qh:Xr.get(z.id)??Qh,initialConnectDelayMs:xt,onStreamReadyChange:kt,onStreamConnected:tr,onViewportReadyChange:Br,onContentReadyChange:cr,onKeyboardVisibilityChange:Kn,showDebug:n,onStatusChange:$?k:void 0})})]},z.id)};return s.jsxs("div",{className:"relative h-full flex flex-col",children:[vt&&U.some(z=>z.id===vt.sessionId)&&s.jsxs("div",{role:"alert",className:"fixed inset-x-3 top-[calc(var(--safe-top-inset)+0.75rem)] z-toast mx-auto flex max-w-lg items-center gap-3 rounded-xl border border-destructive/30 bg-surface-elevated px-4 py-3 text-[12px] text-foreground shadow-lg",children:[s.jsx("span",{className:"min-w-0 flex-1",children:B("tab.closeFailed",{name:U.find(z=>z.id===vt.sessionId).name})}),s.jsx("button",{type:"button",className:"shrink-0 rounded-lg px-2 py-1 text-primary hover:bg-surface-2",onClick:()=>{ot(vt)},children:B("common.retry")}),s.jsx("button",{type:"button",className:"shrink-0 rounded-lg p-1 hover:bg-surface-2","aria-label":B("common.close"),onClick:()=>Yt(null),children:s.jsx(Qn,{size:16})})]}),gr&&s.jsx("section",{className:"fixed inset-x-3 top-[calc(var(--safe-top-inset)+0.75rem)] z-toast mx-auto max-w-lg rounded-2xl border border-warning/30 bg-surface-elevated px-4 py-3.5 shadow-[0_20px_60px_var(--app-shadow-strong)]",role:"alert","aria-live":"assertive",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-warning/15 text-warning",children:s.jsx(k1,{size:18})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{className:"text-[13px] font-semibold text-foreground",children:B("tab.tmuxRecoveryTitle",{count:gr.sessions.length})}),s.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:B("tab.tmuxRecoveryHint")}),s.jsx("p",{className:"mt-1.5 truncate text-[10px] text-foreground/70",children:gr.sessions.map(z=>z.name).join(" · ")}),Lt&&s.jsx("p",{className:"mt-2 text-[10px] text-destructive",children:Lt}),s.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[s.jsxs("button",{type:"button",disabled:Xt!==null,onClick:()=>{Hr()},className:"inline-flex min-h-9 items-center gap-1.5 rounded-lg bg-primary px-3 text-[11px] font-medium text-primary-foreground transition active:opacity-80 disabled:opacity-50",children:[s.jsx(C3,{size:13,className:Xt==="restore"?"animate-spin":""}),B(Xt==="restore"?"tab.tmuxRecoveryRestoring":"tab.tmuxRecoveryRestoreAll")]}),s.jsx("button",{type:"button",disabled:Xt!==null,onClick:()=>{En()},className:"inline-flex min-h-9 items-center rounded-lg px-3 text-[11px] text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:opacity-50",children:B("tab.tmuxRecoveryDismiss")})]})]})]})}),s.jsx("div",{className:"flex-1 overflow-hidden",children:s.jsx(W9,{onSwiper:z=>{Ye.current=z,z.allowTouchMove=Dr.length>1&&!hn&&!ae,kr("[swiper:on-swiper]",{allowTouchMove:z.allowTouchMove}),requestAnimationFrame(()=>Nr("on-swiper"))},onSlideChange:Lr,onTouchStart:(z,N)=>{const $=Bx(N),ee=$==="touch"||$==="pen"||$==="unknown";F("[swipe:touch-start]",{pointerType:$,allowed:ee}),kr("[swiper:touch-start]",{pointerType:$,allowed:ee}),ee&&(Gn(),bt.current=!0,gt.current=!0)},onTouchEnd:(z,N)=>{const $=Bx(N),ee=$==="touch"||$==="pen"||$==="unknown";F("[swipe:touch-end]",{pointerType:$,allowed:ee}),kr("[swiper:touch-end]",{pointerType:$,allowed:ee}),ee&&(bt.current=!1,Vn("touch-end"))},onTransitionEnd:()=>{const z=Ye.current;if(bt.current){kr("[swiper:transition-end-during-touch]");return}if(gt.current&&z&&!ZE(z,me.current)){kr("[swiper:transition-end-deferred]");return}Gn(),gt.current=!1,kr("[swiper:transition-end]")},initialSlide:Math.max(0,$r),speed:e1,slidesPerView:1,resistanceRatio:.82,threshold:8,longSwipesRatio:.2,touchAngle:45,touchStartPreventDefault:!1,simulateTouch:!1,noSwiping:!0,noSwipingSelector:"[data-mobile-keyboard='true']",className:"terminal-session-swiper h-full",children:Dr.map(z=>{const N=z.workspace,$=!!N&&z.sessions.length>=2,ee=q?Vt?"horizontal":"vertical":N?.layout??"horizontal",se=q&&et?z.sessions.some(ze=>ze.id===et):!1,Qe=z.sessions.some(ze=>ze.id===Z)?Z:z.sessions[0]?.id;return s.jsx(G9,{className:"h-full",children:s.jsx("div",{className:"h-full min-w-0","data-pinned-right-sidebar-inset":nn.get(z.key)??0,style:{paddingRight:nn.get(z.key)??0,paddingTop:y&&!$?"2.5rem":void 0},children:$?s.jsxs("div",{className:"flex h-full min-h-0 min-w-0 flex-col bg-[var(--chrome-bg)]",style:q?{transform:"translateY(var(--kb-translate-y, 0px))",transition:"none"}:void 0,children:[s.jsx(a2,{layoutId:z.key,preset:N?.layout??"horizontal",initialTree:DC(z.sessions.map(ze=>ze.id),ee,N?.ratios,N?.gridColumnRatios,N?.gridRowRatios),mobile:q,focusId:se?et:null,panes:z.sessions.map(ze=>({id:ze.id,content:Zt(ze,{showPaneTitle:!q,suppressKeyboard:q&&ze.id!==Qe,keyboardPortalTarget:q?De:null,sharedMobileKeyboardLayout:q,suppressPageFlipRefresh:!0})}))}),q&&s.jsx("div",{ref:er,className:"relative shrink-0 app-chrome-bg","data-split-keyboard-host":"true"})]}):s.jsx(a2,{layoutId:z.key,preset:N?.layout??"horizontal",mobile:q,panes:[{id:z.sessions[0].id,content:Zt(z.sessions[0])}]})})},z.key)})})}),ae&&Z&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop-soft)] backdrop-blur-sm",onClick:()=>Ze(!1),"aria-label":B("common.close")}),s.jsxs("section",{ref:Je,tabIndex:-1,className:"fixed inset-x-3 bottom-3 z-modal-panel mx-auto max-h-[min(78svh,620px)] max-w-md overflow-hidden rounded-2xl border border-border/20 bg-surface shadow-[0_24px_70px_var(--app-shadow-strong)] sm:bottom-auto sm:top-1/2 sm:-translate-y-1/2",style:{paddingBottom:"var(--safe-bottom-inset)"},role:"dialog","aria-modal":"true","aria-label":B("tab.splitTitle"),children:[s.jsxs("header",{className:"flex items-start gap-3 border-b border-border/20 px-4 py-3.5",children:[s.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-xl bg-primary/15 text-primary",children:s.jsx(_l,{size:17})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{className:"text-[14px] font-semibold text-foreground",children:B("tab.splitTitle")}),s.jsx("p",{className:"mt-0.5 text-[11px] leading-relaxed text-muted-foreground",children:B("tab.splitExistingHint")})]}),s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-surface-2 hover:text-foreground",onClick:()=>Ze(!1),"aria-label":B("common.close"),children:s.jsx(Qn,{size:16})})]}),s.jsxs("div",{className:"max-h-[calc(min(78svh,620px)-72px)] overflow-y-auto overscroll-contain p-2",children:[s.jsxs("button",{type:"button",disabled:Ge,onClick:()=>{Le()},className:"flex w-full items-center gap-3 rounded-xl px-3 py-3 text-left transition hover:bg-surface-2 active:bg-surface-elevated disabled:opacity-60",children:[s.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-primary/15 text-primary",children:s.jsx(Us,{size:17})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block text-[13px] font-medium text-foreground",children:B("tab.splitNew")}),s.jsx("span",{className:"mt-0.5 block text-[11px] text-muted-foreground",children:B("tab.splitNewHint")})]})]}),Te.filter(z=>z.id!==Sr?.id).length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-3 pb-1 pt-3 text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground",children:B("tab.splitExistingGroups")}),Te.filter(z=>z.id!==Sr?.id).map((z,N)=>{const $=z.sessionIds.flatMap(Qe=>{const ze=U.find(xt=>xt.id===Qe);return ze?[ze]:[]});if($.length<2)return null;const ee=z.name||`${B("tab.splitWorkspace")} ${N+1}`,se=$.map(Qe=>hr(Qe).primary).join(" · ");return s.jsxs("button",{type:"button",onClick:()=>G($[0].id),className:"group flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left transition hover:bg-surface-2 active:bg-surface-elevated",children:[s.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:s.jsx(_l,{size:15})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-medium text-foreground",children:ee}),s.jsx("span",{className:"shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[9px] font-medium text-primary",children:B("tab.splitOccupied")})]}),s.jsxs("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:[B("tab.sessionCount",{count:$.length})," · ",se]})]}),s.jsx(di,{size:14,className:"text-primary opacity-0 transition group-hover:opacity-100"})]},z.id)})]}),s.jsx("div",{className:"px-3 pb-1 pt-3 text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground",children:B("tab.splitAvailableSessions")}),U.filter(z=>!Te.some(N=>N.sessionIds.includes(z.id))&&z.id!==Z).length===0&&Te.filter(z=>z.id!==Sr?.id).length===0?s.jsx("p",{className:"px-3 py-4 text-[12px] text-muted-foreground",children:B("tab.splitNoOtherSessions")}):U.filter(z=>!Te.some(N=>N.sessionIds.includes(z.id))&&z.id!==Z).map(z=>{const N=Qr.get(z.id)??null,$=hr(z);return s.jsxs("button",{type:"button",onClick:()=>G(z.id),className:"group flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left transition hover:bg-surface-2 active:bg-surface-elevated",children:[s.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground",children:N?s.jsx(jc,{size:15}):s.jsx(_l,{size:15})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-[12px] font-medium text-foreground",children:$.primary}),s.jsx("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:N?Pu(N)??N:z.name})]}),s.jsx(di,{size:14,className:"text-primary opacity-0 transition group-hover:opacity-100"})]},z.id)})]})]})]}),Wt&&s.jsx("div",{className:"fixed inset-x-3 bottom-4 z-toast mx-auto max-w-md rounded-xl border border-border/20 bg-surface-elevated px-4 py-3 text-center text-[12px] text-foreground shadow-lg",children:Wt})]})},rN={sm:"h-4 w-7",md:"h-6 w-10"},nN={sm:"h-3 w-3",md:"h-5 w-5"},sN={sm:"translate-x-3",md:"translate-x-4"};function ll({checked:e,disabled:t=!1,size:r="md",className:n=""}){return s.jsx("span",{"aria-hidden":"true",className:`inline-flex shrink-0 items-center rounded-full transition ${rN[r]} ${e?"bg-primary":"bg-surface-elevated"} ${t?"opacity-50":""} ${n}`,children:s.jsx("span",{className:`mx-0.5 inline-block rounded-full bg-[var(--background)] shadow transition ${nN[r]} ${e?sN[r]:""}`})})}function ta(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var iN=typeof Symbol=="function"&&Symbol.observable||"@@observable",Px=iN,Ox=()=>Math.random().toString(36).substring(7).split("").join("."),aN={INIT:`@@redux/INIT${Ox()}`,REPLACE:`@@redux/REPLACE${Ox()}`},Fx=aN;function oN(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function Uy(e,t,r){if(typeof e!="function")throw new Error(ta(2));if(typeof t=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw new Error(ta(0));if(typeof t=="function"&&typeof r>"u"&&(r=t,t=void 0),typeof r<"u"){if(typeof r!="function")throw new Error(ta(1));return r(Uy)(e,t)}let n=e,a=t,c=new Map,l=c,h=0,p=!1;function m(){l===c&&(l=new Map,c.forEach((E,R)=>{l.set(R,E)}))}function x(){if(p)throw new Error(ta(3));return a}function y(E){if(typeof E!="function")throw new Error(ta(4));if(p)throw new Error(ta(5));let R=!0;m();const B=h++;return l.set(B,E),function(){if(R){if(p)throw new Error(ta(6));R=!1,m(),l.delete(B),c=null}}}function w(E){if(!oN(E))throw new Error(ta(7));if(typeof E.type>"u")throw new Error(ta(8));if(typeof E.type!="string")throw new Error(ta(17));if(p)throw new Error(ta(9));try{p=!0,a=n(a,E)}finally{p=!1}return(c=l).forEach(B=>{B()}),E}function v(E){if(typeof E!="function")throw new Error(ta(10));n=E,w({type:Fx.REPLACE})}function k(){const E=y;return{subscribe(R){if(typeof R!="object"||R===null)throw new Error(ta(11));function B(){const F=R;F.next&&F.next(x())}return B(),{unsubscribe:E(B)}},[Px](){return this}}}return w({type:Fx.INIT}),{dispatch:w,subscribe:y,getState:x,replaceReducer:v,[Px]:k}}function $x(e,t){return function(...r){return t(e.apply(this,r))}}function Ux(e,t){if(typeof e=="function")return $x(e,t);if(typeof e!="object"||e===null)throw new Error(ta(16));const r={};for(const n in e){const a=e[n];typeof a=="function"&&(r[n]=$x(a,t))}return r}function zy(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,r)=>(...n)=>t(r(...n)))}function lN(...e){return t=>(r,n)=>{const a=t(r,n);let c=()=>{throw new Error(ta(15))};const l={getState:a.getState,dispatch:(p,...m)=>c(p,...m)},h=e.map(p=>p(l));return c=zy(...h)(a.dispatch),{...a,dispatch:c}}}var Vp={exports:{}},qp={};var zx;function cN(){if(zx)return qp;zx=1;var e=sA();function t(p,m){return p===m&&(p!==0||1/p===1/m)||p!==p&&m!==m}var r=typeof Object.is=="function"?Object.is:t,n=e.useSyncExternalStore,a=e.useRef,c=e.useEffect,l=e.useMemo,h=e.useDebugValue;return qp.useSyncExternalStoreWithSelector=function(p,m,x,y,w){var v=a(null);if(v.current===null){var k={hasValue:!1,value:null};v.current=k}else k=v.current;v=l(function(){function E(U){if(!R){if(R=!0,B=U,U=y(U),w!==void 0&&k.hasValue){var V=k.value;if(w(V,U))return W=V}return W=U}if(V=W,r(B,U))return V;var Z=y(U);return w!==void 0&&w(V,Z)?(B=U,V):(B=U,W=Z)}var R=!1,B,W,F=x===void 0?null:x;return[function(){return E(m())},F===null?void 0:function(){return E(F())}]},[m,x,y,w]);var L=n(p,v[0],v[1]);return c(function(){k.hasValue=!0,k.value=L},[L]),h(L),L},qp}var Hx;function uN(){return Hx||(Hx=1,Vp.exports=cN()),Vp.exports}uN();var dN=b.version.startsWith("19"),hN=Symbol.for(dN?"react.transitional.element":"react.element"),fN=Symbol.for("react.portal"),pN=Symbol.for("react.fragment"),mN=Symbol.for("react.strict_mode"),gN=Symbol.for("react.profiler"),xN=Symbol.for("react.consumer"),bN=Symbol.for("react.context"),Hy=Symbol.for("react.forward_ref"),yN=Symbol.for("react.suspense"),vN=Symbol.for("react.suspense_list"),W1=Symbol.for("react.memo"),wN=Symbol.for("react.lazy"),AN=Hy,TN=W1;function CN(e){if(typeof e=="object"&&e!==null){const{$$typeof:t}=e;switch(t){case hN:switch(e=e.type,e){case pN:case gN:case mN:case yN:case vN:return e;default:switch(e=e&&e.$$typeof,e){case bN:case Hy:case wN:case W1:return e;case xN:return e;default:return t}}case fN:return t}}}function SN(e){return CN(e)===W1}function _N(e,t,r,n,{areStatesEqual:a,areOwnPropsEqual:c,areStatePropsEqual:l}){let h=!1,p,m,x,y,w;function v(B,W){return p=B,m=W,x=e(p,m),y=t(n,m),w=r(x,y,m),h=!0,w}function k(){return x=e(p,m),t.dependsOnOwnProps&&(y=t(n,m)),w=r(x,y,m),w}function L(){return e.dependsOnOwnProps&&(x=e(p,m)),t.dependsOnOwnProps&&(y=t(n,m)),w=r(x,y,m),w}function E(){const B=e(p,m),W=!l(B,x);return x=B,W&&(w=r(x,y,m)),w}function R(B,W){const F=!c(W,m),U=!a(B,p,W,m);return p=B,m=W,F&&U?k():F?L():U?E():w}return function(W,F){return h?R(W,F):v(W,F)}}function kN(e,{initMapStateToProps:t,initMapDispatchToProps:r,initMergeProps:n,...a}){const c=t(e,a),l=r(e,a),h=n(e,a);return _N(c,l,h,e,a)}function LN(e,t){const r={};for(const n in e){const a=e[n];typeof a=="function"&&(r[n]=(...c)=>t(a(...c)))}return r}function n1(e){return function(r){const n=e(r);function a(){return n}return a.dependsOnOwnProps=!1,a}}function Wx(e){return e.dependsOnOwnProps?!!e.dependsOnOwnProps:e.length!==1}function Wy(e,t){return function(n,{displayName:a}){const c=function(h,p){return c.dependsOnOwnProps?c.mapToProps(h,p):c.mapToProps(h,void 0)};return c.dependsOnOwnProps=!0,c.mapToProps=function(h,p){c.mapToProps=e,c.dependsOnOwnProps=Wx(e);let m=c(h,p);return typeof m=="function"&&(c.mapToProps=m,c.dependsOnOwnProps=Wx(m),m=c(h,p)),m},c}}function G1(e,t){return(r,n)=>{throw new Error(`Invalid value of type ${typeof e} for ${t} argument when connecting component ${n.wrappedComponentName}.`)}}function IN(e){return e&&typeof e=="object"?n1(t=>LN(e,t)):e?typeof e=="function"?Wy(e):G1(e,"mapDispatchToProps"):n1(t=>({dispatch:t}))}function EN(e){return e?typeof e=="function"?Wy(e):G1(e,"mapStateToProps"):n1(()=>({}))}function NN(e,t,r){return{...r,...e,...t}}function RN(e){return function(r,{displayName:n,areMergedPropsEqual:a}){let c=!1,l;return function(p,m,x){const y=e(p,m,x);return c?a(y,l)||(l=y):(c=!0,l=y),l}}}function MN(e){return e?typeof e=="function"?RN(e):G1(e,"mergeProps"):()=>NN}function jN(e){e()}function DN(){let e=null,t=null;return{clear(){e=null,t=null},notify(){jN(()=>{let r=e;for(;r;)r.callback(),r=r.next})},get(){const r=[];let n=e;for(;n;)r.push(n),n=n.next;return r},subscribe(r){let n=!0;const a=t={callback:r,next:null,prev:t};return a.prev?a.prev.next=a:e=a,function(){!n||e===null||(n=!1,a.next?a.next.prev=a.prev:t=a.prev,a.prev?a.prev.next=a.next:e=a.next)}}}}var Gx={notify(){},get:()=>[]};function Gy(e,t){let r,n=Gx,a=0,c=!1;function l(L){x();const E=n.subscribe(L);let R=!1;return()=>{R||(R=!0,E(),y())}}function h(){n.notify()}function p(){k.onStateChange&&k.onStateChange()}function m(){return c}function x(){a++,r||(r=t?t.addNestedSub(p):e.subscribe(p),n=DN())}function y(){a--,r&&a===0&&(r(),r=void 0,n.clear(),n=Gx)}function w(){c||(c=!0,x())}function v(){c&&(c=!1,y())}const k={addNestedSub:l,notifyNestedSubs:h,handleChangeWrapper:p,isSubscribed:m,trySubscribe:w,tryUnsubscribe:v,getListeners:()=>n};return k}var BN=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",QN=BN(),PN=()=>typeof navigator<"u"&&navigator.product==="ReactNative",ON=PN(),FN=()=>QN||ON?b.useLayoutEffect:b.useEffect,uf=FN();function Vx(e,t){return e===t?e!==0||t!==0||1/e===1/t:e!==e&&t!==t}function Yp(e,t){if(Vx(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let a=0;a<r.length;a++)if(!Object.prototype.hasOwnProperty.call(t,r[a])||!Vx(e[r[a]],t[r[a]]))return!1;return!0}var $N={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},UN={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},zN={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},Vy={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},HN={[AN]:zN,[TN]:Vy};function qx(e){return SN(e)?Vy:HN[e.$$typeof]||$N}var WN=Object.defineProperty,GN=Object.getOwnPropertyNames,Yx=Object.getOwnPropertySymbols,VN=Object.getOwnPropertyDescriptor,qN=Object.getPrototypeOf,Zx=Object.prototype;function s1(e,t){if(typeof t!="string"){if(Zx){const c=qN(t);c&&c!==Zx&&s1(e,c)}let r=GN(t);Yx&&(r=r.concat(Yx(t)));const n=qx(e),a=qx(t);for(let c=0;c<r.length;++c){const l=r[c];if(!UN[l]&&!(a&&a[l])&&!(n&&n[l])){const h=VN(t,l);try{WN(e,l,h)}catch{}}}}return e}var YN=Symbol.for("react-redux-context"),ZN=typeof globalThis<"u"?globalThis:{};function KN(){if(!b.createContext)return{};const e=ZN[YN]??=new Map;let t=e.get(b.createContext);return t||(t=b.createContext(null),e.set(b.createContext,t)),t}var qy=KN(),XN=[null,null];function JN(e,t,r){uf(()=>e(...t),r)}function eR(e,t,r,n,a,c){e.current=n,r.current=!1,a.current&&(a.current=null,c())}function tR(e,t,r,n,a,c,l,h,p,m,x){if(!e)return()=>{};let y=!1,w=null;const v=()=>{if(y||!h.current)return;const L=t.getState();let E,R;try{E=n(L,a.current)}catch(B){R=B,w=B}R||(w=null),E===c.current?l.current||m():(c.current=E,p.current=E,l.current=!0,x())};return r.onStateChange=v,r.trySubscribe(),v(),()=>{if(y=!0,r.tryUnsubscribe(),r.onStateChange=null,w)throw w}}function rR(e,t){return e===t}function nR(e,t,r,{pure:n,areStatesEqual:a=rR,areOwnPropsEqual:c=Yp,areStatePropsEqual:l=Yp,areMergedPropsEqual:h=Yp,forwardRef:p=!1,context:m=qy}={}){const x=m,y=EN(e),w=IN(t),v=MN(r),k=!!e;return E=>{const R=E.displayName||E.name||"Component",B=`Connect(${R})`,W={shouldHandleStateChanges:k,displayName:B,wrappedComponentName:R,WrappedComponent:E,initMapStateToProps:y,initMapDispatchToProps:w,initMergeProps:v,areStatesEqual:a,areStatePropsEqual:l,areOwnPropsEqual:c,areMergedPropsEqual:h};function F(Z){const[le,xe,fe]=b.useMemo(()=>{const{reactReduxForwardedRef:Ye,...st}=Z;return[Z.context,Ye,st]},[Z]),te=b.useMemo(()=>{let Ye=x;return le?.Consumer,Ye},[le,x]),ke=b.useContext(te),$e=!!Z.store&&!!Z.store.getState&&!!Z.store.dispatch,Y=!!ke&&!!ke.store,Ae=$e?Z.store:ke.store,lt=Y?ke.getServerState:Ae.getState,Ce=b.useMemo(()=>kN(Ae.dispatch,W),[Ae]),[ye,_e]=b.useMemo(()=>{if(!k)return XN;const Ye=Gy(Ae,$e?void 0:ke.subscription),st=Ye.notifyNestedSubs.bind(Ye);return[Ye,st]},[Ae,$e,ke]),je=b.useMemo(()=>$e?ke:{...ke,subscription:ye},[$e,ke,ye]),re=b.useRef(void 0),Pe=b.useRef(fe),Se=b.useRef(void 0),Ee=b.useRef(!1),Be=b.useRef(!1),Ne=b.useRef(void 0);uf(()=>(Be.current=!0,()=>{Be.current=!1}),[]);const oe=b.useMemo(()=>()=>Se.current&&fe===Pe.current?Se.current:Ce(Ae.getState(),fe),[Ae,fe]),He=b.useMemo(()=>st=>ye?tR(k,Ae,ye,Ce,Pe,re,Ee,Be,Se,_e,st):()=>{},[ye]);JN(eR,[Pe,re,Ee,fe,Se,_e]);let rt;try{rt=b.useSyncExternalStore(He,oe,lt?()=>Ce(lt(),fe):oe)}catch(Ye){throw Ne.current&&(Ye.message+=`
70
+ `),dr(ge),gr(ge,!1),kt("Terminal session ended"),ae(!1),cr(!1),sn(null),Gn(null),mn(ge,!1),On();break}}},onError:(O,ge)=>{if(Dt.current!==T)return;const ve=Y;if(!ve)return;z.current=!1,be.current=!1,ae(!1);const Oe=ge&&O.message==="Authentication required",Xe=Sx(O),pt=Oe?O.message:Xe||ge?"Reconnecting...":O.message||"Terminal stream connection error";console.error(`[Terminal] Stream error (fatal=${ge}):`,pt),Xe&&console.warn("[Terminal] SESSION_NOT_FOUND_DETECTED",{terminalIdAtError:Lr.current,frontendSessionId:ve,isActive:l,isMobile:Be,fatal:ge,stack:new Error().stack}),kt(pt),cr(!!ge),ge&&(sn(null),gr(ve,!1),On(),Xe&&(ye("[onError] Session lost, auto-recreating"),kt("Reconnecting..."),cr(!1),dr(ve),hn(ve),Lr.current=null,Ri.current=!1,Es()))}},{...ME,getDimensions:()=>xr.current?.getDimensions()??null});dn.current=()=>{Q.close(),Dt.current===T&&(Kn.current=null)},Kn.current=ce},[Hr,hn,dr,ye,On,an,W,Ws,Es,ia,gr,Sn,Qr,mn,ir,Wr,Ce,Y]);_.useEffect(()=>{const ce=vE({isActive:l,isStreamReady:H,reconnectStartedAt:Zn,now:Date.now()});if(ce===null)return;const T=window.setTimeout(()=>{ye("[Terminal] visible reconnect watchdog expired",{backendSessionId:Lr.current,reconnectStartedAt:Zn}),On(),gr(Y,!1),kt("Reconnecting..."),cr(!1),sn(Date.now()),Es()},ce);return()=>window.clearTimeout(T)},[ye,On,l,H,Zn,Es,Y,gr]);const Ri=_.useRef(!1),Pa=_.useRef(!1),mi=_.useRef(0);_.useEffect(()=>()=>{mi.current+=1,Ri.current=!1,On()},[On]);const dl=_.useRef(K),Js=_.useRef(Ue);_.useEffect(()=>{const ce=dl.current,T=Js.current;dl.current=K,Js.current=Ue,Nr.current===Y&&(ce===K&&T===Ue||(Ri.current=!1,On(),kr(j=>j+1)))},[K,Ue,On,Y]),_.useEffect(()=>{if(Nr.current!==Y&&(ye(`[useEffect] sessionId changed from ${Nr.current} to ${Y}, allowing reinitialization`),Ri.current=!1,Pa.current=!1),Ri.current&&Nr.current===Y){ye(`[useEffect] Already initialized for sessionId=${Y}, skipping`);return}if(!Mt)return;const ce=async ge=>{if(ye(`[ensureSession] Starting for sessionId=${Y}, runId=${ge}`),!Nr.current||Nr.current!==Y){ye(`[ensureSession] SessionId mismatch or stale run (current=${Nr.current}, target=${Y}), skipping`);return}if(ge!==mi.current){ye(`[ensureSession] Stale run detected (runId=${ge}, currentRunId=${mi.current}), skipping`);return}const ve=Yr.getState(),Oe=ve.getTerminalSession(Y),Xe=Oe?.mode??K;ye("[ensureSession] Current state from store:",{terminalSessionId:Oe?.terminalSessionId,mode:Oe?.mode,tmuxSessionName:Oe?.tmuxSessionName,isConnecting:Oe?.isConnecting});let pt=Oe?.terminalSessionId??null,Jt=!pt;if(pt&&Xe!==K?(ye(`[ensureSession] Store mode mismatch for ${pt}: current=${Xe} desired=${K}, will create new session`),Jt=!0,ve.clearTerminalSession(Y),pt=null):pt&&K==="tmux"&&Ue&&Oe?.tmuxSessionName!==Ue&&(ye(`[ensureSession] Store tmux name mismatch for ${pt}: current=${Oe?.tmuxSessionName} desired=${Ue}, will create new session`),Jt=!0,ve.clearTerminalSession(Y),pt=null),pt&&Ce.checkHealth&&!_t.current){ye(`[ensureSession] Checking health of existing session ${pt}`);try{const fr=await Ce.checkHealth(pt);if(ye("[ensureSession] Health check result:",fr),!fr.healthy)ye(`[ensureSession] Session ${pt} is NOT healthy (healthy=${fr.healthy}), will create new session`),ye("[ensureSession] Health check details:",fr),Jt=!0,fr.mode&&Oe?.terminalSessionId&&ve.setTerminalSession(Y,{sessionId:Oe.terminalSessionId,cols:80,rows:24,mode:fr.mode,tmuxSessionName:fr.tmuxSessionName??null}),ve.clearTerminalSession(Y),ye("[ensureSession] Cleared unhealthy session from store");else{ye(`[ensureSession] Session ${pt} is healthy, reusing it, cwd=${fr.cwd}, clients=${fr.clients}, lastActivity=${Date.now()-(fr.lastActivity||0)}ms ago`),fr.mode&&Oe?.terminalSessionId&&ve.setTerminalSession(Y,{sessionId:Oe.terminalSessionId,cols:80,rows:24,mode:fr.mode,tmuxSessionName:fr.tmuxSessionName??null}),ye(`[ensureSession] Setting terminalIdRef to ${pt} and starting stream`),Lr.current=pt,Ni(pt),ye(`[ensureSession] Successfully reused healthy session ${pt}, returning early`);return}}catch(fr){ye(`[ensureSession] Failed to check health of session ${pt}:`,fr),ye("[ensureSession] Health check API call failed, proceeding as if session might be unhealthy")}}if(ye(`[ensureSession] Decision: shouldCreateNewSession=${Jt}, terminalId=${pt}`),Jt){ye(`[ensureSession] Creating new session, shouldCreateNewSession=${Jt}, runId=${ge}`),kt(null),cr(!1),ve.setConnecting(Y,!0);const Ur=Yr.getState().getTerminalSession(Y),Fn=(Ur?.mode??K)===K&&(K!=="tmux"||!Ue||Ur?.tmuxSessionName===Ue);if(Ur?.terminalSessionId&&Fn)ye(`[ensureSession] Race condition avoided: another instance already created session ${Ur.terminalSessionId}`),ve.setConnecting(Y,!1),pt=Ur.terminalSessionId,Jt=!1;else try{const mr=await Ba();if(ye(`[ensureSession] Opened managed backend session ${mr.sessionId}`),ge!==mi.current){ye(`[ensureSession] Stale run after session creation (runId=${ge}, currentRunId=${mi.current}), leaving ${mr.sessionId} for sibling`);return}ve.setTerminalSession(Y,mr),ye(`[ensureSession] Updated store with new session ${mr.sessionId}`),pt=mr.sessionId}catch(mr){if(ge!==mi.current){ye("[ensureSession] Stale run after session creation failed, skipping error handling");return}if(mr instanceof W0&&Km(mr)){ye("[ensureSession] Confirmed missing persisted session:",{sessionId:Y,error:mr.message}),ve.clearTerminalSession(Y),kt(Ph),cr(!0),ve.setConnecting(Y,!1);return}kt("Reconnecting..."),cr(!0),ve.setConnecting(Y,!1);return}}if(ge!==mi.current){ye(`[ensureSession] Stale run before starting stream (runId=${ge}, currentRunId=${mi.current}), skipping`);return}if(!pt){ye(`[ensureSession] No terminalId, terminalId=${pt}`);return}ye(`[ensureSession] Starting stream for session ${pt}`),Lr.current=pt,Ni(pt),ye(`[ensureSession] ensureSession completed for sessionId=${Y}, terminalId=${pt}`)};let T=null,j=null;const Q=()=>{j=null,!(Ri.current&&Nr.current===Y)&&(ye(`[useEffect] Running ensureSession for sessionId=${Y}, hasInitialized=${Ri.current}`),Ri.current=!0,Pa.current=!0,T=++mi.current,ce(T))};if(!E&&!Pa.current){ye(`[useEffect] Holding background connection until the selected session is ready: ${Y}`);return}const O=Pa.current?0:Math.max(0,L);return O>0?(ye(`[useEffect] Delaying initial connection for sessionId=${Y} by ${O}ms`),j=window.setTimeout(Q,O)):Q(),()=>{j!==null&&window.clearTimeout(j),ye(`[useEffect] Cleanup for sessionId=${Y}, runId=${T??"pending"}`)}},[Y,ln,Ni,On,Ce,ye,K,Ue,Dr,L,E,Mt]);const Fo=_.useCallback(async()=>{if(Y&&!_n){Ls(!0),kt(null),cr(!1),sn(null),On();try{Ce.forceKill&&await Ce.forceKill({sessionId:Y})}catch{}Tn(Y),hn(Y),xr.current?.clear(),await new Promise(ce=>setTimeout(ce,100));try{gr(Y,!0);const ce=await Ba();Cr(Y,ce),Lr.current=ce.sessionId,Ni(ce.sessionId)}catch(ce){kt(ce instanceof W0&&Km(ce)?Ph:"Reconnecting..."),cr(!0),gr(Y,!1)}finally{Ls(!1)}}},[Y,_n,On,Ce,Tn,hn,gr,Cr,Ni,Ba]),oa=_.useCallback((ce,T,j,Q)=>{if(!(Lr.current!==T||ot.current!==j)){if(ce instanceof W0&&Sx(ce)){ye("[Terminal] operation backend missing, recovering",{terminalId:T,sessionId:Y}),kt("Reconnecting..."),cr(!1),On(),dr(Y),Lr.current=null,gr(Y,!0),Es();return}kt(ce instanceof Error?ce.message:Q)}},[dr,ye,On,Es,Y,gr]),xo=_.useCallback((ce,T)=>{const j=T?.ownedPaste?VC(T.ownedPaste,Y,ce):!1;if(T?.ownedPaste&&!j||jt.current||(Fr.current||S1())&&!j)return Promise.resolve(!1);const Q=()=>!!T?.ownedPaste&&qC(T.ownedPaste,Y)&&_t.current&&!jt.current&&be.current&&!tr.current&&!document.hidden&&navigator.onLine!==!1&&hu();if(j&&!Q())return Promise.resolve(!1);if(!_t.current&&!T?.targeted||!ce)return;const O=$I(ce),ge=/^(\x1b\[<6[45];[0-9]+;[0-9]+M)+$/.test(ce);if(Or&&ge&&(ps.current=!0),Date.now()<Rn.current)return;let ve=ce,Oe=T?.consumeModifier??!1;if(!T?.skipModifierTransform&&Lt&&ce.length>0){const Ur=ce[0];if(Ur.length===1&&/[a-zA-Z]/.test(Ur)){const Jr=Ur.toUpperCase();Lt==="ctrl"?(ve=String.fromCharCode(Jr.charCodeAt(0)&31),Oe=!0):Lt==="alt"&&(ve=`\x1B${ce}`,Oe=!0)}Oe||(Lt==="alt"&&(ve=`\x1B${ce}`),Oe=!0)}const Xe=Lr.current;if(!Xe)return;const pt=ot.current,fr=(async()=>{try{if(Or&&!O&&ps.current&&Ce.tmuxAction){ps.current=!1;try{await Ce.tmuxAction(Xe,{action:"copy-mode",enabled:!1})}catch{}if(Lr.current!==Xe||ot.current!==pt)return!1;if(UI(ve))return!0}return j&&(!Q()||Lr.current!==Xe||ot.current!==pt)||(await Ce.sendInput(Xe,ve),j&&(!Q()||Lr.current!==Xe||ot.current!==pt))?!1:(fs(Y),!0)}catch(Ur){return oa(Ur,Xe,pt,"Failed to send input"),!1}})();return Oe&&(Ge||pe(null),ws()),fr},[Lt,fs,ws,oa,Or,Ge,Y,Ce]);_.useEffect(()=>{const ce=T=>{const j=T,Q=j.detail?.sessionId;if(Q?Q!==Y:!_t.current)return;const O=j.detail?.text;if(!O)return;const ge=j.detail?.nonce;if(tr.current||!xr.current){ge&&window.dispatchEvent(new CustomEvent("termdock-insert-reference-ack",{detail:{nonce:ge,ok:!1}}));return}const ve=GC(j.detail,Y),Oe=j.detail?.ownedPaste&&!ve?Promise.resolve(!1):xr.current.sendSequence(O,{paste:j.detail?.paste,submitAfterPaste:j.detail?.submitAfterPaste,targeted:!!Q,ownedPaste:ve??void 0});ge&&Promise.resolve(Oe).then(Xe=>{window.dispatchEvent(new CustomEvent("termdock-insert-reference-ack",{detail:{nonce:ge,ok:Xe===!0}}))},()=>{window.dispatchEvent(new CustomEvent("termdock-insert-reference-ack",{detail:{nonce:ge,ok:!1}}))}),LC(qr.current,j.detail?.focus!==!1)&&ws()};return window.addEventListener("termdock-insert-reference",ce),()=>window.removeEventListener("termdock-insert-reference",ce)},[ws,Y]);const Ta=_.useCallback((ce,T,j)=>{const Q=Lr.current;if(!Q){_e("xterm resize push skipped: no terminalId",{cols:ce,rows:T});return}_e("xterm resize push",{cols:ce,rows:T}),Ce.resize({sessionId:Q,cols:ce,rows:T,seq:j}).catch(O=>{xr.current?.acknowledgeResize({seq:j,ok:!1}),O&&/session not found/i.test(String(O.message||O))&&console.warn("[Terminal] resize 404 session not found",{sessionId:Q,cols:ce,rows:T,stack:new Error().stack})})},[Ce,_e]),ls=_.useCallback(async ce=>{const T=Lr.current;if(!T||!Ce.tmuxAction)return;const j=ot.current;try{const Q=await Ce.tmuxAction(T,ce);if(Lr.current!==T||ot.current!==j)return;Q.layout&&(Gn(Q.layout),ce.action==="switch-session"&&(Cr(Y,{sessionId:T,cols:80,rows:24,mode:"tmux",tmuxSessionName:Q.layout.sessionName}),tw(Y,{tmuxSessionName:Q.layout.sessionName}).catch(O=>{console.warn("[Terminal] failed to update inventory after tmux switch",O)})))}catch(Q){oa(Q,T,j,"Failed to execute tmux action")}},[oa,Y,Cr,Ce]);_.useEffect(()=>{if(!$r||!Xr)return;const T=$r.windows.find(j=>j.id===$r.activeWindowId)?.panes.find(j=>j.id===$r.activePaneId);T&&xr.current?.requestRefresh("tmux-layout",{skipScrollToBottom:!0,dedupeKey:`${Xr}:${$r.sessionId}:${T.id}:${T.width}x${T.height}`})},[$r,Xr]);const gi=_.useCallback((ce,T=5)=>{const j=Math.max(1,Math.min(Math.floor(T)||1,40));ps.current=!0;const Q=G.current;if(Q&&Q.direction===ce){Q.lines+=j;return}Q&&ls({action:"scroll",direction:Q.direction,lines:Q.lines}).finally(()=>{ws()}),G.current={direction:ce,lines:j},Le.current&&clearTimeout(Le.current),Le.current=setTimeout(()=>{const O=G.current;O&&(G.current=null,ls({action:"scroll",direction:O.direction,lines:O.lines}).finally(()=>{ws()}))},0)},[ws,ls]),bo=_.useCallback(ce=>{const T=Date.now(),j=ct.current,Q=j!==null&&j.modifier===ce&&T-j.timestamp<=IE;if(ct.current={modifier:ce,timestamp:T},Ge===ce){ft(null),pe(null);return}if(Q){ft(ce),pe(ce);return}Ge!==null&&Ge!==ce&&ft(null),pe(O=>O===ce?null:ce)},[Ge]),hl=_.useCallback(ce=>{if(Ye(ce&&_t.current),_e("input focus changed",{focused:ce,isActive:_t.current,isMobile:qr.current}),!qr.current||!_t.current){mt(!1);return}mt(T=>T===ce?T:ce)},[_e]),$o=_.useCallback(ce=>{if(os.current=ce,Ws(ce,"viewport-watermark"),!ce&&Nn.current.length>0){const T=Y;if(T){const j=Nn.current;Nn.current=[];for(const Q of j)Hr(T,Q)}}},[Hr,Ws,Y]),gs=_.useCallback(ce=>{_t.current&&xr.current?.ensureSizeMatches(ce)},[]),la=_.useRef(null);_.useEffect(()=>{if(!l)return;const ce=la.current;if(!ce)return;const T=()=>gs("pointerdown"),j=()=>gs("keydown"),Q=()=>gs("touchstart"),O=()=>gs("wheel");return ce.addEventListener("pointerdown",T),ce.addEventListener("keydown",j),ce.addEventListener("touchstart",Q,{passive:!0}),ce.addEventListener("wheel",O,{passive:!0}),()=>{ce.removeEventListener("pointerdown",T),ce.removeEventListener("keydown",j),ce.removeEventListener("touchstart",Q),ce.removeEventListener("wheel",O)}},[l,gs]);const Nl=_.useCallback(ce=>{xr.current=ce},[]),Jn=_.useCallback(ce=>{vt(ce),F?.(Y,ce)},[F,Y]),xi=_.useCallback(ce=>{const T=ZI(ce);if(!T)return;const j=Lt!==null;xr.current?.sendSequence(T,{consumeModifier:j})},[Lt]),ss=_.useCallback(ce=>{const T=WI(ce);if(T.length===0)return;const j=Lt!==null;xr.current?.sendSequence(wx(T[0]),{consumeModifier:j});for(let Q=1;Q<T.length;Q+=1){const O=T[Q];window.setTimeout(()=>{xr.current?.sendSequence(wx(O))},HI*Q)}},[Lt]),Oa=_.useCallback(()=>{xr.current?.pasteClipboardText()},[]),ys=_.useCallback(ce=>{qt.current!==null&&(window.clearTimeout(qt.current),qt.current=null),gt(ce),(ce==="inserted"||ce==="failed")&&(qt.current=window.setTimeout(()=>{qt.current=null,gt("idle")},1400))},[]),Uo=_.useCallback(()=>{ys("idle"),It(0),cn.current?.click()},[ys]),Gs=_.useCallback(()=>{rn(!0)},[]),Ui=_.useCallback(ce=>{const T=ce.currentTarget.files?.[0];if(ce.currentTarget.value="",!T)return;const j=Y;_r(null),pr(null),Ir(null),It(0),ys("uploading");const Q=sr&&T.type.startsWith("video/")?{maxHeight:An,videoBitrate:on,onProgress:It}:null,O=Me&&NE(T)?{maxDimension:nt,quality:wt}:null;let ge=Q?"视频压缩":O?"图片压缩":"文件上传";(async()=>{const ve=Q?await(await kc(async()=>{const{compressVideoLocally:Oe}=await import("./videoCompression-ivJAy00d.js");return{compressVideoLocally:Oe}},__vite__mapDeps([0,1,2,3,4,5]))).compressVideoLocally(T,Q):O?await(await kc(async()=>{const{compressImageLocally:Oe}=await import("./imageCompression-DaUBNTq-.js");return{compressImageLocally:Oe}},[])).compressImageLocally(T,O):T;ge="文件上传",await _E(ve,(Oe,Xe)=>vd(Oe,Xe,void 0,It),Oe=>(ge="插入终端",kx(Xm(Oe,null),j,()=>_t.current&&!tr.current&&Nr.current===j&&Yr.getState().activeSessionId===j))),(Q||O)&&Ir({file:ve,kind:Q?"video":"image",originalSize:T.size,uploadedSize:ve.size,originalRetained:ve===T})})().then(()=>ys("inserted"),ve=>{ve instanceof lf&&_r({path:ve.uploaded.path,sessionId:j});const Oe=ve instanceof lf?ve.uploaded.path:Nx(ve);pr({stage:ge,detail:Oe}),rn(!0),ys("failed"),va("warn","MOBILE_MEDIA_UPLOAD failed",{stage:ge,detail:Oe})})},[on,sr,An,Me,nt,wt,Y,ys]),ca=_.useCallback(async()=>{const ce=nr;if(!ce||ce.sessionId!==Y)return;rn(!1),await new Promise(j=>window.requestAnimationFrame(()=>j())),ys("uploading"),await kx(Xm(ce.path,null),ce.sessionId,()=>_t.current&&!tr.current&&Nr.current===ce.sessionId&&Yr.getState().activeSessionId===ce.sessionId)?(_r(null),pr(null),ys("inserted")):(rn(!0),ys("failed"))},[nr,Y,ys]);_.useEffect(()=>{if(!Mr||!sr)return;let ce=!0;return zt(null),ne({phase:"checking-cache"}),kc(async()=>{const{prepareLocalVideoCompression:T}=await import("./videoCompression-ivJAy00d.js");return{prepareLocalVideoCompression:T}},__vite__mapDeps([0,1,2,3,4,5])).then(({prepareLocalVideoCompression:T})=>{if(ce)return T(j=>{ce&&ne(j)})}).catch(T=>{ce&&zt(Nx(T))}),()=>{ce=!1}},[Mr,sr]);const jn=Pr||Et!==null;tr.current=jn;const bi=_.useRef(Kr);jn||(bi.current=Kr);const Mi=jn?bi.current:Kr,Ca=_.useMemo(()=>GI(Mi,nn),[Mi,nn]),zi=_.useMemo(()=>Tx(nn,Vt),[Vt,nn]),yi=!Be&&Vt!=="auto"&&zi.id!=="default"&&zi.showOnDesktop!==!0?"auto":Vt,ei=yi==="auto"?Ca:yi,Rs=_.useMemo(()=>Tx(nn,ei),[ei,nn]),js=_.useMemo(()=>Rs.actions.filter(ce=>ce.sequence.trim().length>0).map((ce,T)=>({...ce,label:Zm(ce,T)})),[Rs.actions]),ti=_.useMemo(()=>Ly(Kr),[Kr]),Fa=Rs.label,ji=_.useMemo(()=>yi!=="auto"?`Manual preset: ${Rs.label}`:ti?`Auto preset · ${Rs.label} (${ti})`:"Auto preset",[ti,yi,Rs.label]),es=_.useCallback(ce=>{Ve(ce)},[]),ua=_.useCallback(()=>{er(ce=>ce==="copy"?"arrows":"copy"),Ct("idle")},[]),yo=_.useCallback(()=>{typeof window>"u"||(ar.current!==null&&window.clearTimeout(ar.current),ar.current=window.setTimeout(()=>{ar.current=null,Ct("idle")},1200))},[]),Sa=_.useCallback(ce=>{ar.current!==null&&typeof window<"u"&&(window.clearTimeout(ar.current),ar.current=null),Ct(ce?"copied":"failed"),yo()},[yo]),zo=_.useCallback(ce=>{at(ce)},[]),Ho=_.useMemo(()=>Be?VI(nn):qI(nn),[Be,nn]),Hi=_.useMemo(()=>rw(a),[a]);_.useEffect(()=>{if(!Or||!H||!Mt||!Xr)return;const ce=iS(Hi);ce&&Ce.sendInput(Xr,ce).catch(T=>{console.warn("[Terminal] Failed to synchronize tmux default colors:",T)})},[Or,H,Mt,Xr,Ce,Hi]);const vo=_.useMemo(()=>`terminal::${Y}`,[Y]);_.useEffect(()=>{ke?.({isConnecting:Pr,isRestarting:_n,hasError:!!Et,sessionId:Xr})},[Pr,_n,Et,Xr,ke]);const da=!Xr||Pr||_n,$a=_.useCallback((ce,T)=>{if(da)return;const j=Math.max(1,Math.min(Math.floor(T)||1,40));gi(ce,j)},[gi,da]);_.useEffect(()=>{if(!l||!Be)return;xr.current?.requestRefresh("resize",{skipScrollToBottom:!Xt,force:!0})},[l,Be,Xt,Ut,Y]),_.useEffect(()=>{if(!l||!Be)return;const ce=T=>{const j=T.detail;xr.current?.requestRefresh("resize",{skipScrollToBottom:j?.isOpen!==!0,force:!0})};return document.addEventListener("termdock:viewport-keyboard-change",ce),()=>{document.removeEventListener("termdock:viewport-keyboard-change",ce)}},[l,Be,Y]);const wo=!Z&&(Be||Rs.id==="default"||Rs.showOnDesktop===!0),ha=l,As=Be&&!xe?{transform:"translateY(var(--kb-translate-y, 0px))",transition:"none"}:void 0,Di=Be&&!xe?{marginTop:"var(--kb-margin-top, 0px)",transition:"none"}:void 0,xs=s.jsx(KI,{visible:wo,interactive:ha,presentation:Be?"mobile":"desktop-actions",activeModifier:Lt,lockedModifier:Ge,disabled:da,defaultShowExtended:q,presetLabel:Fa,presetModeLabel:ji,presetMode:yi,presetOptions:Ho,includeAlt:Rs.includeAlt,presetRowLayout:Rs.rowLayout,extraActions:js,onKeyPress:xi,onTextPress:ss,onPastePress:Be?Oa:void 0,onFilePress:Be?Uo:void 0,onFileLongPress:Be?Gs:void 0,fileUploadState:Nt,fileUploadProgress:bt,longPressMode:De,copyFeedback:et,onLongPressModeToggle:ua,onModifierToggle:bo,onPresetSelect:es,onExpandedChange:zo}),Rl=typeof window<"u"&&(navigator.maxTouchPoints>0||"ontouchstart"in window);return s.jsxs("div",{className:"relative flex h-full min-h-0 flex-col overflow-hidden",style:As,children:[s.jsx("input",{ref:cn,type:"file",className:"hidden",onChange:Ui}),Mr&&Li.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop cursor-default bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>rn(!1),"aria-label":$e("common.close")}),s.jsxs("section",{role:"dialog","aria-modal":"true","aria-labelledby":"mobile-video-compression-title",className:"fixed bottom-[max(0.75rem,env(safe-area-inset-bottom,0px))] left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] z-modal-panel max-h-[calc(100dvh-1.5rem)] overflow-y-auto rounded-2xl border border-border/15 bg-surface p-4 shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)] sm:left-1/2 sm:right-auto sm:w-[min(28rem,calc(100vw-2rem))] sm:-translate-x-1/2",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h2",{id:"mobile-video-compression-title",className:"text-sm font-semibold text-foreground",children:"本地媒体压缩"}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"按文件类型选择压缩方式,处理完成后才上传。"})]}),s.jsx("button",{type:"button",className:"min-h-10 rounded-lg bg-surface-2 px-3 text-xs",onClick:()=>rn(!1),children:$e("common.close")})]}),yt&&s.jsxs("div",{role:"alert",className:"mt-3 rounded-lg bg-destructive/10 p-3 text-xs text-destructive",children:[s.jsxs("p",{children:[yt.stage,"失败。",yt.stage.endsWith("压缩")?"原文件未上传。":yt.stage==="插入终端"?"文件已上传,路径见详情。":""]}),s.jsxs("details",{className:"mt-2",children:[s.jsx("summary",{className:"cursor-pointer",children:"错误详情"}),s.jsx("p",{className:"mt-2 max-h-40 overflow-auto whitespace-pre-wrap break-words",children:yt.detail})]}),nr&&s.jsx("button",{type:"button",onClick:()=>{ca()},disabled:Nt==="uploading"||nr.sessionId!==Y,className:"mt-2 rounded-lg bg-surface-2 px-3 py-2 text-foreground disabled:opacity-50",children:$e("common.retry")})]}),dt&&s.jsx("p",{className:"mt-2 text-[11px] text-destructive",children:"本机未能保存设置,重新打开后可能恢复默认值。"}),s.jsxs("label",{className:"mt-4 flex min-h-11 items-center justify-between rounded-xl bg-surface-elevated px-3 text-sm",children:[s.jsx("span",{children:"显示压缩结果提示"}),s.jsx("input",{type:"checkbox",checked:Gr.showResultToast,onChange:ce=>it({showResultToast:ce.target.checked}),className:"h-4 w-4 accent-primary"})]}),s.jsxs("label",{className:"mt-4 flex min-h-11 items-center justify-between rounded-xl bg-surface-elevated px-3 text-sm",children:[s.jsx("span",{children:"压缩图片后上传"}),s.jsx("input",{type:"checkbox",checked:Me,onChange:ce=>it({imageEnabled:ce.target.checked}),className:"h-4 w-4 accent-primary"})]}),Me&&s.jsxs("div",{className:"mt-3 space-y-3",children:[s.jsxs("label",{className:"block text-xs text-muted-foreground",children:["图片最长边",s.jsx("select",{value:nt,onChange:ce=>it({imageMaxDimension:Number(ce.target.value)}),className:"mt-1 block min-h-10 w-full rounded-lg bg-surface-2 px-3 text-sm text-foreground",children:Dy.map(ce=>s.jsxs("option",{value:ce,children:[ce," px",ce===640?" · 最省流量":ce===2048?" · 推荐":ce===4096?" · 保留更多细节":""]},ce))})]}),s.jsxs("label",{className:"block text-xs text-muted-foreground",children:["图片画质:",Math.round(wt*100),"%",s.jsx("input",{type:"range",min:K0.min,max:K0.max,step:K0.step,value:wt,onChange:ce=>it({imageQuality:Number(ce.target.value)}),className:"mt-2 h-1 w-full accent-primary"})]}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:"支持 JPEG、PNG、HEIC 照片;GIF、SVG 等保持原文件。压缩后未变小也会保留原图。"})]}),s.jsx("div",{className:"mt-4 border-t border-border/15 pt-1"}),s.jsxs("label",{className:"mt-4 flex min-h-11 items-center justify-between rounded-xl bg-surface-elevated px-3 text-sm",children:[s.jsx("span",{children:"压缩视频后上传"}),s.jsx("input",{type:"checkbox",checked:sr,onChange:ce=>it({videoEnabled:ce.target.checked}),className:"h-4 w-4 accent-primary"})]}),sr&&s.jsxs("div",{className:"mt-4 space-y-4",children:[s.jsxs("label",{className:"block text-xs text-muted-foreground",children:["视频最长边(像素)",s.jsx("select",{value:An,onChange:ce=>it({videoMaxHeight:Number(ce.target.value)}),className:"mt-1 block min-h-10 w-full rounded-lg bg-surface-2 px-3 text-sm text-foreground",children:By.map(ce=>s.jsxs("option",{value:ce,children:[ce," px",ce===240?" · 最省流量":ce===720?" · 推荐":ce>=1440?" · 手机处理较慢":""]},ce))})]}),s.jsxs("label",{className:"block text-xs text-muted-foreground",children:["目标视频码率:",on/1e6," Mbps",s.jsx("input",{type:"range",min:X0.min,max:X0.max,step:X0.step,value:on,onChange:ce=>it({videoBitrate:Number(ce.target.value)}),className:"mt-2 h-1 w-full accent-primary"})]}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:"保持比例,不放大原视频。尺寸越小通常处理越快;码率越低体积通常越小,过高可能比原片更大。"}),s.jsx("p",{className:"text-[11px] text-muted-foreground",role:"status","aria-live":"polite",children:ht?"本地转码器准备失败,请关闭开关后重试。":RE(Er)}),Er?.saved===!1&&s.jsx("p",{className:"text-[11px] text-destructive",children:"本机未能保存转码器,重新打开后可能需要重新下载。"}),ht&&s.jsx("p",{className:"text-[11px] text-destructive",children:ht})]})]})]}),document.body),Vn&&s.jsx(XI,{isMobile:Be,isInputFocused:rt,isIOS:oe,isConnecting:Pr,connectionError:Et,terminalSessionId:Xr}),s.jsxs("div",{className:"relative min-h-0 flex-1 overflow-hidden",style:{backgroundColor:Hi.background,...Di},children:[s.jsx("div",{ref:la,className:"h-full w-full box-border",children:s.jsx(nw,{fallback:s.jsx("div",{className:"flex h-full items-center justify-center bg-background",children:s.jsxs("div",{className:"flex flex-col items-center gap-3 text-center rounded-2xl bg-surface-2 px-6 py-5 shadow-sm",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-destructive/15 flex items-center justify-center",children:s.jsx("svg",{className:"w-5 h-5 text-destructive",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),s.jsx("span",{className:"text-sm text-muted-foreground",children:$e("terminal.componentFailed")})]})}),children:s.jsx(jI,{ref:Nl,sessionKey:vo,sessionId:Y,isLayoutVisible:m,chunks:ks,onInput:xo,onResize:Ta,onFlowControl:$o,onTmuxScroll:Or?$a:void 0,tmuxScrollSensitivity:.38,onDoubleTap:Be?()=>{xr.current?.sendSequence(" ")}:void 0,onInputFocusChange:hl,onMobileLongPressCopyResult:Sa,onReadyChange:Jn,onSizeSynchronizedChange:Wt,onWritesSettled:Hs,onWriteProgress:Po,onCursorPositionChange:Aa,onDirectoryLinkActivate:fn,terminalSettings:Pe,theme:Hi,enableTouchScroll:Be,mobileLongPressMode:De,autoFocus:!Ee&&!Be&&!Rl,cursorVisible:!Ee&&Yt,suppressSmoothScroll:!Ze||!Tt,className:Ee||!Yt?"terminal-focus-suspended":void 0},vo)})}),s.jsx(LE,{result:un,onDismiss:me}),s.jsx(eE,{connectionError:Et,isFatalError:Br,isRestarting:_n,isConnecting:Pr,onHardRestart:Fo})]}),le?Z?null:Li.createPortal(xs,le):xs]})};function DE({session:e,active:t,onActivate:r,onToggleRightSidebar:n}){const{t:a}=zr(),c=Yr(l=>{const h=l.sessions.get(e.id);return sl(e,h?.activeProgram??null,h?.cwd??null,void 0,h?.shellTitle??null,h?.promptState??null).primary});return s.jsxs("div",{"data-pane-titlebar":"true",className:"swiper-no-swiping flex h-6 min-h-6 shrink-0 items-center border-b border-border app-chrome-bg",children:[s.jsxs("button",{type:"button","data-split-pane-title":e.id,draggable:!1,onDragStart:l=>l.preventDefault(),"aria-pressed":t,title:`${c} · 拖动标题移动,边缘拆分,中央交换`,onClick:r,className:"split-pane-drag-handle flex h-full min-w-0 cursor-grab active:cursor-grabbing flex-1 items-center gap-1.5 overflow-hidden px-2 text-left text-[12px] font-medium leading-none text-foreground hover:bg-surface focus-visible:outline focus-visible:outline-1 focus-visible:outline-primary focus-visible:-outline-offset-1",children:[s.jsx(Bo,{size:11,className:`shrink-0 ${t?"text-primary":"text-muted-foreground"}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:c}),s.jsx(If,{size:12,"aria-hidden":"true",className:"shrink-0 text-muted-foreground"}),t&&s.jsx("span",{"aria-hidden":"true",className:"h-1 w-1 shrink-0 rounded-full bg-primary"})]}),n&&s.jsx("button",{type:"button",onClick:n,"aria-label":a("tab.explorerTitle"),title:a("tab.explorerTitle"),className:"inline-flex h-full w-7 shrink-0 items-center justify-center text-muted-foreground hover:bg-surface hover:text-foreground focus-visible:outline focus-visible:outline-1 focus-visible:outline-primary focus-visible:-outline-offset-1",children:s.jsx(T3,{size:14})})]})}const BE="termdock:startup:";function vu(e){if(typeof performance>"u"||typeof performance.mark!="function")return;const t=`${BE}${e}`;performance.getEntriesByName(t,"mark").length>0||performance.mark(t)}function Rx(e,t){e||Li.flushSync(t)}const Jm="horizontal";function Cu(e){return e<=0?[]:Array.from({length:e},()=>1/e)}function Oh(e,t){if(!Array.isArray(e)||e.length!==t)return Cu(t);const r=e.map(Number);if(r.some(a=>!Number.isFinite(a)||a<=0))return Cu(t);const n=r.reduce((a,c)=>a+c,0);return n<=0?Cu(t):r.map(a=>a/n)}function QE(e){const t=Math.max(1,Math.ceil(Math.sqrt(Math.max(1,e))));return{columns:t,rows:Math.max(1,Math.ceil(Math.max(1,e)/t))}}function PE(e){return e==="horizontal"||e==="vertical"||e==="grid"}function OE(e){if(!Array.isArray(e))return[];const t=new Set,r=new Set,n=[];for(const a of e){if(!a||typeof a!="object")continue;const c=a;if(typeof c.id!="string"||!c.id||r.has(c.id))continue;const l=Array.isArray(c.sessionIds)?c.sessionIds.filter(m=>typeof m=="string"&&!!m&&!t.has(m)):[],h=[...new Set(l)];if(h.length<2)continue;const p=QE(h.length);h.forEach(m=>t.add(m)),r.add(c.id),n.push({id:c.id,...typeof c.name=="string"&&c.name.trim()?{name:c.name.trim().slice(0,80)}:{},sessionIds:h,layout:PE(c.layout)?c.layout:Jm,ratios:Oh(c.ratios,h.length),...c.gridColumnRatios!==void 0?{gridColumnRatios:Oh(c.gridColumnRatios,p.columns)}:{},...c.gridRowRatios!==void 0?{gridRowRatios:Oh(c.gridRowRatios,p.rows)}:{}})}return n}function FE(e,t){const r=new Set(t);return e.flatMap(n=>{const a=n.sessionIds.filter(c=>r.has(c));return a.length<2?[]:[{...n,sessionIds:a,ratios:a.length===n.sessionIds.length?Oh(n.ratios,a.length):Cu(a.length)}]})}function dd(e,t){if(t)return e.find(r=>r.sessionIds.includes(t))}function Wp(e,t,r){if(!t||!r||t===r)return e;const n=dd(e,t),a=dd(e,r);if(n&&n.id===a?.id)return e;const c=[...n?.sessionIds??[t],...a?.sessionIds??[r]],l=[...new Set(c)],h={id:n?.id??`split:${t}`,...n?.name?{name:n.name}:{},sessionIds:l,layout:l.length>2&&(!n||n.layout===Jm)?"grid":n?.layout??Jm,ratios:Cu(l.length)},p=new Set([n?.id,a?.id].filter(Boolean)),m=e.filter(y=>!p.has(y.id)),x=n?Math.max(0,e.findIndex(y=>y.id===n.id)):m.length;return m.splice(Math.min(x,m.length),0,h),m}function $E(e,t){const r=dd(e,t);if(!r||!t)return e;if(r.sessionIds.length<=2)return e.filter(a=>a.id!==r.id);const n=r.sessionIds.filter(a=>a!==t);return e.map(a=>a.id===r.id?{...a,sessionIds:n,ratios:Cu(n.length)}:a)}function UE(e,t){const r=dd(e,t);return r?e.filter(n=>n.id!==r.id):e}function zE(e,t,r){return e.map(n=>{if(n.id!==t)return n;const a=[...new Set(r)],c=new Set(n.sessionIds);return a.length===n.sessionIds.length&&a.every(h=>c.has(h))?{...n,sessionIds:a}:n})}function HE(e,t,r){const n=r.trim().slice(0,80);return e.map(a=>a.id===t?{...a,...n?{name:n}:{name:void 0}}:a)}const e1=320,Py=1,WE=e1+120,t1="termdock:split-workspaces:v2",Oy="termdock:split-workspace:v1",GE=.1,VE=.9;function Gp(){if(typeof window>"u")return{mobile:!1,landscape:!1};const t=(navigator.maxTouchPoints>0||"ontouchstart"in window)&&Math.min(window.innerWidth,window.innerHeight)<768;return{mobile:t,landscape:t&&window.innerWidth>window.innerHeight}}function qE(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem(t1);if(e)return OE(JSON.parse(e));const t=JSON.parse(window.localStorage.getItem(Oy)||"null");if(t&&typeof t.primaryId=="string"&&typeof t.secondaryId=="string"&&t.primaryId!==t.secondaryId){const r=Math.min(VE,Math.max(GE,typeof t.ratio=="number"?t.ratio:.5));return[{id:`split:${t.primaryId}`,sessionIds:[t.primaryId,t.secondaryId],layout:t.direction==="vertical"?"vertical":"horizontal",ratios:[r,1-r]}]}}catch{}return[]}function YE(e,t){const r=new Map(e.map(l=>[l.id,l])),n=new Map;t.forEach(l=>l.sessionIds.forEach(h=>n.set(h,l)));const a=new Set,c=[];for(const l of e){const h=n.get(l.id);if(!h){c.push({key:l.id,sessions:[l]});continue}if(a.has(h.id))continue;a.add(h.id);const p=h.sessionIds.flatMap(m=>{const x=r.get(m);return x?[x]:[]});p.length>=2&&c.push({key:h.id,sessions:p,workspace:h})}return c}function Mx(e){const t=e.wrapperEl;if(t)try{t.getAnimations().forEach(r=>r.cancel())}catch{}}function dh(e,t){const r=cf(e,t);if(r===null)return;const n=e.wrapperEl;Mx(e),n&&(n.style.transitionDuration="0ms");try{const a=e;a.setTransition?.(0),a.setTranslate?.(r),Mx(e),n&&(n.style.transitionDuration="0ms",n.style.transform=`translate3d(${r}px, 0px, 0px)`)}catch{n&&(n.style.transitionDuration="0ms",n.style.transform=`translate3d(${r}px, 0px, 0px)`)}}function r1(e){try{const t=typeof e.getTranslate=="function"?e.getTranslate():e.translate;return typeof t=="number"&&Number.isFinite(t)?t:null}catch{return typeof e.translate=="number"&&Number.isFinite(e.translate)?e.translate:null}}function cf(e,t){const r=e.snapGrid,n=Array.isArray(r)?r[t]:void 0;return typeof n!="number"||!Number.isFinite(n)?null:-n}function ZE(e,t){const r=r1(e),n=cf(e,t);return r!==null&&n!==null&&Math.abs(r-n)<=Py}function KE(e){const t=[],r=new Map,n=new Map,a=new Map;for(const c of e){const l=r.get(c.id)??[];if(l.push(c.id),r.set(c.id,l),c.sessionId){const h=n.get(c.sessionId)??[];h.push(c.id),n.set(c.sessionId,h)}if(c.mode==="tmux"&&c.tmuxSessionName){const h=a.get(c.tmuxSessionName)??[];h.push(c.id),a.set(c.tmuxSessionName,h)}}for(const[c,l]of r)l.length>1&&t.push({kind:"frontend",key:c,sessionIds:l});for(const[c,l]of n)l.length>1&&t.push({kind:"backend",key:c,sessionIds:l});for(const[c,l]of a)l.length>1&&t.push({kind:"tmux",key:c,sessionIds:l});return t}function Fy(e){const t=new Map;for(const r of e)t.set(r.id,r);return Array.from(t.values())}function $y(e){return{id:e.sessionId,name:e.name,customName:e.customName===!0,sessionId:e.backendSessionId,mode:e.mode==="tmux"||e.mode==="shell"?e.mode:"shell",tmuxSessionName:e.tmuxSessionName??null}}function XE(e,t){const r=Fy(e),n=r.findIndex(a=>a.id===t.id);if(n>=0){const a=[...r];return a[n]=t,a}return[...r,t]}function jx(e,t){const r=new Map(e.map(n=>[n.id,n]));return t.map(n=>{const a=r.get(n.sessionId);return{...$y(n),history:a?.history}})}function Dx(e,t){return e.length===0?null:t&&e.some(r=>r.sessionId===t)?t:e[0]?.sessionId??null}function Bx(e){if(!e||typeof e!="object")return"unknown";const t=e;if(typeof t.pointerType=="string"&&t.pointerType)return t.pointerType;if(typeof t.type=="string"){if(t.type.startsWith("touch"))return"touch";if(t.type.startsWith("mouse"))return"mouse";if(t.type.startsWith("pointer"))return"pointer"}return"unknown"}function Qx(e){const t=new Map;for(const[r,n]of e)t.set(r,n.cwd??null);return t}function JE(e,t){if(e.size!==t.size)return!1;for(const[r,n]of t)if(e.get(r)!==n)return!1;return!0}function eN(e){const t="".toLowerCase().replace(/[^a-z0-9_-]/g,"").slice(0,12);if(t)return`wt-${t}`;const r=Date.now().toString(36),n=Math.random().toString(36).slice(2,8);return`wt-${r}${n}`}const tN=({terminalSettings:e=F1(),colorTheme:t="dark",toolbarPresets:r=[],showDebug:n,terminalFocusAvailable:a=!0,defaultSessionMode:c="shell",defaultTmuxSessionName:l="",connectionPrioritySessionId:h=null,connectionPriorityReady:p=!0,desktopRightSidebarEnabled:m=!1,onToggleRightSidebar:x,desktopFloatingTitle:y=!1,desktopPinnedLeftSidebarWidth:w=0,desktopViewportWidth:v=0,onStatusChange:k,onSessionDataUpdate:L,onInitialViewportReady:E,onInitialRecoveryRequired:R})=>{const{t:B}=zr(),W=b.useMemo(()=>_u("session"),[]),F=b.useMemo(()=>_u("terminal"),[]),[U,V]=b.useState([]),[Z,le]=b.useState(null),xe=b.useRef(0),fe=b.useRef(0),te=ns(z=>z.activePaneId);b.useEffect(()=>{ns.getState().setActivePane(Z)},[Z]);const[ke,$e]=b.useState(null),[Y,Ae]=b.useState(!0),[lt,Ce]=b.useState({token:0,reason:"visibility",forceForegroundReconnect:!1}),[ye,_e]=b.useState(()=>new Set),[je,re]=b.useState(()=>({token:0,completed:new Set})),[Pe,Se]=b.useState(0),[Ee,Be]=b.useState(()=>new Set),[Ne,oe]=b.useState(()=>new Set),He=b.useRef(new Map),[rt,mt]=b.useState(()=>new Set),de=b.useRef(!1),Ye=b.useRef(null),st=b.useRef({}),[Ie,We]=b.useState(null),[Te,H]=b.useState(()=>qE()),[ae,be]=b.useState(!1),Ze=b.useCallback(z=>{xe.current+=1,be(z)},[]),Je=b.useRef(null),Tt=b.useRef(ae);Tt.current=ae,wd(Je,ae&&!!Z,()=>Ze(!1));const[Wt,Mt]=b.useState(null),[vt,Yt]=b.useState(null),Qt=b.useRef(new Set),[Xt,Ut]=b.useState(null),[Lt,pe]=b.useState(null),[Ge,ft]=b.useState(!1),[q,at]=b.useState(()=>Gp().mobile),[Vt,Ve]=b.useState(()=>Gp().landscape),[De,er]=b.useState(null),[et,Ct]=b.useState(null),Nt=b.useRef(a),gt=b.useRef(!1),bt=b.useRef(!1),It=b.useRef(null),yt=b.useRef(null),pr=b.useRef(q),nr=b.useRef(null),_r=b.useCallback(z=>{z!==nr.current&&(xe.current+=1),nr.current=z,le(z)},[]);b.useEffect(()=>Gt.subscribe((z,N)=>{(z.rightOpen!==N.rightOpen||z.rightTab!==N.rightTab)&&(xe.current+=1)}),[]);const un=b.useRef(0),Ir=b.useRef([]),me=b.useRef(0),Gr=b.useRef(null),it=b.useRef(!1),dt=b.useRef(!0),sr=b.useRef(null),An=b.useRef(""),on=b.useRef(0);b.useEffect(()=>{if(typeof window>"u")return;const z=()=>{const N=Gp();pr.current=N.mobile,at(N.mobile),Ve(N.landscape)};return z(),window.addEventListener("resize",z),()=>window.removeEventListener("resize",z)},[]);const{sessions:Me,inventory:nt,activeSessionId:wt,isLoading:Mr,openSession:rn,setActiveSession:Er,removeSession:ne,renameSession:ht,resetSessionCustomName:zt,reorderSessions:Pt,restoreSessions:Cr}=sw(),gr=nt?.tmuxRecovery??null;b.useEffect(()=>{gr&&R?.()},[gr,R]),b.useEffect(()=>{pe(null),Ut(null)},[gr?.id]);const Hr=b.useCallback(async()=>{Ut("restore"),pe(null);try{const z=await iw();await Cr(),z.failed>0&&pe(B("tab.tmuxRecoveryPartial",{restored:z.restored,failed:z.failed}))}catch{pe(B("tab.tmuxRecoveryFailed"))}finally{Ut(null)}},[Cr,B]),En=b.useCallback(async()=>{Ut("dismiss"),pe(null);try{await aw(),await Cr()}catch{pe(B("tab.tmuxRecoveryDismissFailed"))}finally{Ut(null)}},[Cr,B]),dr=Gt(z=>z.groupByFolder),Tn=Xh(z=>z.collaborationGroups),hn=Gt(z=>z.leftOpen||z.rightOpen),Sn=Gt(z=>z.rightSidebarWidthContextKey),ir=Gt(z=>z.rightSidebarWidth),mn=Gt(z=>z.rightPinned),[Qr,Vr]=b.useState(()=>Qx(Yr.getState().sessions));b.useEffect(()=>Yr.subscribe(z=>{const N=Qx(z.sessions);Vr($=>JE($,N)?$:N)}),[]);const{arranged:Wr}=b.useMemo(()=>Kh(U,z=>Qr.get(z.id)??null,dr,"",Te,Tn),[U,Qr,dr,Te,Tn]),fs=b.useRef(Wr);fs.current=Wr;const Dr=b.useMemo(()=>YE(Wr,Te),[Wr,Te]),Pn=b.useRef(Dr);Pn.current=Dr;const Sr=b.useMemo(()=>dd(Te,Z),[Z,Te]),Kr=b.useMemo(()=>{const z=Dr.find(N=>N.sessions.some($=>$.id===Z));return new Set(z?.sessions.map(N=>N.id)??[])},[Z,Dr]),nn=b.useMemo(()=>{const z=new Map;if(!m||v<=0)return z;for(const N of Dr){const $=N.sessions[0];if(!$)continue;const ee=ow($.id,Qr.get($.id)??null,N.workspace?.id??null);if(!(ee===Sn?mn:lw($.id,Qr.get($.id)??null,N.workspace?.id??null)))continue;const Qe=ee===Sn?ir:cw($.id,Qr.get($.id)??null,N.workspace?.id??null),ze=Ih(Qe,v,w);z.set(N.key,ze+i3)}return z},[Qr,w,m,mn,Sn,ir,v,Dr]),Or=b.useMemo(()=>zp(U.map(z=>({id:z.id,backendSessionId:z.sessionId})),h),[h,U]),ks=b.useMemo(()=>Dx(Me,wt),[wt,Me]),Pr=ch({prioritySessionId:Or,activeSessionId:ke??Z,persistedActiveSessionId:ks,firstSessionId:U[0]?.id??null}),Xr=b.useMemo(()=>wE(Dr.flatMap(z=>z.sessions.map(N=>N.id)),Kr),[Kr,Dr]),fn=Pr!==null&&ye.has(Pr),K=b.useMemo(()=>{const z=new Set(Kr);return ke&&z.add(ke),!z.size&&Pr&&z.add(Pr),z},[Kr,ke,Pr]),Ue=je.token===lt.token&&xE(K,je.completed),Et=Ue||Pe===lt.token?lt.token:-1;b.useEffect(()=>{if(!lt.token||Ue)return;const z=window.setTimeout(()=>Se(lt.token),aE);return()=>window.clearTimeout(z)},[lt.token,Ue]);const kt=b.useCallback((z,N)=>{_e($=>{if($.has(z)===N)return $;const se=new Set($);return N?se.add(z):se.delete(z),se})},[]),tr=b.useCallback(z=>{const N=un.current;re(ee=>{if(ee.token===N&&ee.completed.has(z))return ee;const se=new Set(ee.token===N?ee.completed:[]);return se.add(z),{token:N,completed:se}});const $=Or??ke??nr.current;z===$&&vu("foreground-stream-connected")},[ke,Or]),Br=b.useCallback((z,N)=>{Be($=>{if($.has(z)===N)return $;const ee=new Set($);return N?ee.add(z):ee.delete(z),ee})},[]),cr=b.useCallback((z,N)=>{oe($=>{if($.has(z)===N)return $;const ee=new Set($);return N?ee.add(z):ee.delete(z),ee})},[]);b.useEffect(()=>{for(const[z,N]of He.current){const $=U.find(ee=>ee.id===z);if(!$||$.sessionId!==N.backendSessionId){He.current.delete(z);continue}!ye.has(z)||!Ee.has(z)||!Ne.has(z)||(He.current.delete(z),s3(N.backendSessionId,`${N.command}\r`).catch(ee=>{console.error("[Session] Failed to send startup command:",ee)}))}},[U,ye,Ee,Ne]);const _n=Pr!==null&&Ee.has(Pr),Ls=Pr!==null&&Ne.has(Pr);b.useEffect(()=>{_n&&vu("foreground-viewport-ready")},[_n]),b.useEffect(()=>{Ls&&vu("foreground-content-ready")},[Ls]),b.useEffect(()=>{if(!E)return;if(!Y&&U.length===0){E();return}if(!_n||!fn||!Ls)return;const z=[...Kr].every(Qe=>Ee.has(Qe)&&ye.has(Qe)&&Ne.has(Qe));let N=0,$=0;const ee=()=>{N=requestAnimationFrame(()=>{$=requestAnimationFrame(()=>{vu("initial-viewport-presented"),E()})})};z&&ee();const se=z?void 0:window.setTimeout(ee,8e3);return()=>{cancelAnimationFrame(N),cancelAnimationFrame($),clearTimeout(se)}},[fn,Ls,_n,Y,E,U.length,Kr,Ee,ye,Ne]);const Zn=b.useMemo(()=>q?cE({slides:Dr.map(z=>z.sessions.map(N=>N.id)),visibleSessionIds:Kr,foregroundSessionId:Pr}):rt,[q,Dr,Kr,Pr,rt]);b.useEffect(()=>{if(q||Kr.size===0)return;const z=new Set(Kr),N=Dr.findIndex($=>$.sessions.some(ee=>Kr.has(ee.id)));for(let $=-2;$<=2;$+=1)$!==0&&Dr[N+$]?.sessions.forEach(ee=>z.add(ee.id));mt($=>{let ee=!1;const se=new Set($);for(const Qe of z)se.has(Qe)||(se.add(Qe),ee=!0);return ee?se:$})},[q,Kr,Dr]);const sn=$C(Zn);b.useEffect(()=>{if(!ke)return;if(!U.some(N=>N.id===ke)){$e(null);return}if(!Ee.has(ke)||!ye.has(ke)||!Ne.has(ke))return;const z=window.setTimeout(()=>{$e(N=>N===ke?null:N),Nt.current&&!pr.current&&We({sessionId:ke,token:Date.now()})},80);return()=>window.clearTimeout(z)},[Ne,ke,ye,U,Ee]),b.useEffect(()=>{typeof window>"u"||(Te.length>0?(window.localStorage.setItem(t1,JSON.stringify(Te)),window.localStorage.removeItem(Oy)):window.localStorage.removeItem(t1))},[Te]),b.useEffect(()=>{Mr||Y||Te.length===0||H(z=>FE(z,U.map(N=>N.id)))},[Mr,Y,U,Te.length]),b.useEffect(()=>{if(!Wt)return;const z=window.setTimeout(()=>Mt(null),3200);return()=>window.clearTimeout(z)},[Wt]),nr.current=Z,un.current=lt.token,Ir.current=U,Gr.current=wt,it.current=Mr,dt.current=Y,Nt.current=a;const ln=b.useCallback((z=Ye.current)=>{const N=me.current,$=typeof window<"u"?window.visualViewport:null,ee=z?r1(z):null,se=z?cf(z,N):null;return{sessionsLength:Ir.current.length,workspaceSlidesLength:Pn.current.length,sessionIds:Ir.current.map(Qe=>Qe.id),activeSessionId:nr.current,activeSessionIndex:N,persistedActiveId:Gr.current,isLoading:it.current,isRestoring:dt.current,activeIndex:z?.activeIndex??null,previousIndex:z?.previousIndex??null,animating:z?.animating??null,allowTouchMove:z?.allowTouchMove??null,width:z?.width??null,translate:ee,targetTranslate:se,translateDelta:ee!==null&&se!==null?ee-se:null,snapGridLength:z?.snapGrid?.length??null,targetSnap:z?.snapGrid?.[N]??null,visualViewport:$?{width:Math.round($.width),height:Math.round($.height),offsetTop:Math.round($.offsetTop)}:null}},[]),kr=b.useCallback((z,N)=>{W(z,{...ln(),...N})},[W,ln]);b.useEffect(()=>{Mr||Y||Z!==wt&&Er(Z)},[Z,Mr,Y,wt,Er]);const $r=b.useMemo(()=>{if(Wr.length===0||!Z)return 0;const z=Dr.findIndex(N=>N.sessions.some($=>$.id===Z));return z>=0?z:0},[Dr,Z]);me.current=$r;const Gn=b.useCallback(()=>{It.current&&(clearTimeout(It.current),It.current=null)},[]),Vn=b.useCallback(z=>{Gn(),It.current=setTimeout(()=>{It.current=null,gt.current=!1,kr("[swiper:touch-guard-clear]",{reason:z})},WE)},[Gn,kr]),dn=b.useCallback((z,N={})=>{const $=Ye.current,ee=me.current,se=Pn.current;if(!$||se.length===0||ee<0||ee>=se.length)return;if(gt.current){kr("[swiper:sync-skip-touch]",{reason:z});return}if($.animating){kr("[swiper:sync-skip-animating]",{reason:z});return}const Qe=r1($),ze=cf($,ee),xt=Qe!==null&&ze!==null&&Math.abs(Qe-ze)<=Py,_t=$.activeIndex===ee;if(kr("[swiper:sync-check]",{reason:z,activeIndexAligned:_t,translateAligned:xt,immediate:N.immediate===!0}),!(_t&&xt)){if(_t){dh($,ee),kr("[swiper:sync-forced-active]",{reason:z,translateAligned:xt,immediate:N.immediate===!0});return}N.immediate?(dh($,ee),$.slideTo(ee,0,!1),dh($,ee)):$.slideTo(ee,e1,!1),kr("[swiper:sync-applied]",{reason:z,activeIndexAligned:_t,translateAligned:xt,immediate:N.immediate===!0})}},[kr]);b.useEffect(()=>{const z=N=>{const $=N;Ye.current&&(Ye.current.allowTouchMove=!$.detail.locked),kr("[swiper:gesture-lock]",{locked:$.detail.locked})};return document.addEventListener("termdock:gesture-lock",z),()=>document.removeEventListener("termdock:gesture-lock",z)},[kr]),b.useEffect(()=>{if(U.length===0){Z!==null&&_r(null);return}if(!Z){if(!p)return;_r(ch({prioritySessionId:Or,activeSessionId:null,persistedActiveSessionId:ks,firstSessionId:U[0]?.id??null}));return}U.some(N=>N.id===Z)||_r(U[0].id)},[U,Z,p,Or,ks]);const Kn=b.useCallback((z,N)=>{if(N&&Date.now()<on.current){st.current[z]=!1;return}st.current[z]=N,Ct($=>N?z:$===z?null:$)},[]),Lr=b.useCallback(z=>{if(!gt.current&&z.activeIndex!==me.current){kr("[swiper:slide-change-ignored-layout]",{instanceActiveIndex:z.activeIndex,expectedActiveIndex:me.current}),requestAnimationFrame(()=>dn("ignored-layout-slide-change",{immediate:!0}));return}const N=Pn.current[z.activeIndex],$=N?.sessions.some(Qe=>Qe.id===Z)?Z:N?.sessions[0]?.id;if(kr("[swiper:slide-change]",{nextSessionId:$??null,instanceActiveIndex:z.activeIndex}),!$||$===Z)return;const ee=!!Z&&st.current[Z]===!0,se=Nt.current&&(!pr.current||ee);if(yt.current=$,_r($),se){We({sessionId:$,token:Date.now()});return}We(null)},[U,Z,kr,dn]);b.useLayoutEffect(()=>{if(yt.current===Z){kr("[swiper:sync-skip-swiper-driven]",{activeSessionId:Z}),yt.current=null;return}dn("active-session-index",{immediate:!0})},[Z,$r,U.length,dn,kr]),b.useEffect(()=>{const z=Ye.current;if(!z)return;const N=Dr.length>1&&!hn&&!ae;z.allowTouchMove!==N&&(z.allowTouchMove=N,kr("[swiper:allow-touch-sync]",{nextAllow:N,sidebarOverlayOpen:hn}))},[Dr.length,kr,hn,ae]);const Nr=b.useCallback(z=>{const N=Ye.current;if(!N)return;const $=N.el;if(kr("[swiper:layout-before]",{reason:z,scrollLeft:$?.scrollLeft??null}),$&&($.scrollLeft=0),N.updateSize(),N.updateSlides(),N.updateProgress(),N.updateSlidesClasses(),$&&($.scrollLeft=0),kr("[swiper:layout-after]",{reason:z,scrollLeft:$?.scrollLeft??null}),gt.current||N.animating){kr("[swiper:layout-skip-sync-motion]",{reason:z});return}dn(`layout:${z}`,{immediate:!0}),requestAnimationFrame(()=>{const ee=Ye.current;ee&&(gt.current||ee.animating||dh(ee,me.current))})},[kr,dn]);b.useEffect(()=>()=>Gn(),[Gn]);const xr=Dr.map(z=>z.key).join("\0");b.useEffect(()=>{requestAnimationFrame(()=>Nr("group-change"))},[dr,xr,Nr]),b.useEffect(()=>{let z=null,N="mount";const $=xt=>{N=xt,z===null&&(z=requestAnimationFrame(()=>{z=null,Nr(`viewport-change:${N}`)}))},ee=()=>$("window-resize"),se=()=>$("visual-viewport-resize"),Qe=()=>$("visual-viewport-scroll"),ze=xt=>{$(`measured:${xt.detail?.source??"unknown"}`)};return window.addEventListener("resize",ee),window.visualViewport?.addEventListener("resize",se),window.visualViewport?.addEventListener("scroll",Qe),document.addEventListener(Gg,ze),$("mount"),()=>{window.removeEventListener("resize",ee),window.visualViewport?.removeEventListener("resize",se),window.visualViewport?.removeEventListener("scroll",Qe),document.removeEventListener(Gg,ze),z!==null&&cancelAnimationFrame(z)}},[Nr]),b.useEffect(()=>{if(typeof document>"u")return;let z=null,N=null;const $=_t=>{if(_t!=="online"&&document.hidden)return;const Fr=performance.now();if(!bE(N,Fr))return;N=Fr;const jt=_t==="bfcache"||_t==="online"?_t:"visibility",qr=yE();dp(),va("info","PWA_RESUME scheduled",{source:_t,forceForegroundReconnect:qr,activeSessionId:nr.current}),Ce(pn=>({token:pn.token+1,reason:jt,forceForegroundReconnect:qr})),requestAnimationFrame(()=>Nr(`resume:${_t}:raf`)),z&&clearTimeout(z),z=setTimeout(()=>{z=null,Nr(`resume:${_t}:settled`)},320)},ee=()=>{if(document.hidden){dp();return}$("visibility")},se=()=>{dp()},Qe=_t=>{$(_t.persisted?"bfcache":"pageshow")},ze=()=>$("online"),xt=()=>$("focus");return document.addEventListener("visibilitychange",ee),window.addEventListener("pagehide",se),window.addEventListener("pageshow",Qe),window.addEventListener("online",ze),window.addEventListener("focus",xt),()=>{document.removeEventListener("visibilitychange",ee),window.removeEventListener("pagehide",se),window.removeEventListener("pageshow",Qe),window.removeEventListener("online",ze),window.removeEventListener("focus",xt),z&&clearTimeout(z)}},[Nr]),b.useLayoutEffect(()=>{if(!mE(Y))return;const z=KE(U),N=JSON.stringify(z);z.length>0&&N!==An.current?(An.current=N,console.warn("[session-invariant] duplicate mapping detected",z)):z.length===0&&An.current&&(An.current=""),L?.({sessions:U.map($=>({id:$.id,name:$.name,customName:$.customName,mode:$.mode,tmuxSessionName:$.tmuxSessionName})),activeSessionId:Z,splitWorkspaces:Te.map(({id:$,name:ee,sessionIds:se,layout:Qe})=>({id:$,...ee?{name:ee}:{},sessionIds:se,layout:Qe}))})},[U,Z,Te,L,Y]),b.useEffect(()=>{if(Mr||de.current)return;de.current=!0;const z=zp(Me.map(Qe=>({id:Qe.sessionId,backendSessionId:Qe.backendSessionId??null})),h),N=Dx(Me,wt),$=ch({prioritySessionId:p?z:null,activeSessionId:null,persistedActiveSessionId:N,firstSessionId:Me[0]?.sessionId??null}),ee=Fy(Me.map($y));if(W("[Session] Restoring",ee.length,"persisted sessions (one-shot)"),kr("[swiper:restore-start]",{persistedSessionIds:Me.map(Qe=>Qe.sessionId),nextActiveSessionId:$}),ee.length>0){const Qe=Yr.getState();ee.forEach(xt=>{xt.sessionId&&Qe.setTerminalSession(xt.id,{sessionId:xt.sessionId,cols:80,rows:24,mode:xt.mode,tmuxSessionName:xt.tmuxSessionName,history:xt.history})}),Me.forEach(xt=>{xt.agent!==void 0&&Qe.setSessionAgentIdentity(xt.sessionId,xt.agent),xt.activeProgram!=null&&Qe.setSessionActiveProgram(xt.sessionId,xt.activeProgram),xt.cwd!=null&&Qe.setSessionCwd(xt.sessionId,xt.cwd),xt.shellTitle!=null&&Qe.setSessionShellTitle(xt.sessionId,xt.shellTitle)}),V(ee);const ze=$||ee[0]?.id||null;_r(ze),kr("[swiper:restore-complete]",{restoredSessionIds:ee.map(xt=>xt.id),nextActiveSessionId:ze})}(async()=>(ee.length===0&&await sr.current?.({createIfEmpty:!0}),Ae(!1),requestAnimationFrame(()=>dn("restore-finished",{immediate:!0}))))()},[Mr,Me,wt,W,kr,dn,p,h]),b.useEffect(()=>{if(!p||Y||U.length===0)return;const z=zp(U.map($=>({id:$.id,backendSessionId:$.sessionId})),h),N=ch({prioritySessionId:z,activeSessionId:nr.current,persistedActiveSessionId:ks,firstSessionId:U[0]?.id??null});N&&N!==nr.current&&_r(N)},[p,h,Y,ks,U]);const os=b.useRef([]),Hn=b.useRef(!1);nr.current=Z,b.useEffect(()=>{if(Y)return;const z=os.current,N=Me,$=new Map(z.map(jt=>[jt.sessionId,jt])),ee=Yr.getState();for(const jt of N){const qr=$.get(jt.sessionId),pn=Yr.getState().sessions.get(jt.sessionId);jt.agent!==void 0&&JSON.stringify(jt.agent)!==JSON.stringify(pn?.agent)&&(pn?.agent==null||JSON.stringify(jt.agent)!==JSON.stringify(qr?.agent))&&ee.setSessionAgentIdentity(jt.sessionId,jt.agent),jt.activeProgram!=null&&jt.activeProgram!==pn?.activeProgram&&(pn?.activeProgram==null||jt.activeProgram!==qr?.activeProgram)&&ee.setSessionActiveProgram(jt.sessionId,jt.activeProgram),jt.cwd!=null&&jt.cwd!==pn?.cwd&&(pn?.cwd==null||jt.cwd!==qr?.cwd)&&ee.setSessionCwd(jt.sessionId,jt.cwd),jt.shellTitle!=null&&jt.shellTitle!==pn?.shellTitle&&(pn?.shellTitle==null||jt.shellTitle!==qr?.shellTitle)&&ee.setSessionShellTitle(jt.sessionId,jt.shellTitle)}if(!Hn.current){V(jt=>jx(jt,N)),os.current=N,Hn.current=!0;return}const se=new Set(z.map(jt=>jt.sessionId)),Qe=new Set(N.map(jt=>jt.sessionId)),ze=new Map(z.map(jt=>[jt.sessionId,jt.name]));os.current=N,V(jt=>{const qr=jx(jt,N);return(!nr.current||!qr.some(pn=>pn.id===nr.current))&&_r(qr[0]?.id??null),qr});const xt=N.filter(jt=>!se.has(jt.sessionId)),_t=[...se].filter(jt=>!Qe.has(jt)),Fr=N.filter(jt=>se.has(jt.sessionId)&&ze.get(jt.sessionId)!==jt.name);(xt.length>0||_t.length>0||Fr.length>0)&&W("[Session] Synced persisted sessions:",{newSessionIds:xt.map(jt=>jt.sessionId),removedSessionIds:_t,renamedSessionIds:Fr.map(jt=>jt.sessionId),currentSessionIds:N.map(jt=>jt.sessionId)});for(const jt of N){if(!jt.backendSessionId)continue;Yr.getState().setTerminalSession(jt.sessionId,{sessionId:jt.backendSessionId,cols:80,rows:24,mode:jt.mode,tmuxSessionName:jt.tmuxSessionName})}},[Me,Y,W]);const Nn=b.useCallback(async z=>{const N=++fe.current,$=xe.current,ee=()=>N===fe.current&&$===xe.current&&(z?.shouldActivate?.()??!0);try{const se=Gt.getState(),Qe=Z?{rightOpen:se.rightOpen,rightPinned:se.rightPinned,rightSidebarWidth:se.rightSidebarWidth,rightTab:se.rightTab}:null,ze=z?.mode==="tmux"||z?.mode==="shell"?z.mode:c,xt=(z?.tmuxSessionName||"").trim(),_t=l.trim(),Fr=ze==="tmux"?xt||_t||eN():null,jt=typeof z?.cwd=="string"?z.cwd:null,qr=Z?Yr.getState().sessions.get(Z)?.cwd??null:null,pn=typeof jt=="string"&&jt.trim().length>0?jt:typeof qr=="string"&&qr.trim().length>0?qr:void 0,Xn=await rn({preferredFrontendSessionId:z?.preferredFrontendSessionId,requireExisting:z?.requireExisting===!0,mode:ze,tmuxSessionName:Fr,cwd:pn,termType:"xterm-256color",createIfEmpty:z?.createIfEmpty===!0},{shouldActivate:ee});if(Xn.discarded)return z?.onResult?.({ok:!1,error:"unknown"}),null;const vn=Xn.session,kn=Xn.terminalSession;!Xn.reused&&Qe&&Gt.getState().initializeRightSidebarForSession(vn.sessionId,kn.cwd??pn??null,Qe);const ar={id:vn.sessionId,name:vn.name,customName:vn.customName===!0,sessionId:kn.sessionId,mode:kn.mode??vn.mode,tmuxSessionName:kn.tmuxSessionName??vn.tmuxSessionName},qt=z?.command?.trim();return qt&&He.current.set(ar.id,{backendSessionId:kn.sessionId,command:qt}),V(an=>XE(an,ar)),ee()&&_r(ar.id),Yr.getState().setTerminalSession(ar.id,{sessionId:kn.sessionId,cols:80,rows:24,mode:ar.mode,tmuxSessionName:ar.tmuxSessionName,activeProgram:kn.activeProgram,activeProgramRaw:kn.activeProgramRaw,activeProgramSource:kn.activeProgramSource,cwd:kn.cwd}),W("[Session] Inventory opened session:",{frontendSessionId:ar.id,backendSessionId:kn.sessionId,reused:Xn.reused,mode:ar.mode,tmuxSessionName:ar.tmuxSessionName}),z?.onResult?.({ok:!0,sessionId:ar.id}),ar.id}catch(se){return console.error("[Session] Failed to create new session:",se),z?.onResult?.({ok:!1,error:IC(se)}),null}},[c,l,Z,rn,W]);sr.current=Nn;const Rn=b.useCallback((z,N={})=>{xe.current+=1,ns.getState().setActivePane(z);const $=nr.current,ee=!!$&&st.current[$]===!0;if(_r(z),pr.current&&N.preserveMobileKeyboard===!1){on.current=Date.now()+600,$&&(st.current[$]=!1),Ct(null),We(null);const se=document.activeElement;se instanceof HTMLTextAreaElement&&se.closest(".terminal-viewport-container")&&se.blur();return}ee&&pr.current&&Ct(z),Nt.current&&(!pr.current||ee)&&We({sessionId:z,token:Date.now()})},[]),ps=b.useCallback(z=>{_r(z),Ze(!0),Mt(null)},[]),G=b.useCallback(z=>{const N=nr.current;!N||N===z||(H($=>Wp($,N,z)),Ze(!1),Rn(N,{preserveMobileKeyboard:!1}))},[Rn]),Le=b.useCallback(async()=>{const z=nr.current;if(!z||Ge)return;const N=xe.current;ft(!0);const $=Yr.getState().sessions.get(z)?.cwd??void 0,ee=await Nn({cwd:$||void 0,mode:c,shouldActivate:()=>!1});if(ft(!1),!ee){Mt(B("common.error"));return}!Tt.current||N!==xe.current||!Ir.current.some(se=>se.id===z)||(H(se=>Wp(se,z,ee)),Ze(!1),Rn(z,{preserveMobileKeyboard:!1}))},[Rn,c,Nn,Ge,B]),Ke=b.useCallback(z=>{H(N=>UE(N,z)),z&&Rn(z,{preserveMobileKeyboard:!1})},[Rn]),ct=b.useCallback(z=>{H(N=>$E(N,z)),Rn(z,{preserveMobileKeyboard:!1})},[Rn]),qe=b.useCallback(z=>{if(U.find($=>$.id===z)){if(xe.current+=1,ns.getState().setActivePane(z),z===nr.current)return;if(_r(z),!hE({isMobile:pr.current,viewportReady:Ee.has(z),streamReady:ye.has(z),contentReady:Ne.has(z)})){$e(null),Nt.current&&We({sessionId:z,token:Date.now()}),W("[Session] Switched to session:",z);return}mt(ee=>{if(ee.has(z))return ee;const se=new Set(ee);return se.add(z),se}),$e(z),W("[Session] Switched to session:",z)}},[Ne,W,ye,U,Ee]),At=b.useCallback((z,N)=>{N.trim()&&(V($=>$.map(ee=>ee.id===z?{...ee,name:N.trim(),customName:!0}:ee)),ht(z,N.trim()))},[ht]),Rt=b.useCallback(z=>{V(N=>N.map($=>$.id===z?{...$,customName:!1}:$)),zt(z)},[zt]),Dt=b.useCallback(z=>{V(N=>{const $=new Map(N.map(ze=>[ze.id,ze])),ee=z.map(ze=>$.get(ze)).filter(ze=>ze!==void 0),se=new Set(z),Qe=N.filter(ze=>!se.has(ze.id));return[...ee,...Qe]}),Pt(z),W("[Session] Reordered sessions:",z),requestAnimationFrame(()=>{Ye.current?.update()})},[Pt,W]),ot=b.useCallback(async z=>{const N=typeof z=="string"?z:z.sessionId,$=typeof z=="string"?"auto":z.closeMode??"auto",ee=U.find(xt=>xt.id===N);if(!ee||Qt.current.has(N))return;Qt.current.add(N),xe.current+=1;const se=Vg(Wr,N,xt=>xt.id);try{$==="destroy"&&ee.mode==="tmux"&&ee.tmuxSessionName?(await a3(ee.tmuxSessionName),W("[Session] Destroyed tmux session:",{frontendSessionId:ee.id,tmuxSessionName:ee.tmuxSessionName})):ee.sessionId&&(await n3(ee.sessionId),W("[Session] Closed backend terminal:",ee.sessionId))}catch(xt){console.error("[Session] Failed to close backend terminal:",xt),Yt({sessionId:N,closeMode:$});return}finally{Qt.current.delete(N)}Yt(xt=>xt?.sessionId===N?null:xt);const ze=Ir.current.filter(xt=>xt.id!==N).some(xt=>xt.id===se)?se:Vg(Ir.current,N,xt=>xt.id);nr.current===N&&_r(ze),V(xt=>xt.filter(_t=>_t.id!==N)),ne(N,ze),delete st.current[N],W("[Session] Closed session:",{sessionId:N,closeMode:$})},[U,Wr,ne,W]),Ot=b.useCallback(z=>{if(!z)return;const N=U.filter($=>$.sessionId===z);if(N.length!==0){N.length>1&&console.warn("[session-invariant] backend matched multiple frontend sessions during cleanup",{backendSessionId:z,frontendSessionIds:N.map($=>$.id)}),V($=>{const ee=$.filter(se=>se.sessionId!==z);return ee.length!==$.length&&!ee.some(Qe=>Qe.id===Z)&&_r(ee.length>0?ee[0].id:null),ee});for(const $ of N)ne($.id),delete st.current[$.id];W("[Session] Backend gone, dropped local session(s):",N.map($=>$.id))}},[U,Z,ne,W]);b.useEffect(()=>{const z=ar=>{Nn(ar.detail)},N=ar=>{qe(ar.detail)},$=()=>{const ar=nr.current;!ar||pr.current||We({sessionId:ar,token:Date.now()})},ee=ar=>{const qt=ar;qt.detail&&ps(qt.detail)},se=ar=>{const qt=ar.detail;Ke(qt??nr.current??void 0)},Qe=ar=>{const qt=ar.detail;qt&&ct(qt)},ze=ar=>{const qt=ar.detail,cn=typeof qt=="string"?qt:qt?.layout,an=typeof qt=="string"?nr.current:qt?.sessionId;cn!=="horizontal"&&cn!=="vertical"&&cn!=="grid"||H(Hs=>Hs.map(Is=>Is.sessionIds.includes(an??"")?{...Is,layout:cn}:Is))},xt=ar=>{const cn=ar.detail?.direction;if(cn!=="prev"&&cn!=="next")return;const an=fs.current;if(an.length<=1)return;const Hs=nr.current,Is=Hs?an.findIndex(ia=>ia.id===Hs):-1,Aa=((Is>=0?Is:0)+(cn==="next"?1:-1)+an.length)%an.length,Ln=an[Aa]?.id;Ln&&Ln!==Hs&&qe(Ln)},_t=ar=>{ot(ar.detail)},Fr=ar=>{Ot(ar.detail)},jt=ar=>{const qt=ar;!qt.detail?.sessionId||!qt.detail?.name||At(qt.detail.sessionId,qt.detail.name)},qr=ar=>{const qt=ar;qt.detail?.sessionId&&Rt(qt.detail.sessionId)},pn=ar=>{const qt=ar;qt.detail?.sessionIds&&Dt(qt.detail.sessionIds)},Xn=ar=>{const qt=ar.detail;!qt?.workspaceId||!Array.isArray(qt.sessionIds)||H(cn=>zE(cn,qt.workspaceId,qt.sessionIds))},vn=ar=>{const qt=ar.detail;!qt?.workspaceId||typeof qt.name!="string"||H(cn=>HE(cn,qt.workspaceId,qt.name))},kn=ar=>{const qt=ar.detail;!qt?.primaryId||!qt.secondaryId||qt.primaryId===qt.secondaryId||(H(cn=>Wp(cn,qt.primaryId,qt.secondaryId)),Rn(qt.primaryId,{preserveMobileKeyboard:!1}))};return window.addEventListener("new-terminal-session",z),window.addEventListener("switch-terminal-session",N),window.addEventListener("focus-active-terminal-session",$),window.addEventListener("open-terminal-split-chooser",ee),window.addEventListener("close-terminal-split",se),window.addEventListener("remove-terminal-split-pane",Qe),window.addEventListener("set-terminal-split-direction",ze),window.addEventListener("cycle-terminal-session",xt),window.addEventListener("close-terminal-session",_t),window.addEventListener("close-terminal-session-by-backend",Fr),window.addEventListener("rename-terminal-session",jt),window.addEventListener("reset-terminal-session-name",qr),window.addEventListener("reorder-terminal-session",pn),window.addEventListener("reorder-terminal-split-workspace",Xn),window.addEventListener("rename-terminal-split-workspace",vn),window.addEventListener("combine-terminal-split-sessions",kn),()=>{window.removeEventListener("new-terminal-session",z),window.removeEventListener("switch-terminal-session",N),window.removeEventListener("focus-active-terminal-session",$),window.removeEventListener("open-terminal-split-chooser",ee),window.removeEventListener("close-terminal-split",se),window.removeEventListener("remove-terminal-split-pane",Qe),window.removeEventListener("set-terminal-split-direction",ze),window.removeEventListener("cycle-terminal-session",xt),window.removeEventListener("close-terminal-session",_t),window.removeEventListener("close-terminal-session-by-backend",Fr),window.removeEventListener("rename-terminal-session",jt),window.removeEventListener("reset-terminal-session-name",qr),window.removeEventListener("reorder-terminal-session",pn),window.removeEventListener("reorder-terminal-split-workspace",Xn),window.removeEventListener("rename-terminal-split-workspace",vn),window.removeEventListener("combine-terminal-split-sessions",kn)}},[Rn,Nn,qe,ps,Ke,ct,ot,Ot,At,Rt,Dt]),b.useEffect(()=>{if(!Sr||q)return;const z=N=>{if(!UC(N,S1())||!(N.ctrlKey||N.metaKey)||!N.shiftKey)return;if(Sr.layout==="horizontal"?N.key==="ArrowLeft"||N.key==="ArrowRight":Sr.layout==="vertical"?N.key==="ArrowUp"||N.key==="ArrowDown":N.key.startsWith("Arrow")){N.preventDefault(),N.stopPropagation();const ee=Sr.sessionIds.indexOf(nr.current??""),se=N.key==="ArrowLeft"||N.key==="ArrowUp"?-1:1,Qe=(Math.max(0,ee)+se+Sr.sessionIds.length)%Sr.sessionIds.length,ze=Sr.sessionIds[Qe];if(!ze)return;Rn(ze);return}N.key==="Backspace"&&(N.preventDefault(),N.stopPropagation(),Ke(nr.current??void 0))};return window.addEventListener("keydown",z,!0),()=>window.removeEventListener("keydown",z,!0)},[Rn,Sr,Ke,q]);const hr=z=>{const N=Yr.getState().sessions.get(z.id);return sl(z,N?.activeProgram??null,N?.cwd??null,void 0,N?.shellTitle??null,N?.promptState??null)},Zt=(z,N={})=>{const $=z.id===Z&&!te?.startsWith("@collaboration:"),ee=Kr.has(z.id)&&!N.hidden,se=p&&dE({sessionId:z.id,foregroundSessionId:Pr,visibleSessionIds:Kr,deferredViewportSessionIds:q?sn:Zn}),Qe=uE({sessionId:z.id,foregroundSessionId:Pr,foregroundReady:fn,isVisible:ee})&&p,ze=gE({sessionId:z.id,foregroundSessionId:Pr,requestToken:lt.token,foregroundCompletedToken:Et,isVisible:K.has(z.id)})&&p,xt=ee||z.id===Pr||Zn.has(z.id)?0:Xr.get(z.id)??Qh;return s.jsxs("div",{className:`relative flex h-full min-h-0 min-w-0 flex-col overflow-hidden ${N.hidden?"invisible pointer-events-none":""}`,style:N.containerStyle,"aria-hidden":N.hidden||void 0,onPointerDownCapture:()=>{ee&&Rx($,()=>Rn(z.id))},onWheelCapture:()=>{Rx($,()=>Rn(z.id))},children:[N.showPaneTitle&&s.jsx(DE,{session:z,active:$,onActivate:()=>Rn(z.id),onToggleRightSidebar:$?x:void 0}),s.jsx("div",{className:"min-h-0 flex-1 app-chrome-bg",children:se&&s.jsx(jE,{sessionId:z.id,mode:z.mode,tmuxSessionName:z.tmuxSessionName,terminalSettings:e,colorTheme:t,toolbarPresets:r,isActive:$,focusSuspended:ke!==null,deferCursorUntilPositioned:ke===z.id||z.mode==="tmux"&&!Ne.has(z.id),isLayoutVisible:ee,initialConnectEnabled:Qe&&ze,resumeRequestEnabled:ze,suppressKeyboard:N.suppressKeyboard,keyboardPortalTarget:N.keyboardPortalTarget,sharedMobileKeyboardLayout:N.sharedMobileKeyboardLayout,suppressPageFlipRefresh:N.suppressPageFlipRefresh,focusRequestToken:Ie?.sessionId===z.id?Ie.token:0,resumeRequestToken:lt.token,resumeRequestReason:lt.reason,forceResumeReconnect:lt.forceForegroundReconnect&&K.has(z.id),resumeRequestDelayMs:K.has(z.id)?0:N.hidden?Qh:Xr.get(z.id)??Qh,initialConnectDelayMs:xt,onStreamReadyChange:kt,onStreamConnected:tr,onViewportReadyChange:Br,onContentReadyChange:cr,onKeyboardVisibilityChange:Kn,showDebug:n,onStatusChange:$?k:void 0})})]},z.id)};return s.jsxs("div",{className:"relative h-full flex flex-col",children:[vt&&U.some(z=>z.id===vt.sessionId)&&s.jsxs("div",{role:"alert",className:"fixed inset-x-3 top-[calc(var(--safe-top-inset)+0.75rem)] z-toast mx-auto flex max-w-lg items-center gap-3 rounded-xl border border-destructive/30 bg-surface-elevated px-4 py-3 text-[12px] text-foreground shadow-lg",children:[s.jsx("span",{className:"min-w-0 flex-1",children:B("tab.closeFailed",{name:U.find(z=>z.id===vt.sessionId).name})}),s.jsx("button",{type:"button",className:"shrink-0 rounded-lg px-2 py-1 text-primary hover:bg-surface-2",onClick:()=>{ot(vt)},children:B("common.retry")}),s.jsx("button",{type:"button",className:"shrink-0 rounded-lg p-1 hover:bg-surface-2","aria-label":B("common.close"),onClick:()=>Yt(null),children:s.jsx(Qn,{size:16})})]}),gr&&s.jsx("section",{className:"fixed inset-x-3 top-[calc(var(--safe-top-inset)+0.75rem)] z-toast mx-auto max-w-lg rounded-2xl border border-warning/30 bg-surface-elevated px-4 py-3.5 shadow-[0_20px_60px_var(--app-shadow-strong)]",role:"alert","aria-live":"assertive",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-warning/15 text-warning",children:s.jsx(k1,{size:18})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{className:"text-[13px] font-semibold text-foreground",children:B("tab.tmuxRecoveryTitle",{count:gr.sessions.length})}),s.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:B("tab.tmuxRecoveryHint")}),s.jsx("p",{className:"mt-1.5 truncate text-[10px] text-foreground/70",children:gr.sessions.map(z=>z.name).join(" · ")}),Lt&&s.jsx("p",{className:"mt-2 text-[10px] text-destructive",children:Lt}),s.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[s.jsxs("button",{type:"button",disabled:Xt!==null,onClick:()=>{Hr()},className:"inline-flex min-h-9 items-center gap-1.5 rounded-lg bg-primary px-3 text-[11px] font-medium text-primary-foreground transition active:opacity-80 disabled:opacity-50",children:[s.jsx(C3,{size:13,className:Xt==="restore"?"animate-spin":""}),B(Xt==="restore"?"tab.tmuxRecoveryRestoring":"tab.tmuxRecoveryRestoreAll")]}),s.jsx("button",{type:"button",disabled:Xt!==null,onClick:()=>{En()},className:"inline-flex min-h-9 items-center rounded-lg px-3 text-[11px] text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:opacity-50",children:B("tab.tmuxRecoveryDismiss")})]})]})]})}),s.jsx("div",{className:"flex-1 overflow-hidden",children:s.jsx(W9,{onSwiper:z=>{Ye.current=z,z.allowTouchMove=Dr.length>1&&!hn&&!ae,kr("[swiper:on-swiper]",{allowTouchMove:z.allowTouchMove}),requestAnimationFrame(()=>Nr("on-swiper"))},onSlideChange:Lr,onTouchStart:(z,N)=>{const $=Bx(N),ee=$==="touch"||$==="pen"||$==="unknown";F("[swipe:touch-start]",{pointerType:$,allowed:ee}),kr("[swiper:touch-start]",{pointerType:$,allowed:ee}),ee&&(Gn(),bt.current=!0,gt.current=!0)},onTouchEnd:(z,N)=>{const $=Bx(N),ee=$==="touch"||$==="pen"||$==="unknown";F("[swipe:touch-end]",{pointerType:$,allowed:ee}),kr("[swiper:touch-end]",{pointerType:$,allowed:ee}),ee&&(bt.current=!1,Vn("touch-end"))},onTransitionEnd:()=>{const z=Ye.current;if(bt.current){kr("[swiper:transition-end-during-touch]");return}if(gt.current&&z&&!ZE(z,me.current)){kr("[swiper:transition-end-deferred]");return}Gn(),gt.current=!1,kr("[swiper:transition-end]")},initialSlide:Math.max(0,$r),speed:e1,slidesPerView:1,resistanceRatio:.82,threshold:8,longSwipesRatio:.2,touchAngle:45,touchStartPreventDefault:!1,simulateTouch:!1,noSwiping:!0,noSwipingSelector:"[data-mobile-keyboard='true']",className:"terminal-session-swiper h-full",children:Dr.map(z=>{const N=z.workspace,$=!!N&&z.sessions.length>=2,ee=q?Vt?"horizontal":"vertical":N?.layout??"horizontal",se=q&&et?z.sessions.some(ze=>ze.id===et):!1,Qe=z.sessions.some(ze=>ze.id===Z)?Z:z.sessions[0]?.id;return s.jsx(G9,{className:"h-full",children:s.jsx("div",{className:"h-full min-w-0","data-pinned-right-sidebar-inset":nn.get(z.key)??0,style:{paddingRight:nn.get(z.key)??0,paddingTop:y&&!$?"2.5rem":void 0},children:$?s.jsxs("div",{className:"flex h-full min-h-0 min-w-0 flex-col bg-[var(--chrome-bg)]",style:q?{transform:"translateY(var(--kb-translate-y, 0px))",transition:"none"}:void 0,children:[s.jsx(a2,{layoutId:z.key,preset:N?.layout??"horizontal",initialTree:DC(z.sessions.map(ze=>ze.id),ee,N?.ratios,N?.gridColumnRatios,N?.gridRowRatios),mobile:q,focusId:se?et:null,panes:z.sessions.map(ze=>({id:ze.id,content:Zt(ze,{showPaneTitle:!q,suppressKeyboard:q&&ze.id!==Qe,keyboardPortalTarget:q?De:null,sharedMobileKeyboardLayout:q,suppressPageFlipRefresh:!0})}))}),q&&s.jsx("div",{ref:er,className:"relative shrink-0 app-chrome-bg","data-split-keyboard-host":"true"})]}):s.jsx(a2,{layoutId:z.key,preset:N?.layout??"horizontal",mobile:q,panes:[{id:z.sessions[0].id,content:Zt(z.sessions[0])}]})})},z.key)})})}),ae&&Z&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop-soft)] backdrop-blur-sm",onClick:()=>Ze(!1),"aria-label":B("common.close")}),s.jsxs("section",{ref:Je,tabIndex:-1,className:"fixed inset-x-3 bottom-3 z-modal-panel mx-auto max-h-[min(78svh,620px)] max-w-md overflow-hidden rounded-2xl border border-border/20 bg-surface shadow-[0_24px_70px_var(--app-shadow-strong)] sm:bottom-auto sm:top-1/2 sm:-translate-y-1/2",style:{paddingBottom:"var(--safe-bottom-inset)"},role:"dialog","aria-modal":"true","aria-label":B("tab.splitTitle"),children:[s.jsxs("header",{className:"flex items-start gap-3 border-b border-border/20 px-4 py-3.5",children:[s.jsx("div",{className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-xl bg-primary/15 text-primary",children:s.jsx(_l,{size:17})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{className:"text-[14px] font-semibold text-foreground",children:B("tab.splitTitle")}),s.jsx("p",{className:"mt-0.5 text-[11px] leading-relaxed text-muted-foreground",children:B("tab.splitExistingHint")})]}),s.jsx("button",{type:"button",className:"inline-flex h-8 w-8 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-surface-2 hover:text-foreground",onClick:()=>Ze(!1),"aria-label":B("common.close"),children:s.jsx(Qn,{size:16})})]}),s.jsxs("div",{className:"max-h-[calc(min(78svh,620px)-72px)] overflow-y-auto overscroll-contain p-2",children:[s.jsxs("button",{type:"button",disabled:Ge,onClick:()=>{Le()},className:"flex w-full items-center gap-3 rounded-xl px-3 py-3 text-left transition hover:bg-surface-2 active:bg-surface-elevated disabled:opacity-60",children:[s.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-primary/15 text-primary",children:s.jsx(Us,{size:17})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block text-[13px] font-medium text-foreground",children:B("tab.splitNew")}),s.jsx("span",{className:"mt-0.5 block text-[11px] text-muted-foreground",children:B("tab.splitNewHint")})]})]}),Te.filter(z=>z.id!==Sr?.id).length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-3 pb-1 pt-3 text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground",children:B("tab.splitExistingGroups")}),Te.filter(z=>z.id!==Sr?.id).map((z,N)=>{const $=z.sessionIds.flatMap(Qe=>{const ze=U.find(xt=>xt.id===Qe);return ze?[ze]:[]});if($.length<2)return null;const ee=z.name||`${B("tab.splitWorkspace")} ${N+1}`,se=$.map(Qe=>hr(Qe).primary).join(" · ");return s.jsxs("button",{type:"button",onClick:()=>G($[0].id),className:"group flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left transition hover:bg-surface-2 active:bg-surface-elevated",children:[s.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:s.jsx(_l,{size:15})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-medium text-foreground",children:ee}),s.jsx("span",{className:"shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[9px] font-medium text-primary",children:B("tab.splitOccupied")})]}),s.jsxs("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:[B("tab.sessionCount",{count:$.length})," · ",se]})]}),s.jsx(di,{size:14,className:"text-primary opacity-0 transition group-hover:opacity-100"})]},z.id)})]}),s.jsx("div",{className:"px-3 pb-1 pt-3 text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground",children:B("tab.splitAvailableSessions")}),U.filter(z=>!Te.some(N=>N.sessionIds.includes(z.id))&&z.id!==Z).length===0&&Te.filter(z=>z.id!==Sr?.id).length===0?s.jsx("p",{className:"px-3 py-4 text-[12px] text-muted-foreground",children:B("tab.splitNoOtherSessions")}):U.filter(z=>!Te.some(N=>N.sessionIds.includes(z.id))&&z.id!==Z).map(z=>{const N=Qr.get(z.id)??null,$=hr(z);return s.jsxs("button",{type:"button",onClick:()=>G(z.id),className:"group flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left transition hover:bg-surface-2 active:bg-surface-elevated",children:[s.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground",children:N?s.jsx(jc,{size:15}):s.jsx(_l,{size:15})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-[12px] font-medium text-foreground",children:$.primary}),s.jsx("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:N?Pu(N)??N:z.name})]}),s.jsx(di,{size:14,className:"text-primary opacity-0 transition group-hover:opacity-100"})]},z.id)})]})]})]}),Wt&&s.jsx("div",{className:"fixed inset-x-3 bottom-4 z-toast mx-auto max-w-md rounded-xl border border-border/20 bg-surface-elevated px-4 py-3 text-center text-[12px] text-foreground shadow-lg",children:Wt})]})},rN={sm:"h-4 w-7",md:"h-6 w-10"},nN={sm:"h-3 w-3",md:"h-5 w-5"},sN={sm:"translate-x-3",md:"translate-x-4"};function ll({checked:e,disabled:t=!1,size:r="md",className:n=""}){return s.jsx("span",{"aria-hidden":"true",className:`inline-flex shrink-0 items-center rounded-full transition ${rN[r]} ${e?"bg-primary":"bg-surface-elevated"} ${t?"opacity-50":""} ${n}`,children:s.jsx("span",{className:`mx-0.5 inline-block rounded-full bg-[var(--background)] shadow transition ${nN[r]} ${e?sN[r]:""}`})})}function ta(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var iN=typeof Symbol=="function"&&Symbol.observable||"@@observable",Px=iN,Ox=()=>Math.random().toString(36).substring(7).split("").join("."),aN={INIT:`@@redux/INIT${Ox()}`,REPLACE:`@@redux/REPLACE${Ox()}`},Fx=aN;function oN(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function Uy(e,t,r){if(typeof e!="function")throw new Error(ta(2));if(typeof t=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw new Error(ta(0));if(typeof t=="function"&&typeof r>"u"&&(r=t,t=void 0),typeof r<"u"){if(typeof r!="function")throw new Error(ta(1));return r(Uy)(e,t)}let n=e,a=t,c=new Map,l=c,h=0,p=!1;function m(){l===c&&(l=new Map,c.forEach((E,R)=>{l.set(R,E)}))}function x(){if(p)throw new Error(ta(3));return a}function y(E){if(typeof E!="function")throw new Error(ta(4));if(p)throw new Error(ta(5));let R=!0;m();const B=h++;return l.set(B,E),function(){if(R){if(p)throw new Error(ta(6));R=!1,m(),l.delete(B),c=null}}}function w(E){if(!oN(E))throw new Error(ta(7));if(typeof E.type>"u")throw new Error(ta(8));if(typeof E.type!="string")throw new Error(ta(17));if(p)throw new Error(ta(9));try{p=!0,a=n(a,E)}finally{p=!1}return(c=l).forEach(B=>{B()}),E}function v(E){if(typeof E!="function")throw new Error(ta(10));n=E,w({type:Fx.REPLACE})}function k(){const E=y;return{subscribe(R){if(typeof R!="object"||R===null)throw new Error(ta(11));function B(){const F=R;F.next&&F.next(x())}return B(),{unsubscribe:E(B)}},[Px](){return this}}}return w({type:Fx.INIT}),{dispatch:w,subscribe:y,getState:x,replaceReducer:v,[Px]:k}}function $x(e,t){return function(...r){return t(e.apply(this,r))}}function Ux(e,t){if(typeof e=="function")return $x(e,t);if(typeof e!="object"||e===null)throw new Error(ta(16));const r={};for(const n in e){const a=e[n];typeof a=="function"&&(r[n]=$x(a,t))}return r}function zy(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,r)=>(...n)=>t(r(...n)))}function lN(...e){return t=>(r,n)=>{const a=t(r,n);let c=()=>{throw new Error(ta(15))};const l={getState:a.getState,dispatch:(p,...m)=>c(p,...m)},h=e.map(p=>p(l));return c=zy(...h)(a.dispatch),{...a,dispatch:c}}}var Vp={exports:{}},qp={};var zx;function cN(){if(zx)return qp;zx=1;var e=sA();function t(p,m){return p===m&&(p!==0||1/p===1/m)||p!==p&&m!==m}var r=typeof Object.is=="function"?Object.is:t,n=e.useSyncExternalStore,a=e.useRef,c=e.useEffect,l=e.useMemo,h=e.useDebugValue;return qp.useSyncExternalStoreWithSelector=function(p,m,x,y,w){var v=a(null);if(v.current===null){var k={hasValue:!1,value:null};v.current=k}else k=v.current;v=l(function(){function E(U){if(!R){if(R=!0,B=U,U=y(U),w!==void 0&&k.hasValue){var V=k.value;if(w(V,U))return W=V}return W=U}if(V=W,r(B,U))return V;var Z=y(U);return w!==void 0&&w(V,Z)?(B=U,V):(B=U,W=Z)}var R=!1,B,W,F=x===void 0?null:x;return[function(){return E(m())},F===null?void 0:function(){return E(F())}]},[m,x,y,w]);var L=n(p,v[0],v[1]);return c(function(){k.hasValue=!0,k.value=L},[L]),h(L),L},qp}var Hx;function uN(){return Hx||(Hx=1,Vp.exports=cN()),Vp.exports}uN();var dN=b.version.startsWith("19"),hN=Symbol.for(dN?"react.transitional.element":"react.element"),fN=Symbol.for("react.portal"),pN=Symbol.for("react.fragment"),mN=Symbol.for("react.strict_mode"),gN=Symbol.for("react.profiler"),xN=Symbol.for("react.consumer"),bN=Symbol.for("react.context"),Hy=Symbol.for("react.forward_ref"),yN=Symbol.for("react.suspense"),vN=Symbol.for("react.suspense_list"),W1=Symbol.for("react.memo"),wN=Symbol.for("react.lazy"),AN=Hy,TN=W1;function CN(e){if(typeof e=="object"&&e!==null){const{$$typeof:t}=e;switch(t){case hN:switch(e=e.type,e){case pN:case gN:case mN:case yN:case vN:return e;default:switch(e=e&&e.$$typeof,e){case bN:case Hy:case wN:case W1:return e;case xN:return e;default:return t}}case fN:return t}}}function SN(e){return CN(e)===W1}function _N(e,t,r,n,{areStatesEqual:a,areOwnPropsEqual:c,areStatePropsEqual:l}){let h=!1,p,m,x,y,w;function v(B,W){return p=B,m=W,x=e(p,m),y=t(n,m),w=r(x,y,m),h=!0,w}function k(){return x=e(p,m),t.dependsOnOwnProps&&(y=t(n,m)),w=r(x,y,m),w}function L(){return e.dependsOnOwnProps&&(x=e(p,m)),t.dependsOnOwnProps&&(y=t(n,m)),w=r(x,y,m),w}function E(){const B=e(p,m),W=!l(B,x);return x=B,W&&(w=r(x,y,m)),w}function R(B,W){const F=!c(W,m),U=!a(B,p,W,m);return p=B,m=W,F&&U?k():F?L():U?E():w}return function(W,F){return h?R(W,F):v(W,F)}}function kN(e,{initMapStateToProps:t,initMapDispatchToProps:r,initMergeProps:n,...a}){const c=t(e,a),l=r(e,a),h=n(e,a);return _N(c,l,h,e,a)}function LN(e,t){const r={};for(const n in e){const a=e[n];typeof a=="function"&&(r[n]=(...c)=>t(a(...c)))}return r}function n1(e){return function(r){const n=e(r);function a(){return n}return a.dependsOnOwnProps=!1,a}}function Wx(e){return e.dependsOnOwnProps?!!e.dependsOnOwnProps:e.length!==1}function Wy(e,t){return function(n,{displayName:a}){const c=function(h,p){return c.dependsOnOwnProps?c.mapToProps(h,p):c.mapToProps(h,void 0)};return c.dependsOnOwnProps=!0,c.mapToProps=function(h,p){c.mapToProps=e,c.dependsOnOwnProps=Wx(e);let m=c(h,p);return typeof m=="function"&&(c.mapToProps=m,c.dependsOnOwnProps=Wx(m),m=c(h,p)),m},c}}function G1(e,t){return(r,n)=>{throw new Error(`Invalid value of type ${typeof e} for ${t} argument when connecting component ${n.wrappedComponentName}.`)}}function IN(e){return e&&typeof e=="object"?n1(t=>LN(e,t)):e?typeof e=="function"?Wy(e):G1(e,"mapDispatchToProps"):n1(t=>({dispatch:t}))}function EN(e){return e?typeof e=="function"?Wy(e):G1(e,"mapStateToProps"):n1(()=>({}))}function NN(e,t,r){return{...r,...e,...t}}function RN(e){return function(r,{displayName:n,areMergedPropsEqual:a}){let c=!1,l;return function(p,m,x){const y=e(p,m,x);return c?a(y,l)||(l=y):(c=!0,l=y),l}}}function MN(e){return e?typeof e=="function"?RN(e):G1(e,"mergeProps"):()=>NN}function jN(e){e()}function DN(){let e=null,t=null;return{clear(){e=null,t=null},notify(){jN(()=>{let r=e;for(;r;)r.callback(),r=r.next})},get(){const r=[];let n=e;for(;n;)r.push(n),n=n.next;return r},subscribe(r){let n=!0;const a=t={callback:r,next:null,prev:t};return a.prev?a.prev.next=a:e=a,function(){!n||e===null||(n=!1,a.next?a.next.prev=a.prev:t=a.prev,a.prev?a.prev.next=a.next:e=a.next)}}}}var Gx={notify(){},get:()=>[]};function Gy(e,t){let r,n=Gx,a=0,c=!1;function l(L){x();const E=n.subscribe(L);let R=!1;return()=>{R||(R=!0,E(),y())}}function h(){n.notify()}function p(){k.onStateChange&&k.onStateChange()}function m(){return c}function x(){a++,r||(r=t?t.addNestedSub(p):e.subscribe(p),n=DN())}function y(){a--,r&&a===0&&(r(),r=void 0,n.clear(),n=Gx)}function w(){c||(c=!0,x())}function v(){c&&(c=!1,y())}const k={addNestedSub:l,notifyNestedSubs:h,handleChangeWrapper:p,isSubscribed:m,trySubscribe:w,tryUnsubscribe:v,getListeners:()=>n};return k}var BN=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",QN=BN(),PN=()=>typeof navigator<"u"&&navigator.product==="ReactNative",ON=PN(),FN=()=>QN||ON?b.useLayoutEffect:b.useEffect,uf=FN();function Vx(e,t){return e===t?e!==0||t!==0||1/e===1/t:e!==e&&t!==t}function Yp(e,t){if(Vx(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let a=0;a<r.length;a++)if(!Object.prototype.hasOwnProperty.call(t,r[a])||!Vx(e[r[a]],t[r[a]]))return!1;return!0}var $N={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},UN={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},zN={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},Vy={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},HN={[AN]:zN,[TN]:Vy};function qx(e){return SN(e)?Vy:HN[e.$$typeof]||$N}var WN=Object.defineProperty,GN=Object.getOwnPropertyNames,Yx=Object.getOwnPropertySymbols,VN=Object.getOwnPropertyDescriptor,qN=Object.getPrototypeOf,Zx=Object.prototype;function s1(e,t){if(typeof t!="string"){if(Zx){const c=qN(t);c&&c!==Zx&&s1(e,c)}let r=GN(t);Yx&&(r=r.concat(Yx(t)));const n=qx(e),a=qx(t);for(let c=0;c<r.length;++c){const l=r[c];if(!UN[l]&&!(a&&a[l])&&!(n&&n[l])){const h=VN(t,l);try{WN(e,l,h)}catch{}}}}return e}var YN=Symbol.for("react-redux-context"),ZN=typeof globalThis<"u"?globalThis:{};function KN(){if(!b.createContext)return{};const e=ZN[YN]??=new Map;let t=e.get(b.createContext);return t||(t=b.createContext(null),e.set(b.createContext,t)),t}var qy=KN(),XN=[null,null];function JN(e,t,r){uf(()=>e(...t),r)}function eR(e,t,r,n,a,c){e.current=n,r.current=!1,a.current&&(a.current=null,c())}function tR(e,t,r,n,a,c,l,h,p,m,x){if(!e)return()=>{};let y=!1,w=null;const v=()=>{if(y||!h.current)return;const L=t.getState();let E,R;try{E=n(L,a.current)}catch(B){R=B,w=B}R||(w=null),E===c.current?l.current||m():(c.current=E,p.current=E,l.current=!0,x())};return r.onStateChange=v,r.trySubscribe(),v(),()=>{if(y=!0,r.tryUnsubscribe(),r.onStateChange=null,w)throw w}}function rR(e,t){return e===t}function nR(e,t,r,{pure:n,areStatesEqual:a=rR,areOwnPropsEqual:c=Yp,areStatePropsEqual:l=Yp,areMergedPropsEqual:h=Yp,forwardRef:p=!1,context:m=qy}={}){const x=m,y=EN(e),w=IN(t),v=MN(r),k=!!e;return E=>{const R=E.displayName||E.name||"Component",B=`Connect(${R})`,W={shouldHandleStateChanges:k,displayName:B,wrappedComponentName:R,WrappedComponent:E,initMapStateToProps:y,initMapDispatchToProps:w,initMergeProps:v,areStatesEqual:a,areStatePropsEqual:l,areOwnPropsEqual:c,areMergedPropsEqual:h};function F(Z){const[le,xe,fe]=b.useMemo(()=>{const{reactReduxForwardedRef:Ye,...st}=Z;return[Z.context,Ye,st]},[Z]),te=b.useMemo(()=>{let Ye=x;return le?.Consumer,Ye},[le,x]),ke=b.useContext(te),$e=!!Z.store&&!!Z.store.getState&&!!Z.store.dispatch,Y=!!ke&&!!ke.store,Ae=$e?Z.store:ke.store,lt=Y?ke.getServerState:Ae.getState,Ce=b.useMemo(()=>kN(Ae.dispatch,W),[Ae]),[ye,_e]=b.useMemo(()=>{if(!k)return XN;const Ye=Gy(Ae,$e?void 0:ke.subscription),st=Ye.notifyNestedSubs.bind(Ye);return[Ye,st]},[Ae,$e,ke]),je=b.useMemo(()=>$e?ke:{...ke,subscription:ye},[$e,ke,ye]),re=b.useRef(void 0),Pe=b.useRef(fe),Se=b.useRef(void 0),Ee=b.useRef(!1),Be=b.useRef(!1),Ne=b.useRef(void 0);uf(()=>(Be.current=!0,()=>{Be.current=!1}),[]);const oe=b.useMemo(()=>()=>Se.current&&fe===Pe.current?Se.current:Ce(Ae.getState(),fe),[Ae,fe]),He=b.useMemo(()=>st=>ye?tR(k,Ae,ye,Ce,Pe,re,Ee,Be,Se,_e,st):()=>{},[ye]);JN(eR,[Pe,re,Ee,fe,Se,_e]);let rt;try{rt=b.useSyncExternalStore(He,oe,lt?()=>Ce(lt(),fe):oe)}catch(Ye){throw Ne.current&&(Ye.message+=`
71
71
  The error may be correlated with this previous error:
72
72
  ${Ne.current.stack}
73
73
 
@@ -126,10 +126,10 @@ ${Ne.current.stack}
126
126
  overflow-anchor: none;
127
127
  `}}];return{always:A0(l,"always"),resting:A0(l,"resting"),dragging:A0(l,"dragging"),dropAnimating:A0(l,"dropAnimating"),userCancel:A0(l,"userCancel")}};const Da=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?b.useLayoutEffect:b.useEffect,tm=()=>{const e=document.querySelector("head");return e||Bt(),e},p5=e=>{const t=document.createElement("style");return e&&t.setAttribute("nonce",e),t.type="text/css",t};function Qj(e,t){const r=Cn(()=>Bj(e),[e]),n=b.useRef(null),a=b.useRef(null),c=Tr(fi(y=>{const w=a.current;w||Bt(),w.textContent=y}),[]),l=Tr(y=>{const w=n.current;w||Bt(),w.textContent=y},[]);Da(()=>{!n.current&&!a.current||Bt();const y=p5(t),w=p5(t);return n.current=y,a.current=w,y.setAttribute(`${ju}-always`,e),w.setAttribute(`${ju}-dynamic`,e),tm().appendChild(y),tm().appendChild(w),l(r.always),c(r.resting),()=>{const v=k=>{const L=k.current;L||Bt(),tm().removeChild(L),k.current=null};v(n),v(a)}},[t,l,c,r.always,r.resting,e]);const h=Tr(()=>c(r.dragging),[c,r.dragging]),p=Tr(y=>{if(y==="DROP"){c(r.dropAnimating);return}c(r.userCancel)},[c,r.dropAnimating,r.userCancel]),m=Tr(()=>{a.current&&c(r.resting)},[c,r.resting]);return Cn(()=>({dragging:h,dropping:p,resting:m}),[h,p,m])}function Dv(e,t){return Array.from(e.querySelectorAll(t))}var Bv=e=>e&&e.ownerDocument&&e.ownerDocument.defaultView?e.ownerDocument.defaultView:window;function Pf(e){return e instanceof Bv(e).HTMLElement}function Pj(e,t){const r=`[${Du.contextId}="${e}"]`,n=Dv(document,r);if(!n.length)return null;const a=n.find(c=>c.getAttribute(Du.draggableId)===t);return!a||!Pf(a)?null:a}function Oj(e){const t=b.useRef({}),r=b.useRef(null),n=b.useRef(null),a=b.useRef(!1),c=Tr(function(w,v){const k={id:w,focus:v};return t.current[w]=k,function(){const E=t.current;E[w]!==k&&delete E[w]}},[]),l=Tr(function(w){const v=Pj(e,w);v&&v!==document.activeElement&&v.focus()},[e]),h=Tr(function(w,v){r.current===w&&(r.current=v)},[]),p=Tr(function(){n.current||a.current&&(n.current=requestAnimationFrame(()=>{n.current=null;const w=r.current;w&&l(w)}))},[l]),m=Tr(function(w){r.current=null;const v=document.activeElement;v&&v.getAttribute(Du.draggableId)===w&&(r.current=w)},[]);return Da(()=>(a.current=!0,function(){a.current=!1;const w=n.current;w&&cancelAnimationFrame(w)}),[]),Cn(()=>({register:c,tryRecordFocus:m,tryRestoreFocusRecorded:p,tryShiftRecord:h}),[c,m,p,h])}function Fj(){const e={draggables:{},droppables:{}},t=[];function r(y){return t.push(y),function(){const v=t.indexOf(y);v!==-1&&t.splice(v,1)}}function n(y){t.length&&t.forEach(w=>w(y))}function a(y){return e.draggables[y]||null}function c(y){const w=a(y);return w||Bt(),w}const l={register:y=>{e.draggables[y.descriptor.id]=y,n({type:"ADDITION",value:y})},update:(y,w)=>{const v=e.draggables[w.descriptor.id];v&&v.uniqueId===y.uniqueId&&(delete e.draggables[w.descriptor.id],e.draggables[y.descriptor.id]=y)},unregister:y=>{const w=y.descriptor.id,v=a(w);v&&y.uniqueId===v.uniqueId&&(delete e.draggables[w],e.droppables[y.descriptor.droppableId]&&n({type:"REMOVAL",value:y}))},getById:c,findById:a,exists:y=>!!a(y),getAllByType:y=>Object.values(e.draggables).filter(w=>w.descriptor.type===y)};function h(y){return e.droppables[y]||null}function p(y){const w=h(y);return w||Bt(),w}const m={register:y=>{e.droppables[y.descriptor.id]=y},unregister:y=>{const w=h(y.descriptor.id);w&&y.uniqueId===w.uniqueId&&delete e.droppables[y.descriptor.id]},getById:p,findById:h,exists:y=>!!h(y),getAllByType:y=>Object.values(e.droppables).filter(w=>w.descriptor.type===y)};function x(){e.draggables={},e.droppables={},t.length=0}return{draggable:l,droppable:m,subscribe:r,clean:x}}function $j(){const e=Cn(Fj,[]);return b.useEffect(()=>function(){e.clean()},[e]),e}var cg=_.createContext(null),xf=()=>{const e=document.body;return e||Bt(),e};const Uj={position:"absolute",width:"1px",height:"1px",margin:"-1px",border:"0",padding:"0",overflow:"hidden",clip:"rect(0 0 0 0)","clip-path":"inset(100%)"},zj=e=>`rfd-announcement-${e}`;function Hj(e){const t=Cn(()=>zj(e),[e]),r=b.useRef(null);return b.useEffect(function(){const c=document.createElement("div");return r.current=c,c.id=t,c.setAttribute("aria-live","assertive"),c.setAttribute("aria-atomic","true"),ff(c.style,Uj),xf().appendChild(c),function(){setTimeout(function(){const p=xf();p.contains(c)&&p.removeChild(c),c===r.current&&(r.current=null)})}},[t]),Tr(a=>{const c=r.current;if(c){c.textContent=a;return}},[])}const Wj={separator:"::"};function ug(e,t=Wj){const r=_.useId();return Cn(()=>`${e}${t.separator}${r}`,[t.separator,e,r])}function Gj({contextId:e,uniqueId:t}){return`rfd-hidden-text-${e}-${t}`}function Vj({contextId:e,text:t}){const r=ug("hidden-text",{separator:"-"}),n=Cn(()=>Gj({contextId:e,uniqueId:r}),[r,e]);return b.useEffect(function(){const c=document.createElement("div");return c.id=n,c.textContent=t,c.style.display="none",xf().appendChild(c),function(){const h=xf();h.contains(c)&&h.removeChild(c)}},[n,t]),n}var Of=_.createContext(null);function Qv(e){const t=b.useRef(e);return b.useEffect(()=>{t.current=e}),t}function qj(){let e=null;function t(){return!!e}function r(l){return l===e}function n(l){e&&Bt();const h={abandon:l};return e=h,h}function a(){e||Bt(),e=null}function c(){e&&(e.abandon(),a())}return{isClaimed:t,isActive:r,claim:n,release:a,tryAbandon:c}}function bd(e){return e.phase==="IDLE"||e.phase==="DROP_ANIMATING"?!1:e.isDragging}const Yj=9,Zj=13,dg=27,Pv=32,Kj=33,Xj=34,Jj=35,eD=36,tD=37,rD=38,nD=39,sD=40,iD={[Zj]:!0,[Yj]:!0};var Ov=e=>{iD[e.keyCode]&&e.preventDefault()};const Ff=(()=>{const e="visibilitychange";return typeof document>"u"?e:[e,`ms${e}`,`webkit${e}`,`moz${e}`,`o${e}`].find(n=>`on${n}`in document)||e})(),Fv=0,m5=5;function aD(e,t){return Math.abs(t.x-e.x)>=m5||Math.abs(t.y-e.y)>=m5}const g5={type:"IDLE"};function oD({cancel:e,completed:t,getPhase:r,setPhase:n}){return[{eventName:"mousemove",fn:a=>{const{button:c,clientX:l,clientY:h}=a;if(c!==Fv)return;const p={x:l,y:h},m=r();if(m.type==="DRAGGING"){a.preventDefault(),m.actions.move(p);return}m.type!=="PENDING"&&Bt();const x=m.point;if(!aD(x,p))return;a.preventDefault();const y=m.actions.fluidLift(p);n({type:"DRAGGING",actions:y})}},{eventName:"mouseup",fn:a=>{const c=r();if(c.type!=="DRAGGING"){e();return}a.preventDefault(),c.actions.drop({shouldBlockNextClick:!0}),t()}},{eventName:"mousedown",fn:a=>{r().type==="DRAGGING"&&a.preventDefault(),e()}},{eventName:"keydown",fn:a=>{if(r().type==="PENDING"){e();return}if(a.keyCode===dg){a.preventDefault(),e();return}Ov(a)}},{eventName:"resize",fn:e},{eventName:"scroll",options:{passive:!0,capture:!1},fn:()=>{r().type==="PENDING"&&e()}},{eventName:"webkitmouseforcedown",fn:a=>{const c=r();if(c.type==="IDLE"&&Bt(),c.actions.shouldRespectForcePress()){e();return}a.preventDefault()}},{eventName:Ff,fn:e}]}function lD(e){const t=b.useRef(g5),r=b.useRef(Kl),n=Cn(()=>({eventName:"mousedown",fn:function(y){if(y.defaultPrevented||y.button!==Fv||y.ctrlKey||y.metaKey||y.shiftKey||y.altKey)return;const w=e.findClosestDraggableId(y);if(!w)return;const v=e.tryGetLock(w,l,{sourceEvent:y});if(!v)return;y.preventDefault();const k={x:y.clientX,y:y.clientY};r.current(),m(v,k)}}),[e]),a=Cn(()=>({eventName:"webkitmouseforcewillbegin",fn:x=>{if(x.defaultPrevented)return;const y=e.findClosestDraggableId(x);if(!y)return;const w=e.findOptionsForDraggable(y);w&&(w.shouldRespectForcePress||e.canGetLock(y)&&x.preventDefault())}}),[e]),c=Tr(function(){const y={passive:!1,capture:!0};r.current=uo(window,[a,n],y)},[a,n]),l=Tr(()=>{t.current.type!=="IDLE"&&(t.current=g5,r.current(),c())},[c]),h=Tr(()=>{const x=t.current;l(),x.type==="DRAGGING"&&x.actions.cancel({shouldBlockNextClick:!0}),x.type==="PENDING"&&x.actions.abort()},[l]),p=Tr(function(){const y={capture:!0,passive:!1},w=oD({cancel:h,completed:l,getPhase:()=>t.current,setPhase:v=>{t.current=v}});r.current=uo(window,w,y)},[h,l]),m=Tr(function(y,w){t.current.type!=="IDLE"&&Bt(),t.current={type:"PENDING",point:w,actions:y},p()},[p]);Da(function(){return c(),function(){r.current()}},[c])}function cD(){}const uD={[Xj]:!0,[Kj]:!0,[eD]:!0,[Jj]:!0};function dD(e,t){function r(){t(),e.cancel()}function n(){t(),e.drop()}return[{eventName:"keydown",fn:a=>{if(a.keyCode===dg){a.preventDefault(),r();return}if(a.keyCode===Pv){a.preventDefault(),n();return}if(a.keyCode===sD){a.preventDefault(),e.moveDown();return}if(a.keyCode===rD){a.preventDefault(),e.moveUp();return}if(a.keyCode===nD){a.preventDefault(),e.moveRight();return}if(a.keyCode===tD){a.preventDefault(),e.moveLeft();return}if(uD[a.keyCode]){a.preventDefault();return}Ov(a)}},{eventName:"mousedown",fn:r},{eventName:"mouseup",fn:r},{eventName:"click",fn:r},{eventName:"touchstart",fn:r},{eventName:"resize",fn:r},{eventName:"wheel",fn:r,options:{passive:!0}},{eventName:Ff,fn:r}]}function hD(e){const t=b.useRef(cD),r=Cn(()=>({eventName:"keydown",fn:function(c){if(c.defaultPrevented||c.keyCode!==Pv)return;const l=e.findClosestDraggableId(c);if(!l)return;const h=e.tryGetLock(l,x,{sourceEvent:c});if(!h)return;c.preventDefault();let p=!0;const m=h.snapLift();t.current();function x(){p||Bt(),p=!1,t.current(),n()}t.current=uo(window,dD(m,x),{capture:!0,passive:!1})}}),[e]),n=Tr(function(){const c={passive:!1,capture:!0};t.current=uo(window,[r],c)},[r]);Da(function(){return n(),function(){t.current()}},[n])}const rm={type:"IDLE"},fD=120,pD=.15;function mD({cancel:e,getPhase:t}){return[{eventName:"orientationchange",fn:e},{eventName:"resize",fn:e},{eventName:"contextmenu",fn:r=>{r.preventDefault()}},{eventName:"keydown",fn:r=>{if(t().type!=="DRAGGING"){e();return}r.keyCode===dg&&r.preventDefault(),e()}},{eventName:Ff,fn:e}]}function gD({cancel:e,completed:t,getPhase:r}){return[{eventName:"touchmove",options:{capture:!1},fn:n=>{const a=r();if(a.type!=="DRAGGING"){e();return}a.hasMoved=!0;const{clientX:c,clientY:l}=n.touches[0],h={x:c,y:l};n.preventDefault(),a.actions.move(h)}},{eventName:"touchend",fn:n=>{const a=r();if(a.type!=="DRAGGING"){e();return}n.preventDefault(),a.actions.drop({shouldBlockNextClick:!0}),t()}},{eventName:"touchcancel",fn:n=>{if(r().type!=="DRAGGING"){e();return}n.preventDefault(),e()}},{eventName:"touchforcechange",fn:n=>{const a=r();a.type==="IDLE"&&Bt();const c=n.touches[0];if(!c||!(c.force>=pD))return;const h=a.actions.shouldRespectForcePress();if(a.type==="PENDING"){h&&e();return}if(h){if(a.hasMoved){n.preventDefault();return}e();return}n.preventDefault()}},{eventName:Ff,fn:e}]}function xD(e){const t=b.useRef(rm),r=b.useRef(Kl),n=Tr(function(){return t.current},[]),a=Tr(function(v){t.current=v},[]),c=Cn(()=>({eventName:"touchstart",fn:function(v){if(v.defaultPrevented)return;const k=e.findClosestDraggableId(v);if(!k)return;const L=e.tryGetLock(k,h,{sourceEvent:v});if(!L)return;const E=v.touches[0],{clientX:R,clientY:B}=E,W={x:R,y:B};r.current(),y(L,W)}}),[e]),l=Tr(function(){const v={capture:!0,passive:!1};r.current=uo(window,[c],v)},[c]),h=Tr(()=>{const w=t.current;w.type!=="IDLE"&&(w.type==="PENDING"&&clearTimeout(w.longPressTimerId),a(rm),r.current(),l())},[l,a]),p=Tr(()=>{const w=t.current;h(),w.type==="DRAGGING"&&w.actions.cancel({shouldBlockNextClick:!0}),w.type==="PENDING"&&w.actions.abort()},[h]),m=Tr(function(){const v={capture:!0,passive:!1},k={cancel:p,completed:h,getPhase:n},L=uo(window,gD(k),v),E=uo(window,mD(k),v);r.current=function(){L(),E()}},[p,n,h]),x=Tr(function(){const v=n();v.type!=="PENDING"&&Bt();const k=v.actions.fluidLift(v.point);a({type:"DRAGGING",actions:k,hasMoved:!1})},[n,a]),y=Tr(function(v,k){n().type!=="IDLE"&&Bt();const L=setTimeout(x,fD);a({type:"PENDING",point:k,actions:v,longPressTimerId:L}),m()},[m,n,a,x]);Da(function(){return l(),function(){r.current();const k=n();k.type==="PENDING"&&(clearTimeout(k.longPressTimerId),a(rm))}},[n,l,a]),Da(function(){return uo(window,[{eventName:"touchmove",fn:()=>{},options:{capture:!1,passive:!1}}])},[])}const bD=["input","button","textarea","select","option","optgroup","video","audio"];function $v(e,t){if(t==null)return!1;if(bD.includes(t.tagName.toLowerCase()))return!0;const n=t.getAttribute("contenteditable");return n==="true"||n===""?!0:t===e?!1:$v(e,t.parentElement)}function yD(e,t){const r=t.target;return Pf(r)?$v(e,r):!1}var vD=e=>Do(e.getBoundingClientRect()).center;function wD(e){return e instanceof Bv(e).Element}const AD=(()=>{const e="matches";return typeof document>"u"?e:[e,"msMatchesSelector","webkitMatchesSelector"].find(n=>n in Element.prototype)||e})();function Uv(e,t){return e==null?null:e[AD](t)?e:Uv(e.parentElement,t)}function TD(e,t){return e.closest?e.closest(t):Uv(e,t)}function CD(e){return`[${Du.contextId}="${e}"]`}function SD(e,t){const r=t.target;if(!wD(r))return null;const n=CD(e),a=TD(r,n);return!a||!Pf(a)?null:a}function _D(e,t){const r=SD(e,t);return r?r.getAttribute(Du.draggableId):null}function kD(e,t){const r=`[${c1.contextId}="${e}"]`,a=Dv(document,r).find(c=>c.getAttribute(c1.id)===t);return!a||!Pf(a)?null:a}function LD(e){e.preventDefault()}function fh({expected:e,phase:t,isLockActive:r,shouldWarn:n}){return!(!r()||e!==t)}function zv({lockAPI:e,store:t,registry:r,draggableId:n}){if(e.isClaimed())return!1;const a=r.draggable.findById(n);return!(!a||!a.options.isEnabled||!Nv(t.getState(),n))}function ID({lockAPI:e,contextId:t,store:r,registry:n,draggableId:a,forceSensorStop:c,sourceEvent:l}){if(!zv({lockAPI:e,store:r,registry:n,draggableId:a}))return null;const p=n.draggable.getById(a),m=kD(t,p.descriptor.id);if(!m||l&&!p.options.canDragInteractiveElements&&yD(m,l))return null;const x=e.claim(c||Kl);let y="PRE_DRAG";function w(){return p.options.shouldRespectForcePress}function v(){return e.isActive(x)}function k(U,V){fh({expected:U,phase:y,isLockActive:v,shouldWarn:!0})&&r.dispatch(V())}const L=k.bind(null,"DRAGGING");function E(U){function V(){e.release(),y="COMPLETED"}y!=="PRE_DRAG"&&(V(),Bt()),r.dispatch(TM(U.liftActionArgs)),y="DRAGGING";function Z(le,xe={shouldBlockNextClick:!1}){if(U.cleanup(),xe.shouldBlockNextClick){const fe=uo(window,[{eventName:"click",fn:LD,options:{once:!0,passive:!1,capture:!0}}]);setTimeout(fe)}V(),r.dispatch(Tv({reason:le}))}return{isActive:()=>fh({expected:"DRAGGING",phase:y,isLockActive:v,shouldWarn:!1}),shouldRespectForcePress:w,drop:le=>Z("DROP",le),cancel:le=>Z("CANCEL",le),...U.actions}}function R(U){const V=hd(le=>{L(()=>Av({client:le}))});return{...E({liftActionArgs:{id:a,clientSelection:U,movementMode:"FLUID"},cleanup:()=>V.cancel(),actions:{move:V}}),move:V}}function B(){const U={moveUp:()=>L(RM),moveRight:()=>L(jM),moveDown:()=>L(MM),moveLeft:()=>L(DM)};return E({liftActionArgs:{id:a,clientSelection:vD(m),movementMode:"SNAP"},cleanup:Kl,actions:U})}function W(){fh({expected:"PRE_DRAG",phase:y,isLockActive:v,shouldWarn:!0})&&e.release()}return{isActive:()=>fh({expected:"PRE_DRAG",phase:y,isLockActive:v,shouldWarn:!1}),shouldRespectForcePress:w,fluidLift:R,snapLift:B,abort:W}}const ED=[lD,hD,xD];function ND({contextId:e,store:t,registry:r,customSensors:n,enableDefaultSensors:a}){const c=[...a?ED:[],...n||[]],l=b.useState(()=>qj())[0],h=Tr(function(E,R){bd(E)&&!bd(R)&&l.tryAbandon()},[l]);Da(function(){let E=t.getState();return t.subscribe(()=>{const B=t.getState();h(E,B),E=B})},[l,t,h]),Da(()=>l.tryAbandon,[l.tryAbandon]);const p=Tr(L=>zv({lockAPI:l,registry:r,store:t,draggableId:L}),[l,r,t]),m=Tr((L,E,R)=>ID({lockAPI:l,registry:r,contextId:e,store:t,draggableId:L,forceSensorStop:E||null,sourceEvent:R&&R.sourceEvent?R.sourceEvent:null}),[e,l,r,t]),x=Tr(L=>_D(e,L),[e]),y=Tr(L=>{const E=r.draggable.findById(L);return E?E.options:null},[r.draggable]),w=Tr(function(){l.isClaimed()&&(l.tryAbandon(),t.getState().phase!=="IDLE"&&t.dispatch(rg()))},[l,t]),v=Tr(()=>l.isClaimed(),[l]),k=Cn(()=>({canGetLock:p,tryGetLock:m,findClosestDraggableId:x,findOptionsForDraggable:y,tryReleaseLock:w,isLockClaimed:v}),[p,m,x,y,w,v]);for(let L=0;L<c.length;L++)c[L](k)}const RD=e=>({onBeforeCapture:t=>{const r=()=>{e.onBeforeCapture&&e.onBeforeCapture(t)};Li.flushSync(r)},onBeforeDragStart:e.onBeforeDragStart,onDragStart:e.onDragStart,onDragEnd:e.onDragEnd,onDragUpdate:e.onDragUpdate}),MD=e=>({...xd,...e.autoScrollerOptions,durationDampening:{...xd.durationDampening,...e.autoScrollerOptions}});function T0(e){return e.current||Bt(),e.current}function jD(e){const{contextId:t,setCallbacks:r,sensors:n,nonce:a,dragHandleUsageInstructions:c}=e,l=b.useRef(null),h=Qv(e),p=Tr(()=>RD(h.current),[h]),m=Tr(()=>MD(h.current),[h]),x=Hj(t),y=Vj({contextId:t,text:c}),w=Qj(t,a),v=Tr(fe=>{T0(l).dispatch(fe)},[]),k=Cn(()=>Ux({publishWhileDragging:SM,updateDroppableScroll:kM,updateDroppableIsEnabled:LM,updateDroppableIsCombineEnabled:IM,collectionStarting:_M},v),[v]),L=$j(),E=Cn(()=>mj(L,k),[L,k]),R=Cn(()=>Rj({scrollWindow:gj,scrollDroppable:E.scrollDroppable,getAutoScrollerOptions:m,...Ux({move:Av},v)}),[E.scrollDroppable,v,m]),B=Oj(t),W=Cn(()=>dj({announce:x,autoScroller:R,dimensionMarshal:E,focusMarshal:B,getResponders:p,styleMarshal:w}),[x,R,E,B,p,w]);l.current=W;const F=Tr(()=>{const fe=T0(l);fe.getState().phase!=="IDLE"&&fe.dispatch(rg())},[]),U=Tr(()=>{const fe=T0(l).getState();return fe.phase==="DROP_ANIMATING"?!0:fe.phase==="IDLE"?!1:fe.isDragging},[]),V=Cn(()=>({isDragging:U,tryAbort:F}),[U,F]);r(V);const Z=Tr(fe=>Nv(T0(l).getState(),fe),[]),le=Tr(()=>wc(T0(l).getState()),[]),xe=Cn(()=>({marshal:E,focus:B,contextId:t,canLift:Z,isMovementAllowed:le,dragHandleUsageInstructionsId:y,registry:L}),[t,E,y,B,Z,le,L]);return ND({contextId:t,store:W,registry:L,customSensors:n||null,enableDefaultSensors:e.enableDefaultSensors!==!1}),b.useEffect(()=>F,[F]),_.createElement(Of.Provider,{value:xe},_.createElement(iR,{context:cg,store:W},e.children))}function DD(){return _.useId()}function td(e){const t=DD(),r=e.dragHandleUsageInstructions||Fh.dragHandleUsageInstructions;return _.createElement(hR,null,n=>_.createElement(jD,{nonce:e.nonce,contextId:t,setCallbacks:n,dragHandleUsageInstructions:r,enableDefaultSensors:e.enableDefaultSensors,sensors:e.sensors,onBeforeCapture:e.onBeforeCapture,onBeforeDragStart:e.onBeforeDragStart,onDragStart:e.onDragStart,onDragUpdate:e.onDragUpdate,onDragEnd:e.onDragEnd,autoScrollerOptions:e.autoScrollerOptions},e.children))}const x5={dragging:5e3,dropAnimating:4500},BD=(e,t)=>t?ed.drop(t.duration):e?ed.snap:ed.fluid,QD=(e,t)=>{if(e)return t?gd.opacity.drop:gd.opacity.combining},PD=e=>e.forceShouldAnimate!=null?e.forceShouldAnimate:e.mode==="SNAP";function OD(e){const r=e.dimension.client,{offset:n,combineWith:a,dropping:c}=e,l=!!a,h=PD(e),p=!!c,m=p?o1.drop(n,l):o1.moveTo(n);return{position:"fixed",top:r.marginBox.top,left:r.marginBox.left,boxSizing:"border-box",width:r.borderBox.width,height:r.borderBox.height,transition:BD(h,c),transform:m,opacity:QD(l,p),zIndex:p?x5.dropAnimating:x5.dragging,pointerEvents:"none"}}function FD(e){return{transform:o1.moveTo(e.offset),transition:e.shouldAnimateDisplacement?void 0:"none"}}function $D(e){return e.type==="DRAGGING"?OD(e):FD(e)}function UD(e,t,r=pi){const n=window.getComputedStyle(t),a=t.getBoundingClientRect(),c=Zy(a,n),l=hf(c,r),h={client:c,tagName:t.tagName.toLowerCase(),display:n.display},p={x:c.marginBox.width,y:c.marginBox.height};return{descriptor:e,placeholder:h,displaceBy:p,client:c,page:l}}function zD(e){const t=ug("draggable"),{descriptor:r,registry:n,getDraggableRef:a,canDragInteractiveElements:c,shouldRespectForcePress:l,isEnabled:h}=e,p=Cn(()=>({canDragInteractiveElements:c,shouldRespectForcePress:l,isEnabled:h}),[c,h,l]),m=Tr(v=>{const k=a();return k||Bt(),UD(r,k,v)},[r,a]),x=Cn(()=>({uniqueId:t,descriptor:r,options:p,getDimension:m}),[r,m,p,t]),y=b.useRef(x),w=b.useRef(!0);Da(()=>(n.draggable.register(y.current),()=>n.draggable.unregister(y.current)),[n.draggable]),Da(()=>{if(w.current){w.current=!1;return}const v=y.current;y.current=x,n.draggable.update(x,v)},[x,n.draggable])}var hg=_.createContext(null);function bf(e){const t=b.useContext(e);return t||Bt(),t}function HD(e){e.preventDefault()}const WD=e=>{const t=b.useRef(null),r=Tr((V=null)=>{t.current=V},[]),n=Tr(()=>t.current,[]),{contextId:a,dragHandleUsageInstructionsId:c,registry:l}=bf(Of),{type:h,droppableId:p}=bf(hg),m=Cn(()=>({id:e.draggableId,index:e.index,type:h,droppableId:p}),[e.draggableId,e.index,h,p]),{children:x,draggableId:y,isEnabled:w,shouldRespectForcePress:v,canDragInteractiveElements:k,isClone:L,mapped:E,dropAnimationFinished:R}=e;if(!L){const V=Cn(()=>({descriptor:m,registry:l,getDraggableRef:n,canDragInteractiveElements:k,shouldRespectForcePress:v,isEnabled:w}),[m,l,n,k,v,w]);zD(V)}const B=Cn(()=>w?{tabIndex:0,role:"button","aria-describedby":c,"data-rfd-drag-handle-draggable-id":y,"data-rfd-drag-handle-context-id":a,draggable:!1,onDragStart:HD}:null,[a,c,y,w]),W=Tr(V=>{E.type==="DRAGGING"&&E.dropping&&V.propertyName==="transform"&&Li.flushSync(R)},[R,E]),F=Cn(()=>{const V=$D(E),Z=E.type==="DRAGGING"&&E.dropping?W:void 0;return{innerRef:r,draggableProps:{"data-rfd-draggable-context-id":a,"data-rfd-draggable-id":y,style:V,onTransitionEnd:Z},dragHandleProps:B}},[a,B,y,E,W,r]),U=Cn(()=>({draggableId:m.id,type:m.type,source:{index:m.index,droppableId:m.droppableId}}),[m.droppableId,m.id,m.index,m.type]);return _.createElement(_.Fragment,null,x(F,E.snapshot,U))};var Hv=(e,t)=>e===t,Wv=e=>{const{combine:t,destination:r}=e;return r?r.droppableId:t?t.droppableId:null};const GD=e=>e.combine?e.combine.draggableId:null,VD=e=>e.at&&e.at.type==="COMBINE"?e.at.combine.draggableId:null;function qD(){const e=fi((a,c)=>({x:a,y:c})),t=fi((a,c,l=null,h=null,p=null)=>({isDragging:!0,isClone:c,isDropAnimating:!!p,dropAnimation:p,mode:a,draggingOver:l,combineWith:h,combineTargetFor:null})),r=fi((a,c,l,h,p=null,m=null,x=null)=>({mapped:{type:"DRAGGING",dropping:null,draggingOver:p,combineWith:m,mode:c,offset:a,dimension:l,forceShouldAnimate:x,snapshot:t(c,h,p,m,null)}}));return(a,c)=>{if(bd(a)){if(a.critical.draggable.id!==c.draggableId)return null;const l=a.current.client.offset,h=a.dimensions.draggables[c.draggableId],p=ja(a.impact),m=VD(a.impact),x=a.forceShouldAnimate;return r(e(l.x,l.y),a.movementMode,h,c.isClone,p,m,x)}if(a.phase==="DROP_ANIMATING"){const l=a.completed;if(l.result.draggableId!==c.draggableId)return null;const h=c.isClone,p=a.dimensions.draggables[c.draggableId],m=l.result,x=m.mode,y=Wv(m),w=GD(m),k={duration:a.dropDuration,curve:sg.drop,moveTo:a.newHomeClientOffset,opacity:w?gd.opacity.drop:null,scale:w?gd.scale.drop:null};return{mapped:{type:"DRAGGING",offset:a.newHomeClientOffset,dimension:p,dropping:k,draggingOver:y,combineWith:w,mode:x,forceShouldAnimate:null,snapshot:t(x,h,y,w,k)}}}return null}}function Gv(e=null){return{isDragging:!1,isDropAnimating:!1,isClone:!1,dropAnimation:null,mode:null,draggingOver:null,combineTargetFor:e,combineWith:null}}const YD={mapped:{type:"SECONDARY",offset:pi,combineTargetFor:null,shouldAnimateDisplacement:!0,snapshot:Gv(null)}};function ZD(){const e=fi((l,h)=>({x:l,y:h})),t=fi(Gv),r=fi((l,h=null,p)=>({mapped:{type:"SECONDARY",offset:l,combineTargetFor:h,shouldAnimateDisplacement:p,snapshot:t(h)}})),n=l=>l?r(pi,l,!0):null,a=(l,h,p,m)=>{const x=p.displaced.visible[l],y=!!(m.inVirtualList&&m.effected[l]),w=Df(p),v=w&&w.draggableId===l?h:null;if(!x){if(!y)return n(v);if(p.displaced.invisible[l])return null;const E=$u(m.displacedBy.point),R=e(E.x,E.y);return r(R,v,!0)}if(y)return n(v);const k=p.displacedBy.point,L=e(k.x,k.y);return r(L,v,x.shouldAnimate)};return(l,h)=>{if(bd(l))return l.critical.draggable.id===h.draggableId?null:a(h.draggableId,l.critical.draggable.id,l.impact,l.afterCritical);if(l.phase==="DROP_ANIMATING"){const p=l.completed;return p.result.draggableId===h.draggableId?null:a(h.draggableId,p.result.draggableId,p.impact,p.afterCritical)}return null}}const KD=()=>{const e=qD(),t=ZD();return(n,a)=>e(n,a)||t(n,a)||YD},XD={dropAnimationFinished:Cv},JD=Yy(KD,XD,null,{context:cg,areStatePropsEqual:Hv})(WD);function Vv(e){return bf(hg).isUsingCloneFor===e.draggableId&&!e.isClone?null:_.createElement(JD,e)}function Cl(e){const t=typeof e.isDragDisabled=="boolean"?!e.isDragDisabled:!0,r=!!e.disableInteractiveElementBlocking,n=!!e.shouldRespectForcePress;return _.createElement(Vv,ff({},e,{isClone:!1,isEnabled:t,canDragInteractiveElements:r,shouldRespectForcePress:n}))}const qv=e=>t=>e===t,eB=qv("scroll"),tB=qv("auto"),b5=(e,t)=>t(e.overflowX)||t(e.overflowY),rB=e=>{const t=window.getComputedStyle(e),r={overflowX:t.overflowX,overflowY:t.overflowY};return b5(r,eB)||b5(r,tB)},nB=()=>!1,Yv=e=>e==null?null:e===document.body?nB()?e:null:e===document.documentElement?null:rB(e)?e:Yv(e.parentElement);var u1=e=>({x:e.scrollLeft,y:e.scrollTop});const Zv=e=>e?window.getComputedStyle(e).position==="fixed"?!0:Zv(e.parentElement):!1;var sB=e=>{const t=Yv(e),r=Zv(e);return{closestScrollable:t,isFixedOnPage:r}},iB=({descriptor:e,isEnabled:t,isCombineEnabled:r,isFixedOnPage:n,direction:a,client:c,page:l,closest:h})=>{const p=(()=>{if(!h)return null;const{scrollSize:w,client:v}=h,k=Lv({scrollHeight:w.scrollHeight,scrollWidth:w.scrollWidth,height:v.paddingBox.height,width:v.paddingBox.width});return{pageMarginBox:h.page.marginBox,frameClient:v,scrollSize:w,shouldClipSubject:h.shouldClipSubject,scroll:{initial:h.scroll,current:h.scroll,max:k,diff:{value:pi,displacement:pi}}}})(),m=a==="vertical"?K1:ov,x=Mu({page:l,withPlaceholder:null,axis:m,frame:p});return{descriptor:e,isCombineEnabled:r,isFixedOnPage:n,axis:m,isEnabled:t,client:c,page:l,frame:p,subject:x}};const aB=(e,t)=>{const r=Ky(e);if(!t||e!==t)return r;const n=r.paddingBox.top-t.scrollTop,a=r.paddingBox.left-t.scrollLeft,c=n+t.scrollHeight,l=a+t.scrollWidth,p=V1({top:n,right:l,bottom:c,left:a},r.border);return q1({borderBox:p,margin:r.margin,border:r.border,padding:r.padding})};var oB=({ref:e,descriptor:t,env:r,windowScroll:n,direction:a,isDropDisabled:c,isCombineEnabled:l,shouldClipSubject:h})=>{const p=r.closestScrollable,m=aB(e,p),x=hf(m,n),y=(()=>{if(!p)return null;const v=Ky(p),k={scrollHeight:p.scrollHeight,scrollWidth:p.scrollWidth};return{client:v,page:hf(v,n),scroll:u1(p),scrollSize:k,shouldClipSubject:h}})();return iB({descriptor:t,isEnabled:!c,isCombineEnabled:l,isFixedOnPage:r.isFixedOnPage,direction:a,client:m,page:x,closest:y})};const lB={passive:!1},cB={passive:!0};var y5=e=>e.shouldPublishImmediately?lB:cB;const ph=e=>e&&e.env.closestScrollable||null;function uB(e){const t=b.useRef(null),r=bf(Of),n=ug("droppable"),{registry:a,marshal:c}=r,l=Qv(e),h=Cn(()=>({id:e.droppableId,type:e.type,mode:e.mode}),[e.droppableId,e.mode,e.type]),p=b.useRef(h),m=Cn(()=>fi((F,U)=>{t.current||Bt();const V={x:F,y:U};c.updateDroppableScroll(h.id,V)}),[h.id,c]),x=Tr(()=>{const F=t.current;return!F||!F.env.closestScrollable?pi:u1(F.env.closestScrollable)},[]),y=Tr(()=>{const F=x();m(F.x,F.y)},[x,m]),w=Cn(()=>hd(y),[y]),v=Tr(()=>{const F=t.current,U=ph(F);if(F&&U||Bt(),F.scrollOptions.shouldPublishImmediately){y();return}w()},[w,y]),k=Tr((F,U)=>{t.current&&Bt();const V=l.current,Z=V.getDroppableRef();Z||Bt();const le=sB(Z),xe={ref:Z,descriptor:h,env:le,scrollOptions:U};t.current=xe;const fe=oB({ref:Z,descriptor:h,env:le,windowScroll:F,direction:V.direction,isDropDisabled:V.isDropDisabled,isCombineEnabled:V.isCombineEnabled,shouldClipSubject:!V.ignoreContainerClipping}),te=le.closestScrollable;return te&&(te.setAttribute(f5.contextId,r.contextId),te.addEventListener("scroll",v,y5(xe.scrollOptions))),fe},[r.contextId,h,v,l]),L=Tr(()=>{const F=t.current,U=ph(F);return F&&U||Bt(),u1(U)},[]),E=Tr(()=>{const F=t.current;F||Bt();const U=ph(F);t.current=null,U&&(w.cancel(),U.removeAttribute(f5.contextId),U.removeEventListener("scroll",v,y5(F.scrollOptions)))},[v,w]),R=Tr(F=>{const U=t.current;U||Bt();const V=ph(U);V||Bt(),V.scrollTop+=F.y,V.scrollLeft+=F.x},[]),B=Cn(()=>({getDimensionAndWatchScroll:k,getScrollWhileDragging:L,dragStopped:E,scroll:R}),[E,k,L,R]),W=Cn(()=>({uniqueId:n,descriptor:h,callbacks:B}),[B,h,n]);Da(()=>(p.current=W.descriptor,a.droppable.register(W),()=>{t.current&&E(),a.droppable.unregister(W)}),[B,h,E,W,c,a.droppable]),Da(()=>{t.current&&c.updateDroppableIsEnabled(p.current.id,!e.isDropDisabled)},[e.isDropDisabled,c]),Da(()=>{t.current&&c.updateDroppableIsCombineEnabled(p.current.id,e.isCombineEnabled)},[e.isCombineEnabled,c])}function nm(){}const v5={width:0,height:0,margin:yR},dB=({isAnimatingOpenOnMount:e,placeholder:t,animate:r})=>e||r==="close"?v5:{height:t.client.borderBox.height,width:t.client.borderBox.width,margin:t.client.margin},hB=({isAnimatingOpenOnMount:e,placeholder:t,animate:r})=>{const n=dB({isAnimatingOpenOnMount:e,placeholder:t,animate:r});return{display:t.display,boxSizing:"border-box",width:n.width,height:n.height,marginTop:n.margin.top,marginRight:n.margin.right,marginBottom:n.margin.bottom,marginLeft:n.margin.left,flexShrink:"0",flexGrow:"0",pointerEvents:"none",transition:r!=="none"?ed.placeholder:null}},fB=e=>{const t=b.useRef(null),r=Tr(()=>{t.current&&(clearTimeout(t.current),t.current=null)},[]),{animate:n,onTransitionEnd:a,onClose:c,contextId:l}=e,[h,p]=b.useState(e.animate==="open");b.useEffect(()=>h?n!=="open"?(r(),p(!1),nm):t.current?nm:(t.current=setTimeout(()=>{t.current=null,p(!1)}),r):nm,[n,h,r]);const m=Tr(y=>{y.propertyName==="height"&&(a(),n==="close"&&c())},[n,c,a]),x=hB({isAnimatingOpenOnMount:h,animate:e.animate,placeholder:e.placeholder});return _.createElement(e.placeholder.tagName,{style:x,"data-rfd-placeholder-context-id":l,onTransitionEnd:m,ref:e.innerRef})};var pB=_.memo(fB);class mB extends _.PureComponent{constructor(...t){super(...t),this.state={isVisible:!!this.props.on,data:this.props.on,animate:this.props.shouldAnimate&&this.props.on?"open":"none"},this.onClose=()=>{this.state.animate==="close"&&this.setState({isVisible:!1})}}static getDerivedStateFromProps(t,r){return t.shouldAnimate?t.on?{isVisible:!0,data:t.on,animate:"open"}:r.isVisible?{isVisible:!0,data:r.data,animate:"close"}:{isVisible:!1,animate:"close",data:null}:{isVisible:!!t.on,data:t.on,animate:"none"}}render(){if(!this.state.isVisible)return null;const t={onClose:this.onClose,data:this.state.data,animate:this.state.animate};return this.props.children(t)}}const gB=e=>{const t=b.useContext(Of);t||Bt();const{contextId:r,isMovementAllowed:n}=t,a=b.useRef(null),c=b.useRef(null),{children:l,droppableId:h,type:p,mode:m,direction:x,ignoreContainerClipping:y,isDropDisabled:w,isCombineEnabled:v,snapshot:k,useClone:L,updateViewportMaxScroll:E,getContainerForClone:R}=e,B=Tr(()=>a.current,[]),W=Tr((te=null)=>{a.current=te},[]);Tr(()=>c.current,[]);const F=Tr((te=null)=>{c.current=te},[]),U=Tr(()=>{n()&&E({maxScroll:Ev()})},[n,E]);uB({droppableId:h,type:p,mode:m,direction:x,isDropDisabled:w,isCombineEnabled:v,ignoreContainerClipping:y,getDroppableRef:B});const V=Cn(()=>_.createElement(mB,{on:e.placeholder,shouldAnimate:e.shouldAnimatePlaceholder},({onClose:te,data:ke,animate:$e})=>_.createElement(pB,{placeholder:ke,onClose:te,innerRef:F,animate:$e,contextId:r,onTransitionEnd:U})),[r,U,e.placeholder,e.shouldAnimatePlaceholder,F]),Z=Cn(()=>({innerRef:W,placeholder:V,droppableProps:{"data-rfd-droppable-id":h,"data-rfd-droppable-context-id":r}}),[r,h,V,W]),le=L?L.dragging.draggableId:null,xe=Cn(()=>({droppableId:h,type:p,isUsingCloneFor:le}),[h,le,p]);function fe(){if(!L)return null;const{dragging:te,render:ke}=L,$e=_.createElement(Vv,{draggableId:te.draggableId,index:te.source.index,isClone:!0,isEnabled:!0,shouldRespectForcePress:!1,canDragInteractiveElements:!0},(Y,Ae)=>ke(Y,Ae,te));return H9.createPortal($e,R())}return _.createElement(hg.Provider,{value:xe},l(Z,k),fe())};function xB(){return document.body||Bt(),document.body}const w5={mode:"standard",type:"DEFAULT",direction:"vertical",isDropDisabled:!1,isCombineEnabled:!1,ignoreContainerClipping:!1,renderClone:null,getContainerForClone:xB},Kv=e=>{let t={...e},r;for(r in w5)e[r]===void 0&&(t={...t,[r]:w5[r]});return t},sm=(e,t)=>e===t.droppable.type,A5=(e,t)=>t.draggables[e.draggable.id],bB=()=>{const e={placeholder:null,shouldAnimatePlaceholder:!0,snapshot:{isDraggingOver:!1,draggingOverWith:null,draggingFromThisWith:null,isUsingPlaceholder:!1},useClone:null},t={...e,shouldAnimatePlaceholder:!1},r=fi(c=>({draggableId:c.id,type:c.type,source:{index:c.index,droppableId:c.droppableId}})),n=fi((c,l,h,p,m,x)=>{const y=m.descriptor.id;if(m.descriptor.droppableId===c){const k=x?{render:x,dragging:r(m.descriptor)}:null,L={isDraggingOver:h,draggingOverWith:h?y:null,draggingFromThisWith:y,isUsingPlaceholder:!0};return{placeholder:m.placeholder,shouldAnimatePlaceholder:!1,snapshot:L,useClone:k}}if(!l)return t;if(!p)return e;const v={isDraggingOver:h,draggingOverWith:y,draggingFromThisWith:null,isUsingPlaceholder:!0};return{placeholder:m.placeholder,shouldAnimatePlaceholder:!0,snapshot:v,useClone:null}});return(c,l)=>{const h=Kv(l),p=h.droppableId,m=h.type,x=!h.isDropDisabled,y=h.renderClone;if(bd(c)){const w=c.critical;if(!sm(m,w))return t;const v=A5(w,c.dimensions),k=ja(c.impact)===p;return n(p,x,k,k,v,y)}if(c.phase==="DROP_ANIMATING"){const w=c.completed;if(!sm(m,w.critical))return t;const v=A5(w.critical,c.dimensions);return n(p,x,Wv(w.result)===p,ja(w.impact)===p,v,y)}if(c.phase==="IDLE"&&c.completed&&!c.shouldFlush){const w=c.completed;if(!sm(m,w.critical))return t;const v=ja(w.impact)===p,k=!!(w.impact.at&&w.impact.at.type==="COMBINE"),L=w.critical.droppable.id===p;return v?k?e:t:L?e:t}return t}},yB={updateViewportMaxScroll:NM},Sl=Yy(bB,yB,(e,t,r)=>({...Kv(r),...e,...t}),{context:cg,areStatePropsEqual:Hv})(gB);function vB(){if(typeof window>"u")return Tu(void 0);try{const e=window.localStorage.getItem(qm);return Tu(e?JSON.parse(e):void 0)}catch{return Tu(void 0)}}function im(e){if(!(typeof window>"u"))try{const t=window.localStorage.getItem(qm),r=t?JSON.parse(t):{},n=Tu({...r,...e});window.localStorage.setItem(qm,JSON.stringify(n))}catch{}}function wB(){const[e,t]=_.useState(vB);_.useEffect(()=>{im(e)},[e]);const r=_.useCallback(a=>{t(c=>{const l=Tu({...c,...a});return im(l),l})},[]),n=_.useCallback(()=>{const a=Tu(void 0);t(a),im(a)},[]);return{terminalSettings:e,updateTerminalSettings:r,resetTerminalSettings:n}}const d1="termdock-settings";function AB(e){return e==="shell"||e==="tmux"}function TB(){if(typeof window>"u")return{mode:"shell",tmuxName:"",userSelectedMode:null};try{const e=window.localStorage.getItem(d1);if(!e)return{mode:"shell",tmuxName:"",userSelectedMode:null};const t=JSON.parse(e),r=t.newSessionModeUserSelected===!0&&AB(t.newSessionMode)?t.newSessionMode:null,n=r??"shell",a=typeof t.newSessionTmuxName=="string"?t.newSessionTmuxName:"";return{mode:n,tmuxName:a,userSelectedMode:r}}catch{return{mode:"shell",tmuxName:"",userSelectedMode:null}}}function T5(e){if(!(typeof window>"u"))try{const t=window.localStorage.getItem(d1),n={...t?JSON.parse(t):{},...e};window.localStorage.setItem(d1,JSON.stringify(n))}catch{}}function CB(){const[e,t]=_.useState(TB),r=_.useCallback((a,c)=>{const l=c?.userInitiated!==!1;t(h=>({...h,mode:a,userSelectedMode:l?a:h.userSelectedMode})),l&&T5({newSessionMode:a,newSessionModeUserSelected:!0})},[]),n=_.useCallback(a=>{t(c=>({...c,tmuxName:a})),T5({newSessionTmuxName:a})},[]);return{newSessionMode:e.mode,newSessionTmuxName:e.tmuxName,userSelectedNewSessionMode:e.userSelectedMode,setNewSessionMode:r,setNewSessionTmuxName:n}}const SB=550,_B=10;function Xv(){const e=b.useRef(null),t=b.useRef(null),r=b.useRef(!1),n=b.useRef(!1),a=b.useRef(null),c=b.useCallback(()=>{e.current!=null&&(window.clearTimeout(e.current),e.current=null)},[]),l=b.useCallback(()=>{c(),t.current=null},[c]);return b.useCallback(p=>({onPointerDown:m=>{m.pointerType!=="touch"&&m.pointerType!=="pen"||(l(),r.current=!1,t.current={pointerId:m.pointerId,startX:m.clientX,startY:m.clientY},e.current=window.setTimeout(()=>{e.current=null,t.current&&(r.current=!0,p())},SB))},onPointerMove:m=>{const x=t.current;if(!x||x.pointerId!==m.pointerId||r.current)return;const y=m.clientX-x.startX,w=m.clientY-x.startY;Math.hypot(y,w)>_B&&l()},onPointerUp:m=>{r.current&&(m.preventDefault(),r.current=!1,n.current=!0,a.current!=null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{n.current=!1,a.current=null},600)),l()},onPointerCancel:l,onPointerLeave:m=>{t.current?.pointerId===m.pointerId&&!r.current&&l()},onClickCapture:m=>{n.current&&(n.current=!1,a.current!=null&&(window.clearTimeout(a.current),a.current=null),m.preventDefault(),m.stopPropagation())}}),[l])}function C5({mode:e,activeProgram:t,promptState:r,shellNames:n}){return e!=="tmux"?!1:r==="running"?!0:r==="idle"?!1:t===null||!n.has(t.toLowerCase())}function kB(e,t,r){return!!(e&&t===e&&!r)}function LB({groupId:e,version:t,onRestore:r}){const[n,a]=b.useState([]),[c,l]=b.useState(null),[h,p]=b.useState(""),m=b.useRef(!1);b.useEffect(()=>{let y=!0;const w=async()=>{try{const k=await uw();y&&a(k.entries.filter(L=>L.groups.some(E=>E.id===e)))}catch{}};w();const v=setInterval(()=>{document.hidden||w()},1e4);return()=>{y=!1,clearInterval(v)}},[e,t]);const x=async y=>{if(!m.current){m.current=!0,l(y.sessionId),p("");try{const w=await dw(y.sessionId);await r(w.session),a(v=>v.filter(k=>k.sessionId!==y.sessionId))}catch(w){p(w instanceof Error?w.message:"恢复失败,归档已保留")}finally{m.current=!1,l(null)}}};return!n.length&&!h?null:s.jsxs("details",{className:"border-t border-border/15 text-muted-foreground",children:[s.jsxs("summary",{className:"flex min-h-11 cursor-pointer items-center gap-2 px-2 text-[11px]",children:[s.jsx(m3,{size:13}),"已归档的执行会话 · ",n.length]}),h&&s.jsx("p",{role:"alert",className:"px-2 pb-2 text-xs text-destructive",children:h}),n.map(y=>s.jsxs("div",{className:"border-t border-border/10 px-2 py-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-foreground",children:y.title}),s.jsxs("button",{type:"button",disabled:c!==null,onClick:()=>{x(y)},className:"inline-flex min-h-11 shrink-0 items-center gap-1 rounded-md px-2 text-xs text-primary hover:bg-primary/10 disabled:opacity-40",children:[c===y.sessionId&&s.jsx(yn,{size:12,className:"animate-spin"}),c===y.sessionId?"恢复中…":"恢复"]})]}),s.jsx("p",{className:"text-[10px] leading-4",children:y.cleanup.state==="removed"?"执行目录已回收,恢复时重建;分支和结果保留。":y.cleanup.reason||"目录保留,可继续恢复原会话。"}),s.jsxs("details",{children:[s.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-[10px]",children:[y.agent.slug," 会话 ID 与目录"]}),s.jsx("code",{className:"block select-text break-all text-[10px]",children:y.agent.sessionId}),s.jsx("span",{className:"mt-1 block select-text break-all text-[10px]",children:y.cwd})]})]},y.sessionId))]})}function S5(e,t){const r=new Set,n=new Set;for(const a of e.filter(c=>c.groupId===t)){const c=a.attempts.find(h=>h.id===a.activeAttemptId)?.assignee,l=c&&a.memberSessions[`${c.serviceId}:${c.sessionId}`];if(a.status==="open"){l&&n.add(l);const h=a.scheduledAssignee;h&&n.add(a.memberSessions[`${h.serviceId}:${h.sessionId}`])}else l&&a.workspace&&a.workflow?.kind==="step"&&a.workflow.isolated&&r.add(l);a.coordinator&&n.add(a.memberSessions[`${a.coordinator.serviceId}:${a.coordinator.sessionId}`]),a.workflow?.reviewers.forEach(h=>n.add(a.memberSessions[`${h.serviceId}:${h.sessionId}`]))}return n.forEach(a=>r.delete(a)),r}const yf={ack:"成员确认接手",working:"成员报告进行中",blocked:"成员报告受阻",complete:"成员提交结果",failed:"成员报告失败"};function Jv(e){const t=e.attempts.find(h=>h.id===e.activeAttemptId)?.report;if(!t)return null;const r=typeof t.content=="string"?t.content:"",n=t.summary,a=r.split(/\n\s*\n/).map(h=>h.split(`
128
128
  `).filter(p=>!/^#{1,6}\s/.test(p)).join(`
129
- `).trim()).find(Boolean),c=typeof n=="string"&&n.trim()?n.trim():a,l=Number.isFinite(t.createdAt)&&t.createdAt>0&&Number.isFinite(new Date(t.createdAt).getTime());return{status:t.status,label:yf[t.status]??"成员明确报告",createdAt:l?t.createdAt:null,content:r,summary:c?c.slice(0,512):"报告摘要未提供,请查看详情中的原始报告"}}function $f(e){if(e.status!=="open")return[];const t=Jv(e),r=t&&["blocked","failed"].includes(t.status)?{source:"member",label:t.label,content:t.content,summary:t.summary,createdAt:t.createdAt}:null,n=r&&(e.automationIssueSource==="member-report"||!e.summaryOnly&&!!t?.content&&e.automationIssue===t.content.slice(0,1e3)),a=r&&!t?.content&&!e.automationIssueSource,c=e.automationIssue&&!n?{source:a?"unknown":"system",label:a?"服务记录(来源待核对)":e.automationIssue.startsWith("消息投递")?"投递需要处理":e.activeAttemptId?"自动安排受阻":"执行准备受阻",content:e.automationIssue,summary:e.automationIssue}:null;return[r,c].filter(l=>!!l)}function IB(e){return $f(e)[0]??null}function Qc(e){if(e.status==="accepted")return e.completionMode==="reviewed"?"独立评审通过":"已验收";if(e.status==="closed")return"已关闭";if(e.decisions.some(l=>l.status==="pending"))return"需要你回答";const t=IB(e);if(t)return t.label;if(e.workflow?.paused)return"自动安排已暂停";const r=e.attempts.find(l=>l.id===e.activeAttemptId),n=e.artifacts.filter(l=>l.kind==="plan"&&l.attemptId===e.activeAttemptId).at(-1);if(n&&n.id!==e.approvedPlanArtifactId)return"需要你确认方案";const a=e.artifacts.filter(l=>l.kind==="result"&&l.attemptId===e.activeAttemptId).at(-1),c=a&&e.events.some(l=>l.kind==="revise"&&l.attemptId===e.activeAttemptId&&l.createdAt>=a.createdAt);if(a&&!c){const l=e.artifacts.filter(h=>h.kind==="review"&&h.reviewsArtifactId===a.id).at(-1);return e.workflow&&l?.verdict!=="pass"?l?.verdict==="changes"?"评审要求修改":"等待独立评审":e.workflow?.kind==="step"?"评审通过 · 等待接续":"等待你验收"}return c?e.events.some(l=>l.kind==="revise"&&l.source==="user"&&l.attemptId===e.activeAttemptId&&l.createdAt>=a.createdAt)?"已要求跟进 · 等待新结果":"已要求修改 · 等待新结果":r?r.report?yf[r.report.status]:["failed","expired"].includes(r.deliveryStatus??"")?"投递未成功":e.deliveries.some(l=>l.attemptId===e.activeAttemptId&&l.error)?"投递需要关注":r.deliveryStatus==="delivered"?"已写入终端 · 等待回复":"等待投递":e.scheduledAssignee?e.dependsOn.length?"依赖完成后自动分派":e.workflow?.isolated===!1?"等待分派":"准备独立执行目录":e.dependsOn.length?"等待依赖与分派":"待分派"}function $i(e){return e.status==="open"&&["需要你回答","需要你确认方案","等待你验收","执行准备受阻","自动安排受阻","成员报告受阻","成员报告失败","投递未成功","投递需要关注","投递需要处理"].includes(Qc(e))}const mu=rc(e=>{let t=!1;return{tasks:[],allTasks:[],error:null,refresh:async()=>{if(!t){t=!0;try{const{tasks:r}=await o3();e({tasks:r.filter($i),allTasks:r,error:null})}catch(r){e({error:r instanceof Error?r.message:"协作待处理事项加载失败"})}finally{t=!1}}}}});function _5(e,t){try{localStorage.setItem(`termdock:tasks:${location.origin}:${e}:open-task`,JSON.stringify(t))}catch{}window.dispatchEvent(new CustomEvent("open-collaboration-task",{detail:{groupId:e,taskId:t}}))}function k5({sessionIds:e}){const t=hw(a=>e.reduce((c,l)=>c+(a.unread[l]?.length??0),0)),{locale:r}=zr();if(!t)return null;const n=r==="zh"?`${t} 条未读进展`:`${t} unread progress updates`;return s.jsx("span",{title:n,"aria-label":n,className:"inline-flex h-4 min-w-4 shrink-0 items-center justify-center rounded-full bg-primary/15 px-1 text-[10px] font-medium text-primary",children:t>99?"99+":t})}function EB(e){if(!e.startsWith("remote:"))return null;const t=e.slice(7).split(":");if(t.length!==2)return null;try{const r=decodeURIComponent(t[0]),n=decodeURIComponent(t[1]),a=new URL(r);return!["https:","http:"].includes(a.protocol)||a.origin!==r||!n?null:{origin:r,sessionId:n}}catch{return null}}async function e6(e){const t=EB(e);if(!t)throw new Error("远端会话标识无效");if(window.termdockDesktop?.collaborationFocus)try{if(await window.termdockDesktop.collaborationFocus(e))return}catch{}window.dispatchEvent(new CustomEvent("termdock:open-remote-session",{detail:t}))}function NB(e,t,r){return Math.max(t,Math.min(e,r))}const hs={toVector(e,t){return e===void 0&&(e=t),Array.isArray(e)?e:[e,e]},add(e,t){return[e[0]+t[0],e[1]+t[1]]},sub(e,t){return[e[0]-t[0],e[1]-t[1]]},addTo(e,t){e[0]+=t[0],e[1]+=t[1]},subTo(e,t){e[0]-=t[0],e[1]-=t[1]}};function L5(e,t,r){return t===0||Math.abs(t)===1/0?Math.pow(e,r*5):e*t*r/(t+r*e)}function I5(e,t,r,n=.15){return n===0?NB(e,t,r):e<t?-L5(t-e,r-t,n)+t:e>r?+L5(e-r,r-t,n)+r:e}function RB(e,[t,r],[n,a]){const[[c,l],[h,p]]=e;return[I5(t,c,l,n),I5(r,h,p,a)]}function MB(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function jB(e){var t=MB(e,"string");return typeof t=="symbol"?t:String(t)}function Ps(e,t,r){return t=jB(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function E5(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function vs(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?E5(Object(r),!0).forEach(function(n){Ps(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):E5(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}const t6={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function N5(e){return e?e[0].toUpperCase()+e.slice(1):""}const DB=["enter","leave"];function BB(e=!1,t){return e&&!DB.includes(t)}function QB(e,t="",r=!1){const n=t6[e],a=n&&n[t]||t;return"on"+N5(e)+N5(a)+(BB(r,a)?"Capture":"")}const PB=["gotpointercapture","lostpointercapture"];function OB(e){let t=e.substring(2).toLowerCase();const r=!!~t.indexOf("passive");r&&(t=t.replace("passive",""));const n=PB.includes(t)?"capturecapture":"capture",a=!!~t.indexOf(n);return a&&(t=t.replace("capture","")),{device:t,capture:a,passive:r}}function FB(e,t=""){const r=t6[e],n=r&&r[t]||t;return e+n}function Uf(e){return"touches"in e}function r6(e){return Uf(e)?"touch":"pointerType"in e?e.pointerType:"mouse"}function $B(e){return Array.from(e.touches).filter(t=>{var r,n;return t.target===e.currentTarget||((r=e.currentTarget)===null||r===void 0||(n=r.contains)===null||n===void 0?void 0:n.call(r,t.target))})}function UB(e){return e.type==="touchend"||e.type==="touchcancel"?e.changedTouches:e.targetTouches}function n6(e){return Uf(e)?UB(e)[0]:e}function h1(e,t){try{const r=t.clientX-e.clientX,n=t.clientY-e.clientY,a=(t.clientX+e.clientX)/2,c=(t.clientY+e.clientY)/2,l=Math.hypot(r,n);return{angle:-(Math.atan2(r,n)*180)/Math.PI,distance:l,origin:[a,c]}}catch{}return null}function zB(e){return $B(e).map(t=>t.identifier)}function R5(e,t){const[r,n]=Array.from(e.touches).filter(a=>t.includes(a.identifier));return h1(r,n)}function am(e){const t=n6(e);return Uf(e)?t.identifier:t.pointerId}function Bu(e){const t=n6(e);return[t.clientX,t.clientY]}const M5=40,j5=800;function s6(e){let{deltaX:t,deltaY:r,deltaMode:n}=e;return n===1?(t*=M5,r*=M5):n===2&&(t*=j5,r*=j5),[t,r]}function HB(e){var t,r;const{scrollX:n,scrollY:a,scrollLeft:c,scrollTop:l}=e.currentTarget;return[(t=n??c)!==null&&t!==void 0?t:0,(r=a??l)!==null&&r!==void 0?r:0]}function WB(e){const t={};if("buttons"in e&&(t.buttons=e.buttons),"shiftKey"in e){const{shiftKey:r,altKey:n,metaKey:a,ctrlKey:c}=e;Object.assign(t,{shiftKey:r,altKey:n,metaKey:a,ctrlKey:c})}return t}function vf(e,...t){return typeof e=="function"?e(...t):e}function GB(){}function VB(...e){return e.length===0?GB:e.length===1?e[0]:function(){let t;for(const r of e)t=r.apply(this,arguments)||t;return t}}function D5(e,t){return Object.assign({},t,e||{})}const qB=32;class i6{constructor(t,r,n){this.ctrl=t,this.args=r,this.key=n,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(t){this.ctrl.state[this.key]=t}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:t,shared:r,ingKey:n,args:a}=this;r[n]=t._active=t.active=t._blocked=t._force=!1,t._step=[!1,!1],t.intentional=!1,t._movement=[0,0],t._distance=[0,0],t._direction=[0,0],t._delta=[0,0],t._bounds=[[-1/0,1/0],[-1/0,1/0]],t.args=a,t.axis=void 0,t.memo=void 0,t.elapsedTime=t.timeDelta=0,t.direction=[0,0],t.distance=[0,0],t.overflow=[0,0],t._movementBound=[!1,!1],t.velocity=[0,0],t.movement=[0,0],t.delta=[0,0],t.timeStamp=0}start(t){const r=this.state,n=this.config;r._active||(this.reset(),this.computeInitial(),r._active=!0,r.target=t.target,r.currentTarget=t.currentTarget,r.lastOffset=n.from?vf(n.from,r):r.offset,r.offset=r.lastOffset,r.startTime=r.timeStamp=t.timeStamp)}computeValues(t){const r=this.state;r._values=t,r.values=this.config.transform(t)}computeInitial(){const t=this.state;t._initial=t._values,t.initial=t.values}compute(t){const{state:r,config:n,shared:a}=this;r.args=this.args;let c=0;if(t&&(r.event=t,n.preventDefault&&t.cancelable&&r.event.preventDefault(),r.type=t.type,a.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,a.locked=!!document.pointerLockElement,Object.assign(a,WB(t)),a.down=a.pressed=a.buttons%2===1||a.touches>0,c=t.timeStamp-r.timeStamp,r.timeStamp=t.timeStamp,r.elapsedTime=r.timeStamp-r.startTime),r._active){const V=r._delta.map(Math.abs);hs.addTo(r._distance,V)}this.axisIntent&&this.axisIntent(t);const[l,h]=r._movement,[p,m]=n.threshold,{_step:x,values:y}=r;if(n.hasCustomTransform?(x[0]===!1&&(x[0]=Math.abs(l)>=p&&y[0]),x[1]===!1&&(x[1]=Math.abs(h)>=m&&y[1])):(x[0]===!1&&(x[0]=Math.abs(l)>=p&&Math.sign(l)*p),x[1]===!1&&(x[1]=Math.abs(h)>=m&&Math.sign(h)*m)),r.intentional=x[0]!==!1||x[1]!==!1,!r.intentional)return;const w=[0,0];if(n.hasCustomTransform){const[V,Z]=y;w[0]=x[0]!==!1?V-x[0]:0,w[1]=x[1]!==!1?Z-x[1]:0}else w[0]=x[0]!==!1?l-x[0]:0,w[1]=x[1]!==!1?h-x[1]:0;this.restrictToAxis&&!r._blocked&&this.restrictToAxis(w);const v=r.offset,k=r._active&&!r._blocked||r.active;k&&(r.first=r._active&&!r.active,r.last=!r._active&&r.active,r.active=a[this.ingKey]=r._active,t&&(r.first&&("bounds"in n&&(r._bounds=vf(n.bounds,r)),this.setup&&this.setup()),r.movement=w,this.computeOffset()));const[L,E]=r.offset,[[R,B],[W,F]]=r._bounds;r.overflow=[L<R?-1:L>B?1:0,E<W?-1:E>F?1:0],r._movementBound[0]=r.overflow[0]?r._movementBound[0]===!1?r._movement[0]:r._movementBound[0]:!1,r._movementBound[1]=r.overflow[1]?r._movementBound[1]===!1?r._movement[1]:r._movementBound[1]:!1;const U=r._active?n.rubberband||[0,0]:[0,0];if(r.offset=RB(r._bounds,r.offset,U),r.delta=hs.sub(r.offset,v),this.computeMovement(),k&&(!r.last||c>qB)){r.delta=hs.sub(r.offset,v);const V=r.delta.map(Math.abs);hs.addTo(r.distance,V),r.direction=r.delta.map(Math.sign),r._direction=r._delta.map(Math.sign),!r.first&&c>0&&(r.velocity=[V[0]/c,V[1]/c],r.timeDelta=c)}}emit(){const t=this.state,r=this.shared,n=this.config;if(t._active||this.clean(),(t._blocked||!t.intentional)&&!t._force&&!n.triggerAllEvents)return;const a=this.handler(vs(vs(vs({},r),t),{},{[this.aliasKey]:t.values}));a!==void 0&&(t.memo=a)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function YB([e,t],r){const n=Math.abs(e),a=Math.abs(t);if(n>a&&n>r)return"x";if(a>n&&a>r)return"y"}class Id extends i6{constructor(...t){super(...t),Ps(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=hs.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=hs.sub(this.state.offset,this.state.lastOffset)}axisIntent(t){const r=this.state,n=this.config;if(!r.axis&&t){const a=typeof n.axisThreshold=="object"?n.axisThreshold[r6(t)]:n.axisThreshold;r.axis=YB(r._movement,a)}r._blocked=(n.lockDirection||!!n.axis)&&!r.axis||!!n.axis&&n.axis!==r.axis}restrictToAxis(t){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":t[1]=0;break;case"y":t[0]=0;break}}}const ZB=e=>e,B5=.15,a6={enabled(e=!0){return e},eventOptions(e,t,r){return vs(vs({},r.shared.eventOptions),e)},preventDefault(e=!1){return e},triggerAllEvents(e=!1){return e},rubberband(e=0){switch(e){case!0:return[B5,B5];case!1:return[0,0];default:return hs.toVector(e)}},from(e){if(typeof e=="function")return e;if(e!=null)return hs.toVector(e)},transform(e,t,r){const n=e||r.shared.transform;return this.hasCustomTransform=!!n,n||ZB},threshold(e){return hs.toVector(e,0)}},KB=0,Oc=vs(vs({},a6),{},{axis(e,t,{axis:r}){if(this.lockDirection=r==="lock",!this.lockDirection)return r},axisThreshold(e=KB){return e},bounds(e={}){if(typeof e=="function")return c=>Oc.bounds(e(c));if("current"in e)return()=>e.current;if(typeof HTMLElement=="function"&&e instanceof HTMLElement)return e;const{left:t=-1/0,right:r=1/0,top:n=-1/0,bottom:a=1/0}=e;return[[t,r],[n,a]]}}),Q5={ArrowRight:(e,t=1)=>[e*t,0],ArrowLeft:(e,t=1)=>[-1*e*t,0],ArrowUp:(e,t=1)=>[0,-1*e*t],ArrowDown:(e,t=1)=>[0,e*t]};class XB extends Id{constructor(...t){super(...t),Ps(this,"ingKey","dragging")}reset(){super.reset();const t=this.state;t._pointerId=void 0,t._pointerActive=!1,t._keyboardActive=!1,t._preventScroll=!1,t._delayed=!1,t.swipe=[0,0],t.tap=!1,t.canceled=!1,t.cancel=this.cancel.bind(this)}setup(){const t=this.state;if(t._bounds instanceof HTMLElement){const r=t._bounds.getBoundingClientRect(),n=t.currentTarget.getBoundingClientRect(),a={left:r.left-n.left+t.offset[0],right:r.right-n.right+t.offset[0],top:r.top-n.top+t.offset[1],bottom:r.bottom-n.bottom+t.offset[1]};t._bounds=Oc.bounds(a)}}cancel(){const t=this.state;t.canceled||(t.canceled=!0,t._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(t){const r=this.config,n=this.state;if(t.buttons!=null&&(Array.isArray(r.pointerButtons)?!r.pointerButtons.includes(t.buttons):r.pointerButtons!==-1&&r.pointerButtons!==t.buttons))return;const a=this.ctrl.setEventIds(t);r.pointerCapture&&t.target.setPointerCapture(t.pointerId),!(a&&a.size>1&&n._pointerActive)&&(this.start(t),this.setupPointer(t),n._pointerId=am(t),n._pointerActive=!0,this.computeValues(Bu(t)),this.computeInitial(),r.preventScrollAxis&&r6(t)!=="mouse"?(n._active=!1,this.setupScrollPrevention(t)):r.delay>0?(this.setupDelayTrigger(t),r.triggerAllEvents&&(this.compute(t),this.emit())):this.startPointerDrag(t))}startPointerDrag(t){const r=this.state;r._active=!0,r._preventScroll=!0,r._delayed=!1,this.compute(t),this.emit()}pointerMove(t){const r=this.state,n=this.config;if(!r._pointerActive)return;const a=am(t);if(r._pointerId!==void 0&&a!==r._pointerId)return;const c=Bu(t);if(document.pointerLockElement===t.target?r._delta=[t.movementX,t.movementY]:(r._delta=hs.sub(c,r._values),this.computeValues(c)),hs.addTo(r._movement,r._delta),this.compute(t),r._delayed&&r.intentional){this.timeoutStore.remove("dragDelay"),r.active=!1,this.startPointerDrag(t);return}if(n.preventScrollAxis&&!r._preventScroll)if(r.axis)if(r.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){r._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(t);return}else return;this.emit()}pointerUp(t){this.ctrl.setEventIds(t);try{this.config.pointerCapture&&t.target.hasPointerCapture(t.pointerId)&&t.target.releasePointerCapture(t.pointerId)}catch{}const r=this.state,n=this.config;if(!r._active||!r._pointerActive)return;const a=am(t);if(r._pointerId!==void 0&&a!==r._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(t);const[c,l]=r._distance;if(r.tap=c<=n.tapsThreshold&&l<=n.tapsThreshold,r.tap&&n.filterTaps)r._force=!0;else{const[h,p]=r._delta,[m,x]=r._movement,[y,w]=n.swipe.velocity,[v,k]=n.swipe.distance,L=n.swipe.duration;if(r.elapsedTime<L){const E=Math.abs(h/r.timeDelta),R=Math.abs(p/r.timeDelta);E>y&&Math.abs(m)>v&&(r.swipe[0]=Math.sign(h)),R>w&&Math.abs(x)>k&&(r.swipe[1]=Math.sign(p))}}this.emit()}pointerClick(t){!this.state.tap&&t.detail>0&&(t.preventDefault(),t.stopPropagation())}setupPointer(t){const r=this.config,n=r.device;r.pointerLock&&t.currentTarget.requestPointerLock(),r.pointerCapture||(this.eventStore.add(this.sharedConfig.window,n,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(t){this.state._preventScroll&&t.cancelable&&t.preventDefault()}setupScrollPrevention(t){this.state._preventScroll=!1,JB(t);const r=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",r),this.eventStore.add(this.sharedConfig.window,"touch","cancel",r),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,t)}setupDelayTrigger(t){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(t)},this.config.delay)}keyDown(t){const r=Q5[t.key];if(r){const n=this.state,a=t.shiftKey?10:t.altKey?.1:1;this.start(t),n._delta=r(this.config.keyboardDisplacement,a),n._keyboardActive=!0,hs.addTo(n._movement,n._delta),this.compute(t),this.emit()}}keyUp(t){t.key in Q5&&(this.state._keyboardActive=!1,this.setActive(),this.compute(t),this.emit())}bind(t){const r=this.config.device;t(r,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(t(r,"change",this.pointerMove.bind(this)),t(r,"end",this.pointerUp.bind(this)),t(r,"cancel",this.pointerUp.bind(this)),t("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(t("key","down",this.keyDown.bind(this)),t("key","up",this.keyUp.bind(this))),this.config.filterTaps&&t("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function JB(e){"persist"in e&&typeof e.persist=="function"&&e.persist()}const Ed=typeof window<"u"&&window.document&&window.document.createElement;function o6(){return Ed&&"ontouchstart"in window}function eQ(){return o6()||Ed&&window.navigator.maxTouchPoints>1}function tQ(){return Ed&&"onpointerdown"in window}function rQ(){return Ed&&"exitPointerLock"in window.document}function nQ(){try{return"constructor"in GestureEvent}catch{return!1}}const oo={isBrowser:Ed,gesture:nQ(),touch:o6(),touchscreen:eQ(),pointer:tQ(),pointerLock:rQ()},sQ=250,iQ=180,aQ=.5,oQ=50,lQ=250,cQ=10,P5={mouse:0,touch:0,pen:8},uQ=vs(vs({},Oc),{},{device(e,t,{pointer:{touch:r=!1,lock:n=!1,mouse:a=!1}={}}){return this.pointerLock=n&&oo.pointerLock,oo.touch&&r?"touch":this.pointerLock?"mouse":oo.pointer&&!a?"pointer":oo.touch?"touch":"mouse"},preventScrollAxis(e,t,{preventScroll:r}){if(this.preventScrollDelay=typeof r=="number"?r:r||r===void 0&&e?sQ:void 0,!(!oo.touchscreen||r===!1))return e||(r!==void 0?"y":void 0)},pointerCapture(e,t,{pointer:{capture:r=!0,buttons:n=1,keys:a=!0}={}}){return this.pointerButtons=n,this.keys=a,!this.pointerLock&&this.device==="pointer"&&r},threshold(e,t,{filterTaps:r=!1,tapsThreshold:n=3,axis:a=void 0}){const c=hs.toVector(e,r?n:a?1:0);return this.filterTaps=r,this.tapsThreshold=n,c},swipe({velocity:e=aQ,distance:t=oQ,duration:r=lQ}={}){return{velocity:this.transform(hs.toVector(e)),distance:this.transform(hs.toVector(t)),duration:r}},delay(e=0){switch(e){case!0:return iQ;case!1:return 0;default:return e}},axisThreshold(e){return e?vs(vs({},P5),e):P5},keyboardDisplacement(e=cQ){return e}});function l6(e){const[t,r]=e.overflow,[n,a]=e._delta,[c,l]=e._direction;(t<0&&n>0&&c<0||t>0&&n<0&&c>0)&&(e._movement[0]=e._movementBound[0]),(r<0&&a>0&&l<0||r>0&&a<0&&l>0)&&(e._movement[1]=e._movementBound[1])}const dQ=30,hQ=100;class fQ extends i6{constructor(...t){super(...t),Ps(this,"ingKey","pinching"),Ps(this,"aliasKey","da")}init(){this.state.offset=[1,0],this.state.lastOffset=[1,0],this.state._pointerEvents=new Map}reset(){super.reset();const t=this.state;t._touchIds=[],t.canceled=!1,t.cancel=this.cancel.bind(this),t.turns=0}computeOffset(){const{type:t,movement:r,lastOffset:n}=this.state;t==="wheel"?this.state.offset=hs.add(r,n):this.state.offset=[(1+r[0])*n[0],r[1]+n[1]]}computeMovement(){const{offset:t,lastOffset:r}=this.state;this.state.movement=[t[0]/r[0],t[1]-r[1]]}axisIntent(){const t=this.state,[r,n]=t._movement;if(!t.axis){const a=Math.abs(r)*dQ-Math.abs(n);a<0?t.axis="angle":a>0&&(t.axis="scale")}}restrictToAxis(t){this.config.lockDirection&&(this.state.axis==="scale"?t[1]=0:this.state.axis==="angle"&&(t[0]=0))}cancel(){const t=this.state;t.canceled||setTimeout(()=>{t.canceled=!0,t._active=!1,this.compute(),this.emit()},0)}touchStart(t){this.ctrl.setEventIds(t);const r=this.state,n=this.ctrl.touchIds;if(r._active&&r._touchIds.every(c=>n.has(c))||n.size<2)return;this.start(t),r._touchIds=Array.from(n).slice(0,2);const a=R5(t,r._touchIds);a&&this.pinchStart(t,a)}pointerStart(t){if(t.buttons!=null&&t.buttons%2!==1)return;this.ctrl.setEventIds(t),t.target.setPointerCapture(t.pointerId);const r=this.state,n=r._pointerEvents,a=this.ctrl.pointerIds;if(r._active&&Array.from(n.keys()).every(l=>a.has(l))||(n.size<2&&n.set(t.pointerId,t),r._pointerEvents.size<2))return;this.start(t);const c=h1(...Array.from(n.values()));c&&this.pinchStart(t,c)}pinchStart(t,r){const n=this.state;n.origin=r.origin,this.computeValues([r.distance,r.angle]),this.computeInitial(),this.compute(t),this.emit()}touchMove(t){if(!this.state._active)return;const r=R5(t,this.state._touchIds);r&&this.pinchMove(t,r)}pointerMove(t){const r=this.state._pointerEvents;if(r.has(t.pointerId)&&r.set(t.pointerId,t),!this.state._active)return;const n=h1(...Array.from(r.values()));n&&this.pinchMove(t,n)}pinchMove(t,r){const n=this.state,a=n._values[1],c=r.angle-a;let l=0;Math.abs(c)>270&&(l+=Math.sign(c)),this.computeValues([r.distance,r.angle-360*l]),n.origin=r.origin,n.turns=l,n._movement=[n._values[0]/n._initial[0]-1,n._values[1]-n._initial[1]],this.compute(t),this.emit()}touchEnd(t){this.ctrl.setEventIds(t),this.state._active&&this.state._touchIds.some(r=>!this.ctrl.touchIds.has(r))&&(this.state._active=!1,this.compute(t),this.emit())}pointerEnd(t){const r=this.state;this.ctrl.setEventIds(t);try{t.target.releasePointerCapture(t.pointerId)}catch{}r._pointerEvents.has(t.pointerId)&&r._pointerEvents.delete(t.pointerId),r._active&&r._pointerEvents.size<2&&(r._active=!1,this.compute(t),this.emit())}gestureStart(t){t.cancelable&&t.preventDefault();const r=this.state;r._active||(this.start(t),this.computeValues([t.scale,t.rotation]),r.origin=[t.clientX,t.clientY],this.compute(t),this.emit())}gestureMove(t){if(t.cancelable&&t.preventDefault(),!this.state._active)return;const r=this.state;this.computeValues([t.scale,t.rotation]),r.origin=[t.clientX,t.clientY];const n=r._movement;r._movement=[t.scale-1,t.rotation],r._delta=hs.sub(r._movement,n),this.compute(t),this.emit()}gestureEnd(t){this.state._active&&(this.state._active=!1,this.compute(t),this.emit())}wheel(t){const r=this.config.modifierKey;r&&(Array.isArray(r)?!r.find(n=>t[n]):!t[r])||(this.state._active?this.wheelChange(t):this.wheelStart(t),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this)))}wheelStart(t){this.start(t),this.wheelChange(t)}wheelChange(t){"uv"in t||t.cancelable&&t.preventDefault();const n=this.state;n._delta=[-s6(t)[1]/hQ*n.offset[0],0],hs.addTo(n._movement,n._delta),l6(n),this.state.origin=[t.clientX,t.clientY],this.compute(t),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){const r=this.config.device;r&&(t(r,"start",this[r+"Start"].bind(this)),t(r,"change",this[r+"Move"].bind(this)),t(r,"end",this[r+"End"].bind(this)),t(r,"cancel",this[r+"End"].bind(this)),t("lostPointerCapture","",this[r+"End"].bind(this))),this.config.pinchOnWheel&&t("wheel","",this.wheel.bind(this),{passive:!1})}}const pQ=vs(vs({},a6),{},{device(e,t,{shared:r,pointer:{touch:n=!1}={}}){if(r.target&&!oo.touch&&oo.gesture)return"gesture";if(oo.touch&&n)return"touch";if(oo.touchscreen){if(oo.pointer)return"pointer";if(oo.touch)return"touch"}},bounds(e,t,{scaleBounds:r={},angleBounds:n={}}){const a=l=>{const h=D5(vf(r,l),{min:-1/0,max:1/0});return[h.min,h.max]},c=l=>{const h=D5(vf(n,l),{min:-1/0,max:1/0});return[h.min,h.max]};return typeof r!="function"&&typeof n!="function"?[a(),c()]:l=>[a(l),c(l)]},threshold(e,t,r){return this.lockDirection=r.axis==="lock",hs.toVector(e,this.lockDirection?[.1,3]:0)},modifierKey(e){return e===void 0?"ctrlKey":e},pinchOnWheel(e=!0){return e}});class mQ extends Id{constructor(...t){super(...t),Ps(this,"ingKey","moving")}move(t){this.config.mouseOnly&&t.pointerType!=="mouse"||(this.state._active?this.moveChange(t):this.moveStart(t),this.timeoutStore.add("moveEnd",this.moveEnd.bind(this)))}moveStart(t){this.start(t),this.computeValues(Bu(t)),this.compute(t),this.computeInitial(),this.emit()}moveChange(t){if(!this.state._active)return;const r=Bu(t),n=this.state;n._delta=hs.sub(r,n._values),hs.addTo(n._movement,n._delta),this.computeValues(r),this.compute(t),this.emit()}moveEnd(t){this.state._active&&(this.state._active=!1,this.compute(t),this.emit())}bind(t){t("pointer","change",this.move.bind(this)),t("pointer","leave",this.moveEnd.bind(this))}}const gQ=vs(vs({},Oc),{},{mouseOnly:(e=!0)=>e});class xQ extends Id{constructor(...t){super(...t),Ps(this,"ingKey","scrolling")}scroll(t){this.state._active||this.start(t),this.scrollChange(t),this.timeoutStore.add("scrollEnd",this.scrollEnd.bind(this))}scrollChange(t){t.cancelable&&t.preventDefault();const r=this.state,n=HB(t);r._delta=hs.sub(n,r._values),hs.addTo(r._movement,r._delta),this.computeValues(n),this.compute(t),this.emit()}scrollEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){t("scroll","",this.scroll.bind(this))}}const bQ=Oc;class yQ extends Id{constructor(...t){super(...t),Ps(this,"ingKey","wheeling")}wheel(t){this.state._active||this.start(t),this.wheelChange(t),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this))}wheelChange(t){const r=this.state;r._delta=s6(t),hs.addTo(r._movement,r._delta),l6(r),this.compute(t),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){t("wheel","",this.wheel.bind(this))}}const vQ=Oc;class wQ extends Id{constructor(...t){super(...t),Ps(this,"ingKey","hovering")}enter(t){this.config.mouseOnly&&t.pointerType!=="mouse"||(this.start(t),this.computeValues(Bu(t)),this.compute(t),this.emit())}leave(t){if(this.config.mouseOnly&&t.pointerType!=="mouse")return;const r=this.state;if(!r._active)return;r._active=!1;const n=Bu(t);r._movement=r._delta=hs.sub(n,r._values),this.computeValues(n),this.compute(t),r.delta=r.movement,this.emit()}bind(t){t("pointer","enter",this.enter.bind(this)),t("pointer","leave",this.leave.bind(this))}}const AQ=vs(vs({},Oc),{},{mouseOnly:(e=!0)=>e}),fg=new Map,f1=new Map;function c6(e){fg.set(e.key,e.engine),f1.set(e.key,e.resolver)}const u6={key:"drag",engine:XB,resolver:uQ},TQ={key:"hover",engine:wQ,resolver:AQ},CQ={key:"move",engine:mQ,resolver:gQ},SQ={key:"pinch",engine:fQ,resolver:pQ},_Q={key:"scroll",engine:xQ,resolver:bQ},kQ={key:"wheel",engine:yQ,resolver:vQ};function LQ(e,t){if(e==null)return{};var r={},n=Object.keys(e),a,c;for(c=0;c<n.length;c++)a=n[c],!(t.indexOf(a)>=0)&&(r[a]=e[a]);return r}function IQ(e,t){if(e==null)return{};var r=LQ(e,t),n,a;if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)n=c[a],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}const EQ={target(e){if(e)return()=>"current"in e?e.current:e},enabled(e=!0){return e},window(e=oo.isBrowser?window:void 0){return e},eventOptions({passive:e=!0,capture:t=!1}={}){return{passive:e,capture:t}},transform(e){return e}},NQ=["target","eventOptions","window","enabled","transform"];function $h(e={},t){const r={};for(const[n,a]of Object.entries(t))switch(typeof a){case"function":r[n]=a.call(r,e[n],n,e);break;case"object":r[n]=$h(e[n],a);break;case"boolean":a&&(r[n]=e[n]);break}return r}function RQ(e,t,r={}){const n=e,{target:a,eventOptions:c,window:l,enabled:h,transform:p}=n,m=IQ(n,NQ);if(r.shared=$h({target:a,eventOptions:c,window:l,enabled:h,transform:p},EQ),t){const x=f1.get(t);r[t]=$h(vs({shared:r.shared},m),x)}else for(const x in m){const y=f1.get(x);y&&(r[x]=$h(vs({shared:r.shared},m[x]),y))}return r}class d6{constructor(t,r){Ps(this,"_listeners",new Set),this._ctrl=t,this._gestureKey=r}add(t,r,n,a,c){const l=this._listeners,h=FB(r,n),p=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},m=vs(vs({},p),c);t.addEventListener(h,a,m);const x=()=>{t.removeEventListener(h,a,m),l.delete(x)};return l.add(x),x}clean(){this._listeners.forEach(t=>t()),this._listeners.clear()}}class MQ{constructor(){Ps(this,"_timeouts",new Map)}add(t,r,n=140,...a){this.remove(t),this._timeouts.set(t,window.setTimeout(r,n,...a))}remove(t){const r=this._timeouts.get(t);r&&window.clearTimeout(r)}clean(){this._timeouts.forEach(t=>{window.clearTimeout(t)}),this._timeouts.clear()}}class jQ{constructor(t){Ps(this,"gestures",new Set),Ps(this,"_targetEventStore",new d6(this)),Ps(this,"gestureEventStores",{}),Ps(this,"gestureTimeoutStores",{}),Ps(this,"handlers",{}),Ps(this,"config",{}),Ps(this,"pointerIds",new Set),Ps(this,"touchIds",new Set),Ps(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),DQ(this,t)}setEventIds(t){if(Uf(t))return this.touchIds=new Set(zB(t)),this.touchIds;if("pointerId"in t)return t.type==="pointerup"||t.type==="pointercancel"?this.pointerIds.delete(t.pointerId):t.type==="pointerdown"&&this.pointerIds.add(t.pointerId),this.pointerIds}applyHandlers(t,r){this.handlers=t,this.nativeHandlers=r}applyConfig(t,r){this.config=RQ(t,r,this.config)}clean(){this._targetEventStore.clean();for(const t of this.gestures)this.gestureEventStores[t].clean(),this.gestureTimeoutStores[t].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...t){const r=this.config.shared,n={};let a;if(!(r.target&&(a=r.target(),!a))){if(r.enabled){for(const l of this.gestures){const h=this.config[l],p=O5(n,h.eventOptions,!!a);if(h.enabled){const m=fg.get(l);new m(this,t,l).bind(p)}}const c=O5(n,r.eventOptions,!!a);for(const l in this.nativeHandlers)c(l,"",h=>this.nativeHandlers[l](vs(vs({},this.state.shared),{},{event:h,args:t})),void 0,!0)}for(const c in n)n[c]=VB(...n[c]);if(!a)return n;for(const c in n){const{device:l,capture:h,passive:p}=OB(c);this._targetEventStore.add(a,l,"",n[c],{capture:h,passive:p})}}}}function lu(e,t){e.gestures.add(t),e.gestureEventStores[t]=new d6(e,t),e.gestureTimeoutStores[t]=new MQ}function DQ(e,t){t.drag&&lu(e,"drag"),t.wheel&&lu(e,"wheel"),t.scroll&&lu(e,"scroll"),t.move&&lu(e,"move"),t.pinch&&lu(e,"pinch"),t.hover&&lu(e,"hover")}const O5=(e,t,r)=>(n,a,c,l={},h=!1)=>{var p,m;const x=(p=l.capture)!==null&&p!==void 0?p:t.capture,y=(m=l.passive)!==null&&m!==void 0?m:t.passive;let w=h?n:QB(n,a,x);r&&y&&(w+="Passive"),e[w]=e[w]||[],e[w].push(c)},BQ=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function QQ(e){const t={},r={},n=new Set;for(let a in e)BQ.test(a)?(n.add(RegExp.lastMatch),r[a]=e[a]):t[a]=e[a];return[r,t,n]}function cu(e,t,r,n,a,c){if(!e.has(r)||!fg.has(n))return;const l=r+"Start",h=r+"End",p=m=>{let x;return m.first&&l in t&&t[l](m),r in t&&(x=t[r](m)),m.last&&h in t&&t[h](m),x};a[n]=p,c[n]=c[n]||{}}function PQ(e,t){const[r,n,a]=QQ(e),c={};return cu(a,r,"onDrag","drag",c,t),cu(a,r,"onWheel","wheel",c,t),cu(a,r,"onScroll","scroll",c,t),cu(a,r,"onPinch","pinch",c,t),cu(a,r,"onMove","move",c,t),cu(a,r,"onHover","hover",c,t),{handlers:c,config:t,nativeHandlers:n}}function h6(e,t={},r,n){const a=_.useMemo(()=>new jQ(e),[]);if(a.applyHandlers(e,n),a.applyConfig(t,r),_.useEffect(a.effect.bind(a)),_.useEffect(()=>a.clean.bind(a),[]),t.target===void 0)return a.bind.bind(a)}function F5(e,t){return c6(u6),h6({drag:e},t||{},"drag")}function OQ(e){return e.forEach(c6),function(r,n){const{handlers:a,nativeHandlers:c,config:l}=PQ(r,n||{});return h6(a,l,void 0,c)}}function tU(e,t){return OQ([u6,SQ,_Q,kQ,CQ,TQ])(e,t||{})}const $5={dampingRatio:.8,response:.3},FQ=.998;function $Q(e,t,r,n){const a=2*Math.PI/Math.max(e.response,.001),c=t-n,l=r,h=e.dampingRatio;if(Math.abs(h-1)<1e-4){const v=c,k=l+a*c;return{value:L=>n+(v+k*L)*Math.exp(-a*L),velocity:L=>(k-a*(v+k*L))*Math.exp(-a*L)}}if(h<1){const v=a*Math.sqrt(1-h*h),k=c,L=(l+h*a*c)/v;return{value:E=>n+Math.exp(-h*a*E)*(k*Math.cos(v*E)+L*Math.sin(v*E)),velocity:E=>Math.exp(-h*a*E)*((L*v-h*a*k)*Math.cos(v*E)-(k*v+h*a*L)*Math.sin(v*E))}}const p=a*Math.sqrt(h*h-1),m=-h*a+p,x=-h*a-p,y=(l-x*c)/(m-x),w=c-y;return{value:v=>n+y*Math.exp(m*v)+w*Math.exp(x*v),velocity:v=>y*m*Math.exp(m*v)+w*x*Math.exp(x*v)}}function UQ(e,t=FQ){return e/1e3*(t/(1-t))}function U5(e,t,r=.55){return e*t*r/(t+r*Math.abs(e))}function zQ(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}const HQ=.1,WQ=5;function GQ(e,t,r,n,a){const c=$Q(e,t,r,n),l=1e3/60,h=240,p=[];for(let m=0;m<h;m++){const x=m*l/1e3,y=c.value(x),w=c.velocity(x);if(p.push(a?a(y):y),m>0&&Math.abs(y-n)<HQ&&Math.abs(w)<WQ)break}return p.push(a?a(n):n),{frames:p,durationMs:(p.length-1)*l,solver:c}}const VQ='input:not([type="hidden"]), textarea, select, [contenteditable]:not([contenteditable="false"])';function qQ(){if(typeof document>"u")return;const e=document.activeElement;e instanceof HTMLElement&&e.matches(VQ)&&e.blur()}const YQ=18,z5=8,H5={touch:z5,pen:z5},ZQ=500,om=200,W5=50,KQ=`[${V9}]`;function lm(e,t,r){return Math.min(r,Math.max(t,e))}function G5(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.pointerType=="string"?t.pointerType==="touch"||t.pointerType==="pen":typeof t.type=="string"&&t.type.startsWith("touch")}function V5(e){if(!e||typeof e!="object")return!1;const t=e.target;return t instanceof Element&&!!t.closest(KQ)}function C0(...e){typeof window<"u"&&window.__SIDEBAR_DEBUG__&&console.log("[Sidebar]",...e)}const f6=_.forwardRef(function({side:t,isOpen:r,drawerWidthPx:n,onClose:a,onOpen:c,children:l,pinned:h=!1},p){const{t:m}=zr(),x=t==="left",y=x?-n:n,w=b.useRef(null),v=b.useRef(null),k=b.useRef(r?0:y),L=b.useRef(null),E=b.useRef(null),R=b.useRef(0),B=b.useRef(null),W=b.useRef(null),F=b.useRef(!1),U=b.useRef(null),V=b.useRef(!1),Z=b.useRef([]),le=b.useRef(null),xe=b.useRef(k.current),fe=b.useRef(r?1:0),te=b.useRef(r);te.current=r;const ke=b.useRef(y);ke.current=y;const $e=b.useRef(n);$e.current=n;const Y=b.useRef(x);Y.current=x;const Ae=b.useRef(a);Ae.current=a;const lt=b.useRef(c);lt.current=c;const Ce=b.useCallback(ae=>{w.current=ae,typeof p=="function"?p(ae):p&&(p.current=ae)},[p]),ye=b.useCallback(()=>{E.current!==null&&(window.cancelAnimationFrame(E.current),E.current=null),L.current=null},[]),_e=b.useCallback(ae=>{const be=$e.current;return Y.current?(ae+be)/be:(be-ae)/be},[]),je=b.useCallback(ae=>{const be=v.current;be&&(be.style.opacity=String(lm(_e(ae),0,1)))},[_e]),re=b.useCallback(ae=>{k.current=ae;const be=w.current;be&&(be.style.transform=`translateX(${ae}px)`,je(ae))},[je]),Pe=b.useCallback(ae=>{L.current=ae,E.current===null&&(E.current=window.requestAnimationFrame(()=>{E.current=null;const be=L.current;L.current=null,be!==null&&re(be)}))},[re]),Se=b.useCallback(()=>{E.current!==null&&(window.cancelAnimationFrame(E.current),E.current=null);const ae=L.current;L.current=null,ae!==null&&re(ae)},[re]),Ee=b.useCallback(ae=>{const be=ke.current;return lm(ae,Math.min(0,be),Math.max(0,be))},[]),Be=b.useCallback(()=>{const ae=B.current;if(!ae)return null;B.current=null;const be=(performance.now()-ae.startTime)/1e3,Ze={value:ae.solver.value(be),velocity:ae.solver.velocity(be)};return ae.animations.forEach(Je=>Je.cancel()),Ze},[]),Ne=b.useCallback(()=>{W.current!==null&&(window.clearTimeout(W.current),W.current=null)},[]),oe=b.useCallback(()=>{le.current?.(),le.current=null},[]),He=b.useCallback(()=>{Se(),Ne();const ae=Be();ae&&re(Ee(ae.value));const be=w.current,Ze=v.current;be?.getAnimations().forEach(Je=>Je.cancel()),be&&(be.style.transition="none",be.style.opacity="1"),Ze?.getAnimations().forEach(Je=>Je.cancel()),Ze&&(Ze.style.transition="none")},[re,Ne,Ee,Se,Be]),rt=b.useCallback((ae,be)=>{Se(),Ne();const Ze=w.current,Je=v.current,Tt=ae?0:ke.current;Je&&(Je.style.pointerEvents=ae?"auto":"none");const Wt=Be(),Mt=Wt?Ee(Wt.value):k.current,vt=be?.velocity??Wt?.velocity??0;if(zQ())return k.current=Tt,Ze&&(Ze.style.transition=`opacity ${om}ms ease`,Ze.style.opacity=ae?"1":"0",Ze.style.transform=`translateX(${Tt}px)`),Je&&(Je.style.transition=`opacity ${om}ms ease`,Je.style.opacity=ae?"1":"0"),om;Ze&&(Ze.style.transition="none",Ze.style.opacity="1"),Je&&(Je.style.transition="none");const Yt=Math.abs(be?.velocity??0)>ZQ,{frames:Qt,durationMs:Xt,solver:Ut}=GQ({dampingRatio:Yt?$5.dampingRatio:1,response:$5.response},Mt,vt,Tt,Ee);if(!Ze||Math.abs(Mt-Tt)<.5&&Math.abs(vt)<5)return re(Tt),0;const Lt=Ze.animate(Qt.map(Ge=>({transform:`translateX(${Ge}px)`})),{duration:Xt,easing:"linear",fill:"forwards"}),pe=[Lt];return Je&&pe.push(Je.animate(Qt.map(Ge=>({opacity:String(lm(_e(Ge),0,1))})),{duration:Xt,easing:"linear",fill:"forwards"})),B.current={solver:Ut,startTime:performance.now(),target:Tt,animations:pe},C0("spring start",{startX:Mt,startVelocity:vt,targetX:Tt,frames:Qt.length,durationMs:Xt}),Lt.onfinish=()=>{const Ge=B.current;!Ge||!Ge.animations.includes(Lt)||(B.current=null,re(Tt),Ge.animations.forEach(ft=>ft.cancel()),C0("spring finish",{targetX:Tt}))},Xt},[re,Ne,Ee,Se,_e,Be]),mt=b.useCallback(ae=>{Se();const be=ae,Ze=0,Je=ke.current,Tt=k.current+UQ(be),Wt=Math.abs(Tt-Ze)<=Math.abs(Tt-Je);C0("decideSnap",{velocity:be,currentX:k.current,projected:Tt,shouldOpen:Wt});const Mt=rt(Wt,{velocity:be});return Wt&&!te.current?W.current=window.setTimeout(()=>{W.current=null,lt.current?.()},Mt+W5):!Wt&&te.current&&(W.current=window.setTimeout(()=>{W.current=null,Ae.current()},Mt+W5)),Wt},[rt,Se]),de=b.useCallback(ae=>{const be=ke.current,Ze=Math.min(0,be),Je=Math.max(0,be),Tt=$e.current;return ae<Ze?Ze-U5(Ze-ae,Tt):ae>Je?Je+U5(ae-Je,Tt):ae},[]),Ye=b.useCallback(ae=>{const be=Z.current,Ze=performance.now();be.push({t:Ze,x:ae});const Je=Ze-120;for(;be.length>0&&be[0].t<Je;)be.shift()},[]),st=b.useCallback(()=>{const ae=Z.current;if(ae.length<2)return 0;const be=ae[ae.length-1];if(performance.now()-be.t>60)return 0;const Ze=ae[0],Je=(be.t-Ze.t)/1e3;return Je<.016?0:(be.x-Ze.x)/Je},[]);b.useEffect(()=>{Ne();const ae=B.current,be=r?0:ke.current;ae&&ae.target===be||rt(r)},[r,rt,Ne]),b.useEffect(()=>{He(),Pe(te.current?0:y)},[y,He,Pe]),b.useEffect(()=>()=>{ye(),Ne(),Be(),oe()},[Ne,ye,oe,Be]);const Ie=F5(({active:ae,cancel:be,first:Ze,last:Je,movement:[Tt],event:Wt})=>{if(C0("bindPanel",{active:ae,first:Ze,last:Je,mx:Tt}),!G5(Wt)){be();return}if(Ze){if(oe(),F.current=!1,U.current=null,Z.current=[],V5(Wt)){be();return}const Mt=w.current,vt=Mt?q9(Wt.target,Mt):null;if(!vt||Y9()){be();return}const Yt=Z9(vt,Tt,Y.current?-1:1);if(C0("arbitrate",{owner:Yt.kind,mx:Tt}),Yt.kind==="swiper"){le.current=K9(Yt.instance),be();return}if(Yt.kind==="scroller"){const Qt=X9(Yt.element);if(Qt)U.current=Qt;else{be();return}}U.current||(F.current=!0,He(),R.current=k.current)}if(!ae){U.current=null,F.current&&(F.current=!1,mt(st()));return}if(U.current){J9(U.current,Tt);return}if(F.current){const Mt=de(R.current+Tt);Ye(Mt),Pe(Mt)}},{axis:"x",axisThreshold:H5,filterTaps:!0,pointer:{touch:!0}}),We=F5(({active:ae,cancel:be,first:Ze,movement:[Je],event:Tt})=>{if(!G5(Tt)){be();return}if(te.current){be();return}if(Ze&&(V.current=!0,Z.current=[],He(),R.current=k.current),!ae){V.current&&(V.current=!1,mt(st())&&qQ());return}if(V.current){const Wt=de(R.current+Je);Ye(Wt),Pe(Wt)}},{axis:"x",axisThreshold:H5,filterTaps:!0,pointer:{touch:!0}}),Te=b.useCallback(ae=>{ae.preventDefault(),ae.stopPropagation(),te.current||lt.current?.()},[]);if(h)return s.jsx("aside",{ref:Ce,"data-sidebar":t,"data-sidebar-pinned":"true",className:"relative flex h-full min-h-0 w-full flex-col app-chrome-bg",children:l});const H=Ie();return s.jsxs(s.Fragment,{children:[s.jsx("div",{...We(),style:{position:"fixed",top:"1.5rem",bottom:"10rem",...x?{left:0}:{right:0},width:YQ,zIndex:"var(--z-chrome-hint)",touchAction:"none",pointerEvents:r?"none":"auto"},onClick:Te,"aria-label":m(x?"sidebar.openLeftSidebar":"sidebar.openRightSidebar")}),s.jsx("div",{ref:v,"data-sidebar-backdrop":t,className:"fixed inset-0 z-sidebar-backdrop bg-[var(--app-backdrop)] cursor-default",style:{opacity:fe.current,pointerEvents:r?"auto":"none",transition:"none",willChange:"opacity"},onClick:a,"aria-label":m("sidebar.closeSidebar")}),s.jsx("aside",{...H,onClickCapture:ae=>{V5(ae)||H.onClickCapture?.(ae)},ref:Ce,"data-sidebar":t,className:`fixed inset-y-0 z-sidebar-panel flex flex-col chrome-glow-panel will-change-transform ${x?"border-r border-border":"border-l border-border/15"}`,style:{...x?{left:0}:{right:0},width:n,maxWidth:x?"94vw":"95vw",transform:`translateX(${xe.current}px)`,transition:"none",touchAction:"pan-y",pointerEvents:r?"auto":"none",paddingTop:"var(--safe-top-inset, env(safe-area-inset-top, 0px))",paddingBottom:"var(--safe-bottom-inset, env(safe-area-inset-bottom, 0px))",...x?{paddingLeft:"var(--safe-left-inset, env(safe-area-inset-left, 0px))"}:{paddingRight:"var(--safe-right-inset, env(safe-area-inset-right, 0px))"}},children:l})]})}),XQ={activeKey:"root",items:[]},JQ=()=>()=>{},eP=()=>XQ;function tP(e){const t=ol(),r=b.useSyncExternalStore(t?.subscribe??JQ,t?.snapshot??eP),n=fw(),a=r.items.map(c=>c.key===n?{...c,reviewCount:e}:c).filter(c=>c.reviewCount>0);return{host:t,groups:a,currentKey:n,active:!t||r.activeKey===n,total:t?e+a.reduce((c,l)=>c+(l.key===n?0:l.reviewCount),0):e,hasOtherAttention:a.some(c=>c.key!==n)}}function rP({groups:e,currentKey:t,onClose:r}){const{t:n}=zr(),a=b.useId(),c=b.useRef(null),l=b.useRef(null),h=b.useRef(r);h.current=r;const p=b.useRef(!0),[m,x]=b.useState(""),y=e.reduce((k,L)=>k+L.reviewCount,0);b.useEffect(()=>{const k=document.activeElement;l.current?.focus({preventScroll:!0});const L=E=>{if(E.key==="Escape"&&(E.preventDefault(),E.stopImmediatePropagation(),h.current()),E.key!=="Tab")return;const R=Array.from(c.current?.querySelectorAll("button:not(:disabled)")??[]),B=R[0],W=R[R.length-1],F=!c.current?.contains(document.activeElement);E.shiftKey&&(document.activeElement===B||F)?(E.preventDefault(),W?.focus()):!E.shiftKey&&(document.activeElement===W||F)&&(E.preventDefault(),B?.focus())};return document.addEventListener("keydown",L,!0),()=>{document.removeEventListener("keydown",L,!0),p.current&&k?.isConnected&&!k.closest("[inert]")&&k.focus({preventScroll:!0})}},[]);const w=(k,L)=>{const E=ol(),R=E?.snapshot().items.find(W=>W.key===k.key);if(!R?.reviewCount||L&&!R.attentionSessions?.some(W=>W.id===L)){x(n("serviceAttention.changed"));return}p.current=!1;let B=!1;L&&k.key===t?(window.dispatchEvent(new CustomEvent("termdock:focus-session",{detail:L})),B=!0):L&&R.service?.targetPeerId?B=E?.focusSession(R.service.targetPeerId,L)??!1:R.service&&(B=E?.activate(R.service,!0)??!1),B?r():(p.current=!0,x(n("serviceAttention.unavailable")))},v=k=>k.phase==="offline"?n("serviceAttention.offline"):k.phase==="login"?n("serviceAttention.login"):k.phase==="connecting"||k.phase==="reconnecting"?n("connection.reconnecting"):null;return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button","aria-label":n("common.close"),tabIndex:-1,className:"fixed inset-0 z-modal-backdrop cursor-default bg-[var(--app-backdrop)]",onClick:r}),s.jsx("div",{className:"pointer-events-none fixed inset-0 z-modal-panel flex items-end justify-center p-3 sm:items-center sm:p-6",style:{paddingTop:"max(12px, var(--safe-top-inset, env(safe-area-inset-top, 0px)))",paddingBottom:"max(12px, var(--safe-bottom-inset, env(safe-area-inset-bottom, 0px)))"},children:s.jsxs("section",{ref:c,role:"dialog","aria-modal":"true","aria-labelledby":a,"data-sidebar-gesture-ignore":!0,onKeyDown:k=>k.stopPropagation(),className:"pointer-events-auto flex max-h-full w-full max-w-md flex-col overflow-hidden rounded-2xl border border-border bg-surface text-foreground shadow-xl",children:[s.jsxs("header",{className:"flex shrink-0 items-center gap-3 border-b border-border px-4 py-3",children:[s.jsx(Jl,{size:20,className:"shrink-0 text-[color:var(--warning)]","aria-hidden":"true"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{id:a,className:"text-sm font-semibold",children:n("serviceAttention.title")}),s.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:n("serviceAttention.summary",{services:e.length,count:y})})]}),s.jsx("button",{ref:l,type:"button","aria-label":n("common.close"),onClick:r,className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl text-muted-foreground hover:bg-surface-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:s.jsx(Qn,{size:18})})]}),s.jsxs("div",{className:"min-h-0 overflow-y-auto overscroll-contain p-2",children:[e.length===0&&s.jsx("p",{role:"status",className:"px-4 py-8 text-center text-sm text-muted-foreground",children:n("serviceAttention.empty")}),e.map(k=>s.jsxs("section",{className:"mb-2 last:mb-0",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-3 pb-1 pt-2 text-xs",children:[s.jsx("h3",{className:"min-w-0 flex-1 truncate font-medium",title:k.service?.label,children:k.service?.label||n("serviceAttention.currentService")}),k.key===t&&s.jsx("span",{className:"shrink-0 text-muted-foreground",children:n("agent.currentSession")}),s.jsx("span",{className:"shrink-0 tabular-nums text-[color:var(--warning)]",children:k.reviewCount})]}),v(k)&&s.jsx("p",{className:"px-3 pb-1 text-xs text-[color:var(--warning)]",children:v(k)}),k.attentionSessions?.length?k.attentionSessions.map(L=>s.jsxs("button",{type:"button",onClick:()=>w(k,L.id),className:"flex min-h-14 w-full items-center gap-3 rounded-xl px-3 py-2 text-left hover:bg-surface-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"line-clamp-2 break-words text-sm",title:L.label,children:L.label}),s.jsx("span",{className:"mt-0.5 block text-xs text-muted-foreground",children:L.waiting?n("serviceAttention.waiting"):n("agent.needsReview")})]}),s.jsx(hi,{size:16,className:"shrink-0 text-muted-foreground","aria-hidden":"true"})]},L.id)):s.jsx("button",{type:"button",onClick:()=>w(k),className:"min-h-11 w-full rounded-xl px-3 py-2 text-left text-sm hover:bg-surface-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary",children:n("serviceAttention.viewService")})]},k.key))]}),s.jsxs("footer",{className:"shrink-0 border-t border-border px-4 py-3 text-xs text-muted-foreground",children:[m&&s.jsx("p",{role:"alert",className:"mb-1 text-[color:var(--warning)]",children:m}),n("serviceAttention.scope")]})]})})]})}function nP(e){const t=e.icon&&e.isPlugin?`/api/terminal/agent-plugin-icon/${encodeURIComponent(e.slug)}${e.iconVersion?`?v=${Math.floor(e.iconVersion)}`:""}`:void 0,[r,n]=b.useState();if(b.useEffect(()=>{if(n(void 0),!t)return;const a=new AbortController;let c;return fetch(t,{signal:a.signal}).then(async l=>{if(!l.ok)throw new Error(`Icon request failed: ${l.status}`);const h=await l.blob();a.signal.aborted||(c=URL.createObjectURL(h),n({endpoint:t,src:c}))}).catch(()=>{}),()=>{a.abort(),c&&URL.revokeObjectURL(c)}},[t]),!!e.icon)return e.isPlugin?r?.endpoint===t?r?.src:void 0:`/icons/agents/${e.icon}.svg`}function sP(e){return e.agentStatus==="waiting"||e.agentNeedsReview===!0}function iP(e,t,r,n="next"){if(e.length===0)return null;const a=t?e.findIndex(c=>c.sessionId===t):-1;for(let c=1;c<=e.length;c+=1){const l=n==="next"?c:-c,h=(a+l+e.length)%e.length,p=e[h];if(p&&r(p))return p.sessionId}return null}function aP(e,t,r="next"){return iP(e,t,sP,r)}const Ma=42,wf=20,oP=10;function p1(e,t,r){return Math.min(r,Math.max(t,e))}function zf(e){const t=Math.max(0,e.safeTop??0),r=Math.max(0,e.safeRight??0),n=Math.max(0,e.safeBottom??0),a=Math.max(0,e.safeLeft??0),c=Math.max(0,e.bottomClearance??72),l=a+wf,h=Math.max(l,e.width-r-wf-Ma),p=Math.max(t+12,52),m=Math.max(p,e.height-n-c-Ma);return{minX:l,maxX:h,minY:p,maxY:m}}function q5(e,t){const r=zf(e),n=p1(t.yRatio,0,1);return{x:t.side==="left"?r.minX:r.maxX,y:r.minY+(r.maxY-r.minY)*n}}function Rc(e,t){const r=zf(e);return{x:p1(t.x,r.minX,r.maxX),y:p1(t.y,r.minY,r.maxY)}}function Y5(e,t){const r=zf(e),n=Rc(e,t),a=(r.minX+r.maxX+Ma)/2,c=n.x+Ma/2<a?"left":"right",l=r.maxY-r.minY;return{position:{x:c==="left"?r.minX:r.maxX,y:n.y},preference:{side:c,yRatio:l>0?(n.y-r.minY)/l:0}}}function Z5(e,t,r){const n=Rc(e,t),a=Ma+oP,c=m=>Math.abs(m.x-r.x)<a&&Math.abs(m.y-r.y)<a;if(!c(n))return n;const l=[{...n,y:r.y-a},{...n,y:r.y+a}].map(m=>Rc(e,m)).filter(m=>!c(m)).sort((m,x)=>Math.abs(m.y-n.y)-Math.abs(x.y-n.y));if(l[0])return l[0];const h=zf(e);return[{...n,x:h.minX},{...n,x:h.maxX}].map(m=>Rc(e,m)).filter(m=>!c(m)).sort((m,x)=>Math.abs(m.x-n.x)-Math.abs(x.x-n.x))[0]??n}const cm="var(--warning)",lP="var(--success)",K5="var(--tmux)",X5="termdock:mobile-attention-position:v1",J5="termdock:running-session-position:v1",cP={side:"right",yRatio:.68},uP={side:"right",yRatio:.54};function eb(e,t){if(typeof window>"u")return t;try{const r=JSON.parse(window.localStorage.getItem(e)??"null");if(r&&(r.side==="left"||r.side==="right")&&typeof r.yRatio=="number"&&Number.isFinite(r.yRatio))return{side:r.side,yRatio:Math.min(1,Math.max(0,r.yRatio))}}catch{}return t}function dP(e,t){try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}function mh(e){if(typeof document>"u")return 0;const t=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue(e));return Number.isFinite(t)?Math.max(0,t):0}function hP(e,t,r={}){if(typeof window>"u")return{width:390,height:664};const n=window.visualViewport,a=n?.width??window.innerWidth,c=n?.height??window.innerHeight,l=t?.getBoundingClientRect(),h=!!(l&&l.width>0&&l.height>0);return{width:a,height:c,safeTop:Math.max(mh("--safe-top-inset"),(h?Math.max(0,l.top):0)+Math.max(0,r.top??0)),safeRight:Math.max(mh("--safe-right-inset"),(h?Math.max(0,a-l.right):0)+Math.max(0,r.right??0)),safeBottom:Math.max(mh("--safe-bottom-inset"),(h?Math.max(0,c-l.bottom):0)+Math.max(0,r.bottom??0)),safeLeft:Math.max(mh("--safe-left-inset"),(h?Math.max(0,l.left):0)+Math.max(0,r.left??0)),bottomClearance:e?wf:72}}function p6(){const e=Yr.getState(),t=Array.from(e.sessions.values()),r=aP(t,e.activeSessionId);if(!r)return;const n=e.activeSessionId?e.sessions.get(e.activeSessionId):void 0;n?.agentNeedsReview&&e.clearAgentNeedsReview(n.sessionId),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:r}))}function tb(e){window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:e}))}function m6(e){switch(e){case"success":return"var(--success)";case"warning":return"var(--warning)";case"danger":return"var(--destructive)";case"info":case"accent":return"var(--accent)";default:return"var(--muted-foreground)"}}function fP({indicator:e,tone:t,size:r}){const n=m6(t);switch(e){case"spinner":return s.jsx(In,{size:r,className:"shrink-0 animate-spin",style:{color:n}});case"question":return s.jsx(Yh,{size:r,className:"shrink-0 animate-bounce-y",style:{color:n}});case"badge":return s.jsx(Jl,{size:r+1,className:"shrink-0 animate-pulse",style:{color:n}});case"terminal":return s.jsx(Bo,{size:r,className:"shrink-0",style:{color:n}});case"pulse":return s.jsx(SA,{size:r,className:"shrink-0 animate-pulse",style:{color:n}});case"ring":return s.jsx("span",{className:"block shrink-0 rounded-full border-2",style:{width:r,height:r,borderColor:n}});case"dot":return s.jsx("span",{className:"block shrink-0 rounded-full",style:{width:Math.max(5,r-4),height:Math.max(5,r-4),backgroundColor:n}})}}function Mc({agent:e,size:t=12}){const r=t-4,n=nP(e);return n?e.iconMode==="native"?s.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-[3px]",style:{width:t,height:t},title:e.displayName,children:s.jsx("img",{src:n,alt:e.displayName,style:{width:r,height:r}})}):s.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-[3px]",style:{width:t,height:t,backgroundColor:e.accentColor},title:e.displayName,children:s.jsx("span",{className:"block bg-white",style:{width:r,height:r,WebkitMask:`url(${n}) center / contain no-repeat`,mask:`url(${n}) center / contain no-repeat`}})}):s.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-[3px]",style:{width:t,height:t,backgroundColor:e.accentColor},title:e.displayName,children:s.jsx(Ad,{size:r,className:"text-white"})})}function pP({sessionMode:e,state:t,size:r=11}){const n=t?.agent?s.jsx(Mc,{agent:t.agent,size:r+1}):e==="tmux"?s.jsx(Nu,{size:r,className:"shrink-0"}):s.jsx(Bo,{size:r,className:"shrink-0"});return t?.agentStatusDetail&&t.agentIndicator&&!(t.agentStatus==="done"&&t.agentNeedsReview)?s.jsx("span",{title:t.agentMessage??t.agentStatusDetail.label,"aria-label":t.agentStatusDetail.label,children:s.jsx(fP,{indicator:t.agentIndicator,tone:t.agentStatusDetail.tone,size:r})}):t?.agentStatus==="working"?s.jsx("span",{title:t.agentMessage??t.agent?.displayName,children:s.jsx(In,{size:r,className:"shrink-0 animate-spin",style:{color:lP}})}):t?.agentStatus==="waiting"?s.jsx("span",{title:t.agentMessage??void 0,children:s.jsx(Yh,{size:r,className:"shrink-0 animate-bounce-y",style:{color:cm}})}):t?.agentStatus==="done"&&t.agentNeedsReview?s.jsx("span",{title:t.agentMessage??void 0,children:s.jsx(Jl,{size:r+1,className:"shrink-0 animate-pulse",style:{color:cm}})}):t?.agentNeedsReview?s.jsx("span",{title:t.agentMessage??void 0,children:s.jsx(Jl,{size:r+1,className:"shrink-0 animate-pulse",style:{color:cm}})}):t?.inCopyMode?e==="tmux"?s.jsx(Nu,{size:r,className:"shrink-0 animate-pulse",style:{color:K5}}):s.jsx(Bo,{size:r,className:"shrink-0 animate-pulse",style:{color:K5}}):n}function mP({status:e,detail:t,needsReview:r,inCopyMode:n}){const{t:a}=zr();return t&&!r?s.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-full ring-2 ring-surface animate-pulse",style:{backgroundColor:m6(t.tone)},title:t.label}):e==="working"?s.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-full bg-[var(--success)] ring-2 ring-surface shadow-[0_0_6px_rgb(var(--success-rgb)_/_0.50)] animate-pulse",title:a("agent.aiRunning")}):e==="waiting"||r?s.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-full bg-[var(--warning)] ring-2 ring-surface shadow-[0_0_0_1px_rgb(var(--warning-rgb)_/_0.24)] animate-pulse",title:a(r?"agent.finishedReview":"agent.aiWaiting")}):e==="done"&&r?s.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-full bg-[var(--warning)] ring-2 ring-surface shadow-[0_0_0_1px_rgb(var(--warning-rgb)_/_0.24)] animate-pulse",title:a("agent.finishedReview")}):n?s.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-[2px] bg-[var(--tmux)] ring-2 ring-surface",title:a("agent.copyMode")}):null}function g6({count:e,tone:t,title:r}){const{t:n}=zr();if(e<=0)return null;const a=t==="running"?"inline-flex items-center gap-1 rounded-full bg-[rgb(var(--success-rgb)_/_0.12)] px-1.5 py-0.5 text-[10px] font-medium text-[color:var(--success)]":"inline-flex min-h-6 items-center gap-1 rounded-full bg-[rgb(var(--warning-rgb)_/_0.14)] px-2 py-0.5 text-[10px] font-semibold text-[color:var(--warning)] ring-1 ring-[rgb(var(--warning-rgb)_/_0.24)] transition hover:bg-[rgb(var(--warning-rgb)_/_0.22)] active:scale-[0.97]",c=t==="running"?"h-1.5 w-1.5 rounded-full bg-[var(--success)] animate-pulse":"h-1.5 w-1.5 rounded-full bg-[var(--warning)] animate-pulse";if(t==="review"){const l=r??n("agent.jumpToNext");return s.jsxs("button",{type:"button",className:a,title:`${l} · ${n("agent.jumpToNext")}`,"aria-label":`${l}: ${e}. ${n("agent.jumpToNext")}`,onClick:p6,children:[s.jsx(Jl,{size:11,className:"shrink-0"}),s.jsx("span",{children:n("agent.needsReview")}),s.jsx("span",{className:"tabular-nums",children:e})]})}return s.jsxs("span",{className:a,title:r,children:[s.jsx("span",{className:c}),e]})}function gP({runningCount:e,reviewCount:t,className:r=""}){const n=[];return e>0&&n.push({key:"running",count:e,className:"bg-[var(--success)] text-[color:var(--success-foreground)]"}),t>0&&n.push({key:"review",count:t,className:"bg-[var(--warning)] text-[color:var(--warning-foreground)]"}),n.length===0?null:s.jsx("span",{"aria-hidden":"true",className:`pointer-events-none absolute -right-1 ${n.length>1?"top-0.5 flex flex-col gap-0.5":"-top-1"} ${r}`,children:n.map(a=>s.jsx("span",{className:`flex h-3 min-w-3 items-center justify-center rounded-full px-0.5 text-[7px] font-bold leading-3 shadow-sm ring-1 ring-background ${a.className}`,children:a.count>9?"9+":a.count},a.key))})}const xP=380,rb=10,gh=10,um=52,bP=104;function yP(e,t,r){const n=Math.max(0,t.safeLeft??0),a=t.width-Math.max(0,t.safeRight??0),c=Math.max(0,t.safeTop??0),l=t.height-Math.max(0,t.safeBottom??0),h=wf,p=e.x+Ma/2>=n+(a-n)/2,m=p?e.x-gh-n-h:a-h-e.x-Ma-gh,x=Math.max(1,Math.min(Math.max(0,m),Math.max(168,r*bP))),y=p?e.x-gh-x:e.x+Ma+gh,w=Math.min(Math.max(y,n+h),Math.max(n+h,a-h-x)),v=e.y+Ma/2-um/2,k=Math.min(Math.max(v,c+h),Math.max(c+h,l-h-um));return{left:w,top:k,width:x,height:um,itemWidth:x/Math.max(1,r),side:p?"left":"right"}}function nb(e,t,r,n){return t<e.left||t>e.left+e.width||r<e.top-14||r>e.top+e.height+14?null:Math.min(n-1,Math.max(0,Math.floor((t-e.left)/e.itemWidth)))}function vP(e,t){if(e.length===0)return null;const r=t?e.findIndex(n=>n.id===t):-1;return e[(r+1)%e.length]?.id??null}function wP({reviewCount:e,runningSessions:t,activeSessionId:r,runningButtonEnabled:n,attentionButtonEnabled:a=!0,isDesktopLayout:c,containerElement:l,occlusionInsets:h}){const{t:p}=zr(),m=Gt(Ie=>Ie.leftOpen),x=Gt(Ie=>Ie.rightOpen),{isOpen:y}=My({enabled:!c}),w=c||!m&&!x&&!y,v=tP(e),[k,L]=_.useState(!1);_.useEffect(()=>{(!v.active||!w)&&L(!1)},[v.active,w]);const E=a&&v.total>0&&w,R=t.length>1||t.length===1&&t[0]?.id!==r,B=n&&t.length>0&&R&&w,W=Math.max(0,h?.top??0),F=Math.max(0,h?.right??0),U=Math.max(0,h?.bottom??0),V=Math.max(0,h?.left??0),Z=_.useCallback(()=>hP(c,l,{top:W,right:F,bottom:U,left:V}),[l,c,U,V,F,W]),le=_.useRef({attention:eb(X5,cP),running:eb(J5,uP)}),xe=_.useCallback(()=>{const Ie=Z(),We=q5(Ie,le.current.attention),Te=q5(Ie,le.current.running);return{attention:We,running:E&&B?Z5(Ie,Te,We):Te}},[E,Z,B]),[fe,te]=_.useState(()=>xe()),ke=_.useRef(fe);ke.current=fe;const[$e,Y]=_.useState(null),Ae=_.useRef(null),[lt,Ce]=_.useState("idle"),[ye,_e]=_.useState(null),je=_.useRef(null),re=_.useRef({attention:!1,running:!1});_.useEffect(()=>()=>{const Ie=je.current?.longPressTimer;Ie!=null&&window.clearTimeout(Ie)},[]),_.useEffect(()=>{if(B)return;const Ie=je.current?.longPressTimer;Ie!=null&&window.clearTimeout(Ie),je.current=null,Ce("idle"),_e(null)},[B]),_.useLayoutEffect(()=>{const Ie=()=>{const Te=xe();ke.current=Te,te(Te)};Ie(),window.addEventListener("resize",Ie),window.addEventListener("orientationchange",Ie),window.visualViewport?.addEventListener("resize",Ie);const We=typeof ResizeObserver>"u"?null:new ResizeObserver(Ie);return l&&We?.observe(l),()=>{window.removeEventListener("resize",Ie),window.removeEventListener("orientationchange",Ie),window.visualViewport?.removeEventListener("resize",Ie),We?.disconnect()}},[l,xe]);const Pe=_.useCallback(Ie=>Ie==="attention"?B:E,[E,B]),Se=_.useCallback((Ie,We)=>{if(!Pe(Ie))return We;const Te=Ie==="attention"?"running":"attention";return Z5(Z(),We,ke.current[Te])},[Z,Pe]),Ee=_.useCallback((Ie,We,Te,H)=>{const ae=Z(),be=We.moved?Rc(ae,{x:We.startX+(Te-We.originX),y:We.startY+(H-We.originY)}):ke.current[Ie],Ze=Y5(ae,be),Je=Se(Ie,Ze.position),Tt=Y5(ae,Je);le.current[Ie]=Tt.preference,dP(Ie==="attention"?X5:J5,Tt.preference);const Wt={...ke.current,[Ie]:Tt.position};ke.current=Wt,te(Wt)},[Se,Z]),Be=_.useCallback(Ie=>{re.current[Ie]=!0,window.setTimeout(()=>{re.current[Ie]=!1},0)},[]),Ne=_.useCallback(Ie=>{const We=Ae.current;!We||We.kind!=="attention"||We.pointerId!==Ie.pointerId||(Ae.current=null,Y(null),Ee("attention",We,Ie.clientX,Ie.clientY),We.moved&&Be("attention"))},[Ee,Be]),oe={onPointerDown:Ie=>{Ie.stopPropagation(),Ie.currentTarget.setPointerCapture(Ie.pointerId),Ae.current={kind:"attention",pointerId:Ie.pointerId,originX:Ie.clientX,originY:Ie.clientY,startX:fe.attention.x,startY:fe.attention.y,moved:!1}},onPointerMove:Ie=>{const We=Ae.current;if(!We||We.kind!=="attention"||We.pointerId!==Ie.pointerId)return;const Te=Ie.clientX-We.originX,H=Ie.clientY-We.originY;if(!We.moved&&Math.hypot(Te,H)<5)return;We.moved=!0,Y("attention");const ae=Z(),be=Se("attention",Rc(ae,{x:We.startX+Te,y:We.startY+H})),Ze={...ke.current,attention:be};ke.current=Ze,te(Ze)},onPointerUp:Ne,onPointerCancel:Ne},He=l?yP(fe.running,Z(),t.length):null,rt=Ie=>{Ie.longPressTimer!==null&&(window.clearTimeout(Ie.longPressTimer),Ie.longPressTimer=null)},mt={onPointerDown:Ie=>{Ie.stopPropagation(),Ie.currentTarget.setPointerCapture(Ie.pointerId);const We=Ie.pointerId,Te={pointerId:We,originX:Ie.clientX,originY:Ie.clientY,startX:fe.running.x,startY:fe.running.y,mode:"pressing",moved:!1,selectedIndex:null,longPressTimer:null};Te.longPressTimer=window.setTimeout(()=>{const H=je.current;!H||H.pointerId!==We||H.mode!=="pressing"||(H.longPressTimer=null,H.mode="dragging",re.current.running=!0,Ce("dragging"))},xP),je.current=Te,Ce("pressing"),_e(null)},onPointerMove:Ie=>{const We=je.current;if(!We||We.pointerId!==Ie.pointerId)return;const Te=Ie.clientX-We.originX,H=Ie.clientY-We.originY;if(We.mode==="pressing")if(Math.abs(Te)>=rb&&Math.abs(Te)>=Math.abs(H))rt(We),We.mode="selecting",re.current.running=!0,Ce("selecting");else if(Math.hypot(Te,H)>=rb){rt(We),We.mode="cancelled",re.current.running=!0,Ce("idle");return}else return;if(We.mode==="selecting"){const Je=He?nb(He,Ie.clientX,Ie.clientY,t.length):null;We.selectedIndex=Je,_e(Je);return}if(We.mode!=="dragging"||!We.moved&&Math.hypot(Te,H)<5)return;We.moved=!0;const ae=Z(),be=Se("running",Rc(ae,{x:We.startX+Te,y:We.startY+H})),Ze={...ke.current,running:be};ke.current=Ze,te(Ze)},onPointerUp:Ie=>{const We=je.current;if(!We||We.pointerId!==Ie.pointerId)return;rt(We);const Te=We.mode;if(Te==="selecting"){const H=He?nb(He,Ie.clientX,Ie.clientY,t.length):We.selectedIndex,ae=H===null?null:t[H]?.id;ae&&tb(ae)}else Te==="dragging"&&Ee("running",We,Ie.clientX,Ie.clientY);je.current=null,Ce("idle"),_e(null),Te!=="pressing"&&Be("running")},onPointerCancel:Ie=>{const We=je.current;!We||We.pointerId!==Ie.pointerId||(rt(We),je.current=null,Ce("idle"),_e(null),Be("running"))}},de=(Ie,We)=>s.jsx("span",{className:`pointer-events-none absolute -right-1 -top-1 z-10 flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-surface px-1 text-[9px] font-bold tabular-nums ring-2 ring-[var(--chrome-bg)] ${We==="attention"?"text-[color:var(--warning)]":"text-[color:var(--success)]"}`,children:Ie>9?"9+":Ie}),Ye=()=>{const Ie=v.hasOtherAttention?p("serviceAttention.title"):p("agent.jumpToNext"),We=fe.attention,Te=$e==="attention";return s.jsxs("button",{type:"button","data-attention-button":!0,"data-mobile-attention-button":!0,...oe,onClick:H=>{H.stopPropagation(),!re.current.attention&&(v.hasOtherAttention?L(!0):p6())},className:`fixed z-chrome-hint inline-flex items-center justify-center rounded-full bg-[var(--warning)] text-[color:var(--warning-foreground)] shadow-[0_8px_24px_var(--app-shadow-strong)] ring-1 ring-[rgb(var(--warning-rgb)_/_0.35)] animate-fade-in ${Te?"cursor-grabbing scale-[1.04] shadow-[0_12px_30px_var(--app-shadow-strong)]":"cursor-grab transition-[left,top,transform,box-shadow] duration-200 active:scale-95"}`,style:{display:k?"none":void 0,left:We.x,top:We.y,width:Ma,height:Ma,touchAction:"none"},"aria-label":`${Ie}: ${v.total}`,"aria-haspopup":v.hasOtherAttention?"dialog":void 0,title:Ie,children:[s.jsx(Jl,{size:17,className:"shrink-0"}),de(v.total,"attention")]},"attention")},st=()=>{const Ie=t.length,We=fe.running,Te=lt==="selecting",H=lt==="dragging";return s.jsxs(_.Fragment,{children:[s.jsxs("button",{type:"button","data-running-session-button":!0,"data-running-session-gesture":lt,...mt,onClick:ae=>{if(ae.stopPropagation(),re.current.running)return;const be=vP(t,r);be&&tb(be)},className:`fixed z-chrome-hint inline-flex select-none items-center justify-center rounded-full bg-[var(--success)] text-[color:var(--success-foreground)] shadow-[0_8px_24px_var(--app-shadow-strong)] ring-1 ring-[rgb(var(--success-rgb)_/_0.35)] animate-fade-in ${H?"cursor-grabbing scale-[1.04] shadow-[0_12px_30px_var(--app-shadow-strong)]":Te?"cursor-ew-resize scale-[1.04] ring-2 ring-[rgb(var(--success-rgb)_/_0.55)]":"cursor-grab transition-[left,top,transform,box-shadow] duration-200 active:scale-95"}`,style:{left:We.x,top:We.y,width:Ma,height:Ma,touchAction:"none"},"aria-label":`${p("agent.jumpToNextRunning")}: ${Ie}`,title:p("agent.runningSessionGestureHint"),children:[s.jsx(In,{size:18,className:"shrink-0 animate-spin"}),de(Ie,"running")]}),Te&&He&&s.jsx("div",{role:"listbox","data-running-session-rail":!0,"data-side":He.side,"aria-label":p("agent.selectRunningSession"),className:"pointer-events-none fixed z-popover flex overflow-hidden rounded-full border border-border/15 bg-surface/95 p-1 shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",style:{left:He.left,top:He.top,width:He.width,height:He.height},children:t.map((ae,be)=>{const Ze=be===ye,Je=ae.id===r,Tt=`${ae.label}${ae.detail?` · ${ae.detail}`:""}${Je?` · ${p("agent.currentSession")}`:""}`;return s.jsxs("div",{role:"option","aria-selected":Ze,"data-running-session-option":ae.id,"data-selected":Ze?"true":"false",title:Tt,className:`relative flex min-w-0 flex-1 items-center justify-center gap-1.5 rounded-full px-2 transition-[background-color,color,transform] duration-100 ${Ze?"scale-[1.02] bg-[var(--success)] text-[color:var(--success-foreground)]":Je?"bg-primary/15 text-primary ring-1 ring-primary/30":"text-foreground"}`,children:[s.jsx("span",{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-[9px] font-bold tabular-nums ${Ze?"bg-surface/25":"bg-surface-2 text-muted-foreground"}`,children:be+1}),s.jsx("span",{className:"truncate text-[10px] font-medium",children:ae.label})]},ae.id)})})]},"running")};return!E&&!B&&!k||l===null||typeof document>"u"?null:s.jsxs(pw,{children:[E&&Ye(),B&&!k&&st(),k&&v.active&&w&&s.jsx(rP,{groups:v.groups,currentKey:v.currentKey,onClose:()=>L(!1)})]})}function AP(){const{t:e}=zr();return s.jsxs("div",{role:"status",className:"td-loading-skeleton overflow-hidden px-3 py-2",children:[s.jsx("span",{className:"sr-only",children:e("common.loading")}),s.jsx("div",{"aria-hidden":"true",children:["w-2/5","w-3/5","w-1/3","w-1/2","w-2/5","w-1/3"].map((t,r)=>s.jsxs("div",{className:"flex h-8 items-center gap-2",style:{paddingLeft:r>1&&r<5?20:0},children:[s.jsx("div",{className:"h-3 w-3 shrink-0 rounded-sm bg-surface-2"}),s.jsx("div",{className:`h-2 rounded bg-surface-2 ${t}`})]},r))})]})}const TP=new Set([".ts",".tsx",".js",".jsx",".py",".rs",".go",".java",".c",".cpp",".h",".rb",".php",".swift",".kt",".sh",".css",".scss",".html",".json",".yaml",".yml",".toml",".md"]),sb=120,ib=120,CP=new Set,SP=[],_P={added:{label:"A",className:"text-[color:var(--diff-insert-strong)]",title:"Added"},modified:{label:"M",className:"text-[color:var(--diff-hunk-accent)]",title:"Modified"},deleted:{label:"D",className:"text-[color:var(--diff-delete-strong)]",title:"Deleted"},renamed:{label:"R",className:"text-muted-foreground",title:"Renamed"},copied:{label:"C",className:"text-[color:var(--diff-insert-strong)]",title:"Copied"},untracked:{label:"U",className:"text-[color:var(--diff-insert-strong)]",title:"Untracked (new file)"},conflicted:{label:"!",className:"text-destructive",title:"Conflicted"},unknown:{label:"?",className:"text-muted-foreground",title:"Unknown"}};function pg(e,t){if(t==="directory")return null;if(xw(e))return s.jsx(mA,{size:14});if(bw(e))return s.jsx(k3,{size:14});const r=e.lastIndexOf(".")>=0?e.slice(e.lastIndexOf(".")):"";return TP.has(r)?s.jsx(UA,{size:14}):s.jsx(y3,{size:14})}function x6({path:e}){const r=Gt(a=>a.changedFiles.get(e))?.status;if(!r)return null;const n=_P[r]??{label:"?",className:"text-muted-foreground",title:r};return s.jsx("span",{className:`w-4 shrink-0 text-center text-[10px] font-mono font-bold ${n.className}`,title:n.title,children:n.label})}function Qu(e){return e?"ml-1 w-6 opacity-100":"ml-1 w-6 opacity-100 sm:ml-0 sm:w-0 sm:overflow-hidden sm:opacity-0 sm:group-hover:ml-1 sm:group-hover:w-6 sm:group-hover:opacity-100 sm:group-focus-within:ml-1 sm:group-focus-within:w-6 sm:group-focus-within:overflow-visible sm:group-focus-within:opacity-100"}function mg(e){return Qu(e)}const kP=b.memo(function({path:t}){const{t:r}=zr(),[n,a]=b.useState("idle"),[c,l]=b.useState(null),h=b.useCallback(async p=>{if(p.stopPropagation(),n!=="pending"){a("pending"),l(null);try{await l3(t),a("idle")}catch(m){a("error"),l(m instanceof Error?m.message:r("rightSidebar.downloadFailed"))}}},[t,n,r]);return s.jsx("button",{type:"button",disabled:n==="pending","aria-label":r("rightSidebar.downloadFile"),onClick:p=>{h(p)},className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-muted-foreground transition focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary active:scale-95 ${Qu(n==="pending")} ${n==="pending"?"bg-surface-elevated text-foreground":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,title:n==="error"?c??r("rightSidebar.downloadFailed"):r("rightSidebar.downloadFile"),children:n==="pending"?s.jsx(In,{size:12,className:"animate-spin"}):s.jsx(id,{size:12})})});function b6(){const{t:e}=zr(),[t,r]=b.useState({status:"idle"}),n=b.useCallback(async a=>{r({status:"pending"});try{await l3(a),r({status:"idle"})}catch(c){r({status:"error",message:c instanceof Error?c.message:e("rightSidebar.downloadFailed")})}},[e]);return{state:t,run:n}}function m1(e){return e instanceof DOMException&&e.name==="AbortError"}function Af(){if(typeof window>"u")return!1;const e=window.getSelection();return!!(e&&!e.isCollapsed&&e.toString().trim())}function y6(e){return e.button===2||e.ctrlKey}const LP=176,IP=160,S0=8;function ab(e,t,r,n){const a=window.visualViewport,c=a?.offsetLeft??0,l=a?.offsetTop??0,h=c+(a?.width??window.innerWidth),p=l+(a?.height??window.innerHeight),m=c+S0,x=l+S0,y=Math.max(m,h-r-S0),w=Math.max(x,p-n-S0),v=t+n<=p-S0?t:t-n;return{anchorX:e,anchorY:t,left:Math.min(Math.max(e,m),y),top:Math.min(Math.max(v,x),w)}}function v6(e){const[t,r]=b.useState(null),n=b.useRef(null),a=b.useCallback((c,l)=>{r(ab(c,l,LP,IP))},[]);return b.useLayoutEffect(()=>{if(!e||!t||!n.current)return;const c=n.current.getBoundingClientRect();if(c.width<=0||c.height<=0)return;const l=ab(t.anchorX,t.anchorY,c.width,c.height);l.left===t.left&&l.top===t.top||r(l)},[e,t]),{position:t,menuRef:n,openAt:a,clearPosition:()=>r(null)}}function w6(e,t){return t&&typeof document<"u"?Li.createPortal(e,document.body):e}function EP(e,t){return t?`${e.name} ${e.path}`.toLowerCase().includes(t):!0}function gg(e,t,r){if(!t||EP(e,t))return!0;const n=r.get(e.path);return n?n.some(a=>gg(a,t,r)):!1}function g1(e){return e.map(t=>({name:t.name,path:t.path,type:t.type,isSymlink:t.isSymlink,modified:t.modified,expanded:!1,loaded:!1,children:t.type==="directory"?[]:void 0}))}function x1(e,t){return!e||!t.startsWith(e)?t:t.slice(e.length).replace(/^\/+/,"")||t}const NP=b.memo(function e({node:t,depth:r,onFileSelect:n,directoriesOnly:a=!1,onPathReference:c,referenceSelection:l,getReferenceText:h,onReferenceCopied:p,insertedReferenceKey:m,copiedReferenceKey:x,onDirectoryRoot:y,onSearchFromDirectory:w,onDirectoryPinToggle:v,onFilePinToggle:k,onOpenInFileBrowser:L,canOpenInFileBrowser:E,pinnedPaths:R,selectedFilePath:B,queryLower:W,onDirectoryDropFiles:F,onFileDeleteRequest:U,deletingFilePath:V,revealedDirectoryPath:Z,gitIgnoreRoot:le}){const{t:xe}=zr(),fe=Gt(bt=>bt.expandedPaths.has(t.path)),te=Gt(bt=>bt.directoryCache.get(t.path)),ke=Gt(bt=>bt.showHiddenFiles),$e=Gt(bt=>bt.toggleExpanded),Y=Gt(bt=>bt.setDirectoryCache),Ae=Gt(bt=>bt.fileSortModes[t.path]??"name"),lt=Gt(bt=>bt.setDirectorySortMode),[Ce,ye]=b.useState(!1),[_e,je]=b.useState(!1),{position:re,menuRef:Pe,openAt:Se,clearPosition:Ee}=v6(_e),[Be,Ne]=b.useState(!1),oe=b.useRef(0),He=b.useRef(null),rt=`file-tree-reference:${b.useId()}:${t.path}`;wd(Pe,_e&&!!l,()=>je(!1));const mt=b.useRef(null),de=t.path===B||t.path===Z,Ye=t.type==="directory"&&(fe||!!W),st=t.type==="directory",Ie=R.has(t.path),We=!st&&!!k,Te=!!(E&&L),H=`path:${t.path}`,ae=m===H||!!l?.paths.has(t.path),be=x===H,Ze=h?.(t.path)??t.path,Je=L1(p,!!l),{state:Tt,run:Wt}=b6(),Mt=V===t.path,vt=st&&!a&&!!(y||w||v||Te),Yt=b.useMemo(()=>{if(!te)return;if(!W)return te;const bt=Gt.getState().directoryCache;return te.filter(It=>(!a||It.type==="directory")&&gg(It,W,bt))},[te,a,W]),Qt=b.useCallback(async()=>{if(!Gt.getState().directoryCache.has(t.path)&&!Ce){const It=l?rt:`file-tree:${t.path}`;He.current?.abort(),Im(It);const yt=new AbortController;He.current=yt,ye(!0);try{const pr=await C1(t.path,yt.signal,ke,"expand_directory",It,Ae,le);if(yt.signal.aborted)return;const nr=g1(pr.entries);Y(t.path,nr)}catch(pr){m1(pr)}finally{He.current===yt&&(He.current=null),ye(!1)}}},[t.path,Ce,Y,ke,Ae,le,!!l,rt]),Xt=b.useCallback(async()=>{if(t.type!=="directory"){n(t.path);return}if(a&&y){y(t.path);return}const bt=!Gt.getState().expandedPaths.has(t.path);$e(t.path),bt&&await Qt()},[a,t.path,t.type,Qt,y,$e,n]);b.useEffect(()=>{t.type==="directory"&&fe&&!te&&!Ce&&Qt()},[te,fe,Qt,Ce,t.type]);const Ut=b.useCallback(bt=>{bt.stopPropagation(),c?.(t.path,H)},[c,t.path,H]),Lt=b.useCallback(bt=>{bt.stopPropagation(),y?.(t.path),je(!1)},[t.path,y]),pe=b.useCallback(bt=>{bt.stopPropagation(),w?.(t.path),je(!1)},[t.path,w]),Ge=b.useCallback(bt=>{bt.stopPropagation(),v?.(t.path),je(!1)},[t.path,v]),ft=b.useCallback(bt=>{bt.stopPropagation(),lt(t.path,Ae==="modified"?"name":"modified"),je(!1)},[t.path,lt,Ae]),q=b.useCallback(bt=>{bt.stopPropagation(),k?.(t.path),je(!1)},[t.path,k]),at=b.useCallback(bt=>{bt.stopPropagation(),je(!1),Wt(t.path)},[t.path,Wt]),Vt=b.useCallback(bt=>{bt.stopPropagation(),je(!1),U(t)},[t,U]),Ve=b.useCallback(bt=>{bt.stopPropagation(),L?.(t.path),je(!1)},[t.path,L]),De=b.useCallback(bt=>{!st||!F||!bt.dataTransfer.types.includes("Files")||(bt.preventDefault(),bt.stopPropagation(),oe.current+=1,Ne(!0))},[st,F]),er=b.useCallback(bt=>{!st||!F||!bt.dataTransfer.types.includes("Files")||(bt.preventDefault(),bt.stopPropagation(),bt.dataTransfer.dropEffect="copy",Ne(!0))},[st,F]),et=b.useCallback(bt=>{!st||!F||(bt.preventDefault(),bt.stopPropagation(),oe.current-=1,oe.current<=0&&(oe.current=0,Ne(!1)))},[st,F]),Ct=b.useCallback(bt=>{if(!st||!F)return;bt.preventDefault(),bt.stopPropagation(),oe.current=0,Ne(!1);const It=Array.from(bt.dataTransfer.files);It.length>0&&F(t.path,It)},[st,t.path,F]),Nt=b.useCallback(bt=>{bt.stopPropagation(),l?Se(bt.clientX,bt.clientY):Ee(),je(It=>!It)},[Ee,Se,!!l]),gt=b.useCallback(bt=>{!vt||!y6(bt)||(bt.preventDefault(),bt.stopPropagation(),Se(bt.clientX,bt.clientY),je(!0))},[vt,Se]);return b.useEffect(()=>{if(!_e)return;const bt=yt=>{const pr=yt.target;pr instanceof Node&&(mt.current?.contains(pr)||Pe.current?.contains(pr))||je(!1)},It=yt=>{yt.key==="Escape"&&je(!1)};return document.addEventListener("pointerdown",bt),document.addEventListener("keydown",It),()=>{document.removeEventListener("pointerdown",bt),document.removeEventListener("keydown",It)}},[_e,Pe]),b.useEffect(()=>()=>{He.current?.abort()},[]),s.jsxs("div",{style:!Ye&&!_e?{contentVisibility:"auto",containIntrinsicSize:"auto 32px"}:void 0,children:[s.jsxs("div",{ref:mt,className:"relative",children:[Je.popoverNode,s.jsxs("div",{"data-file-tree-path":t.path,"data-sort-mode":Ae,role:"button",tabIndex:0,onClick:()=>{Af()||Xt()},onContextMenu:gt,onKeyDown:bt=>{bt.target!==bt.currentTarget||bt.key!=="Enter"&&bt.key!==" "||(bt.preventDefault(),Xt())},onDragEnter:De,onDragOver:er,onDragLeave:et,onDrop:Ct,className:`group relative flex w-full cursor-pointer items-center gap-1 rounded px-2 py-1 text-[13px] transition ${Be?"scale-[1.015] bg-primary/15 text-foreground shadow-[0_0_0_1px_rgb(var(--primary-rgb)_/_0.45)]":de?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:t.path,children:[r>0&&s.jsx("span",{"aria-hidden":"true",className:"shrink-0",style:{width:`${r*14-4}px`}}),Be&&s.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 z-10 -translate-y-1/2 rounded-full bg-primary px-2 py-0.5 text-[10px] font-semibold text-primary-foreground shadow-md",children:xe("fileTree.dropToUploadHere")}),t.type==="directory"?s.jsxs(s.Fragment,{children:[Ye?s.jsx(ul,{size:14,className:"shrink-0 text-muted-foreground/80"}):s.jsx(hi,{size:14,className:"shrink-0 text-muted-foreground/80"}),Ye?s.jsx(wu,{size:14,className:"shrink-0 text-[color:var(--folder)]"}):s.jsx(jc,{size:14,className:"shrink-0 text-[color:var(--folder)]"})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"w-[14px] shrink-0"}),s.jsx("span",{className:de?"text-primary":"text-muted-foreground/80",children:pg(t.name,t.type)})]}),s.jsxs("span",{className:`flex-1 select-text whitespace-nowrap text-left leading-snug ${de?"font-medium":""}`,children:[t.name,Ae==="modified"&&s.jsx("span",{className:"ml-1 inline-flex align-middle text-primary",title:xe("fileTree.sortedByModified"),"aria-label":xe("fileTree.sortedByModified"),children:s.jsx(sd,{size:11})}),t.isSymlink&&s.jsx("span",{className:"ml-1 inline-flex align-middle text-muted-foreground/70",title:xe("fileTree.symbolicLink"),children:s.jsx(Lu,{size:11})})]}),s.jsxs("div",{className:`sticky right-0 z-20 flex shrink-0 items-center rounded pl-1 ${de?"bg-surface-elevated":"bg-surface group-hover:bg-surface-2"}`,onClick:bt=>bt.stopPropagation(),children:[Ce&&s.jsx(In,{size:12,className:"shrink-0 animate-spin text-muted-foreground"}),s.jsx(x6,{path:t.path}),vt&&s.jsx("button",{type:"button",onClick:Nt,className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-muted-foreground transition focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary active:scale-95 ${Qu(_e)} ${_e?"bg-surface-elevated text-foreground":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":xe("fileTree.moreDirActions"),"aria-expanded":_e,title:xe("fileTree.moreDirActions"),children:s.jsx(Qo,{size:13})}),!st&&!l&&s.jsx("button",{type:"button",onClick:Nt,className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-muted-foreground transition focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary active:scale-95 ${Qu(_e||Tt.status==="pending"||Mt||Ie)} ${_e?"bg-surface-elevated text-foreground":Ie?"bg-primary/15 text-primary":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":xe("fileTree.moreFileActions"),"aria-expanded":_e,title:Tt.status==="error"?Tt.message??xe("rightSidebar.downloadFailed"):xe("fileTree.moreFileActions"),children:Tt.status==="pending"||Mt?s.jsx(In,{size:13,className:"animate-spin"}):s.jsx(Qo,{size:13})}),c&&s.jsx("button",{type:"button",onClick:Ut,...Je(Ze,H),className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-[11px] font-semibold transition focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary active:scale-95 ${l?"ml-1 min-h-11 min-w-11":mg(ae||be)} ${ae||be?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":l?`${l.label}: ${t.name}`:xe(be?"rightSidebar.copied":ae?"rightSidebar.inserted":"fileTree.insertRefTitle"),"aria-pressed":l?ae:void 0,disabled:!!l?.disabled&&!ae,title:l?`${l.label}: ${t.name}`:xe(be?"rightSidebar.copied":ae?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:be||ae?s.jsx(di,{size:12}):s.jsx(Lu,{size:12})}),vt&&_e&&w6(s.jsxs("div",{ref:Pe,className:`${re?l?"fixed z-popover":"fixed z-menu-panel":"absolute right-2 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`,style:re?{left:re.left,top:re.top}:void 0,children:[Te&&s.jsxs("button",{type:"button",onClick:Ve,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:xe("fileTree.openInFileBrowserTitle"),children:[s.jsx(wu,{size:13,className:"shrink-0 text-[color:var(--folder)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe("fileTree.openInFileBrowser")})]}),y&&s.jsxs("button",{type:"button",onClick:Lt,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:xe("fileTree.openDirRootTitle"),children:[s.jsx(wu,{size:13,className:"shrink-0 text-[color:var(--folder)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe("fileTree.openDirRoot")})]}),w&&s.jsxs("button",{type:"button",onClick:pe,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:xe("fileTree.searchFromDirTitle"),children:[s.jsx(I1,{size:13,className:"shrink-0 text-primary"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe("fileTree.searchFromDir")})]}),v&&s.jsxs("button",{type:"button",onClick:Ge,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] ${Ie?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:xe(Ie?"fileTree.unpinDirTitle":"fileTree.pinDirTitle"),children:[Ie?s.jsx(od,{size:13,className:"shrink-0"}):s.jsx(ad,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe(Ie?"fileTree.unpinDir":"fileTree.pinDir")})]}),s.jsxs("button",{type:"button",onClick:ft,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",children:[Ae==="modified"?s.jsx(lA,{size:13,className:"shrink-0"}):s.jsx(sd,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe(Ae==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]}),!!re),!st&&!l&&_e&&s.jsxs("div",{className:"absolute right-2 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:[Te&&s.jsxs("button",{type:"button",onClick:Ve,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:xe("fileTree.openInFileBrowserTitle"),children:[s.jsx(y3,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe("fileTree.openInFileBrowser")})]}),s.jsxs("button",{type:"button",onClick:at,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:xe("rightSidebar.downloadFile"),children:[s.jsx(id,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe("rightSidebar.downloadFile")})]}),We&&s.jsxs("button",{type:"button",onClick:q,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] ${Ie?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:xe(Ie?"fileTree.unpinFileTitle":"fileTree.pinFileTitle"),children:[Ie?s.jsx(od,{size:13,className:"shrink-0"}):s.jsx(ad,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe(Ie?"fileTree.unpinFile":"fileTree.pinFile")})]}),s.jsxs("button",{type:"button",onClick:Vt,disabled:Mt,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-destructive transition hover:bg-destructive/10 active:scale-[0.99] disabled:opacity-50",title:xe("fileTree.deleteFile"),children:[Mt?s.jsx(In,{size:13,className:"shrink-0 animate-spin"}):s.jsx(zs,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe("fileTree.deleteFile")})]})]})]})]})]}),Ye&&Yt&&Yt.length>0&&s.jsx("div",{className:r===0?"mt-0.5":"",children:Yt.map(bt=>s.jsx(e,{node:bt,depth:r+1,onFileSelect:n,directoriesOnly:a,onPathReference:c,referenceSelection:l,getReferenceText:h,onReferenceCopied:p,onDirectoryRoot:y,onSearchFromDirectory:w,onDirectoryPinToggle:v,onFilePinToggle:k,onOpenInFileBrowser:L,canOpenInFileBrowser:E,pinnedPaths:R,selectedFilePath:B,queryLower:W,insertedReferenceKey:m,copiedReferenceKey:x,onDirectoryDropFiles:F,onFileDeleteRequest:U,deletingFilePath:V,gitIgnoreRoot:le,revealedDirectoryPath:Z},bt.path))})]})}),RP=b.memo(function({node:t,rootPath:r,onFileSelect:n,onPathReference:a,referenceSelection:c,getReferenceText:l,onReferenceCopied:h,insertedReferenceKey:p,copiedReferenceKey:m,onDirectoryRoot:x,onSearchFromDirectory:y,onDirectoryPinToggle:w,onFilePinToggle:v,pinnedPaths:k,selectedFilePath:L,onFileDeleteRequest:E,deletingFilePath:R}){const{t:B}=zr(),W=t.path===L,F=t.type==="directory",U=k.has(t.path),V=!F&&!!v,Z=`path:${t.path}`,le=p===Z||!!c?.paths.has(t.path),xe=m===Z,fe=l?.(t.path)??t.path,te=L1(h,!!c),{state:ke,run:$e}=b6(),[Y,Ae]=b.useState(!1),{position:lt,menuRef:Ce,openAt:ye,clearPosition:_e}=v6(Y);wd(Ce,Y&&!!c,()=>Ae(!1));const je=b.useRef(null),re=R===t.path,Pe=F&&!!(x||y||w),Se=b.useCallback(()=>{Af()||(t.type==="directory"?x?.(t.path):n(t.path))},[t.path,t.type,x,n]),Ee=b.useCallback(de=>{de.stopPropagation(),a?.(t.path,Z)},[a,t.path,Z]),Be=b.useCallback(de=>{de.stopPropagation(),w?.(t.path),Ae(!1)},[t.path,w]),Ne=b.useCallback(de=>{de.stopPropagation(),v?.(t.path),Ae(!1)},[t.path,v]),oe=b.useCallback(de=>{de.stopPropagation(),Ae(!1),$e(t.path)},[t.path,$e]),He=b.useCallback(de=>{de.stopPropagation(),Ae(!1),E(t)},[t,E]),rt=b.useCallback(de=>{de.stopPropagation(),c?ye(de.clientX,de.clientY):_e(),Ae(Ye=>!Ye)},[_e,ye,!!c]),mt=b.useCallback(de=>{!Pe||!y6(de)||(de.preventDefault(),de.stopPropagation(),ye(de.clientX,de.clientY),Ae(!0))},[Pe,ye]);return b.useEffect(()=>{if(!Y)return;const de=st=>{const Ie=st.target;Ie instanceof Node&&(je.current?.contains(Ie)||Ce.current?.contains(Ie))||Ae(!1)},Ye=st=>{st.key==="Escape"&&Ae(!1)};return document.addEventListener("pointerdown",de),document.addEventListener("keydown",Ye),()=>{document.removeEventListener("pointerdown",de),document.removeEventListener("keydown",Ye)}},[Y,Ce]),s.jsxs("div",{ref:je,className:"relative border-b border-border/10 last:border-b-0",children:[te.popoverNode,s.jsxs("div",{role:"button",tabIndex:0,onClick:Se,onContextMenu:mt,onKeyDown:de=>{de.target!==de.currentTarget||de.key!=="Enter"&&de.key!==" "||(de.preventDefault(),Se())},className:`group flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-2 text-left text-[13px] transition ${W?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:t.path,children:[t.type==="directory"?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"w-[14px] shrink-0"}),s.jsx(jc,{size:14,className:"shrink-0 text-[color:var(--folder)]"})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"w-[14px] shrink-0"}),s.jsx("span",{className:W?"text-primary":"text-muted-foreground/80",children:pg(t.name,t.type)})]}),s.jsxs("span",{className:"min-w-0 flex-1 select-text",children:[s.jsxs("span",{className:`block whitespace-normal break-all font-medium leading-snug ${W?"text-primary":"text-foreground"}`,children:[t.name,t.isSymlink&&s.jsx("span",{className:"ml-1 inline-flex align-middle text-muted-foreground/70",title:B("fileTree.symbolicLink"),children:s.jsx(Lu,{size:11})})]}),s.jsx("span",{className:"mt-0.5 block truncate font-mono text-[10px] text-muted-foreground/80",children:x1(r,t.path)})]}),s.jsx(x6,{path:t.path}),t.type==="directory"&&(w||y)&&s.jsx("button",{type:"button",onClick:rt,className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-muted-foreground transition focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary active:scale-95 ${Qu(Y)} ${Y?"bg-surface-elevated text-foreground":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":B("fileTree.moreDirActions"),"aria-expanded":Y,title:B("fileTree.moreDirActions"),children:s.jsx(Qo,{size:13})}),!F&&!c&&s.jsx("button",{type:"button",onClick:rt,className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-muted-foreground transition focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary active:scale-95 ${Qu(Y||ke.status==="pending"||re||U)} ${Y?"bg-surface-elevated text-foreground":U?"bg-primary/15 text-primary":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":B("fileTree.moreFileActions"),"aria-expanded":Y,title:ke.status==="error"?ke.message??B("rightSidebar.downloadFailed"):B("fileTree.moreFileActions"),children:ke.status==="pending"||re?s.jsx(In,{size:13,className:"animate-spin"}):s.jsx(Qo,{size:13})}),a&&s.jsx("button",{type:"button",onClick:Ee,...te(fe,Z),className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-[11px] font-semibold transition focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary active:scale-95 ${c?"ml-1 min-h-11 min-w-11":mg(le||xe)} ${le||xe?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":c?`${c.label}: ${t.name}`:B(xe?"rightSidebar.copied":le?"rightSidebar.inserted":"fileTree.insertRefTitle"),"aria-pressed":c?le:void 0,disabled:!!c?.disabled&&!le,title:c?`${c.label}: ${t.name}`:B(xe?"rightSidebar.copied":le?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:xe||le?s.jsx(di,{size:12}):s.jsx(Lu,{size:12})})]}),Pe&&Y&&w6(s.jsxs("div",{ref:Ce,className:`${lt?c?"fixed z-popover":"fixed z-menu-panel":"absolute right-2 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`,style:lt?{left:lt.left,top:lt.top}:void 0,children:[x&&s.jsxs("button",{type:"button",onClick:de=>{de.stopPropagation(),x(t.path),Ae(!1)},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:B("fileTree.openDirRootTitle"),children:[s.jsx(wu,{size:13,className:"shrink-0 text-[color:var(--folder)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B("fileTree.openDirRoot")})]}),y&&s.jsxs("button",{type:"button",onClick:de=>{de.stopPropagation(),y(t.path),Ae(!1)},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",children:[s.jsx(I1,{size:13,className:"shrink-0 text-primary"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B("fileTree.searchFromDir")})]}),w&&s.jsxs("button",{type:"button",onClick:Be,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] ${U?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:B(U?"fileTree.unpinDirTitle":"fileTree.pinDirTitle"),children:[U?s.jsx(od,{size:13,className:"shrink-0"}):s.jsx(ad,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B(U?"fileTree.unpinDir":"fileTree.pinDir")})]})]}),!!lt),!F&&!c&&Y&&s.jsxs("div",{className:"absolute right-2 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:[s.jsxs("button",{type:"button",onClick:oe,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:B("rightSidebar.downloadFile"),children:[s.jsx(id,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B("rightSidebar.downloadFile")})]}),V&&s.jsxs("button",{type:"button",onClick:Ne,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] ${U?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:B(U?"fileTree.unpinFileTitle":"fileTree.pinFileTitle"),children:[U?s.jsx(od,{size:13,className:"shrink-0"}):s.jsx(ad,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B(U?"fileTree.unpinFile":"fileTree.pinFile")})]}),s.jsxs("button",{type:"button",onClick:He,disabled:re,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-destructive transition hover:bg-destructive/10 active:scale-[0.99] disabled:opacity-50",title:B("fileTree.deleteFile"),children:[re?s.jsx(In,{size:13,className:"shrink-0 animate-spin"}):s.jsx(zs,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B("fileTree.deleteFile")})]})]})]})}),MP=60,ob=60,jP=20;function lb({count:e,loading:t,engine:r,limited:n,scope:a,content:c}){const{t:l}=zr();return s.jsxs("div",{className:"sticky top-0 z-10 -mx-2 -mt-2 mb-2 border-b border-border/15 bg-surface/95 px-3 py-2.5 backdrop-blur",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2 text-[12px] font-semibold text-foreground",children:[s.jsx(I1,{size:14,className:"shrink-0 text-primary"}),s.jsx("span",{children:c?l("fileTree.contentMatchesCount",{count:e}):l("fileTree.searchResults",{count:e})})]}),r&&s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full bg-surface-2 px-2 py-0.5 text-[9px] uppercase tracking-[0.12em] text-muted-foreground",children:[t&&s.jsx(In,{size:9,className:"animate-spin"}),r,n?" · limited":""]})]}),s.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-1.5 text-[10px] text-muted-foreground",children:[s.jsx("span",{className:"shrink-0",children:l("fileTree.searchScope")}),s.jsx("span",{className:"min-w-0 truncate font-mono text-foreground/75",title:a,children:a}),t&&s.jsx("span",{className:"ml-auto shrink-0",children:l("fileTree.searching")})]})]})}function DP(e,t){if(!t)return e;const r=e.toLowerCase(),n=t.toLowerCase(),a=[];let c=0,l=r.indexOf(n,c),h=0;for(;l>=0&&n;)l>c&&a.push(e.slice(c,l)),a.push(s.jsx("mark",{className:"rounded-sm bg-[rgb(var(--warning-rgb)_/_0.30)] px-0.5 text-foreground",children:e.slice(l,l+n.length)},`m-${h++}`)),c=l+n.length,l=r.indexOf(n,c);return c<e.length&&a.push(e.slice(c)),a.length>0?a:e}const BP=b.memo(function({entry:t,rootPath:r,selectedFilePath:n,query:a,onContentMatchSelect:c,onPathReference:l,referenceSelection:h,getReferenceText:p,onReferenceCopied:m,insertedReferenceKey:x,copiedReferenceKey:y}){const{t:w}=zr(),[v,k]=b.useState(!0),L=t.path===n,E=v?t.matches.slice(0,jP):[],R=t.matches.length-E.length,B=`path:${t.path}`,W=x===B||!!h?.paths.has(t.path),F=y===B,U=p?.(t.path)??t.path,V=L1(m,!!h);return s.jsxs("div",{className:"border-b border-border/10 last:border-b-0",children:[V.popoverNode,s.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{Af()||k(Z=>!Z)},onKeyDown:Z=>{Z.target!==Z.currentTarget||Z.key!=="Enter"&&Z.key!==" "||(Z.preventDefault(),k(le=>!le))},className:`group flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-2 text-left text-[13px] transition ${L?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:t.path,children:[v?s.jsx(ul,{size:14,className:"shrink-0 text-muted-foreground/80"}):s.jsx(hi,{size:14,className:"shrink-0 text-muted-foreground/80"}),s.jsx("span",{className:L?"text-primary":"text-muted-foreground/80",children:pg(t.name,"file")}),s.jsxs("span",{className:"min-w-0 flex-1 select-text",children:[s.jsx("span",{className:"block whitespace-normal break-all font-medium leading-snug",children:t.name}),s.jsx("span",{className:"mt-0.5 block truncate font-mono text-[10px] text-muted-foreground/80",children:x1(r,t.path)})]}),s.jsx("span",{className:"shrink-0 select-none rounded-full bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:t.matches.length}),!h&&s.jsx(kP,{path:t.path}),l&&s.jsx("button",{type:"button",onClick:Z=>{Z.stopPropagation(),l(t.path,B)},...V(U,B),className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-[11px] font-semibold transition focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary active:scale-95 ${h?"ml-1 min-h-11 min-w-11":mg(W||F)} ${W||F?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":h?`${h.label}: ${t.name}`:w(F?"rightSidebar.copied":W?"rightSidebar.inserted":"fileTree.insertRefTitle"),"aria-pressed":h?W:void 0,disabled:!!h?.disabled&&!W,title:h?`${h.label}: ${t.name}`:w(F?"rightSidebar.copied":W?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:F||W?s.jsx(di,{size:12}):s.jsx(Lu,{size:12})})]}),v&&s.jsxs("div",{className:"mb-1 ml-3 border-l border-border/20 pl-1",children:[E.map((Z,le)=>s.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{Af()||c?.(t.path,Z.line)},onKeyDown:xe=>{xe.target!==xe.currentTarget||xe.key!=="Enter"&&xe.key!==" "||(xe.preventDefault(),c?.(t.path,Z.line))},className:"flex w-full cursor-pointer items-start gap-2 rounded px-2 py-1 text-left font-mono text-[11px] text-muted-foreground transition hover:bg-surface-2 hover:text-foreground",title:`${x1(r,t.path)}:${Z.line}`,children:[s.jsx("span",{className:"shrink-0 select-none tabular-nums text-muted-foreground/60",children:Z.line}),s.jsx("span",{className:"min-w-0 flex-1 truncate whitespace-pre select-text",children:DP(Z.text,a)})]},`${Z.line}-${le}`)),R>0&&s.jsx("div",{className:"px-2 py-1 text-[10px] text-muted-foreground/70",children:w("fileTree.moreMatches",{count:R})})]})]})});function QP({rootPath:e,onFileSelect:t,directoriesOnly:r=!1,onPathReference:n,referenceSelection:a,getReferenceText:c,onReferenceCopied:l,insertedReferenceKey:h,copiedReferenceKey:p,onDirectoryRoot:m,onSearchFromDirectory:x,onDirectoryPinToggle:y,onFilePinToggle:w,onOpenInFileBrowser:v,canOpenInFileBrowser:k=!1,pinnedPaths:L=CP,selectedFilePath:E,query:R="",searchRootPath:B,searchOptions:W={},searchMode:F="name",onContentMatchSelect:U,onDirectoryDropFiles:V,revealDirectory:Z}){const{t:le}=zr(),xe=b.useId(),fe=a?`file-tree-reference-root:${xe}:${e}`:`file-tree-root:${e}`,te=Gt(Ve=>e?Ve.directoryCache.get(e):void 0),ke=Gt(Ve=>Ve.setDirectoryCache),$e=Gt(Ve=>Ve.showHiddenFiles),Y=Gt(Ve=>Ve.fileSortModesHydrated),Ae=Gt(Ve=>Ve.fileSortModes[e]??"name"),lt=Gt(Ve=>Ve.hydrateFileSortModes),Ce=Gt(Ve=>Ve.hydrateHideGitIgnoredRoots),ye=Gt(Ve=>!!Ve.hideGitIgnoredRoots[e]),_e=Gt(Ve=>Ve.hideGitIgnoredRootsHydrated),je=Gt(Ve=>JSON.stringify(Ve.gitIgnoreExceptions[e]??[])),re=Gt(Ve=>Ve.invalidateDirectoryCache),Pe=`${e}:${ye}:${je}`,[Se,Ee]=b.useState("");b.useLayoutEffect(()=>{e&&re(e,!0),Ee(Pe)},[e,ye,je,re,Pe]);const[Be,Ne]=b.useState(!1),[oe,He]=b.useState(null),[rt,mt]=b.useState(!1),[de,Ye]=b.useState(!1),[st,Ie]=b.useState(null),[We,Te]=b.useState(Y&&_e),H=Y&&_e||We;b.useEffect(()=>{let Ve=!1;return Promise.all([lt(),Ce()]).catch(()=>{}).finally(()=>{Ve||Te(!0)}),()=>{Ve=!0}},[lt,Ce]);const[ae,be]=b.useState([]),[Ze,Je]=b.useState(null),[Tt,Wt]=b.useState(sb),[Mt,vt]=b.useState([]),[Yt,Qt]=b.useState(null),Xt=b.useRef(null),Ut=b.useRef(0),Lt=R.trim().toLowerCase(),pe=F==="content",Ge=B||e,ft=W.excludePatterns??SP,q=ft.join(`
129
+ `).trim()).find(Boolean),c=typeof n=="string"&&n.trim()?n.trim():a,l=Number.isFinite(t.createdAt)&&t.createdAt>0&&Number.isFinite(new Date(t.createdAt).getTime());return{status:t.status,label:yf[t.status]??"成员明确报告",createdAt:l?t.createdAt:null,content:r,summary:c?c.slice(0,512):"报告摘要未提供,请查看详情中的原始报告"}}function $f(e){if(e.status!=="open")return[];const t=Jv(e),r=t&&["blocked","failed"].includes(t.status)?{source:"member",label:t.label,content:t.content,summary:t.summary,createdAt:t.createdAt}:null,n=r&&(e.automationIssueSource==="member-report"||!e.summaryOnly&&!!t?.content&&e.automationIssue===t.content.slice(0,1e3)),a=r&&!t?.content&&!e.automationIssueSource,c=e.automationIssue&&!n?{source:a?"unknown":"system",label:a?"服务记录(来源待核对)":e.automationIssue.startsWith("消息投递")?"投递需要处理":e.activeAttemptId?"自动安排受阻":"执行准备受阻",content:e.automationIssue,summary:e.automationIssue}:null;return[r,c].filter(l=>!!l)}function IB(e){return $f(e)[0]??null}function Qc(e){if(e.status==="accepted")return e.completionMode==="reviewed"?"独立评审通过":"已验收";if(e.status==="closed")return"已关闭";if(e.purpose==="automation"){const l={unassigned:"后台记录待分派",awaiting_report:"后台执行等待明确报告",ack:"执行成员已确认接手",working:"成员报告进行中",blocked:"成员报告受阻",failed:"成员报告失败",complete:"执行已交付"};return e.execution?l[e.execution.status]:"后台执行记录"}if(e.decisions.some(l=>l.status==="pending"))return"需要你回答";const t=IB(e);if(t)return t.label;if(e.workflow?.paused)return"自动安排已暂停";const r=e.attempts.find(l=>l.id===e.activeAttemptId),n=e.artifacts.filter(l=>l.kind==="plan"&&l.attemptId===e.activeAttemptId).at(-1);if(n&&n.id!==e.approvedPlanArtifactId)return"需要你确认方案";const a=e.artifacts.filter(l=>l.kind==="result"&&l.attemptId===e.activeAttemptId).at(-1),c=a&&e.events.some(l=>l.kind==="revise"&&l.attemptId===e.activeAttemptId&&l.createdAt>=a.createdAt);if(a&&!c){const l=e.artifacts.filter(h=>h.kind==="review"&&h.reviewsArtifactId===a.id).at(-1);return e.workflow&&l?.verdict!=="pass"?l?.verdict==="changes"?"评审要求修改":"等待独立评审":e.workflow?.kind==="step"?"评审通过 · 等待接续":"等待你验收"}return c?e.events.some(l=>l.kind==="revise"&&l.source==="user"&&l.attemptId===e.activeAttemptId&&l.createdAt>=a.createdAt)?"已要求跟进 · 等待新结果":"已要求修改 · 等待新结果":r?r.report?yf[r.report.status]:["failed","expired"].includes(r.deliveryStatus??"")?"投递未成功":e.deliveries.some(l=>l.attemptId===e.activeAttemptId&&l.error)?"投递需要关注":r.deliveryStatus==="delivered"?"已写入终端 · 等待回复":"等待投递":e.scheduledAssignee?e.dependsOn.length?"依赖完成后自动分派":e.workflow?.isolated===!1?"等待分派":"准备独立执行目录":e.dependsOn.length?"等待依赖与分派":"待分派"}function $i(e){return e.purpose!=="automation"&&e.status==="open"&&["需要你回答","需要你确认方案","等待你验收","执行准备受阻","自动安排受阻","成员报告受阻","成员报告失败","投递未成功","投递需要关注","投递需要处理"].includes(Qc(e))}const mu=rc(e=>{let t=!1;return{tasks:[],allTasks:[],error:null,refresh:async()=>{if(!t){t=!0;try{const{tasks:r}=await o3();e({tasks:r.filter($i),allTasks:r,error:null})}catch(r){e({error:r instanceof Error?r.message:"协作待处理事项加载失败"})}finally{t=!1}}}}});function _5(e,t){try{localStorage.setItem(`termdock:tasks:${location.origin}:${e}:open-task`,JSON.stringify(t))}catch{}window.dispatchEvent(new CustomEvent("open-collaboration-task",{detail:{groupId:e,taskId:t}}))}function k5({sessionIds:e}){const t=hw(a=>e.reduce((c,l)=>c+(a.unread[l]?.length??0),0)),{locale:r}=zr();if(!t)return null;const n=r==="zh"?`${t} 条未读进展`:`${t} unread progress updates`;return s.jsx("span",{title:n,"aria-label":n,className:"inline-flex h-4 min-w-4 shrink-0 items-center justify-center rounded-full bg-primary/15 px-1 text-[10px] font-medium text-primary",children:t>99?"99+":t})}function EB(e){if(!e.startsWith("remote:"))return null;const t=e.slice(7).split(":");if(t.length!==2)return null;try{const r=decodeURIComponent(t[0]),n=decodeURIComponent(t[1]),a=new URL(r);return!["https:","http:"].includes(a.protocol)||a.origin!==r||!n?null:{origin:r,sessionId:n}}catch{return null}}async function e6(e){const t=EB(e);if(!t)throw new Error("远端会话标识无效");if(window.termdockDesktop?.collaborationFocus)try{if(await window.termdockDesktop.collaborationFocus(e))return}catch{}window.dispatchEvent(new CustomEvent("termdock:open-remote-session",{detail:t}))}function NB(e,t,r){return Math.max(t,Math.min(e,r))}const hs={toVector(e,t){return e===void 0&&(e=t),Array.isArray(e)?e:[e,e]},add(e,t){return[e[0]+t[0],e[1]+t[1]]},sub(e,t){return[e[0]-t[0],e[1]-t[1]]},addTo(e,t){e[0]+=t[0],e[1]+=t[1]},subTo(e,t){e[0]-=t[0],e[1]-=t[1]}};function L5(e,t,r){return t===0||Math.abs(t)===1/0?Math.pow(e,r*5):e*t*r/(t+r*e)}function I5(e,t,r,n=.15){return n===0?NB(e,t,r):e<t?-L5(t-e,r-t,n)+t:e>r?+L5(e-r,r-t,n)+r:e}function RB(e,[t,r],[n,a]){const[[c,l],[h,p]]=e;return[I5(t,c,l,n),I5(r,h,p,a)]}function MB(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function jB(e){var t=MB(e,"string");return typeof t=="symbol"?t:String(t)}function Ps(e,t,r){return t=jB(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function E5(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function vs(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?E5(Object(r),!0).forEach(function(n){Ps(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):E5(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}const t6={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function N5(e){return e?e[0].toUpperCase()+e.slice(1):""}const DB=["enter","leave"];function BB(e=!1,t){return e&&!DB.includes(t)}function QB(e,t="",r=!1){const n=t6[e],a=n&&n[t]||t;return"on"+N5(e)+N5(a)+(BB(r,a)?"Capture":"")}const PB=["gotpointercapture","lostpointercapture"];function OB(e){let t=e.substring(2).toLowerCase();const r=!!~t.indexOf("passive");r&&(t=t.replace("passive",""));const n=PB.includes(t)?"capturecapture":"capture",a=!!~t.indexOf(n);return a&&(t=t.replace("capture","")),{device:t,capture:a,passive:r}}function FB(e,t=""){const r=t6[e],n=r&&r[t]||t;return e+n}function Uf(e){return"touches"in e}function r6(e){return Uf(e)?"touch":"pointerType"in e?e.pointerType:"mouse"}function $B(e){return Array.from(e.touches).filter(t=>{var r,n;return t.target===e.currentTarget||((r=e.currentTarget)===null||r===void 0||(n=r.contains)===null||n===void 0?void 0:n.call(r,t.target))})}function UB(e){return e.type==="touchend"||e.type==="touchcancel"?e.changedTouches:e.targetTouches}function n6(e){return Uf(e)?UB(e)[0]:e}function h1(e,t){try{const r=t.clientX-e.clientX,n=t.clientY-e.clientY,a=(t.clientX+e.clientX)/2,c=(t.clientY+e.clientY)/2,l=Math.hypot(r,n);return{angle:-(Math.atan2(r,n)*180)/Math.PI,distance:l,origin:[a,c]}}catch{}return null}function zB(e){return $B(e).map(t=>t.identifier)}function R5(e,t){const[r,n]=Array.from(e.touches).filter(a=>t.includes(a.identifier));return h1(r,n)}function am(e){const t=n6(e);return Uf(e)?t.identifier:t.pointerId}function Bu(e){const t=n6(e);return[t.clientX,t.clientY]}const M5=40,j5=800;function s6(e){let{deltaX:t,deltaY:r,deltaMode:n}=e;return n===1?(t*=M5,r*=M5):n===2&&(t*=j5,r*=j5),[t,r]}function HB(e){var t,r;const{scrollX:n,scrollY:a,scrollLeft:c,scrollTop:l}=e.currentTarget;return[(t=n??c)!==null&&t!==void 0?t:0,(r=a??l)!==null&&r!==void 0?r:0]}function WB(e){const t={};if("buttons"in e&&(t.buttons=e.buttons),"shiftKey"in e){const{shiftKey:r,altKey:n,metaKey:a,ctrlKey:c}=e;Object.assign(t,{shiftKey:r,altKey:n,metaKey:a,ctrlKey:c})}return t}function vf(e,...t){return typeof e=="function"?e(...t):e}function GB(){}function VB(...e){return e.length===0?GB:e.length===1?e[0]:function(){let t;for(const r of e)t=r.apply(this,arguments)||t;return t}}function D5(e,t){return Object.assign({},t,e||{})}const qB=32;class i6{constructor(t,r,n){this.ctrl=t,this.args=r,this.key=n,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(t){this.ctrl.state[this.key]=t}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:t,shared:r,ingKey:n,args:a}=this;r[n]=t._active=t.active=t._blocked=t._force=!1,t._step=[!1,!1],t.intentional=!1,t._movement=[0,0],t._distance=[0,0],t._direction=[0,0],t._delta=[0,0],t._bounds=[[-1/0,1/0],[-1/0,1/0]],t.args=a,t.axis=void 0,t.memo=void 0,t.elapsedTime=t.timeDelta=0,t.direction=[0,0],t.distance=[0,0],t.overflow=[0,0],t._movementBound=[!1,!1],t.velocity=[0,0],t.movement=[0,0],t.delta=[0,0],t.timeStamp=0}start(t){const r=this.state,n=this.config;r._active||(this.reset(),this.computeInitial(),r._active=!0,r.target=t.target,r.currentTarget=t.currentTarget,r.lastOffset=n.from?vf(n.from,r):r.offset,r.offset=r.lastOffset,r.startTime=r.timeStamp=t.timeStamp)}computeValues(t){const r=this.state;r._values=t,r.values=this.config.transform(t)}computeInitial(){const t=this.state;t._initial=t._values,t.initial=t.values}compute(t){const{state:r,config:n,shared:a}=this;r.args=this.args;let c=0;if(t&&(r.event=t,n.preventDefault&&t.cancelable&&r.event.preventDefault(),r.type=t.type,a.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,a.locked=!!document.pointerLockElement,Object.assign(a,WB(t)),a.down=a.pressed=a.buttons%2===1||a.touches>0,c=t.timeStamp-r.timeStamp,r.timeStamp=t.timeStamp,r.elapsedTime=r.timeStamp-r.startTime),r._active){const V=r._delta.map(Math.abs);hs.addTo(r._distance,V)}this.axisIntent&&this.axisIntent(t);const[l,h]=r._movement,[p,m]=n.threshold,{_step:x,values:y}=r;if(n.hasCustomTransform?(x[0]===!1&&(x[0]=Math.abs(l)>=p&&y[0]),x[1]===!1&&(x[1]=Math.abs(h)>=m&&y[1])):(x[0]===!1&&(x[0]=Math.abs(l)>=p&&Math.sign(l)*p),x[1]===!1&&(x[1]=Math.abs(h)>=m&&Math.sign(h)*m)),r.intentional=x[0]!==!1||x[1]!==!1,!r.intentional)return;const w=[0,0];if(n.hasCustomTransform){const[V,Z]=y;w[0]=x[0]!==!1?V-x[0]:0,w[1]=x[1]!==!1?Z-x[1]:0}else w[0]=x[0]!==!1?l-x[0]:0,w[1]=x[1]!==!1?h-x[1]:0;this.restrictToAxis&&!r._blocked&&this.restrictToAxis(w);const v=r.offset,k=r._active&&!r._blocked||r.active;k&&(r.first=r._active&&!r.active,r.last=!r._active&&r.active,r.active=a[this.ingKey]=r._active,t&&(r.first&&("bounds"in n&&(r._bounds=vf(n.bounds,r)),this.setup&&this.setup()),r.movement=w,this.computeOffset()));const[L,E]=r.offset,[[R,B],[W,F]]=r._bounds;r.overflow=[L<R?-1:L>B?1:0,E<W?-1:E>F?1:0],r._movementBound[0]=r.overflow[0]?r._movementBound[0]===!1?r._movement[0]:r._movementBound[0]:!1,r._movementBound[1]=r.overflow[1]?r._movementBound[1]===!1?r._movement[1]:r._movementBound[1]:!1;const U=r._active?n.rubberband||[0,0]:[0,0];if(r.offset=RB(r._bounds,r.offset,U),r.delta=hs.sub(r.offset,v),this.computeMovement(),k&&(!r.last||c>qB)){r.delta=hs.sub(r.offset,v);const V=r.delta.map(Math.abs);hs.addTo(r.distance,V),r.direction=r.delta.map(Math.sign),r._direction=r._delta.map(Math.sign),!r.first&&c>0&&(r.velocity=[V[0]/c,V[1]/c],r.timeDelta=c)}}emit(){const t=this.state,r=this.shared,n=this.config;if(t._active||this.clean(),(t._blocked||!t.intentional)&&!t._force&&!n.triggerAllEvents)return;const a=this.handler(vs(vs(vs({},r),t),{},{[this.aliasKey]:t.values}));a!==void 0&&(t.memo=a)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function YB([e,t],r){const n=Math.abs(e),a=Math.abs(t);if(n>a&&n>r)return"x";if(a>n&&a>r)return"y"}class Id extends i6{constructor(...t){super(...t),Ps(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=hs.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=hs.sub(this.state.offset,this.state.lastOffset)}axisIntent(t){const r=this.state,n=this.config;if(!r.axis&&t){const a=typeof n.axisThreshold=="object"?n.axisThreshold[r6(t)]:n.axisThreshold;r.axis=YB(r._movement,a)}r._blocked=(n.lockDirection||!!n.axis)&&!r.axis||!!n.axis&&n.axis!==r.axis}restrictToAxis(t){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":t[1]=0;break;case"y":t[0]=0;break}}}const ZB=e=>e,B5=.15,a6={enabled(e=!0){return e},eventOptions(e,t,r){return vs(vs({},r.shared.eventOptions),e)},preventDefault(e=!1){return e},triggerAllEvents(e=!1){return e},rubberband(e=0){switch(e){case!0:return[B5,B5];case!1:return[0,0];default:return hs.toVector(e)}},from(e){if(typeof e=="function")return e;if(e!=null)return hs.toVector(e)},transform(e,t,r){const n=e||r.shared.transform;return this.hasCustomTransform=!!n,n||ZB},threshold(e){return hs.toVector(e,0)}},KB=0,Oc=vs(vs({},a6),{},{axis(e,t,{axis:r}){if(this.lockDirection=r==="lock",!this.lockDirection)return r},axisThreshold(e=KB){return e},bounds(e={}){if(typeof e=="function")return c=>Oc.bounds(e(c));if("current"in e)return()=>e.current;if(typeof HTMLElement=="function"&&e instanceof HTMLElement)return e;const{left:t=-1/0,right:r=1/0,top:n=-1/0,bottom:a=1/0}=e;return[[t,r],[n,a]]}}),Q5={ArrowRight:(e,t=1)=>[e*t,0],ArrowLeft:(e,t=1)=>[-1*e*t,0],ArrowUp:(e,t=1)=>[0,-1*e*t],ArrowDown:(e,t=1)=>[0,e*t]};class XB extends Id{constructor(...t){super(...t),Ps(this,"ingKey","dragging")}reset(){super.reset();const t=this.state;t._pointerId=void 0,t._pointerActive=!1,t._keyboardActive=!1,t._preventScroll=!1,t._delayed=!1,t.swipe=[0,0],t.tap=!1,t.canceled=!1,t.cancel=this.cancel.bind(this)}setup(){const t=this.state;if(t._bounds instanceof HTMLElement){const r=t._bounds.getBoundingClientRect(),n=t.currentTarget.getBoundingClientRect(),a={left:r.left-n.left+t.offset[0],right:r.right-n.right+t.offset[0],top:r.top-n.top+t.offset[1],bottom:r.bottom-n.bottom+t.offset[1]};t._bounds=Oc.bounds(a)}}cancel(){const t=this.state;t.canceled||(t.canceled=!0,t._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(t){const r=this.config,n=this.state;if(t.buttons!=null&&(Array.isArray(r.pointerButtons)?!r.pointerButtons.includes(t.buttons):r.pointerButtons!==-1&&r.pointerButtons!==t.buttons))return;const a=this.ctrl.setEventIds(t);r.pointerCapture&&t.target.setPointerCapture(t.pointerId),!(a&&a.size>1&&n._pointerActive)&&(this.start(t),this.setupPointer(t),n._pointerId=am(t),n._pointerActive=!0,this.computeValues(Bu(t)),this.computeInitial(),r.preventScrollAxis&&r6(t)!=="mouse"?(n._active=!1,this.setupScrollPrevention(t)):r.delay>0?(this.setupDelayTrigger(t),r.triggerAllEvents&&(this.compute(t),this.emit())):this.startPointerDrag(t))}startPointerDrag(t){const r=this.state;r._active=!0,r._preventScroll=!0,r._delayed=!1,this.compute(t),this.emit()}pointerMove(t){const r=this.state,n=this.config;if(!r._pointerActive)return;const a=am(t);if(r._pointerId!==void 0&&a!==r._pointerId)return;const c=Bu(t);if(document.pointerLockElement===t.target?r._delta=[t.movementX,t.movementY]:(r._delta=hs.sub(c,r._values),this.computeValues(c)),hs.addTo(r._movement,r._delta),this.compute(t),r._delayed&&r.intentional){this.timeoutStore.remove("dragDelay"),r.active=!1,this.startPointerDrag(t);return}if(n.preventScrollAxis&&!r._preventScroll)if(r.axis)if(r.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){r._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(t);return}else return;this.emit()}pointerUp(t){this.ctrl.setEventIds(t);try{this.config.pointerCapture&&t.target.hasPointerCapture(t.pointerId)&&t.target.releasePointerCapture(t.pointerId)}catch{}const r=this.state,n=this.config;if(!r._active||!r._pointerActive)return;const a=am(t);if(r._pointerId!==void 0&&a!==r._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(t);const[c,l]=r._distance;if(r.tap=c<=n.tapsThreshold&&l<=n.tapsThreshold,r.tap&&n.filterTaps)r._force=!0;else{const[h,p]=r._delta,[m,x]=r._movement,[y,w]=n.swipe.velocity,[v,k]=n.swipe.distance,L=n.swipe.duration;if(r.elapsedTime<L){const E=Math.abs(h/r.timeDelta),R=Math.abs(p/r.timeDelta);E>y&&Math.abs(m)>v&&(r.swipe[0]=Math.sign(h)),R>w&&Math.abs(x)>k&&(r.swipe[1]=Math.sign(p))}}this.emit()}pointerClick(t){!this.state.tap&&t.detail>0&&(t.preventDefault(),t.stopPropagation())}setupPointer(t){const r=this.config,n=r.device;r.pointerLock&&t.currentTarget.requestPointerLock(),r.pointerCapture||(this.eventStore.add(this.sharedConfig.window,n,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(t){this.state._preventScroll&&t.cancelable&&t.preventDefault()}setupScrollPrevention(t){this.state._preventScroll=!1,JB(t);const r=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",r),this.eventStore.add(this.sharedConfig.window,"touch","cancel",r),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,t)}setupDelayTrigger(t){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(t)},this.config.delay)}keyDown(t){const r=Q5[t.key];if(r){const n=this.state,a=t.shiftKey?10:t.altKey?.1:1;this.start(t),n._delta=r(this.config.keyboardDisplacement,a),n._keyboardActive=!0,hs.addTo(n._movement,n._delta),this.compute(t),this.emit()}}keyUp(t){t.key in Q5&&(this.state._keyboardActive=!1,this.setActive(),this.compute(t),this.emit())}bind(t){const r=this.config.device;t(r,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(t(r,"change",this.pointerMove.bind(this)),t(r,"end",this.pointerUp.bind(this)),t(r,"cancel",this.pointerUp.bind(this)),t("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(t("key","down",this.keyDown.bind(this)),t("key","up",this.keyUp.bind(this))),this.config.filterTaps&&t("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function JB(e){"persist"in e&&typeof e.persist=="function"&&e.persist()}const Ed=typeof window<"u"&&window.document&&window.document.createElement;function o6(){return Ed&&"ontouchstart"in window}function eQ(){return o6()||Ed&&window.navigator.maxTouchPoints>1}function tQ(){return Ed&&"onpointerdown"in window}function rQ(){return Ed&&"exitPointerLock"in window.document}function nQ(){try{return"constructor"in GestureEvent}catch{return!1}}const oo={isBrowser:Ed,gesture:nQ(),touch:o6(),touchscreen:eQ(),pointer:tQ(),pointerLock:rQ()},sQ=250,iQ=180,aQ=.5,oQ=50,lQ=250,cQ=10,P5={mouse:0,touch:0,pen:8},uQ=vs(vs({},Oc),{},{device(e,t,{pointer:{touch:r=!1,lock:n=!1,mouse:a=!1}={}}){return this.pointerLock=n&&oo.pointerLock,oo.touch&&r?"touch":this.pointerLock?"mouse":oo.pointer&&!a?"pointer":oo.touch?"touch":"mouse"},preventScrollAxis(e,t,{preventScroll:r}){if(this.preventScrollDelay=typeof r=="number"?r:r||r===void 0&&e?sQ:void 0,!(!oo.touchscreen||r===!1))return e||(r!==void 0?"y":void 0)},pointerCapture(e,t,{pointer:{capture:r=!0,buttons:n=1,keys:a=!0}={}}){return this.pointerButtons=n,this.keys=a,!this.pointerLock&&this.device==="pointer"&&r},threshold(e,t,{filterTaps:r=!1,tapsThreshold:n=3,axis:a=void 0}){const c=hs.toVector(e,r?n:a?1:0);return this.filterTaps=r,this.tapsThreshold=n,c},swipe({velocity:e=aQ,distance:t=oQ,duration:r=lQ}={}){return{velocity:this.transform(hs.toVector(e)),distance:this.transform(hs.toVector(t)),duration:r}},delay(e=0){switch(e){case!0:return iQ;case!1:return 0;default:return e}},axisThreshold(e){return e?vs(vs({},P5),e):P5},keyboardDisplacement(e=cQ){return e}});function l6(e){const[t,r]=e.overflow,[n,a]=e._delta,[c,l]=e._direction;(t<0&&n>0&&c<0||t>0&&n<0&&c>0)&&(e._movement[0]=e._movementBound[0]),(r<0&&a>0&&l<0||r>0&&a<0&&l>0)&&(e._movement[1]=e._movementBound[1])}const dQ=30,hQ=100;class fQ extends i6{constructor(...t){super(...t),Ps(this,"ingKey","pinching"),Ps(this,"aliasKey","da")}init(){this.state.offset=[1,0],this.state.lastOffset=[1,0],this.state._pointerEvents=new Map}reset(){super.reset();const t=this.state;t._touchIds=[],t.canceled=!1,t.cancel=this.cancel.bind(this),t.turns=0}computeOffset(){const{type:t,movement:r,lastOffset:n}=this.state;t==="wheel"?this.state.offset=hs.add(r,n):this.state.offset=[(1+r[0])*n[0],r[1]+n[1]]}computeMovement(){const{offset:t,lastOffset:r}=this.state;this.state.movement=[t[0]/r[0],t[1]-r[1]]}axisIntent(){const t=this.state,[r,n]=t._movement;if(!t.axis){const a=Math.abs(r)*dQ-Math.abs(n);a<0?t.axis="angle":a>0&&(t.axis="scale")}}restrictToAxis(t){this.config.lockDirection&&(this.state.axis==="scale"?t[1]=0:this.state.axis==="angle"&&(t[0]=0))}cancel(){const t=this.state;t.canceled||setTimeout(()=>{t.canceled=!0,t._active=!1,this.compute(),this.emit()},0)}touchStart(t){this.ctrl.setEventIds(t);const r=this.state,n=this.ctrl.touchIds;if(r._active&&r._touchIds.every(c=>n.has(c))||n.size<2)return;this.start(t),r._touchIds=Array.from(n).slice(0,2);const a=R5(t,r._touchIds);a&&this.pinchStart(t,a)}pointerStart(t){if(t.buttons!=null&&t.buttons%2!==1)return;this.ctrl.setEventIds(t),t.target.setPointerCapture(t.pointerId);const r=this.state,n=r._pointerEvents,a=this.ctrl.pointerIds;if(r._active&&Array.from(n.keys()).every(l=>a.has(l))||(n.size<2&&n.set(t.pointerId,t),r._pointerEvents.size<2))return;this.start(t);const c=h1(...Array.from(n.values()));c&&this.pinchStart(t,c)}pinchStart(t,r){const n=this.state;n.origin=r.origin,this.computeValues([r.distance,r.angle]),this.computeInitial(),this.compute(t),this.emit()}touchMove(t){if(!this.state._active)return;const r=R5(t,this.state._touchIds);r&&this.pinchMove(t,r)}pointerMove(t){const r=this.state._pointerEvents;if(r.has(t.pointerId)&&r.set(t.pointerId,t),!this.state._active)return;const n=h1(...Array.from(r.values()));n&&this.pinchMove(t,n)}pinchMove(t,r){const n=this.state,a=n._values[1],c=r.angle-a;let l=0;Math.abs(c)>270&&(l+=Math.sign(c)),this.computeValues([r.distance,r.angle-360*l]),n.origin=r.origin,n.turns=l,n._movement=[n._values[0]/n._initial[0]-1,n._values[1]-n._initial[1]],this.compute(t),this.emit()}touchEnd(t){this.ctrl.setEventIds(t),this.state._active&&this.state._touchIds.some(r=>!this.ctrl.touchIds.has(r))&&(this.state._active=!1,this.compute(t),this.emit())}pointerEnd(t){const r=this.state;this.ctrl.setEventIds(t);try{t.target.releasePointerCapture(t.pointerId)}catch{}r._pointerEvents.has(t.pointerId)&&r._pointerEvents.delete(t.pointerId),r._active&&r._pointerEvents.size<2&&(r._active=!1,this.compute(t),this.emit())}gestureStart(t){t.cancelable&&t.preventDefault();const r=this.state;r._active||(this.start(t),this.computeValues([t.scale,t.rotation]),r.origin=[t.clientX,t.clientY],this.compute(t),this.emit())}gestureMove(t){if(t.cancelable&&t.preventDefault(),!this.state._active)return;const r=this.state;this.computeValues([t.scale,t.rotation]),r.origin=[t.clientX,t.clientY];const n=r._movement;r._movement=[t.scale-1,t.rotation],r._delta=hs.sub(r._movement,n),this.compute(t),this.emit()}gestureEnd(t){this.state._active&&(this.state._active=!1,this.compute(t),this.emit())}wheel(t){const r=this.config.modifierKey;r&&(Array.isArray(r)?!r.find(n=>t[n]):!t[r])||(this.state._active?this.wheelChange(t):this.wheelStart(t),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this)))}wheelStart(t){this.start(t),this.wheelChange(t)}wheelChange(t){"uv"in t||t.cancelable&&t.preventDefault();const n=this.state;n._delta=[-s6(t)[1]/hQ*n.offset[0],0],hs.addTo(n._movement,n._delta),l6(n),this.state.origin=[t.clientX,t.clientY],this.compute(t),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){const r=this.config.device;r&&(t(r,"start",this[r+"Start"].bind(this)),t(r,"change",this[r+"Move"].bind(this)),t(r,"end",this[r+"End"].bind(this)),t(r,"cancel",this[r+"End"].bind(this)),t("lostPointerCapture","",this[r+"End"].bind(this))),this.config.pinchOnWheel&&t("wheel","",this.wheel.bind(this),{passive:!1})}}const pQ=vs(vs({},a6),{},{device(e,t,{shared:r,pointer:{touch:n=!1}={}}){if(r.target&&!oo.touch&&oo.gesture)return"gesture";if(oo.touch&&n)return"touch";if(oo.touchscreen){if(oo.pointer)return"pointer";if(oo.touch)return"touch"}},bounds(e,t,{scaleBounds:r={},angleBounds:n={}}){const a=l=>{const h=D5(vf(r,l),{min:-1/0,max:1/0});return[h.min,h.max]},c=l=>{const h=D5(vf(n,l),{min:-1/0,max:1/0});return[h.min,h.max]};return typeof r!="function"&&typeof n!="function"?[a(),c()]:l=>[a(l),c(l)]},threshold(e,t,r){return this.lockDirection=r.axis==="lock",hs.toVector(e,this.lockDirection?[.1,3]:0)},modifierKey(e){return e===void 0?"ctrlKey":e},pinchOnWheel(e=!0){return e}});class mQ extends Id{constructor(...t){super(...t),Ps(this,"ingKey","moving")}move(t){this.config.mouseOnly&&t.pointerType!=="mouse"||(this.state._active?this.moveChange(t):this.moveStart(t),this.timeoutStore.add("moveEnd",this.moveEnd.bind(this)))}moveStart(t){this.start(t),this.computeValues(Bu(t)),this.compute(t),this.computeInitial(),this.emit()}moveChange(t){if(!this.state._active)return;const r=Bu(t),n=this.state;n._delta=hs.sub(r,n._values),hs.addTo(n._movement,n._delta),this.computeValues(r),this.compute(t),this.emit()}moveEnd(t){this.state._active&&(this.state._active=!1,this.compute(t),this.emit())}bind(t){t("pointer","change",this.move.bind(this)),t("pointer","leave",this.moveEnd.bind(this))}}const gQ=vs(vs({},Oc),{},{mouseOnly:(e=!0)=>e});class xQ extends Id{constructor(...t){super(...t),Ps(this,"ingKey","scrolling")}scroll(t){this.state._active||this.start(t),this.scrollChange(t),this.timeoutStore.add("scrollEnd",this.scrollEnd.bind(this))}scrollChange(t){t.cancelable&&t.preventDefault();const r=this.state,n=HB(t);r._delta=hs.sub(n,r._values),hs.addTo(r._movement,r._delta),this.computeValues(n),this.compute(t),this.emit()}scrollEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){t("scroll","",this.scroll.bind(this))}}const bQ=Oc;class yQ extends Id{constructor(...t){super(...t),Ps(this,"ingKey","wheeling")}wheel(t){this.state._active||this.start(t),this.wheelChange(t),this.timeoutStore.add("wheelEnd",this.wheelEnd.bind(this))}wheelChange(t){const r=this.state;r._delta=s6(t),hs.addTo(r._movement,r._delta),l6(r),this.compute(t),this.emit()}wheelEnd(){this.state._active&&(this.state._active=!1,this.compute(),this.emit())}bind(t){t("wheel","",this.wheel.bind(this))}}const vQ=Oc;class wQ extends Id{constructor(...t){super(...t),Ps(this,"ingKey","hovering")}enter(t){this.config.mouseOnly&&t.pointerType!=="mouse"||(this.start(t),this.computeValues(Bu(t)),this.compute(t),this.emit())}leave(t){if(this.config.mouseOnly&&t.pointerType!=="mouse")return;const r=this.state;if(!r._active)return;r._active=!1;const n=Bu(t);r._movement=r._delta=hs.sub(n,r._values),this.computeValues(n),this.compute(t),r.delta=r.movement,this.emit()}bind(t){t("pointer","enter",this.enter.bind(this)),t("pointer","leave",this.leave.bind(this))}}const AQ=vs(vs({},Oc),{},{mouseOnly:(e=!0)=>e}),fg=new Map,f1=new Map;function c6(e){fg.set(e.key,e.engine),f1.set(e.key,e.resolver)}const u6={key:"drag",engine:XB,resolver:uQ},TQ={key:"hover",engine:wQ,resolver:AQ},CQ={key:"move",engine:mQ,resolver:gQ},SQ={key:"pinch",engine:fQ,resolver:pQ},_Q={key:"scroll",engine:xQ,resolver:bQ},kQ={key:"wheel",engine:yQ,resolver:vQ};function LQ(e,t){if(e==null)return{};var r={},n=Object.keys(e),a,c;for(c=0;c<n.length;c++)a=n[c],!(t.indexOf(a)>=0)&&(r[a]=e[a]);return r}function IQ(e,t){if(e==null)return{};var r=LQ(e,t),n,a;if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(a=0;a<c.length;a++)n=c[a],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}const EQ={target(e){if(e)return()=>"current"in e?e.current:e},enabled(e=!0){return e},window(e=oo.isBrowser?window:void 0){return e},eventOptions({passive:e=!0,capture:t=!1}={}){return{passive:e,capture:t}},transform(e){return e}},NQ=["target","eventOptions","window","enabled","transform"];function $h(e={},t){const r={};for(const[n,a]of Object.entries(t))switch(typeof a){case"function":r[n]=a.call(r,e[n],n,e);break;case"object":r[n]=$h(e[n],a);break;case"boolean":a&&(r[n]=e[n]);break}return r}function RQ(e,t,r={}){const n=e,{target:a,eventOptions:c,window:l,enabled:h,transform:p}=n,m=IQ(n,NQ);if(r.shared=$h({target:a,eventOptions:c,window:l,enabled:h,transform:p},EQ),t){const x=f1.get(t);r[t]=$h(vs({shared:r.shared},m),x)}else for(const x in m){const y=f1.get(x);y&&(r[x]=$h(vs({shared:r.shared},m[x]),y))}return r}class d6{constructor(t,r){Ps(this,"_listeners",new Set),this._ctrl=t,this._gestureKey=r}add(t,r,n,a,c){const l=this._listeners,h=FB(r,n),p=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},m=vs(vs({},p),c);t.addEventListener(h,a,m);const x=()=>{t.removeEventListener(h,a,m),l.delete(x)};return l.add(x),x}clean(){this._listeners.forEach(t=>t()),this._listeners.clear()}}class MQ{constructor(){Ps(this,"_timeouts",new Map)}add(t,r,n=140,...a){this.remove(t),this._timeouts.set(t,window.setTimeout(r,n,...a))}remove(t){const r=this._timeouts.get(t);r&&window.clearTimeout(r)}clean(){this._timeouts.forEach(t=>{window.clearTimeout(t)}),this._timeouts.clear()}}class jQ{constructor(t){Ps(this,"gestures",new Set),Ps(this,"_targetEventStore",new d6(this)),Ps(this,"gestureEventStores",{}),Ps(this,"gestureTimeoutStores",{}),Ps(this,"handlers",{}),Ps(this,"config",{}),Ps(this,"pointerIds",new Set),Ps(this,"touchIds",new Set),Ps(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),DQ(this,t)}setEventIds(t){if(Uf(t))return this.touchIds=new Set(zB(t)),this.touchIds;if("pointerId"in t)return t.type==="pointerup"||t.type==="pointercancel"?this.pointerIds.delete(t.pointerId):t.type==="pointerdown"&&this.pointerIds.add(t.pointerId),this.pointerIds}applyHandlers(t,r){this.handlers=t,this.nativeHandlers=r}applyConfig(t,r){this.config=RQ(t,r,this.config)}clean(){this._targetEventStore.clean();for(const t of this.gestures)this.gestureEventStores[t].clean(),this.gestureTimeoutStores[t].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...t){const r=this.config.shared,n={};let a;if(!(r.target&&(a=r.target(),!a))){if(r.enabled){for(const l of this.gestures){const h=this.config[l],p=O5(n,h.eventOptions,!!a);if(h.enabled){const m=fg.get(l);new m(this,t,l).bind(p)}}const c=O5(n,r.eventOptions,!!a);for(const l in this.nativeHandlers)c(l,"",h=>this.nativeHandlers[l](vs(vs({},this.state.shared),{},{event:h,args:t})),void 0,!0)}for(const c in n)n[c]=VB(...n[c]);if(!a)return n;for(const c in n){const{device:l,capture:h,passive:p}=OB(c);this._targetEventStore.add(a,l,"",n[c],{capture:h,passive:p})}}}}function lu(e,t){e.gestures.add(t),e.gestureEventStores[t]=new d6(e,t),e.gestureTimeoutStores[t]=new MQ}function DQ(e,t){t.drag&&lu(e,"drag"),t.wheel&&lu(e,"wheel"),t.scroll&&lu(e,"scroll"),t.move&&lu(e,"move"),t.pinch&&lu(e,"pinch"),t.hover&&lu(e,"hover")}const O5=(e,t,r)=>(n,a,c,l={},h=!1)=>{var p,m;const x=(p=l.capture)!==null&&p!==void 0?p:t.capture,y=(m=l.passive)!==null&&m!==void 0?m:t.passive;let w=h?n:QB(n,a,x);r&&y&&(w+="Passive"),e[w]=e[w]||[],e[w].push(c)},BQ=/^on(Drag|Wheel|Scroll|Move|Pinch|Hover)/;function QQ(e){const t={},r={},n=new Set;for(let a in e)BQ.test(a)?(n.add(RegExp.lastMatch),r[a]=e[a]):t[a]=e[a];return[r,t,n]}function cu(e,t,r,n,a,c){if(!e.has(r)||!fg.has(n))return;const l=r+"Start",h=r+"End",p=m=>{let x;return m.first&&l in t&&t[l](m),r in t&&(x=t[r](m)),m.last&&h in t&&t[h](m),x};a[n]=p,c[n]=c[n]||{}}function PQ(e,t){const[r,n,a]=QQ(e),c={};return cu(a,r,"onDrag","drag",c,t),cu(a,r,"onWheel","wheel",c,t),cu(a,r,"onScroll","scroll",c,t),cu(a,r,"onPinch","pinch",c,t),cu(a,r,"onMove","move",c,t),cu(a,r,"onHover","hover",c,t),{handlers:c,config:t,nativeHandlers:n}}function h6(e,t={},r,n){const a=_.useMemo(()=>new jQ(e),[]);if(a.applyHandlers(e,n),a.applyConfig(t,r),_.useEffect(a.effect.bind(a)),_.useEffect(()=>a.clean.bind(a),[]),t.target===void 0)return a.bind.bind(a)}function F5(e,t){return c6(u6),h6({drag:e},t||{},"drag")}function OQ(e){return e.forEach(c6),function(r,n){const{handlers:a,nativeHandlers:c,config:l}=PQ(r,n||{});return h6(a,l,void 0,c)}}function tU(e,t){return OQ([u6,SQ,_Q,kQ,CQ,TQ])(e,t||{})}const $5={dampingRatio:.8,response:.3},FQ=.998;function $Q(e,t,r,n){const a=2*Math.PI/Math.max(e.response,.001),c=t-n,l=r,h=e.dampingRatio;if(Math.abs(h-1)<1e-4){const v=c,k=l+a*c;return{value:L=>n+(v+k*L)*Math.exp(-a*L),velocity:L=>(k-a*(v+k*L))*Math.exp(-a*L)}}if(h<1){const v=a*Math.sqrt(1-h*h),k=c,L=(l+h*a*c)/v;return{value:E=>n+Math.exp(-h*a*E)*(k*Math.cos(v*E)+L*Math.sin(v*E)),velocity:E=>Math.exp(-h*a*E)*((L*v-h*a*k)*Math.cos(v*E)-(k*v+h*a*L)*Math.sin(v*E))}}const p=a*Math.sqrt(h*h-1),m=-h*a+p,x=-h*a-p,y=(l-x*c)/(m-x),w=c-y;return{value:v=>n+y*Math.exp(m*v)+w*Math.exp(x*v),velocity:v=>y*m*Math.exp(m*v)+w*x*Math.exp(x*v)}}function UQ(e,t=FQ){return e/1e3*(t/(1-t))}function U5(e,t,r=.55){return e*t*r/(t+r*Math.abs(e))}function zQ(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}const HQ=.1,WQ=5;function GQ(e,t,r,n,a){const c=$Q(e,t,r,n),l=1e3/60,h=240,p=[];for(let m=0;m<h;m++){const x=m*l/1e3,y=c.value(x),w=c.velocity(x);if(p.push(a?a(y):y),m>0&&Math.abs(y-n)<HQ&&Math.abs(w)<WQ)break}return p.push(a?a(n):n),{frames:p,durationMs:(p.length-1)*l,solver:c}}const VQ='input:not([type="hidden"]), textarea, select, [contenteditable]:not([contenteditable="false"])';function qQ(){if(typeof document>"u")return;const e=document.activeElement;e instanceof HTMLElement&&e.matches(VQ)&&e.blur()}const YQ=18,z5=8,H5={touch:z5,pen:z5},ZQ=500,om=200,W5=50,KQ=`[${V9}]`;function lm(e,t,r){return Math.min(r,Math.max(t,e))}function G5(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.pointerType=="string"?t.pointerType==="touch"||t.pointerType==="pen":typeof t.type=="string"&&t.type.startsWith("touch")}function V5(e){if(!e||typeof e!="object")return!1;const t=e.target;return t instanceof Element&&!!t.closest(KQ)}function C0(...e){typeof window<"u"&&window.__SIDEBAR_DEBUG__&&console.log("[Sidebar]",...e)}const f6=_.forwardRef(function({side:t,isOpen:r,drawerWidthPx:n,onClose:a,onOpen:c,children:l,pinned:h=!1},p){const{t:m}=zr(),x=t==="left",y=x?-n:n,w=b.useRef(null),v=b.useRef(null),k=b.useRef(r?0:y),L=b.useRef(null),E=b.useRef(null),R=b.useRef(0),B=b.useRef(null),W=b.useRef(null),F=b.useRef(!1),U=b.useRef(null),V=b.useRef(!1),Z=b.useRef([]),le=b.useRef(null),xe=b.useRef(k.current),fe=b.useRef(r?1:0),te=b.useRef(r);te.current=r;const ke=b.useRef(y);ke.current=y;const $e=b.useRef(n);$e.current=n;const Y=b.useRef(x);Y.current=x;const Ae=b.useRef(a);Ae.current=a;const lt=b.useRef(c);lt.current=c;const Ce=b.useCallback(ae=>{w.current=ae,typeof p=="function"?p(ae):p&&(p.current=ae)},[p]),ye=b.useCallback(()=>{E.current!==null&&(window.cancelAnimationFrame(E.current),E.current=null),L.current=null},[]),_e=b.useCallback(ae=>{const be=$e.current;return Y.current?(ae+be)/be:(be-ae)/be},[]),je=b.useCallback(ae=>{const be=v.current;be&&(be.style.opacity=String(lm(_e(ae),0,1)))},[_e]),re=b.useCallback(ae=>{k.current=ae;const be=w.current;be&&(be.style.transform=`translateX(${ae}px)`,je(ae))},[je]),Pe=b.useCallback(ae=>{L.current=ae,E.current===null&&(E.current=window.requestAnimationFrame(()=>{E.current=null;const be=L.current;L.current=null,be!==null&&re(be)}))},[re]),Se=b.useCallback(()=>{E.current!==null&&(window.cancelAnimationFrame(E.current),E.current=null);const ae=L.current;L.current=null,ae!==null&&re(ae)},[re]),Ee=b.useCallback(ae=>{const be=ke.current;return lm(ae,Math.min(0,be),Math.max(0,be))},[]),Be=b.useCallback(()=>{const ae=B.current;if(!ae)return null;B.current=null;const be=(performance.now()-ae.startTime)/1e3,Ze={value:ae.solver.value(be),velocity:ae.solver.velocity(be)};return ae.animations.forEach(Je=>Je.cancel()),Ze},[]),Ne=b.useCallback(()=>{W.current!==null&&(window.clearTimeout(W.current),W.current=null)},[]),oe=b.useCallback(()=>{le.current?.(),le.current=null},[]),He=b.useCallback(()=>{Se(),Ne();const ae=Be();ae&&re(Ee(ae.value));const be=w.current,Ze=v.current;be?.getAnimations().forEach(Je=>Je.cancel()),be&&(be.style.transition="none",be.style.opacity="1"),Ze?.getAnimations().forEach(Je=>Je.cancel()),Ze&&(Ze.style.transition="none")},[re,Ne,Ee,Se,Be]),rt=b.useCallback((ae,be)=>{Se(),Ne();const Ze=w.current,Je=v.current,Tt=ae?0:ke.current;Je&&(Je.style.pointerEvents=ae?"auto":"none");const Wt=Be(),Mt=Wt?Ee(Wt.value):k.current,vt=be?.velocity??Wt?.velocity??0;if(zQ())return k.current=Tt,Ze&&(Ze.style.transition=`opacity ${om}ms ease`,Ze.style.opacity=ae?"1":"0",Ze.style.transform=`translateX(${Tt}px)`),Je&&(Je.style.transition=`opacity ${om}ms ease`,Je.style.opacity=ae?"1":"0"),om;Ze&&(Ze.style.transition="none",Ze.style.opacity="1"),Je&&(Je.style.transition="none");const Yt=Math.abs(be?.velocity??0)>ZQ,{frames:Qt,durationMs:Xt,solver:Ut}=GQ({dampingRatio:Yt?$5.dampingRatio:1,response:$5.response},Mt,vt,Tt,Ee);if(!Ze||Math.abs(Mt-Tt)<.5&&Math.abs(vt)<5)return re(Tt),0;const Lt=Ze.animate(Qt.map(Ge=>({transform:`translateX(${Ge}px)`})),{duration:Xt,easing:"linear",fill:"forwards"}),pe=[Lt];return Je&&pe.push(Je.animate(Qt.map(Ge=>({opacity:String(lm(_e(Ge),0,1))})),{duration:Xt,easing:"linear",fill:"forwards"})),B.current={solver:Ut,startTime:performance.now(),target:Tt,animations:pe},C0("spring start",{startX:Mt,startVelocity:vt,targetX:Tt,frames:Qt.length,durationMs:Xt}),Lt.onfinish=()=>{const Ge=B.current;!Ge||!Ge.animations.includes(Lt)||(B.current=null,re(Tt),Ge.animations.forEach(ft=>ft.cancel()),C0("spring finish",{targetX:Tt}))},Xt},[re,Ne,Ee,Se,_e,Be]),mt=b.useCallback(ae=>{Se();const be=ae,Ze=0,Je=ke.current,Tt=k.current+UQ(be),Wt=Math.abs(Tt-Ze)<=Math.abs(Tt-Je);C0("decideSnap",{velocity:be,currentX:k.current,projected:Tt,shouldOpen:Wt});const Mt=rt(Wt,{velocity:be});return Wt&&!te.current?W.current=window.setTimeout(()=>{W.current=null,lt.current?.()},Mt+W5):!Wt&&te.current&&(W.current=window.setTimeout(()=>{W.current=null,Ae.current()},Mt+W5)),Wt},[rt,Se]),de=b.useCallback(ae=>{const be=ke.current,Ze=Math.min(0,be),Je=Math.max(0,be),Tt=$e.current;return ae<Ze?Ze-U5(Ze-ae,Tt):ae>Je?Je+U5(ae-Je,Tt):ae},[]),Ye=b.useCallback(ae=>{const be=Z.current,Ze=performance.now();be.push({t:Ze,x:ae});const Je=Ze-120;for(;be.length>0&&be[0].t<Je;)be.shift()},[]),st=b.useCallback(()=>{const ae=Z.current;if(ae.length<2)return 0;const be=ae[ae.length-1];if(performance.now()-be.t>60)return 0;const Ze=ae[0],Je=(be.t-Ze.t)/1e3;return Je<.016?0:(be.x-Ze.x)/Je},[]);b.useEffect(()=>{Ne();const ae=B.current,be=r?0:ke.current;ae&&ae.target===be||rt(r)},[r,rt,Ne]),b.useEffect(()=>{He(),Pe(te.current?0:y)},[y,He,Pe]),b.useEffect(()=>()=>{ye(),Ne(),Be(),oe()},[Ne,ye,oe,Be]);const Ie=F5(({active:ae,cancel:be,first:Ze,last:Je,movement:[Tt],event:Wt})=>{if(C0("bindPanel",{active:ae,first:Ze,last:Je,mx:Tt}),!G5(Wt)){be();return}if(Ze){if(oe(),F.current=!1,U.current=null,Z.current=[],V5(Wt)){be();return}const Mt=w.current,vt=Mt?q9(Wt.target,Mt):null;if(!vt||Y9()){be();return}const Yt=Z9(vt,Tt,Y.current?-1:1);if(C0("arbitrate",{owner:Yt.kind,mx:Tt}),Yt.kind==="swiper"){le.current=K9(Yt.instance),be();return}if(Yt.kind==="scroller"){const Qt=X9(Yt.element);if(Qt)U.current=Qt;else{be();return}}U.current||(F.current=!0,He(),R.current=k.current)}if(!ae){U.current=null,F.current&&(F.current=!1,mt(st()));return}if(U.current){J9(U.current,Tt);return}if(F.current){const Mt=de(R.current+Tt);Ye(Mt),Pe(Mt)}},{axis:"x",axisThreshold:H5,filterTaps:!0,pointer:{touch:!0}}),We=F5(({active:ae,cancel:be,first:Ze,movement:[Je],event:Tt})=>{if(!G5(Tt)){be();return}if(te.current){be();return}if(Ze&&(V.current=!0,Z.current=[],He(),R.current=k.current),!ae){V.current&&(V.current=!1,mt(st())&&qQ());return}if(V.current){const Wt=de(R.current+Je);Ye(Wt),Pe(Wt)}},{axis:"x",axisThreshold:H5,filterTaps:!0,pointer:{touch:!0}}),Te=b.useCallback(ae=>{ae.preventDefault(),ae.stopPropagation(),te.current||lt.current?.()},[]);if(h)return s.jsx("aside",{ref:Ce,"data-sidebar":t,"data-sidebar-pinned":"true",className:"relative flex h-full min-h-0 w-full flex-col app-chrome-bg",children:l});const H=Ie();return s.jsxs(s.Fragment,{children:[s.jsx("div",{...We(),style:{position:"fixed",top:"1.5rem",bottom:"10rem",...x?{left:0}:{right:0},width:YQ,zIndex:"var(--z-chrome-hint)",touchAction:"none",pointerEvents:r?"none":"auto"},onClick:Te,"aria-label":m(x?"sidebar.openLeftSidebar":"sidebar.openRightSidebar")}),s.jsx("div",{ref:v,"data-sidebar-backdrop":t,className:"fixed inset-0 z-sidebar-backdrop bg-[var(--app-backdrop)] cursor-default",style:{opacity:fe.current,pointerEvents:r?"auto":"none",transition:"none",willChange:"opacity"},onClick:a,"aria-label":m("sidebar.closeSidebar")}),s.jsx("aside",{...H,onClickCapture:ae=>{V5(ae)||H.onClickCapture?.(ae)},ref:Ce,"data-sidebar":t,className:`fixed inset-y-0 z-sidebar-panel flex flex-col chrome-glow-panel will-change-transform ${x?"border-r border-border":"border-l border-border/15"}`,style:{...x?{left:0}:{right:0},width:n,maxWidth:x?"94vw":"95vw",transform:`translateX(${xe.current}px)`,transition:"none",touchAction:"pan-y",pointerEvents:r?"auto":"none",paddingTop:"var(--safe-top-inset, env(safe-area-inset-top, 0px))",paddingBottom:"var(--safe-bottom-inset, env(safe-area-inset-bottom, 0px))",...x?{paddingLeft:"var(--safe-left-inset, env(safe-area-inset-left, 0px))"}:{paddingRight:"var(--safe-right-inset, env(safe-area-inset-right, 0px))"}},children:l})]})}),XQ={activeKey:"root",items:[]},JQ=()=>()=>{},eP=()=>XQ;function tP(e){const t=ol(),r=b.useSyncExternalStore(t?.subscribe??JQ,t?.snapshot??eP),n=fw(),a=r.items.map(c=>c.key===n?{...c,reviewCount:e}:c).filter(c=>c.reviewCount>0);return{host:t,groups:a,currentKey:n,active:!t||r.activeKey===n,total:t?e+a.reduce((c,l)=>c+(l.key===n?0:l.reviewCount),0):e,hasOtherAttention:a.some(c=>c.key!==n)}}function rP({groups:e,currentKey:t,onClose:r}){const{t:n}=zr(),a=b.useId(),c=b.useRef(null),l=b.useRef(null),h=b.useRef(r);h.current=r;const p=b.useRef(!0),[m,x]=b.useState(""),y=e.reduce((k,L)=>k+L.reviewCount,0);b.useEffect(()=>{const k=document.activeElement;l.current?.focus({preventScroll:!0});const L=E=>{if(E.key==="Escape"&&(E.preventDefault(),E.stopImmediatePropagation(),h.current()),E.key!=="Tab")return;const R=Array.from(c.current?.querySelectorAll("button:not(:disabled)")??[]),B=R[0],W=R[R.length-1],F=!c.current?.contains(document.activeElement);E.shiftKey&&(document.activeElement===B||F)?(E.preventDefault(),W?.focus()):!E.shiftKey&&(document.activeElement===W||F)&&(E.preventDefault(),B?.focus())};return document.addEventListener("keydown",L,!0),()=>{document.removeEventListener("keydown",L,!0),p.current&&k?.isConnected&&!k.closest("[inert]")&&k.focus({preventScroll:!0})}},[]);const w=(k,L)=>{const E=ol(),R=E?.snapshot().items.find(W=>W.key===k.key);if(!R?.reviewCount||L&&!R.attentionSessions?.some(W=>W.id===L)){x(n("serviceAttention.changed"));return}p.current=!1;let B=!1;L&&k.key===t?(window.dispatchEvent(new CustomEvent("termdock:focus-session",{detail:L})),B=!0):L&&R.service?.targetPeerId?B=E?.focusSession(R.service.targetPeerId,L)??!1:R.service&&(B=E?.activate(R.service,!0)??!1),B?r():(p.current=!0,x(n("serviceAttention.unavailable")))},v=k=>k.phase==="offline"?n("serviceAttention.offline"):k.phase==="login"?n("serviceAttention.login"):k.phase==="connecting"||k.phase==="reconnecting"?n("connection.reconnecting"):null;return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button","aria-label":n("common.close"),tabIndex:-1,className:"fixed inset-0 z-modal-backdrop cursor-default bg-[var(--app-backdrop)]",onClick:r}),s.jsx("div",{className:"pointer-events-none fixed inset-0 z-modal-panel flex items-end justify-center p-3 sm:items-center sm:p-6",style:{paddingTop:"max(12px, var(--safe-top-inset, env(safe-area-inset-top, 0px)))",paddingBottom:"max(12px, var(--safe-bottom-inset, env(safe-area-inset-bottom, 0px)))"},children:s.jsxs("section",{ref:c,role:"dialog","aria-modal":"true","aria-labelledby":a,"data-sidebar-gesture-ignore":!0,onKeyDown:k=>k.stopPropagation(),className:"pointer-events-auto flex max-h-full w-full max-w-md flex-col overflow-hidden rounded-2xl border border-border bg-surface text-foreground shadow-xl",children:[s.jsxs("header",{className:"flex shrink-0 items-center gap-3 border-b border-border px-4 py-3",children:[s.jsx(Jl,{size:20,className:"shrink-0 text-[color:var(--warning)]","aria-hidden":"true"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{id:a,className:"text-sm font-semibold",children:n("serviceAttention.title")}),s.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:n("serviceAttention.summary",{services:e.length,count:y})})]}),s.jsx("button",{ref:l,type:"button","aria-label":n("common.close"),onClick:r,className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl text-muted-foreground hover:bg-surface-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:s.jsx(Qn,{size:18})})]}),s.jsxs("div",{className:"min-h-0 overflow-y-auto overscroll-contain p-2",children:[e.length===0&&s.jsx("p",{role:"status",className:"px-4 py-8 text-center text-sm text-muted-foreground",children:n("serviceAttention.empty")}),e.map(k=>s.jsxs("section",{className:"mb-2 last:mb-0",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-3 pb-1 pt-2 text-xs",children:[s.jsx("h3",{className:"min-w-0 flex-1 truncate font-medium",title:k.service?.label,children:k.service?.label||n("serviceAttention.currentService")}),k.key===t&&s.jsx("span",{className:"shrink-0 text-muted-foreground",children:n("agent.currentSession")}),s.jsx("span",{className:"shrink-0 tabular-nums text-[color:var(--warning)]",children:k.reviewCount})]}),v(k)&&s.jsx("p",{className:"px-3 pb-1 text-xs text-[color:var(--warning)]",children:v(k)}),k.attentionSessions?.length?k.attentionSessions.map(L=>s.jsxs("button",{type:"button",onClick:()=>w(k,L.id),className:"flex min-h-14 w-full items-center gap-3 rounded-xl px-3 py-2 text-left hover:bg-surface-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"line-clamp-2 break-words text-sm",title:L.label,children:L.label}),s.jsx("span",{className:"mt-0.5 block text-xs text-muted-foreground",children:L.waiting?n("serviceAttention.waiting"):n("agent.needsReview")})]}),s.jsx(hi,{size:16,className:"shrink-0 text-muted-foreground","aria-hidden":"true"})]},L.id)):s.jsx("button",{type:"button",onClick:()=>w(k),className:"min-h-11 w-full rounded-xl px-3 py-2 text-left text-sm hover:bg-surface-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary",children:n("serviceAttention.viewService")})]},k.key))]}),s.jsxs("footer",{className:"shrink-0 border-t border-border px-4 py-3 text-xs text-muted-foreground",children:[m&&s.jsx("p",{role:"alert",className:"mb-1 text-[color:var(--warning)]",children:m}),n("serviceAttention.scope")]})]})})]})}function nP(e){const t=e.icon&&e.isPlugin?`/api/terminal/agent-plugin-icon/${encodeURIComponent(e.slug)}${e.iconVersion?`?v=${Math.floor(e.iconVersion)}`:""}`:void 0,[r,n]=b.useState();if(b.useEffect(()=>{if(n(void 0),!t)return;const a=new AbortController;let c;return fetch(t,{signal:a.signal}).then(async l=>{if(!l.ok)throw new Error(`Icon request failed: ${l.status}`);const h=await l.blob();a.signal.aborted||(c=URL.createObjectURL(h),n({endpoint:t,src:c}))}).catch(()=>{}),()=>{a.abort(),c&&URL.revokeObjectURL(c)}},[t]),!!e.icon)return e.isPlugin?r?.endpoint===t?r?.src:void 0:`/icons/agents/${e.icon}.svg`}function sP(e){return e.agentStatus==="waiting"||e.agentNeedsReview===!0}function iP(e,t,r,n="next"){if(e.length===0)return null;const a=t?e.findIndex(c=>c.sessionId===t):-1;for(let c=1;c<=e.length;c+=1){const l=n==="next"?c:-c,h=(a+l+e.length)%e.length,p=e[h];if(p&&r(p))return p.sessionId}return null}function aP(e,t,r="next"){return iP(e,t,sP,r)}const Ma=42,wf=20,oP=10;function p1(e,t,r){return Math.min(r,Math.max(t,e))}function zf(e){const t=Math.max(0,e.safeTop??0),r=Math.max(0,e.safeRight??0),n=Math.max(0,e.safeBottom??0),a=Math.max(0,e.safeLeft??0),c=Math.max(0,e.bottomClearance??72),l=a+wf,h=Math.max(l,e.width-r-wf-Ma),p=Math.max(t+12,52),m=Math.max(p,e.height-n-c-Ma);return{minX:l,maxX:h,minY:p,maxY:m}}function q5(e,t){const r=zf(e),n=p1(t.yRatio,0,1);return{x:t.side==="left"?r.minX:r.maxX,y:r.minY+(r.maxY-r.minY)*n}}function Rc(e,t){const r=zf(e);return{x:p1(t.x,r.minX,r.maxX),y:p1(t.y,r.minY,r.maxY)}}function Y5(e,t){const r=zf(e),n=Rc(e,t),a=(r.minX+r.maxX+Ma)/2,c=n.x+Ma/2<a?"left":"right",l=r.maxY-r.minY;return{position:{x:c==="left"?r.minX:r.maxX,y:n.y},preference:{side:c,yRatio:l>0?(n.y-r.minY)/l:0}}}function Z5(e,t,r){const n=Rc(e,t),a=Ma+oP,c=m=>Math.abs(m.x-r.x)<a&&Math.abs(m.y-r.y)<a;if(!c(n))return n;const l=[{...n,y:r.y-a},{...n,y:r.y+a}].map(m=>Rc(e,m)).filter(m=>!c(m)).sort((m,x)=>Math.abs(m.y-n.y)-Math.abs(x.y-n.y));if(l[0])return l[0];const h=zf(e);return[{...n,x:h.minX},{...n,x:h.maxX}].map(m=>Rc(e,m)).filter(m=>!c(m)).sort((m,x)=>Math.abs(m.x-n.x)-Math.abs(x.x-n.x))[0]??n}const cm="var(--warning)",lP="var(--success)",K5="var(--tmux)",X5="termdock:mobile-attention-position:v1",J5="termdock:running-session-position:v1",cP={side:"right",yRatio:.68},uP={side:"right",yRatio:.54};function eb(e,t){if(typeof window>"u")return t;try{const r=JSON.parse(window.localStorage.getItem(e)??"null");if(r&&(r.side==="left"||r.side==="right")&&typeof r.yRatio=="number"&&Number.isFinite(r.yRatio))return{side:r.side,yRatio:Math.min(1,Math.max(0,r.yRatio))}}catch{}return t}function dP(e,t){try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}function mh(e){if(typeof document>"u")return 0;const t=Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue(e));return Number.isFinite(t)?Math.max(0,t):0}function hP(e,t,r={}){if(typeof window>"u")return{width:390,height:664};const n=window.visualViewport,a=n?.width??window.innerWidth,c=n?.height??window.innerHeight,l=t?.getBoundingClientRect(),h=!!(l&&l.width>0&&l.height>0);return{width:a,height:c,safeTop:Math.max(mh("--safe-top-inset"),(h?Math.max(0,l.top):0)+Math.max(0,r.top??0)),safeRight:Math.max(mh("--safe-right-inset"),(h?Math.max(0,a-l.right):0)+Math.max(0,r.right??0)),safeBottom:Math.max(mh("--safe-bottom-inset"),(h?Math.max(0,c-l.bottom):0)+Math.max(0,r.bottom??0)),safeLeft:Math.max(mh("--safe-left-inset"),(h?Math.max(0,l.left):0)+Math.max(0,r.left??0)),bottomClearance:e?wf:72}}function p6(){const e=Yr.getState(),t=Array.from(e.sessions.values()),r=aP(t,e.activeSessionId);if(!r)return;const n=e.activeSessionId?e.sessions.get(e.activeSessionId):void 0;n?.agentNeedsReview&&e.clearAgentNeedsReview(n.sessionId),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:r}))}function tb(e){window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:e}))}function m6(e){switch(e){case"success":return"var(--success)";case"warning":return"var(--warning)";case"danger":return"var(--destructive)";case"info":case"accent":return"var(--accent)";default:return"var(--muted-foreground)"}}function fP({indicator:e,tone:t,size:r}){const n=m6(t);switch(e){case"spinner":return s.jsx(In,{size:r,className:"shrink-0 animate-spin",style:{color:n}});case"question":return s.jsx(Yh,{size:r,className:"shrink-0 animate-bounce-y",style:{color:n}});case"badge":return s.jsx(Jl,{size:r+1,className:"shrink-0 animate-pulse",style:{color:n}});case"terminal":return s.jsx(Bo,{size:r,className:"shrink-0",style:{color:n}});case"pulse":return s.jsx(SA,{size:r,className:"shrink-0 animate-pulse",style:{color:n}});case"ring":return s.jsx("span",{className:"block shrink-0 rounded-full border-2",style:{width:r,height:r,borderColor:n}});case"dot":return s.jsx("span",{className:"block shrink-0 rounded-full",style:{width:Math.max(5,r-4),height:Math.max(5,r-4),backgroundColor:n}})}}function Mc({agent:e,size:t=12}){const r=t-4,n=nP(e);return n?e.iconMode==="native"?s.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-[3px]",style:{width:t,height:t},title:e.displayName,children:s.jsx("img",{src:n,alt:e.displayName,style:{width:r,height:r}})}):s.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-[3px]",style:{width:t,height:t,backgroundColor:e.accentColor},title:e.displayName,children:s.jsx("span",{className:"block bg-white",style:{width:r,height:r,WebkitMask:`url(${n}) center / contain no-repeat`,mask:`url(${n}) center / contain no-repeat`}})}):s.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-[3px]",style:{width:t,height:t,backgroundColor:e.accentColor},title:e.displayName,children:s.jsx(Ad,{size:r,className:"text-white"})})}function pP({sessionMode:e,state:t,size:r=11}){const n=t?.agent?s.jsx(Mc,{agent:t.agent,size:r+1}):e==="tmux"?s.jsx(Nu,{size:r,className:"shrink-0"}):s.jsx(Bo,{size:r,className:"shrink-0"});return t?.agentStatusDetail&&t.agentIndicator&&!(t.agentStatus==="done"&&t.agentNeedsReview)?s.jsx("span",{title:t.agentMessage??t.agentStatusDetail.label,"aria-label":t.agentStatusDetail.label,children:s.jsx(fP,{indicator:t.agentIndicator,tone:t.agentStatusDetail.tone,size:r})}):t?.agentStatus==="working"?s.jsx("span",{title:t.agentMessage??t.agent?.displayName,children:s.jsx(In,{size:r,className:"shrink-0 animate-spin",style:{color:lP}})}):t?.agentStatus==="waiting"?s.jsx("span",{title:t.agentMessage??void 0,children:s.jsx(Yh,{size:r,className:"shrink-0 animate-bounce-y",style:{color:cm}})}):t?.agentStatus==="done"&&t.agentNeedsReview?s.jsx("span",{title:t.agentMessage??void 0,children:s.jsx(Jl,{size:r+1,className:"shrink-0 animate-pulse",style:{color:cm}})}):t?.agentNeedsReview?s.jsx("span",{title:t.agentMessage??void 0,children:s.jsx(Jl,{size:r+1,className:"shrink-0 animate-pulse",style:{color:cm}})}):t?.inCopyMode?e==="tmux"?s.jsx(Nu,{size:r,className:"shrink-0 animate-pulse",style:{color:K5}}):s.jsx(Bo,{size:r,className:"shrink-0 animate-pulse",style:{color:K5}}):n}function mP({status:e,detail:t,needsReview:r,inCopyMode:n}){const{t:a}=zr();return t&&!r?s.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-full ring-2 ring-surface animate-pulse",style:{backgroundColor:m6(t.tone)},title:t.label}):e==="working"?s.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-full bg-[var(--success)] ring-2 ring-surface shadow-[0_0_6px_rgb(var(--success-rgb)_/_0.50)] animate-pulse",title:a("agent.aiRunning")}):e==="waiting"||r?s.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-full bg-[var(--warning)] ring-2 ring-surface shadow-[0_0_0_1px_rgb(var(--warning-rgb)_/_0.24)] animate-pulse",title:a(r?"agent.finishedReview":"agent.aiWaiting")}):e==="done"&&r?s.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-full bg-[var(--warning)] ring-2 ring-surface shadow-[0_0_0_1px_rgb(var(--warning-rgb)_/_0.24)] animate-pulse",title:a("agent.finishedReview")}):n?s.jsx("span",{className:"absolute right-0.5 top-0.5 h-2.5 w-2.5 rounded-[2px] bg-[var(--tmux)] ring-2 ring-surface",title:a("agent.copyMode")}):null}function g6({count:e,tone:t,title:r}){const{t:n}=zr();if(e<=0)return null;const a=t==="running"?"inline-flex items-center gap-1 rounded-full bg-[rgb(var(--success-rgb)_/_0.12)] px-1.5 py-0.5 text-[10px] font-medium text-[color:var(--success)]":"inline-flex min-h-6 items-center gap-1 rounded-full bg-[rgb(var(--warning-rgb)_/_0.14)] px-2 py-0.5 text-[10px] font-semibold text-[color:var(--warning)] ring-1 ring-[rgb(var(--warning-rgb)_/_0.24)] transition hover:bg-[rgb(var(--warning-rgb)_/_0.22)] active:scale-[0.97]",c=t==="running"?"h-1.5 w-1.5 rounded-full bg-[var(--success)] animate-pulse":"h-1.5 w-1.5 rounded-full bg-[var(--warning)] animate-pulse";if(t==="review"){const l=r??n("agent.jumpToNext");return s.jsxs("button",{type:"button",className:a,title:`${l} · ${n("agent.jumpToNext")}`,"aria-label":`${l}: ${e}. ${n("agent.jumpToNext")}`,onClick:p6,children:[s.jsx(Jl,{size:11,className:"shrink-0"}),s.jsx("span",{children:n("agent.needsReview")}),s.jsx("span",{className:"tabular-nums",children:e})]})}return s.jsxs("span",{className:a,title:r,children:[s.jsx("span",{className:c}),e]})}function gP({runningCount:e,reviewCount:t,className:r=""}){const n=[];return e>0&&n.push({key:"running",count:e,className:"bg-[var(--success)] text-[color:var(--success-foreground)]"}),t>0&&n.push({key:"review",count:t,className:"bg-[var(--warning)] text-[color:var(--warning-foreground)]"}),n.length===0?null:s.jsx("span",{"aria-hidden":"true",className:`pointer-events-none absolute -right-1 ${n.length>1?"top-0.5 flex flex-col gap-0.5":"-top-1"} ${r}`,children:n.map(a=>s.jsx("span",{className:`flex h-3 min-w-3 items-center justify-center rounded-full px-0.5 text-[7px] font-bold leading-3 shadow-sm ring-1 ring-background ${a.className}`,children:a.count>9?"9+":a.count},a.key))})}const xP=380,rb=10,gh=10,um=52,bP=104;function yP(e,t,r){const n=Math.max(0,t.safeLeft??0),a=t.width-Math.max(0,t.safeRight??0),c=Math.max(0,t.safeTop??0),l=t.height-Math.max(0,t.safeBottom??0),h=wf,p=e.x+Ma/2>=n+(a-n)/2,m=p?e.x-gh-n-h:a-h-e.x-Ma-gh,x=Math.max(1,Math.min(Math.max(0,m),Math.max(168,r*bP))),y=p?e.x-gh-x:e.x+Ma+gh,w=Math.min(Math.max(y,n+h),Math.max(n+h,a-h-x)),v=e.y+Ma/2-um/2,k=Math.min(Math.max(v,c+h),Math.max(c+h,l-h-um));return{left:w,top:k,width:x,height:um,itemWidth:x/Math.max(1,r),side:p?"left":"right"}}function nb(e,t,r,n){return t<e.left||t>e.left+e.width||r<e.top-14||r>e.top+e.height+14?null:Math.min(n-1,Math.max(0,Math.floor((t-e.left)/e.itemWidth)))}function vP(e,t){if(e.length===0)return null;const r=t?e.findIndex(n=>n.id===t):-1;return e[(r+1)%e.length]?.id??null}function wP({reviewCount:e,runningSessions:t,activeSessionId:r,runningButtonEnabled:n,attentionButtonEnabled:a=!0,isDesktopLayout:c,containerElement:l,occlusionInsets:h}){const{t:p}=zr(),m=Gt(Ie=>Ie.leftOpen),x=Gt(Ie=>Ie.rightOpen),{isOpen:y}=My({enabled:!c}),w=c||!m&&!x&&!y,v=tP(e),[k,L]=_.useState(!1);_.useEffect(()=>{(!v.active||!w)&&L(!1)},[v.active,w]);const E=a&&v.total>0&&w,R=t.length>1||t.length===1&&t[0]?.id!==r,B=n&&t.length>0&&R&&w,W=Math.max(0,h?.top??0),F=Math.max(0,h?.right??0),U=Math.max(0,h?.bottom??0),V=Math.max(0,h?.left??0),Z=_.useCallback(()=>hP(c,l,{top:W,right:F,bottom:U,left:V}),[l,c,U,V,F,W]),le=_.useRef({attention:eb(X5,cP),running:eb(J5,uP)}),xe=_.useCallback(()=>{const Ie=Z(),We=q5(Ie,le.current.attention),Te=q5(Ie,le.current.running);return{attention:We,running:E&&B?Z5(Ie,Te,We):Te}},[E,Z,B]),[fe,te]=_.useState(()=>xe()),ke=_.useRef(fe);ke.current=fe;const[$e,Y]=_.useState(null),Ae=_.useRef(null),[lt,Ce]=_.useState("idle"),[ye,_e]=_.useState(null),je=_.useRef(null),re=_.useRef({attention:!1,running:!1});_.useEffect(()=>()=>{const Ie=je.current?.longPressTimer;Ie!=null&&window.clearTimeout(Ie)},[]),_.useEffect(()=>{if(B)return;const Ie=je.current?.longPressTimer;Ie!=null&&window.clearTimeout(Ie),je.current=null,Ce("idle"),_e(null)},[B]),_.useLayoutEffect(()=>{const Ie=()=>{const Te=xe();ke.current=Te,te(Te)};Ie(),window.addEventListener("resize",Ie),window.addEventListener("orientationchange",Ie),window.visualViewport?.addEventListener("resize",Ie);const We=typeof ResizeObserver>"u"?null:new ResizeObserver(Ie);return l&&We?.observe(l),()=>{window.removeEventListener("resize",Ie),window.removeEventListener("orientationchange",Ie),window.visualViewport?.removeEventListener("resize",Ie),We?.disconnect()}},[l,xe]);const Pe=_.useCallback(Ie=>Ie==="attention"?B:E,[E,B]),Se=_.useCallback((Ie,We)=>{if(!Pe(Ie))return We;const Te=Ie==="attention"?"running":"attention";return Z5(Z(),We,ke.current[Te])},[Z,Pe]),Ee=_.useCallback((Ie,We,Te,H)=>{const ae=Z(),be=We.moved?Rc(ae,{x:We.startX+(Te-We.originX),y:We.startY+(H-We.originY)}):ke.current[Ie],Ze=Y5(ae,be),Je=Se(Ie,Ze.position),Tt=Y5(ae,Je);le.current[Ie]=Tt.preference,dP(Ie==="attention"?X5:J5,Tt.preference);const Wt={...ke.current,[Ie]:Tt.position};ke.current=Wt,te(Wt)},[Se,Z]),Be=_.useCallback(Ie=>{re.current[Ie]=!0,window.setTimeout(()=>{re.current[Ie]=!1},0)},[]),Ne=_.useCallback(Ie=>{const We=Ae.current;!We||We.kind!=="attention"||We.pointerId!==Ie.pointerId||(Ae.current=null,Y(null),Ee("attention",We,Ie.clientX,Ie.clientY),We.moved&&Be("attention"))},[Ee,Be]),oe={onPointerDown:Ie=>{Ie.stopPropagation(),Ie.currentTarget.setPointerCapture(Ie.pointerId),Ae.current={kind:"attention",pointerId:Ie.pointerId,originX:Ie.clientX,originY:Ie.clientY,startX:fe.attention.x,startY:fe.attention.y,moved:!1}},onPointerMove:Ie=>{const We=Ae.current;if(!We||We.kind!=="attention"||We.pointerId!==Ie.pointerId)return;const Te=Ie.clientX-We.originX,H=Ie.clientY-We.originY;if(!We.moved&&Math.hypot(Te,H)<5)return;We.moved=!0,Y("attention");const ae=Z(),be=Se("attention",Rc(ae,{x:We.startX+Te,y:We.startY+H})),Ze={...ke.current,attention:be};ke.current=Ze,te(Ze)},onPointerUp:Ne,onPointerCancel:Ne},He=l?yP(fe.running,Z(),t.length):null,rt=Ie=>{Ie.longPressTimer!==null&&(window.clearTimeout(Ie.longPressTimer),Ie.longPressTimer=null)},mt={onPointerDown:Ie=>{Ie.stopPropagation(),Ie.currentTarget.setPointerCapture(Ie.pointerId);const We=Ie.pointerId,Te={pointerId:We,originX:Ie.clientX,originY:Ie.clientY,startX:fe.running.x,startY:fe.running.y,mode:"pressing",moved:!1,selectedIndex:null,longPressTimer:null};Te.longPressTimer=window.setTimeout(()=>{const H=je.current;!H||H.pointerId!==We||H.mode!=="pressing"||(H.longPressTimer=null,H.mode="dragging",re.current.running=!0,Ce("dragging"))},xP),je.current=Te,Ce("pressing"),_e(null)},onPointerMove:Ie=>{const We=je.current;if(!We||We.pointerId!==Ie.pointerId)return;const Te=Ie.clientX-We.originX,H=Ie.clientY-We.originY;if(We.mode==="pressing")if(Math.abs(Te)>=rb&&Math.abs(Te)>=Math.abs(H))rt(We),We.mode="selecting",re.current.running=!0,Ce("selecting");else if(Math.hypot(Te,H)>=rb){rt(We),We.mode="cancelled",re.current.running=!0,Ce("idle");return}else return;if(We.mode==="selecting"){const Je=He?nb(He,Ie.clientX,Ie.clientY,t.length):null;We.selectedIndex=Je,_e(Je);return}if(We.mode!=="dragging"||!We.moved&&Math.hypot(Te,H)<5)return;We.moved=!0;const ae=Z(),be=Se("running",Rc(ae,{x:We.startX+Te,y:We.startY+H})),Ze={...ke.current,running:be};ke.current=Ze,te(Ze)},onPointerUp:Ie=>{const We=je.current;if(!We||We.pointerId!==Ie.pointerId)return;rt(We);const Te=We.mode;if(Te==="selecting"){const H=He?nb(He,Ie.clientX,Ie.clientY,t.length):We.selectedIndex,ae=H===null?null:t[H]?.id;ae&&tb(ae)}else Te==="dragging"&&Ee("running",We,Ie.clientX,Ie.clientY);je.current=null,Ce("idle"),_e(null),Te!=="pressing"&&Be("running")},onPointerCancel:Ie=>{const We=je.current;!We||We.pointerId!==Ie.pointerId||(rt(We),je.current=null,Ce("idle"),_e(null),Be("running"))}},de=(Ie,We)=>s.jsx("span",{className:`pointer-events-none absolute -right-1 -top-1 z-10 flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-surface px-1 text-[9px] font-bold tabular-nums ring-2 ring-[var(--chrome-bg)] ${We==="attention"?"text-[color:var(--warning)]":"text-[color:var(--success)]"}`,children:Ie>9?"9+":Ie}),Ye=()=>{const Ie=v.hasOtherAttention?p("serviceAttention.title"):p("agent.jumpToNext"),We=fe.attention,Te=$e==="attention";return s.jsxs("button",{type:"button","data-attention-button":!0,"data-mobile-attention-button":!0,...oe,onClick:H=>{H.stopPropagation(),!re.current.attention&&(v.hasOtherAttention?L(!0):p6())},className:`fixed z-chrome-hint inline-flex items-center justify-center rounded-full bg-[var(--warning)] text-[color:var(--warning-foreground)] shadow-[0_8px_24px_var(--app-shadow-strong)] ring-1 ring-[rgb(var(--warning-rgb)_/_0.35)] animate-fade-in ${Te?"cursor-grabbing scale-[1.04] shadow-[0_12px_30px_var(--app-shadow-strong)]":"cursor-grab transition-[left,top,transform,box-shadow] duration-200 active:scale-95"}`,style:{display:k?"none":void 0,left:We.x,top:We.y,width:Ma,height:Ma,touchAction:"none"},"aria-label":`${Ie}: ${v.total}`,"aria-haspopup":v.hasOtherAttention?"dialog":void 0,title:Ie,children:[s.jsx(Jl,{size:17,className:"shrink-0"}),de(v.total,"attention")]},"attention")},st=()=>{const Ie=t.length,We=fe.running,Te=lt==="selecting",H=lt==="dragging";return s.jsxs(_.Fragment,{children:[s.jsxs("button",{type:"button","data-running-session-button":!0,"data-running-session-gesture":lt,...mt,onClick:ae=>{if(ae.stopPropagation(),re.current.running)return;const be=vP(t,r);be&&tb(be)},className:`fixed z-chrome-hint inline-flex select-none items-center justify-center rounded-full bg-[var(--success)] text-[color:var(--success-foreground)] shadow-[0_8px_24px_var(--app-shadow-strong)] ring-1 ring-[rgb(var(--success-rgb)_/_0.35)] animate-fade-in ${H?"cursor-grabbing scale-[1.04] shadow-[0_12px_30px_var(--app-shadow-strong)]":Te?"cursor-ew-resize scale-[1.04] ring-2 ring-[rgb(var(--success-rgb)_/_0.55)]":"cursor-grab transition-[left,top,transform,box-shadow] duration-200 active:scale-95"}`,style:{left:We.x,top:We.y,width:Ma,height:Ma,touchAction:"none"},"aria-label":`${p("agent.jumpToNextRunning")}: ${Ie}`,title:p("agent.runningSessionGestureHint"),children:[s.jsx(In,{size:18,className:"shrink-0 animate-spin"}),de(Ie,"running")]}),Te&&He&&s.jsx("div",{role:"listbox","data-running-session-rail":!0,"data-side":He.side,"aria-label":p("agent.selectRunningSession"),className:"pointer-events-none fixed z-popover flex overflow-hidden rounded-full border border-border/15 bg-surface/95 p-1 shadow-[0_18px_48px_var(--app-shadow-soft)] backdrop-blur animate-fade-in",style:{left:He.left,top:He.top,width:He.width,height:He.height},children:t.map((ae,be)=>{const Ze=be===ye,Je=ae.id===r,Tt=`${ae.label}${ae.detail?` · ${ae.detail}`:""}${Je?` · ${p("agent.currentSession")}`:""}`;return s.jsxs("div",{role:"option","aria-selected":Ze,"data-running-session-option":ae.id,"data-selected":Ze?"true":"false",title:Tt,className:`relative flex min-w-0 flex-1 items-center justify-center gap-1.5 rounded-full px-2 transition-[background-color,color,transform] duration-100 ${Ze?"scale-[1.02] bg-[var(--success)] text-[color:var(--success-foreground)]":Je?"bg-primary/15 text-primary ring-1 ring-primary/30":"text-foreground"}`,children:[s.jsx("span",{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-[9px] font-bold tabular-nums ${Ze?"bg-surface/25":"bg-surface-2 text-muted-foreground"}`,children:be+1}),s.jsx("span",{className:"truncate text-[10px] font-medium",children:ae.label})]},ae.id)})})]},"running")};return!E&&!B&&!k||l===null||typeof document>"u"?null:s.jsxs(pw,{children:[E&&Ye(),B&&!k&&st(),k&&v.active&&w&&s.jsx(rP,{groups:v.groups,currentKey:v.currentKey,onClose:()=>L(!1)})]})}function AP(){const{t:e}=zr();return s.jsxs("div",{role:"status",className:"td-loading-skeleton overflow-hidden px-3 py-2",children:[s.jsx("span",{className:"sr-only",children:e("common.loading")}),s.jsx("div",{"aria-hidden":"true",children:["w-2/5","w-3/5","w-1/3","w-1/2","w-2/5","w-1/3"].map((t,r)=>s.jsxs("div",{className:"flex h-8 items-center gap-2",style:{paddingLeft:r>1&&r<5?20:0},children:[s.jsx("div",{className:"h-3 w-3 shrink-0 rounded-sm bg-surface-2"}),s.jsx("div",{className:`h-2 rounded bg-surface-2 ${t}`})]},r))})]})}const TP=new Set([".ts",".tsx",".js",".jsx",".py",".rs",".go",".java",".c",".cpp",".h",".rb",".php",".swift",".kt",".sh",".css",".scss",".html",".json",".yaml",".yml",".toml",".md"]),sb=120,ib=120,CP=new Set,SP=[],_P={added:{label:"A",className:"text-[color:var(--diff-insert-strong)]",title:"Added"},modified:{label:"M",className:"text-[color:var(--diff-hunk-accent)]",title:"Modified"},deleted:{label:"D",className:"text-[color:var(--diff-delete-strong)]",title:"Deleted"},renamed:{label:"R",className:"text-muted-foreground",title:"Renamed"},copied:{label:"C",className:"text-[color:var(--diff-insert-strong)]",title:"Copied"},untracked:{label:"U",className:"text-[color:var(--diff-insert-strong)]",title:"Untracked (new file)"},conflicted:{label:"!",className:"text-destructive",title:"Conflicted"},unknown:{label:"?",className:"text-muted-foreground",title:"Unknown"}};function pg(e,t){if(t==="directory")return null;if(xw(e))return s.jsx(mA,{size:14});if(bw(e))return s.jsx(k3,{size:14});const r=e.lastIndexOf(".")>=0?e.slice(e.lastIndexOf(".")):"";return TP.has(r)?s.jsx(UA,{size:14}):s.jsx(y3,{size:14})}function x6({path:e}){const r=Gt(a=>a.changedFiles.get(e))?.status;if(!r)return null;const n=_P[r]??{label:"?",className:"text-muted-foreground",title:r};return s.jsx("span",{className:`w-4 shrink-0 text-center text-[10px] font-mono font-bold ${n.className}`,title:n.title,children:n.label})}function Qu(e){return e?"ml-1 w-6 opacity-100":"ml-1 w-6 opacity-100 sm:ml-0 sm:w-0 sm:overflow-hidden sm:opacity-0 sm:group-hover:ml-1 sm:group-hover:w-6 sm:group-hover:opacity-100 sm:group-focus-within:ml-1 sm:group-focus-within:w-6 sm:group-focus-within:overflow-visible sm:group-focus-within:opacity-100"}function mg(e){return Qu(e)}const kP=b.memo(function({path:t}){const{t:r}=zr(),[n,a]=b.useState("idle"),[c,l]=b.useState(null),h=b.useCallback(async p=>{if(p.stopPropagation(),n!=="pending"){a("pending"),l(null);try{await l3(t),a("idle")}catch(m){a("error"),l(m instanceof Error?m.message:r("rightSidebar.downloadFailed"))}}},[t,n,r]);return s.jsx("button",{type:"button",disabled:n==="pending","aria-label":r("rightSidebar.downloadFile"),onClick:p=>{h(p)},className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-muted-foreground transition focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary active:scale-95 ${Qu(n==="pending")} ${n==="pending"?"bg-surface-elevated text-foreground":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,title:n==="error"?c??r("rightSidebar.downloadFailed"):r("rightSidebar.downloadFile"),children:n==="pending"?s.jsx(In,{size:12,className:"animate-spin"}):s.jsx(id,{size:12})})});function b6(){const{t:e}=zr(),[t,r]=b.useState({status:"idle"}),n=b.useCallback(async a=>{r({status:"pending"});try{await l3(a),r({status:"idle"})}catch(c){r({status:"error",message:c instanceof Error?c.message:e("rightSidebar.downloadFailed")})}},[e]);return{state:t,run:n}}function m1(e){return e instanceof DOMException&&e.name==="AbortError"}function Af(){if(typeof window>"u")return!1;const e=window.getSelection();return!!(e&&!e.isCollapsed&&e.toString().trim())}function y6(e){return e.button===2||e.ctrlKey}const LP=176,IP=160,S0=8;function ab(e,t,r,n){const a=window.visualViewport,c=a?.offsetLeft??0,l=a?.offsetTop??0,h=c+(a?.width??window.innerWidth),p=l+(a?.height??window.innerHeight),m=c+S0,x=l+S0,y=Math.max(m,h-r-S0),w=Math.max(x,p-n-S0),v=t+n<=p-S0?t:t-n;return{anchorX:e,anchorY:t,left:Math.min(Math.max(e,m),y),top:Math.min(Math.max(v,x),w)}}function v6(e){const[t,r]=b.useState(null),n=b.useRef(null),a=b.useCallback((c,l)=>{r(ab(c,l,LP,IP))},[]);return b.useLayoutEffect(()=>{if(!e||!t||!n.current)return;const c=n.current.getBoundingClientRect();if(c.width<=0||c.height<=0)return;const l=ab(t.anchorX,t.anchorY,c.width,c.height);l.left===t.left&&l.top===t.top||r(l)},[e,t]),{position:t,menuRef:n,openAt:a,clearPosition:()=>r(null)}}function w6(e,t){return t&&typeof document<"u"?Li.createPortal(e,document.body):e}function EP(e,t){return t?`${e.name} ${e.path}`.toLowerCase().includes(t):!0}function gg(e,t,r){if(!t||EP(e,t))return!0;const n=r.get(e.path);return n?n.some(a=>gg(a,t,r)):!1}function g1(e){return e.map(t=>({name:t.name,path:t.path,type:t.type,isSymlink:t.isSymlink,modified:t.modified,expanded:!1,loaded:!1,children:t.type==="directory"?[]:void 0}))}function x1(e,t){return!e||!t.startsWith(e)?t:t.slice(e.length).replace(/^\/+/,"")||t}const NP=b.memo(function e({node:t,depth:r,onFileSelect:n,directoriesOnly:a=!1,onPathReference:c,referenceSelection:l,getReferenceText:h,onReferenceCopied:p,insertedReferenceKey:m,copiedReferenceKey:x,onDirectoryRoot:y,onSearchFromDirectory:w,onDirectoryPinToggle:v,onFilePinToggle:k,onOpenInFileBrowser:L,canOpenInFileBrowser:E,pinnedPaths:R,selectedFilePath:B,queryLower:W,onDirectoryDropFiles:F,onFileDeleteRequest:U,deletingFilePath:V,revealedDirectoryPath:Z,gitIgnoreRoot:le}){const{t:xe}=zr(),fe=Gt(bt=>bt.expandedPaths.has(t.path)),te=Gt(bt=>bt.directoryCache.get(t.path)),ke=Gt(bt=>bt.showHiddenFiles),$e=Gt(bt=>bt.toggleExpanded),Y=Gt(bt=>bt.setDirectoryCache),Ae=Gt(bt=>bt.fileSortModes[t.path]??"name"),lt=Gt(bt=>bt.setDirectorySortMode),[Ce,ye]=b.useState(!1),[_e,je]=b.useState(!1),{position:re,menuRef:Pe,openAt:Se,clearPosition:Ee}=v6(_e),[Be,Ne]=b.useState(!1),oe=b.useRef(0),He=b.useRef(null),rt=`file-tree-reference:${b.useId()}:${t.path}`;wd(Pe,_e&&!!l,()=>je(!1));const mt=b.useRef(null),de=t.path===B||t.path===Z,Ye=t.type==="directory"&&(fe||!!W),st=t.type==="directory",Ie=R.has(t.path),We=!st&&!!k,Te=!!(E&&L),H=`path:${t.path}`,ae=m===H||!!l?.paths.has(t.path),be=x===H,Ze=h?.(t.path)??t.path,Je=L1(p,!!l),{state:Tt,run:Wt}=b6(),Mt=V===t.path,vt=st&&!a&&!!(y||w||v||Te),Yt=b.useMemo(()=>{if(!te)return;if(!W)return te;const bt=Gt.getState().directoryCache;return te.filter(It=>(!a||It.type==="directory")&&gg(It,W,bt))},[te,a,W]),Qt=b.useCallback(async()=>{if(!Gt.getState().directoryCache.has(t.path)&&!Ce){const It=l?rt:`file-tree:${t.path}`;He.current?.abort(),Im(It);const yt=new AbortController;He.current=yt,ye(!0);try{const pr=await C1(t.path,yt.signal,ke,"expand_directory",It,Ae,le);if(yt.signal.aborted)return;const nr=g1(pr.entries);Y(t.path,nr)}catch(pr){m1(pr)}finally{He.current===yt&&(He.current=null),ye(!1)}}},[t.path,Ce,Y,ke,Ae,le,!!l,rt]),Xt=b.useCallback(async()=>{if(t.type!=="directory"){n(t.path);return}if(a&&y){y(t.path);return}const bt=!Gt.getState().expandedPaths.has(t.path);$e(t.path),bt&&await Qt()},[a,t.path,t.type,Qt,y,$e,n]);b.useEffect(()=>{t.type==="directory"&&fe&&!te&&!Ce&&Qt()},[te,fe,Qt,Ce,t.type]);const Ut=b.useCallback(bt=>{bt.stopPropagation(),c?.(t.path,H)},[c,t.path,H]),Lt=b.useCallback(bt=>{bt.stopPropagation(),y?.(t.path),je(!1)},[t.path,y]),pe=b.useCallback(bt=>{bt.stopPropagation(),w?.(t.path),je(!1)},[t.path,w]),Ge=b.useCallback(bt=>{bt.stopPropagation(),v?.(t.path),je(!1)},[t.path,v]),ft=b.useCallback(bt=>{bt.stopPropagation(),lt(t.path,Ae==="modified"?"name":"modified"),je(!1)},[t.path,lt,Ae]),q=b.useCallback(bt=>{bt.stopPropagation(),k?.(t.path),je(!1)},[t.path,k]),at=b.useCallback(bt=>{bt.stopPropagation(),je(!1),Wt(t.path)},[t.path,Wt]),Vt=b.useCallback(bt=>{bt.stopPropagation(),je(!1),U(t)},[t,U]),Ve=b.useCallback(bt=>{bt.stopPropagation(),L?.(t.path),je(!1)},[t.path,L]),De=b.useCallback(bt=>{!st||!F||!bt.dataTransfer.types.includes("Files")||(bt.preventDefault(),bt.stopPropagation(),oe.current+=1,Ne(!0))},[st,F]),er=b.useCallback(bt=>{!st||!F||!bt.dataTransfer.types.includes("Files")||(bt.preventDefault(),bt.stopPropagation(),bt.dataTransfer.dropEffect="copy",Ne(!0))},[st,F]),et=b.useCallback(bt=>{!st||!F||(bt.preventDefault(),bt.stopPropagation(),oe.current-=1,oe.current<=0&&(oe.current=0,Ne(!1)))},[st,F]),Ct=b.useCallback(bt=>{if(!st||!F)return;bt.preventDefault(),bt.stopPropagation(),oe.current=0,Ne(!1);const It=Array.from(bt.dataTransfer.files);It.length>0&&F(t.path,It)},[st,t.path,F]),Nt=b.useCallback(bt=>{bt.stopPropagation(),l?Se(bt.clientX,bt.clientY):Ee(),je(It=>!It)},[Ee,Se,!!l]),gt=b.useCallback(bt=>{!vt||!y6(bt)||(bt.preventDefault(),bt.stopPropagation(),Se(bt.clientX,bt.clientY),je(!0))},[vt,Se]);return b.useEffect(()=>{if(!_e)return;const bt=yt=>{const pr=yt.target;pr instanceof Node&&(mt.current?.contains(pr)||Pe.current?.contains(pr))||je(!1)},It=yt=>{yt.key==="Escape"&&je(!1)};return document.addEventListener("pointerdown",bt),document.addEventListener("keydown",It),()=>{document.removeEventListener("pointerdown",bt),document.removeEventListener("keydown",It)}},[_e,Pe]),b.useEffect(()=>()=>{He.current?.abort()},[]),s.jsxs("div",{style:!Ye&&!_e?{contentVisibility:"auto",containIntrinsicSize:"auto 32px"}:void 0,children:[s.jsxs("div",{ref:mt,className:"relative",children:[Je.popoverNode,s.jsxs("div",{"data-file-tree-path":t.path,"data-sort-mode":Ae,role:"button",tabIndex:0,onClick:()=>{Af()||Xt()},onContextMenu:gt,onKeyDown:bt=>{bt.target!==bt.currentTarget||bt.key!=="Enter"&&bt.key!==" "||(bt.preventDefault(),Xt())},onDragEnter:De,onDragOver:er,onDragLeave:et,onDrop:Ct,className:`group relative flex w-full cursor-pointer items-center gap-1 rounded px-2 py-1 text-[13px] transition ${Be?"scale-[1.015] bg-primary/15 text-foreground shadow-[0_0_0_1px_rgb(var(--primary-rgb)_/_0.45)]":de?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:t.path,children:[r>0&&s.jsx("span",{"aria-hidden":"true",className:"shrink-0",style:{width:`${r*14-4}px`}}),Be&&s.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 z-10 -translate-y-1/2 rounded-full bg-primary px-2 py-0.5 text-[10px] font-semibold text-primary-foreground shadow-md",children:xe("fileTree.dropToUploadHere")}),t.type==="directory"?s.jsxs(s.Fragment,{children:[Ye?s.jsx(ul,{size:14,className:"shrink-0 text-muted-foreground/80"}):s.jsx(hi,{size:14,className:"shrink-0 text-muted-foreground/80"}),Ye?s.jsx(wu,{size:14,className:"shrink-0 text-[color:var(--folder)]"}):s.jsx(jc,{size:14,className:"shrink-0 text-[color:var(--folder)]"})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"w-[14px] shrink-0"}),s.jsx("span",{className:de?"text-primary":"text-muted-foreground/80",children:pg(t.name,t.type)})]}),s.jsxs("span",{className:`flex-1 select-text whitespace-nowrap text-left leading-snug ${de?"font-medium":""}`,children:[t.name,Ae==="modified"&&s.jsx("span",{className:"ml-1 inline-flex align-middle text-primary",title:xe("fileTree.sortedByModified"),"aria-label":xe("fileTree.sortedByModified"),children:s.jsx(sd,{size:11})}),t.isSymlink&&s.jsx("span",{className:"ml-1 inline-flex align-middle text-muted-foreground/70",title:xe("fileTree.symbolicLink"),children:s.jsx(Lu,{size:11})})]}),s.jsxs("div",{className:`sticky right-0 z-20 flex shrink-0 items-center rounded pl-1 ${de?"bg-surface-elevated":"bg-surface group-hover:bg-surface-2"}`,onClick:bt=>bt.stopPropagation(),children:[Ce&&s.jsx(In,{size:12,className:"shrink-0 animate-spin text-muted-foreground"}),s.jsx(x6,{path:t.path}),vt&&s.jsx("button",{type:"button",onClick:Nt,className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-muted-foreground transition focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary active:scale-95 ${Qu(_e)} ${_e?"bg-surface-elevated text-foreground":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":xe("fileTree.moreDirActions"),"aria-expanded":_e,title:xe("fileTree.moreDirActions"),children:s.jsx(Qo,{size:13})}),!st&&!l&&s.jsx("button",{type:"button",onClick:Nt,className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-muted-foreground transition focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary active:scale-95 ${Qu(_e||Tt.status==="pending"||Mt||Ie)} ${_e?"bg-surface-elevated text-foreground":Ie?"bg-primary/15 text-primary":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":xe("fileTree.moreFileActions"),"aria-expanded":_e,title:Tt.status==="error"?Tt.message??xe("rightSidebar.downloadFailed"):xe("fileTree.moreFileActions"),children:Tt.status==="pending"||Mt?s.jsx(In,{size:13,className:"animate-spin"}):s.jsx(Qo,{size:13})}),c&&s.jsx("button",{type:"button",onClick:Ut,...Je(Ze,H),className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-[11px] font-semibold transition focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary active:scale-95 ${l?"ml-1 min-h-11 min-w-11":mg(ae||be)} ${ae||be?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":l?`${l.label}: ${t.name}`:xe(be?"rightSidebar.copied":ae?"rightSidebar.inserted":"fileTree.insertRefTitle"),"aria-pressed":l?ae:void 0,disabled:!!l?.disabled&&!ae,title:l?`${l.label}: ${t.name}`:xe(be?"rightSidebar.copied":ae?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:be||ae?s.jsx(di,{size:12}):s.jsx(Lu,{size:12})}),vt&&_e&&w6(s.jsxs("div",{ref:Pe,className:`${re?l?"fixed z-popover":"fixed z-menu-panel":"absolute right-2 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`,style:re?{left:re.left,top:re.top}:void 0,children:[Te&&s.jsxs("button",{type:"button",onClick:Ve,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:xe("fileTree.openInFileBrowserTitle"),children:[s.jsx(wu,{size:13,className:"shrink-0 text-[color:var(--folder)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe("fileTree.openInFileBrowser")})]}),y&&s.jsxs("button",{type:"button",onClick:Lt,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:xe("fileTree.openDirRootTitle"),children:[s.jsx(wu,{size:13,className:"shrink-0 text-[color:var(--folder)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe("fileTree.openDirRoot")})]}),w&&s.jsxs("button",{type:"button",onClick:pe,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:xe("fileTree.searchFromDirTitle"),children:[s.jsx(I1,{size:13,className:"shrink-0 text-primary"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe("fileTree.searchFromDir")})]}),v&&s.jsxs("button",{type:"button",onClick:Ge,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] ${Ie?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:xe(Ie?"fileTree.unpinDirTitle":"fileTree.pinDirTitle"),children:[Ie?s.jsx(od,{size:13,className:"shrink-0"}):s.jsx(ad,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe(Ie?"fileTree.unpinDir":"fileTree.pinDir")})]}),s.jsxs("button",{type:"button",onClick:ft,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",children:[Ae==="modified"?s.jsx(lA,{size:13,className:"shrink-0"}):s.jsx(sd,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe(Ae==="modified"?"fileTree.sortByName":"fileTree.sortByModified")})]})]}),!!re),!st&&!l&&_e&&s.jsxs("div",{className:"absolute right-2 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:[Te&&s.jsxs("button",{type:"button",onClick:Ve,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:xe("fileTree.openInFileBrowserTitle"),children:[s.jsx(y3,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe("fileTree.openInFileBrowser")})]}),s.jsxs("button",{type:"button",onClick:at,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:xe("rightSidebar.downloadFile"),children:[s.jsx(id,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe("rightSidebar.downloadFile")})]}),We&&s.jsxs("button",{type:"button",onClick:q,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] ${Ie?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:xe(Ie?"fileTree.unpinFileTitle":"fileTree.pinFileTitle"),children:[Ie?s.jsx(od,{size:13,className:"shrink-0"}):s.jsx(ad,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe(Ie?"fileTree.unpinFile":"fileTree.pinFile")})]}),s.jsxs("button",{type:"button",onClick:Vt,disabled:Mt,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-destructive transition hover:bg-destructive/10 active:scale-[0.99] disabled:opacity-50",title:xe("fileTree.deleteFile"),children:[Mt?s.jsx(In,{size:13,className:"shrink-0 animate-spin"}):s.jsx(zs,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:xe("fileTree.deleteFile")})]})]})]})]})]}),Ye&&Yt&&Yt.length>0&&s.jsx("div",{className:r===0?"mt-0.5":"",children:Yt.map(bt=>s.jsx(e,{node:bt,depth:r+1,onFileSelect:n,directoriesOnly:a,onPathReference:c,referenceSelection:l,getReferenceText:h,onReferenceCopied:p,onDirectoryRoot:y,onSearchFromDirectory:w,onDirectoryPinToggle:v,onFilePinToggle:k,onOpenInFileBrowser:L,canOpenInFileBrowser:E,pinnedPaths:R,selectedFilePath:B,queryLower:W,insertedReferenceKey:m,copiedReferenceKey:x,onDirectoryDropFiles:F,onFileDeleteRequest:U,deletingFilePath:V,gitIgnoreRoot:le,revealedDirectoryPath:Z},bt.path))})]})}),RP=b.memo(function({node:t,rootPath:r,onFileSelect:n,onPathReference:a,referenceSelection:c,getReferenceText:l,onReferenceCopied:h,insertedReferenceKey:p,copiedReferenceKey:m,onDirectoryRoot:x,onSearchFromDirectory:y,onDirectoryPinToggle:w,onFilePinToggle:v,pinnedPaths:k,selectedFilePath:L,onFileDeleteRequest:E,deletingFilePath:R}){const{t:B}=zr(),W=t.path===L,F=t.type==="directory",U=k.has(t.path),V=!F&&!!v,Z=`path:${t.path}`,le=p===Z||!!c?.paths.has(t.path),xe=m===Z,fe=l?.(t.path)??t.path,te=L1(h,!!c),{state:ke,run:$e}=b6(),[Y,Ae]=b.useState(!1),{position:lt,menuRef:Ce,openAt:ye,clearPosition:_e}=v6(Y);wd(Ce,Y&&!!c,()=>Ae(!1));const je=b.useRef(null),re=R===t.path,Pe=F&&!!(x||y||w),Se=b.useCallback(()=>{Af()||(t.type==="directory"?x?.(t.path):n(t.path))},[t.path,t.type,x,n]),Ee=b.useCallback(de=>{de.stopPropagation(),a?.(t.path,Z)},[a,t.path,Z]),Be=b.useCallback(de=>{de.stopPropagation(),w?.(t.path),Ae(!1)},[t.path,w]),Ne=b.useCallback(de=>{de.stopPropagation(),v?.(t.path),Ae(!1)},[t.path,v]),oe=b.useCallback(de=>{de.stopPropagation(),Ae(!1),$e(t.path)},[t.path,$e]),He=b.useCallback(de=>{de.stopPropagation(),Ae(!1),E(t)},[t,E]),rt=b.useCallback(de=>{de.stopPropagation(),c?ye(de.clientX,de.clientY):_e(),Ae(Ye=>!Ye)},[_e,ye,!!c]),mt=b.useCallback(de=>{!Pe||!y6(de)||(de.preventDefault(),de.stopPropagation(),ye(de.clientX,de.clientY),Ae(!0))},[Pe,ye]);return b.useEffect(()=>{if(!Y)return;const de=st=>{const Ie=st.target;Ie instanceof Node&&(je.current?.contains(Ie)||Ce.current?.contains(Ie))||Ae(!1)},Ye=st=>{st.key==="Escape"&&Ae(!1)};return document.addEventListener("pointerdown",de),document.addEventListener("keydown",Ye),()=>{document.removeEventListener("pointerdown",de),document.removeEventListener("keydown",Ye)}},[Y,Ce]),s.jsxs("div",{ref:je,className:"relative border-b border-border/10 last:border-b-0",children:[te.popoverNode,s.jsxs("div",{role:"button",tabIndex:0,onClick:Se,onContextMenu:mt,onKeyDown:de=>{de.target!==de.currentTarget||de.key!=="Enter"&&de.key!==" "||(de.preventDefault(),Se())},className:`group flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-2 text-left text-[13px] transition ${W?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:t.path,children:[t.type==="directory"?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"w-[14px] shrink-0"}),s.jsx(jc,{size:14,className:"shrink-0 text-[color:var(--folder)]"})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"w-[14px] shrink-0"}),s.jsx("span",{className:W?"text-primary":"text-muted-foreground/80",children:pg(t.name,t.type)})]}),s.jsxs("span",{className:"min-w-0 flex-1 select-text",children:[s.jsxs("span",{className:`block whitespace-normal break-all font-medium leading-snug ${W?"text-primary":"text-foreground"}`,children:[t.name,t.isSymlink&&s.jsx("span",{className:"ml-1 inline-flex align-middle text-muted-foreground/70",title:B("fileTree.symbolicLink"),children:s.jsx(Lu,{size:11})})]}),s.jsx("span",{className:"mt-0.5 block truncate font-mono text-[10px] text-muted-foreground/80",children:x1(r,t.path)})]}),s.jsx(x6,{path:t.path}),t.type==="directory"&&(w||y)&&s.jsx("button",{type:"button",onClick:rt,className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-muted-foreground transition focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary active:scale-95 ${Qu(Y)} ${Y?"bg-surface-elevated text-foreground":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":B("fileTree.moreDirActions"),"aria-expanded":Y,title:B("fileTree.moreDirActions"),children:s.jsx(Qo,{size:13})}),!F&&!c&&s.jsx("button",{type:"button",onClick:rt,className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-muted-foreground transition focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary active:scale-95 ${Qu(Y||ke.status==="pending"||re||U)} ${Y?"bg-surface-elevated text-foreground":U?"bg-primary/15 text-primary":"bg-surface-2 hover:bg-surface-elevated hover:text-foreground"}`,"aria-label":B("fileTree.moreFileActions"),"aria-expanded":Y,title:ke.status==="error"?ke.message??B("rightSidebar.downloadFailed"):B("fileTree.moreFileActions"),children:ke.status==="pending"||re?s.jsx(In,{size:13,className:"animate-spin"}):s.jsx(Qo,{size:13})}),a&&s.jsx("button",{type:"button",onClick:Ee,...te(fe,Z),className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-[11px] font-semibold transition focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary active:scale-95 ${c?"ml-1 min-h-11 min-w-11":mg(le||xe)} ${le||xe?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":c?`${c.label}: ${t.name}`:B(xe?"rightSidebar.copied":le?"rightSidebar.inserted":"fileTree.insertRefTitle"),"aria-pressed":c?le:void 0,disabled:!!c?.disabled&&!le,title:c?`${c.label}: ${t.name}`:B(xe?"rightSidebar.copied":le?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:xe||le?s.jsx(di,{size:12}):s.jsx(Lu,{size:12})})]}),Pe&&Y&&w6(s.jsxs("div",{ref:Ce,className:`${lt?c?"fixed z-popover":"fixed z-menu-panel":"absolute right-2 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`,style:lt?{left:lt.left,top:lt.top}:void 0,children:[x&&s.jsxs("button",{type:"button",onClick:de=>{de.stopPropagation(),x(t.path),Ae(!1)},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:B("fileTree.openDirRootTitle"),children:[s.jsx(wu,{size:13,className:"shrink-0 text-[color:var(--folder)]"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B("fileTree.openDirRoot")})]}),y&&s.jsxs("button",{type:"button",onClick:de=>{de.stopPropagation(),y(t.path),Ae(!1)},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",children:[s.jsx(I1,{size:13,className:"shrink-0 text-primary"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B("fileTree.searchFromDir")})]}),w&&s.jsxs("button",{type:"button",onClick:Be,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] ${U?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:B(U?"fileTree.unpinDirTitle":"fileTree.pinDirTitle"),children:[U?s.jsx(od,{size:13,className:"shrink-0"}):s.jsx(ad,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B(U?"fileTree.unpinDir":"fileTree.pinDir")})]})]}),!!lt),!F&&!c&&Y&&s.jsxs("div",{className:"absolute right-2 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:[s.jsxs("button",{type:"button",onClick:oe,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-foreground transition hover:bg-surface-2 active:scale-[0.99]",title:B("rightSidebar.downloadFile"),children:[s.jsx(id,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B("rightSidebar.downloadFile")})]}),V&&s.jsxs("button",{type:"button",onClick:Ne,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] ${U?"text-primary hover:bg-primary/10":"text-foreground hover:bg-surface-2"}`,title:B(U?"fileTree.unpinFileTitle":"fileTree.pinFileTitle"),children:[U?s.jsx(od,{size:13,className:"shrink-0"}):s.jsx(ad,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B(U?"fileTree.unpinFile":"fileTree.pinFile")})]}),s.jsxs("button",{type:"button",onClick:He,disabled:re,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left font-medium text-destructive transition hover:bg-destructive/10 active:scale-[0.99] disabled:opacity-50",title:B("fileTree.deleteFile"),children:[re?s.jsx(In,{size:13,className:"shrink-0 animate-spin"}):s.jsx(zs,{size:13,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:B("fileTree.deleteFile")})]})]})]})}),MP=60,ob=60,jP=20;function lb({count:e,loading:t,engine:r,limited:n,scope:a,content:c}){const{t:l}=zr();return s.jsxs("div",{className:"sticky top-0 z-10 -mx-2 -mt-2 mb-2 border-b border-border/15 bg-surface/95 px-3 py-2.5 backdrop-blur",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2 text-[12px] font-semibold text-foreground",children:[s.jsx(I1,{size:14,className:"shrink-0 text-primary"}),s.jsx("span",{children:c?l("fileTree.contentMatchesCount",{count:e}):l("fileTree.searchResults",{count:e})})]}),r&&s.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full bg-surface-2 px-2 py-0.5 text-[9px] uppercase tracking-[0.12em] text-muted-foreground",children:[t&&s.jsx(In,{size:9,className:"animate-spin"}),r,n?" · limited":""]})]}),s.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-1.5 text-[10px] text-muted-foreground",children:[s.jsx("span",{className:"shrink-0",children:l("fileTree.searchScope")}),s.jsx("span",{className:"min-w-0 truncate font-mono text-foreground/75",title:a,children:a}),t&&s.jsx("span",{className:"ml-auto shrink-0",children:l("fileTree.searching")})]})]})}function DP(e,t){if(!t)return e;const r=e.toLowerCase(),n=t.toLowerCase(),a=[];let c=0,l=r.indexOf(n,c),h=0;for(;l>=0&&n;)l>c&&a.push(e.slice(c,l)),a.push(s.jsx("mark",{className:"rounded-sm bg-[rgb(var(--warning-rgb)_/_0.30)] px-0.5 text-foreground",children:e.slice(l,l+n.length)},`m-${h++}`)),c=l+n.length,l=r.indexOf(n,c);return c<e.length&&a.push(e.slice(c)),a.length>0?a:e}const BP=b.memo(function({entry:t,rootPath:r,selectedFilePath:n,query:a,onContentMatchSelect:c,onPathReference:l,referenceSelection:h,getReferenceText:p,onReferenceCopied:m,insertedReferenceKey:x,copiedReferenceKey:y}){const{t:w}=zr(),[v,k]=b.useState(!0),L=t.path===n,E=v?t.matches.slice(0,jP):[],R=t.matches.length-E.length,B=`path:${t.path}`,W=x===B||!!h?.paths.has(t.path),F=y===B,U=p?.(t.path)??t.path,V=L1(m,!!h);return s.jsxs("div",{className:"border-b border-border/10 last:border-b-0",children:[V.popoverNode,s.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{Af()||k(Z=>!Z)},onKeyDown:Z=>{Z.target!==Z.currentTarget||Z.key!=="Enter"&&Z.key!==" "||(Z.preventDefault(),k(le=>!le))},className:`group flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-2 text-left text-[13px] transition ${L?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,title:t.path,children:[v?s.jsx(ul,{size:14,className:"shrink-0 text-muted-foreground/80"}):s.jsx(hi,{size:14,className:"shrink-0 text-muted-foreground/80"}),s.jsx("span",{className:L?"text-primary":"text-muted-foreground/80",children:pg(t.name,"file")}),s.jsxs("span",{className:"min-w-0 flex-1 select-text",children:[s.jsx("span",{className:"block whitespace-normal break-all font-medium leading-snug",children:t.name}),s.jsx("span",{className:"mt-0.5 block truncate font-mono text-[10px] text-muted-foreground/80",children:x1(r,t.path)})]}),s.jsx("span",{className:"shrink-0 select-none rounded-full bg-surface-2 px-1.5 py-0.5 text-[10px] text-muted-foreground",children:t.matches.length}),!h&&s.jsx(kP,{path:t.path}),l&&s.jsx("button",{type:"button",onClick:Z=>{Z.stopPropagation(),l(t.path,B)},...V(U,B),className:`inline-flex h-6 shrink-0 select-none items-center justify-center rounded-md text-[11px] font-semibold transition focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary active:scale-95 ${h?"ml-1 min-h-11 min-w-11":mg(W||F)} ${W||F?"bg-surface-elevated text-foreground":"bg-primary/10 text-primary"}`,"aria-label":h?`${h.label}: ${t.name}`:w(F?"rightSidebar.copied":W?"rightSidebar.inserted":"fileTree.insertRefTitle"),"aria-pressed":h?W:void 0,disabled:!!h?.disabled&&!W,title:h?`${h.label}: ${t.name}`:w(F?"rightSidebar.copied":W?"rightSidebar.inserted":"fileTree.insertRefTitle"),children:F||W?s.jsx(di,{size:12}):s.jsx(Lu,{size:12})})]}),v&&s.jsxs("div",{className:"mb-1 ml-3 border-l border-border/20 pl-1",children:[E.map((Z,le)=>s.jsxs("div",{role:"button",tabIndex:0,onClick:()=>{Af()||c?.(t.path,Z.line)},onKeyDown:xe=>{xe.target!==xe.currentTarget||xe.key!=="Enter"&&xe.key!==" "||(xe.preventDefault(),c?.(t.path,Z.line))},className:"flex w-full cursor-pointer items-start gap-2 rounded px-2 py-1 text-left font-mono text-[11px] text-muted-foreground transition hover:bg-surface-2 hover:text-foreground",title:`${x1(r,t.path)}:${Z.line}`,children:[s.jsx("span",{className:"shrink-0 select-none tabular-nums text-muted-foreground/60",children:Z.line}),s.jsx("span",{className:"min-w-0 flex-1 truncate whitespace-pre select-text",children:DP(Z.text,a)})]},`${Z.line}-${le}`)),R>0&&s.jsx("div",{className:"px-2 py-1 text-[10px] text-muted-foreground/70",children:w("fileTree.moreMatches",{count:R})})]})]})});function QP({rootPath:e,onFileSelect:t,directoriesOnly:r=!1,onPathReference:n,referenceSelection:a,getReferenceText:c,onReferenceCopied:l,insertedReferenceKey:h,copiedReferenceKey:p,onDirectoryRoot:m,onSearchFromDirectory:x,onDirectoryPinToggle:y,onFilePinToggle:w,onOpenInFileBrowser:v,canOpenInFileBrowser:k=!1,pinnedPaths:L=CP,selectedFilePath:E,query:R="",searchRootPath:B,searchOptions:W={},searchMode:F="name",onContentMatchSelect:U,onDirectoryDropFiles:V,revealDirectory:Z}){const{t:le}=zr(),xe=b.useId(),fe=a?`file-tree-reference-root:${xe}:${e}`:`file-tree-root:${e}`,te=Gt(Ve=>e?Ve.directoryCache.get(e):void 0),ke=Gt(Ve=>Ve.setDirectoryCache),$e=Gt(Ve=>Ve.showHiddenFiles),Y=Gt(Ve=>Ve.fileSortModesHydrated),Ae=Gt(Ve=>Ve.fileSortModes[e]??"name"),lt=Gt(Ve=>Ve.hydrateFileSortModes),Ce=Gt(Ve=>Ve.hydrateHideGitIgnoredRoots),ye=Gt(Ve=>!!Ve.hideGitIgnoredRoots[e]),_e=Gt(Ve=>Ve.hideGitIgnoredRootsHydrated),je=Gt(Ve=>JSON.stringify(Ve.gitIgnoreExceptions[e]??[])),re=Gt(Ve=>Ve.invalidateDirectoryCache),Pe=`${e}:${ye}:${je}`,[Se,Ee]=b.useState("");b.useLayoutEffect(()=>{e&&re(e,!0),Ee(Pe)},[e,ye,je,re,Pe]);const[Be,Ne]=b.useState(!1),[oe,He]=b.useState(null),[rt,mt]=b.useState(!1),[de,Ye]=b.useState(!1),[st,Ie]=b.useState(null),[We,Te]=b.useState(Y&&_e),H=Y&&_e||We;b.useEffect(()=>{let Ve=!1;return Promise.all([lt(),Ce()]).catch(()=>{}).finally(()=>{Ve||Te(!0)}),()=>{Ve=!0}},[lt,Ce]);const[ae,be]=b.useState([]),[Ze,Je]=b.useState(null),[Tt,Wt]=b.useState(sb),[Mt,vt]=b.useState([]),[Yt,Qt]=b.useState(null),Xt=b.useRef(null),Ut=b.useRef(0),Lt=R.trim().toLowerCase(),pe=F==="content",Ge=B||e,ft=W.excludePatterns??SP,q=ft.join(`
130
130
  `);b.useEffect(()=>{const Ve=Z?.path;if(!Ve||!Ve.startsWith(`${e}/`)&&Ve!==e)return;const De=Ve.slice(e.length).replace(/^\/+/,""),er=De?De.split("/"):[],et=er.map((pr,nr)=>`${e}/${er.slice(0,nr+1).join("/")}`),Ct=Gt.getState(),Nt=et.filter(pr=>!Ct.expandedPaths.has(pr));Nt.length>0&&Gt.setState(pr=>({expandedPaths:new Set([...pr.expandedPaths,...Nt])}));let gt=!1,bt=0;const It=()=>{if(gt)return;const pr=Array.from(document.querySelectorAll("[data-file-tree-path]")).find(nr=>nr.dataset.fileTreePath===Ve);if(pr){pr.scrollIntoView({block:"center",behavior:"smooth"});return}bt+=1,bt<80&&window.setTimeout(It,50)},yt=window.requestAnimationFrame(It);return()=>{gt=!0,window.cancelAnimationFrame(yt)}},[Z?.nonce,Z?.path,e]);const at=b.useCallback(async Ve=>{if(!(Yt||Ve.type==="directory")&&window.confirm(le("fileTree.deleteFileConfirm",{name:Ve.name}))){Qt(Ve.path);try{await mw(Ve.path),Gt.getState().applyFileWatchEvents([{type:"deleted",path:Ve.path}]),be(De=>De.filter(er=>er.path!==Ve.path)),vt(De=>De.filter(er=>er.path!==Ve.path)),L.has(Ve.path)&&w?.(Ve.path)}catch(De){const er=De instanceof Error?De.message:String(De);window.alert(le("fileTree.deleteFileFailed",{message:er}))}finally{Qt(null)}}},[Yt,w,L,le]);b.useEffect(()=>{if(!e||!H||Se!==Pe)return;if(Lt){Ne(!1);return}if(Gt.getState().directoryCache.has(e)){Ne(!1);return}let Ve=!1;const De=new AbortController;return Ne(!0),He(null),C1(e,De.signal,$e,"load_file_tree_root",fe,Ae,e).then(er=>{if(Ve)return;const et=g1(er.entries);mt(!!er.truncated),ke(e,et)}).catch(er=>{Ve||m1(er)||He(er instanceof Error?er.message:"Failed to load directory")}).finally(()=>{Ve||Ne(!1)}),()=>{Ve=!0,De.abort(),Im(fe)}},[Lt,te,e,Ae,ke,$e,H,ye,je,fe,Se,Pe]),b.useEffect(()=>{if(!Ge||!Lt){Ye(!1),Ie(null),be([]),vt([]),Je(null);return}let Ve=!1;const De=new AbortController,er=new Set;Ye(!0),Ie(null),be([]),vt([]),Wt(pe?MP:sb),Je({truncated:!1,total:0,engine:"rg",limited:!1,done:!1});const et=`file-search:${a?xe+":":""}${Ge}:${++Ut.current}`;return gw(Ge,R.trim(),Ct=>{if(!Ve){if(Ct.engine&&Je(Nt=>({truncated:Nt?.truncated??!1,total:Nt?.total??0,engine:Ct.engine,limited:Ct.limited??Nt?.limited??!1,done:Nt?.done??!1})),Ct.entries?.length){const Nt=Ct.entries.filter(gt=>er.has(gt.path)?!1:(er.add(gt.path),!0));Nt.length>0&&(be(gt=>[...gt,...g1(Nt)]),Je(gt=>gt?{...gt,total:er.size}:{truncated:!1,total:er.size,engine:"rg",limited:!1,done:!1}))}if(Ct.contentEntries?.length){const Nt=Ct.contentEntries.filter(gt=>er.has(gt.path)?!1:(er.add(gt.path),!0));Nt.length>0&&(vt(gt=>[...gt,...Nt]),Je(gt=>gt?{...gt,total:er.size}:{truncated:!1,total:er.size,engine:"rg",limited:!1,done:!1}))}Ct.done&&Je(Nt=>({truncated:!!Ct.truncated,total:typeof Ct.total=="number"?Ct.total:er.size,engine:Ct.engine??Nt?.engine??"rg",limited:!!Ct.limited,done:!0}))}},De.signal,$e,F,et,{excludePatterns:ft,caseSensitive:W.caseSensitive,wholeWord:W.wholeWord,regex:W.regex}).catch(Ct=>{Ve||m1(Ct)||(Ie(Ct instanceof Error?Ct.message:"Failed to search files"),be([]),vt([]),Je(null))}).finally(()=>{Ve||Ye(!1)}),()=>{Ve=!0,De.abort(),Im(et)}},[Ge,q,pe,R,Lt,F,W.caseSensitive,W.regex,W.wholeWord,$e,!!a,xe]),b.useEffect(()=>{if(!Lt)return;const Ve=Xt.current;if(!Ve)return;const De=pe?Mt.length:ae.length,er=pe?ob:ib,et=new IntersectionObserver(Ct=>{Ct.some(Nt=>Nt.isIntersecting)&&Wt(Nt=>Math.min(Nt+er,De))},{rootMargin:"160px 0px"});return et.observe(Ve),()=>et.disconnect()},[Lt,ae.length,Mt.length,pe]);const Vt=b.useMemo(()=>{if(!te)return;if(!Lt)return r?te.filter(De=>De.type==="directory"):te;const Ve=Gt.getState().directoryCache;return te.filter(De=>(!r||De.type==="directory")&&gg(De,Lt,Ve))},[r,Lt,te]);if(!e)return s.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:le("fileTree.noWorkingDir")});if(Be||!H)return s.jsx(AP,{});if(Lt&&pe){const Ve=Ze?.total??Mt.length,De=Mt.slice(0,Tt),er=Tt<Mt.length;return s.jsxs("div",{className:"termdock-native-select min-h-full space-y-px bg-surface px-2 py-2",children:[s.jsx(lb,{count:Ve,loading:de,engine:Ze?.engine,limited:Ze?.limited,scope:Ge,content:!0}),st?s.jsxs("div",{className:"mx-1 mt-3 rounded-xl border border-border/15 bg-surface-2 px-4 py-5 text-center text-sm text-muted-foreground",children:[le("fileTree.contentSearchNeedsRipgrep"),s.jsx("div",{className:"mt-1 break-words text-[11px] text-muted-foreground/70",children:st})]}):de&&Mt.length===0?s.jsx(nd,{label:le("fileTree.searching"),className:"py-8"}):Mt.length===0?s.jsx("div",{className:"mx-1 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:le("fileTree.noContentMatches")}):s.jsxs(s.Fragment,{children:[Ze?.limited&&s.jsx("div",{className:"mb-2 rounded-xl bg-[rgb(var(--warning-rgb)_/_0.12)] px-3 py-2 text-[11px] text-[color:var(--warning)]",children:le("fileTree.searchTruncatedHint",{count:Ze.total})}),De.map(et=>s.jsx(BP,{entry:et,rootPath:Ge,selectedFilePath:E,query:R.trim(),onContentMatchSelect:U,onPathReference:n,referenceSelection:a,getReferenceText:c,onReferenceCopied:l,insertedReferenceKey:h,copiedReferenceKey:p},et.path)),s.jsx("div",{ref:Xt,className:"py-2 text-center text-[11px] text-muted-foreground",children:er?s.jsx("button",{type:"button",onClick:()=>Wt(et=>Math.min(et+ob,Mt.length)),className:"rounded-full bg-surface-2 px-3 py-1 hover:bg-surface-elevated hover:text-foreground",children:le("fileTree.loadMoreSearchResults",{shown:De.length,total:Mt.length})}):de?s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(In,{size:10,className:"animate-spin"}),le("fileTree.searchStillRunning")]}):De.length>0?s.jsx("span",{children:le("fileTree.showingSearchResults",{shown:De.length,total:Ve})}):null})]})]})}if(Lt){const Ve=Ze?.total??ae.length,De=ae.slice(0,Tt),er=Tt<ae.length;return s.jsxs("div",{className:"termdock-native-select min-h-full space-y-px bg-surface px-2 py-2",children:[s.jsx(lb,{count:Ve,loading:de,engine:Ze?.engine,limited:Ze?.limited,scope:Ge,content:!1}),de&&ae.length===0?s.jsx(nd,{label:le("fileTree.searching"),className:"py-8"}):st?s.jsx("div",{className:"px-4 py-4 text-sm text-destructive",children:st}):ae.length===0?s.jsx("div",{className:"mx-1 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:le("fileTree.noMatchingFiles")}):s.jsxs(s.Fragment,{children:[Ze?.limited&&s.jsx("div",{className:"mb-2 rounded-xl bg-[rgb(var(--warning-rgb)_/_0.12)] px-3 py-2 text-[11px] text-[color:var(--warning)]",children:le("fileTree.searchTruncatedHint",{count:Ze.total})}),De.map(et=>s.jsx(RP,{node:et,rootPath:Ge,onFileSelect:t,onPathReference:n,referenceSelection:a,getReferenceText:c,onReferenceCopied:l,onDirectoryRoot:m,onSearchFromDirectory:x,onDirectoryPinToggle:y,onFilePinToggle:w,pinnedPaths:L,selectedFilePath:E,insertedReferenceKey:h,copiedReferenceKey:p,onFileDeleteRequest:at,deletingFilePath:Yt},et.path)),s.jsx("div",{ref:Xt,className:"py-2 text-center text-[11px] text-muted-foreground",children:er?s.jsx("button",{type:"button",onClick:()=>Wt(et=>Math.min(et+ib,ae.length)),className:"rounded-full bg-surface-2 px-3 py-1 hover:bg-surface-elevated hover:text-foreground",children:le("fileTree.loadMoreSearchResults",{shown:De.length,total:ae.length})}):de?s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(In,{size:10,className:"animate-spin"}),le("fileTree.searchStillRunning")]}):De.length>0?s.jsx("span",{children:le("fileTree.showingSearchResults",{shown:De.length,total:Ve})}):null})]})]})}return oe?s.jsx("div",{role:a?"alert":void 0,className:"px-4 py-4 text-sm text-destructive",children:oe}):!te||te.length===0?s.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:le("fileTree.emptyDir")}):!Vt||Vt.length===0?s.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:le("fileTree.noMatchingFiles")}):s.jsxs("div",{className:"termdock-native-select w-max min-w-full space-y-px px-2 py-2",children:[rt&&s.jsx("div",{className:"mb-2 rounded-xl bg-[rgb(var(--warning-rgb)_/_0.12)] px-3 py-2 text-[11px] text-[color:var(--warning)]",children:le("fileTree.truncatedHint")}),Vt.map(Ve=>s.jsx(NP,{node:Ve,gitIgnoreRoot:e,depth:0,onFileSelect:t,directoriesOnly:r,onPathReference:n,referenceSelection:a,getReferenceText:c,onReferenceCopied:l,onDirectoryRoot:m,onSearchFromDirectory:x,onDirectoryPinToggle:y,onFilePinToggle:w,onOpenInFileBrowser:v,canOpenInFileBrowser:k,pinnedPaths:L,selectedFilePath:E,queryLower:Lt,insertedReferenceKey:h,copiedReferenceKey:p,onDirectoryDropFiles:V,onFileDeleteRequest:at,deletingFilePath:Yt,revealedDirectoryPath:Z?.path},Ve.path))]})}function b1(e){return e.trim().replace(/\/+$/,"")||"/"}function PP(e){const t=b1(e);if(t==="/")return"/";const r=t.lastIndexOf("/");return r<=0?"/":t.slice(0,r)}function Hf({open:e,initialPath:t,title:r,labels:n,onCancel:a,onConfirm:c}){const{t:l}=zr(),h={hint:n?.hint??l("sidebar.directoryPickerHint"),cancel:n?.cancel??l("common.cancel"),confirm:n?.confirm??l("sidebar.useThisFolder"),close:n?.close??l("common.close"),parent:n?.parent??l("rightSidebar.parentFolder")},p=b.useRef(null);wd(p,e,a);const[m,x]=b.useState(()=>b1(t));return b.useEffect(()=>{e&&x(b1(t))},[t,e]),b.useEffect(()=>{if(!e)return;const y=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=y}},[e]),e?Li.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop cursor-default bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:a,"aria-label":h.cancel}),s.jsxs("section",{ref:p,tabIndex:-1,role:"dialog","aria-modal":"true","aria-labelledby":"directory-picker-title",className:"fixed bottom-[max(0.75rem,env(safe-area-inset-bottom,0px))] left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] top-[max(0.75rem,env(safe-area-inset-top,0px))] z-modal-panel flex flex-col overflow-hidden rounded-2xl border border-border/15 bg-surface shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)] sm:bottom-auto sm:left-1/2 sm:right-auto sm:top-1/2 sm:h-[min(72svh,36rem)] sm:w-[min(36rem,calc(100vw-2rem))] sm:-translate-x-1/2 sm:-translate-y-1/2",children:[s.jsxs("header",{className:"flex shrink-0 items-center gap-3 border-b border-border/15 px-4 py-3",children:[s.jsx("span",{className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/15 text-primary",children:s.jsx(YA,{size:15})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h2",{id:"directory-picker-title",className:"text-[13px] font-semibold text-foreground",children:r}),s.jsx("p",{className:"mt-0.5 text-[10px] text-muted-foreground",children:h.hint})]}),s.jsx("button",{type:"button",onClick:a,className:"inline-flex h-9 w-9 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-surface-2 hover:text-foreground","aria-label":h.close,children:s.jsx(Qn,{size:15})})]}),s.jsxs("div",{className:"flex min-h-11 shrink-0 items-center gap-2 border-b border-border/15 px-3 py-1.5",children:[s.jsx("button",{type:"button",disabled:m==="/",onClick:()=>x(PP(m)),className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-surface-2 hover:text-foreground disabled:opacity-30","aria-label":h.parent,children:s.jsx(g3,{size:14})}),s.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10.5px] text-foreground",title:m,children:m})]}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain py-1",children:s.jsx(QP,{rootPath:m,directoriesOnly:!0,onFileSelect:()=>{},onDirectoryRoot:x,selectedFilePath:t||null})}),s.jsxs("footer",{className:"flex shrink-0 items-center justify-end gap-2 border-t border-border/15 bg-surface-elevated px-3 py-3",children:[s.jsx("button",{type:"button",onClick:a,className:"min-h-10 rounded-lg bg-surface-2 px-4 text-[11px] font-medium text-foreground transition hover:bg-surface",children:h.cancel}),s.jsxs("button",{type:"button",onClick:()=>c(m),className:"inline-flex min-h-10 items-center gap-1.5 rounded-lg bg-primary px-4 text-[11px] font-semibold text-primary-foreground transition hover:bg-primary/90",children:[s.jsx(di,{size:13}),h.confirm]})]})]})]}),document.body):null}const OP=Object.freeze(Object.defineProperty({__proto__:null,DirectoryPickerDialog:Hf},Symbol.toStringTag,{value:"Module"})),y1="termdock:new-session-commands:v1",Yl="__saved_command__:";function xh(e){return[...new Set(Object.entries(e).filter(([t])=>t.startsWith(Yl)||t==="__custom__"||t==="__terminal__").map(([,t])=>t.trim()).filter(Boolean))]}function _0(){try{const e=JSON.parse(localStorage.getItem(y1)||"{}");return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(t=>typeof t[1]=="string"))}catch{return{}}}function FP({directories:e,tmuxAvailable:t,options:r,agents:n,selectedAgent:a,detecting:c,resumeHistory:l,resumeHistoryLoading:h,resumeHistoryPendingId:p,resumeHistoryError:m,onRefreshAgents:x,onSelectAgent:y,onLaunchAgent:w,onResumeHistory:v,onRemoveResumeHistory:k,onClose:L,onOptionsChange:E,additionalContent:R,footerActions:B,launchPending:W=!1,launchError:F}){const{t:U,locale:V}=zr(),Z=b.useRef(null);wd(Z,!0,L,()=>document.querySelector('[aria-controls="sidebar-launch-options"]'));const[le,xe]=b.useState(a),[fe,te]=b.useState(!1),[ke,$e]=b.useState(!1),[Y,Ae]=b.useState(_0),[lt,Ce]=b.useState(()=>xh(_0())),[ye,_e]=b.useState(null),[je,re]=b.useState("idle"),Pe=ke?"__custom__":le?.slug??"__terminal__",Se=le?.command??"",Ee=ke?Y.__custom__??Y.__terminal__??"":le?Y[Pe]??Se:"",Be=()=>{const Te=Ee.trim()||Se;if(!(ke&&!Te))try{const H={..._0(),[Pe]:Te};if(ke){for(const ae of xh(_0()))H[Yl+ae]=ae;H[Yl+Te]=Te}localStorage.setItem(y1,JSON.stringify(H)),Ce(xh(H)),ke&&_e(Te),re("saved")}catch{re("error")}},Ne=()=>{if(ye)try{const Te=_0();for(const[H,ae]of Object.entries(Te))(H.startsWith(Yl)||H==="__custom__"||H==="__terminal__")&&ae.trim()===ye&&delete Te[H];localStorage.setItem(y1,JSON.stringify(Te)),Ce(xh(Te)),Ae(H=>({...H,__custom__:""})),_e(null),re("idle")}catch{re("error")}},oe=()=>{const Te=Ee.trim()||Se;W||ke&&!Te||(Be(),w(le,Te))},He=b.useMemo(()=>[...new Set(e.filter(Boolean))].slice(0,5),[e]),rt=ke?ye?Yl+ye:"__custom__":le?.slug??"__terminal__",mt=Te=>{re("idle");const H=Te.startsWith(Yl)?Te.slice(Yl.length):null;_e(H),$e(Te==="__custom__"||H!==null),(H!==null||Te==="__custom__")&&Ae(ae=>({...ae,__custom__:H??""})),xe(n.find(ae=>ae.slug===Te)??null)},de=ke?ye??U("sidebar.customStartupCommand"):le?.displayName??"Terminal",Ye=a?.displayName??"Terminal",st=!ke&&(le===null?a===null:a?.slug===le.slug);b.useEffect(()=>{if(fe)return;const Te=H=>{H.target instanceof Node&&(Z.current?.contains(H.target)||H.target instanceof Element&&H.target.closest("[data-sidebar-composer-popover]")?.getAttribute("data-sidebar-composer-popover")===Z.current?.id||H.target instanceof Element&&H.target.closest('[aria-controls="sidebar-launch-options"]')||L())};return document.addEventListener("pointerdown",Te,!0),()=>document.removeEventListener("pointerdown",Te,!0)},[fe,L]);const Ie=Te=>{E({...r,cwd:Te}),te(!1)},We=Te=>new Intl.DateTimeFormat(V==="zh"?"zh-CN":"en",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(Te));return s.jsxs("section",{ref:Z,tabIndex:-1,"aria-busy":W,id:"sidebar-launch-options",className:`absolute inset-x-3 bottom-3 z-30 flex flex-col overflow-hidden rounded-2xl border border-border bg-surface shadow-[0_18px_50px_var(--app-shadow-strong),0_4px_14px_var(--app-shadow-soft)] animate-slide-down ${B?"max-h-[min(70svh,42rem,calc(100%_-_4.5rem))]":"max-h-[min(56svh,36rem,calc(100%_-_4.5rem))]"}`,"aria-label":U("sidebar.newSessionComposerTitle"),children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 px-3 py-1.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[s.jsx("span",{className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground",children:s.jsx(Bo,{size:14})}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-[12px] font-semibold text-foreground",children:U("sidebar.newSessionComposerTitle")})})]}),s.jsx("button",{type:"button",onClick:L,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-surface-2 hover:text-foreground","aria-label":U("common.close"),children:s.jsx(Qn,{size:14})})]}),s.jsxs("fieldset",{disabled:W,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain border-0 px-3 pb-1",children:[s.jsxs("div",{className:"flex min-h-11 items-center justify-between gap-3",children:[s.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:U("sidebar.sessionMode")}),s.jsx("div",{className:"grid grid-cols-2 gap-1 rounded-lg bg-surface p-0.5",children:["shell","tmux"].map(Te=>s.jsx("button",{type:"button",disabled:Te==="tmux"&&!t,onClick:()=>E({...r,mode:Te}),"aria-pressed":r.mode===Te,title:Te==="tmux"?U(t?"sidebar.tmuxKeepsRunning":"sidebar.newTmuxDisabled"):void 0,className:`min-h-9 rounded-md px-4 text-[11px] font-medium transition ${r.mode===Te?"bg-surface-2 text-foreground":"text-muted-foreground hover:text-foreground"} disabled:cursor-not-allowed disabled:opacity-40`,children:U(Te==="shell"?"sidebar.newShell":"sidebar.newTmux")},Te))})]}),s.jsxs("div",{className:"mt-1 flex items-center justify-between",children:[s.jsx("span",{className:"text-[11px] text-muted-foreground",children:U("sidebar.startupCommand")}),s.jsx("button",{type:"button",onClick:x,disabled:c,className:"inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface hover:text-foreground disabled:opacity-50",title:U("sidebar.detectAgents"),"aria-label":U("sidebar.detectAgents"),children:s.jsx(yn,{size:12,className:c?"animate-spin":""})})]}),s.jsxs("div",{role:"radiogroup","aria-label":U("sidebar.startupCommand"),className:"flex flex-wrap gap-1",children:[n.map(Te=>{const H=!ke&&le?.slug===Te.slug;return s.jsxs("button",{type:"button",role:"radio","aria-checked":H,onClick:()=>mt(Te.slug),className:`inline-flex min-h-7 items-center gap-1 rounded-md px-2 text-[10.5px] font-medium transition ${H?"bg-surface-2 text-foreground ring-1 ring-inset ring-primary/50":"bg-surface text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[s.jsx(Mc,{agent:Te,size:12}),s.jsx("span",{className:"max-w-[9rem] truncate",children:Te.displayName}),a?.slug===Te.slug&&s.jsx("span",{className:"ml-0.5 text-[9px] text-muted-foreground",children:U("sidebar.defaultAgent")})]},Te.slug)}),lt.map(Te=>{const H=ke&&ye===Te;return s.jsxs("button",{type:"button",role:"radio","aria-checked":H,onClick:()=>mt(Yl+Te),title:Te,className:`inline-flex min-h-7 items-center gap-1 rounded-md px-2 transition ${H?"bg-surface-2 text-foreground ring-1 ring-inset ring-primary/50":"bg-surface text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[s.jsx(Sc,{size:10,className:"shrink-0"}),s.jsx("span",{className:"max-w-[9rem] truncate font-mono text-[10px]",children:Te})]},Te)}),s.jsxs("button",{type:"button",role:"radio","aria-checked":rt==="__terminal__",onClick:()=>mt("__terminal__"),className:`inline-flex min-h-7 items-center gap-1 rounded-md px-2 text-[10.5px] font-medium transition ${rt==="__terminal__"?"bg-surface-2 text-foreground ring-1 ring-inset ring-primary/50":"bg-surface text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[s.jsx(Bo,{size:11,className:"shrink-0"}),s.jsx("span",{children:"Terminal"}),a===null&&s.jsx("span",{className:"ml-0.5 text-[9px] font-normal text-muted-foreground",children:U("sidebar.defaultAgent")})]}),s.jsxs("button",{type:"button",role:"radio","aria-checked":rt==="__custom__",onClick:()=>mt("__custom__"),className:`inline-flex min-h-7 items-center gap-0.5 rounded-md px-2 text-[10.5px] font-medium transition ${rt==="__custom__"?"bg-surface-2 text-foreground ring-1 ring-inset ring-primary/50":"bg-surface text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[s.jsx(Us,{size:10,className:"shrink-0"}),s.jsx("span",{children:U("sidebar.addStartupCommand")})]})]}),!st&&!ke&&s.jsxs("div",{className:"mt-1 flex min-h-8 items-center justify-between gap-2 px-0.5 text-[10px]",children:[s.jsx("span",{className:"truncate text-muted-foreground",children:U("sidebar.currentDefaultAgent",{name:Ye})}),s.jsx("button",{type:"button",onClick:()=>y(le),className:"relative z-10 shrink-0 rounded-md px-2 py-1.5 font-medium text-primary transition hover:bg-primary/10",children:U("sidebar.makeDefault")})]}),je==="error"&&s.jsx("p",{role:"alert",className:"text-[10px] text-destructive",children:U("sidebar.saveStartupCommandFailed")}),(le||ke)&&s.jsxs("details",{open:ke&&!ye||void 0,className:"group/command mt-0.5",children:[s.jsxs("summary",{className:"ml-auto flex min-h-8 w-fit cursor-pointer list-none items-center gap-1 rounded-md px-1 text-[10px] text-muted-foreground transition hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50 [&::-webkit-details-marker]:hidden",children:[U(ke&&!ye?"sidebar.customStartupCommand":"sidebar.changeStartupCommand"),s.jsx(ul,{size:11,className:"transition-transform group-open/command:rotate-180"})]}),s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsx("label",{htmlFor:"new-session-command",className:"sr-only",children:U("sidebar.startupCommand")}),le&&Ee!==Se&&s.jsx("button",{type:"button",onClick:()=>{Ae(Te=>({...Te,[Pe]:Se})),re("idle")},className:"min-h-8 rounded-md px-2 text-[10px] text-primary transition hover:bg-primary/10",children:U("sidebar.resetStartupCommand")})]}),s.jsx("input",{id:"new-session-command",value:Ee,onChange:Te=>{Ae(H=>({...H,[Pe]:Te.target.value})),re("idle")},placeholder:Se||U("sidebar.startupCommandPlaceholder"),autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,autoComplete:"off",className:"min-h-10 w-full rounded-lg border-0 bg-surface px-3 font-mono text-[16px] text-foreground outline-none ring-1 ring-inset ring-border transition focus:ring-primary/50 sm:text-[11px]"}),s.jsxs("div",{className:"mt-1 flex items-center justify-end gap-2","aria-live":"polite",children:[ke&&ye&&s.jsxs("button",{type:"button",onClick:Ne,className:"mr-auto inline-flex min-h-9 items-center gap-1 rounded-md px-2 text-[10px] text-muted-foreground transition hover:text-destructive","aria-label":U("sidebar.deleteStartupCommand"),children:[s.jsx(zs,{size:11}),U("sidebar.deleteStartupCommand")]}),s.jsx("button",{type:"button",onClick:Be,disabled:je==="saved"||ke&&!Ee.trim(),className:"min-h-8 rounded-md px-2 text-[10px] font-medium text-primary transition hover:bg-primary/10 disabled:cursor-default disabled:opacity-50",children:U(je==="saved"?"sidebar.startupCommandSaved":"sidebar.saveStartupCommand")})]}),s.jsx("p",{className:"mb-2 mt-1.5 px-0.5 text-[10px] leading-relaxed text-muted-foreground",children:U(le?"sidebar.agentStartupCommandHint":"sidebar.terminalStartupCommandHint")})]},ye??Pe),s.jsx("label",{htmlFor:"new-session-directory",className:"mt-2 block text-[11px] text-muted-foreground",children:U("sidebar.workingDirectory")}),s.jsxs("button",{id:"new-session-directory",type:"button","aria-haspopup":"dialog",onClick:()=>te(!0),className:"mt-1 flex min-h-11 w-full items-center gap-2 rounded-lg border border-transparent bg-surface px-2.5 font-mono text-[11px] text-foreground outline-none transition hover:bg-surface-2 focus-visible:border-primary",children:[s.jsx(jc,{size:12,className:"shrink-0 text-muted-foreground"}),s.jsx("span",{className:`min-w-0 flex-1 truncate text-left ${r.cwd?"":"text-muted-foreground"}`,children:r.cwd||U("sidebar.directoryPlaceholder")})]}),He.length>0&&s.jsx("div",{className:"mt-1.5 flex gap-1 overflow-x-auto pb-0.5","aria-label":U("sidebar.recentDirectories"),children:He.map(Te=>s.jsx("button",{type:"button",onClick:()=>Ie(Te),title:Te,className:"min-h-8 shrink-0 rounded-md px-2 text-[10px] text-muted-foreground transition hover:bg-surface hover:text-foreground",children:Pu(Te)||Te},Te))}),(l.length>0||m)&&s.jsxs("details",{className:"mt-1",children:[s.jsxs("summary",{className:"flex min-h-9 cursor-pointer list-none items-center gap-2 rounded-md px-1 text-[10px] font-medium uppercase tracking-[0.12em] text-muted-foreground transition hover:text-foreground",children:[s.jsx(Sc,{size:11}),s.jsx("span",{className:"flex-1",children:U("sidebar.resumeHistory")}),h&&s.jsx(In,{size:10,className:"animate-spin"}),l.length>0&&s.jsx("span",{className:"normal-case tracking-normal",children:U("sidebar.resumeHistoryCount",{n:l.length})}),s.jsx(ul,{size:11})]}),l.length>0&&s.jsx("div",{className:"mt-1 divide-y divide-border overflow-hidden rounded-lg border border-border bg-surface",children:l.slice(0,6).map(Te=>{const H=p===Te.id;return s.jsxs("div",{className:"group flex min-w-0 items-stretch transition hover:bg-surface-2",children:[s.jsxs("button",{type:"button",disabled:p!==null,onClick:()=>v(Te),className:"flex min-h-11 min-w-0 flex-1 items-center gap-2.5 px-2.5 py-2 text-left disabled:cursor-wait disabled:opacity-60","aria-label":U("sidebar.resumeHistoryAction",{title:Te.title}),children:[s.jsx("span",{className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:H?s.jsx(In,{size:13,className:"animate-spin"}):s.jsx(Mc,{agent:Te.agent,size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-[11px] font-semibold text-foreground",children:Te.title}),s.jsxs("span",{className:"block truncate text-[9.5px] text-muted-foreground",children:[Te.agent.displayName," · ",We(Te.closedAt)]})]}),s.jsx(C3,{size:12,className:"shrink-0 text-muted-foreground transition group-hover:text-primary"})]}),s.jsxs("button",{type:"button",disabled:p!==null,onClick:()=>k(Te.id),className:"relative inline-flex w-11 shrink-0 items-center justify-center text-muted-foreground transition hover:text-destructive disabled:opacity-40","aria-label":U("sidebar.resumeHistoryRemove",{title:Te.title}),children:[s.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-2 left-0 w-px bg-border opacity-30"}),s.jsx(zs,{size:12})]})]},Te.id)})}),m&&s.jsx("div",{role:"alert",className:"mt-1.5 px-1 text-[10px] text-destructive",children:m})]}),R]}),s.jsxs("div",{className:"shrink-0 bg-surface px-3 pb-3 pt-2",children:[F&&s.jsx("p",{role:"alert",className:"mb-2 text-[11px] leading-relaxed text-destructive",children:F}),s.jsxs("button",{type:"button",onClick:oe,disabled:W||ke&&!Ee.trim(),className:"flex min-h-11 w-full items-center justify-center gap-2 rounded-lg bg-primary px-3 text-[12px] font-semibold text-primary-foreground transition hover:brightness-110 active:scale-[0.99] disabled:cursor-not-allowed disabled:opacity-40","aria-label":U("sidebar.launchSessionWith",{name:de}),children:[W?s.jsx(In,{size:14}):le?s.jsx(Mc,{agent:le,size:15}):s.jsx(Bo,{size:14}),s.jsx("span",{className:"truncate",children:W?U("sidebar.sessionCreating"):U("sidebar.launchSessionWith",{name:de})})]}),B]}),s.jsx(Hf,{open:fe,initialPath:r.cwd?.trim()||He[0]||"/",title:U("sidebar.chooseDirectory"),onCancel:()=>te(!1),onConfirm:Ie})]})}const A6="termdock:new-session-agent:v1";function $P(){if(typeof window>"u")return null;try{const e=JSON.parse(window.localStorage.getItem(A6)||"null");return!e||typeof e.slug!="string"||typeof e.command!="string"?null:{slug:e.slug,command:e.command,displayName:typeof e.displayName=="string"?e.displayName:e.slug,capabilities:Array.isArray(e.capabilities)?e.capabilities.filter(t=>typeof t=="string"):void 0,accentColor:typeof e.accentColor=="string"?e.accentColor:"var(--muted-foreground)",icon:typeof e.icon=="string"?e.icon:null,isPlugin:e.isPlugin===!0,iconMode:e.iconMode==="native"?"native":e.iconMode==="mask"?"mask":void 0,iconVersion:typeof e.iconVersion=="number"?e.iconVersion:void 0}}catch{return null}}function dm(e){if(!(typeof window>"u"))try{window.localStorage.setItem(A6,JSON.stringify(e))}catch{}}function UP(e,t){return e?t.find(r=>r.slug===e)??null:null}function zP(){const[e,t]=b.useState($P),[r,n]=b.useState([]),[a,c]=b.useState(!0),l=b.useCallback(async()=>{c(!0);try{const[p,m]=await Promise.all([nc(),c3()]),x=UP(p.newSessionAgentSlug,m);n(m),t(x),dm(x)}finally{c(!1)}},[]);b.useEffect(()=>{const p=()=>{l().catch(()=>{})};if(performance.getEntriesByName("termdock:startup:initial-viewport-presented").length>0){p();return}return window.addEventListener("termdock:initial-viewport-presented",p,{once:!0}),()=>window.removeEventListener("termdock:initial-viewport-presented",p)},[l]);const h=b.useCallback(async p=>{const m=e;t(p),dm(p);try{await wa({newSessionAgentSlug:p?.slug??null})}catch(x){throw t(m),dm(m),x}},[e]);return{preference:e,agents:r,detecting:a,refresh:l,selectAgent:h}}function HP({groups:e,sessions:t,busy:r,onOpen:n,onSettings:a,onCreate:c}){const[l,h]=b.useState(""),p=e.filter(m=>!l.trim()||`${m.name} ${m.sessionIds.map(x=>t.find(y=>y.sessionId===x)?.name??"").join(" ")}`.toLowerCase().includes(l.trim().toLowerCase()));return s.jsxs("section",{"aria-label":"协作组列表",className:"space-y-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsx("p",{className:"text-xs leading-6 text-muted-foreground",children:"成员消息用于日常交流;看板用于目标、交付与验收。"}),s.jsxs("button",{type:"button",disabled:r,className:"inline-flex min-h-11 shrink-0 items-center gap-1.5 rounded-lg bg-primary px-3 text-xs font-medium text-primary-foreground disabled:opacity-40",onClick:c,children:[s.jsx(Us,{size:14}),"新建协作组"]})]}),(e.length>5||l)&&s.jsxs("label",{className:"relative block",children:[s.jsx("span",{className:"sr-only",children:"搜索协作组"}),s.jsx(El,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{type:"search",value:l,onChange:m=>h(m.target.value),placeholder:"搜索组名或成员",className:"min-h-11 w-full rounded-lg border border-border/20 bg-surface-2 py-2 pl-9 pr-3 text-xs text-foreground outline-none focus:border-primary/60"})]}),s.jsxs("div",{className:"divide-y divide-border/15 rounded-xl border border-border/15",children:[p.map(m=>{const x=m.sessionIds.flatMap(y=>{const w=t.find(v=>v.sessionId===y);return w?[w]:[]});return s.jsxs("article",{"aria-label":m.name,className:"p-3 sm:flex sm:items-center sm:gap-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h3",{className:"break-words text-sm font-medium leading-6 text-foreground",children:m.name}),s.jsx("p",{className:"mt-1 break-words text-[11px] leading-5 text-muted-foreground",children:m.sessionIds.length?`${m.sessionIds.length} 位成员${x.length?` · ${x.slice(0,2).map(y=>gu(y,x)).join("、")}${x.length>2?"等":""}`:""}`:"尚未添加成员,可以稍后配置"})]}),s.jsxs("div",{className:"mt-2 flex shrink-0 items-center gap-1 sm:mt-0",children:[s.jsxs("button",{type:"button","aria-label":`成员消息:${m.name}`,disabled:r,className:"inline-flex min-h-11 items-center justify-center gap-1.5 rounded-lg bg-surface-2 px-3 text-xs text-foreground hover:bg-surface-elevated disabled:opacity-40",onClick:()=>n(m.id,"messages"),children:[s.jsx(Td,{size:14}),"成员消息"]}),s.jsxs("button",{type:"button","aria-label":`看板:${m.name}`,disabled:r,className:"inline-flex min-h-11 items-center justify-center gap-1.5 rounded-lg px-3 text-xs text-muted-foreground hover:bg-surface-2 disabled:opacity-40",onClick:()=>n(m.id,"tasks"),children:[s.jsx(aT,{size:14}),"看板"]}),s.jsx("button",{type:"button","aria-label":`设置:${m.name}`,title:"组设置",disabled:r,className:"inline-flex min-h-11 min-w-11 items-center justify-center rounded-lg text-muted-foreground hover:bg-surface-2 disabled:opacity-40",onClick:y=>a(m.id,y.currentTarget),children:s.jsx(G0,{size:14})})]})]},m.id)}),!p.length&&s.jsx("p",{className:"px-3 py-6 text-xs text-muted-foreground",children:"没有匹配的协作组,试试其他名称。"})]})]})}const Ac="min-h-11 w-full rounded-lg border border-border/20 bg-surface px-3 py-2 text-xs text-foreground outline-none focus:border-primary",bh="inline-flex min-h-11 items-center justify-center gap-2 rounded-lg px-3 text-xs disabled:opacity-40",yh=e=>({profiles:e.launchProfiles??[],defaultId:e.defaultLaunchProfileId??"",group:e}),hm=new Map,k0=e=>JSON.stringify(e.profiles)!==JSON.stringify(e.group.launchProfiles??[])||e.defaultId!==(e.group.defaultLaunchProfileId??"");function WP({group:e,value:t,onChange:r,disabled:n}){if(!e.launchProfiles?.length&&!t)return null;const a=e.launchProfiles?.find(c=>c.id===t);return s.jsxs("div",{className:"mt-3 space-y-1",children:[s.jsxs("label",{className:"block space-y-1 text-xs text-muted-foreground",children:["启动方案",s.jsxs("select",{"aria-label":"启动方案",className:Ac,value:t,disabled:n,onChange:c=>r(c.target.value),children:[s.jsx("option",{value:"",children:"Agent 默认命令"}),e.launchProfiles?.map(c=>s.jsx("option",{value:c.id,children:c.name},c.id))]})]}),a&&s.jsxs("p",{className:"whitespace-pre-wrap break-words text-xs leading-5 text-muted-foreground",children:[a.notes||"未填写使用备注",s.jsx("code",{className:"block break-all",children:a.command})]}),t&&!a&&s.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"原方案已删除,请重新选择。"})]})}function GP({group:e,agents:t,busy:r,setBusy:n,refresh:a}){const c=`${window.location.origin}:${e.id}`,[l,h]=b.useState(()=>hm.get(c)??yh(e)),p=b.useRef(l);p.current=l;const[m,x]=b.useState(l.profiles[0]?.id??""),[y,w]=b.useState(null),[v,k]=b.useState(""),L=(U,V=!0)=>{p.current=U,h(U),k0(U)?hm.set(c,U):hm.delete(c),V&&k("")};b.useEffect(()=>{!k0(p.current)&&e.updatedAt>=p.current.group.updatedAt&&L(yh(e),!1)},[e.updatedAt]);const E=l.profiles.find(U=>U.id===m),R=U=>L({...l,profiles:l.profiles.map(V=>V.id===m?{...V,...U}:V)}),B=l.profiles.every(U=>U.name.trim()&&U.agentSlug&&U.command.trim()&&!/[\x00-\x1f\x7f]/.test(U.command)),W=()=>{const U=t[0],V={id:`profile-${crypto.randomUUID()}`,name:"",agentSlug:U?.slug??"",command:U?.command??"",notes:""};L({...l,profiles:[...l.profiles,V]}),x(V.id)},F=async()=>{if(!(r||!B||!k0(l))){n("launch-profiles"),w(null),k("");try{const{group:U}=await Zl({id:e.id,name:l.group.name,sessionIds:l.group.sessionIds,expectedUpdatedAt:l.group.updatedAt,launchProfiles:l.profiles,defaultLaunchProfileId:l.defaultId||null});L(yh(U)),k("启动方案已保存。新会话使用所选方案,正在运行的成员保持原配置。"),await a()}catch(U){w(U instanceof Error?U.message:"保存失败")}finally{n(null)}}};return s.jsxs("details",{className:"mt-3 border-t border-border/15 pt-2",children:[s.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-xs font-medium text-foreground",children:["Agent 启动方案 · ",l.profiles.length," 个",k0(l)?" · 未保存":""]}),s.jsxs("section",{"aria-label":"Agent 启动方案",className:"space-y-3",children:[s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"保存不同模型和参数的启动命令,填写适用场景,让协调者按备注选择。保存配置不会启动 Agent。"}),s.jsxs("fieldset",{disabled:!!r,className:"space-y-3",children:[s.jsxs("label",{className:"block space-y-1 text-xs text-muted-foreground",children:["默认启动方案",s.jsxs("select",{"aria-label":"默认启动方案",className:Ac,value:l.defaultId,onChange:U=>L({...l,defaultId:U.target.value}),children:[s.jsx("option",{value:"",children:"使用 Agent 默认命令"}),l.profiles.map(U=>s.jsx("option",{value:U.id,children:U.name||"未命名方案"},U.id))]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{className:"min-w-0 flex-1 text-xs text-muted-foreground",children:["编辑方案",s.jsxs("select",{"aria-label":"编辑方案",className:`${Ac} mt-1`,value:m,onChange:U=>x(U.target.value),children:[s.jsx("option",{value:"",children:"选择方案"}),l.profiles.map(U=>s.jsx("option",{value:U.id,children:U.name||"未命名方案"},U.id))]})]}),s.jsxs("button",{type:"button",className:`${bh} self-end bg-surface text-foreground`,disabled:l.profiles.length>=20,onClick:W,children:[s.jsx(Us,{size:14}),"新增方案"]})]}),E?s.jsxs("div",{className:"space-y-3 rounded-lg border border-border/20 p-3",children:[s.jsxs("label",{className:"block space-y-1 text-xs text-muted-foreground",children:["方案名称",s.jsx("input",{className:Ac,value:E.name,maxLength:100,onChange:U=>R({name:U.target.value}),placeholder:"例如:快速排查、深度实现"})]}),s.jsxs("label",{className:"block space-y-1 text-xs text-muted-foreground",children:["Agent 类型",s.jsxs("select",{"aria-label":"Agent 类型",className:Ac,value:E.agentSlug,onChange:U=>R({agentSlug:U.target.value,command:t.find(V=>V.slug===U.target.value)?.command??""}),children:[!t.some(U=>U.slug===E.agentSlug)&&s.jsxs("option",{value:E.agentSlug,children:[E.agentSlug||"选择 Agent","(当前不可用)"]}),t.map(U=>s.jsx("option",{value:U.slug,children:U.displayName},U.slug))]})]}),s.jsxs("label",{className:"block space-y-1 text-xs text-muted-foreground",children:["启动命令",s.jsx("input",{className:`${Ac} font-mono`,value:E.command,maxLength:4096,onChange:U=>R({command:U.target.value}),placeholder:"填写完整命令,包括模型和启动参数"})]}),s.jsxs("label",{className:"block space-y-1 text-xs text-muted-foreground",children:["使用备注",s.jsx("textarea",{"aria-label":"使用备注",className:`${Ac} min-h-24 resize-y`,value:E.notes,maxLength:2e3,onChange:U=>R({notes:U.target.value}),placeholder:"适合哪些任务、何时不要使用;协调者会读取这些备注。"})]}),s.jsxs("details",{className:"text-[11px] text-muted-foreground",children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-3",children:"CLI 方案标识"}),s.jsx("code",{className:"break-all",children:E.id})]}),s.jsxs("button",{type:"button",className:`${bh} text-destructive hover:bg-destructive/10`,onClick:()=>{const U=l.profiles.filter(V=>V.id!==m);L({...l,profiles:U,defaultId:l.defaultId===m?"":l.defaultId}),x(U[0]?.id??"")},children:[s.jsx(zs,{size:14}),"移除方案(保存后生效)"]})]}):s.jsx("p",{className:"text-xs text-muted-foreground",children:"尚未选择方案。新增后可填写模型、参数和备注。"})]}),y&&s.jsxs("p",{role:"alert",className:"text-xs leading-5 text-destructive",children:[y,"。草稿已保留;重新载入会放弃草稿。"]}),v&&s.jsx("p",{role:"status",className:"text-xs leading-5 text-primary",children:v}),s.jsxs("div",{className:"flex flex-wrap justify-between gap-2",children:[s.jsx("button",{type:"button",className:`${bh} bg-surface text-muted-foreground`,disabled:!!r,onClick:()=>{L(yh(e)),x(e.launchProfiles?.[0]?.id??""),w(null)},children:"重新载入(放弃方案草稿)"}),s.jsx("button",{type:"button",disabled:!!r||!B||!k0(l),className:`${bh} bg-primary text-primary-foreground`,onClick:()=>{F()},children:r==="launch-profiles"?"保存中…":"保存启动方案"})]})]})]})}function VP(e,t){const r=t.events.filter(p=>p.kind==="retry"&&!e.events.some(m=>m.id===p.id)).at(-1),n=new Set(e.deliveries.filter(p=>p.status==="delivered").map(p=>p.id)),a=new Set(e.outbox.filter(p=>!n.has(p.id)).map(p=>p.id)),c=r&&t.deliveries.some(p=>a.has(p.id)&&p.status==="delivered"&&p.deliveredAt!==null&&p.deliveredAt>=r.createdAt);let l=c?"重试请求已保存,匹配本次请求的投递已写入终端。":"重试请求已保存,服务将重新检查现有投递与协调条件。";!t.outbox.length&&!c&&(l+=" 当前没有待重试的投递记录。"),t.workflow?.paused&&(l+=" 后续自动安排仍已暂停。");const h=t.attempts.find(p=>p.id===t.activeAttemptId)?.report;return h&&["blocked","failed"].includes(h.status)&&(l+=" 成员原报告仍保留;请补齐条件并通知成员,收到新的明确回复后更新报告。"),l}function qP(e,t){const r=Math.floor(Math.max(0,t-e)/6e4);return r<1?"刚刚更新":r<60?`${r} 分钟前更新`:r<1440?`${Math.floor(r/60)} 小时前更新`:r<10080?`${Math.floor(r/1440)} 天前更新`:`${new Date(e).toLocaleDateString([],{month:"numeric",day:"numeric"})} 更新`}function cb(e){return new Date(e).toLocaleString([],{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1})}function Tf({task:e,now:t,compact:r=!1}){const n=Jv(e),a=Number.isFinite(e.updatedAt)&&e.updatedAt>0&&Number.isFinite(new Date(e.updatedAt).getTime());return r&&!n?null:s.jsxs("span",{className:"mt-1 block space-y-1 text-[11px] leading-5 text-muted-foreground",children:[s.jsx("span",{className:"block break-words",children:n?s.jsxs(s.Fragment,{children:["最近明确报告:",n.label," · ",n.createdAt===null?"报告时间未提供":s.jsx("time",{dateTime:new Date(n.createdAt).toISOString(),title:new Date(n.createdAt).toLocaleString(),children:cb(n.createdAt)})]}):"暂无明确报告"}),!r&&s.jsx("span",{className:"block",children:a?s.jsxs(s.Fragment,{children:["记录更新:",s.jsx("time",{dateTime:new Date(e.updatedAt).toISOString(),title:t===void 0?new Date(e.updatedAt).toLocaleString():qP(e.updatedAt,t),children:cb(e.updatedAt)})]}):"记录更新时间未提供"})]})}function T6(e,t){const r=e.trim().split(/\n\s*\n/),n=l=>{const h=r.findIndex(m=>l.test(m.trim()));return h<0?"":r[h].trim().replace(l,"").trim()||r[h+1]?.trim()||""},a=t?.trim()||n(/^(?:#{1,6}\s*)?(?:结论|Summary|Conclusion|结果摘要)(?:[::]\s*|\s*$)/i),c=n(/^(?:#{1,6}\s*)?(?:限制与变更|限制|Limitations)(?:[::]\s*|\s*$)/i);return{summary:a||e.trim(),limitations:a?c:"",condensed:!!a&&a!==e.trim(),explicit:!!t?.trim()}}function Uh({inputKey:e,paneKey:t,label:r,value:n,onChange:a,active:c=!0,disabled:l=!1,required:h,autoFocus:p,placeholder:m,className:x,onUploadChange:y}){const w=b.useId(),v=b.useRef(null),k=b.useRef(null),L=b.useRef({value:n,onChange:a,onUploadChange:y});L.current={value:n,onChange:a,onUploadChange:y};const[E,R]=b.useState(0),[B,W]=b.useState(""),F=b.useRef(Promise.resolve());b.useEffect(()=>{const te=v.current;te&&te.setSelectionRange(te.value.length,te.value.length)},[e]);const U=()=>({value:L.current.value,start:v.current?.selectionStart??n.length,end:v.current?.selectionEnd??n.length}),V=(te,ke=U())=>{L.current.onChange($e=>$e!==ke.value?$e+($e&&!/\s$/.test($e)?`
131
131
  `:"")+te:$e.slice(0,ke.start)+te+$e.slice(ke.end))};b.useEffect(()=>{if(!c)return;const te=u3(ke=>V(ke.replace(/\r\n?/g,`
132
- `)),e,!!t,t);return t||V0(e),te},[c,e,t]);const Z=()=>{const te=rd();return`${location.origin}:${te?.targetPeerId??""}:${te?.serviceOrigin??""}`},le=te=>{const ke=U(),$e=Z(),Y=L.current.onUploadChange;W(""),R(Ae=>Ae+1),Y?.(1),F.current=F.current.then(async()=>{try{if($e!==Z())throw new Error("目标服务已切换,请重新添加附件");const Ae=await te();if($e!==Z())throw new Error("目标服务已切换,请重新添加附件");Array.isArray(Ae)?V(Ae.map(Tc).join(" ")+" ",ke):Ae&&V(Ae,ke)}catch(Ae){const lt=Ae instanceof Error?Ae.message:"附件准备失败,请重试";W(lt.includes("Upload did not return")?"附件上传未返回完整路径,请重试":lt)}finally{R(Ae=>Ae-1),Y?.(-1)}})},xe=async te=>te.length===1&&te[0].type.startsWith("image/")?[await Q3(te[0])]:F3(te),fe=te=>{const ke=te.clipboardData.files.length?Array.from(te.clipboardData.files):Array.from(te.clipboardData.items??[]).filter(Ae=>Ae.kind==="file").map(Ae=>Ae.getAsFile()).filter(Ae=>Ae!==null),$e=te.clipboardData.getData("text/plain"),Y=lo();!Y?.readClipboardFiles&&!ke.length&&$e||!Y&&!ke.length&&typeof navigator.clipboard?.read!="function"||(te.preventDefault(),le(async()=>{const Ae=Z();let lt;if(Y?.readClipboardFiles)try{const Ce=await O3();if(Ce.paths.length||Ce.files.length)return[...Ce.paths,...await xe(Ce.files)]}catch(Ce){if(Ce instanceof Z0)throw Ce;lt=Ce}if(Ae!==Z())throw new Error("目标服务已切换,请重新粘贴");if(ke.length)return xe(ke);if($e)return $e;if(typeof navigator.clipboard?.read=="function"){const Ce=await navigator.clipboard.read(),ye={read:async()=>Ce},_e=await P3(ye);if(_e.length)return xe(_e);const je=await ef(ye);if(je)return xe([je]);for(const re of Ce)if(re.types.includes("text/plain"))return(await re.getType("text/plain")).text()}else{const Ce=await ef();if(Ce)return xe([Ce])}if(lt)throw lt;return null}))};return s.jsxs("div",{className:"space-y-1.5",onFocusCapture:()=>V0(e),onPointerDownCapture:()=>V0(e),children:[s.jsx("label",{htmlFor:w,className:"block text-xs text-muted-foreground",children:r}),s.jsx("textarea",{ref:v,id:w,value:n,required:h,disabled:l,autoFocus:p,"aria-describedby":E||B?`${w}-status`:void 0,placeholder:m,className:x,onChange:te=>a(te.target.value),onPaste:fe,onDragOver:te=>{!l&&te.dataTransfer.types.includes("Files")&&te.preventDefault()},onDrop:te=>{const ke=Array.from(te.dataTransfer.files);!ke.length||l||(te.preventDefault(),te.stopPropagation(),le(()=>xe(ke)))}}),s.jsxs("div",{className:"flex min-h-9 items-center gap-2",children:[s.jsx("input",{ref:k,type:"file",multiple:!0,hidden:!0,"aria-label":`选择附件:${r}`,onChange:te=>{const ke=Array.from(te.target.files??[]);te.target.value="",ke.length&&le(()=>xe(ke))}}),s.jsxs("button",{type:"button","aria-label":`添加附件:${r}`,title:"添加附件",disabled:l,className:"inline-flex min-h-9 shrink-0 items-center gap-1.5 rounded-lg px-2 text-xs text-muted-foreground hover:bg-surface-2 disabled:opacity-40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",onClick:()=>k.current?.click(),children:[s.jsx(ET,{size:14}),"附件"]}),E>0?s.jsxs("span",{id:`${w}-status`,role:"status",className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[s.jsx(yn,{size:12,className:"animate-spin"}),"正在准备附件…"]}):B?s.jsx("span",{id:`${w}-status`,role:"alert",className:"break-words text-xs text-destructive",children:B}):s.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:"可粘贴图片、文件或拖入附件"})]})]})}function ub(e,t=!1,r=""){const n=new Map(e.map(h=>[h.id,h])),a=h=>n.get(h.parentTaskId??h.workflow?.rootTaskId??""),c=h=>{const p=[];let m=h;for(;;){const x=p.findIndex(w=>w.id===m.id);if(x!==-1)return p.slice(x).sort((w,v)=>w.id.localeCompare(v.id))[0];p.push(m);const y=a(m);if(!y||y.status==="closed"&&m.status!=="closed")return m;m=y}},l=new Map(e.map(h=>[h.id,c(h).id]));return e.filter(h=>t||!!r.trim()||l.get(h.id)===h.id).map(h=>{const p=t||r.trim()?[]:e.filter(y=>y.id!==h.id&&l.get(y.id)===h.id&&y.status!=="closed"),m=h.status==="open"&&!$i(h)?p.find(y=>y.decisions.some(w=>w.status==="pending"))??p.find(y=>$i(y)||y.workflow?.paused):void 0,x=p.filter(y=>$i(y)||y.workflow?.paused).length;return{task:h,children:p,attention:m,attentionCount:x,rootId:l.get(h.id)}})}function C6(e,t=[]){const r=Qc(e),n={已验收:"已完成 · 你已验收",独立评审通过:"执行交付已评审",需要你回答:"请回答成员的问题",需要你确认方案:"请确认方案",等待你验收:"请查看结果并验收",成员报告受阻:"需要补充条件",成员报告失败:"成员报告执行失败",成员确认接手:"已接手 · 等待后续报告",成员报告进行中:"成员报告:进行中",等待独立评审:"结果已提交 · 等待评审","评审通过 · 等待接续":"交付已评审 · 等待接续","已要求跟进 · 等待新结果":"已提出跟进 · 等待新结果"};return e.status==="open"&&t.length&&!$i(e)&&!e.artifacts.some(a=>a.kind==="result"&&a.attemptId===e.activeAttemptId)?t.every(a=>a.status==="accepted")?"执行交付已评审 · 等待总结果":"目标未完成 · 执行交付待齐":n[r]??r}function YP({task:e,children:t,onSelect:r}){const n=new Map(t.map(m=>[m.id,m])),a=(t.length?t:e.children??[]).filter(m=>m.status!=="closed");if(!a.length)return null;const c=(m,x)=>{const y=n.get(m);return y&&($i(y)||y.workflow?.paused)?0:x?2:1},l=[...a].sort((m,x)=>c(m.id,m.status==="accepted")-c(x.id,x.status==="accepted")||(n.get(x.id)?.updatedAt??0)-(n.get(m.id)?.updatedAt??0)),h=a.filter(m=>m.status==="accepted").length,p=m=>{const x=n.get(m.id),y=m.status==="accepted",w=x&&($i(x)||x.workflow?.paused),v=x?C6(x):y?m.completionMode==="reviewed"?"执行交付已评审":"已验收":"等待报告",k=y?Iu:Eu;return s.jsxs("button",{type:"button",className:"flex min-h-11 w-full items-start gap-2 rounded-lg px-1 py-2 text-left hover:bg-surface-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",onClick:()=>r(m.id),children:[s.jsx(k,{size:14,className:`mt-0.5 shrink-0 ${y||w?"text-primary":"text-muted-foreground"}`}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{title:m.title,className:"block line-clamp-2 break-words text-xs leading-5 text-foreground",children:m.title}),s.jsx("span",{className:`block text-[11px] leading-5 ${w?"text-primary":"text-muted-foreground"}`,children:v})]}),s.jsx(hi,{size:12,className:"mt-1 shrink-0 text-muted-foreground"})]},m.id)};return s.jsxs("section",{"aria-label":"执行事项",className:"mx-4 border-t border-border/15 py-2",children:[s.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:"执行事项"}),s.jsxs("span",{children:[h,"/",a.length," 项已完成"]})]}),l.slice(0,3).map(p),l.length>3&&s.jsxs("details",{children:[s.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-[11px] text-muted-foreground",children:["展开其余 ",l.length-3," 项"]}),l.slice(3).map(p)]})]})}function db(e){return e.status!=="open"?"done":$i(e)||e.workflow?.paused?"attention":e.activeAttemptId?"running":"backlog"}const Al=[{id:"backlog",label:"待开始",icon:Eu,hint:"等待分派或依赖完成"},{id:"running",label:"执行中",icon:Zh,hint:"分派后的任务会出现在这里"},{id:"attention",label:"需要你",icon:Td,hint:"问题、方案与验收都在这里"},{id:"done",label:"已完成",icon:Iu,hint:"验收后的结果会保留在这里"}];function ZP({tasks:e,selectedId:t,onSelect:r,name:n,storage:a,action:c,navigation:l,settings:h}){const p=b.useRef(null),m=b.useRef(null),x=b.useRef("backlog"),y=b.useRef(0),w=b.useRef(null),[v,k]=b.useState(Date.now);b.useEffect(()=>{const H=setInterval(()=>k(Date.now()),3e4);return()=>clearInterval(H)},[]);const[L,E]=b.useState(!1);b.useEffect(()=>{const H=new ResizeObserver(ae=>{const be=ae[0].contentRect.width;E(be>=760),be!==y.current&&be<760&&m.current&&(m.current.scrollLeft=Al.findIndex(Ze=>Ze.id===x.current)*m.current.clientWidth),y.current=be});return p.current&&H.observe(p.current),()=>H.disconnect()},[]);const[R]=b.useState(()=>{try{return JSON.parse(localStorage.getItem(`${a}:board`)??"null")}catch{return null}}),[B,W]=b.useState(()=>{if(Al.some(be=>be.id===R?.lane))return R.lane;const ae=ub(e,R?.showSteps===!0,R?.query??"").map(be=>be.attention?"attention":db(be.task));return ae.includes("attention")?"attention":ae.includes("running")?"running":ae.includes("backlog")?"backlog":"done"});x.current=B;function F(H,ae=!0){W(H);const be=m.current;if(!be||!be.clientWidth)return;w.current=H;const Ze=Al.findIndex(Tt=>Tt.id===H)*be.clientWidth,Je=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;be.scrollTo?be.scrollTo({left:Ze,behavior:ae&&!Je?"smooth":"auto"}):be.scrollLeft=Ze}b.useEffect(()=>{L||F(x.current,!1)},[L]);const[U,V]=b.useState(typeof R?.scope=="string"?R.scope:"all"),[Z,le]=b.useState(typeof R?.query=="string"?R.query:""),[xe,fe]=b.useState(R?.closed===!0),[te,ke]=b.useState(R?.showSteps===!0),[$e,Y]=b.useState(!!R?.query),[Ae,lt]=b.useState(!1),[Ce,ye]=b.useState(!1),_e=b.useRef(null),je=b.useRef(null);b.useEffect(()=>{if(!Ce)return;_e.current?.querySelector('[aria-label="看板更多操作"] button')?.focus();const H=be=>{_e.current?.contains(be.target)||ye(!1)},ae=be=>{be.key==="Escape"&&(be.preventDefault(),be.stopPropagation(),ye(!1),je.current?.focus())};return document.addEventListener("pointerdown",H),document.addEventListener("keydown",ae),()=>{document.removeEventListener("pointerdown",H),document.removeEventListener("keydown",ae)}},[Ce]);const re=b.useRef(null),Pe=b.useRef(null),Se=b.useRef(null),Ee=b.useRef(null);b.useEffect(()=>{$e&&re.current?.focus()},[$e]),b.useEffect(()=>{if(!Ae)return;Se.current?.querySelector("select")?.focus();const H=be=>{Se.current?.contains(be.target)||lt(!1)},ae=be=>{be.key==="Escape"&&(be.preventDefault(),be.stopPropagation(),lt(!1),(L?Ee:je).current?.focus())};return document.addEventListener("pointerdown",H),document.addEventListener("keydown",ae),()=>{document.removeEventListener("pointerdown",H),document.removeEventListener("keydown",ae)}},[Ae]),b.useEffect(()=>{try{localStorage.setItem(`${a}:board`,JSON.stringify({lane:B,scope:U,query:Z,closed:xe,showSteps:te}))}catch{}},[a,B,U,Z,xe,te]);const Be=e.filter(H=>H.workflow?.kind==="goal"),Ne=ub(e,te,Z),oe=new Map(Ne.map(H=>[H.task.id,H])),He=H=>oe.get(H.id)?.attention?"attention":db(H),rt=t?Ne.find(H=>H.task.id===t||H.children.some(ae=>ae.id===t)):void 0,mt=rt?He(rt.task):void 0;b.useEffect(()=>{mt&&F(mt,!1)},[t,mt]);const de=Ne.map(H=>H.task).filter(H=>(xe||H.status!=="closed")&&(U==="all"||H.id===U||oe.get(H.id)?.rootId===U)&&(!Z.trim()||`${H.title} ${H.spec} ${H.attempts.map(ae=>n(H,ae.assignee)).join(" ")}`.toLocaleLowerCase().includes(Z.trim().toLocaleLowerCase()))),Ye=+(U!=="all")+Number(xe)+Number(te),st="inline-flex min-h-11 min-w-11 shrink-0 items-center justify-center gap-1.5 rounded-lg px-2 text-xs text-muted-foreground hover:bg-surface-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",Ie="flex min-h-11 w-full items-center justify-start gap-3 rounded-lg px-3 text-left text-sm font-medium text-foreground hover:bg-surface-2 active:bg-surface-elevated focus-visible:bg-surface-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",We=s.jsxs("div",{className:`relative flex min-w-0 items-center ${L?"flex-1 max-w-[240px]":"w-full"}`,children:[s.jsx("span",{className:"sr-only",children:"搜索任务"}),s.jsx(El,{"aria-hidden":"true",size:15,className:"pointer-events-none absolute left-3 text-muted-foreground"}),s.jsx("input",{ref:re,"aria-label":"搜索任务",type:"search",value:Z,onChange:H=>le(H.target.value),onKeyDown:H=>{H.key==="Escape"&&(H.preventDefault(),H.stopPropagation(),Z?le(""):(Y(!1),requestAnimationFrame(()=>(L?Pe:je).current?.focus())))},placeholder:"搜索任务或负责人",className:"min-h-11 w-full rounded-lg border border-border/20 bg-transparent pl-9 pr-9 text-xs outline-none focus:border-primary"}),s.jsx("button",{type:"button","aria-label":"关闭搜索",className:"absolute right-0 flex min-h-11 w-9 items-center justify-center text-muted-foreground",onClick:()=>{le(""),Y(!1),requestAnimationFrame(()=>(L?Pe:je).current?.focus())},children:s.jsx(Qn,{size:14})})]}),Te=s.jsxs("div",{"aria-label":"任务筛选",className:"absolute right-0 top-full z-30 mt-1 w-64 space-y-3 rounded-xl border border-border/30 bg-surface p-3 shadow-xl",children:[s.jsxs("label",{className:"block space-y-1 text-xs text-muted-foreground",children:[s.jsx("span",{children:"目标范围"}),s.jsxs("select",{"aria-label":"按目标查看",value:U,onChange:H=>V(H.target.value),className:"min-h-11 w-full rounded-lg border border-border/20 bg-surface-2 px-3 text-xs text-foreground",children:[s.jsx("option",{value:"all",children:"所有目标"}),Be.map(H=>s.jsx("option",{value:H.id,children:H.title},H.id))]})]}),s.jsxs("label",{className:"flex min-h-11 items-center gap-2 text-xs text-muted-foreground",children:[s.jsx("input",{type:"checkbox",checked:xe,onChange:H=>fe(H.target.checked)}),"含已关闭"]}),s.jsxs("label",{className:"flex min-h-11 items-center gap-2 text-xs text-muted-foreground",children:[s.jsx("input",{type:"checkbox",checked:te,onChange:H=>ke(H.target.checked)}),"显示执行子任务"]}),Ye>0&&s.jsx("button",{type:"button",className:"min-h-11 w-full rounded-lg text-xs text-primary hover:bg-surface-2",onClick:()=>{V("all"),fe(!1),ke(!1)},children:"清除筛选"})]});return s.jsxs("div",{ref:p,className:"flex min-h-0 min-w-0 flex-1 flex-col gap-2",children:[s.jsx("div",{ref:L?void 0:Se,"aria-label":"看板工具栏",className:"relative z-20 flex shrink-0 flex-wrap items-center gap-1.5 border-b border-border/15 pb-2",children:L?s.jsxs(s.Fragment,{children:[l&&s.jsx("div",{className:"flex min-w-0 items-center mr-auto",children:l}),$e?We:s.jsx("button",{ref:Pe,type:"button","aria-label":"搜索任务",title:"搜索任务",className:`${st} ${l?"":"ml-auto"}`,onClick:()=>Y(!0),children:s.jsx(El,{size:16})}),s.jsxs("div",{ref:Se,className:"relative shrink-0",children:[s.jsxs("button",{ref:Ee,type:"button","aria-label":Ye?`筛选任务,${Ye} 项已启用`:"筛选任务","aria-expanded":Ae,className:`${st} ${Ye?"text-primary":""}`,onClick:()=>lt(H=>!H),children:[s.jsx(Nm,{size:15}),s.jsx("span",{children:"筛选"}),Ye>0&&s.jsx("span",{className:"tabular-nums text-primary",children:Ye})]}),Ae&&Te]}),h,c&&s.jsx("div",{className:"shrink-0",children:c})]}):s.jsxs(s.Fragment,{children:[l&&s.jsx("div",{className:"mr-auto flex min-w-0 items-center",children:l}),c&&s.jsx("div",{className:"shrink-0",children:c}),s.jsxs("div",{ref:_e,className:"relative shrink-0",children:[s.jsxs("button",{ref:je,type:"button","aria-label":"更多看板操作","aria-expanded":Ce,className:`${st} ${Ce?"bg-surface-2 text-foreground":Ye||Z.trim()?"text-primary":""}`,onClick:()=>{ye(H=>!H),lt(!1)},children:[s.jsx(Qo,{size:18}),Ye>0&&s.jsx("span",{className:"text-[10px]",children:Ye})]}),Ce&&s.jsxs("div",{role:"group","aria-label":"看板更多操作",className:"absolute right-0 top-full z-30 mt-2 flex w-52 max-w-[calc(100vw-2rem)] flex-col gap-0.5 rounded-xl border border-border/40 bg-surface p-1.5 shadow-xl",onClick:()=>ye(!1),children:[s.jsxs("button",{ref:Pe,type:"button","aria-label":"搜索任务",className:Ie,onClick:()=>Y(!0),children:[s.jsx(El,{size:18,className:"shrink-0 text-muted-foreground"}),"搜索任务"]}),s.jsxs("button",{ref:Ee,type:"button","aria-label":Ye?`筛选任务,${Ye} 项已启用`:"筛选任务",className:Ie,onClick:()=>lt(!0),children:[s.jsx(Nm,{size:18,className:"shrink-0 text-muted-foreground"}),"筛选任务",Ye>0&&s.jsx("span",{className:"ml-auto rounded bg-primary/10 px-1.5 text-xs tabular-nums text-primary",children:Ye})]}),h&&s.jsx("div",{className:"mt-1 border-t border-border/30 pt-1 [&>button]:min-h-11 [&>button]:w-full [&>button]:justify-start [&>button]:gap-3 [&>button]:px-3 [&>button]:text-left [&>button]:text-sm [&>button]:text-foreground [&>button:hover]:bg-surface-2 [&>button:active]:bg-surface-elevated [&>button:focus-visible]:bg-surface-2 [&>button>svg]:h-[18px] [&>button>svg]:w-[18px] [&>button>svg]:shrink-0 [&>button>svg]:text-muted-foreground [&>button>span]:not-sr-only",children:h})]})]}),$e&&We,Ae&&Te]})}),s.jsx("p",{className:"px-1 text-[11px] leading-5 text-muted-foreground",children:te?"包含执行子任务,可在筛选中切回目标视图。":"每张卡片对应一个目标,待完成事项和最近交付直接显示在卡片中。"}),s.jsx("nav",{hidden:L,"aria-label":"看板阶段",className:`${L?"hidden":"grid"} shrink-0 grid-cols-4 gap-1`,children:Al.map(H=>s.jsxs("button",{type:"button","aria-pressed":B===H.id,className:`min-h-11 rounded-lg px-1 text-xs ${B===H.id?"bg-surface-2 text-foreground":"text-muted-foreground"}`,onClick:()=>F(H.id),children:[H.label,s.jsx("span",{className:"ml-1 tabular-nums",children:de.filter(ae=>He(ae)===H.id).length})]},H.id))}),s.jsxs("div",{ref:L?void 0:m,"data-kanban-scroll":!0,onPointerDown:()=>{w.current=null},onWheel:()=>{w.current=null},"aria-label":L?void 0:"可左右滑动的任务看板",onScroll:L?void 0:H=>{if(H.target!==H.currentTarget||!H.currentTarget.clientWidth)return;const ae=w.current;if(ae){const Ze=Al.findIndex(Je=>Je.id===ae)*H.currentTarget.clientWidth;if(Math.abs(H.currentTarget.scrollLeft-Ze)>2)return;w.current=null}const be=Math.max(0,Math.min(Al.length-1,Math.round(H.currentTarget.scrollLeft/H.currentTarget.clientWidth)));W(Al[be].id)},className:L?"min-h-0 flex-1 overflow-auto pb-3":"min-h-0 flex-1 snap-x snap-mandatory overflow-x-auto overflow-y-hidden overscroll-x-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[L&&s.jsx("div",{"aria-label":"看板列标题",className:"sticky top-0 z-10 grid min-w-[1000px] grid-cols-4 gap-4 border-b border-border/15 bg-[var(--chrome-bg)] pb-2",children:Al.map(H=>{const ae=H.icon;return s.jsxs("h4",{className:`flex items-center gap-2 px-3 py-2 text-[13px] font-medium ${H.id==="attention"?"text-primary":"text-muted-foreground"}`,children:[s.jsx(ae,{size:15}),H.label,s.jsx("span",{className:"ml-auto tabular-nums text-xs",children:de.filter(be=>He(be)===H.id).length})]},H.id)})}),s.jsx("div",{className:L?"grid min-h-full min-w-[1000px] grid-cols-4 items-start gap-4 pt-2":"flex h-full",children:Al.map(H=>{const ae=de.filter(be=>He(be)===H.id).sort((be,Ze)=>Ze.updatedAt-be.updatedAt);return s.jsx("section",{"aria-label":`${H.label}任务`,"aria-hidden":!L&&B!==H.id?!0:void 0,ref:be=>{be&&(be.inert=!L&&B!==H.id)},style:L?void 0:{width:"100%"},className:L?"min-w-0 px-1":"h-full min-w-0 shrink-0 snap-start snap-always overflow-y-auto overscroll-y-contain px-1 pb-3 pt-2",children:s.jsxs("div",{className:"space-y-2",children:[ae.map(be=>{const Ze=oe.get(be.id),Je=Ze.attention??be,Tt=Je.attempts.find(Ve=>Ve.id===Je.activeAttemptId),Wt=Je.decisions.find(Ve=>Ve.status==="pending"),Mt=Qc(Je),vt=C6(Je,Ze.children),Yt=$f(Je),Qt=Yt[0],Xt=Yt.find(Ve=>Ve.source==="system"),Ut=Yt.find(Ve=>Ve.source==="unknown"),Lt=Xt?.content,pe=H.id==="attention",Ge=Wt?"回答问题":Ut?"查看详情核对记录":Qt?.source==="member"&&Xt?"查看条件与异常处理":Qt?.source==="member"?"查看阻塞并补充条件":Lt?"查看原因与处理":Mt==="等待你验收"?"查看结果并验收":Mt==="需要你确认方案"?"查看并确认方案":"查看任务并处理",ft=Je.artifacts.filter(Ve=>Ve.kind==="result"&&Ve.attemptId===Je.activeAttemptId).at(-1),q=Je.events.filter(Ve=>Ve.kind==="revise"&&Ve.source==="user"&&Ve.attemptId===Je.activeAttemptId&&(!ft||Ve.createdAt>=ft.createdAt)).at(-1),at=Wt?Wt.question||"成员提出了一个问题,打开后可查看并回答。":Qt?.summary||q?.content||ft?.summary||(Tt?.report?.content?T6(Tt.report.content).summary:Tt?.report?.summary||""),Vt=e.find(Ve=>Ve.id===be.parentTaskId);return s.jsxs("article",{"aria-label":be.title,className:`overflow-hidden rounded-xl border bg-surface text-left shadow-sm ${t===be.id?"border-primary/60":Lt?"border-destructive/35":"border-border/20"}`,children:[s.jsxs("button",{type:"button","data-task-id":be.id,"aria-pressed":t===be.id,className:"block w-full rounded-xl p-4 text-left transition hover:bg-surface-2/40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",onClick:()=>r(Je.id),children:[Vt&&s.jsx("span",{className:"mb-2 block truncate text-[10px] text-muted-foreground",children:Vt.title}),s.jsx("span",{title:be.title,className:"block line-clamp-3 break-words text-sm font-medium leading-6 text-foreground",children:be.title}),s.jsxs("span",{className:`mt-3 flex items-center gap-1.5 text-xs ${Lt&&Qt?.source!=="member"?"text-destructive":pe?"text-primary":"text-muted-foreground"}`,children:[Lt&&Qt?.source!=="member"&&s.jsx(k1,{size:13,className:"shrink-0"}),vt]}),Ze.attention&&s.jsxs("span",{className:"mt-2 block truncate text-[11px] text-muted-foreground",children:["来自执行任务:",Ze.attention.title]}),Ze.attention&&Ze.attentionCount>1&&s.jsxs("span",{className:"mt-1 block text-[11px] text-primary",children:["共 ",Ze.attentionCount," 项执行需要你处理"]}),at&&s.jsx("span",{className:"mt-2 line-clamp-3 break-words text-xs leading-5 text-foreground/80",children:at}),Xt&&Qt?.source==="member"&&s.jsxs("span",{className:"mt-2 block line-clamp-2 break-words text-xs leading-5 text-destructive",children:[Xt.label,":",Xt.summary]}),Ut&&s.jsxs("span",{className:"mt-2 block line-clamp-2 break-words text-xs leading-5 text-muted-foreground",children:[Ut.label,":",Ut.summary]}),pe&&s.jsxs("span",{className:`mt-4 flex min-h-9 items-center justify-between rounded-lg px-2.5 text-xs font-medium ${Lt?"bg-destructive/10 text-destructive":"bg-primary/10 text-primary"}`,children:[Ge,s.jsx(Em,{size:14})]}),!pe&&(be.status==="accepted"||be.artifacts.some(Ve=>Ve.kind==="result"&&Ve.attemptId===be.activeAttemptId))&&s.jsxs("span",{className:"mt-3 flex min-h-9 items-center justify-between text-xs font-medium text-primary",children:[q?"查看跟进":"查看结果",s.jsx(Em,{size:14})]})]}),s.jsx(YP,{task:be,children:Ze.children,onSelect:r}),s.jsxs("div",{className:"mx-4 border-t border-border/10 py-3 text-[11px] text-muted-foreground",children:[s.jsxs("span",{className:"block truncate",children:[Ze.attention?"待处理任务负责人:":be.workflow?.kind==="goal"?"协调者:":"负责人:",Tt?n(Je,Tt.assignee):Je.scheduledAssignee?n(Je,Je.scheduledAssignee):"未分派"]}),s.jsx(Tf,{task:Je,now:v,compact:!0})]})]},be.id)}),!ae.length&&s.jsx("p",{className:"px-2 py-3 text-xs leading-6 text-muted-foreground/70",children:Z||U!=="all"?"没有匹配的任务":e.length?"暂无任务":H.hint})]})},H.id)})})]})]})}const Il=rc((e,t)=>({views:{},details:{},ensureDetail:(r,n)=>{const a=t().details[r];return a||(e(c=>({details:{...c.details,[r]:n}})),n)},updateDetail:(r,n,a)=>e(c=>{const l=c.details[r];if(!l)return c;const h=typeof a=="function"?a(l[n]):a;return Object.is(l[n],h)?c:{details:{...c.details,[r]:{...l,[n]:h}}}}),ensure:(r,n)=>{const a=t().views[r];return a||(e(c=>({views:{...c.views,[r]:n}})),n)},update:(r,n,a)=>e(c=>{const l=c.views[r];if(!l)return c;const h=typeof a=="function"?a(l[n]):a;return Object.is(l[n],h)?c:{views:{...c.views,[r]:{...l,[n]:h}}}})}));function vh(e,t){return r=>Il.getState().update(e,t,r)}function fm(e,t){return r=>Il.getState().updateDetail(e,t,r)}const KP=b.lazy(()=>kc(()=>Promise.resolve().then(()=>OP),void 0).then(e=>({default:e.DirectoryPickerDialog}))),XP=b.lazy(()=>kc(()=>import("./CollaborationTaskContent-B_mzpNuw.js"),__vite__mapDeps([6,1,2,3,4,5,7,8,9,10,11,12,13,14,15,16,17]))),ra="inline-flex min-h-11 items-center justify-center gap-2 rounded-lg px-3 text-[13px] transition disabled:cursor-not-allowed disabled:opacity-40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",Qs="w-full min-h-11 rounded-lg border border-border/30 bg-surface-2 px-3 py-2 text-sm text-foreground outline-none focus:border-primary",cl=`${ra} bg-primary text-primary-foreground`,si=`${ra} bg-surface-2 text-foreground hover:bg-surface-2/80`,JP={created:"创建任务",assigned:"分派",report:"成员报告",respond:"答复",question:"提出问题",answer:"回答问题","submit-plan":"提交方案",review:"提交评审","request-review":"请求独立评审","approve-plan":"用户确认方案",accepted:"用户验收",revise:"要求修改",comment:"补充说明",coordinator:"协调者变更",close:"关闭",reopen:"重新打开",scheduled:"等待自动分派",coordinate:"协调说明","child-update":"子任务更新","review-passed":"独立评审通过","review-blocked":"评审受阻","automation-blocked":"自动安排受阻",pause:"暂停安排",resume:"继续安排",retry:"请求重新检查"},Su=e=>`${e.serviceId}:${e.sessionId}`,xa=e=>new Date(e).toLocaleString([],{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"});function Mo(e,t){try{const r=JSON.parse(localStorage.getItem(e)??"null");return r===null||t!==null&&(typeof r!=typeof t||Array.isArray(r)!==Array.isArray(t))?t:r}catch{return t}}function Na(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}const z0={mode:"goal",isolated:!0,title:"",spec:"",constraints:"",acceptance:"",assignee:"",coordinator:"",parent:"",dependencies:[]};function eO(e){const t={...z0,...Mo(e,z0)};return!t||!Array.isArray(t.dependencies)||t.dependencies.some(r=>typeof r!="string")||Object.keys(z0).some(r=>!["dependencies","isolated"].includes(r)&&typeof t[r]!="string")?z0:{...t,mode:t.mode==="task"?"task":"goal",isolated:t.isolated!==!1}}function S6(e,t){const r=e.workflow?.rootTaskId?t.find(c=>c.id===e.workflow?.rootTaskId):null;if(r?.workflow?.paused)return r;const n=new Set([e.id]);let a=e.parentTaskId;for(;a&&!n.has(a);){n.add(a);const c=t.find(l=>l.id===a);if(!c)break;if(c.workflow?.kind==="goal"&&c.workflow.paused)return c;a=c.parentTaskId}return e.workflow?.paused?e:null}function tO({group:e,sessions:t,active:r,onOpenSession:n,onAttentionChange:a,onManageMembers:c,board:l=!1,boardNavigation:h,boardSettings:p,paneKey:m,agents:x=[],defaultCwd:y,onTeamReady:w}){const v=`termdock:tasks:${location.origin}:${e.id}`,[k,L]=b.useState([]),E=b.useRef(k);E.current=k;const[R,B]=b.useState(null),[W]=b.useState(()=>Il.getState().ensure(v,{draft:eO(`${v}:draft`),selectedId:Mo(`${v}:selected`,null),creating:!1,mobileDetail:!1})),{selectedId:F,mobileDetail:U,creating:V,draft:Z}=Il(ne=>ne.views[v]??W),le=vh(v,"selectedId"),xe=vh(v,"mobileDetail"),fe=vh(v,"creating"),te=vh(v,"draft"),[ke,$e]=b.useState(!1),[Y,Ae]=b.useState(!1),lt=b.useRef(null),Ce=b.useRef(null),ye=b.useRef(!1),_e=b.useCallback(ne=>{!ne&&Ce.current===document.activeElement&&(ye.current=!0),Ce.current=ne,ne&&ye.current&&(ye.current=!1,ne.focus())},[]);b.useEffect(()=>{const ne=lt.current;if(!ne)return;const ht=new ResizeObserver(zt=>$e(zt[0].contentRect.width>=(l?1100:760)));return ht.observe(ne),()=>ht.disconnect()},[l]);const[je,re]=b.useState(!1),[Pe,Se]=b.useState(null),Ee=d3(),[Be,Ne]=b.useState(0),[oe,He]=b.useState(null),[rt,mt]=b.useState(!1),[de,Ye]=b.useState(0),st=ne=>Ye(ht=>Math.max(0,ht+ne)),[Ie,We]=b.useState("");b.useEffect(()=>{if(!Ie)return;const ne=setTimeout(()=>We(""),5e3);return()=>clearTimeout(ne)},[Ie]);const[Te,H]=b.useState("open"),[ae,be]=b.useState(""),Ze=b.useRef(!1),Je=b.useRef(!0),Tt=b.useRef(new Map),Wt=b.useRef(!1),Mt=e.sessionIds.flatMap(ne=>{const ht=t.find(zt=>zt.sessionId===ne);return ht?[ht]:[]}),vt=Mt.map(ne=>({...ne,name:gu(ne,Mt)})),Yt=Z.coordinator||Mo(`${v}:lead`,""),Qt=vt.find(ne=>ne.sessionId===Yt)?.sessionId||vt.find(ne=>ne.agent)?.sessionId||vt[0]?.sessionId||"",Xt=vt.filter(ne=>ne.sessionId!==Qt&&ne.agent).map(ne=>ne.sessionId),[Ut,Lt]=b.useState(!1),[pe,Ge]=b.useState(!1),[ft,q]=b.useState(()=>Mo(`${v}:agent`,x[0]?.slug??"")),[at,Vt]=b.useState(()=>Mo(`${v}:launch-profile`,e.defaultLaunchProfileId??"")),Ve=e.launchProfiles?.find(ne=>ne.id===at),De=Ve?.agentSlug??ft,[er,et]=b.useState(()=>Mo(`${v}:cwd`,vt[0]?.cwd??y??""));b.useEffect(()=>{!ft&&x[0]&&q(x[0].slug)},[x,ft]);const Ct=!vt.find(ne=>ne.sessionId===Qt)?.agent||!Xt.length,[Nt,gt]=b.useState(null),bt=!!Z.spec.trim()&&(!!Nt||!Ct||!e.federated&&(!at||!!Ve)&&!!x.find(ne=>ne.slug===De)&&!!er.trim()),It=k.find(ne=>ne.id===F)??null,yt=R?.id===F?R:null;b.useEffect(()=>(Je.current=!0,()=>{Je.current=!1}),[]),b.useEffect(()=>{Na(`${v}:draft`,Z)},[v,Z]),b.useEffect(()=>{Na(`${v}:selected`,F)},[v,F]),b.useEffect(()=>{const ne=zt=>{const Pt=zt.detail;Pt?.groupId===e.id&&(Na(`${v}:open-task`,null),le(Pt.taskId),xe(!0),fe(!1),H("all"),pr())};window.addEventListener("open-collaboration-task",ne);const ht=Mo(`${v}:open-task`,null);return ht&&(le(ht),xe(!0),H("all"),Na(`${v}:open-task`,null)),()=>window.removeEventListener("open-collaboration-task",ne)},[e.id]),b.useEffect(()=>{if(!r||!It||R?.id===It.id&&R.revision===It.revision)return;let ne=!1;return yw(It.id).then(ht=>{ne||(B(ht.task),Se(null))}).catch(ht=>{ne||Se(ht instanceof Error?ht.message:"任务详情加载失败")}),()=>{ne=!0}},[r,It?.id,It?.revision,R?.id,R?.revision,Be]);const pr=async()=>{if(!Wt.current){Wt.current=!0;try{const ne=await o3(e.id);Je.current&&(L(ne.tasks),re(!0),Se(null),Ne(ht=>ht+1))}catch(ne){Je.current&&Se(ne instanceof Error?ne.message:"任务加载失败")}finally{Wt.current=!1}}};b.useEffect(()=>{if(!r)return;pr();const ne=()=>{!document.hidden&&navigator.onLine!==!1&&pr()},ht=setInterval(ne,2500);return document.addEventListener("visibilitychange",ne),window.addEventListener(Vh,ne),window.addEventListener("pageshow",ne),()=>{clearInterval(ht),document.removeEventListener("visibilitychange",ne),window.removeEventListener(Vh,ne),window.removeEventListener("pageshow",ne)}},[r,e.id]);const nr=ne=>{const ht=JSON.stringify(ne),zt=Mo(`${v}:request`,null);let Pt=Tt.current.get(ht)??(zt?.fingerprint===ht?zt.key:void 0);return Pt||(Pt=crypto.randomUUID(),Tt.current.set(ht,Pt)),Na(`${v}:request`,{fingerprint:ht,key:Pt}),Pt},_r=ne=>{Tt.current.delete(JSON.stringify(ne)),Na(`${v}:request`,null)},un=async(ne,ht)=>{if(rt||Ze.current)return{ok:!1,error:"已有操作正在提交,请稍候。"};Ze.current=!0,mt(!0),He(null),We("");let zt={...ht,expectedRevision:ne.revision};if(["comment","revise"].includes(ht.kind)){const Pt=Mo(`${v}:request`,null);try{const[Cr,gr]=JSON.parse(Pt?.fingerprint??"null"),{expectedRevision:Hr,...En}=gr;Cr===ne.id&&JSON.stringify(En)===JSON.stringify(ht)&&(zt=gr)}catch{}}try{const Pt=await Aw(ne.id,{...zt,idempotencyKey:nr([ne.id,zt])});if(_r([ne.id,zt]),mu.getState().refresh(),Je.current){const Cr=E.current.find(dr=>dr.id===Pt.task.id),gr=Cr&&Cr.revision>Pt.task.revision?Cr:Pt.task;L(dr=>dr.map(Tn=>Tn.id===Pt.task.id&&Tn.revision<=Pt.task.revision?Pt.task:Tn)),B(dr=>dr?.id===Pt.task.id&&dr.revision>Pt.task.revision?dr:Pt.task);const Hr=S6(gr,E.current),En=`${ht.kind==="answer"?"回答已保存":"方案确认已保存"},${Hr?Hr.workflow?.kind==="goal"?"目标仍暂停;恢复目标后才能投递。":"任务仍暂停;继续安排后才能投递。":"投递状态请查看任务记录。"}`;We(["comment","revise"].includes(ht.kind)?"":ht.kind==="retry"?VP(ne,Pt.task):["answer","approve-plan"].includes(ht.kind)?En:ht.kind==="accept"?"已验收此版本结果。":"记录已保存。")}return{ok:!0}}catch(Pt){const Cr=Pt instanceof Error?Pt.message:"操作失败";return Cr.includes("任务已更新")&&_r([ne.id,zt]),Je.current&&(He(["comment","revise"].includes(ht.kind)?null:Cr),pr()),{ok:!1,error:Cr}}finally{Ze.current=!1,Je.current&&mt(!1)}},Ir=async ne=>{if(ne.preventDefault(),rt||de>0||(Z.mode==="goal"?!bt:!Z.title.trim()||!Z.spec.trim())||Ze.current)return;Ze.current=!0,mt(!0),He(null);const ht=Z.mode==="goal",zt={groupId:e.id,title:Z.title.trim()||Z.spec.trim().split(`
132
+ `)),e,!!t,t);return t||V0(e),te},[c,e,t]);const Z=()=>{const te=rd();return`${location.origin}:${te?.targetPeerId??""}:${te?.serviceOrigin??""}`},le=te=>{const ke=U(),$e=Z(),Y=L.current.onUploadChange;W(""),R(Ae=>Ae+1),Y?.(1),F.current=F.current.then(async()=>{try{if($e!==Z())throw new Error("目标服务已切换,请重新添加附件");const Ae=await te();if($e!==Z())throw new Error("目标服务已切换,请重新添加附件");Array.isArray(Ae)?V(Ae.map(Tc).join(" ")+" ",ke):Ae&&V(Ae,ke)}catch(Ae){const lt=Ae instanceof Error?Ae.message:"附件准备失败,请重试";W(lt.includes("Upload did not return")?"附件上传未返回完整路径,请重试":lt)}finally{R(Ae=>Ae-1),Y?.(-1)}})},xe=async te=>te.length===1&&te[0].type.startsWith("image/")?[await Q3(te[0])]:F3(te),fe=te=>{const ke=te.clipboardData.files.length?Array.from(te.clipboardData.files):Array.from(te.clipboardData.items??[]).filter(Ae=>Ae.kind==="file").map(Ae=>Ae.getAsFile()).filter(Ae=>Ae!==null),$e=te.clipboardData.getData("text/plain"),Y=lo();!Y?.readClipboardFiles&&!ke.length&&$e||!Y&&!ke.length&&typeof navigator.clipboard?.read!="function"||(te.preventDefault(),le(async()=>{const Ae=Z();let lt;if(Y?.readClipboardFiles)try{const Ce=await O3();if(Ce.paths.length||Ce.files.length)return[...Ce.paths,...await xe(Ce.files)]}catch(Ce){if(Ce instanceof Z0)throw Ce;lt=Ce}if(Ae!==Z())throw new Error("目标服务已切换,请重新粘贴");if(ke.length)return xe(ke);if($e)return $e;if(typeof navigator.clipboard?.read=="function"){const Ce=await navigator.clipboard.read(),ye={read:async()=>Ce},_e=await P3(ye);if(_e.length)return xe(_e);const je=await ef(ye);if(je)return xe([je]);for(const re of Ce)if(re.types.includes("text/plain"))return(await re.getType("text/plain")).text()}else{const Ce=await ef();if(Ce)return xe([Ce])}if(lt)throw lt;return null}))};return s.jsxs("div",{className:"space-y-1.5",onFocusCapture:()=>V0(e),onPointerDownCapture:()=>V0(e),children:[s.jsx("label",{htmlFor:w,className:"block text-xs text-muted-foreground",children:r}),s.jsx("textarea",{ref:v,id:w,value:n,required:h,disabled:l,autoFocus:p,"aria-describedby":E||B?`${w}-status`:void 0,placeholder:m,className:x,onChange:te=>a(te.target.value),onPaste:fe,onDragOver:te=>{!l&&te.dataTransfer.types.includes("Files")&&te.preventDefault()},onDrop:te=>{const ke=Array.from(te.dataTransfer.files);!ke.length||l||(te.preventDefault(),te.stopPropagation(),le(()=>xe(ke)))}}),s.jsxs("div",{className:"flex min-h-9 items-center gap-2",children:[s.jsx("input",{ref:k,type:"file",multiple:!0,hidden:!0,"aria-label":`选择附件:${r}`,onChange:te=>{const ke=Array.from(te.target.files??[]);te.target.value="",ke.length&&le(()=>xe(ke))}}),s.jsxs("button",{type:"button","aria-label":`添加附件:${r}`,title:"添加附件",disabled:l,className:"inline-flex min-h-9 shrink-0 items-center gap-1.5 rounded-lg px-2 text-xs text-muted-foreground hover:bg-surface-2 disabled:opacity-40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",onClick:()=>k.current?.click(),children:[s.jsx(ET,{size:14}),"附件"]}),E>0?s.jsxs("span",{id:`${w}-status`,role:"status",className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[s.jsx(yn,{size:12,className:"animate-spin"}),"正在准备附件…"]}):B?s.jsx("span",{id:`${w}-status`,role:"alert",className:"break-words text-xs text-destructive",children:B}):s.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:"可粘贴图片、文件或拖入附件"})]})]})}function ub(e,t=!1,r=""){e=e.filter(h=>h.purpose!=="automation");const n=new Map(e.map(h=>[h.id,h])),a=h=>n.get(h.parentTaskId??h.workflow?.rootTaskId??""),c=h=>{const p=[];let m=h;for(;;){const x=p.findIndex(w=>w.id===m.id);if(x!==-1)return p.slice(x).sort((w,v)=>w.id.localeCompare(v.id))[0];p.push(m);const y=a(m);if(!y||y.status==="closed"&&m.status!=="closed")return m;m=y}},l=new Map(e.map(h=>[h.id,c(h).id]));return e.filter(h=>t||!!r.trim()||l.get(h.id)===h.id).map(h=>{const p=t||r.trim()?[]:e.filter(y=>y.id!==h.id&&l.get(y.id)===h.id&&y.status!=="closed"),m=h.status==="open"&&!$i(h)?p.find(y=>y.decisions.some(w=>w.status==="pending"))??p.find(y=>$i(y)||y.workflow?.paused):void 0,x=p.filter(y=>$i(y)||y.workflow?.paused).length;return{task:h,children:p,attention:m,attentionCount:x,rootId:l.get(h.id)}})}function C6(e,t=[]){const r=Qc(e),n={已验收:"已完成 · 你已验收",独立评审通过:"执行交付已评审",需要你回答:"请回答成员的问题",需要你确认方案:"请确认方案",等待你验收:"请查看结果并验收",成员报告受阻:"需要补充条件",成员报告失败:"成员报告执行失败",成员确认接手:"已接手 · 等待后续报告",成员报告进行中:"成员报告:进行中",等待独立评审:"结果已提交 · 等待评审","评审通过 · 等待接续":"交付已评审 · 等待接续","已要求跟进 · 等待新结果":"已提出跟进 · 等待新结果"};return e.status==="open"&&t.length&&!$i(e)&&!e.artifacts.some(a=>a.kind==="result"&&a.attemptId===e.activeAttemptId)?t.every(a=>a.status==="accepted")?"执行交付已评审 · 等待总结果":"目标未完成 · 执行交付待齐":n[r]??r}function YP({task:e,children:t,onSelect:r}){const n=new Map(t.map(m=>[m.id,m])),a=(t.length?t:e.children??[]).filter(m=>m.status!=="closed");if(!a.length)return null;const c=(m,x)=>{const y=n.get(m);return y&&($i(y)||y.workflow?.paused)?0:x?2:1},l=[...a].sort((m,x)=>c(m.id,m.status==="accepted")-c(x.id,x.status==="accepted")||(n.get(x.id)?.updatedAt??0)-(n.get(m.id)?.updatedAt??0)),h=a.filter(m=>m.status==="accepted").length,p=m=>{const x=n.get(m.id),y=m.status==="accepted",w=x&&($i(x)||x.workflow?.paused),v=x?C6(x):y?m.completionMode==="reviewed"?"执行交付已评审":"已验收":"等待报告",k=y?Iu:Eu;return s.jsxs("button",{type:"button",className:"flex min-h-11 w-full items-start gap-2 rounded-lg px-1 py-2 text-left hover:bg-surface-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",onClick:()=>r(m.id),children:[s.jsx(k,{size:14,className:`mt-0.5 shrink-0 ${y||w?"text-primary":"text-muted-foreground"}`}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{title:m.title,className:"block line-clamp-2 break-words text-xs leading-5 text-foreground",children:m.title}),s.jsx("span",{className:`block text-[11px] leading-5 ${w?"text-primary":"text-muted-foreground"}`,children:v})]}),s.jsx(hi,{size:12,className:"mt-1 shrink-0 text-muted-foreground"})]},m.id)};return s.jsxs("section",{"aria-label":"执行事项",className:"mx-4 border-t border-border/15 py-2",children:[s.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:"执行事项"}),s.jsxs("span",{children:[h,"/",a.length," 项已完成"]})]}),l.slice(0,3).map(p),l.length>3&&s.jsxs("details",{children:[s.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-[11px] text-muted-foreground",children:["展开其余 ",l.length-3," 项"]}),l.slice(3).map(p)]})]})}function db(e){return e.status!=="open"?"done":$i(e)||e.workflow?.paused?"attention":e.activeAttemptId?"running":"backlog"}const Al=[{id:"backlog",label:"待开始",icon:Eu,hint:"等待分派或依赖完成"},{id:"running",label:"执行中",icon:Zh,hint:"分派后的任务会出现在这里"},{id:"attention",label:"需要你",icon:Td,hint:"问题、方案与验收都在这里"},{id:"done",label:"已完成",icon:Iu,hint:"验收后的结果会保留在这里"}];function ZP({tasks:e,selectedId:t,onSelect:r,name:n,storage:a,action:c,navigation:l,settings:h}){const p=b.useRef(null),m=b.useRef(null),x=b.useRef("backlog"),y=b.useRef(0),w=b.useRef(null),[v,k]=b.useState(Date.now);b.useEffect(()=>{const H=setInterval(()=>k(Date.now()),3e4);return()=>clearInterval(H)},[]);const[L,E]=b.useState(!1);b.useEffect(()=>{const H=new ResizeObserver(ae=>{const be=ae[0].contentRect.width;E(be>=760),be!==y.current&&be<760&&m.current&&(m.current.scrollLeft=Al.findIndex(Ze=>Ze.id===x.current)*m.current.clientWidth),y.current=be});return p.current&&H.observe(p.current),()=>H.disconnect()},[]);const[R]=b.useState(()=>{try{return JSON.parse(localStorage.getItem(`${a}:board`)??"null")}catch{return null}}),[B,W]=b.useState(()=>{if(Al.some(be=>be.id===R?.lane))return R.lane;const ae=ub(e,R?.showSteps===!0,R?.query??"").map(be=>be.attention?"attention":db(be.task));return ae.includes("attention")?"attention":ae.includes("running")?"running":ae.includes("backlog")?"backlog":"done"});x.current=B;function F(H,ae=!0){W(H);const be=m.current;if(!be||!be.clientWidth)return;w.current=H;const Ze=Al.findIndex(Tt=>Tt.id===H)*be.clientWidth,Je=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;be.scrollTo?be.scrollTo({left:Ze,behavior:ae&&!Je?"smooth":"auto"}):be.scrollLeft=Ze}b.useEffect(()=>{L||F(x.current,!1)},[L]);const[U,V]=b.useState(typeof R?.scope=="string"?R.scope:"all"),[Z,le]=b.useState(typeof R?.query=="string"?R.query:""),[xe,fe]=b.useState(R?.closed===!0),[te,ke]=b.useState(R?.showSteps===!0),[$e,Y]=b.useState(!!R?.query),[Ae,lt]=b.useState(!1),[Ce,ye]=b.useState(!1),_e=b.useRef(null),je=b.useRef(null);b.useEffect(()=>{if(!Ce)return;_e.current?.querySelector('[aria-label="看板更多操作"] button')?.focus();const H=be=>{_e.current?.contains(be.target)||ye(!1)},ae=be=>{be.key==="Escape"&&(be.preventDefault(),be.stopPropagation(),ye(!1),je.current?.focus())};return document.addEventListener("pointerdown",H),document.addEventListener("keydown",ae),()=>{document.removeEventListener("pointerdown",H),document.removeEventListener("keydown",ae)}},[Ce]);const re=b.useRef(null),Pe=b.useRef(null),Se=b.useRef(null),Ee=b.useRef(null);b.useEffect(()=>{$e&&re.current?.focus()},[$e]),b.useEffect(()=>{if(!Ae)return;Se.current?.querySelector("select")?.focus();const H=be=>{Se.current?.contains(be.target)||lt(!1)},ae=be=>{be.key==="Escape"&&(be.preventDefault(),be.stopPropagation(),lt(!1),(L?Ee:je).current?.focus())};return document.addEventListener("pointerdown",H),document.addEventListener("keydown",ae),()=>{document.removeEventListener("pointerdown",H),document.removeEventListener("keydown",ae)}},[Ae]),b.useEffect(()=>{try{localStorage.setItem(`${a}:board`,JSON.stringify({lane:B,scope:U,query:Z,closed:xe,showSteps:te}))}catch{}},[a,B,U,Z,xe,te]);const Be=e.filter(H=>H.workflow?.kind==="goal"),Ne=ub(e,te,Z),oe=new Map(Ne.map(H=>[H.task.id,H])),He=H=>oe.get(H.id)?.attention?"attention":db(H),rt=t?Ne.find(H=>H.task.id===t||H.children.some(ae=>ae.id===t)):void 0,mt=rt?He(rt.task):void 0;b.useEffect(()=>{mt&&F(mt,!1)},[t,mt]);const de=Ne.map(H=>H.task).filter(H=>(xe||H.status!=="closed")&&(U==="all"||H.id===U||oe.get(H.id)?.rootId===U)&&(!Z.trim()||`${H.title} ${H.spec} ${H.attempts.map(ae=>n(H,ae.assignee)).join(" ")}`.toLocaleLowerCase().includes(Z.trim().toLocaleLowerCase()))),Ye=+(U!=="all")+Number(xe)+Number(te),st="inline-flex min-h-11 min-w-11 shrink-0 items-center justify-center gap-1.5 rounded-lg px-2 text-xs text-muted-foreground hover:bg-surface-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",Ie="flex min-h-11 w-full items-center justify-start gap-3 rounded-lg px-3 text-left text-sm font-medium text-foreground hover:bg-surface-2 active:bg-surface-elevated focus-visible:bg-surface-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",We=s.jsxs("div",{className:`relative flex min-w-0 items-center ${L?"flex-1 max-w-[240px]":"w-full"}`,children:[s.jsx("span",{className:"sr-only",children:"搜索任务"}),s.jsx(El,{"aria-hidden":"true",size:15,className:"pointer-events-none absolute left-3 text-muted-foreground"}),s.jsx("input",{ref:re,"aria-label":"搜索任务",type:"search",value:Z,onChange:H=>le(H.target.value),onKeyDown:H=>{H.key==="Escape"&&(H.preventDefault(),H.stopPropagation(),Z?le(""):(Y(!1),requestAnimationFrame(()=>(L?Pe:je).current?.focus())))},placeholder:"搜索任务或负责人",className:"min-h-11 w-full rounded-lg border border-border/20 bg-transparent pl-9 pr-9 text-xs outline-none focus:border-primary"}),s.jsx("button",{type:"button","aria-label":"关闭搜索",className:"absolute right-0 flex min-h-11 w-9 items-center justify-center text-muted-foreground",onClick:()=>{le(""),Y(!1),requestAnimationFrame(()=>(L?Pe:je).current?.focus())},children:s.jsx(Qn,{size:14})})]}),Te=s.jsxs("div",{"aria-label":"任务筛选",className:"absolute right-0 top-full z-30 mt-1 w-64 space-y-3 rounded-xl border border-border/30 bg-surface p-3 shadow-xl",children:[s.jsxs("label",{className:"block space-y-1 text-xs text-muted-foreground",children:[s.jsx("span",{children:"目标范围"}),s.jsxs("select",{"aria-label":"按目标查看",value:U,onChange:H=>V(H.target.value),className:"min-h-11 w-full rounded-lg border border-border/20 bg-surface-2 px-3 text-xs text-foreground",children:[s.jsx("option",{value:"all",children:"所有目标"}),Be.map(H=>s.jsx("option",{value:H.id,children:H.title},H.id))]})]}),s.jsxs("label",{className:"flex min-h-11 items-center gap-2 text-xs text-muted-foreground",children:[s.jsx("input",{type:"checkbox",checked:xe,onChange:H=>fe(H.target.checked)}),"含已关闭"]}),s.jsxs("label",{className:"flex min-h-11 items-center gap-2 text-xs text-muted-foreground",children:[s.jsx("input",{type:"checkbox",checked:te,onChange:H=>ke(H.target.checked)}),"显示执行子任务"]}),Ye>0&&s.jsx("button",{type:"button",className:"min-h-11 w-full rounded-lg text-xs text-primary hover:bg-surface-2",onClick:()=>{V("all"),fe(!1),ke(!1)},children:"清除筛选"})]});return s.jsxs("div",{ref:p,className:"flex min-h-0 min-w-0 flex-1 flex-col gap-2",children:[s.jsx("div",{ref:L?void 0:Se,"aria-label":"看板工具栏",className:"relative z-20 flex shrink-0 flex-wrap items-center gap-1.5 border-b border-border/15 pb-2",children:L?s.jsxs(s.Fragment,{children:[l&&s.jsx("div",{className:"flex min-w-0 items-center mr-auto",children:l}),$e?We:s.jsx("button",{ref:Pe,type:"button","aria-label":"搜索任务",title:"搜索任务",className:`${st} ${l?"":"ml-auto"}`,onClick:()=>Y(!0),children:s.jsx(El,{size:16})}),s.jsxs("div",{ref:Se,className:"relative shrink-0",children:[s.jsxs("button",{ref:Ee,type:"button","aria-label":Ye?`筛选任务,${Ye} 项已启用`:"筛选任务","aria-expanded":Ae,className:`${st} ${Ye?"text-primary":""}`,onClick:()=>lt(H=>!H),children:[s.jsx(Nm,{size:15}),s.jsx("span",{children:"筛选"}),Ye>0&&s.jsx("span",{className:"tabular-nums text-primary",children:Ye})]}),Ae&&Te]}),h,c&&s.jsx("div",{className:"shrink-0",children:c})]}):s.jsxs(s.Fragment,{children:[l&&s.jsx("div",{className:"mr-auto flex min-w-0 items-center",children:l}),c&&s.jsx("div",{className:"shrink-0",children:c}),s.jsxs("div",{ref:_e,className:"relative shrink-0",children:[s.jsxs("button",{ref:je,type:"button","aria-label":"更多看板操作","aria-expanded":Ce,className:`${st} ${Ce?"bg-surface-2 text-foreground":Ye||Z.trim()?"text-primary":""}`,onClick:()=>{ye(H=>!H),lt(!1)},children:[s.jsx(Qo,{size:18}),Ye>0&&s.jsx("span",{className:"text-[10px]",children:Ye})]}),Ce&&s.jsxs("div",{role:"group","aria-label":"看板更多操作",className:"absolute right-0 top-full z-30 mt-2 flex w-52 max-w-[calc(100vw-2rem)] flex-col gap-0.5 rounded-xl border border-border/40 bg-surface p-1.5 shadow-xl",onClick:()=>ye(!1),children:[s.jsxs("button",{ref:Pe,type:"button","aria-label":"搜索任务",className:Ie,onClick:()=>Y(!0),children:[s.jsx(El,{size:18,className:"shrink-0 text-muted-foreground"}),"搜索任务"]}),s.jsxs("button",{ref:Ee,type:"button","aria-label":Ye?`筛选任务,${Ye} 项已启用`:"筛选任务",className:Ie,onClick:()=>lt(!0),children:[s.jsx(Nm,{size:18,className:"shrink-0 text-muted-foreground"}),"筛选任务",Ye>0&&s.jsx("span",{className:"ml-auto rounded bg-primary/10 px-1.5 text-xs tabular-nums text-primary",children:Ye})]}),h&&s.jsx("div",{className:"mt-1 border-t border-border/30 pt-1 [&>button]:min-h-11 [&>button]:w-full [&>button]:justify-start [&>button]:gap-3 [&>button]:px-3 [&>button]:text-left [&>button]:text-sm [&>button]:text-foreground [&>button:hover]:bg-surface-2 [&>button:active]:bg-surface-elevated [&>button:focus-visible]:bg-surface-2 [&>button>svg]:h-[18px] [&>button>svg]:w-[18px] [&>button>svg]:shrink-0 [&>button>svg]:text-muted-foreground [&>button>span]:not-sr-only",children:h})]})]}),$e&&We,Ae&&Te]})}),s.jsx("p",{className:"px-1 text-[11px] leading-5 text-muted-foreground",children:te?"包含执行子任务,可在筛选中切回目标视图。":"每张卡片对应一个目标,待完成事项和最近交付直接显示在卡片中。"}),s.jsx("nav",{hidden:L,"aria-label":"看板阶段",className:`${L?"hidden":"grid"} shrink-0 grid-cols-4 gap-1`,children:Al.map(H=>s.jsxs("button",{type:"button","aria-pressed":B===H.id,className:`min-h-11 rounded-lg px-1 text-xs ${B===H.id?"bg-surface-2 text-foreground":"text-muted-foreground"}`,onClick:()=>F(H.id),children:[H.label,s.jsx("span",{className:"ml-1 tabular-nums",children:de.filter(ae=>He(ae)===H.id).length})]},H.id))}),s.jsxs("div",{ref:L?void 0:m,"data-kanban-scroll":!0,onPointerDown:()=>{w.current=null},onWheel:()=>{w.current=null},"aria-label":L?void 0:"可左右滑动的任务看板",onScroll:L?void 0:H=>{if(H.target!==H.currentTarget||!H.currentTarget.clientWidth)return;const ae=w.current;if(ae){const Ze=Al.findIndex(Je=>Je.id===ae)*H.currentTarget.clientWidth;if(Math.abs(H.currentTarget.scrollLeft-Ze)>2)return;w.current=null}const be=Math.max(0,Math.min(Al.length-1,Math.round(H.currentTarget.scrollLeft/H.currentTarget.clientWidth)));W(Al[be].id)},className:L?"min-h-0 flex-1 overflow-auto pb-3":"min-h-0 flex-1 snap-x snap-mandatory overflow-x-auto overflow-y-hidden overscroll-x-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[L&&s.jsx("div",{"aria-label":"看板列标题",className:"sticky top-0 z-10 grid min-w-[1000px] grid-cols-4 gap-4 border-b border-border/15 bg-[var(--chrome-bg)] pb-2",children:Al.map(H=>{const ae=H.icon;return s.jsxs("h4",{className:`flex items-center gap-2 px-3 py-2 text-[13px] font-medium ${H.id==="attention"?"text-primary":"text-muted-foreground"}`,children:[s.jsx(ae,{size:15}),H.label,s.jsx("span",{className:"ml-auto tabular-nums text-xs",children:de.filter(be=>He(be)===H.id).length})]},H.id)})}),s.jsx("div",{className:L?"grid min-h-full min-w-[1000px] grid-cols-4 items-start gap-4 pt-2":"flex h-full",children:Al.map(H=>{const ae=de.filter(be=>He(be)===H.id).sort((be,Ze)=>Ze.updatedAt-be.updatedAt);return s.jsx("section",{"aria-label":`${H.label}任务`,"aria-hidden":!L&&B!==H.id?!0:void 0,ref:be=>{be&&(be.inert=!L&&B!==H.id)},style:L?void 0:{width:"100%"},className:L?"min-w-0 px-1":"h-full min-w-0 shrink-0 snap-start snap-always overflow-y-auto overscroll-y-contain px-1 pb-3 pt-2",children:s.jsxs("div",{className:"space-y-2",children:[ae.map(be=>{const Ze=oe.get(be.id),Je=Ze.attention??be,Tt=Je.attempts.find(Ve=>Ve.id===Je.activeAttemptId),Wt=Je.decisions.find(Ve=>Ve.status==="pending"),Mt=Qc(Je),vt=C6(Je,Ze.children),Yt=$f(Je),Qt=Yt[0],Xt=Yt.find(Ve=>Ve.source==="system"),Ut=Yt.find(Ve=>Ve.source==="unknown"),Lt=Xt?.content,pe=H.id==="attention",Ge=Wt?"回答问题":Ut?"查看详情核对记录":Qt?.source==="member"&&Xt?"查看条件与异常处理":Qt?.source==="member"?"查看阻塞并补充条件":Lt?"查看原因与处理":Mt==="等待你验收"?"查看结果并验收":Mt==="需要你确认方案"?"查看并确认方案":"查看任务并处理",ft=Je.artifacts.filter(Ve=>Ve.kind==="result"&&Ve.attemptId===Je.activeAttemptId).at(-1),q=Je.events.filter(Ve=>Ve.kind==="revise"&&Ve.source==="user"&&Ve.attemptId===Je.activeAttemptId&&(!ft||Ve.createdAt>=ft.createdAt)).at(-1),at=Wt?Wt.question||"成员提出了一个问题,打开后可查看并回答。":Qt?.summary||q?.content||ft?.summary||(Tt?.report?.content?T6(Tt.report.content).summary:Tt?.report?.summary||""),Vt=e.find(Ve=>Ve.id===be.parentTaskId);return s.jsxs("article",{"aria-label":be.title,className:`overflow-hidden rounded-xl border bg-surface text-left shadow-sm ${t===be.id?"border-primary/60":Lt?"border-destructive/35":"border-border/20"}`,children:[s.jsxs("button",{type:"button","data-task-id":be.id,"aria-pressed":t===be.id,className:"block w-full rounded-xl p-4 text-left transition hover:bg-surface-2/40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",onClick:()=>r(Je.id),children:[Vt&&s.jsx("span",{className:"mb-2 block truncate text-[10px] text-muted-foreground",children:Vt.title}),s.jsx("span",{title:be.title,className:"block line-clamp-3 break-words text-sm font-medium leading-6 text-foreground",children:be.title}),s.jsxs("span",{className:`mt-3 flex items-center gap-1.5 text-xs ${Lt&&Qt?.source!=="member"?"text-destructive":pe?"text-primary":"text-muted-foreground"}`,children:[Lt&&Qt?.source!=="member"&&s.jsx(k1,{size:13,className:"shrink-0"}),vt]}),Ze.attention&&s.jsxs("span",{className:"mt-2 block truncate text-[11px] text-muted-foreground",children:["来自执行任务:",Ze.attention.title]}),Ze.attention&&Ze.attentionCount>1&&s.jsxs("span",{className:"mt-1 block text-[11px] text-primary",children:["共 ",Ze.attentionCount," 项执行需要你处理"]}),at&&s.jsx("span",{className:"mt-2 line-clamp-3 break-words text-xs leading-5 text-foreground/80",children:at}),Xt&&Qt?.source==="member"&&s.jsxs("span",{className:"mt-2 block line-clamp-2 break-words text-xs leading-5 text-destructive",children:[Xt.label,":",Xt.summary]}),Ut&&s.jsxs("span",{className:"mt-2 block line-clamp-2 break-words text-xs leading-5 text-muted-foreground",children:[Ut.label,":",Ut.summary]}),pe&&s.jsxs("span",{className:`mt-4 flex min-h-9 items-center justify-between rounded-lg px-2.5 text-xs font-medium ${Lt?"bg-destructive/10 text-destructive":"bg-primary/10 text-primary"}`,children:[Ge,s.jsx(Em,{size:14})]}),!pe&&(be.status==="accepted"||be.artifacts.some(Ve=>Ve.kind==="result"&&Ve.attemptId===be.activeAttemptId))&&s.jsxs("span",{className:"mt-3 flex min-h-9 items-center justify-between text-xs font-medium text-primary",children:[q?"查看跟进":"查看结果",s.jsx(Em,{size:14})]})]}),s.jsx(YP,{task:be,children:Ze.children,onSelect:r}),s.jsxs("div",{className:"mx-4 border-t border-border/10 py-3 text-[11px] text-muted-foreground",children:[s.jsxs("span",{className:"block truncate",children:[Ze.attention?"待处理任务负责人:":be.workflow?.kind==="goal"?"协调者:":"负责人:",Tt?n(Je,Tt.assignee):Je.scheduledAssignee?n(Je,Je.scheduledAssignee):"未分派"]}),s.jsx(Tf,{task:Je,now:v,compact:!0})]})]},be.id)}),!ae.length&&s.jsx("p",{className:"px-2 py-3 text-xs leading-6 text-muted-foreground/70",children:Z||U!=="all"?"没有匹配的任务":e.length?"暂无任务":H.hint})]})},H.id)})})]})]})}const Il=rc((e,t)=>({views:{},details:{},ensureDetail:(r,n)=>{const a=t().details[r];return a||(e(c=>({details:{...c.details,[r]:n}})),n)},updateDetail:(r,n,a)=>e(c=>{const l=c.details[r];if(!l)return c;const h=typeof a=="function"?a(l[n]):a;return Object.is(l[n],h)?c:{details:{...c.details,[r]:{...l,[n]:h}}}}),ensure:(r,n)=>{const a=t().views[r];return a||(e(c=>({views:{...c.views,[r]:n}})),n)},update:(r,n,a)=>e(c=>{const l=c.views[r];if(!l)return c;const h=typeof a=="function"?a(l[n]):a;return Object.is(l[n],h)?c:{views:{...c.views,[r]:{...l,[n]:h}}}})}));function vh(e,t){return r=>Il.getState().update(e,t,r)}function fm(e,t){return r=>Il.getState().updateDetail(e,t,r)}const KP=b.lazy(()=>kc(()=>Promise.resolve().then(()=>OP),void 0).then(e=>({default:e.DirectoryPickerDialog}))),XP=b.lazy(()=>kc(()=>import("./CollaborationTaskContent-CTSJJqze.js"),__vite__mapDeps([6,1,2,3,4,5,7,8,9,10,11,12,13,14,15,16,17]))),ra="inline-flex min-h-11 items-center justify-center gap-2 rounded-lg px-3 text-[13px] transition disabled:cursor-not-allowed disabled:opacity-40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",Qs="w-full min-h-11 rounded-lg border border-border/30 bg-surface-2 px-3 py-2 text-sm text-foreground outline-none focus:border-primary",cl=`${ra} bg-primary text-primary-foreground`,si=`${ra} bg-surface-2 text-foreground hover:bg-surface-2/80`,JP={created:"创建任务",assigned:"分派",report:"成员报告",respond:"答复",question:"提出问题",answer:"回答问题","submit-plan":"提交方案",review:"提交评审","request-review":"请求独立评审","approve-plan":"用户确认方案",accepted:"用户验收",revise:"要求修改",comment:"补充说明",coordinator:"协调者变更",close:"关闭",reopen:"重新打开",scheduled:"等待自动分派",coordinate:"协调说明","child-update":"子任务更新","review-passed":"独立评审通过","review-blocked":"评审受阻","automation-blocked":"自动安排受阻",pause:"暂停安排",resume:"继续安排",retry:"请求重新检查"},Su=e=>`${e.serviceId}:${e.sessionId}`,xa=e=>new Date(e).toLocaleString([],{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"});function Mo(e,t){try{const r=JSON.parse(localStorage.getItem(e)??"null");return r===null||t!==null&&(typeof r!=typeof t||Array.isArray(r)!==Array.isArray(t))?t:r}catch{return t}}function Na(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}const z0={mode:"goal",isolated:!0,title:"",spec:"",constraints:"",acceptance:"",assignee:"",coordinator:"",parent:"",dependencies:[]};function eO(e){const t={...z0,...Mo(e,z0)};return!t||!Array.isArray(t.dependencies)||t.dependencies.some(r=>typeof r!="string")||Object.keys(z0).some(r=>!["dependencies","isolated"].includes(r)&&typeof t[r]!="string")?z0:{...t,mode:t.mode==="task"?"task":"goal",isolated:t.isolated!==!1}}function S6(e,t){const r=e.workflow?.rootTaskId?t.find(c=>c.id===e.workflow?.rootTaskId):null;if(r?.workflow?.paused)return r;const n=new Set([e.id]);let a=e.parentTaskId;for(;a&&!n.has(a);){n.add(a);const c=t.find(l=>l.id===a);if(!c)break;if(c.workflow?.kind==="goal"&&c.workflow.paused)return c;a=c.parentTaskId}return e.workflow?.paused?e:null}function tO({group:e,sessions:t,active:r,onOpenSession:n,onAttentionChange:a,onManageMembers:c,board:l=!1,boardNavigation:h,boardSettings:p,paneKey:m,agents:x=[],defaultCwd:y,onTeamReady:w}){const v=`termdock:tasks:${location.origin}:${e.id}`,[k,L]=b.useState([]),E=b.useRef(k);E.current=k;const[R,B]=b.useState(null),[W]=b.useState(()=>Il.getState().ensure(v,{draft:eO(`${v}:draft`),selectedId:Mo(`${v}:selected`,null),creating:!1,mobileDetail:!1})),{selectedId:F,mobileDetail:U,creating:V,draft:Z}=Il(ne=>ne.views[v]??W),le=vh(v,"selectedId"),xe=vh(v,"mobileDetail"),fe=vh(v,"creating"),te=vh(v,"draft"),[ke,$e]=b.useState(!1),[Y,Ae]=b.useState(!1),lt=b.useRef(null),Ce=b.useRef(null),ye=b.useRef(!1),_e=b.useCallback(ne=>{!ne&&Ce.current===document.activeElement&&(ye.current=!0),Ce.current=ne,ne&&ye.current&&(ye.current=!1,ne.focus())},[]);b.useEffect(()=>{const ne=lt.current;if(!ne)return;const ht=new ResizeObserver(zt=>$e(zt[0].contentRect.width>=(l?1100:760)));return ht.observe(ne),()=>ht.disconnect()},[l]);const[je,re]=b.useState(!1),[Pe,Se]=b.useState(null),Ee=d3(),[Be,Ne]=b.useState(0),[oe,He]=b.useState(null),[rt,mt]=b.useState(!1),[de,Ye]=b.useState(0),st=ne=>Ye(ht=>Math.max(0,ht+ne)),[Ie,We]=b.useState("");b.useEffect(()=>{if(!Ie)return;const ne=setTimeout(()=>We(""),5e3);return()=>clearTimeout(ne)},[Ie]);const[Te,H]=b.useState("open"),[ae,be]=b.useState(""),Ze=b.useRef(!1),Je=b.useRef(!0),Tt=b.useRef(new Map),Wt=b.useRef(!1),Mt=e.sessionIds.flatMap(ne=>{const ht=t.find(zt=>zt.sessionId===ne);return ht?[ht]:[]}),vt=Mt.map(ne=>({...ne,name:gu(ne,Mt)})),Yt=Z.coordinator||Mo(`${v}:lead`,""),Qt=vt.find(ne=>ne.sessionId===Yt)?.sessionId||vt.find(ne=>ne.agent)?.sessionId||vt[0]?.sessionId||"",Xt=vt.filter(ne=>ne.sessionId!==Qt&&ne.agent).map(ne=>ne.sessionId),[Ut,Lt]=b.useState(!1),[pe,Ge]=b.useState(!1),[ft,q]=b.useState(()=>Mo(`${v}:agent`,x[0]?.slug??"")),[at,Vt]=b.useState(()=>Mo(`${v}:launch-profile`,e.defaultLaunchProfileId??"")),Ve=e.launchProfiles?.find(ne=>ne.id===at),De=Ve?.agentSlug??ft,[er,et]=b.useState(()=>Mo(`${v}:cwd`,vt[0]?.cwd??y??""));b.useEffect(()=>{!ft&&x[0]&&q(x[0].slug)},[x,ft]);const Ct=!vt.find(ne=>ne.sessionId===Qt)?.agent||!Xt.length,[Nt,gt]=b.useState(null),bt=!!Z.spec.trim()&&(!!Nt||!Ct||!e.federated&&(!at||!!Ve)&&!!x.find(ne=>ne.slug===De)&&!!er.trim()),It=k.find(ne=>ne.id===F)??null,yt=R?.id===F?R:null;b.useEffect(()=>(Je.current=!0,()=>{Je.current=!1}),[]),b.useEffect(()=>{Na(`${v}:draft`,Z)},[v,Z]),b.useEffect(()=>{Na(`${v}:selected`,F)},[v,F]),b.useEffect(()=>{const ne=zt=>{const Pt=zt.detail;Pt?.groupId===e.id&&(Na(`${v}:open-task`,null),le(Pt.taskId),xe(!0),fe(!1),H("all"),pr())};window.addEventListener("open-collaboration-task",ne);const ht=Mo(`${v}:open-task`,null);return ht&&(le(ht),xe(!0),H("all"),Na(`${v}:open-task`,null)),()=>window.removeEventListener("open-collaboration-task",ne)},[e.id]),b.useEffect(()=>{if(!r||!It||R?.id===It.id&&R.revision===It.revision)return;let ne=!1;return yw(It.id).then(ht=>{ne||(B(ht.task),Se(null))}).catch(ht=>{ne||Se(ht instanceof Error?ht.message:"任务详情加载失败")}),()=>{ne=!0}},[r,It?.id,It?.revision,R?.id,R?.revision,Be]);const pr=async()=>{if(!Wt.current){Wt.current=!0;try{const ne=await o3(e.id);Je.current&&(L(ne.tasks),re(!0),Se(null),Ne(ht=>ht+1))}catch(ne){Je.current&&Se(ne instanceof Error?ne.message:"任务加载失败")}finally{Wt.current=!1}}};b.useEffect(()=>{if(!r)return;pr();const ne=()=>{!document.hidden&&navigator.onLine!==!1&&pr()},ht=setInterval(ne,2500);return document.addEventListener("visibilitychange",ne),window.addEventListener(Vh,ne),window.addEventListener("pageshow",ne),()=>{clearInterval(ht),document.removeEventListener("visibilitychange",ne),window.removeEventListener(Vh,ne),window.removeEventListener("pageshow",ne)}},[r,e.id]);const nr=ne=>{const ht=JSON.stringify(ne),zt=Mo(`${v}:request`,null);let Pt=Tt.current.get(ht)??(zt?.fingerprint===ht?zt.key:void 0);return Pt||(Pt=crypto.randomUUID(),Tt.current.set(ht,Pt)),Na(`${v}:request`,{fingerprint:ht,key:Pt}),Pt},_r=ne=>{Tt.current.delete(JSON.stringify(ne)),Na(`${v}:request`,null)},un=async(ne,ht)=>{if(rt||Ze.current)return{ok:!1,error:"已有操作正在提交,请稍候。"};Ze.current=!0,mt(!0),He(null),We("");let zt={...ht,expectedRevision:ne.revision};if(["comment","revise"].includes(ht.kind)){const Pt=Mo(`${v}:request`,null);try{const[Cr,gr]=JSON.parse(Pt?.fingerprint??"null"),{expectedRevision:Hr,...En}=gr;Cr===ne.id&&JSON.stringify(En)===JSON.stringify(ht)&&(zt=gr)}catch{}}try{const Pt=await Aw(ne.id,{...zt,idempotencyKey:nr([ne.id,zt])});if(_r([ne.id,zt]),mu.getState().refresh(),Je.current){const Cr=E.current.find(dr=>dr.id===Pt.task.id),gr=Cr&&Cr.revision>Pt.task.revision?Cr:Pt.task;L(dr=>dr.map(Tn=>Tn.id===Pt.task.id&&Tn.revision<=Pt.task.revision?Pt.task:Tn)),B(dr=>dr?.id===Pt.task.id&&dr.revision>Pt.task.revision?dr:Pt.task);const Hr=S6(gr,E.current),En=`${ht.kind==="answer"?"回答已保存":"方案确认已保存"},${Hr?Hr.workflow?.kind==="goal"?"目标仍暂停;恢复目标后才能投递。":"任务仍暂停;继续安排后才能投递。":"投递状态请查看任务记录。"}`;We(["comment","revise"].includes(ht.kind)?"":ht.kind==="retry"?VP(ne,Pt.task):["answer","approve-plan"].includes(ht.kind)?En:ht.kind==="accept"?"已验收此版本结果。":"记录已保存。")}return{ok:!0}}catch(Pt){const Cr=Pt instanceof Error?Pt.message:"操作失败";return Cr.includes("任务已更新")&&_r([ne.id,zt]),Je.current&&(He(["comment","revise"].includes(ht.kind)?null:Cr),pr()),{ok:!1,error:Cr}}finally{Ze.current=!1,Je.current&&mt(!1)}},Ir=async ne=>{if(ne.preventDefault(),rt||de>0||(Z.mode==="goal"?!bt:!Z.title.trim()||!Z.spec.trim())||Ze.current)return;Ze.current=!0,mt(!0),He(null);const ht=Z.mode==="goal",zt={groupId:e.id,title:Z.title.trim()||Z.spec.trim().split(`
133
133
  `)[0].slice(0,100),spec:Z.spec,constraints:Z.constraints,acceptance:Z.acceptance,assigneeSessionId:ht?void 0:Z.assignee||void 0,coordinatorSessionId:ht?Qt:Z.coordinator||void 0,parentTaskId:ht?void 0:Z.parent||void 0,dependsOn:ht?[]:Z.dependencies,managed:ht,isolated:Z.isolated,reviewerSessionIds:ht?Xt:void 0};try{if(ht&&(Ct||Nt)){Ge(!0);const Cr=Nt??await vw(e.id,{agentSlug:De,...at?{launchProfileId:at}:e.launchProfiles?.length?{launchProfileId:""}:{},cwd:er.trim()});Ge(!1),gt(Cr),zt.coordinatorSessionId=Cr.coordinatorSessionId,zt.reviewerSessionIds=Cr.reviewerSessionIds,Na(`${v}:agent`,ft),Na(`${v}:cwd`,er.trim()),Na(`${v}:launch-profile`,at)}const{task:Pt}=await ww({...zt,idempotencyKey:nr(zt)});_r(zt),Je.current&&(L(Cr=>[Pt,...Cr.filter(gr=>gr.id!==Pt.id)]),le(Pt.id),xe(!0),B(Pt),ht&&Na(`${v}:lead`,zt.coordinatorSessionId),gt(null),w?.(),te(z0),fe(!1),H("open"),be(""),We(ht?"目标已提交,协调者收到后开始拆分与分派。后续评审和依赖由服务接续。":"任务已保存。分派后由服务端持续投递。"))}catch(Pt){Je.current&&He(Pt instanceof Error?Pt.message:"创建失败")}finally{Ze.current=!1,Je.current&&(mt(!1),Ge(!1))}},me=(ne,ht)=>{if(!ht)return"用户";const zt=ne.memberSessions[Su(ht)];return vt.find(Pt=>Pt.sessionId===zt)?.name??t.find(Pt=>Pt.sessionId===zt)?.name??"暂不可用的成员"},Gr=k.filter(ne=>(Te==="all"?!0:Te==="archive"?ne.status!=="open":ne.status==="open")&&(Te==="all"||Te==="attention"||ne.workflow?.kind!=="step")&&(Te!=="attention"||$i(ne))&&(!ae.trim()||`${ne.title} ${ne.spec} ${ne.attempts.map(ht=>me(ne,ht.assignee)).join(" ")}`.toLowerCase().includes(ae.trim().toLowerCase()))),it=k.filter($i).length;b.useEffect(()=>{a?.(it)},[it,a]);const dt=!!It&&(l?U:ke||U),sr=()=>{fe(!1),requestAnimationFrame(()=>Ce.current?.focus())},An=ne=>{Il.getState().updateDetail(`${v}:${ne}`,"view","overview"),le(ne),xe(!0),We("")},on=k.filter($i).filter(ne=>!ae.trim()||`${ne.title} ${ne.spec} ${ne.attempts.map(ht=>me(ne,ht.assignee)).join(" ")}`.toLowerCase().includes(ae.trim().toLowerCase())),Me=(ne,ht=!1)=>{const zt=ne.attempts.find(dr=>dr.id===ne.activeAttemptId),Pt=ne.children?.filter(dr=>dr.status==="accepted").length??0,Cr=ne.children?.filter(dr=>dr.status!=="closed").length??0,gr=$f(ne),Hr=gr.length>1?gr.find(dr=>dr.source!=="member"):null,En=(ht?ne.decisions.find(dr=>dr.status==="pending")?.question:"")||gr[0]?.summary||zt?.report?.summary||zt?.report?.content;return s.jsxs("button",{type:"button","aria-pressed":F===ne.id,className:`group flex min-h-11 w-full items-start gap-3 rounded-xl p-3 text-left transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary ${F===ne.id?"bg-surface-2":"hover:bg-surface-2/70"}`,onClick:()=>An(ne.id),children:[s.jsx("span",{className:`mt-0.5 shrink-0 ${ht||ne.status==="accepted"?"text-primary":"text-muted-foreground"}`,children:ht?s.jsx(Td,{size:16}):ne.status==="accepted"?s.jsx(Iu,{size:16}):s.jsx(Eu,{size:16})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block break-words text-sm font-medium leading-5 text-foreground",children:ne.title}),s.jsx("span",{className:`mt-1 block text-xs leading-5 ${ht?"text-primary":"text-muted-foreground"}`,children:Qc(ne)}),En&&s.jsx("span",{className:"mt-1 block line-clamp-2 break-words text-xs leading-5 text-muted-foreground",children:En}),Hr&&s.jsxs("span",{className:`mt-1 block line-clamp-2 break-words text-xs leading-5 ${Hr.source==="system"?"text-destructive":"text-muted-foreground"}`,children:[Hr.label,":",Hr.summary]}),Cr>0&&s.jsxs("span",{className:"mt-2 flex items-center gap-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"flex gap-1","aria-hidden":"true",children:(ne.children??[]).filter(dr=>dr.status!=="closed").slice(0,8).map(dr=>s.jsx("span",{className:`h-1.5 w-3 rounded-full ${dr.status==="accepted"?"bg-primary":"bg-border/30"}`},dr.id))}),Pt,"/",Cr," 子任务已验收"]}),s.jsxs("span",{className:"mt-2 block text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"block truncate",children:zt?me(ne,zt.assignee):"尚未分派"}),s.jsx(Tf,{task:ne})]})]}),s.jsx(hi,{size:14,className:"mt-1 shrink-0 text-muted-foreground/60"})]},ne.id)},nt=[],wt=new Set([F]);let Mr=It?.parentTaskId;for(;Mr&&!wt.has(Mr);){wt.add(Mr);const ne=k.find(ht=>ht.id===Mr);if(!ne)break;nt.unshift(ne),Mr=ne.parentTaskId}const rn=()=>{const ne=Array.from(lt.current?.querySelectorAll("button[data-task-id]")??[]).find(ht=>ht.dataset.taskId===F);xe(!1),requestAnimationFrame(()=>{ne&&!ne.closest("[hidden]")?ne.focus():Ce.current?.focus()})},Er=V||!l&&je&&k.length===0;return s.jsxs("section",{ref:lt,"aria-label":"协作任务",className:l?"relative flex h-full min-h-0 min-w-0 flex-col gap-2":"space-y-5",children:[l&&(Er||!je)&&h&&s.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border/15 pb-2",children:[h,s.jsx("div",{className:"ml-auto",children:p})]}),(oe||Pe&&Ee==="ready"&&!qh(Pe))&&s.jsxs("div",{role:"alert",className:"flex items-center gap-2 rounded-lg bg-destructive/10 px-3 py-2 text-xs text-destructive",children:[s.jsxs("span",{className:"min-w-0 flex-1 break-words",children:[oe||Pe,!oe&&je?" · 显示最近保存的记录":""]}),s.jsxs("button",{type:"button",className:ra,onClick:()=>oe?He(null):void pr(),children:[s.jsx(yn,{size:14}),oe?"关闭提示":"重试"]})]}),Pe&&qh(Pe)&&!l&&s.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:"正在恢复任务同步,现有记录和草稿已保留"}),Ie&&s.jsx("p",{role:"status",className:"rounded-lg bg-primary/10 px-3 py-2 text-xs leading-5 text-primary",children:Ie}),Er?s.jsxs("form",{onSubmit:ne=>{Ir(ne)},className:`mx-auto w-full max-w-xl space-y-4 ${l?"overflow-auto px-1 py-5":""}`,onKeyDown:ne=>{ne.key==="Escape"&&V&&!ne.defaultPrevented&&!ne.nativeEvent.isComposing&&T1(ne.currentTarget)&&(ne.preventDefault(),ne.stopPropagation(),rt||sr())},children:[s.jsxs("header",{className:"flex items-start gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("h3",{className:"text-lg font-semibold text-foreground",children:Z.mode==="goal"?"一起完成什么?":"新建手动任务"}),s.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:Z.mode==="goal"?"交给协调者拆分,你在这里看交付、回答问题。":"选择负责人,保留分派和验收记录。"})]}),(k.length>0||l)&&s.jsx("button",{type:"button","aria-label":"取消创建,保留草稿",className:`${ra} shrink-0 px-2 text-muted-foreground hover:bg-surface-2`,disabled:rt,onClick:sr,children:s.jsx(Qn,{size:16})})]}),Z.mode==="task"&&s.jsx(Ro,{label:"任务标题",children:s.jsx("input",{className:Qs,required:!0,maxLength:200,value:Z.title,onChange:ne=>te(ht=>({...ht,title:ne.target.value})),placeholder:"要完成什么?"})}),s.jsx(Uh,{paneKey:m,inputKey:`${v}:spec`,active:r&&Er,label:Z.mode==="goal"?"协作目标":"目标与交付要求",className:`${Qs} ${Ct&&Z.mode==="goal"?"min-h-24":"min-h-32"} resize-y text-sm leading-6`,autoFocus:V,required:!0,disabled:rt,value:Z.spec,onUploadChange:st,onChange:ne=>te(ht=>({...ht,spec:typeof ne=="function"?ne(ht.spec):ne})),placeholder:"例如:完善附件预览体验,交付实现和评审结果,保留现有快捷键。"}),Z.mode==="goal"&&Nt&&s.jsxs("section",{role:"status","aria-label":"目标提交阶段",className:"space-y-2 rounded-lg bg-primary/10 px-3 py-2 text-xs leading-5",children:[s.jsx("p",{className:"text-primary",children:"成员已准备,目标尚未提交。重试会复用这些成员。"}),s.jsx("p",{className:"text-muted-foreground",children:"Agent 和工作目录已用于准备成员,因此暂时锁定;目标正文仍可修改。"}),c&&s.jsx("button",{type:"button",className:si,disabled:rt,onClick:()=>{w?.(),c()},children:"查看已准备的成员"})]}),Z.mode==="goal"&&(Ct||Nt)?s.jsxs("fieldset",{disabled:rt||!!Nt,className:"space-y-3",children:[s.jsx("legend",{className:"mb-2 text-xs text-muted-foreground",children:Nt?"已用于准备成员的配置":"首次开始时配置 Agent"}),(!!e.launchProfiles?.length||!!at)&&s.jsxs(Ro,{label:"启动方案",children:[s.jsxs("select",{"aria-label":"协作启动方案",className:Qs,value:at,onChange:ne=>Vt(ne.target.value),children:[s.jsx("option",{value:"",children:"Agent 默认命令"}),e.launchProfiles?.map(ne=>s.jsxs("option",{value:ne.id,children:[ne.name," · ",x.find(ht=>ht.slug===ne.agentSlug)?.displayName??ne.agentSlug]},ne.id))]}),Ve&&s.jsxs("details",{className:"text-xs leading-5 text-muted-foreground",children:[s.jsx("summary",{className:"min-h-11 cursor-pointer py-2",children:s.jsx("span",{className:"line-clamp-2 break-words",children:Ve.notes||"查看启动命令与使用备注"})}),s.jsx("p",{"aria-label":"完整使用备注",className:"whitespace-pre-wrap break-words",children:Ve.notes}),s.jsx("code",{className:"mt-1 block break-all",children:Ve.command})]}),at&&!Ve&&s.jsx("p",{role:"alert",className:"text-xs text-destructive",children:"原方案已删除,请重新选择。"})]}),!Ve&&s.jsx(Ro,{label:"Agent",children:s.jsxs("select",{"aria-label":"协作 Agent",className:Qs,disabled:!!Ve,value:De,onChange:ne=>q(ne.target.value),children:[s.jsx("option",{value:"",disabled:!0,children:"选择已安装的 Agent"}),x.map(ne=>s.jsx("option",{value:ne.slug,children:ne.displayName},ne.slug))]})}),s.jsxs(Ro,{label:"工作目录",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{"aria-label":"工作目录",className:`${Qs} min-w-0 flex-1`,value:er,onChange:ne=>et(ne.target.value),placeholder:"选择项目所在的目录"}),s.jsx("button",{type:"button",className:si,onClick:()=>Lt(!0),children:"浏览目录"})]}),Ut&&s.jsx(b.Suspense,{fallback:s.jsx("p",{className:"text-xs",children:"正在打开目录…"}),children:s.jsx(KP,{open:!0,initialPath:er.trim()||y||"/",title:"选择协作项目目录",onCancel:()=>Lt(!1),onConfirm:ne=>{et(ne),Lt(!1)}})})]}),!Nt&&s.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"开始时配置协调者与执行/评审成员,后续目标复用。"}),e.federated&&s.jsxs("p",{role:"alert",className:"text-xs text-muted-foreground",children:["跨服务组请从成员设置添加 Agent。",c&&s.jsx("button",{type:"button",className:si,onClick:c,children:"管理成员"})]}),!x.length&&s.jsxs("p",{role:"alert",className:"text-xs text-muted-foreground",children:["尚未检测到可启动的 Agent。安装后刷新,或从成员设置复用现有 Agent。",c&&s.jsx("button",{type:"button",className:si,onClick:c,children:"管理成员"})]})]}):Z.mode==="goal"?s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"shrink-0 text-xs text-muted-foreground",children:"协调者"}),s.jsx("select",{"aria-label":"协调者",className:`${Qs} min-w-0 flex-1`,value:Qt,onChange:ne=>te(ht=>({...ht,coordinator:ne.target.value})),children:vt.map(ne=>s.jsxs("option",{value:ne.sessionId,disabled:!ne.agent,children:[ne.name,ne.agent?"":"(需要启动 Agent)"]},ne.sessionId))})]}):s.jsx(Ro,{label:"分派给",children:s.jsxs("select",{className:Qs,value:Z.assignee,onChange:ne=>te(ht=>({...ht,assignee:ne.target.value})),children:[s.jsx("option",{value:"",children:"先保存,稍后分派"}),vt.map(ne=>s.jsx("option",{value:ne.sessionId,children:ne.name},ne.sessionId))]})}),s.jsxs("details",{className:"border-y border-border/15",children:[s.jsxs("summary",{className:"flex min-h-11 cursor-pointer items-center gap-2 text-xs text-muted-foreground",children:["验收标准与更多设置",(Z.acceptance||Z.constraints)&&s.jsx("span",{className:"text-primary",children:"已补充"})]}),s.jsxs("div",{className:"space-y-3 pb-4",children:[s.jsx(Ro,{label:"验收标准(选填)",children:s.jsx("textarea",{className:`${Qs} min-h-20 resize-y`,value:Z.acceptance,onChange:ne=>te(ht=>({...ht,acceptance:ne.target.value})),placeholder:"什么结果满足要求?"})}),s.jsx(Ro,{label:"约束(选填)",children:s.jsx("textarea",{className:`${Qs} min-h-20 resize-y`,value:Z.constraints,onChange:ne=>te(ht=>({...ht,constraints:ne.target.value})),placeholder:"必须保留什么?哪些操作需要先问你?"})}),Z.mode==="goal"?s.jsxs("label",{className:"flex min-h-11 items-start gap-2 text-xs leading-5 text-muted-foreground",children:[s.jsx("input",{type:"checkbox",className:"mt-1",checked:Z.isolated,onChange:ne=>te(ht=>({...ht,isolated:ne.target.checked}))}),s.jsxs("span",{children:["代码任务使用独立目录",s.jsx("br",{}),s.jsx("span",{className:"text-[11px]",children:"协调者自动区分查询与代码任务;查询复用成员会话,只有代码需要目录与集成。"})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(Ro,{label:"协调者",children:s.jsxs("select",{className:Qs,value:Z.coordinator,onChange:ne=>te(ht=>({...ht,coordinator:ne.target.value})),children:[s.jsx("option",{value:"",children:"由用户协调"}),vt.map(ne=>s.jsx("option",{value:ne.sessionId,children:ne.name},ne.sessionId))]})}),s.jsx(Ro,{label:"父任务",children:s.jsxs("select",{className:Qs,value:Z.parent,onChange:ne=>te(ht=>({...ht,parent:ne.target.value})),children:[s.jsx("option",{value:"",children:"独立任务"}),k.filter(ne=>!ne.workflow).map(ne=>s.jsx("option",{value:ne.id,children:ne.title},ne.id))]})}),s.jsxs("fieldset",{className:"space-y-1",children:[s.jsx("legend",{className:"text-xs text-muted-foreground",children:"需先验收的依赖任务"}),k.filter(ne=>ne.status!=="closed").map(ne=>s.jsxs("label",{className:"flex min-h-11 items-center gap-2 text-xs text-foreground",children:[s.jsx("input",{type:"checkbox",checked:Z.dependencies.includes(ne.id),onChange:ht=>te(zt=>({...zt,dependencies:ht.target.checked?[...zt.dependencies,ne.id]:zt.dependencies.filter(Pt=>Pt!==ne.id)}))}),ne.title]},ne.id))]})]}),s.jsx("button",{type:"button",className:`${ra} text-muted-foreground hover:bg-surface-2`,onClick:()=>te(ne=>({...ne,mode:ne.mode==="goal"?"task":"goal"})),children:Z.mode==="goal"?"改为手动分派任务":"改为自动协作目标"})]})]}),s.jsxs("button",{className:`${cl} w-full`,disabled:rt||de>0||(Z.mode==="goal"?!bt:!Z.title.trim()||!Z.spec.trim()),children:[rt?s.jsx(yn,{size:14,className:"animate-spin"}):s.jsx(q0,{size:14}),rt?pe?"正在准备成员…":"提交中…":Z.mode==="goal"?Nt?"重试提交目标":"开始协作":Z.assignee?"创建并分派":"保存任务"]}),s.jsx("p",{className:"text-center text-[11px] leading-5 text-muted-foreground",children:Z.mode==="goal"?"拆分任务 → 执行与独立评审 → 你验收结果":"草稿自动保存,分派后保留投递与回复记录。"})]}):l&&je?s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"sr-only",children:"任务看板"}),s.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 gap-5",children:[s.jsx("div",{hidden:dt,className:`${dt?"hidden":"flex"} min-h-0 min-w-0 flex-1`,children:s.jsx(ZP,{navigation:h,settings:p,action:s.jsxs("button",{ref:_e,type:"button",className:cl,disabled:rt,onClick:()=>fe(!0),children:[s.jsx(Us,{size:14}),"新目标"]}),storage:v,tasks:k,selectedId:dt?F:null,name:me,onSelect:An})}),dt&&s.jsxs("aside",{"aria-label":"任务详情",className:"mx-auto flex min-h-0 min-w-0 w-full max-w-[1040px] flex-col",children:[s.jsx("nav",{"aria-label":"任务位置",className:"mb-2 shrink-0",children:s.jsxs("ol",{className:"flex min-w-0 items-center gap-1 text-xs text-muted-foreground",children:[s.jsx("li",{className:"shrink-0",children:s.jsx("button",{type:"button","aria-label":"返回看板",title:"查看此协作组的任务看板",className:`${ra} px-2 hover:bg-surface-2`,onClick:rn,children:"看板"})}),nt.map(ne=>s.jsxs("li",{className:"flex min-w-0 flex-1 items-center gap-1 sm:max-w-xs sm:flex-none",children:[s.jsx(hi,{"aria-hidden":"true",size:12,className:"shrink-0"}),s.jsx("button",{type:"button","aria-label":`查看${ne.workflow?.kind==="goal"?"目标":"父任务"}:${ne.title}`,title:`查看${ne.workflow?.kind==="goal"?"目标":"父任务"}:${ne.title}`,className:`${ra} min-w-0 px-2 hover:bg-surface-2`,onClick:()=>An(ne.id),children:s.jsxs("span",{className:"truncate",children:[ne.workflow?.kind==="goal"?"目标":"父任务",":",ne.title]})})]},ne.id)),s.jsxs("li",{"aria-current":"page",className:"flex shrink-0 items-center gap-1",children:[s.jsx(hi,{"aria-hidden":"true",size:12}),s.jsx("span",{className:"px-2",children:It?.parentTaskId?"子任务详情":It?.workflow?.kind==="goal"?"目标详情":"任务详情"})]})]})}),s.jsx("div",{className:"min-h-0 flex-1",children:yt?s.jsx(hb,{reader:!0,paneKey:m,active:r,task:yt,tasks:k,members:vt,busy:rt,name:ne=>me(yt,ne),act:ne=>un(yt,ne),storage:v,onSelectTask:An,onOpenSession:async ne=>{const ht=t.find(zt=>zt.sessionId===yt.memberSessions[Su(ne)]);if(!ht){He("成员会话暂不可用,任务历史已保留。");return}try{await n(ht)}catch(zt){He(zt instanceof Error?zt.message:"无法打开终端")}}},yt.id):s.jsx("p",{role:"status",className:"py-8 text-center text-xs text-muted-foreground",children:"正在加载任务详情…"})})]})]})]}):!je&&!k.length?s.jsxs("div",{role:"status",className:"space-y-3 py-8",children:[s.jsx("p",{className:"text-center text-xs text-muted-foreground",children:Pe?"任务暂时无法加载,请重试。":"正在加载目标…"}),!Pe&&[0,1,2].map(ne=>s.jsx("div",{className:"h-14 animate-pulse rounded-lg bg-surface-2"},ne))]}):s.jsxs(s.Fragment,{children:[(!dt||ke)&&s.jsxs("header",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-semibold text-foreground",children:"协作目标"}),s.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground",children:[k.filter(ne=>ne.status==="open"&&ne.workflow?.kind!=="step").length," 个进行中 · ",k.filter(ne=>ne.status==="accepted"&&ne.workflow?.kind!=="step").length," 个已验收"]})]}),s.jsxs("button",{ref:_e,type:"button",className:cl,disabled:rt,onClick:()=>fe(!0),children:[s.jsx(Us,{size:14}),"新目标"]})]}),s.jsxs("div",{className:ke&&dt?"grid items-start gap-6 grid-cols-[260px_minmax(0,1fr)]":"",children:[(!dt||ke)&&s.jsxs("div",{className:"min-w-0 space-y-5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{"aria-label":"任务筛选",className:`${Qs} min-w-0 flex-1 border-transparent bg-transparent`,value:Te,onChange:ne=>H(ne.target.value),children:[s.jsx("option",{value:"open",children:"进行中的目标"}),s.jsxs("option",{value:"attention",children:["需要你处理(",it,")"]}),s.jsx("option",{value:"archive",children:"已归档"}),s.jsx("option",{value:"all",children:"全部任务"})]}),s.jsx("button",{type:"button","aria-label":"搜索任务","aria-expanded":Y,className:`${ra} shrink-0 px-3 text-muted-foreground hover:bg-surface-2`,onClick:()=>{Ae(ne=>!ne),be("")},children:s.jsx(El,{size:16})})]}),Y&&s.jsx("input",{"aria-label":"搜索任务或负责人",autoFocus:!0,className:Qs,value:ae,onChange:ne=>be(ne.target.value),placeholder:"搜索目标、内容或负责人"}),Te==="open"&&on.length>0&&s.jsxs("section",{"aria-label":"需要你处理",className:"rounded-xl bg-surface-2/40 p-1",children:[s.jsxs("h4",{className:"flex items-center justify-between px-3 pb-1 pt-3 text-xs font-medium text-primary",children:["需要你处理",s.jsx("span",{className:"rounded-md bg-primary/15 px-2 py-0.5",children:on.length})]}),on.map(ne=>Me(ne,!0))]}),(Te!=="open"||Gr.some(ne=>!$i(ne))||Gr.length===0)&&s.jsxs("section",{className:"space-y-1",children:[s.jsx("h4",{className:"px-3 text-[11px] font-medium text-muted-foreground",children:Te==="attention"?"需要你处理":Te==="archive"?"已归档":Te==="all"?"全部任务":"当前目标"}),Gr.filter(ne=>Te!=="open"||!$i(ne)).map(ne=>Me(ne,Te==="attention")),!Gr.length&&s.jsxs("div",{className:"px-3 py-6 text-center text-xs leading-5 text-muted-foreground",children:[ae.trim()?"没有匹配的任务。":Te==="attention"?"目前没有需要你处理的任务。":Te==="archive"?"还没有归档任务。":"当前没有进行中的目标。",(Te!=="all"||ae)&&s.jsx("button",{type:"button",className:`${ra} mt-2 text-primary`,onClick:()=>{H("all"),be("")},children:"查看全部任务"})]})]})]}),dt&&s.jsxs("div",{className:"min-w-0",children:[!ke&&s.jsxs("button",{type:"button",className:`${ra} mb-4 -ml-2 text-muted-foreground hover:bg-surface-2`,onClick:()=>xe(!1),children:[s.jsx(h3,{size:14}),"全部目标"]}),yt?s.jsx(hb,{paneKey:m,active:r,task:yt,tasks:k,members:vt,busy:rt,name:ne=>me(yt,ne),act:ne=>un(yt,ne),storage:v,onSelectTask:An,onOpenSession:async ne=>{const ht=t.find(zt=>zt.sessionId===yt.memberSessions[Su(ne)]);if(!ht){He("成员会话暂不可用,任务历史已保留。");return}try{await n(ht)}catch(zt){He(zt instanceof Error?zt.message:"无法打开终端")}}},yt.id):s.jsx("p",{role:"status",className:"py-8 text-center text-xs text-muted-foreground",children:"正在加载任务详情…"})]})]})]})]})}function Ro({label:e,children:t}){return s.jsxs("label",{className:"block space-y-1.5",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:e}),t]})}function hb({reader:e=!1,active:t,paneKey:r,task:n,tasks:a,members:c,name:l,busy:h,act:p,storage:m,onOpenSession:x,onSelectTask:y}){const[w,v]=b.useState(""),[k,L]=b.useState(""),[E,R]=b.useState(""),[B,W]=b.useState(!1),[F,U]=b.useState(null),V=b.useRef(!1),Z=b.useRef(!0);b.useEffect(()=>(Z.current=!0,()=>{Z.current=!1}),[]);const le=b.useRef(null),xe=b.useRef(null);b.useEffect(()=>{!e&&F&&F.state!=="pending"&&t&&requestAnimationFrame(()=>xe.current?.scrollIntoView({block:"nearest"}))},[F]);const fe=b.useRef(null),[te,ke]=b.useState(0),$e=q=>ke(at=>Math.max(0,at+q)),Y=b.useRef(null);b.useEffect(()=>{Y.current?.focus()},[]);const Ae=`${m}:${n.id}`,[lt]=b.useState(()=>Il.getState().ensureDetail(Ae,{feedback:Mo(`${Ae}:feedback`,""),answers:Mo(`${Ae}:answers`,{}),view:"overview"})),{feedback:Ce,answers:ye,view:_e}=Il(q=>q.details[Ae]??lt),je=fm(Ae,"feedback"),re=fm(Ae,"answers"),Pe=fm(Ae,"view");b.useEffect(()=>{fe.current&&(fe.current.scrollTop=0)},[_e]),b.useEffect(()=>Na(`${m}:${n.id}:answers`,ye),[m,n.id,ye]),b.useEffect(()=>Na(`${m}:${n.id}:feedback`,Ce),[m,n.id,Ce]);const Se=n.attempts.find(q=>q.id===n.activeAttemptId),Ee=n.status==="open",Be=S6(n,a),Ne=n.artifacts.filter(q=>q.kind==="result"&&q.attemptId===n.activeAttemptId).at(-1);b.useEffect(()=>{F?.state==="saved"&&Ne?.id!==F.resultId&&U(null)},[Ne?.id,F]);const oe=n.artifacts.filter(q=>q.kind==="plan"&&q.attemptId===n.activeAttemptId).at(-1),He=n.events.filter(q=>q.kind==="revise"&&q.source==="user"&&q.attemptId===n.activeAttemptId).at(-1),rt=Ne&&n.events.some(q=>q.kind==="revise"&&q.attemptId===n.activeAttemptId&&q.createdAt>=Ne.createdAt),mt=e&&Ee&&!!rt,de=F?.state==="saved"&&F.kind==="revise"&&F.resultId===Ne?.id,Ye=n.decisions.filter(q=>q.status==="pending"&&q.attemptId===n.activeAttemptId),st=n.dependsOn.some(q=>a.find(at=>at.id===q)?.status!=="accepted"),Ie=!n.workflow||n.artifacts.filter(q=>q.kind==="review"&&q.reviewsArtifactId===Ne?.id).at(-1)?.verdict==="pass",We=n.children??[],Te=n.workflow?.kind==="goal"&&We.some(q=>!["accepted","closed"].includes(q.status)),H=`任务:${n.title}
134
134
  任务 ID:${n.id}
135
135
  ${n.spec}
@@ -152,7 +152,7 @@ ${Ye.map(q=>`待回答:${q.question}`).join(`
152
152
  `))},Gr,me)},[w,e,n,y,dt?.id,me,Gr,Y,vt]),b.useEffect(()=>{const K=Ir.current;if(!w||!K)return;const Ue=Et=>fe(String(Et.detail));return K.addEventListener("termdock:file-drop-error",Ue),()=>K.removeEventListener("termdock:file-drop-error",Ue)},[w,dt?.id,fe]);const Pt=async K=>{const Ue=dt?.id;fe(null),on(Et=>Et+1);try{const Et=await vd("/tmp",K);if(Et.files.length!==K.length||Et.files.some(tr=>!tr.path))throw new Error("文件路径准备失败,请重试");const kt=Et.files.map(tr=>Tc(tr.path)).join(" ")+" ";if(wt.current===Ue)Tt(tr=>tr+(tr&&!/\s$/.test(tr)?`
153
153
  `:"")+kt);else if(Ue){const tr=Me.current.get(Ue)??{content:"",targets:null},Br={...tr,content:tr.content+`
154
154
  `+kt};Me.current.set(Ue,Br),zt({drafts:{[Ue]:Br}})}}catch(Et){fe(Et instanceof Error?Et.message:"文件上传失败")}finally{on(Et=>Et-1)}},Cr=new Set(L.filter(pm).map(K=>K.sessionId)),gr=Pe.size,Hr=[...Pe].filter(K=>!Cr.has(K)),En=fO(dt,L),dr=Ee.trim().toLocaleLowerCase(),Tn=L.filter(K=>!dr||[gu(K,L),K.name,K.serviceLabel??"",K.cwd,gm(K.currentTask)].some(Ue=>Ue.toLocaleLowerCase().includes(dr))),hn=gb(Tn),Sn=gb(En),ir=K=>!dr&&Ne.has(K),mn=K=>oe(Ue=>{const Et=new Set(Ue);return Et.has(K)?Et.delete(K):Et.add(K),Et});b.useEffect(()=>{Mt(!1),Ut.current!==dt?.id&&Yt(!1),Ut.current=null,Ce(!1),et(!1),rt(!1),De({}),q(new Set(dt?.sessionIds??[])),bt(dt?.defaultLaunchProfileId??"")},[dt?.id]),b.useEffect(()=>{!Ct&&E[0]&&Nt(E[0].slug)},[E,Ct]),b.useEffect(()=>{st([]),H(null)},[dt?.id]),b.useEffect(()=>{if(!B||!n||w&&!y||!dt){We(!1);return}We(!0);let K=!1,Ue=0,Et=!1;const kt=()=>{if(K||Et||document.hidden||navigator.onLine===!1)return;Et=!0;const Br=++Ue;qg(dt.id).then(cr=>{!K&&Br===Ue&&(st(cr.messages),H(null))}).catch(cr=>{!K&&Br===Ue&&H(cr instanceof Error?cr.message:"消息加载失败")}).finally(()=>{Et=!1,!K&&Br===Ue&&We(!1)})};kt();const tr=window.setInterval(kt,3e3);return document.addEventListener("visibilitychange",kt),window.addEventListener(Vh,kt),window.addEventListener("pageshow",kt),()=>{K=!0,window.clearInterval(tr),document.removeEventListener("visibilitychange",kt),window.removeEventListener(Vh,kt),window.removeEventListener("pageshow",kt)}},[dt?.id,n,w,y]),b.useEffect(()=>{!B||dt?.id!==B||it.current||(it.current=!0,Y==="messages"&&Ir.current?.scrollIntoView?.({block:"nearest"}))},[B,dt?.id]);const Qr=async()=>{xe("create-group"),fe(null),te(null);try{if(Hr.length)throw new Error("所选会话已变化,请先清除不可用选择");const K=await Zl({name:je,sessionIds:[...Pe]});re(""),Be(""),x(K.group.id),await ke(),te(`“${K.group.name}”已创建。`),r?await r(K.group.id,"messages"):U&&await U(K.group.id)}catch(K){fe(K instanceof Error?K.message:"创建失败")}finally{xe(null)}},Vr=dt?.sessionIds.filter(K=>be===null||be.includes(K))??[],Wr=async()=>{if(!dt||le||An||!Je.trim()||!Vr.length)return;const K=Je,Ue=dt.id;xe("send-message"),fe(null),te(null);try{const Et=await Tw(dt.id,{fromSessionId:null,toSessionIds:be===null?void 0:Vr,kind:"message",content:Je});if(wt.current===Ue){const cr=Er.current,_n=cr===K?"":cr.startsWith(K)?cr.slice(K.length).replace(/^\n/,""):cr;Tt(_n),zt({drafts:{[Ue]:{content:_n,targets:rn.current}}})}else{const cr=Me.current.get(Ue);if(cr){const _n={...cr,content:cr.content===K?"":cr.content.startsWith(K)?cr.content.slice(K.length).replace(/^\n/,""):cr.content};Me.current.set(Ue,_n),zt({drafts:{[Ue]:_n}})}}const kt=await qg(Ue).catch(()=>null);kt&&wt.current===Ue&&st(kt.messages);const tr=Et.deliveries?.filter(cr=>cr.serviceUnavailable).length??0,Br=Et.deliveries?.filter(cr=>cr.pending>0).length??0;te(tr>0?`已保存消息;${tr} 个接收成员的服务不可达,尚未送达,等待重连`:Br>0?`已保存消息;${Br} 个成员等待投递确认`:`消息已送达 ${Et.messages.length} 个会话`)}catch(Et){fe(Et instanceof Error?Et.message:"发送失败")}finally{xe(null)}},fs=async()=>{if(!dt)return;xe(`delete:${dt.id}`),fe(null),te(null);const K=dt.name;try{await Cw(dt.id,mt),x(null),rt(!1),await ke(),te(`“${K}”已删除`)}catch(Ue){fe(Ue instanceof Error?Ue.message:"删除失败")}finally{xe(null)}},Dr=async()=>{if(!dt)return;const K=[...ft];xe("save-members"),fe(null),te(null);try{const Ue=await Zl({id:dt.id,name:dt.name,sessionIds:K,expectedUpdatedAt:at});x(Ue.group.id),Mt(!1),await ke(),te(`“${dt.name}”成员已更新,共 ${K.length} 个会话`)}catch(Ue){fe(Ue instanceof Error?Ue.message:"成员更新失败")}finally{xe(null)}},Pn=async K=>{if(!dt||!dt.sessionIds.includes(K)){Ge(null);return}const Ue=L.find(kt=>kt.sessionId===K)?.name??K,Et=dt.name;xe(`remove-member:${K}`),fe(null),te(null);try{await Zl({id:dt.id,name:Et,sessionIds:dt.sessionIds.filter(kt=>kt!==K),expectedUpdatedAt:dt.updatedAt}),Ge(null),q(kt=>new Set([...kt].filter(tr=>tr!==K))),De(kt=>Object.fromEntries(Object.entries(kt).filter(([tr])=>tr!==K))),await ke(),te(`已把“${Ue}”移出“${Et}”`)}catch(kt){fe(kt instanceof Error?kt.message:"移出成员失败")}finally{xe(null)}},Sr=async K=>{if(!dt)return;const Ue=Ve[K]??"";xe(`role:${K}`),fe(null),te(null);try{await Lw(dt.id,K,Ue.trim()||null),await ke(),te(Ue.trim()?"定位已保存,该成员每次收到消息都会看到":"定位已清除")}catch(Et){fe(Et instanceof Error?Et.message:"定位保存失败")}finally{xe(null)}},Kr=()=>{bt(dt?.defaultLaunchProfileId??"");const K=L.find(Ue=>Ue.sessionId===R)?.cwd??L.find(Ue=>dt?.sessionIds.includes(Ue.sessionId))?.cwd??"";nr(K),yt(""),un(""),et(!0),Mt(!1)},nn=async()=>{if(!(!dt||!Ct||gt&&!dt.launchProfiles?.some(K=>K.id===gt))){xe("spawn-agent"),fe(null),te(null);try{const K=await Sw(dt.id,{agentSlug:dt.launchProfiles?.find(Ue=>Ue.id===gt)?.agentSlug??Ct,...gt||dt.launchProfiles?.length?{launchProfileId:gt}:{},name:It.trim()||void 0,cwd:pr.trim()||void 0,task:_r.trim()||void 0,mode:Z});et(!1),await ke(),te(`“${K.session.name}”已创建并加入“${K.group.name}”`)}catch(K){fe(K instanceof Error?K.message:"Agent Session 创建失败")}finally{xe(null)}}},Or=bO(Ye,L),ks=K=>s.jsxs("label",{className:"flex cursor-pointer items-start gap-3 px-2 py-2.5 transition hover:bg-surface-2",children:[s.jsx("input",{className:"mt-0.5",type:"checkbox",disabled:!pm(K),checked:Pe.has(K.sessionId),onChange:()=>Se(Ue=>{const Et=new Set(Ue);return Et.has(K.sessionId)?Et.delete(K.sessionId):Et.add(K.sessionId),Et})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"truncate text-[12px] text-foreground",children:gu(K,L)}),s.jsx(mm,{session:K}),s.jsx("span",{className:"shrink-0 text-[9px] text-muted-foreground",children:Wh(K)})]}),s.jsx("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:K.currentTask?`${gm(K.currentTask)} · ${K.cwd}`:K.cwd||K.capability||"终端会话"})]})]},K.sessionId),Pr=K=>{const Ue=Ve[K.sessionId]??"",Et=dt?.roles?.[K.sessionId]??"";return s.jsxs("div",{className:"px-2 py-2 transition hover:bg-surface-2",children:[s.jsxs("label",{className:"flex cursor-pointer items-center gap-3",children:[s.jsx("input",{type:"checkbox",disabled:!dt?.sessionIds.includes(K.sessionId)&&!pm(K),checked:ft.has(K.sessionId),onChange:()=>q(kt=>{const tr=new Set(kt);return tr.has(K.sessionId)?tr.delete(K.sessionId):tr.add(K.sessionId),tr})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-[11px] text-foreground",children:K.name}),s.jsx(mm,{session:K}),s.jsxs("span",{className:"block truncate text-[9px] text-muted-foreground",children:[Wh(K)," · ",K.cwd]})]})]}),s.jsxs("div",{className:"mt-2 flex items-center gap-2 pl-7",children:[s.jsx("span",{className:"shrink-0 text-[9px] text-muted-foreground",children:"定位"}),s.jsx("input",{"aria-label":`${K.name} 的定位`,className:`${Fs} min-h-8 py-1 text-[10px]`,value:Ue,maxLength:200,placeholder:"成员收到的定位;清空后保存可移除",onChange:kt=>De(tr=>({...tr,[K.sessionId]:kt.target.value}))}),s.jsx("button",{"aria-label":`保存 ${K.name} 的定位`,title:Ue.trim()===Et?"定位未变化":"保存此成员的定位",disabled:le!==null||Ue.trim()===Et,className:`${Ar} min-h-8 shrink-0 px-2 text-muted-foreground`,onClick:()=>{Sr(K.sessionId)},children:le===`role:${K.sessionId}`?s.jsx(yn,{size:12,className:"animate-spin"}):s.jsx(di,{size:12})})]})]},K.sessionId)},Xr=s.jsx("nav",{"aria-label":"协作工作区",className:"flex shrink-0 items-center gap-1",children:[["tasks",e||$e?"看板":"目标"],["messages","成员与消息"]].map(([K,Ue])=>s.jsxs("button",{type:"button","aria-label":Ue,"aria-pressed":Y===K,className:`${Ar} min-h-11 ${Y===K?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2"}`,onClick:Et=>{if($e&&K==="tasks"){U?.(dt.id).catch(Br=>fe(Br instanceof Error?Br.message:"无法打开看板"));return}const kt=Et.currentTarget.closest("[data-collaboration-views]"),tr=Et.currentTarget;Ae(K),requestAnimationFrame(()=>{const Br=document.activeElement;Br!==tr&&Br!==document.body&&Br?.isConnected&&!Br.closest("[hidden]")||Array.from(kt?.querySelectorAll('nav[aria-label="协作工作区"] button')??[]).find(cr=>cr.getAttribute("aria-pressed")==="true"&&!cr.closest("[hidden]"))?.focus()})},children:[e&&K==="messages"?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"sm:hidden",children:"成员"}),s.jsx("span",{className:"hidden sm:inline",children:Ue})]}):Ue,!e&&K==="tasks"&&ye>0&&s.jsxs("span",{className:"rounded bg-primary/15 px-1.5 text-[11px] text-primary",children:[ye," 待处理"]})]},K))}),fn=s.jsxs("button",{type:"button","aria-label":"组设置",title:"组设置","aria-expanded":vt,className:`${Ar} min-h-11 shrink-0 text-muted-foreground hover:bg-surface-2`,onClick:K=>{Xt.current=K.currentTarget,Yt(Ue=>!Ue),fe(null),te(null)},children:[s.jsx(G0,{size:14}),e&&s.jsx("span",{className:"sm:sr-only",children:"组设置"})]});return s.jsxs("div",{ref:Qt,className:e?"flex min-h-0 flex-1 flex-col gap-3":$e?void 0:"space-y-3",children:[Te&&ae==="ready"&&!qh(Te)&&s.jsxs("p",{role:"alert",className:"rounded-lg bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:["消息同步暂时失败,正在自动重试:",Te]}),Te&&qh(Te)&&!e&&s.jsx("p",{role:"status",className:"text-[11px] text-muted-foreground",children:"正在恢复消息同步,现有记录已保留"}),s.jsxs("div",{className:e?vt?"min-h-0 flex-1 overflow-auto":"contents":void 0,children:[!B&&m!=="new"&&k.length>0&&s.jsx("div",{hidden:vt,children:s.jsx(HP,{groups:k,sessions:L,busy:le!==null,onOpen:(K,Ue)=>{r?.(K,Ue)},onSettings:(K,Ue)=>{Ut.current=K,x(K),Xt.current=Ue,Yt(!0),fe(null),te(null)},onCreate:()=>{x("new"),rt(!1),te(null)}})}),!B&&(m==="new"||vt)&&k.length>0&&s.jsx("button",{type:"button",className:`${Ar} min-h-11 text-muted-foreground hover:bg-surface-2`,onClick:()=>{vt?Lt():x(k[0].id)},children:"返回协作组"}),vt&&dt&&s.jsx(cO,{group:dt,agents:E,activeSessionId:R,sessions:L,busy:le,setBusy:xe,setError:fe,setNotice:te,refresh:ke,onClose:Lt},dt.id),!B&&v!=="loaded"&&!k.length&&s.jsx("p",{role:"status",className:"py-5 text-xs text-muted-foreground",children:v==="loading"?"正在加载协作组与会话…":"会话加载失败,请重试"}),!dt&&(B||m==="new"||v==="loaded")&&s.jsxs("section",{className:"border-y border-border/15 py-4",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"text-[12px] font-medium text-foreground",children:"创建协作组"}),s.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-muted-foreground",children:"先给协作组命名。成员可以现在选择,也可以以后添加;消息和看板都能独立使用。"})]}),s.jsxs("span",{className:`shrink-0 text-[10px] ${gr>=2?"text-primary":"text-muted-foreground"}`,children:["已选 ",gr," 个"]})]}),s.jsxs("label",{className:"mt-4 block space-y-1 text-[10px] text-muted-foreground",children:["协作组名称",s.jsx("input",{className:Fs,value:je,onChange:K=>re(K.target.value),placeholder:"例如:发布准备"})]}),s.jsxs("details",{className:"mt-3",children:[s.jsxs("summary",{className:"min-h-11 cursor-pointer py-3 text-xs text-muted-foreground",children:["复用已有会话(选填) · 已选 ",gr," 个"]}),L.length>5&&s.jsxs("label",{className:"relative mt-3 block",children:[s.jsx("span",{className:"sr-only",children:"筛选会话"}),s.jsx(El,{size:13,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{className:`${Fs} pl-8`,value:Ee,onChange:K=>Be(K.target.value),placeholder:"按名称、目录或当前任务筛选"})]}),s.jsxs("div",{className:"mt-3 max-h-64 divide-y divide-border/10 overflow-y-auto border-y border-border/10",children:[hn.length<=1?Tn.map(ks):hn.map(K=>{const Ue=ir(K.key);return s.jsxs("div",{children:[s.jsx(xb,{label:K.label,count:K.sessions.length,collapsed:Ue,onToggle:()=>mn(K.key)}),!Ue&&s.jsx("div",{className:"divide-y divide-border/10",children:K.sessions.map(ks)})]},K.key)}),L.length===0&&s.jsx("p",{className:"px-3 py-6 text-center text-[11px] text-muted-foreground",children:v==="loading"?"正在加载会话…":v==="error"?"会话加载失败,请重试":"没有现有会话也可以创建,开始目标时会启动 Agent"}),L.length>0&&Tn.length===0&&s.jsx("p",{className:"px-3 py-6 text-center text-[11px] text-muted-foreground",children:"没有符合筛选条件的会话"})]})]}),Hr.length>0&&s.jsxs("div",{role:"alert",className:"mt-2 text-[11px] text-destructive",children:["有 ",Hr.length," 个所选会话暂不可用。",s.jsx("button",{className:Ar,onClick:()=>Se(K=>new Set([...K].filter(Ue=>Cr.has(Ue)))),children:"清除不可用选择"})]}),s.jsxs("div",{className:"mt-3 flex flex-col gap-2 sm:flex-row sm:items-center",children:[s.jsx("p",{className:`min-w-0 flex-1 text-[10px] ${gr<2?"text-muted-foreground":"text-primary"}`,children:je.trim()?"创建后进入成员消息,看板可随时使用":"请填写协作组名称"}),s.jsxs("div",{className:"flex justify-end gap-2",children:[k.length>0&&s.jsx("button",{className:`${Ar} bg-surface-2 text-foreground`,onClick:()=>x(k[0]?.id??null),children:"取消"}),s.jsxs("button",{disabled:le!==null||!je.trim()||Hr.length>0,className:`${Ar} bg-primary text-primary-foreground`,onClick:()=>{Qr()},children:[le==="create-group"?s.jsx(yn,{size:13,className:"animate-spin"}):s.jsx(Us,{size:13}),"创建协作组"]})]})]})]})]}),dt&&B&&s.jsxs("div",{"data-collaboration-views":!0,hidden:vt,className:e?`${vt?"hidden":"flex"} min-h-0 flex-1 flex-col gap-3`:$e?void 0:"space-y-3",children:[!$e&&(!e||Y==="messages")&&s.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b border-border/15 pb-2",children:[Xr,s.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[e&&Y==="messages"&&s.jsxs("button",{type:"button","aria-label":"放到终端旁",title:V?"在当前终端分屏中使用成员与消息":"先打开一个终端,再嵌入消息面板",disabled:!V||le!==null,className:`${Ar} min-h-11 text-muted-foreground hover:bg-surface-2`,onClick:()=>{xe("dock-messages"),fe(null),V?.().catch(K=>fe(K instanceof Error?K.message:"消息面板打开失败,草稿已保留")).finally(()=>xe(null))},children:[s.jsx(Lc,{size:14}),s.jsx("span",{className:"hidden sm:inline",children:"放到终端旁"})]}),fn]})]}),!$e&&Y==="messages"&&s.jsx("div",{className:"flex gap-1 overflow-x-auto","aria-label":"工作组终端",children:sr.map(K=>s.jsx("button",{type:"button","aria-pressed":K.sessionId===R,title:`${K.name} · ${K.cwd||"终端会话"}`,className:`${Ar} min-h-9 shrink-0 ${K.sessionId===R?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2"}`,onClick:()=>{F(K).catch(Ue=>fe(Ue instanceof Error?Ue.message:"无法打开终端"))},children:gu(K,sr)},K.sessionId))}),!$e&&s.jsx("div",{hidden:Y!=="tasks",className:e?`${Y==="tasks"?"flex":"hidden"} min-h-0 flex-1 flex-col`:void 0,children:s.jsx(tO,{paneKey:h?Gr:void 0,boardNavigation:e?Xr:void 0,boardSettings:e?fn:void 0,board:e,group:dt,sessions:L,agents:E,defaultCwd:L.find(K=>K.sessionId===R)?.cwd??void 0,onTeamReady:ke,active:n&&!vt&&Y==="tasks"&&(!w||y),onAttentionChange:_e,onManageMembers:()=>Ae("messages"),onOpenSession:F},dt.id)}),s.jsxs("div",{hidden:Y!=="messages",className:e?"min-h-0 flex-1 overflow-auto":void 0,children:[s.jsxs("section",{onFocusCapture:()=>V0(Gr),onPointerDownCapture:()=>V0(Gr),"data-termdock-terminal-dropzone":w?R??"collaboration-composer":void 0,onDragOver:K=>{w&&K.preventDefault()},onDrop:K=>{if(!w)return;const Ue=Array.from(K.dataTransfer.files);if(!(Ue.length&&lo()))if(K.preventDefault(),K.stopPropagation(),Ue.length)Pt(Ue);else{const Et=K.dataTransfer.getData("text/plain")||K.dataTransfer.getData("text/uri-list");Et&&Tt(kt=>kt+(kt?`
155
- `:"")+Et)}},ref:Ir,className:w?"":"rounded-xl border border-primary/20 bg-primary/5 px-3 py-3",children:[!w&&s.jsxs("h4",{className:"truncate text-[12px] font-medium text-foreground",children:[dt.name," · 发送给成员"]}),s.jsxs("div",{className:w?"space-y-2":"mt-2 space-y-2",children:[$e&&s.jsxs("div",{className:"relative z-20 flex items-center justify-between gap-2",children:[s.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["发送给 ",s.jsx("span",{className:"text-[9px]",children:"· 可多选"})]}),s.jsxs("details",{className:"relative",onKeyDown:K=>{K.key==="Escape"&&(K.currentTarget.removeAttribute("open"),K.currentTarget.querySelector("summary")?.focus(),K.stopPropagation())},children:[s.jsx("summary",{"aria-label":"更多协作操作",className:"flex min-h-11 min-w-11 cursor-pointer list-none items-center justify-center rounded text-muted-foreground hover:bg-surface-2 sm:min-h-8 sm:min-w-8 [&::-webkit-details-marker]:hidden",children:s.jsx(Qo,{size:16})}),s.jsxs("div",{className:"absolute right-0 top-full z-30 w-44 rounded-lg border border-border/20 bg-surface-2 p-1 shadow-lg",children:[s.jsxs("button",{type:"button",className:`${Ar} min-h-11 w-full justify-start text-foreground hover:bg-surface-elevated`,onClick:K=>{K.currentTarget.closest("details")?.removeAttribute("open"),U?.(dt.id).catch(Ue=>fe(Ue instanceof Error?Ue.message:"无法打开看板"))},children:[s.jsx(Lc,{size:14}),"看板"]}),s.jsx("button",{type:"button","aria-expanded":lt,className:`${Ar} min-h-11 w-full justify-start text-foreground hover:bg-surface-elevated`,onClick:K=>{K.currentTarget.closest("details")?.removeAttribute("open"),Ce(Ue=>!Ue)},children:"成员管理"}),s.jsxs("button",{type:"button","aria-label":"组设置","aria-expanded":vt,className:`${Ar} min-h-11 w-full justify-start text-foreground hover:bg-surface-elevated`,onClick:K=>{K.currentTarget.closest("details")?.removeAttribute("open"),Xt.current=K.currentTarget,Yt(!0),fe(null),te(null)},children:[s.jsx(G0,{size:14}),"组设置"]})]})]})]}),s.jsxs("fieldset",{className:"min-w-0",children:[s.jsx("legend",{className:$e?"sr-only":"mb-1 text-[10px] text-muted-foreground",children:"接收人(可多选)"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:[{id:"*",label:"全组成员"},...dt.sessionIds.map(K=>({id:K,label:(()=>{const Ue=sr.find(Et=>Et.sessionId===K);return Ue?gu(Ue,sr):void 0})()??`${K.slice(0,8)}(离线)`}))].map(({id:K,label:Ue})=>{const Et=K==="*"?be===null:be?.includes(K)??!1,kt=L.find(tr=>tr.sessionId===K);return s.jsxs("span",{className:"inline-flex max-w-full items-center gap-0.5",children:[s.jsxs("button",{type:"button","aria-pressed":Et,onClick:()=>Ze(tr=>K==="*"?null:tr?.includes(K)?tr.filter(Br=>Br!==K):[...tr??[],K]),className:`${v1} min-h-9 min-w-0 gap-1 sm:min-h-7 ${Et?"border-primary/40 bg-primary/15 text-primary":"border-border/20 bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[Et&&s.jsx(di,{size:12,"aria-hidden":"true",className:"shrink-0"}),s.jsx("span",{className:"break-words text-left",children:Ue})]}),kt&&s.jsx("button",{type:"button","aria-label":`打开 ${Ue} 的终端`,title:`打开 ${Ue} 的终端`,className:"inline-flex h-9 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-2 hover:text-primary sm:h-7 sm:w-6",onClick:()=>{W(kt).catch(tr=>fe(tr instanceof Error?tr.message:"无法打开会话"))},children:s.jsx(Lc,{size:12})})]},K)})})]})]}),s.jsxs("label",{className:"mt-2 block space-y-1 text-[9px] text-muted-foreground",children:[s.jsx("span",{className:$e?"sr-only":void 0,children:"内容"}),s.jsx("textarea",{onKeyDown:K=>{K.key==="Enter"&&(K.metaKey||K.ctrlKey)&&!K.nativeEvent.isComposing&&K.keyCode!==229&&(K.preventDefault(),Wr())},onPaste:K=>{const Ue=Array.from(K.clipboardData.files);Ue.length&&(K.preventDefault(),Pt(Ue))},className:`${Fs} min-h-16 max-h-48 resize-y`,value:Je,onChange:K=>Tt(K.target.value),placeholder:"输入消息,可粘贴引用或文件…"})]}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-3",children:[s.jsx("p",{role:"status","aria-live":"polite",title:w&&a?a:void 0,className:`min-w-0 flex-1 text-[9px] leading-relaxed ${w?"truncate":""} ${w&&a?"text-primary":"text-muted-foreground"}`,children:An>0?"正在准备文件路径…":w&&a?a:dt.federated?"消息由服务端后台投递,可查看送达结果;无需保持客户端在线。":"在线成员立即入队;离线成员上线后送达。"}),s.jsxs("button",{disabled:le!==null||An>0||!Je.trim()||!Vr.length,className:`${Ar} shrink-0 bg-primary text-primary-foreground`,title:"发送(⌘ / Ctrl + Enter)",onClick:()=>{Wr()},children:[le==="send-message"?s.jsx(yn,{size:13,className:"animate-spin"}):null,"发送"]})]})]}),s.jsxs("div",{children:[s.jsxs("details",{hidden:$e&&!lt,open:$e?lt:void 0,onToggle:K=>{$e&&Ce(K.currentTarget.open)},className:"mt-4 rounded-xl border border-border/15",children:[s.jsxs("summary",{className:"cursor-pointer px-3 py-3 text-[11px] font-medium text-foreground",children:["管理成员、角色与删除 · ",dt.sessionIds.length," 个成员"]}),s.jsxs("section",{className:"border-t border-border/15 p-3",children:[s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h4",{className:"text-[13px] font-medium text-foreground",children:dt.name}),s.jsxs("p",{className:"mt-1 text-[10px] text-muted-foreground",children:[dt.sessionIds.length," 个成员 · 组 ID:",s.jsx("span",{className:"break-all font-mono",children:k6(dt.id)})]})]}),He?s.jsxs("div",{className:"flex flex-wrap items-center gap-1 sm:justify-end",children:[s.jsx("button",{className:`${Ar} bg-surface-2 px-2 text-foreground`,onClick:()=>rt(!1),children:"取消"}),s.jsxs("button",{disabled:le!==null,className:`${Ar} bg-destructive px-2 text-destructive-foreground`,onClick:()=>{fs()},children:[le===`delete:${dt.id}`?s.jsx(yn,{size:13,className:"animate-spin"}):null,"确认删除"]})]}):s.jsxs("div",{className:"flex flex-wrap items-center gap-1 sm:justify-end",children:[s.jsxs("button",{className:`${Ar} px-2 text-muted-foreground hover:bg-surface-2 hover:text-foreground`,onClick:()=>{q(new Set(dt.sessionIds)),Vt(dt.updatedAt);const K=!Wt;Mt(K),K&&De(Object.fromEntries(dt.sessionIds.map(Ue=>[Ue,dt.roles?.[Ue]??""]))),et(!1)},children:[s.jsx(G0,{size:13}),"管理成员"]}),s.jsxs("button",{className:`${Ar} px-2 text-primary hover:bg-primary/10`,onClick:Kr,children:[s.jsx(Us,{size:13}),"新建 Agent"]}),s.jsx("button",{"aria-label":`删除协作组 ${dt.name}`,title:"删除协作组",disabled:le!==null,className:"rounded-lg p-2 text-muted-foreground transition hover:bg-destructive/10 hover:text-destructive",onClick:()=>{de(dt.updatedAt),rt(!0)},children:s.jsx(zs,{size:14})})]})]}),He&&s.jsxs("p",{role:"alert",className:"mt-2 rounded-lg bg-destructive/10 px-3 py-2 text-[10px] leading-relaxed text-destructive",children:["将删除“",dt.name,"”协作组及其协作记录,",dt.sessionIds.length," 个成员的终端会话会保留。"]}),s.jsx("div",{className:"mt-3 grid divide-y divide-border/10 border-y border-border/10 sm:grid-cols-2 sm:divide-x sm:divide-y-0",children:dt.sessionIds.map(K=>{const Ue=L.find(tr=>tr.sessionId===K),Et=dt.roles?.[K],kt=Ue?.name??K;return s.jsxs("div",{className:`flex min-w-0 items-stretch transition ${pe===K?"bg-destructive/5":"hover:bg-surface-2"}`,children:[s.jsxs("button",{disabled:!Ue,onClick:()=>Ue&&void W(Ue).catch(tr=>fe(tr instanceof Error?tr.message:"无法打开会话")),className:"min-w-0 flex-1 px-3 py-2.5 text-left disabled:cursor-default",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`h-2 w-2 shrink-0 rounded-full ${Ue&&["ready","shell","terminal-connected","service-reachable","working","idle","done"].includes(Ue.status)&&Ue.serviceConnected!==!1?"bg-[var(--success)]":"bg-muted-foreground"}`}),s.jsx("span",{className:"truncate text-[11px] text-foreground",children:kt}),Ue&&s.jsx(mm,{session:Ue}),s.jsx("span",{className:"ml-auto shrink-0 text-[9px] text-muted-foreground",children:Ue?Wh(Ue):"已离线"})]}),s.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-[9px] text-muted-foreground",children:[Et?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"min-w-0 truncate font-medium text-primary/80",children:["定位:",Et]}),s.jsx("span",{className:"shrink-0 text-muted-foreground/50",children:"·"})]}):null,Ue?s.jsx("span",{className:"min-w-0 truncate",children:gm(Ue.currentTask)}):s.jsx("span",{className:"shrink-0",children:"重新上线后可继续接收消息"})]})]}),s.jsx("button",{"aria-label":`把 ${kt} 移出协作组`,"aria-expanded":pe===K,title:"移出协作组",disabled:le!==null,className:`mr-1 shrink-0 self-center rounded-lg p-2 transition ${pe===K?"text-destructive":"text-muted-foreground hover:bg-destructive/10 hover:text-destructive"}`,onClick:()=>Ge(pe===K?null:K),children:s.jsx(zs,{size:13})})]},K)})}),pe&&dt.sessionIds.includes(pe)&&(()=>{const K=L.find(Et=>Et.sessionId===pe)?.name??pe,Ue=le===`remove-member:${pe}`;return s.jsxs("div",{role:"group","aria-label":`确认移除成员 ${K}`,className:"flex flex-wrap items-center gap-x-3 gap-y-2 border-y border-destructive/25 bg-destructive/5 px-3 py-2.5",children:[s.jsx("p",{className:"min-w-0 flex-1 text-[10px] leading-relaxed text-destructive",children:`把“${K}”移出“${dt.name}”?移出后它不再收到这个组的消息,可以随时重新加入`}),s.jsxs("div",{className:"flex shrink-0 gap-2",children:[s.jsx("button",{className:`${Ar} min-h-8 bg-surface-2 px-2 text-[10px] text-foreground`,onClick:()=>Ge(null),children:"取消"}),s.jsxs("button",{disabled:le!==null,className:`${Ar} min-h-8 px-2 text-[10px] bg-destructive text-destructive-foreground`,onClick:()=>{Pn(pe)},children:[Ue?s.jsx(yn,{size:12,className:"animate-spin"}):s.jsx(zs,{size:12}),"移出"]})]})]})})(),Wt&&s.jsxs("div",{className:"mt-4 border-t border-border/15 pt-4",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h5",{className:"text-[11px] font-medium text-foreground",children:"管理成员"}),s.jsx("p",{className:"mt-1 text-[9px] text-muted-foreground",children:"暂不可用的原成员会保留,只有取消勾选才会移出;定位(角色)在每行独立保存,成员收到消息时会看到自己的定位。"})]}),s.jsxs("span",{className:"text-[9px] text-muted-foreground",children:["已选 ",ft.size]})]}),s.jsx("div",{className:"mt-3 max-h-72 divide-y divide-border/10 overflow-y-auto border-y border-border/10",children:Sn.length<=1?En.map(Pr):Sn.map(K=>{const Ue=ir(K.key);return s.jsxs("div",{children:[s.jsx(xb,{label:K.label,count:K.sessions.length,collapsed:Ue,onToggle:()=>mn(K.key)}),!Ue&&s.jsx("div",{className:"divide-y divide-border/10",children:K.sessions.map(Pr)})]},K.key)})}),s.jsxs("div",{className:"mt-3 flex justify-end gap-2",children:[s.jsx("button",{className:`${Ar} bg-surface-2 text-foreground`,onClick:()=>{Mt(!1),De({})},children:"取消"}),s.jsxs("button",{disabled:le!==null||v!=="loaded",className:`${Ar} bg-primary text-primary-foreground`,onClick:()=>{Dr()},children:[le==="save-members"?s.jsx(yn,{size:13,className:"animate-spin"}):s.jsx(di,{size:13}),"保存成员"]})]})]}),er&&s.jsxs("div",{className:"mt-4 border-t border-primary/20 pt-4",children:[s.jsxs("div",{children:[s.jsx("h5",{className:"text-[11px] font-medium text-foreground",children:"创建 Agent Session"}),s.jsx("p",{className:"mt-1 text-[9px] text-muted-foreground",children:"新会话启动后自动加入本组,并收到初始任务和成员信息。"})]}),s.jsx(WP,{group:dt,value:gt,onChange:bt,disabled:le!==null}),s.jsxs("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:[s.jsxs("label",{className:"space-y-1 text-[9px] text-muted-foreground",children:["Agent / Plugin",s.jsx("select",{"aria-label":"新 Agent 类型",className:Fs,disabled:!!gt,value:dt.launchProfiles?.find(K=>K.id===gt)?.agentSlug??Ct,onChange:K=>Nt(K.target.value),children:E.map(K=>s.jsxs("option",{value:K.slug,children:[K.displayName,K.isPlugin?" · Plugin":""]},K.slug))})]}),s.jsxs("label",{className:"space-y-1 text-[9px] text-muted-foreground",children:["会话名称",s.jsx("input",{"aria-label":"新 Agent 会话名称",className:Fs,value:It,onChange:K=>yt(K.target.value),placeholder:"留空则自动命名"})]})]}),s.jsxs("label",{className:"mt-2 block space-y-1 text-[9px] text-muted-foreground",children:["工作目录",s.jsx("input",{"aria-label":"新 Agent 工作目录",className:Fs,value:pr,onChange:K=>nr(K.target.value),placeholder:"默认继承当前会话"})]}),s.jsxs("label",{className:"mt-2 block space-y-1 text-[9px] text-muted-foreground",children:["初始任务",s.jsx("textarea",{"aria-label":"新 Agent 初始任务",className:`${Fs} min-h-16 resize-y`,value:_r,onChange:K=>un(K.target.value),placeholder:"说明它加入后要先完成什么"})]}),s.jsxs("div",{className:"mt-3 flex justify-end gap-2",children:[s.jsx("button",{className:`${Ar} bg-surface-2 text-foreground`,onClick:()=>et(!1),children:"取消"}),s.jsxs("button",{disabled:le!==null||!Ct||!!gt&&!dt.launchProfiles?.some(K=>K.id===gt),className:`${Ar} bg-primary text-primary-foreground`,onClick:()=>{nn()},children:[le==="spawn-agent"?s.jsx(yn,{size:13,className:"animate-spin"}):s.jsx(Ad,{size:13}),"创建并加入"]})]})]})]})]},dt.id),s.jsxs("section",{className:"mt-4",children:[s.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[s.jsx("h4",{className:"text-[11px] font-medium text-foreground",children:"协作记录"}),s.jsxs("span",{className:"text-[9px] text-muted-foreground",children:[Or.length," 条"]})]}),s.jsxs("div",{className:"divide-y divide-border/10 border-y border-border/10 [overflow-wrap:anywhere]",children:[Or.map(K=>s.jsxs("div",{className:"px-2 py-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[9px] text-muted-foreground",children:[s.jsx("span",{className:"font-medium text-primary",children:K.responseKind==="ack"?"收到确认":K.responseKind==="progress"?"进展":K.responseKind==="result"?"结果":xO(K.kind)}),s.jsx("span",{children:K.fromName}),s.jsx("span",{children:"→"}),s.jsx("span",{className:"truncate",children:K.toNames.join("、")}),s.jsx("span",{className:"ml-auto shrink-0",children:new Date(K.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),s.jsx("p",{className:"mt-1 whitespace-pre-wrap text-[11px] leading-relaxed text-foreground",children:K.content}),s.jsx("p",{className:"mt-1 text-[9px] text-muted-foreground",children:K.status==="pending"?"已入队 · 等待投递":K.status==="failed"?"投递失败":K.status==="expired"?"消息已过期,未继续投递":"已写入接收方终端 · 等待接手确认"}),(K.task||K.failureReason)&&s.jsxs("details",{className:"mt-2 text-[10px] text-muted-foreground",children:[s.jsx("summary",{className:"cursor-pointer",children:"任务详情与证据"}),s.jsx("pre",{className:"mt-1 max-h-40 overflow-auto whitespace-pre-wrap break-words",children:JSON.stringify(K.task??{failure_reason:K.failureReason},null,2)})]})]},K.key)),Or.length===0&&s.jsx(_O,{text:Ie?"正在加载协作记录…":"还没有消息。可以直接给成员发送说明或问题。"})]})]})]})]})]})]})}function cO({group:e,agents:t,activeSessionId:r,sessions:n,busy:a,setBusy:c,setError:l,setNotice:h,refresh:p,onClose:m}){const x=n.filter(Y=>e.sessionIds.includes(Y.sessionId)&&!ku(Y.sessionId)),[y,w]=b.useState(()=>nO(e,r&&x.some(Y=>Y.sessionId===r)?r:"")),v=b.useRef(y),[k,L]=b.useState(null),E=Y=>{const Ae={...v.current,...Y};v.current=Ae,sO(e.id,Ae),w(Ae)},{name:R,rules:B,savedName:W,savedRules:F,rulesVersion:U,rulesMemberId:V}=y,Z=Sf(y),le=new TextEncoder().encode(B).length,xe=x.some(Y=>Y.sessionId===V),fe=async()=>{if(!(a||!R.trim())){c("group-name"),l(null),h(null);try{const Y=await Zl({id:e.id,name:R.trim(),sessionIds:y.sessionIds??e.sessionIds,expectedUpdatedAt:y.updatedAt});L(null),E({savedName:Y.group.name,name:Y.group.name,updatedAt:Y.group.updatedAt,sessionIds:Y.group.sessionIds,...B===F?{rules:Y.group.instructions?.text??"",savedRules:Y.group.instructions?.text??"",rulesVersion:Y.group.instructions?.version??""}:{}}),await p(),h("协作组名称已更新")}catch(Y){L(null),l(Y instanceof W0&&Y.status===409?"组设置已被其他人修改。请查看最新状态并确认,名称与群规草稿仍保留。":Y instanceof Error?Y.message:"改名失败")}finally{c(null)}}},te=async()=>{if(!(a||!xe||le>8192)){c("group-rules"),l(null),h(null);try{const Y=await kw(e.id,{sessionId:V,text:B,expectedVersion:U});L(null),E({savedName:Y.group.name,...R===W?{name:Y.group.name}:{},updatedAt:Y.group.updatedAt,sessionIds:Y.group.sessionIds,rules:Y.group.instructions?.text??"",savedRules:Y.group.instructions?.text??"",rulesVersion:Y.group.instructions?.version??""}),await p(),h(B.trim()?"群规已保存,变更通知已入队":"群规已清空,变更通知已入队")}catch(Y){L(null),l(Y instanceof W0&&Y.status===409?"群规已被其他人修改。请查看最新状态并确认,名称与群规草稿仍保留。":Y instanceof Error?Y.message:"群规保存失败")}finally{c(null)}}},ke=()=>{E(xg(e,V)),L(null),l(null)},$e=async()=>{if(!a){c("group-latest"),l(null),h(null),L(null);try{const Ae=(await _1()).groups.find(lt=>lt.id===e.id);if(!Ae)throw new Error("协作组已删除;草稿仍保留,请返回看板查看。");L(Ae)}catch(Y){l(Y instanceof Error?Y.message:"最新状态读取失败;草稿仍保留,请重试。")}finally{c(null)}}};return s.jsxs("section",{"aria-label":"协作组设置",onKeyDown:Y=>{Y.key!=="Escape"||Y.defaultPrevented||Y.nativeEvent.isComposing||(Y.preventDefault(),Y.stopPropagation(),a||m())},className:"mt-3 rounded-xl border border-border/20 bg-surface-2 p-3",children:[s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[s.jsx("h4",{className:"text-[12px] font-medium text-foreground",children:"组设置"}),s.jsx("button",{type:"button",disabled:!!a,"aria-label":"关闭组设置",className:"rounded-lg p-2 text-muted-foreground hover:bg-surface-elevated",onClick:m,children:s.jsx(Qn,{size:14})})]}),s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["协作组名称",s.jsx("input",{autoFocus:!0,className:Fs,value:R,maxLength:240,disabled:!!a,onChange:Y=>E({name:Y.target.value})})]}),s.jsx("div",{className:"mt-2 flex justify-end",children:s.jsx("button",{type:"button",disabled:!!a||!!k||!R.trim()||R.trim()===W,className:`${Ar} min-h-9 bg-primary text-primary-foreground`,onClick:()=>{fe()},children:a==="group-name"?"保存中…":"保存名称"})}),s.jsx(GP,{group:e,agents:t,busy:a,setBusy:c,refresh:p}),s.jsxs("div",{className:"mt-3 space-y-2 border-t border-border/15 pt-3",children:[s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["由本组成员发布群规变更",s.jsxs("select",{className:Fs,value:V,disabled:!!a||!x.length,onChange:Y=>E({rulesMemberId:Y.target.value}),children:[s.jsx("option",{value:"",children:"选择当前服务的一个成员"}),!x.some(Y=>Y.sessionId===V)&&V&&s.jsx("option",{value:V,children:"原成员已不在组内,请重新选择"}),x.map(Y=>s.jsx("option",{value:Y.sessionId,children:Y.name},Y.sessionId))]})]}),s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["群规与协作约定",s.jsx("textarea",{className:`${Fs} min-h-24 resize-y`,value:B,maxLength:8192,disabled:!!a,onChange:Y=>E({rules:Y.target.value}),placeholder:"例如:说明分工、交接要求和结果格式。清空后保存可移除群规。"})]})]}),!xe&&s.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:x.length?"选择发布变更的成员后即可保存,不需要关闭工作台。":"当前服务没有本组成员,请先添加成员或切换到成员所在的服务。已有群规可在此查看。"}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[s.jsx("p",{className:`text-[9px] ${le>8192?"text-destructive":"text-muted-foreground"}`,children:le>8192?"内容过长,请缩短群规":"保存或清空群规会通知本组其他成员"}),s.jsx("button",{type:"button",disabled:!!a||!!k||!xe||le>8192||B===F,className:`${Ar} min-h-9 shrink-0 bg-primary text-primary-foreground`,onClick:()=>{te()},children:a==="group-rules"?"保存中…":B.trim()?"保存群规":"清空群规"})]}),Z&&s.jsx("p",{role:"status",className:"mt-3 text-[11px] leading-5 text-muted-foreground",children:"有未保存修改。关闭、Escape 或切换组后,草稿仍保留在本标签页;名称与群规需分别保存。"}),Z&&s.jsx("button",{type:"button",disabled:!!a,className:`${Ar} mt-2 min-h-11 text-primary hover:bg-surface-elevated`,onClick:()=>{$e()},children:a==="group-latest"?"读取中…":"查看最新状态并保留草稿"}),k&&s.jsxs("section",{"aria-label":"最新组设置",className:"mt-3 space-y-2 rounded-lg bg-surface p-3 text-[11px] leading-5",children:[s.jsx("p",{className:"font-medium text-foreground",children:"确认最新状态后,再分别保存草稿"}),s.jsxs("p",{className:"break-words text-muted-foreground",children:["当前名称:",k.name]}),s.jsxs("p",{className:"whitespace-pre-wrap break-words text-muted-foreground",children:["当前群规:",k.instructions?.text||"未设置"]}),s.jsxs("p",{className:"break-words text-muted-foreground",children:["当前成员(",k.sessionIds.length,"):",k.sessionIds.map(Y=>n.find(Ae=>Ae.sessionId===Y)?.name??k6(Y)).join("、")||"暂无成员"]}),s.jsx("p",{className:"text-muted-foreground",children:"保留你的未保存内容;名称保存将保留以上成员,群规保存会通知当前成员。再次发生修改时仍会检查冲突。"}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx("button",{type:"button",disabled:!!a,className:`${Ar} min-h-11 bg-primary text-primary-foreground`,onClick:()=>{E(rO(v.current,k)),L(null),l(null),h("已确认最新状态,草稿仍保留;请分别保存名称与群规。")},children:"确认最新状态,保留草稿"}),s.jsx("button",{type:"button",className:`${Ar} min-h-11 text-muted-foreground`,onClick:()=>L(null),children:"取消确认"})]})]}),s.jsxs("div",{className:"mt-3 flex justify-between gap-2 border-t border-border/15 pt-2",children:[s.jsxs("button",{type:"button",disabled:!!a,className:`${Ar} min-h-9 text-muted-foreground hover:bg-surface-elevated`,onClick:ke,children:[s.jsx(yn,{size:12}),"重新载入",Z&&"(放弃草稿)"]}),s.jsx("button",{type:"button",disabled:!!a,className:`${Ar} min-h-9 bg-surface text-foreground`,onClick:m,children:Z?"关闭并保留草稿":"关闭"})]})]})}function uO({peers:e,currentGroupId:t,busy:r,setBusy:n,setError:a,setNotice:c,onSelectGroup:l}){const[h,p]=b.useState(null),[m,x]=b.useState(!1),y=e.services??[],w=e.removedServices??[],v=y.filter(E=>!E.connected),k=v.some(E=>E.groups?.some(R=>R.id===t)),L=async(E,R)=>{if(!r){n(`peer:${E}`),a(null),c(null);try{R?await Mw(E):await jw(E),p(null),x(!1),c(R?"协作连接已恢复,正在连接服务":"协作连接已移除,不会再自动重连;已有会话和消息保留")}catch(B){a(B instanceof Error?B.message:R?"重新连接失败":"移除连接失败")}finally{n(null)}}};return s.jsxs("details",{className:"mt-4 shrink-0 rounded-lg border border-border/15",open:k||void 0,children:[s.jsxs("summary",{className:"cursor-pointer px-3 py-2.5 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"font-medium text-foreground",children:"协作连接与管理"}),s.jsx("span",{className:"ml-2",children:e.state==="loading"?"正在加载…":`${y.length-v.length} 个已连接${v.length?` · ${v.length} 个离线`:""}`})]}),s.jsxs("div",{className:"max-h-64 overflow-y-auto border-t border-border/15 px-3 py-2",children:[y.length>0&&s.jsx("p",{className:"mb-1 text-[10px] leading-relaxed text-muted-foreground",children:"与以下服务进行跨服务协作,名称与服务切换器一致。"}),v.length>0&&s.jsx("p",{className:"mb-2 text-[10px] leading-relaxed text-muted-foreground",children:k?"当前协作组的部分服务不可达,消息会保留并等待重连。":"其他服务暂时离线;当前服务内的协作可以继续。不再使用的连接可移除。"}),e.error&&s.jsx("p",{role:"status",className:"mb-2 break-words text-[10px] text-destructive",children:e.error}),e.state==="unsupported"&&s.jsx("p",{className:"mb-2 text-[10px] text-muted-foreground",children:"请更新客户端以管理跨服务连接。"}),s.jsx("div",{className:"divide-y divide-border/10",children:y.map(E=>s.jsxs("div",{className:"py-2.5",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("p",{className:"text-[11px] text-foreground",children:[ec({serviceLabel:E.label,serviceOrigin:E.origin}),s.jsx("span",{className:`ml-2 text-[9px] ${E.connected?"text-[var(--success)]":"text-muted-foreground"}`,children:E.connected?"已连接":E.error==="CONNECTING"?"连接中":"暂时离线"})]}),s.jsx(dO,{service:E})]}),E.serviceId&&s.jsxs("button",{type:"button",disabled:!!r,"aria-label":`移除协作连接 ${E.origin}`,className:`${Ar} min-h-9 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,onClick:()=>p(h===E.serviceId?null:E.serviceId),children:[s.jsx(zs,{size:12}),"移除"]})]}),!!E.groups?.length&&s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1 text-[9px] text-muted-foreground",children:[s.jsx("span",{children:"用于"}),E.groups.map(R=>s.jsx("button",{type:"button",className:"rounded px-1.5 py-1 text-primary hover:bg-primary/10",onClick:()=>l(R.id),children:R.name},R.id))]}),!E.connected&&E.error&&E.error!=="CONNECTING"&&s.jsxs("details",{className:"mt-1 text-[9px] text-muted-foreground",children:[s.jsx("summary",{className:"cursor-pointer",children:yO(E.error)}),s.jsx("p",{className:"mt-1 select-text break-words",children:E.error})]}),h===E.serviceId&&s.jsxs("div",{role:"group","aria-label":"确认移除协作连接",className:"mt-2 rounded-lg bg-surface-2 p-2.5",children:[s.jsx("p",{className:"text-[10px] leading-relaxed text-foreground",children:E.groups?.length?"请先处理上方协作组的成员,再移除这条连接。":"移除后停止与该服务协作,保留已有会话和消息;以后可重新连接。"}),s.jsxs("div",{className:"mt-2 flex justify-end gap-2",children:[s.jsx("button",{type:"button",disabled:!!r,className:`${Ar} min-h-9 text-muted-foreground`,onClick:()=>p(null),children:"取消"}),s.jsx("button",{type:"button",disabled:!!r||!!E.groups?.length,className:`${Ar} min-h-9 bg-destructive text-destructive-foreground`,onClick:()=>{L(E.serviceId,!1)},children:r===`peer:${E.serviceId}`?"正在移除…":"确认移除"})]})]})]},E.serviceId||E.origin))}),y.length===0&&e.state==="ready"&&s.jsx("p",{className:"py-2 text-[10px] text-muted-foreground",children:"当前没有其他协作服务,当前服务内仍可创建协作组。"}),v.length>0&&s.jsxs("button",{type:"button",className:`${Ar} mt-1 min-h-9 text-primary hover:bg-primary/10`,onClick:Rw,children:[s.jsx(yn,{size:12}),"重试连接"]}),w.length>0&&s.jsxs("div",{className:"mt-2 border-t border-border/15 pt-1",children:[s.jsx("button",{type:"button","aria-expanded":m,className:`${Ar} min-h-9 text-muted-foreground hover:bg-surface-2`,onClick:()=>x(E=>!E),children:m?"收起恢复列表":"恢复已移除连接"}),m&&s.jsxs("section",{"aria-label":"恢复已移除连接",className:"mt-1 rounded-lg bg-surface-2 px-2.5 py-2",children:[s.jsx("p",{className:"text-[10px] leading-relaxed text-muted-foreground",children:"以下是恢复记录,连接已停用,不会自动重连。点击恢复后才会重新启用协作。"}),s.jsx("div",{className:"mt-1 divide-y divide-border/10",children:w.map(E=>s.jsxs("div",{className:"flex items-start gap-2 py-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("p",{className:"break-words text-[10px] text-foreground",children:[ec({serviceLabel:E.label,serviceOrigin:E.origin}),s.jsx("span",{className:"ml-2 text-[9px] text-muted-foreground",children:"已停用"})]}),s.jsx("p",{className:"mt-0.5 select-text break-all text-[9px] text-muted-foreground",children:E.accessUrl||E.origin})]}),s.jsx("button",{type:"button",disabled:!!r||!E.serviceId,className:`${Ar} min-h-9 shrink-0 text-primary hover:bg-primary/10`,onClick:()=>{L(E.serviceId,!0)},children:r===`peer:${E.serviceId}`?"恢复中…":"恢复连接"})]},E.serviceId||E.origin))})]})]})]})]},k?"affected":"other")}function dO({service:e}){let t=!1;try{t=["localhost","127.0.0.1","[::1]"].includes(new URL(e.origin).hostname)}catch{}const r=e.accessUrl||(t?"":e.origin);return s.jsxs("details",{className:"mt-1 text-[9px] text-muted-foreground",children:[s.jsx("summary",{className:"w-fit cursor-pointer py-1",children:"连接详情"}),s.jsxs("dl",{className:"mt-1 space-y-1 select-text break-all",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"inline",children:"服务地址:"}),s.jsx("dd",{className:"inline",children:r||"暂未获取,请在服务切换器中查看"})]}),e.serviceId&&s.jsxs("div",{children:[s.jsx("dt",{className:"inline",children:"服务身份:"}),s.jsx("dd",{className:"inline",children:e.serviceId})]})]})]})}function pm(e){return!ku(e.sessionId)||e.serviceConnected!==!1}function hO(e){return e.serviceOrigin?e.serviceOrigin===window.location.origin?"":e.serviceOrigin:ku(e.sessionId)?.origin??""}function gb(e){const t=new Map;for(const r of e){const n=hO(r),a=t.get(n)??{key:n,label:n?ec(r):"本机服务",sessions:[]};n&&a.label==="远端服务"&&(a.label=ec(r)),a.sessions.push(r),t.set(n,a)}return[...t.values()].sort((r,n)=>(r.key?1:0)-(n.key?1:0)||r.label.localeCompare(n.label))}function xb({label:e,count:t,collapsed:r,onToggle:n}){return s.jsxs("button",{type:"button","aria-expanded":!r,onClick:n,className:"flex w-full items-center gap-1.5 bg-surface-2/50 px-2 py-1.5 text-left text-muted-foreground transition hover:bg-surface-elevated",children:[s.jsx(ul,{size:12,className:`shrink-0 transition-transform ${r?"-rotate-90":""}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-[10px] font-semibold uppercase tracking-wide",children:e}),s.jsx("span",{className:"shrink-0 text-[9px] text-muted-foreground/70",children:t})]})}function fO(e,t){const r=new Map(t.map(n=>[n.sessionId,n]));for(const n of e?.sessionIds??[]){if(r.has(n))continue;const a=e?.remoteSessions?.find(c=>c.sessionId===n);r.set(n,a?{...a,status:"offline",serviceConnected:!1}:{sessionId:n,name:n,backendSessionId:null,cwd:"",agent:null,status:"offline",capability:"",currentTask:"暂不可用,保留成员身份",updatedAt:0,...ku(n)?{serviceConnected:!1}:{}})}return[...r.values()]}function mm({session:e}){return!e.serviceOrigin||e.serviceOrigin===window.location.origin?null:s.jsxs("span",{className:"inline-flex max-w-28 shrink-0 items-center gap-1 rounded border border-border/20 px-1 py-0.5 text-[9px] text-muted-foreground",children:[s.jsx(Lc,{size:9}),s.jsx("span",{className:"truncate",children:ec(e)})]})}function Wh(e){return e.serviceConnected===!1?"服务不可达":e.status==="recovering"&&e.route_error==="ROUTE_NOT_CHECKED"?"投递目标未检查":gO(e.status)}function pO(e,t=[]){if(!e)return;const r=t.some(a=>a.sessionId!==e.sessionId&&a.name.trim()===e.name.trim()),n=e.sessionId.startsWith("remote:")?ec(e):"本机服务";return r?`${e.name} · ${n}`:e.name}async function mO(e){e.sessionId.startsWith("remote:")?await e6(e.sessionId):window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:e.sessionId}))}function gO(e){return{ready:"终端可达",shell:"Shell 终端",recovering:"正在检查投递目标",unchecked:"投递目标未检查","terminal-connected":"终端已连接",detached:"终端未连接","agent-exited":"Agent 已退出",offline:"已离线",ambiguous:"需确认目标终端","identity-mismatch":"终端身份已变化",unavailable:"终端暂不可达","service-reachable":"服务可达","service-unreachable":"服务不可达"}[e]??"在线"}function gm(e){if(!e)return"暂无任务摘要";try{const t=JSON.parse(e);if(typeof t.prompt=="string")return _f(t.prompt)||"暂无任务摘要"}catch{}return _f(e)||"暂无任务摘要"}function xO(e){return{message:"消息",ask:"问题",reply:"回复",task:"任务",handoff:"交接",done:"完成"}[e]}function bO(e,t){const r=new Map(t.map(a=>[a.sessionId,pO(a,t)])),n=new Map;for(const a of e){const c=`${a.threadId}:${a.createdAt}:${a.fromSessionId??"user"}:${a.kind}:${a.responseKind??""}:${JSON.stringify(a.task??null)}:${a.content}`,l=n.get(c),h=r.get(a.toSessionId)??a.toSessionId.slice(0,8);if(l){l.toNames.push(h);const p={failed:-2,expired:-1,pending:0,delivered:1,read:2};p[a.status]<p[l.status]&&(l.status=a.status);continue}n.set(c,{key:c,kind:a.kind,content:a.content,createdAt:a.createdAt,fromName:a.fromSessionId?r.get(a.fromSessionId)??a.fromSessionId.slice(0,8):"你",toNames:[h],status:a.status,responseKind:a.responseKind,task:a.task,failureReason:a.failureReason})}return[...n.values()].sort((a,c)=>c.createdAt-a.createdAt)}function yO(e){return/timeout|timed out|超时|operation was aborted/i.test(e)?"连接超时,暂时无法访问该服务。请确认远端服务已启动,并检查网络或 VPN 连接。":/ECONNREFUSED|connection refused/i.test(e)?"远端拒绝连接,请确认服务已启动且端口正确。":/ENOTFOUND|EHOSTUNREACH|ENETUNREACH/i.test(e)?"无法访问远端地址,请检查地址和网络连接。":/certificate|fingerprint|TLS|证书/i.test(e)?"远端证书校验失败,请检查服务连接授权。":"服务连接暂时不可用,可查看连接详情并重试。"}function xm({value:e,query:t}){const r=t.trim().toLocaleLowerCase();if(!r)return s.jsx(s.Fragment,{children:e});const n=e.toLocaleLowerCase(),a=[];let c=0,l;for(;(l=n.indexOf(r,c))>=0;)a.push(e.slice(c,l)),a.push(s.jsx("mark",{className:"rounded bg-primary/15 text-primary",children:e.slice(l,l+r.length)},l)),c=l+r.length;return a.push(e.slice(c)),s.jsx(s.Fragment,{children:a})}function vO({active:e,onClose:t,onNewSession:r,setError:n}){const[a,c]=b.useState(""),[l,h]=b.useState([]),[p,m]=b.useState(0),[x,y]=b.useState(),[w,v]=b.useState(50),[k,L]=b.useState(0),[E,R]=b.useState(!1),[B,W]=b.useState(null),[F,U]=b.useState(null),V=b.useRef(null),Z=b.useRef(0);b.useEffect(()=>{e&&V.current?.focus({preventScroll:!0})},[e]),b.useEffect(()=>{if(!e)return;const fe=++Z.current,te=new AbortController;let ke;W(null),R(!0);const $e=async()=>{try{const Y=await Dw(a.trim(),w,te.signal);if(fe!==Z.current)return;h(Y.results),m(Y.total??Y.results.length),y(Y.index),Y.index?.building&&(ke=window.setTimeout(()=>{$e()},2500))}catch(Y){fe===Z.current&&!te.signal.aborted&&W(Y instanceof Error?Y.message:"搜索失败")}finally{fe===Z.current&&R(!1)}};return ke=window.setTimeout(()=>{$e()},a.trim()?250:0),()=>{window.clearTimeout(ke),te.abort(),++Z.current}},[e,a,w,k]);const le=fe=>{n(null),c(fe),h([]),m(0),v(50)},xe=async fe=>{if(!F){if(fe.live){window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:fe.sessionId})),t();return}if(!(!fe.nativeKey&&!fe.resumeHistoryId)){U(fe.sessionId),n(null);try{const te=fe.nativeKey?await Bw(fe.nativeKey):await p3(fe.resumeHistoryId);if("sessionId"in te&&te.sessionId)window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:te.sessionId}));else if(te.command)r({mode:"shell",cwd:te.cwd,command:te.command});else throw new Error("这条会话暂时无法恢复,请重新搜索");t()}catch(te){n(te instanceof Error?te.message:"恢复失败")}finally{U(null)}}}};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"sticky -top-4 z-20 -mx-4 -mt-4 border-b border-border/15 bg-surface px-4 py-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:"历史会话搜索"}),s.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-muted-foreground",children:"搜索当前服务的 Codex、Claude 历史对话和 Termdock 终端记录,未启动的会话也能找到并恢复。"})]}),s.jsxs("label",{className:"relative mt-3 block",children:[s.jsx("span",{className:"sr-only",children:"搜索历史会话"}),s.jsx(El,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{ref:V,maxLength:512,className:`${Fs} pl-9 pr-9`,value:a,onChange:fe=>le(fe.target.value),placeholder:"搜索会话名称、对话关键词、目录或 session ID"}),E?s.jsx(yn,{size:13,className:"absolute right-3 top-1/2 -translate-y-1/2 animate-spin text-muted-foreground"}):a&&s.jsx("button",{type:"button","aria-label":"清空搜索",className:"absolute right-1.5 top-1/2 -translate-y-1/2 rounded-md p-1.5 text-muted-foreground hover:bg-surface-2 hover:text-foreground",onClick:()=>le(""),children:s.jsx(Qn,{size:13})})]}),x?.building&&s.jsxs("div",{role:"status",className:"mt-2 text-[10px] text-muted-foreground",children:["正在建立历史索引:",x.indexed,"/",x.total," 个会话。可以先搜名称和目录,对话结果会自动补齐。"]}),x?.warning&&s.jsx("p",{role:"status",className:"mt-2 text-[10px] text-destructive",children:x.warning}),!!x?.failed&&s.jsxs("p",{role:"status",className:"mt-2 text-[10px] text-destructive",children:[x.failed," 个会话暂未完成索引,其余结果可正常使用。请稍后刷新重试。"]})]}),s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("p",{className:"text-[11px] text-foreground",children:[a.trim()?`找到 ${p} 个会话`:"最近的会话",p>l.length?` · 显示 ${l.length} 个`:""]}),s.jsxs("button",{type:"button",disabled:E,className:`${Ar} text-muted-foreground hover:bg-surface-2 hover:text-foreground`,onClick:()=>L(fe=>fe+1),children:[s.jsx(yn,{size:12}),"刷新"]})]}),!a.trim()&&s.jsx("p",{className:"text-[10px] text-muted-foreground",children:"记得之前讨论过什么?输入一句话中的关键词,就能找到对应会话。历史对话与索引保存在当前服务机器上。"}),s.jsx("div",{className:"divide-y divide-border/10 border-y border-border/10",children:l.map(fe=>{const te=fe.live||!!(fe.nativeKey||fe.resumeHistoryId),ke=F===fe.sessionId?"正在恢复…":fe.live?"打开会话":te?"恢复会话":"仅供查阅",$e=fe.source==="codex"||fe.source==="claude"?fe.snippet:wO(fe),Y=fe.source==="codex"?"Codex 历史":fe.source==="claude"?"Claude 历史":"终端记录",Ae=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"break-words text-[12px] font-medium text-foreground",children:s.jsx(xm,{value:fe.title,query:a})}),s.jsx("p",{className:"mt-0.5 break-all text-[9px] text-muted-foreground",children:s.jsx(xm,{value:fe.cwd||"项目目录待索引",query:a})})]}),s.jsx("span",{className:`shrink-0 text-[10px] ${fe.live?"text-[var(--success)]":te?"text-primary":"text-muted-foreground"}`,children:ke})]}),$e&&s.jsx("p",{className:"mt-2 line-clamp-3 break-words text-[10px] leading-relaxed text-foreground/75",children:s.jsx(xm,{value:$e,query:a})}),s.jsxs("p",{className:"mt-2 text-[9px] text-muted-foreground",children:[Y," · ",kf(fe.updatedAt),a.trim()?` · ${fe.matchCount>=999?"999+":fe.matchCount} 处匹配`:"",te?"":" · 没有可恢复记录"]}),fe.agentNativeSessionId&&s.jsx("p",{className:"mt-1 select-text break-all text-[9px] text-muted-foreground",children:fe.agentNativeSessionId})]});return te?s.jsx("button",{disabled:!!F,onClick:()=>{xe(fe)},className:"block w-full px-2 py-3 text-left transition hover:bg-surface-2 focus-visible:bg-surface-2 focus-visible:outline-none",children:Ae},fe.nativeKey||fe.sessionId):s.jsx("article",{className:"px-2 py-3",children:Ae},fe.sessionId)})}),p>l.length&&w<5e3&&s.jsx("button",{type:"button",disabled:E,className:`${Ar} w-full bg-surface-2 text-foreground`,onClick:()=>v(fe=>fe+50),children:E?"正在加载…":"加载更多会话"}),B&&s.jsxs("div",{role:"alert",className:"rounded-lg bg-destructive/10 p-3 text-[11px] text-destructive",children:["搜索失败:",B,s.jsx("button",{type:"button",className:`${Ar} ml-2`,onClick:()=>L(fe=>fe+1),children:"重试"})]}),!E&&!B&&l.length===0&&s.jsxs("div",{className:"border-y border-border/15 py-8 text-center",children:[s.jsx("p",{className:"text-[12px] text-foreground",children:x?.building?"历史对话仍在索引,请稍候":x?.warning||x?.failed?"暂未找到结果,部分历史记录尚不可搜索":a.trim()?`没有找到“${a.trim()}”`:"当前服务还没有可搜索的历史会话"}),s.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:x?.building?"新结果会自动显示,也可以先搜会话名称或目录。":"可尝试更短的关键词、项目目录或 session ID;其他机器的历史需切换到对应服务搜索。"}),a.trim()&&s.jsx("button",{className:`${Ar} mt-3 bg-surface-2 text-foreground`,onClick:()=>le(""),children:"查看最近会话"})]})]})}function _f(e){return e.replace(/\u001B\][^\u0007]*(?:\u0007|\u001B\\)/g," ").replace(/\u001B\[[0-?]*[ -/]*[@-~]/g," ").replace(/\(B/g," ").replace(/<[^>]{1,120}>/g," ").replace(/[─━│┃┄┅┆┇┈┉┊┋┌┐└┘├┤┬┴┼╭╮╯╰═║╔╗╚╝╠╣╦╩╬]+/g," ").replace(/([^\p{L}\p{N}\s])\1{3,}/gu," ").replace(/([A-Za-z])\1{12,}/g," ").replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g," ").replace(/\s+/g," ").trim().slice(0,280)}function wO(e){let t=_f(e.snippet);for(const r of[e.title,e.cwd,e.agentSlug])r&&(t=t.split(r).join(" "));return _f(t)}function AO(e){if(e.schedule.kind==="interval")return e.schedule.everyMinutes===60?"每小时":e.schedule.everyMinutes===1440?"每天":`每 ${e.schedule.everyMinutes} 分钟`;const t=["日","一","二","三","四","五","六"];return`${e.schedule.weekdays.length===7?"每天":e.schedule.weekdays.map(n=>`周${t[n]}`).join("、")} ${e.schedule.time}`}function TO(e,t=Date.now(),r=t){if(e.kind==="interval"){const c=e.everyMinutes*6e4,l=Math.max(0,t-r);return r+(Math.floor(l/c)+1)*c}const[n,a]=e.time.split(":").map(Number);for(let c=0;c<=7;c+=1){const l=new Date(t);if(l.setDate(l.getDate()+c),l.setHours(n,a,0,0),l.getTime()>t&&e.weekdays.includes(l.getDay()))return l.getTime()}return t}function kf(e){return new Intl.DateTimeFormat("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(e)}function CO(e){return e==="running"?"投递中":e==="success"?"已投递":e==="failed"?"投递失败":""}function SO(e){return e==="running"?"text-[var(--warning)]":e==="success"?"text-[var(--success)]":e==="failed"?"text-destructive":"text-muted-foreground"}function _O({text:e}){return s.jsx("div",{className:"rounded-xl border border-dashed border-border/20 px-4 py-8 text-center text-[11px] text-muted-foreground",children:e})}function kO({onOpenSettings:e,serverAttention:t,actions:r}){const{t:n}=zr(),[a,c]=b.useState(!1),l=b.useRef(null),h=b.useRef(null),p=b.useRef(null),m=b.useId();return b.useLayoutEffect(()=>{if(!a)return;const x=l.current,y=p.current;if(!x||!y)return;const w=window.visualViewport,v=()=>{const L=x.getBoundingClientRect(),E=(w?.offsetLeft??0)+8,R=(w?.offsetTop??0)+8,B=(w?.width??window.innerWidth)-16,W=(w?.offsetTop??0)+(w?.height??window.innerHeight)-8,F=Math.max(0,Math.min(256,B)),U=Math.max(0,L.top-R-4),V=Math.max(0,W-L.bottom-4),Z=U>=180||U>=V;Object.assign(y.style,{width:`${F}px`,left:`${Math.max(E,Math.min(L.right-F,E+B-F))}px`,top:`${Z?L.top-4:L.bottom+4}px`,maxHeight:`${Z?U:V}px`,transform:Z?"translateY(-100%)":"none"})};v();const k=typeof ResizeObserver>"u"?null:new ResizeObserver(v);return k?.observe(x),window.addEventListener("resize",v),window.addEventListener("scroll",v,!0),w?.addEventListener("resize",v),w?.addEventListener("scroll",v),()=>{k?.disconnect(),window.removeEventListener("resize",v),window.removeEventListener("scroll",v,!0),w?.removeEventListener("resize",v),w?.removeEventListener("scroll",v)}},[a]),b.useEffect(()=>{if(!a)return;p.current?.querySelector('[role="menuitem"]')?.focus({preventScroll:!0});const x=y=>{y.target instanceof Node&&!l.current?.contains(y.target)&&!p.current?.contains(y.target)&&c(!1)};return document.addEventListener("pointerdown",x),()=>document.removeEventListener("pointerdown",x)},[a]),s.jsxs("div",{ref:l,role:"group","data-sidebar-gesture-ignore":!0,"aria-label":n("sidebar.moreActions"),className:"relative z-20 mt-2 flex items-center justify-between gap-2",onKeyDown:x=>{a&&x.key==="Escape"&&(x.preventDefault(),x.stopPropagation(),c(!1),h.current?.focus({preventScroll:!0}))},children:[s.jsxs("button",{type:"button",onClick:e,title:t?n("sidebar.serverAttention"):void 0,className:"inline-flex min-h-9 items-center gap-1.5 whitespace-nowrap rounded-lg px-2 text-[11px] text-muted-foreground transition hover:bg-surface-2 hover:text-foreground focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",children:[s.jsx(XT,{size:14,className:t?"text-destructive":void 0}),s.jsx("span",{children:n("sidebar.settings")})]}),s.jsxs("button",{ref:h,type:"button","aria-haspopup":"menu","aria-expanded":a,"aria-controls":a?m:void 0,onClick:()=>c(x=>!x),onKeyDown:x=>{(x.key==="ArrowDown"||x.key==="ArrowUp")&&(x.preventDefault(),c(!0))},className:`inline-flex min-h-9 items-center gap-1.5 whitespace-nowrap rounded-lg px-2 text-[11px] transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary ${a?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[s.jsx(Qo,{size:15}),s.jsx("span",{children:n("sidebar.moreActions")})]}),a&&Li.createPortal(s.jsx("div",{ref:p,id:m,role:"menu","data-sidebar-gesture-ignore":!0,"data-sidebar-composer-popover":"sidebar-launch-options","aria-label":n("sidebar.moreActions"),className:"fixed z-popover overflow-y-auto overscroll-contain rounded-xl border border-border/15 bg-surface p-1 shadow-[0_12px_32px_var(--app-shadow-soft)] animate-fade-in",onKeyDown:x=>{const y=[...x.currentTarget.querySelectorAll('[role="menuitem"]')],w=y.indexOf(document.activeElement);let v;if(x.key==="ArrowDown")v=(w+1)%y.length;else if(x.key==="ArrowUp")v=(w-1+y.length)%y.length;else if(x.key==="Home")v=0;else if(x.key==="End")v=y.length-1;else if(x.key==="Tab"){c(!1);return}else return;x.preventDefault(),y[v]?.focus({preventScroll:!0})},children:r.map(({label:x,icon:y,onSelect:w,separated:v})=>s.jsxs("div",{role:"none",children:[v&&s.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/40"}),s.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{c(!1),w()},className:"flex min-h-10 w-full items-center gap-2.5 whitespace-nowrap rounded-lg px-2.5 text-left text-[12px] text-foreground transition hover:bg-surface-2 focus:bg-surface-2 focus:outline-none",children:[s.jsx(y,{size:15,className:"shrink-0 text-muted-foreground"}),s.jsx("span",{children:x})]})]},x))}),document.body)]})}const L0=64,bb=10,LO=120;function IO({children:e,open:t,onOpenChange:r,onClose:n,closeLabel:a,closeTitle:c,compact:l}){const h=b.useRef(null),p=b.useRef(null),m=b.useRef(0),[x,y]=b.useState(null),w=x??(t?L0:0);return b.useEffect(()=>{if(!t)return;const v=k=>{k.target instanceof Node&&!h.current?.contains(k.target)&&r(!1)};return document.addEventListener("pointerdown",v,!0),()=>document.removeEventListener("pointerdown",v,!0)},[t,r]),s.jsxs("div",{ref:h,"data-sidebar-gesture-ignore":!0,"data-session-swipe":!0,className:`relative flex min-w-0 flex-1 items-center ${l?"":"gap-1"}`,style:{touchAction:"pan-y"},onPointerDown:v=>{if(m.current=0,!(v.pointerType!=="touch"&&v.pointerType!=="pen")){if(v.isPrimary===!1){p.current=null,y(null);return}!(v.target instanceof Element)||!v.target.closest(".sidebar-session-primary")||(p.current={pointerId:v.pointerId,x:v.clientX,y:v.clientY,startedAt:Date.now(),initialOffset:t?L0:0,offset:t?L0:0,horizontal:!1})}},onPointerMove:v=>{const k=p.current;if(!k||k.pointerId!==v.pointerId)return;const L=v.clientX-k.x,E=v.clientY-k.y;if(!k.horizontal){if(v.defaultPrevented||Date.now()-k.startedAt>=LO||Math.abs(E)>bb){p.current=null;return}if(Math.abs(L)<=bb)return;if(Math.abs(L)<Math.abs(E)*1.5||!t&&L<0){p.current=null;return}k.horizontal=!0,v.currentTarget.setPointerCapture?.(v.pointerId)}v.preventDefault(),k.offset=Math.max(0,Math.min(L0,k.initialOffset+L)),y(k.offset)},onPointerUp:v=>{const k=p.current;!k||k.pointerId!==v.pointerId||(p.current=null,k.horizontal&&(m.current=Date.now()+600,r(k.offset>=L0/2),y(null)))},onPointerCancel:()=>{p.current?.horizontal&&(m.current=Date.now()+600),p.current=null,y(null)},onClickCapture:v=>{if(Date.now()<m.current){m.current=0,v.preventDefault(),v.stopPropagation();return}t&&v.target instanceof Element&&v.target.closest(".sidebar-session-primary")&&(r(!1),v.preventDefault(),v.stopPropagation())},onKeyDown:v=>{t&&v.key==="Escape"&&(v.stopPropagation(),r(!1))},children:[s.jsx("div",{className:"shrink-0 overflow-hidden rounded-md transition-[width] duration-150 ease-out motion-reduce:transition-none",style:{width:w,transition:x===null?void 0:"none"},children:w>0&&s.jsxs("button",{type:"button",tabIndex:t?0:-1,"aria-hidden":!t,"aria-label":c,className:"flex min-h-8 w-16 flex-col items-center justify-center gap-0.5 bg-destructive py-1 text-[10px] text-destructive-foreground",onClick:v=>{v.stopPropagation(),r(!1),n(v)},children:[s.jsx(zs,{size:14}),a]})}),e]})}const yb="recoverable-tmux";function EO({sessions:e,loading:t,attachingName:r,onRefresh:n,onRestore:a,onClose:c}){const{t:l}=zr(),h=Gt(R=>R.collapsedGroups.has(yb)),p=Gt(R=>R.toggleGroupCollapsed),[m,x]=b.useState(null),[y,w]=b.useState(null),[v,k]=b.useState(null),L=b.useRef(!1),E=async R=>{if(!(!c||L.current)){L.current=!0,w(R),k(null);try{await c(R),x(null)}catch(B){k(B instanceof Error?B.message:l("sidebar.closeRecoverableSessionFailed"))}finally{L.current=!1,w(null)}}};return e.length===0?null:s.jsxs("section",{className:"mb-2 shrink-0 rounded-lg bg-[rgb(var(--tmux-rgb)_/_0.07)] p-1","aria-label":l("sidebar.recoverableSessions"),children:[s.jsxs("div",{className:"flex items-center gap-1 text-[10.5px] font-semibold text-[color:var(--tmux)]",children:[s.jsxs("button",{type:"button","aria-expanded":!h,onClick:()=>p(yb),className:"flex min-h-11 min-w-0 flex-1 items-center gap-2 rounded-md px-2 text-left hover:bg-surface-elevated md:min-h-8",children:[s.jsx(hi,{size:12,className:`shrink-0 ${h?"":"rotate-90"}`}),s.jsx(Sc,{size:12,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:l("sidebar.recoverableSessions")}),s.jsx("span",{className:"text-muted-foreground",children:e.length})]}),n&&s.jsx("button",{type:"button",onClick:n,disabled:t||y!==null,className:"inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-50 md:h-7 md:w-7","aria-label":l("sidebar.refreshRecoverableSessions"),title:l("sidebar.refreshRecoverableSessions"),children:s.jsx(yn,{size:11,className:t?"animate-spin":""})})]}),!h&&s.jsx("div",{className:"space-y-0.5",children:e.map(R=>{const B=R.friendlyName?.trim()||R.label?.trim()||R.name,W=Pu(R.cwd??null),F=r===R.name,U=m===R.name;return s.jsxs("div",{children:[s.jsxs("div",{className:"flex min-w-0 items-center",children:[s.jsxs("button",{type:"button",disabled:r!==null||y!==null||U,onClick:()=>a(R),className:"group flex min-h-11 min-w-0 flex-1 items-center gap-2 rounded-md px-2 text-left text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-60 md:min-h-10","aria-label":l("sidebar.restoreRecoverableSession",{name:B}),title:R.cwd||R.name,children:[s.jsx("span",{className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-[rgb(var(--tmux-rgb)_/_0.11)] text-[color:var(--tmux)]",children:F?s.jsx(In,{size:12,className:"animate-spin"}):s.jsx(Nu,{size:12})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-[11.5px] font-semibold text-foreground",children:B}),s.jsx("span",{className:"block truncate text-[9.5px] text-muted-foreground",children:[R.program,W].filter(Boolean).join(" · ")||`tmux:${R.name}`})]}),s.jsx("span",{className:"shrink-0 text-[10px] font-medium text-[color:var(--tmux)] group-hover:text-foreground",children:l(F?"sidebar.restoringRecoverableSession":"sidebar.restore")})]}),c&&s.jsx("button",{type:"button",disabled:r!==null||y!==null,onClick:()=>{x(R.name),k(null)},className:"inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-destructive/15 hover:text-destructive disabled:opacity-50 md:h-7 md:w-7","aria-label":l("sidebar.closeSession",{name:B}),title:l("sidebar.closeSession",{name:B}),children:s.jsx(Qn,{size:12})})]}),U&&s.jsxs("div",{role:"group","aria-label":l("sidebar.closeSession",{name:B}),className:"space-y-2 rounded-md bg-surface px-2 py-2",children:[s.jsx("p",{className:"text-[11px] text-foreground",children:l("sidebar.confirmCloseRecoverableSession",{name:B})}),v&&s.jsx("p",{role:"alert",className:"text-[11px] text-destructive",children:v}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{type:"button",disabled:y!==null,onClick:()=>{x(null),k(null)},className:"min-h-11 rounded-md px-2 text-[11px] text-muted-foreground hover:bg-surface-elevated disabled:opacity-50 md:min-h-8",children:l("common.cancel")}),s.jsx("button",{type:"button",disabled:y!==null,onClick:()=>{E(R.name)},className:"min-h-11 rounded-md bg-destructive/15 px-2 text-[11px] text-destructive hover:bg-destructive/25 disabled:opacity-50 md:min-h-8",children:y===R.name?l("common.loading"):l("sidebar.endRecoverableSession")})]})]})]},R.name)})})]})}function NO(e,t){return E3(e,t)}function I0(e,t){const r=new Set(e),n=t.filter(c=>c.sessionIds.length>=2&&c.sessionIds.every(l=>r.has(l))),a=new Set;return e.flatMap(c=>{const l=n.find(h=>h.sessionIds.includes(c));return l?a.has(l.id)?[]:(a.add(l.id),[{sessionIds:l.sessionIds,workspace:l}]):[{sessionIds:[c]}]})}function E0(e,t,r,n=[]){const a=new Map,c=new Map,l=new Set(e.map(x=>x.id));for(const x of n){const y=x.sessionIds.filter(v=>l.has(v));if(!y.length)continue;const w=y.length===x.sessionIds.length?x:{...x,sessionIds:y};y.forEach(v=>a.set(v,w))}for(const x of t)if(!(x.sessionIds.length<2||!x.sessionIds.every(y=>l.has(y)))&&!x.sessionIds.some(y=>a.has(y)))for(const y of x.sessionIds)c.set(y,x);const h=new Set,p=new Set,m=[];for(const x of e){const y=a.get(x.id);if(y){if(h.has(y.id))continue;h.add(y.id);const k=y.sessionIds.flatMap(L=>{const E=r.get(L);return E?[E]:[]});m.push({kind:"collaboration",id:`collaboration:${y.id}`,group:y,members:k,sessionIds:y.sessionIds});continue}const w=c.get(x.id);if(!w){m.push({kind:"session",id:`session:${x.id}`,session:x,sessionIds:[x.id]});continue}if(p.has(w.id))continue;p.add(w.id);const v=w.sessionIds.flatMap(k=>{const L=r.get(k);return L?[L]:[]});m.push({kind:"workspace",id:`workspace:${w.id}`,workspace:w,members:v,sessionIds:w.sessionIds})}return m}function vb(e,t,r){const n=Math.min(e.length,Math.max(0,r)),a=e.slice(0,n).flatMap(l=>l.sessionIds.filter(h=>h!==t)),c=e.slice(n).flatMap(l=>l.sessionIds.filter(h=>h!==t));return[...a,t,...c]}function RO({status:e,detail:t,needsReview:r,inCopyMode:n}){return s.jsx(mP,{status:e,detail:t,needsReview:r,inCopyMode:n})}function wb({isOpen:e,drawerWidthPx:t,onClose:r,onOpen:n,sessions:a,activeSessionId:c,sessionStates:l,onJumpToNextAttention:h,onNewSession:p,onCloseSession:m,onSplitSession:x,onCloseSplit:y,onRemoveFromSplit:w,splitWorkspaces:v,onSetSplitLayout:k,onReorderSplitWorkspace:L,onCombineSplitSessions:E,onReorderSessions:R,onSessionMenu:B,onOpenSettings:W,onOpenQuota:F,updateState:U,updateActionPending:V=!1,onConfirmUpdateRestart:Z,onRetryUpdate:le,serverHealthState:xe,tmuxAvailable:fe=!0,defaultSessionMode:te="shell",push:ke,pinned:$e,onTogglePinned:Y,recoverableTmuxSessions:Ae=[],recoverableTmuxSessionsLoading:lt=!1,onRefreshRecoverableTmuxSessions:Ce,onCloseRecoverableTmuxSession:ye}){const{t:_e}=zr(),[,je]=b.useState(0),[re,Pe]=b.useState(null),[Se,Ee]=b.useState(!1),[Be,Ne]=b.useState(!1),[oe,He]=b.useState(null),rt=b.useRef(!1),mt=b.useRef(0),de=b.useCallback(G=>{G||(mt.current+=1),Ee(G)},[]),[Ye,st]=b.useState(!1),Ie=na(G=>G.groupId),[We,Te]=b.useState({}),H=Ye||Object.keys(We).length>0,ae=b.useRef(!1),be=b.useRef(!1),[Ze,Je]=b.useState(null);b.useEffect(()=>{let G=!1;return nc().then(Le=>{G||ae.current||Te(Object.fromEntries(M3(Le.collaborationPanels?.[Ef()]).map(Ke=>[Ke,!0])))}).catch(()=>{}),()=>{G=!0}},[]);const Tt=async(G,Le)=>{ae.current=!0,await co({floatingGroupId:Le},G),Te(Ke=>({...Ke,[G]:Le!==null}))},[Wt,Mt]=b.useState([]),[vt,Yt]=b.useState(!1),[Qt,Xt]=b.useState(null),[Ut,Lt]=b.useState(null),[pe,Ge]=b.useState(null),[ft,q]=b.useState(null),at=mu(G=>G.tasks),Vt=mu(G=>G.allTasks),[Ve,De]=b.useState(0),[er,et]=b.useState(null),Ct=b.useRef(!1),[Nt,gt]=b.useState({}),bt=mu(G=>G.error),[It,yt]=b.useState(!1);b.useEffect(()=>{const G=()=>{document.hidden||mu.getState().refresh()};G();const Le=window.setInterval(G,5e3);return document.addEventListener("visibilitychange",G),()=>{clearInterval(Le),document.removeEventListener("visibilitychange",G)}},[]);const pr=async G=>(de(!1),ae.current=!0,G?(na.getState().open(G),Or(),!0):(st(!0),Or(),!0)),nr=Xh(G=>G.collaborationGroups),_r=Xh(G=>G.setCollaborationGroups),[un,Ir]=b.useState({mode:te}),{preference:me,agents:Gr,detecting:it,refresh:dt,selectAgent:sr}=zP(),An=b.useRef(null),on=!!(U?.latestVersion&&["installing","ready","restarting","error"].includes(U.status)),Me=!!xe?.attention,nt=[_e("sidebar.moreActions"),Me?_e("sidebar.serverAttention"):null,on&&U?.latestVersion?_e("sidebar.updateAvailable",{version:U.latestVersion}):null].filter(Boolean).join(": "),wt=Gt(G=>G.groupByFolder),Mr=Gt(G=>G.collapsedGroups),rn=Gt(G=>G.toggleGroupCollapsed),Er=b.useRef(null),ne=b.useRef(null),ht=b.useRef(null),zt=b.useRef(0),Pt=b.useRef(!1),Cr=b.useRef(null),gr=b.useRef(null),[Hr,En]=b.useState(!1),dr=b.useRef([]),Tn=b.useRef(null),hn=b.useRef(null),Sn=b.useRef(new Set),ir=b.useRef(null),mn=b.useMemo(()=>new Set(v.flatMap(G=>G.sessionIds)),[v]),Qr=b.useMemo(()=>new Map(a.map(G=>[G.id,G])),[a]),Vr=b.useMemo(()=>NO(nr,new Set(Qr.keys())),[nr,Qr]),Wr=b.useCallback(async()=>{const G=++zt.current;try{const Le=await _1();if(G!==zt.current)return;_r(Array.isArray(Le.groups)?Le.groups:[])}catch{}},[]);b.useEffect(()=>f3(G=>_r(G.groups)),[]),b.useEffect(()=>{Wr();const G=window.setInterval(()=>{Wr()},1e4),Le=()=>{Wr()};return window.addEventListener("focus",Le),()=>{zt.current+=1,window.clearInterval(G),window.removeEventListener("focus",Le)}},[Wr]),b.useEffect(()=>{(e||!H)&&Wr()},[H,e,Wr]);const fs=b.useCallback(()=>{dr.current=Array.from(document.querySelectorAll("[data-collaboration-member], [data-collaboration-background]")).flatMap(G=>{const Le=G.dataset.collaborationMember??"",Ke=G.hasAttribute("data-collaboration-background"),ct=G.closest("[data-collaboration-group]")?.dataset.collaborationGroup;if(!Le&&!Ke||!ct)return[];const qe=[];for(let At=G.parentElement;At;At=At.parentElement)qe.push({element:At,top:At.scrollTop,left:At.scrollLeft});return[{element:G,sessionId:Le,groupId:ct,background:Ke,rect:G.getBoundingClientRect(),scrollParents:qe}]})},[]),Dr=b.useCallback((G,Le)=>{if(!Pt.current)return;document.querySelectorAll("[data-split-exit-drop-index]").forEach(N=>N.removeAttribute("data-active")),document.querySelectorAll("[data-drop-active]").forEach(N=>N.removeAttribute("data-drop-active"));const ct=document.elementsFromPoint(G,Le).map(N=>N.closest("[data-collaboration-background]")).find(Boolean)?.closest("[data-collaboration-group]");if(ct?.dataset.collaborationGroup){ct.dataset.dropActive="true",hn.current={kind:"collaboration",groupId:ct.dataset.collaborationGroup,background:!0};return}const qe=dr.current.find(N=>{if(N.sessionId===gr.current||!N.element.isConnected)return!1;const $=N.scrollParents.reduce((se,Qe)=>se+Qe.element.scrollLeft-Qe.left,0),ee=N.scrollParents.reduce((se,Qe)=>se+Qe.element.scrollTop-Qe.top,0);return G>=N.rect.left-$&&G<=N.rect.right-$&&Le>=N.rect.top-ee+N.rect.height*.25&&Le<=N.rect.bottom-ee-N.rect.height*.25});if(qe?.background){qe.element.closest("[data-collaboration-group]")?.setAttribute("data-drop-active","true"),hn.current={kind:"collaboration",groupId:qe.groupId,background:!0};return}if(qe&&!v.find($=>$.sessionIds.includes(qe.sessionId))?.sessionIds.includes(gr.current??"")){qe.element.dataset.dropActive="true",hn.current={kind:"split",sessionId:qe.sessionId,groupId:qe.groupId};return}const At=document.elementsFromPoint(G,Le).filter(N=>{const $=N.closest("[data-rfd-draggable-id]");return!$||!["session:","split-member:","collaboration-member:"].some(ee=>$.dataset.rfdDraggableId===`${ee}${gr.current}`)}),Rt=At.map(N=>N.closest("[data-collaboration-group]")).find(N=>N?.dataset.collaborationGroup);if(Rt?.dataset.collaborationGroup){const N=Rt.dataset.collaborationGroup,$=At.map(ze=>ze.closest("[data-collaboration-split]")).find(Boolean),ee=At.map(ze=>ze.closest("[data-collaboration-member]")).find(Boolean),se=ee?.dataset.collaborationMember??$?.dataset.splitAnchor,Qe=N===Cr.current&&v.some(ze=>ze.sessionIds.includes(se??"")&&ze.sessionIds.includes(gr.current??""));if(se&&!Qe&&(N!==Cr.current||!ee&&$)){Rt.dataset.dropActive="true";const ze=ee??$;ze&&(ze.dataset.dropActive="true"),hn.current={kind:"split",sessionId:se,groupId:N}}else{const ze=At.some(xt=>xt.closest("[data-collaboration-background]"));(N!==Cr.current||ze)&&(Rt.dataset.dropActive="true"),hn.current={kind:"collaboration",groupId:N,background:ze}}return}const ot=Array.from(document.querySelectorAll("[data-sidebar-entity-list-id]")).filter(N=>N.dataset.sidebarEntityListId===Tn.current).find(N=>{const $=N.getBoundingClientRect();return G>=$.left&&G<=$.right&&Le>=$.top-8&&Le<=$.bottom+8});if(!ot){hn.current=null;return}const Ot=Array.from(ot.children).filter(N=>N instanceof HTMLElement&&N.hasAttribute("data-sidebar-entity-index")),hr=Ot.findIndex(N=>{const $=N.getBoundingClientRect();return Le<$.top+$.height/2}),Zt=hr<0?Ot.length:hr;hn.current={kind:"list",listId:ot.dataset.sidebarEntityListId??"",index:Zt};const z=Array.from(ot.querySelectorAll(":scope > [data-sidebar-entity-index] > [data-split-exit-drop-index]")).find(N=>N.dataset.splitExitDropIndex===String(Zt));z instanceof HTMLElement&&(z.dataset.active="true")},[v]);b.useEffect(()=>{const G=Ke=>Dr(Ke.clientX,Ke.clientY),Le=Ke=>{const ct=Ke.touches[0];ct&&Dr(ct.clientX,ct.clientY)};return window.addEventListener("pointermove",G),window.addEventListener("touchmove",Le,{passive:!0}),()=>{window.removeEventListener("pointermove",G),window.removeEventListener("touchmove",Le)}},[Dr]);const Pn=b.useCallback((G,Le)=>{try{G(Le)}finally{document.querySelectorAll("[data-sidebar-dragging]").forEach(Ke=>{delete Ke.dataset.sidebarDragging}),Pt.current=!1,dr.current=[],En(!1),Cr.current=null,gr.current=null,Tn.current=null,hn.current=null,document.querySelectorAll("[data-split-exit-drop-index]").forEach(Ke=>Ke.removeAttribute("data-active")),document.querySelectorAll("[data-drop-active]").forEach(Ke=>Ke.removeAttribute("data-drop-active"))}},[]),Sr=b.useMemo(()=>a.filter(G=>!mn.has(G.id)),[a,mn]),Kr=b.useMemo(()=>{let G=0;for(const Le of a)l.get(Le.id)?.agentStatus==="working"&&(G+=1);return G},[a,l]);b.useLayoutEffect(()=>{const G=Er.current,Le=ne.current;if(!e||!G||!Le){ht.current=null;return}const Ke=Le.getBoundingClientRect(),ct=G.getBoundingClientRect(),qe={item:G,top:Math.round(ct.top-Ke.top+Le.scrollTop),height:Math.round(ct.height),viewportHeight:Le.clientHeight},At=ht.current;if(ht.current=qe,At?.item===qe.item&&At.top===qe.top&&At.height===qe.height&&At.viewportHeight===qe.viewportHeight||Pt.current||Le.clientHeight===0)return;const Rt=8,Dt=ct.top-Ke.top,ot=ct.bottom-Ke.top;Dt<Rt?Le.scrollTop+=Dt-Rt:ot>Le.clientHeight-Rt&&(Le.scrollTop+=ot-Le.clientHeight+Rt)});const nn=b.useMemo(()=>{if(!wt||!c)return null;const G=l.get(c)?.cwd??null;return CC(G)},[wt,c,l]);b.useEffect(()=>{if(!wt){ir.current=null,Sn.current.clear();return}if(!c){ir.current=null;return}const G=Gt.getState(),Le=Sn.current,Ke=ir.current,ct=nn;Ke!==null&&Ke!==ct&&Le.has(Ke)&&(G.collapsedGroups.has(Ke)||G.toggleGroupCollapsed(Ke),Le.delete(Ke)),ct!==null&&ct!==""&&G.collapsedGroups.has(ct)&&(G.toggleGroupCollapsed(ct),Le.add(ct)),ir.current=ct},[wt,c,nn]),b.useEffect(()=>{e||de(!1)},[e]),b.useEffect(()=>{Ir(G=>({...G,command:me?.command}))},[me]),b.useEffect(()=>{if(!Se)return;let G=!1;return Yt(!0),Lt(null),Yg().then(Le=>{G||Mt(Le)}).catch(()=>{G||Lt(_e("sidebar.resumeHistoryLoadFailed"))}).finally(()=>{G||Yt(!1)}),()=>{G=!0}},[Se,_e]),b.useEffect(()=>{if(!re)return;const G=Le=>{Le instanceof KeyboardEvent&&Le.key!=="Escape"||Le instanceof PointerEvent&&Le.target instanceof Node&&An.current?.contains(Le.target)||Pe(null)};return window.addEventListener("pointerdown",G),window.addEventListener("keydown",G),()=>{window.removeEventListener("pointerdown",G),window.removeEventListener("keydown",G)}},[re]);const Or=()=>{!ke&&!$e&&r()};b.useEffect(()=>{const G=Le=>{de(!1);const{groupId:Ke,dock:ct}=Le.detail;ae.current=!0,ns.getState().setDock(Ke,{...ct,preferredWidth:360}),Te(qe=>({...qe,[Ke]:!0})),na.getState().terminal(),Or()};return window.addEventListener("termdock:open-collaboration-messages",G),()=>window.removeEventListener("termdock:open-collaboration-messages",G)},[Or]);const ks=te==="tmux"&&!fe?"shell":te,Pr=(G,Le=!1)=>{if(rt.current)return;rt.current=!0,Ne(!0),He(null);const Ke=mt.current;p({...G,shouldActivate:()=>Ke===mt.current&&(G.shouldActivate?.()??!0),onResult:ct=>{if(rt.current=!1,Ne(!1),!ct.ok){He(ct.error);return}Ke===mt.current&&(Le&&de(!1),Or())}})},Xr=()=>{Pr({mode:ks})},fn=()=>{me&&Pr({mode:ks,command:me.command})},K=G=>{de(!1),Ge(G.name),p({mode:"tmux",tmuxSessionName:G.name,cwd:G.cwd??void 0}),Or()};b.useEffect(()=>{pe&&(Ae.some(G=>G.name===pe)||Ge(null))},[pe,Ae]);const Ue=(G,Le)=>{Pr({...un,cwd:un.cwd?.trim()||void 0,command:Le??G?.command},!0)},Et=async G=>{Xt(G.id),Lt(null);try{const Le=await p3(G.id);Pr({mode:"shell",cwd:Le.cwd,command:Le.command},!0)}catch(Le){const Ke=Le&&typeof Le=="object"&&"code"in Le?String(Le.code??""):"";Lt(_e(Ke==="AGENT_SESSION_ACTIVE_ELSEWHERE"?"tab.resumeAgentConflict":"sidebar.resumeHistoryFailed"))}finally{Xt(null)}},kt=async G=>{Mt(Le=>Le.filter(Ke=>Ke.id!==G));try{await Gw(G)}catch{Lt(_e("sidebar.resumeHistoryRemoveFailed")),Yg().then(Mt).catch(()=>{})}},tr=()=>{if(Se){de(!1);return}rt.current||(mt.current+=1,rt.current||He(null),Ir({mode:te==="tmux"&&!fe?"shell":te,cwd:c?l.get(c)?.cwd??void 0:void 0,command:me?.command}),de(!0))},Br=b.useCallback(G=>{const Le=l.get(G);return Le?.agentStatus==="waiting"||Le?.agentNeedsReview?"bg-[rgb(var(--warning-rgb)_/_0.10)] text-foreground":Le?.agentStatus==="working"?"bg-[rgb(var(--success-rgb)_/_0.08)] text-foreground":Le?.inCopyMode?"bg-[rgb(var(--tmux-rgb)_/_0.08)] text-foreground":null},[l]),cr=Xv(),[_n,Ls]=b.useState(null);b.useEffect(()=>{e||Ls(null)},[e]);const Zn=b.useCallback((G,Le,Ke,ct,qe)=>{const At=!Ie&&G.id===c,Rt=mn.has(G.id),Dt=!!(Ke&&Rt),ot=l.get(G.id),Ot=Pu(ot?.cwd??null),hr=ot?.shellTitle??Pw(G.id),Zt=hr===ot?.cwd||hr===Ot?null:hr,z=Ow(G,ot?.activeProgram??null,null,Fw,Zt,ot?.promptState??null),N=!!(ot?.tuiProgress&&ot.tuiProgress.state!=="remove"),ee=ot?.promptState==="running"||ot?.agentStatus==="working"||N?"bg-[var(--success)]":ot?.agentStatus==="waiting"||ot?.agentNeedsReview?"bg-[var(--warning)]":ot?.inCopyMode?"bg-[var(--tmux)]":"bg-primary";return s.jsxs(IO,{open:_n===G.id,onOpenChange:se=>Ls(Qe=>se?G.id:Qe===G.id?null:Qe),onClose:se=>m(G.id,se,{skipConfirmation:!0}),closeLabel:_e("common.close"),closeTitle:_e("sidebar.closeSession",{name:z}),compact:Ke,children:[s.jsxs("button",{ref:At?Er:null,type:"button",...Le??{},onContextMenu:se=>{B&&(se.preventDefault(),B(G.id,{x:se.clientX,y:se.clientY}))},onClick:()=>{de(!1),na.getState().terminal(),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:G.id})),Or()},className:`sidebar-session-primary relative min-w-0 flex flex-1 items-center overflow-hidden text-left ${Le?"cursor-grab active:cursor-grabbing ":""}${Ke?"gap-1.5 py-0.5 pl-1.5 pr-0.5":"gap-1.5 py-1 pl-2 pr-1"}`,title:ot?.cwd??G.name,children:[At&&s.jsx("span",{className:`absolute inset-y-2 left-0 w-0.5 rounded-full ${ee}`}),s.jsxs("span",{className:`relative inline-flex shrink-0 items-center justify-center rounded-md ${Ke?"h-5 w-[22px]":"h-[22px] w-[22px]"} ${At?G.mode==="tmux"?"bg-[rgb(var(--tmux-rgb)_/_0.15)] text-[color:var(--tmux)]":"bg-primary/15 text-primary":G.mode==="tmux"?"bg-surface text-[rgb(var(--tmux-rgb)_/_0.80)]":"bg-surface text-muted-foreground"}`,children:[ot?.isConnecting||N&&!ot?.agentStatus?s.jsx(In,{size:Ke?10:11,className:"animate-spin"}):ot?.agent??Zg(G.id)?s.jsx(Mc,{agent:ot?.agent??Zg(G.id),size:Ke?13:15}):G.mode==="tmux"?s.jsx(Nu,{size:Ke?10:11}):s.jsx(Bo,{size:Ke?10:11}),s.jsx(RO,{status:ot?.agentStatus??null,detail:ot?.agentStatusDetail,needsReview:ot?.agentNeedsReview,inCopyMode:ot?.inCopyMode})]}),s.jsx("span",{className:`min-w-0 flex-1 truncate leading-tight ${Ke?"text-[11px]":"text-[12px]"} ${At?"font-medium text-foreground":""} ${ot?.inCopyMode?"text-[color:var(--tmux)]":""}`,children:z}),s.jsx(k5,{sessionIds:[G.id]})]}),ct,s.jsx("button",{type:"button",onClick:se=>{se.stopPropagation(),Dt?w(G.id):Rt?y(G.id):x(G.id)},className:`sidebar-session-action inline-flex shrink-0 items-center justify-center rounded-md transition hover:bg-primary/15 hover:text-primary active:scale-95 ${Ke?"h-6 w-6":"h-[26px] w-[26px]"} ${Rt?"bg-primary/15 text-primary":"text-muted-foreground/70"}`,"aria-label":`${_e(Dt?"tab.splitRemovePane":Rt?"tab.splitClose":"tab.split")} ${z}`,title:_e(Dt?"tab.splitRemovePane":Rt?"tab.splitClose":"tab.split"),children:Dt?s.jsx(fC,{size:11}):s.jsx(_l,{size:12})}),qe??s.jsx("button",{type:"button",onClick:se=>{se.stopPropagation(),m(G.id,se)},className:`sidebar-session-action inline-flex shrink-0 items-center justify-center rounded-md text-muted-foreground/70 transition hover:bg-destructive/15 hover:text-destructive active:scale-95 ${Ke?"h-6 w-6":"h-[26px] w-[26px]"}`,"aria-label":_e("sidebar.closeSession",{name:z}),title:_e("common.close"),children:s.jsx(Qn,{size:Ke?11:12})})]})},[c,mn,l,m,x,y,w,B,_e,_n]),sn=b.useMemo(()=>Kh(a,G=>l.get(G.id)?.cwd??null,wt,_e("sidebar.ungrouped"),v,Vr).groups,[Vr,wt,a,l,v,_e]),ln=b.useMemo(()=>E0(a,v,Qr,Vr),[Vr,a,Qr,v]),kr=b.useCallback(G=>{En(G.draggableId.startsWith("collaboration:")||G.draggableId.startsWith("workspace:"));const Le=G.draggableId.replace(/^split-member:/,"");gr.current=G.draggableId.replace(/^(?:session|split-member|collaboration-member):/,"");const Ke=G.type==="split-member"?v.find(Dt=>Dt.sessionIds.includes(Le)):null,ct=G.type==="collaboration-member"?G.source.droppableId.replace(/^collaboration-members:/,""):null,qe=ct?Vr.find(Dt=>Dt.id===ct):null;Pt.current=!!(Ke||qe||G.type==="session"&&G.draggableId.startsWith("session:")),Pt.current&&document.querySelectorAll("[data-collaboration-group]").forEach(Dt=>{Dt.dataset.sidebarDragging="true"}),Cr.current=qe?.id??null;const At=Ke?.sessionIds??qe?.sessionIds??[],Rt=At.length>0?sn.find(Dt=>At.every(ot=>Dt.sessions.some(Ot=>Ot.id===ot))):null;Tn.current=wt?Rt?`group-sessions:${Rt.key}`:null:At.length>0?"sidebar-entities":null,hn.current=null},[Vr,sn,wt,v]),$r=b.useCallback((G,Le,Ke)=>{if(Le===Ke)return;const ct=Le?nr.find(ot=>ot.id===Le):null,qe=Ke?nr.find(ot=>ot.id===Ke):null;if(Ke&&!qe)return;if(qe){const ot=a.map(hr=>hr.id).filter(hr=>hr!==G);let Ot=-1;ot.forEach((hr,Zt)=>{qe.sessionIds.includes(hr)&&(Ot=Zt)}),Ot>=0&&(ot.splice(Ot+1,0,G),R(ot))}const At=ct?.sessionIds.filter(ot=>ot!==G)??[],Rt=qe?[...qe.sessionIds.filter(ot=>ot!==G),G]:[];_r(ot=>ot.flatMap(Ot=>Ot.id===Le?[{...Ot,sessionIds:At}]:Ot.id===Ke?[{...Ot,sessionIds:Rt}]:[Ot])),q(null),(ct&&qe?$w({sourceGroupId:ct.id,targetGroupId:qe.id,sessionId:G,expectedSourceUpdatedAt:ct.updatedAt,expectedTargetUpdatedAt:qe.updatedAt}):ct?Zl({id:ct.id,name:ct.name,sessionIds:At,expectedUpdatedAt:ct.updatedAt}):qe?Zl({id:qe.id,name:qe.name,sessionIds:Rt,expectedUpdatedAt:qe.updatedAt}):Promise.resolve()).then(()=>Wr(),ot=>(q(ot instanceof Error?ot.message:"协作成员移动失败"),Wr()))},[nr,Wr,a,R]),Gn=b.useCallback((G,Le,Ke,ct=!1)=>{const qe=nr.find($=>$.id===G);if(!qe||Le===Ke)return;const At=qe.sessionIds.filter($=>!$.startsWith("remote:")),Rt=I0(At,v).flatMap($=>$.sessionIds),Dt=S5(Vt,qe.id),ot=ct&&!Nt[qe.id]?Rt.filter($=>!Dt.has($)||$===c||mn.has($)):Rt.slice(),Ot=new Set(ot),[hr]=ot.splice(Le,1);if(!hr)return;ot.splice(Ke,0,hr);let Zt=0;const z=Rt.map($=>Ot.has($)?ot[Zt++]:$),N=v.find($=>$.sessionIds.includes(hr));if(N&&N.sessionIds.every($=>qe.sessionIds.includes($))){const $=z.filter(ee=>N.sessionIds.includes(ee));L(N.id,$)}z.push(...qe.sessionIds.filter($=>$.startsWith("remote:"))),_r($=>$.map(ee=>ee.id===G?{...ee,sessionIds:z}:ee)),q(null),Zl({id:qe.id,name:qe.name,sessionIds:z,expectedUpdatedAt:qe.updatedAt}).then(()=>Wr(),$=>(q($ instanceof Error?$.message:"成员排序失败"),Wr()))},[nr,Wr,v,L,Vt,Nt,c,mn]);b.useEffect(()=>{const G=Le=>{const{sourceId:Ke,targetId:ct}=Le.detail;if(!Ke||!ct||Ke===ct)return;const qe=Kh(a,se=>l.get(se.id)?.cwd??null,wt,"",v,Vr).arranged.map(se=>se.id),At=qe.indexOf(Ke),Rt=qe.indexOf(ct);if(At<0||Rt<0)return;const Dt=Vr.find(se=>se.sessionIds.includes(Ke));if(Dt?.sessionIds.includes(ct)){const se=I0(Dt.sessionIds,v).flatMap(Qe=>Qe.sessionIds);Gn(Dt.id,se.indexOf(Ke),se.indexOf(ct));return}const ot=v.filter(se=>se.sessionIds.length>=2&&se.sessionIds.every(Qe=>Qr.has(Qe))&&!Vr.some(Qe=>se.sessionIds.some(ze=>Qe.sessionIds.includes(ze)))),Ot=ot.find(se=>se.sessionIds.includes(Ke));if(Ot?.sessionIds.includes(ct)){const se=[...Ot.sessionIds];se.splice(se.indexOf(Ke),1),se.splice(Ot.sessionIds.indexOf(ct),0,Ke),L(Ot.id,se);return}const hr=se=>Vr.find(Qe=>Qe.sessionIds.includes(se))?.sessionIds??ot.find(Qe=>Qe.sessionIds.includes(se))?.sessionIds??[se],Zt=new Set(hr(Ke)),z=new Set(hr(ct)),N=qe.filter(se=>!Zt.has(se)),$=N.flatMap((se,Qe)=>z.has(se)?[Qe]:[]),ee=At<Rt?Math.max(...$)+1:Math.min(...$);N.splice(ee,0,...qe.filter(se=>Zt.has(se))),R(N)};return window.addEventListener("reorder-navigation-session",G),()=>window.removeEventListener("reorder-navigation-session",G)},[a,l,wt,v,Vr,Qr,Gn,L,R]);const Vn=b.useCallback(G=>{if(G.type!=="collaboration-member")return!1;if(G.reason==="CANCEL")return!0;const Le=G.source.droppableId.replace(/^collaboration-members:/,""),Ke=G.draggableId.replace(/^collaboration-member:/,""),ct=hn.current;if(ct?.kind==="split")return $r(Ke,Le,ct.groupId),E(ct.sessionId,Ke),!0;if(ct?.kind==="collaboration"&&ct.groupId!==Le)return $r(Ke,Le,ct.groupId),!0;if(ct?.kind==="collaboration"&&ct.background)return mn.has(Ke)&&w(Ke),!0;if(G.destination&&G.destination.droppableId!==G.source.droppableId){const qe=G.destination.droppableId.replace(/^collaboration-members:/,"");if(Vr.some(At=>At.id===qe))return $r(Ke,Le,qe),!0}if(G.combine){const qe=G.combine.droppableId.replace(/^collaboration-members:/,"");qe!==Le&&$r(Ke,Le,qe);const At=G.combine.draggableId.replace(/^collaboration-member:/,"");if(v.find(Dt=>Dt.sessionIds.includes(Ke))?.sessionIds.includes(At)){const Dt=Vr.find(Ot=>Ot.id===Le),ot=Dt?I0(Dt.sessionIds,v).flatMap(Ot=>Ot.sessionIds).indexOf(At):-1;ot>=0&&Dt&&Gn(Le,I0(Dt.sessionIds,v).flatMap(Ot=>Ot.sessionIds).indexOf(Ke),ot)}else Qr.has(At)&&E(At,Ke);return!0}if(G.destination?.droppableId===G.source.droppableId)return Gn(Le,G.source.index,G.destination.index,!0),!0;if(ct?.kind!=="list")return!0;if(ct?.kind==="list"){const qe=sn.find(Rt=>`group-sessions:${Rt.key}`===ct.listId),At=ct.listId==="sidebar-entities"?ln:qe?E0(qe.sessions,v,Qr,Vr):null;if(At){const Rt=vb(At,Ke,ct.index);ct.listId==="sidebar-entities"?R(Rt):qe&&R(sn.flatMap(Dt=>Dt.key===qe.key?Rt:Dt.sessions.map(ot=>ot.id)))}}return $r(Ke,Le,null),!0},[Vr,ln,sn,$r,R,Gn,Qr,v,mn,w,E]),dn=b.useCallback(G=>{if(G.type!=="split-member")return!1;if(G.reason==="CANCEL")return!0;const Le=G.draggableId.replace(/^split-member:/,""),Ke=v.find(ot=>ot.sessionIds.includes(Le));if(!Ke?.sessionIds.includes(Le))return!0;const ct=Ke.id,qe=hn.current;if(qe?.kind==="split")return $r(Le,null,qe.groupId),E(qe.sessionId,Le),!0;if(qe?.kind==="collaboration")return $r(Le,null,qe.groupId),!0;if(!G.destination&&qe?.kind==="list"){const ot=sn.find(Zt=>`group-sessions:${Zt.key}`===qe.listId),Ot=qe.listId==="sidebar-entities"?ln:ot?E0(ot.sessions,v,Qr,Vr):null;if(!Ot)return!0;const hr=vb(Ot,Le,qe.index);return w(Le),qe.listId==="sidebar-entities"?R(hr):ot&&R(sn.flatMap(Zt=>Zt.key===ot.key?hr:Zt.sessions.map(z=>z.id))),!0}if(!G.destination)return!0;const At=G.destination.droppableId.replace(/^split-members:/,"");if(At!==ct){const Ot=v.find(hr=>hr.id===At)?.sessionIds[0];return Ot&&E(Ot,Le),!0}if(G.source.index===G.destination.index)return!0;const Rt=[...Ke.sessionIds],[Dt]=Rt.splice(G.source.index,1);return Dt&&(Rt.splice(G.destination.index,0,Dt),L(ct,Rt)),!0},[Vr,ln,sn,$r,E,w,R,L,Qr,v]),Kn=(G,Le="top")=>s.jsx("div",{"data-split-exit-drop-index":G,className:`group/split-exit pointer-events-none absolute inset-x-0 z-10 h-2 ${Le==="top"?"-top-1":"-bottom-1"}`,children:s.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-1 top-1/2 h-px -translate-y-1/2 rounded-full bg-transparent transition-colors group-data-[active=true]/split-exit:bg-primary"})}),Lr=b.useCallback((G,Le,Ke)=>{if(Vn(G)||dn(G)||G.reason==="CANCEL")return;const ct=Le.find(ot=>ot.id===G.draggableId);if(!ct)return;const qe=hn.current;if(qe?.kind==="split"&&ct.kind==="session"){$r(ct.session.id,null,qe.groupId),E(qe.sessionId,ct.session.id);return}if(qe?.kind==="collaboration"&&ct.kind==="session"){$r(ct.session.id,null,qe.groupId);return}if(G.combine&&ct.kind!=="session"){const ot=Le.findIndex(Ot=>Ot.id===G.combine?.draggableId);if(ot<0)return;G={...G,combine:null,destination:{...G.source,index:ot}}}if(G.combine){const ot=Le.find(N=>N.id===G.combine?.draggableId);if(!ot)return;const Ot=ot.kind==="workspace"?ot:ct.kind==="workspace"?ct:ot,hr=Ot===ct?ot:ct,Zt=Ot.sessionIds[0],z=hr.sessionIds[0];Zt&&z&&Zt!==z&&E(Zt,z);return}if(!G.destination||G.source.index===G.destination.index)return;const At=[...Le],[Rt]=At.splice(G.source.index,1);if(!Rt)return;At.splice(G.destination.index,0,Rt);const Dt=At.flatMap(ot=>ot.sessionIds);if(Ke===void 0){R(Dt);return}R(sn.flatMap(ot=>ot.key===Ke?Dt:ot.sessions.map(Ot=>Ot.id)))},[sn,Vn,dn,$r,E,R]),Nr=b.useCallback(G=>{if(G.reason==="CANCEL"||Vn(G)||dn(G))return;if(G.type==="group"){if(!G.destination||G.source.index===G.destination.index)return;R(I3(sn,G.source.index,G.destination.index));return}const Le=G.source.droppableId.replace(/^group-sessions:/,""),Ke=sn.find(qe=>qe.key===Le);if(!Ke)return;const ct=E0(Ke.sessions,v,Qr,Vr);if(G.combine||hn.current?.kind==="collaboration"||hn.current?.kind==="split"){Lr(G,ct,Le);return}!G.destination||G.destination.droppableId!==G.source.droppableId||Lr(G,ct,Le)},[Vr,sn,Qr,v,Vn,Lr,dn,R]),xr=G=>{const Le=re===G.id,Ke=[{layout:"horizontal",label:_e("tab.splitHorizontal"),icon:_l},{layout:"vertical",label:_e("tab.splitVertical"),icon:t2},...G.sessionIds.length>=3||G.layout==="grid"?[{layout:"grid",label:_e("tab.splitGrid"),icon:e2}]:[]],ct=G.layout==="vertical"?t2:G.layout==="grid"?e2:_l,qe=Ke.find(At=>At.layout===G.layout)?.label??_e("tab.splitHorizontal");return s.jsxs("div",{ref:Le?An:void 0,className:"relative shrink-0",onPointerDown:At=>At.stopPropagation(),children:[s.jsx("button",{type:"button",className:`sidebar-session-action inline-flex h-6 w-6 items-center justify-center rounded-md transition active:scale-95 ${Le?"bg-primary/15 text-primary":"text-muted-foreground/70 hover:bg-surface-2 hover:text-foreground"}`,"aria-label":`${_e("tab.splitLayout")}: ${qe}`,"aria-haspopup":"menu","aria-expanded":Le,title:_e("tab.splitLayout"),onClick:At=>{At.stopPropagation(),Pe(Rt=>Rt===G.id?null:G.id)},children:s.jsx(ct,{size:12})}),Le&&s.jsx("div",{role:"menu","aria-label":_e("tab.splitLayout"),className:"absolute right-0 top-full z-30 mt-1 flex gap-0.5 rounded-md border border-border bg-surface-elevated p-1 shadow-lg",children:Ke.map(At=>{const Rt=At.icon,Dt=At.layout===G.layout;return s.jsx("button",{type:"button",role:"menuitemradio","aria-checked":Dt,"aria-label":At.label,title:At.label,className:`sidebar-session-action inline-flex h-7 w-7 items-center justify-center rounded-sm transition active:scale-95 ${Dt?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,onClick:ot=>{ot.stopPropagation(),k(G.sessionIds[0],At.layout),Pe(null)},children:s.jsx(Rt,{size:13})},At.layout)})})]})},os=(G,Le)=>Le&&s.jsx("button",{type:"button",...Le,"aria-label":G,title:G,onClick:Ke=>Ke.stopPropagation(),className:"absolute -left-2 inset-y-0 z-10 flex w-3 cursor-grab items-start justify-center pt-1.5 text-muted-foreground/60 transition hover:text-foreground focus-visible:text-foreground active:cursor-grabbing",children:s.jsx(If,{size:10})}),Hn=(G,Le,Ke=!1,ct=!1,qe)=>{if(Le.length<2)return null;const At=Le.some(Zt=>Zt.id===c),Rt=[],Dt=[],ot=[];for(const Zt of Le){const z=l.get(Zt.id);z?.agentStatus==="waiting"||z?.agentNeedsReview?Rt.push(Zt):z?.agentStatus==="working"?Dt.push(Zt):z?.inCopyMode&&ot.push(Zt)}const Ot=G.name?.trim()||`${_e("tab.splitWorkspace")} ${v.findIndex(Zt=>Zt.id===G.id)+1}`,hr=re===G.id;return s.jsxs("section",{"data-split-workspace":G.id,"aria-label":Ot,className:`group/split relative rounded-md p-0.5 before:pointer-events-none before:absolute before:inset-0 before:rounded-md before:border before:border-border transition-colors ${ct?"bg-primary/15 ring-1 ring-primary/40":Ke?"bg-surface-elevated opacity-90 shadow-lg":Rt.length>0?"bg-[rgb(var(--warning-rgb)_/_0.08)] hover:bg-[rgb(var(--warning-rgb)_/_0.12)]":Dt.length>0?"bg-[rgb(var(--success-rgb)_/_0.06)] hover:bg-[rgb(var(--success-rgb)_/_0.10)]":ot.length>0?"bg-[rgb(var(--tmux-rgb)_/_0.07)] hover:bg-[rgb(var(--tmux-rgb)_/_0.11)]":At?"bg-primary/[0.07]":"hover:bg-surface-2"}`,children:[os(`移动分屏组 ${Ot}`,qe),s.jsx(Sl,{droppableId:`split-members:${G.id}`,type:"split-member",direction:"vertical",children:(Zt,z)=>s.jsxs("div",{ref:Zt.innerRef,...Zt.droppableProps,"data-split-members":!0,className:z.isDraggingOver?"rounded-sm bg-primary/10 ring-1 ring-primary/40":"",children:[Le.map((N,$)=>s.jsx(Cl,{draggableId:`split-member:${N.id}`,index:$,disableInteractiveElementBlocking:!0,children:(ee,se)=>s.jsx("div",{ref:ee.innerRef,...ee.draggableProps,...B?cr(()=>B(N.id)):{},className:`${$===0&&hr?"relative z-20 ":"relative "}flex items-center rounded-sm pr-0.5 transition-colors ${se.isDragging?"bg-surface-elevated opacity-90 shadow-lg ":""}${Br(N.id)??(N.id===c?"bg-surface-elevated/80 text-foreground":"text-muted-foreground hover:bg-surface-2")}`,children:Zn(N,ee.dragHandleProps,!0,$===0?xr(G):void 0)})},N.id)),Zt.placeholder]})})]})},Nn=(G,Le,Ke,ct=!1,qe=!1)=>{const At=`collaboration:${G.id}`,Rt=Mr.has(At),Dt=`collaboration-members-${G.id}`,ot=Ie===G.id||!Ie&&Le.some(se=>se.id===c),Ot=S5(Vt,G.id),hr=G.sessionIds.filter(se=>Ot.has(se)&&se!==c&&!mn.has(se)),Zt=Nt[G.id]===!0,z=Zt?G.sessionIds:G.sessionIds.filter(se=>!hr.includes(se)),N=I0(z,v),$=N.flatMap(se=>se.sessionIds),ee=N.length===1?N[0]?.workspace:void 0;return s.jsxs("section",{"data-collaboration-group":G.id,"data-collaboration-group-name":G.name,"aria-label":`Agent 工作组:${G.name}`,className:`group/collaboration relative rounded-md ${Rt?"":"p-0.5 before:pointer-events-none before:absolute before:inset-0 before:rounded-md before:border before:border-border"} transition-colors data-[drop-active=true]:bg-primary/15 data-[drop-active=true]:ring-1 data-[drop-active=true]:ring-primary/40 ${qe?"bg-primary/15 ring-1 ring-primary/40":ct?"bg-surface-elevated opacity-90 shadow-lg":ot?"bg-primary/[0.07]":"hover:bg-surface-2"}`,children:[os(`移动工作组 ${G.name}`,Ke),s.jsxs("div",{className:"flex items-center",children:[s.jsx("button",{type:"button","aria-label":`${Rt?"展开":"收起"} ${G.name} 的成员会话`,"aria-expanded":!Rt,"aria-controls":Dt,title:`${Rt?"展开":"收起"}成员会话`,className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-surface-elevated hover:text-foreground focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary md:h-[30px] md:w-5",onClick:se=>{se.stopPropagation(),rn(At)},children:s.jsx(hi,{size:14,className:Rt?"":"rotate-90"})}),s.jsxs("button",{type:"button",className:"flex min-h-11 min-w-0 flex-1 items-center gap-1.5 rounded-sm px-1 text-left text-xs font-medium text-foreground transition hover:text-primary md:min-h-[30px]",title:`打开 ${G.name} 的协作工作区`,"aria-label":`打开协作工作区:${G.name}`,"aria-current":Ie===G.id?"page":void 0,onClick:se=>{se.stopPropagation(),pr(G.id)},children:[s.jsx(Vd,{size:14,className:"shrink-0 text-primary"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:G.name}),at.some(se=>se.groupId===G.id)&&s.jsxs("span",{className:"shrink-0 text-[10px] font-normal text-primary",children:[at.filter(se=>se.groupId===G.id).length," 待处理"]})]}),s.jsx("button",{type:"button","aria-label":`成员与消息:${G.name}`,title:"在终端旁打开成员与消息",disabled:Ze!==null||!c&&!Le.length,"aria-busy":Ze===G.id,className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-surface-elevated hover:text-primary disabled:opacity-40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary md:h-[30px] md:w-7",onClick:se=>{se.stopPropagation(),!be.current&&(de(!1),be.current=!0,Je(G.id),q(null),QC(G.id,c??Le[0].id).catch(Qe=>q(Qe instanceof Error?Qe.message:"消息面板打开失败,请重试")).finally(()=>{be.current=!1,Je(null)}))},children:Ze===G.id?s.jsx(yn,{size:14,className:"animate-spin"}):s.jsx(Td,{size:14})})]}),s.jsx("div",{id:Dt,children:!Rt&&s.jsxs(s.Fragment,{children:[hr.length>0&&s.jsxs("button",{type:"button","aria-expanded":Zt,className:"flex min-h-11 w-full items-center gap-2 rounded-sm px-2 text-left text-[11px] text-muted-foreground hover:bg-surface-elevated md:min-h-8",title:"展开后可查看或归档执行会话,任务结果保留。",onClick:()=>gt(se=>({...se,[G.id]:!Zt})),children:[s.jsx(hi,{size:12,className:Zt?"rotate-90":""}),"已完成的执行会话 · ",hr.length]}),s.jsx(Sl,{droppableId:`collaboration-members:${G.id}`,type:"collaboration-member",direction:"vertical",isCombineEnabled:!0,children:(se,Qe)=>s.jsxs("div",{ref:se.innerRef,...se.droppableProps,"data-collaboration-members":!0,className:`${Qe.isDraggingOver?"rounded-sm bg-primary/10":""}`,children:[N.map(ze=>s.jsx("div",{"data-collaboration-split":ze.workspace?.id,"data-split-anchor":ze.workspace?.sessionIds[0],role:ze.workspace?"region":void 0,"aria-label":ze.workspace?`${_e("tab.splitWorkspace")} · ${ze.sessionIds.length}`:void 0,className:ze.workspace&&!ee?`relative my-0.5 rounded-sm before:pointer-events-none before:absolute before:inset-0 before:rounded-sm before:border before:border-border data-[drop-active=true]:ring-1 data-[drop-active=true]:ring-primary/40 ${ze.sessionIds.includes(c??"")?"bg-primary/[0.07]":"bg-surface/35"}`:void 0,children:ze.sessionIds.map(xt=>{const _t=Qr.get(xt);return _t?s.jsx(Cl,{draggableId:`collaboration-member:${_t.id}`,index:$.indexOf(_t.id),disableInteractiveElementBlocking:!0,children:(Fr,jt)=>s.jsxs("div",{ref:Fr.innerRef,...Fr.draggableProps,"data-collaboration-member":_t.id,"data-split-member":mn.has(_t.id)?"true":void 0,...B?cr(()=>B(_t.id)):{},className:`${ze.workspace&&xt===ze.sessionIds[0]&&re===ze.workspace.id?"z-20 ":""}relative flex items-center rounded-sm pr-0.5 transition-colors data-[drop-active=true]:bg-primary/15 data-[drop-active=true]:ring-1 data-[drop-active=true]:ring-primary/40 ${jt.combineTargetFor?"bg-primary/15 ring-1 ring-primary/40 ":jt.isDragging?"bg-surface-elevated opacity-90 shadow-lg ":""}${Br(_t.id)??(_t.id===c?"bg-surface-elevated/80 text-foreground":mn.has(_t.id)?"bg-primary/[0.05] text-muted-foreground hover:bg-primary/[0.09]":"text-muted-foreground hover:bg-surface-2")}`,children:[Zn(_t,Fr.dragHandleProps,!0,ze.workspace&&xt===ze.sessionIds[0]?xr(ze.workspace):void 0,Ot.has(xt)?s.jsxs("button",{type:"button","aria-label":`归档 ${_t.name}`,title:"保存 Agent 会话 ID 并停止终端;只回收干净的执行目录,结果和分支保留",disabled:er!==null,className:"sidebar-session-action inline-flex h-11 min-w-11 shrink-0 items-center justify-center gap-1 rounded-md px-2 text-muted-foreground hover:bg-primary/15 hover:text-primary disabled:opacity-40 md:h-6 md:min-w-6 md:px-1",onClick:qr=>{qr.stopPropagation(),!Ct.current&&(Ct.current=!0,et(xt),q(null),Ww(xt).then(async()=>{De(pn=>pn+1),await Wr()}).catch(pn=>q(pn instanceof Error?pn.message:"归档失败,终端已保留")).finally(()=>{Ct.current=!1,et(null)}))},children:[er===xt?s.jsx(yn,{size:13,className:"animate-spin"}):s.jsx(m3,{size:13}),s.jsx("span",{className:"text-[10px] md:sr-only",children:"归档"})]}):void 0),!ze.workspace&&mn.has(_t.id)&&s.jsx("button",{type:"button",className:"shrink-0 px-1 text-[10px] text-primary",title:`与 ${v.find(qr=>qr.sessionIds.includes(_t.id))?.sessionIds.filter(qr=>qr!==_t.id).map(qr=>Qr.get(qr)?.name??qr).join("、")} 分屏`,"aria-label":`查看 ${_t.name} 的跨组分屏`,onClick:()=>{de(!1),na.getState().terminal(),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:_t.id})),Or()},children:s.jsx(_l,{size:10})})]})},_t.id):null})},ze.workspace?.id??ze.sessionIds[0])),se.placeholder]})}),s.jsx(LB,{groupId:G.id,version:Ve,onRestore:async se=>{de(!1),window.dispatchEvent(new CustomEvent("new-terminal-session",{detail:{mode:"tmux",cwd:se.cwd,preferredFrontendSessionId:se.sessionId,requireExisting:!0}})),await Wr(),na.getState().terminal(),Or()}}),G.remoteSessions?.map(se=>s.jsxs("button",{type:"button",title:`${ec(se)} · ${se.serviceConnected===!1?"服务不可达,消息尚未送达":se.status}`,className:"flex w-full min-w-0 items-center gap-1.5 rounded-sm px-2 py-1 text-left text-[11px] text-muted-foreground hover:bg-surface-2",onClick:()=>{de(!1),e6(se.sessionId).catch(()=>{pr(G.id)})},children:[s.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${se.serviceConnected===!1?"bg-muted-foreground":"bg-primary"}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:se.name}),s.jsx("span",{className:"max-w-20 truncate rounded border border-border/20 px-1 text-[9px]",children:ec(se)}),se.serviceConnected===!1&&s.jsx("span",{className:"shrink-0 text-[9px]",children:"不可达"})]},se.sessionId))]})}),s.jsx("div",{"data-collaboration-background":!0,className:Rt?"absolute inset-0 pointer-events-none":"h-1.5"})]})},Rn=(G,Le,Ke)=>s.jsx(td,{onBeforeCapture:fs,onDragStart:kr,onDragEnd:ct=>Pn(qe=>Lr(qe,G,Ke),ct),children:s.jsx(Sl,{droppableId:Le,direction:"vertical",isCombineEnabled:!Hr,children:ct=>s.jsxs("div",{ref:ct.innerRef,...ct.droppableProps,"data-sidebar-entity-list-id":Le,className:"flex-1 space-y-0.5",children:[G.map((qe,At)=>s.jsx(Cl,{draggableId:qe.id,index:At,disableInteractiveElementBlocking:!0,children:(Rt,Dt)=>s.jsxs("div",{ref:Rt.innerRef,...Rt.draggableProps,"data-sidebar-gesture-ignore":!0,"data-sidebar-entity-index":At,className:"relative",children:[Kn(At),At===G.length-1&&Kn(G.length,"bottom"),qe.kind==="workspace"?Hn(qe.workspace,qe.members,Dt.isDragging,!!Dt.combineTargetFor,Rt.dragHandleProps):qe.kind==="collaboration"?Nn(qe.group,qe.members,Rt.dragHandleProps,Dt.isDragging,!!Dt.combineTargetFor):s.jsx("div",{...B?cr(()=>B(qe.session.id)):{},className:`group relative flex items-center gap-1 rounded-md pr-1 transition-colors ${Dt.combineTargetFor?"bg-primary/15 text-foreground ring-1 ring-primary/40":Dt.isDragging?"bg-surface-elevated text-foreground opacity-90 shadow-lg":Br(qe.session.id)??(!Ie&&qe.session.id===c?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2")} cursor-grab active:cursor-grabbing`,children:Zn(qe.session,Rt.dragHandleProps)})]})},qe.id)),ct.placeholder]})})}),ps=s.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[s.jsxs("div",{"data-session-sidebar-header":!0,className:"relative z-20 shrink-0 px-3 py-0.5",children:[s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-3 bottom-0 z-10 h-px bg-border opacity-40"}),s.jsxs("div",{className:"flex w-full items-center gap-1.5",children:[s.jsx("div",{className:"min-w-0 flex-1",children:s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-[12px] font-medium text-muted-foreground",children:_e("sidebar.sessions")}),s.jsx("span",{className:"text-[11px] text-muted-foreground",children:a.length}),Kr>0&&s.jsx("span",{className:"ml-0.5 flex items-center",children:s.jsx(g6,{count:Kr,tone:"running",title:_e("agent.aiRunning")})})]})}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsx("button",{"data-session-sidebar-header-action":!0,type:"button",onClick:()=>{de(!1),pr(null)},className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-primary/15 hover:text-primary active:scale-95","aria-label":"Agent 工作台",title:"Agent 工作台",children:s.jsx(Vd,{size:16})}),(!ke||$e)&&s.jsx("button",{"data-session-sidebar-header-action":!0,type:"button",onClick:r,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-destructive/20 hover:text-destructive active:scale-95","aria-label":_e("common.close"),children:s.jsx(Qn,{size:16})})]})]})]}),ft&&s.jsxs("div",{role:"alert",className:"mx-2 mt-2 flex items-start gap-2 rounded-lg bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:[s.jsx("span",{className:"min-w-0 flex-1",children:ft}),s.jsx("button",{type:"button","aria-label":"关闭协作错误提示",className:"shrink-0",onClick:()=>q(null),children:s.jsx(Qn,{size:14})})]}),s.jsxs("div",{ref:ne,className:"relative z-10 flex min-h-0 flex-1 flex-col overflow-y-auto overscroll-contain px-1.5 pt-0.5 pb-1.5",children:[(at.length>0||bt)&&s.jsxs("section",{className:"mb-2 rounded-lg border border-primary/20 bg-primary/5","aria-label":"协作待处理事项",children:[s.jsxs("button",{type:"button",className:"flex min-h-11 w-full items-center gap-2 px-3 text-left text-xs text-primary","aria-expanded":It,onClick:()=>yt(G=>!G),children:[s.jsx(Vd,{size:14}),s.jsx("span",{className:"min-w-0 flex-1",children:"需要你处理"}),s.jsx("span",{children:at.length}),s.jsx(hi,{size:12,className:It?"rotate-90":""})]}),It&&s.jsxs("div",{className:"space-y-1 p-1 pt-0",children:[bt&&s.jsxs("p",{role:"alert",className:"px-2 py-2 text-[11px] text-destructive",children:[bt,s.jsx("button",{type:"button",className:"ml-2 text-primary",onClick:()=>{mu.getState().refresh()},children:"重试"})]}),at.map(G=>s.jsxs("button",{type:"button",className:"min-h-11 w-full rounded-md px-2 py-2 text-left hover:bg-surface-2",onClick:()=>{_5(G.groupId,G.id),pr(G.groupId).then(Le=>{Le&&_5(G.groupId,G.id)})},children:[s.jsx("span",{className:"block truncate text-xs text-foreground",children:G.title}),s.jsxs("span",{className:"mt-1 block truncate text-[10px] text-muted-foreground",children:[nr.find(Le=>Le.id===G.groupId)?.name??"协作组"," · ",Qc(G)]})]},G.id))]})]}),s.jsx(EO,{sessions:Ae,loading:lt,attachingName:pe,onRefresh:Ce,onRestore:K,onClose:ye}),Vr.filter(G=>!G.sessionIds.length).map(G=>s.jsx(td,{onDragEnd:()=>{},children:Nn(G,[])},G.id)),a.length===0?s.jsxs("div",{className:"rounded-xl bg-surface-2/60 px-4 py-8 text-center",children:[s.jsx(Bo,{size:26,className:"mx-auto mb-2 text-muted-foreground"}),s.jsx("p",{className:"text-[12px] text-muted-foreground",children:_e("sidebar.noSessions")})]}):Sr.length===0&&v.length===0?s.jsx("div",{className:"rounded-xl bg-surface-2/60 px-4 py-6 text-center",children:s.jsx("p",{className:"text-[12px] text-muted-foreground",children:_e("sidebar.noMatchingSessions")})}):wt?s.jsx("div",{className:"flex flex-1 flex-col",children:s.jsx(td,{onBeforeCapture:fs,onDragStart:kr,onDragEnd:G=>Pn(Nr,G),children:s.jsx(Sl,{droppableId:"sidebar-groups",type:"group",direction:"vertical",children:G=>s.jsxs("div",{ref:G.innerRef,...G.droppableProps,className:"flex flex-1 flex-col space-y-1.5",children:[sn.map((Le,Ke)=>{const ct=Mr.has(Le.key),qe=!ct&&Ke===sn.length-1,At=E0(Le.sessions,v,Qr,Vr);let Rt=0,Dt=0;for(const Ot of Le.sessions){const hr=l.get(Ot.id);hr?.agentStatus==="working"&&(Rt+=1),(hr?.agentStatus==="waiting"||hr?.agentNeedsReview)&&(Dt+=1)}const ot=Le.key==="";return s.jsx(Cl,{draggableId:`sidebar-group:${Le.key||"__ungrouped__"}`,index:Ke,isDragDisabled:ot,disableInteractiveElementBlocking:!0,children:(Ot,hr)=>s.jsxs("div",{ref:Ot.innerRef,...Ot.draggableProps,className:`shrink-0 rounded-md transition-colors ${qe?"flex flex-1 flex-col ":""}${hr.isDragging?"bg-surface-elevated shadow-lg opacity-90":""}`,children:[s.jsxs("button",{type:"button",...ot?{}:Ot.dragHandleProps,onClick:()=>{rn(Le.key),Sn.current.delete(Le.key)},className:`flex w-full shrink-0 items-center gap-1.5 rounded-md px-1.5 py-1 text-left text-muted-foreground transition hover:bg-surface-2 ${ot?"":"cursor-grab active:cursor-grabbing"}`,title:Le.key||Le.label,children:[s.jsx(hi,{size:13,className:`shrink-0 transition-transform ${ct?"":"rotate-90"}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-[11.5px] font-semibold uppercase tracking-wide",children:Le.label}),Rt>0&&s.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--success)] animate-pulse"}),Dt>0&&s.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--warning)] animate-pulse"}),s.jsx(k5,{sessionIds:Le.sessions.map(Zt=>Zt.id)}),s.jsx("span",{className:"shrink-0 text-[10.5px] text-muted-foreground/70",children:Le.sessions.length})]}),!ct&&s.jsx("div",{className:`mt-0.5 pl-2 ${qe?"flex flex-1 flex-col":""}`,children:s.jsx(Sl,{droppableId:`group-sessions:${Le.key}`,type:"session",direction:"vertical",isCombineEnabled:!Hr,children:Zt=>s.jsxs("div",{ref:Zt.innerRef,...Zt.droppableProps,"data-sidebar-entity-list-id":`group-sessions:${Le.key}`,className:`${qe?"flex-1 ":""}space-y-0.5`,children:[At.map((z,N)=>s.jsx(Cl,{draggableId:z.id,index:N,disableInteractiveElementBlocking:!0,children:($,ee)=>s.jsxs("div",{ref:$.innerRef,...$.draggableProps,"data-sidebar-gesture-ignore":!0,"data-sidebar-entity-index":N,className:"relative",children:[Kn(N),N===At.length-1&&Kn(At.length,"bottom"),z.kind==="workspace"?Hn(z.workspace,z.members,ee.isDragging,!!ee.combineTargetFor,$.dragHandleProps):z.kind==="collaboration"?Nn(z.group,z.members,$.dragHandleProps,ee.isDragging,!!ee.combineTargetFor):s.jsx("div",{...B?cr(()=>B(z.session.id)):{},className:`group relative flex items-center gap-1 rounded-md pr-1 transition-colors ${ee.combineTargetFor?"bg-primary/15 text-foreground ring-1 ring-primary/40":ee.isDragging?"bg-surface-elevated text-foreground opacity-90 shadow-lg":Br(z.session.id)??(!Ie&&z.session.id===c?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2")} cursor-grab active:cursor-grabbing`,children:Zn(z.session,$.dragHandleProps)})]})},z.id)),Zt.placeholder]})})})]})},Le.key||"__ungrouped__")}),G.placeholder]})})})}):Rn(ln,"sidebar-entities")]}),s.jsx(Uw,{onReselect:()=>{h&&(ht.current=null,je(G=>G+1),h())}}),Se&&s.jsx(FP,{directories:a.flatMap(G=>{const Le=l.get(G.id)?.cwd;return Le?[Le]:[]}),tmuxAvailable:fe,options:un,launchPending:Be,launchError:oe?_e(Rm(oe)):null,agents:Gr,selectedAgent:me,detecting:it,resumeHistory:Wt,resumeHistoryLoading:vt,resumeHistoryPendingId:Qt,resumeHistoryError:Ut,onRefreshAgents:()=>{dt().catch(()=>{})},onSelectAgent:G=>{sr(G).catch(()=>{})},onLaunchAgent:Ue,onResumeHistory:G=>{Et(G)},onRemoveResumeHistory:G=>{kt(G)},onClose:()=>de(!1),onOptionsChange:Ir,additionalContent:on&&U?.latestVersion&&s.jsxs("div",{className:"mb-1 rounded-lg bg-[rgb(var(--warning-rgb)_/_0.10)] px-2.5 py-2.5 text-foreground",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"mt-0.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-[rgb(var(--warning-rgb)_/_0.16)] text-[color:var(--warning)]",children:s.jsx(yn,{size:13,className:U.status==="installing"||U.status==="restarting"?"animate-spin":""})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-semibold",children:_e("sidebar.updateAvailable",{version:U.latestVersion})}),s.jsx("span",{className:"mt-0.5 block text-[10.5px] leading-relaxed text-muted-foreground",children:U.status==="installing"?_e("sidebar.updateInstalling"):U.status==="ready"?_e("sidebar.updateReady"):U.status==="restarting"?_e("sidebar.updateRestarting"):_e("sidebar.updateFailed")})]})]}),U.status==="ready"&&Z&&s.jsx("button",{type:"button",disabled:V,onClick:Z,className:"mt-2 flex w-full items-center justify-center rounded-md bg-[var(--warning)] px-2 py-1.5 text-[11px] font-semibold text-[color:var(--bg)] transition hover:opacity-90 disabled:cursor-wait disabled:opacity-60",children:_e("sidebar.updateRestart")}),U.status==="error"&&le&&s.jsx("button",{type:"button",disabled:V,onClick:le,className:"mt-2 flex w-full items-center justify-center rounded-md bg-surface-elevated px-2 py-1.5 text-[11px] font-semibold text-foreground transition hover:bg-surface-2 disabled:cursor-wait disabled:opacity-60",children:_e("sidebar.updateRetry")})]}),footerActions:s.jsx(kO,{serverAttention:Me,onOpenSettings:()=>{de(!1),W()},actions:[...F?[{label:_e("sidebar.subscriptionQuota"),icon:TA,onSelect:()=>{de(!1),F()}}]:[],{label:"Agent 工作台",icon:Vd,onSelect:()=>{de(!1),pr(null)}},{label:"服务与设备",icon:zw,onSelect:()=>{de(!1),Hw()}},...Y?[{label:_e($e?"sidebar.unpinSidebar":"sidebar.pinSidebar"),icon:$e?od:ad,separated:!0,onSelect:()=>{de(!1),Y()}}]:[]]})}),Ye&&s.jsx(fb,{onEnterGroup:async G=>{if(!await pr(G))throw new Error("协作组已保存,打开工作区失败,请重试");st(!1)},onFloatingChange:async G=>{if(G){if(!await pr(G))throw new Error("打开协作工作区失败");st(!1)}},activeSessionId:c,defaultSessionMode:te,onClose:()=>st(!1),onNewSession:G=>p(G)}),Object.entries(We).map(([G,Le])=>s.jsx(fb,{activeSessionId:c,initialCollaborationGroupId:G,initialFloating:Le,visible:!Ie,onEnterGroup:async Ke=>{if(Ke===G){await pr(Ke);return}if(!await pr(Ke))throw new Error("协作组已保存,打开工作区失败,请重试");await co({floatingGroupId:null},G),Te(ct=>{const qe={...ct};return delete qe[G],qe})},onFloatingChange:Ke=>Tt(G,Ke),defaultSessionMode:te,onClose:()=>{ae.current=!0,Te(Ke=>{const ct={...Ke};return delete ct[G],ct})},onNewSession:Ke=>p(Ke)},G)),!Se&&s.jsxs("div",{className:"relative z-10 shrink-0 bg-[var(--chrome-bg)] px-3 pb-3 pt-1 md:border-t md:border-border md:p-2",children:[oe&&s.jsx("p",{role:"alert",className:"mb-2 text-[11px] leading-relaxed text-destructive",children:_e(Rm(oe))}),s.jsxs("div",{className:`grid gap-1.5 [&>button]:min-h-11 [&>button]:shadow-none [&>button]:ring-0 md:[&>button]:min-h-0 ${me?"grid-cols-[minmax(0,1fr)_minmax(0,1fr)_2.5rem]":"grid-cols-[minmax(0,1fr)_2.5rem]"}`,children:[s.jsxs("button",{type:"button",onClick:Xr,disabled:Be,"aria-busy":Be,className:`flex min-w-0 items-center justify-center gap-2 rounded-lg px-2 py-2.5 text-[12px] font-semibold transition active:scale-[0.99] ${me?"bg-surface-elevated text-foreground ring-1 ring-border/30 hover:bg-surface-2":"bg-primary text-primary-foreground ring-1 ring-primary/40 shadow-md shadow-primary/25 hover:bg-primary/90"}`,title:_e("sidebar.newSession"),"aria-label":_e("sidebar.newSession"),children:[s.jsx(Bo,{size:15,className:"shrink-0"}),s.jsx("span",{className:"truncate",children:Be?_e("sidebar.sessionCreating"):"Terminal"})]}),me&&s.jsxs("button",{type:"button",onClick:fn,disabled:Be,"aria-busy":Be,className:"flex min-w-0 items-center justify-center gap-2 rounded-lg bg-primary px-2 py-2.5 text-[12px] font-semibold text-primary-foreground ring-1 ring-primary/40 shadow-md shadow-primary/25 transition hover:bg-primary/90 active:scale-[0.99]",title:_e("sidebar.newSessionWithAgent",{agent:me.displayName}),"aria-label":_e("sidebar.newSessionWithAgent",{agent:me.displayName}),children:[s.jsx(Mc,{agent:me,size:15}),s.jsx("span",{className:"truncate",children:me.displayName})]}),s.jsxs("button",{type:"button",onClick:tr,disabled:Be,className:"relative inline-flex w-10 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-[0.97]",title:nt,"aria-label":nt,"aria-expanded":Se,"aria-controls":"sidebar-launch-options",children:[s.jsx(Qo,{size:15}),Me&&s.jsx("span",{className:"absolute right-0.5 top-0.5 h-2 w-2 rounded-full bg-destructive ring-2 ring-[var(--chrome-bg)]","aria-hidden":"true"}),on&&s.jsx("span",{className:`absolute top-0.5 h-2 w-2 rounded-full bg-[var(--warning)] ring-2 ring-[var(--chrome-bg)] ${Me?"right-3.5":"right-0.5"}`,"aria-hidden":"true"})]})]})]})]});return $e?s.jsx("div",{"data-session-sidebar-pinned":!0,className:"h-full flex flex-col app-chrome-bg border-r border-border",children:ps}):s.jsx(f6,{side:"left",isOpen:e,drawerWidthPx:t,onClose:r,onOpen:n,push:ke,children:ps})}function MO(){const{t:e}=zr();return s.jsxs("div",{role:"status","aria-label":e("rightSidebar.loadingGitChanges"),className:"td-loading-skeleton flex h-full min-h-0 flex-col overflow-hidden bg-surface",children:[s.jsx("span",{className:"sr-only",children:e("rightSidebar.loadingGitChanges")}),s.jsxs("div",{"aria-hidden":"true",className:"shrink-0 border-b border-border/15 px-3 py-2",children:[s.jsxs("div",{className:"mb-2 flex h-5 items-center gap-1",children:[s.jsx("div",{className:"h-4 w-16 rounded bg-surface-2"}),s.jsx("div",{className:"h-4 w-7 rounded bg-surface-2"}),s.jsx("div",{className:"h-4 w-12 rounded bg-surface-2"})]}),s.jsxs("div",{className:"flex h-[15px] items-center justify-between",children:[s.jsx("div",{className:"h-2 w-14 rounded bg-surface-2"}),s.jsx("div",{className:"h-2 w-6 rounded bg-surface-2"})]}),s.jsxs("div",{className:"mt-2 flex h-7 items-center gap-1.5",children:[s.jsx("div",{className:"h-7 w-12 rounded-full bg-surface-2"}),s.jsx("div",{className:"h-7 w-16 rounded-full bg-surface-2"}),s.jsx("div",{className:"h-3 w-24 max-w-[30%] rounded bg-surface-2"}),s.jsx("div",{className:"ml-auto h-4 w-4 rounded-full bg-surface-2"})]})]}),s.jsxs("div",{"aria-hidden":"true",className:"overflow-hidden px-3 py-2",children:[s.jsxs("div",{className:"flex h-8 items-center gap-2",children:[s.jsx("div",{className:"h-3 w-3 rounded-sm bg-surface-2"}),s.jsx("div",{className:"h-2 w-32 max-w-[55%] rounded bg-surface-2"})]}),["w-3/5","w-2/5","w-1/2","w-1/3"].map((t,r)=>s.jsxs("div",{className:"flex h-9 items-center gap-2 pl-5",style:{opacity:1-r*.15},children:[s.jsx("div",{className:"h-3 w-3 shrink-0 rounded-sm bg-surface-2"}),s.jsx("div",{className:`h-2 rounded bg-surface-2 ${t}`})]},t))]})]})}function jO({slow:e=!1}){const{t}=zr();return s.jsxs("div",{role:"status","aria-label":t("rightSidebar.loadingGitChanges"),className:"td-loading-skeleton relative h-full min-h-0 overflow-hidden bg-surface px-3",children:[s.jsx("span",{className:"sr-only",children:t("rightSidebar.loadingGitChanges")}),s.jsxs("div",{"aria-hidden":"true",children:[s.jsxs("div",{className:"flex h-[76px] items-center gap-2 border-b border-border/40 px-2",children:[s.jsx("div",{className:"h-6 w-6 rounded-md bg-surface-2"}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"h-3 w-16 rounded bg-surface-2"}),s.jsx("div",{className:"h-2 w-12 rounded bg-surface-2"})]})]}),s.jsxs("div",{className:"flex h-11 items-center gap-2 px-1 pt-3",children:[s.jsx("div",{className:"h-6 w-6 rounded-md bg-surface-2"}),s.jsx("div",{className:"h-3 w-16 rounded bg-surface-2"}),s.jsx("div",{className:"ml-auto h-4 w-12 rounded-full bg-surface-2"})]}),[!1,!0].map(r=>s.jsxs("div",{className:"border-b border-border/40 px-1 py-4",children:[s.jsxs("div",{className:"mb-2 flex h-8 items-center justify-between",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"h-3 w-14 rounded bg-surface-2"}),r&&s.jsx("div",{className:"h-2 w-28 rounded bg-surface-2"})]}),s.jsx("div",{className:"h-8 w-12 rounded-md bg-surface-2"})]}),s.jsx("div",{className:"h-10 rounded-md bg-surface-2"})]},String(r))),s.jsx("div",{className:"flex h-[69px] items-center border-b border-border/40 px-2",children:s.jsx("div",{className:"h-3 w-16 rounded bg-surface-2"})}),s.jsxs("div",{className:"space-y-2 px-1 py-4",children:[s.jsxs("div",{className:"flex h-8 items-center justify-between",children:[s.jsx("div",{className:"h-3 w-14 rounded bg-surface-2"}),s.jsx("div",{className:"h-8 w-28 rounded-md bg-surface-2"})]}),s.jsx("div",{className:"h-7 rounded-md bg-surface-2"}),s.jsx("div",{className:"h-10 rounded-md bg-surface-2"})]})]}),e&&s.jsx("div",{className:"absolute inset-x-3 bottom-3 rounded-md bg-surface-elevated px-3 py-2 text-xs text-muted-foreground",children:t("rightSidebar.loadingGitChangesSlow")})]})}const L6=()=>kc(()=>import("./RightSidebar-CcMSU1v8.js").then(e=>e.R),__vite__mapDeps([7,1,2,3,4,5,8,9,10,11,12,13,14,15,16,17])).then(e=>({default:e.RightSidebar})),DO=b.lazy(L6);function Ab(e){const t=b.useRef(!1);b.useEffect(()=>{const p=navigator.connection;if(!(p?.saveData||/2g|3g/.test(p?.effectiveType??"")))return E1(()=>{L6().catch(()=>{})},3e3)},[]);const{t:r}=zr(),n=Gt(p=>p.rootPath),a=Gt(p=>p.rightTab),c=Gt(p=>p.setRightTab),l=n?.replace(/\/+$/,"").split("/").pop()||r("rightSidebar.workspace");(e.isOpen||e.pinned)&&(t.current=!0);const h=s.jsx(f6,{side:"right",isOpen:e.isOpen,drawerWidthPx:e.drawerWidthPx,onClose:e.onClose,onOpen:e.onOpen,pinned:e.pinned,children:s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[s.jsxs("div",{className:"shrink-0 border-b border-border/15 bg-surface px-2 pt-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"min-w-0 flex-1 px-1",children:s.jsx("div",{className:"flex min-h-[1.25rem] items-baseline gap-1.5",children:s.jsx("span",{className:"truncate text-[13px] font-semibold text-foreground",children:l})})}),s.jsx("div",{"aria-hidden":"true",className:"flex items-center gap-1.5",children:[El,BT,Qo].map((p,m)=>s.jsx("span",{className:"inline-flex h-8 w-8 items-center justify-center rounded-full bg-surface-2 text-muted-foreground",children:s.jsx(p,{size:14})},m))}),s.jsx("button",{type:"button",onClick:e.onClose,"aria-label":r("common.close"),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",children:s.jsx(Qn,{size:14})})]}),s.jsx("div",{className:"mt-2 grid grid-cols-5 gap-0.5 rounded-md bg-surface-2 p-0.5",children:[["git",nA,"rightSidebar.tabGit"],["diff",iA,"rightSidebar.tabChanges"],["files",jc,"rightSidebar.tabFiles"],["architecture",wT,"architecture.tab"],["computer",Vw,"rightSidebar.tabComputer"]].map(([p,m,x])=>s.jsxs("button",{type:"button",onClick:()=>c(p),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium ${a===p?"bg-surface-elevated text-foreground":"text-muted-foreground"}`,children:[s.jsx(m,{size:12}),r(x)]},p))}),s.jsx("div",{className:"h-2"})]}),s.jsx("div",{className:"min-h-0 flex-1 bg-surface",children:a==="architecture"?s.jsx("div",{role:"status",className:"p-3 text-xs text-muted-foreground",children:r("architecture.loading")}):a==="computer"?s.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:r("computer.loading")}):a==="git"?s.jsx(jO,{}):s.jsx(MO,{})})]})});return t.current?s.jsx(b.Suspense,{fallback:h,children:s.jsx(DO,{...e})}):h}const Tb=rc(e=>({overlay:"off",setOverlay:t=>e({overlay:t})}));function BO(e){let t=1,r="terminal";for(;;){let n=!1;for(const a of e.values())if(a.name===r){n=!0;break}if(!n)break;r=`terminal-${t}`,t++}return r}const QO=rc((e,t)=>({sessions:new Map,activeSessionId:null,nextSessionNumber:1,createSession:r=>{const n=j3(),a=Date.now(),c=t().sessions,l=BO(c),h={id:n,cwd:r,sessionId:null,name:l,customName:!1,createdAt:a,lastActivity:a};return e(p=>{const m=new Map(p.sessions);return m.set(n,h),{sessions:m,activeSessionId:p.activeSessionId??n,nextSessionNumber:p.nextSessionNumber+1}}),n},closeSession:r=>{e(n=>{const a=new Map(n.sessions),c=n.activeSessionId===r;a.delete(r);let l=n.activeSessionId;if(c){const h=Array.from(a.keys());l=h.length>0?h[0]:null}return{sessions:a,activeSessionId:l}})},switchSession:r=>{e(n=>n.sessions.has(r)?{activeSessionId:r}:n)},updateSession:(r,n)=>{e(a=>{const c=a.sessions.get(r);if(!c)return a;const l=new Map(a.sessions);return l.set(r,{...c,...n,lastActivity:Date.now()}),{sessions:l}})},setTerminalSession:(r,n)=>{t().updateSession(r,{sessionId:n.sessionId})},getActiveSession:()=>{const r=t();if(r.activeSessionId)return r.sessions.get(r.activeSessionId)},getSessionCount:()=>t().sessions.size,clearAllSessions:()=>{e({sessions:new Map,activeSessionId:null,nextSessionNumber:1})}})),PO=[7e5,1e6,14e5,18e5,24e5,32e5,4e6,5e6,6e6,8e6,1e7,12e6].map(e=>({id:"auto",maxSize:1600,bitRate:e,maxFps:30}));class OO{level=6;badSince=null;goodSince=null;connectedAt=0;lastSample=-1/0;lastChange=-1/0;lastUpgrade=-1/0;upgradeAfter=0;failedProbes=0;baselineRtt=1/0;get quality(){return PO[this.level]}connected(t){this.connectedAt=t,this.badSince=this.goodSince=null,this.lastSample=-1/0}sample(t,r,n=1600){if(r-this.lastSample>2500&&(this.badSince=this.goodSince=null),this.lastSample=r,t.rttMs!==null&&(this.baselineRtt=Math.min(this.baselineRtt,t.rttMs)),r-this.connectedAt<3e3)return null;const a=t.rttMs!==null&&t.rttMs>this.baselineRtt+150,c=t.deliveryDelayMs>250||t.decodeQueue>=4||a&&t.frames>0&&t.deliveryDelayMs>100,l=t.deliveryDelayMs>800||t.decodeQueue>=8,h=t.rttMs!==null&&t.rttMs<this.baselineRtt+100&&t.deliveryDelayMs<80&&t.decodeQueue<=1;this.badSince=c?this.badSince??r:null,this.goodSince=h?this.goodSince??r:null;const p=n<=1080?7:n<=1600?9:11;if(this.badSince!==null&&r-this.badSince>=(l?1e3:2e3)&&r-this.lastChange>=(l?2e3:3e3)&&this.level>0){this.level=Math.max(0,this.level-(l?2:1));const m=r-this.lastUpgrade<2e4;this.failedProbes=m?this.failedProbes+1:0,this.upgradeAfter=r+(m?Math.min(3e4,8e3*2**(this.failedProbes-1)):5e3),this.lastUpgrade=-1/0}else if(this.goodSince!==null&&r-this.goodSince>=3e3&&r-this.lastChange>=4e3&&r>=this.upgradeAfter&&this.level<p)this.level++,this.lastUpgrade=r;else return null;return this.lastChange=r,this.badSince=this.goodSince=null,this.quality}}async function Fc(e,t){const r=await fetch(e,{...t,headers:{"Content-Type":"application/json",Accept:"application/json",...t?.headers??{}}}),n=await r.json().catch(()=>null);if(!r.ok||!n){const a=n?.error||n?.code||`ANDROID_REQUEST_FAILED_${r.status}`;throw new Error(a)}return n}async function FO(){return Fc("/api/android/devices")}async function $O(e){return Fc("/api/android/connect",{method:"POST",body:JSON.stringify({address:e})})}const Lf=[{id:"low",maxSize:720,bitRate:12e5,maxFps:30},{id:"medium",maxSize:1080,bitRate:4e6,maxFps:30},{id:"high",maxSize:1600,bitRate:8e6,maxFps:60}],yd=Lf[1];function w1(e){if(!e||typeof e!="object")return yd;const t=e;if(t.id==="auto")return{id:"auto",maxSize:1600,bitRate:4e6,maxFps:30};const r=Lf.find(l=>l.id===t.id);if(r)return r;if(t.id!=="custom")return yd;const n=typeof t.maxSize=="number"?Math.max(360,Math.min(2160,Math.round(t.maxSize))):1080,a=typeof t.bitRate=="number"?Math.max(3e5,Math.min(3e7,Math.round(t.bitRate))):4e6,c=typeof t.maxFps=="number"?Math.max(0,Math.min(60,Math.round(t.maxFps))):30;return{id:"custom",maxSize:n,bitRate:a,maxFps:c}}function UO(e,t){if(!/^[0-9a-zA-Z_.:\-]{1,128}$/.test(e))throw new Error("INVALID_SERIAL");const r=new URLSearchParams;t&&(r.set("max_size",String(t.maxSize)),r.set("bit_rate",String(t.bitRate)),t.maxFps>0&&r.set("max_fps",String(t.maxFps)));const n=r.toString();return`/api/android/${e}/ws${n?`?${n}`:""}`}function Cb(e){const t={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[r,n]of Object.entries(t))if(e.includes(r))return n;return e}function zO(e){return Fc(`/api/android/recordings?serial=${encodeURIComponent(e)}`)}function HO(e){return Fc("/api/android/recordings",{method:"POST",body:JSON.stringify({serial:e})})}function WO(e){return Fc(`/api/android/recordings/${encodeURIComponent(e)}/stop`,{method:"POST"})}function GO(e,t){return Fc(`/api/android/recordings/${encodeURIComponent(e)}/save`,{method:"POST",body:JSON.stringify({directory:t})})}function VO(e){return Fc(`/api/android/recordings/${encodeURIComponent(e)}`,{method:"DELETE"})}const qO=0,YO=1,ZO=2,KO=3,XO=4,JO=5,eF=7,tF=10,rF=11,nF=16,Sb=17,_b=0,bm=1,sF=2,kb=3,ym=0,Lb=1,Ib=1,uu=0xffffffffffffffffn,wh=0xfffffffffffffffen,N0={HOME:3,APP_SWITCH:187,POWER:26,VOLUME_UP:24,VOLUME_DOWN:25};function I6(e,t,r){e.setUint32(t,Math.max(0,Math.round(r.x))&4294967295),e.setUint32(t+4,Math.max(0,Math.round(r.y))&4294967295),e.setUint16(t+8,Math.min(65535,Math.round(r.screenWidth))),e.setUint16(t+10,Math.min(65535,Math.round(r.screenHeight)))}function iF(e,t,r,n,a,c){const l=new Uint8Array(32),h=new DataView(l.buffer);return h.setUint8(0,ZO),h.setUint8(1,e),h.setBigUint64(2,t),I6(h,10,r),h.setUint16(22,Math.max(0,Math.min(65535,Math.round(n*65536)))),h.setUint32(24,a>>>0),h.setUint32(28,c>>>0),l}function vm(e,t,r=0,n=0){const a=new Uint8Array(14),c=new DataView(a.buffer);return c.setUint8(0,qO),c.setUint8(1,e),c.setUint32(2,t>>>0),c.setUint32(6,r>>>0),c.setUint32(10,n>>>0),a}function aF(e,t,r,n=0){const a=new Uint8Array(21),c=new DataView(a.buffer);c.setUint8(0,KO),I6(c,1,e);const l=h=>Math.max(-32768,Math.min(32767,Math.round(Math.max(-1,Math.min(1,h/16))*32768)));return c.setInt16(13,l(t)),c.setInt16(15,l(r)),c.setUint32(17,n>>>0),a}function oF(e){const t=new TextEncoder().encode(e);if(!t.length)return null;const r=t.subarray(0,300),n=new Uint8Array(5+r.length),a=new DataView(n.buffer);return a.setUint8(0,YO),a.setUint32(1,r.length),n.set(r,5),n}function lF(e){const t=new TextEncoder().encode(e);if(!t.length||t.length>255)return null;const r=new Uint8Array(2+t.length);return r[0]=nF,r[1]=t.length,r.set(t,2),r}function R0(e){return new Uint8Array([e])}function Eb(e){return new Uint8Array([XO,e])}function cF(e){return new Uint8Array([tF,e?1:0])}function uF(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t)}function dF(e){const t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function wm(e){return e.toString(16).padStart(2,"0")}function E6(e,t,r){for(let n=0;n+4<e.length;n++){const a=e[n]===0&&e[n+1]===0&&e[n+2]===1,l=e[n]===0&&e[n+1]===0&&e[n+2]===0&&e[n+3]===1?n+4:a?n+3:-1;if(l<0||l>=e.length)continue;if((r?e[l]>>1&63:e[l]&31)!==t){n=l-1;continue}let p=l+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(l,Math.min(e.length,p))}return null}function hF(e){const t=e?E6(e,7,!1):null;return t&&t.length>=4?`avc1.${wm(t[1])}${wm(t[2])}${wm(t[3])}`:"avc1.42e01e"}function fF(e){const t=e?E6(e,32,!0):null;if(t&&t.length>=13){const r=t[1]>>6&3,n=t[1]&31,a=t[12];return`hev1.${r}.${n}.L${a}.B0`}return"hev1.1.6.L120.B0"}class pF{constructor(t,r){this.canvas=t,this.callbacks=r}canvas;callbacks;liveBitrate=!1;bitrateFailureDetail;get lastBitrateFailure(){return this.bitrateFailureDetail}bitrateRequestId=0;bitratePending=null;get supportsLiveBitrate(){return this.liveBitrate}get canSetBitrate(){return this.liveBitrate&&!this.bitratePending&&this.socket?.readyState===1}setBitrate(t){return!this.canSetBitrate||!Number.isInteger(t)||t<3e5||t>3e7?Promise.resolve(!1):new Promise(r=>{const n=++this.bitrateRequestId,a=setTimeout(()=>this.finishBitrate(!1,`BITRATE_CLIENT_TIMEOUT: requested=${t} bps; no server confirmation within 4000ms`),4e3);this.bitratePending={id:n,value:t,resolve:r,timer:a},this.send({type:"bitrate",requestId:n,bitRate:t})})}finishBitrate(t,r){const n=this.bitratePending;n&&(this.bitratePending=null,clearTimeout(n.timer),t||(this.liveBitrate=!1,this.bitrateFailureDetail=r??this.bitrateFailureDetail??"BITRATE_REASON_UNAVAILABLE: server rejected adjustment without a diagnostic",this.closedByUser||this.callbacks.onBitrateSupport?.(!1,this.bitrateFailureDetail)),n.resolve(t))}socket=null;decoder=null;configured=!1;configData=null;header=null;closedByUser=!1;lastMessageAt=0;lastFrameAt=0;lastResetAt=0;heartbeat=null;statsTimer=null;stallTimer=null;pendingConfig=null;needsKeyframe=!1;frameCount=0;receivedFrames=0;decodedFrames=0;controlsSent=0;lastSeq=0;lastType="";bytesSinceSample=0;warnedUnsupported=!1;lastSampleAt=0;serial="";autoQuality=!1;pingAt=null;rttMs=null;rttAt=0;minimumFrameOffset=1/0;deliveryDelayMs=0;peakDecodeQueue=0;sampleFrames=0;get currentHeader(){return this.header}connect(t,r){this.liveBitrate=!1,this.bitrateFailureDetail=void 0,this.serial=t,this.autoQuality=r?.id==="auto",this.closedByUser=!1,this.callbacks.onState("connecting");let n;try{n=qw(UO(t,r))}catch(a){this.callbacks.onState("error",a instanceof Error?a.message:"ANDROID_STREAM_FAILED");return}this.socket=n,n.onopen=()=>{this.lastMessageAt=Date.now()},n.onmessage=a=>{this.closedByUser||this.handleMessage(a.data)},n.onerror=()=>{this.closedByUser||this.callbacks.onState("error","SCRCPY_CONNECTION_LOST")},n.onclose=()=>{this.finishBitrate(!1,"BITRATE_CONNECTION_CLOSED: preview connection closed"),this.liveBitrate=!1,this.teardownTimers(),this.closedByUser?this.callbacks.onState("idle"):this.callbacks.onState("error","SCRCPY_CONNECTION_CLOSED")},this.startTimers()}disconnect(){this.closedByUser=!0,this.finishBitrate(!1),this.liveBitrate=!1,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.stallTimer&&clearInterval(this.stallTimer),this.heartbeat=null,this.statsTimer=null,this.stallTimer=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.pingAt===null&&(this.pingAt=performance.now(),this.send({type:"ping"}))}},this.autoQuality?2e3:15e3),this.stallTimer=setInterval(()=>{if(!this.header||this.closedByUser)return;const t=Date.now();t-this.lastFrameAt>8e3&&t-this.lastResetAt>8e3&&(this.lastResetAt=t,console.warn("[android] no frames for 8s; requesting keyframe reset"),this.sendControl(R0(Sb)))},2e3),this.statsTimer=setInterval(()=>{const t=Date.now(),r=(t-this.lastSampleAt)/1e3;r<=0||(this.callbacks.onStats({fps:Math.round(this.frameCount/r*10)/10,kbps:Math.round(this.bytesSinceSample*8/r/1e3),width:this.header?.width??0,height:this.header?.height??0,received:this.receivedFrames,decoded:this.decodedFrames,controls:this.controlsSent,last:this.lastType,adaptation:this.autoQuality?{rttMs:this.pingAt!==null&&performance.now()-this.pingAt>2e3?performance.now()-this.pingAt:performance.now()-this.rttAt<6e3?this.rttMs:null,deliveryDelayMs:this.sampleFrames?this.deliveryDelayMs:0,decodeQueue:Math.max(this.peakDecodeQueue,this.decoder?.decodeQueueSize??0),frames:this.sampleFrames}:void 0}),this.sampleFrames=0,this.peakDecodeQueue=0,this.frameCount=0,this.bytesSinceSample=0,this.lastSampleAt=t)},1e3)}send(t){if(!(!this.socket||this.socket.readyState!==1))try{this.socket.send(JSON.stringify(t))}catch{}}sendControl(t){t&&(this.controlsSent++,this.send({type:"control",data:uF(t)}))}ack(){this.send({type:"ack",seq:this.lastSeq})}handleMessage(t){if(typeof t!="string")return;this.lastMessageAt=Date.now();let r;try{r=JSON.parse(t)}catch{return}this.lastType=`${r.type??"?"}${r.config?":cfg":""}${r.key?":key":""}`;try{this.dispatchMessage(r)}catch(n){console.warn("[android] message handling failed",n),this.callbacks.onWarning(`处理消息失败:${n instanceof Error?n.message:String(n)}`)}}dispatchMessage(t){switch(t.type){case"bitrate-support":this.liveBitrate=t.supported===!0,this.bitrateFailureDetail=this.liveBitrate?void 0:typeof t.detail=="string"?t.detail.slice(0,4096):"BITRATE_REASON_UNAVAILABLE: server did not provide diagnostics",this.liveBitrate||this.finishBitrate(!1,this.bitrateFailureDetail),this.callbacks.onBitrateSupport?.(this.liveBitrate,this.bitrateFailureDetail);break;case"bitrate-result":t.requestId===this.bitratePending?.id&&this.finishBitrate(t.applied===!0&&t.bitRate===this.bitratePending?.value,typeof t.detail=="string"?t.detail.slice(0,4096):void 0);break;case"header":this.header={deviceName:t.deviceName??this.serial,codec:t.codec??"h264",width:t.width??0,height:t.height??0},this.lastFrameAt=Date.now(),this.callbacks.onHeader(this.header),this.callbacks.onState("streaming");break;case"frame":this.handleFrame(t);break;case"error":this.callbacks.onState("error",t.message||"SCRCPY_ERROR");break;case"closed":this.callbacks.onState("error","SCRCPY_SESSION_CLOSED");break;case"pong":this.pingAt!==null&&(this.rttMs=performance.now()-this.pingAt,this.rttAt=performance.now(),this.pingAt=null);break}}handleFrame(t){if(typeof t.data!="string")return;typeof t.seq=="number"&&(this.lastSeq=t.seq);const r=dF(t.data);if(this.bytesSinceSample+=t.data.length,this.receivedFrames++,this.lastFrameAt=Date.now(),this.decoder?.state==="closed"&&(this.decoder=null,this.configured=!1),t.config){this.configData=r,this.pendingConfig=r,this.configureDecoder(),this.ack();return}this.sampleFrames++;const n=Number(t.pts);if(t.pts!==void 0&&Number.isFinite(n)){const l=performance.now()-n/1e3;this.minimumFrameOffset=Math.min(this.minimumFrameOffset,l),this.deliveryDelayMs=Math.max(0,l-this.minimumFrameOffset)}this.configured||this.configureDecoder();const a=t.key===!0;if(this.needsKeyframe&&!a){this.ack();return}let c=r;this.pendingConfig&&(c=new Uint8Array(this.pendingConfig.length+r.length),c.set(this.pendingConfig,0),c.set(r,this.pendingConfig.length),this.pendingConfig=null),a&&(this.needsKeyframe=!1),this.decode(c,a,t.pts),this.ack()}configureDecoder(){const t=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(R0(Sb))}})}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 r={codec:"avc1.42e01e",optimizeForLatency:!0};let n;t==="h264"?(n=[hF(this.configData),"avc1.42e01e","avc1.4d401e","avc1.64001f"].filter((l,h,p)=>p.indexOf(l)===h),r.avc={format:"annexb"}):t==="h265"?(n=[fF(this.configData),"hev1.1.6.L120.B0","hvc1.1.6.L120.B0"],r.hevc={format:"annexb"}):n=["av01.0.04M.08"];const a=[];for(const c of n)try{this.decoder.configure({...r,codec:c}),this.configured=!0,this.needsKeyframe=!0,c!==n[0]&&console.warn("[android] decoder configured with fallback codec",c);return}catch(l){a.push(`${c}: ${l instanceof Error?l.message:String(l)}`),console.warn("[android] decoder configure failed",c,l)}this.callbacks.onWarning(`解码器配置失败(${a.join(";")})`),this.callbacks.onState("error","VIDEO_DECODER_UNSUPPORTED")}decode(t,r,n){if(!(!this.decoder||this.decoder.state!=="configured"))try{this.decoder.decode(new EncodedVideoChunk({type:r?"key":"delta",timestamp:n?Number(n):this.lastTimestamp+1,data:t})),this.peakDecodeQueue=Math.max(this.peakDecodeQueue,this.decoder.decodeQueueSize),this.lastTimestamp=n?Number(n):this.lastTimestamp+1}catch(a){this.decodeFailureCount++<3&&(console.warn("[android] decode threw",a),this.callbacks.onWarning(`送入解码器失败:${a instanceof Error?a.message:String(a)}`))}}decodeFailureCount=0;lastTimestamp=0;onDecodedFrame(t){this.frameCount++,this.decodedFrames++;const r=t.displayWidth||t.codedWidth,n=t.displayHeight||t.codedHeight,a=this.canvas;(a.width!==r||a.height!==n)&&(a.width=r,a.height=n,this.header&&(this.header={...this.header,width:r,height:n},this.callbacks.onHeader(this.header)));const c=a.getContext("2d");c&&c.drawImage(t,0,0,a.width,a.height),t.close()}pointerPoint(t,r){return{x:t,y:r,screenWidth:this.header?.width??0,screenHeight:this.header?.height??0}}touch(t,r,n,a){const c=t===bm||t===kb,l=c?0:1,h=a===uu&&!c?Ib:0,p=(t===_b||t===bm)&&a===uu?Ib:0;this.sendControl(iF(t,a,this.pointerPoint(r,n),l,p,h))}pointerDown(t,r,n){this.touch(_b,t,r,n==="mouse"?uu:wh)}pointerMove(t,r,n){this.touch(sF,t,r,n==="mouse"?uu:wh)}pointerUp(t,r,n){this.touch(bm,t,r,n==="mouse"?uu:wh)}pointerCancel(t,r,n){this.touch(kb,t,r,n==="mouse"?uu:wh)}scroll(t,r,n,a){this.sendControl(aF(this.pointerPoint(t,r),n,a))}key(t,r=ym){this.sendControl(vm(r,t))}tapKey(t){this.sendControl(vm(ym,t)),this.sendControl(vm(Lb,t))}back(){this.sendControl(Eb(ym)),this.sendControl(Eb(Lb))}home(){this.tapKey(N0.HOME)}recents(){this.tapKey(N0.APP_SWITCH)}power(){this.tapKey(N0.POWER)}volumeUp(){this.tapKey(N0.VOLUME_UP)}volumeDown(){this.tapKey(N0.VOLUME_DOWN)}rotate(){this.sendControl(R0(rF))}expandNotifications(){this.sendControl(R0(JO))}collapsePanels(){this.sendControl(R0(eF))}setDisplayPower(t){this.sendControl(cF(t))}sendText(t){this.sendControl(oF(t))}startApp(t){this.sendControl(lF(t))}}function mF(){try{return crypto.randomUUID().slice(0,8)}catch{return Math.random().toString(36).slice(2,10)}}function gF(){return`termdock-mirror-shot-${new Date().toISOString().replace(/[-:T]/g,"").slice(0,14)}-${mF()}.png`}function Nb(e){const t=Math.max(0,Math.floor(e/1e3)),r=Math.floor(t/60),n=t%60;return`${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}`}async function xF(e,t=gF()){const r=e.width,n=e.height;if(!r||!n)throw new Error("投屏画面尚未就绪");const a=document.createElement("canvas");a.width=r,a.height=n;const c=a.getContext("2d");if(!c)throw new Error("无法读取投屏画面");c.drawImage(e,0,0);const l=await new Promise(h=>a.toBlob(h,"image/png"));if(!l||l.size===0)throw new Error("截图失败,请重试");return new File([l],t,{type:"image/png"})}function N6(e,t,r){const n=r.contentWidth*(t-1)/2,a=r.contentHeight*(t-1)/2;return{x:Math.max(-n,Math.min(n,e.x)),y:Math.max(-a,Math.min(a,e.y))}}function Rb(e,t,r,n,a){const c=Math.max(1,Math.min(8,e.zoom*a)),l=c/e.zoom;return{zoom:c,pan:N6({x:n.x-t.cx-(r.x-t.cx-e.pan.x)*l,y:n.y-t.cy-(r.y-t.cy-e.pan.y)*l},c,t)}}function R6(e,t){return t?new Promise((r,n)=>{const a=crypto.randomUUID(),c=p=>{window.clearTimeout(h),window.removeEventListener("termdock-insert-reference-ack",l),p?r():n(new Error("目标终端不可用,内容尚未插入,请连接终端后重试"))},l=p=>{const m=p.detail;m?.nonce===a&&c(m.ok===!0)},h=window.setTimeout(()=>c(!1),1e4);window.addEventListener("termdock-insert-reference-ack",l),window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:e,sessionId:t,nonce:a,focus:!1,paste:!0}}))}):Promise.reject(new Error("没有可接收内容的终端"))}function Mb(e,t){return R6(Xm(e,null),t)}const Am=rc(e=>({pending:[],enqueue:(t,r,n="/",a)=>e(c=>c.pending.some(l=>l.file.id===t.id)?c:{pending:[...c.pending,{file:t,sessionId:r,initialPath:n,insert:a}]}),remove:t=>e(r=>({pending:r.pending.filter(n=>n.file.id!==t)}))}));function bF({file:e,initialPath:t,onInsert:r,onDone:n}){const{t:a}=zr(),[c,l]=b.useState(!1),[h,p]=b.useState(!1),[m,x]=b.useState(!1),[y,w]=b.useState(!1),[v,k]=b.useState(null),L=b.useRef(!1),E=b.useRef(null),R=async()=>{if(!L.current){L.current=!0,p(!0),w(!0);try{await VO(e.id),n()}catch(W){k(W instanceof Error?W.message:String(W))}finally{L.current=!1,p(!1),w(!1)}}};b.useEffect(()=>{if(c)return;E.current?.focus();const W=F=>{if(F.stopPropagation(),F.key==="Escape"&&F.preventDefault(),F.key!=="Tab")return;const U=Array.from(E.current?.querySelectorAll("button:not(:disabled)")??[]),V=U[0],Z=U.at(-1);F.shiftKey&&(document.activeElement===V||document.activeElement===E.current)?(F.preventDefault(),Z?.focus()):!F.shiftKey&&document.activeElement===Z&&(F.preventDefault(),V?.focus())};return document.addEventListener("keydown",W,!0),()=>document.removeEventListener("keydown",W,!0)},[c]);const B=async W=>{if(!L.current){L.current=!0,p(!0),x(W!==void 0),l(!1),k(null);try{const F=await GO(e.id,W);W===void 0&&await r(F.path),n()}catch(F){k(F instanceof Error?F.message:String(F))}finally{L.current=!1,p(!1)}}};return c?s.jsx(Hf,{open:!0,initialPath:t||"/",title:a("android.recordingSave"),onCancel:()=>l(!1),onConfirm:W=>{B(W)}}):Li.createPortal(s.jsx("div",{className:"fixed inset-0 z-modal-panel flex items-center justify-center bg-[var(--app-backdrop)] p-4",children:s.jsxs("div",{ref:E,role:"dialog","aria-modal":"true","aria-labelledby":"recording-save-title",tabIndex:-1,"aria-busy":h,className:"w-full max-w-sm rounded-xl border border-border bg-surface p-4 text-foreground shadow-xl outline-none",children:[s.jsx("h2",{id:"recording-save-title",className:"text-sm font-semibold",children:a("android.recordingConfirm")}),s.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:a("android.recordingSaveHint")}),s.jsxs("p",{className:"mt-2 break-all text-xs text-muted-foreground",children:[e.name," · ",(e.size/1024/1024).toFixed(1)," MB"]}),(v||e.error)&&s.jsx("p",{role:"alert",className:"mt-3 break-words text-xs text-destructive",children:v||e.error}),h&&s.jsxs("p",{role:"status",className:"mt-3 flex items-center gap-2 text-sm text-primary",children:[s.jsx(In,{size:16,className:"animate-spin"}),y?`${a("android.recordingDiscard")}…`:a(m?"android.recordingSaving":"android.captureInserting")]}),s.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[s.jsx("button",{type:"button",disabled:h||e.status!=="ready",onClick:()=>{B()},className:"min-h-10 rounded-lg bg-primary px-3 text-sm text-primary-foreground disabled:opacity-40",children:a("android.recordingInsert")}),s.jsx("button",{type:"button",disabled:h||e.status!=="ready",onClick:()=>l(!0),className:"min-h-10 rounded-lg bg-surface-2 px-3 text-sm disabled:opacity-40",children:a("android.recordingSave")}),s.jsx("button",{type:"button",disabled:h,onClick:()=>{R()},className:"min-h-10 rounded-lg px-3 text-sm text-muted-foreground disabled:opacity-40",children:a("android.recordingDiscard")})]})]})}),document.body)}const H0="android-mirror",M0=H0,M6="termdock:android:quality:v1",Tm=176,yF=204,Tl=1,Gh=8,jb=[1,1.25,1.5,2,2.5,3,4,6,8],vF=e=>Math.max(Tl,Math.min(Gh,e));function wF(e){return`${Number.isInteger(e)?e:e.toFixed(1)}×`}function Ah(e){const t=e.parentElement;if(!t)return null;const r=t.getBoundingClientRect(),n=getComputedStyle(t),a=parseFloat(n.paddingLeft)||0,c=parseFloat(n.paddingTop)||0,l=t.clientWidth-a-(parseFloat(n.paddingRight)||0),h=t.clientHeight-c-(parseFloat(n.paddingBottom)||0);return{cx:r.left+t.clientLeft+a+l/2,cy:r.top+t.clientTop+c+h/2,width:l,height:h,contentWidth:e.offsetWidth,contentHeight:e.offsetHeight}}function AF(e,t){try{e.setPointerCapture?.(t)}catch{}}function Db(e,t){try{e.releasePointerCapture?.(t)}catch{}}const Bb=e=>typeof requestAnimationFrame=="function"?requestAnimationFrame(e):window.setTimeout(e,16),Th=e=>{typeof cancelAnimationFrame=="function"?cancelAnimationFrame(e):window.clearTimeout(e)},Cm={auto:"android.qualityAuto",low:"android.qualityLow",medium:"android.qualityMedium",high:"android.qualityHigh",custom:"android.qualityCustom"},TF=()=>{try{const e=localStorage.getItem(M6);return e?w1(JSON.parse(e)):yd}catch{return yd}},j0=e=>{try{localStorage.setItem(M6,JSON.stringify(e))}catch{}};function CF({sessionId:e,dockOnly:t=!1,onInsertPrompt:r,onInsertFile:n,onRecordingComplete:a,onCloseTab:c}){const{t:l}=zr(),h=Tb(N=>N.overlay),p=Tb(N=>N.setOverlay),m=b.useRef(null),x=b.useRef(null),y=b.useRef(null),w=b.useMemo(TF,[]),v=b.useRef(w),k=b.useRef(null),L=b.useRef(null),[E,R]=b.useState(4e6),B=b.useRef(null),W=b.useRef(new Map),F=b.useRef(null),U=b.useRef(!1),[V,Z]=b.useState(Tl),le=b.useRef(V),xe=b.useRef({x:0,y:0}),fe=b.useRef(null),te=b.useRef(0),ke=b.useRef(0),$e=b.useRef(null),Y=b.useRef(0),[Ae,lt]=b.useState(null),[Ce,ye]=b.useState(null),[_e,je]=b.useState(!0),[re,Pe]=b.useState(""),[Se,Ee]=b.useState(w.id),[Be,Ne]=b.useState([]),[oe,He]=b.useState(null),[rt,mt]=b.useState(""),[de,Ye]=b.useState(!0),[st,Ie]=b.useState({maxSize:w.maxSize,bitRate:w.bitRate,maxFps:w.maxFps}),[We,Te]=b.useState("idle"),[H,ae]=b.useState(null),[be,Ze]=b.useState(null),[Je,Tt]=b.useState({fps:0,kbps:0,width:0,height:0,received:0,decoded:0,controls:0,last:""}),[Wt,Mt]=b.useState(null),[vt,Yt]=b.useState(null),[Qt,Xt]=b.useState(!1),[Ut,Lt]=b.useState([]),[pe,Ge]=b.useState(null),[ft,q]=b.useState([]),[at,Vt]=b.useState(!1),Ve=b.useRef(null),De=b.useRef(0),er=b.useRef([]),[et,Ct]=b.useState(!1),[Nt,gt]=b.useState(""),[bt,It]=b.useState(!1),[yt,pr]=b.useState(!1),[nr,_r]=b.useState(""),[un,Ir]=b.useState(null),[me,Gr]=b.useState(null),[it,dt]=b.useState(!1),[sr,An]=b.useState(0),on=b.useRef(null),[Me,nt]=b.useState(!1),wt=b.useRef(!1),Mr=b.useRef(new Set),rn=b.useRef(null),Er=b.useRef(null),ne=b.useRef(!1),[ht,zt]=b.useState(!1),Pt=b.useRef(a);Pt.current=a;const[Cr,gr]=b.useState(!1),[Hr,En]=b.useState(null),dr=b.useRef(null),Tn=b.useRef(null),hn=QO(N=>N.activeSessionId??N.sessions.keys().next().value??null),Sn=e??hn,ir=ns(N=>!!N.docks[M0]),mn=ns(N=>N.hosts[M0]),Qr=ns(N=>N.setDock),Vr=b.useCallback(async()=>{je(!0);try{const N=await FO();lt(N),ye(null)}catch(N){ye(N instanceof Error?N.message:"ADB_UNAVAILABLE")}finally{je(!1)}},[]);b.useEffect(()=>{Vr()},[Vr]);const Wr=Ae?.devices??[],fs=Wr.find(N=>N.serial===re)??null,Dr=!!(Ce&&/ADB_NOT_FOUND|ADB_UNAVAILABLE/i.test(Ce)),Pn=!!(Ae?.adbAvailable&&!Ae.scrcpyVersion),Sr=b.useCallback(()=>{const N=B.current,$=[...W.current.keys()];B.current=null,W.current.clear(),F.current=null,U.current=!1,Ve.current=null,Th(te.current),te.current=0,N&&x.current?.pointerCancel(N.x,N.y,N.type);const ee=m.current;if(ee)for(const se of $)Db(ee,se);Ge(null),Vt(!1),q([]),Z(le.current)},[]);b.useEffect(()=>{const N=se=>{W.current.has(se.pointerId)&&(se.type==="pointercancel"||se.target!==m.current)&&Sr()},$=()=>Sr(),ee=()=>{document.hidden&&Sr()};return window.addEventListener("pointerup",N,!0),window.addEventListener("pointercancel",N,!0),window.addEventListener("blur",$),document.addEventListener("visibilitychange",ee),()=>{window.removeEventListener("pointerup",N,!0),window.removeEventListener("pointercancel",N,!0),window.removeEventListener("blur",$),document.removeEventListener("visibilitychange",ee),Sr()}},[Sr]);const Kr=b.useCallback(()=>{Sr(),x.current?.disconnect(),x.current=null,Te("idle"),ae(null),Ze(null)},[Sr]),nn=b.useCallback((N,$=!1)=>{const ee=m.current;if(!ee||!N)return;Sr(),x.current?.disconnect(),ae(null),!$&&y.current!==N&&Ze(null),y.current=N,Yt(null),Mt(null);const se=new pF(ee,{onBitrateSupport:(ze,xt)=>{x.current!==se||v.current.id!=="auto"||Mt(ze?null:xt??"BITRATE_REASON_UNAVAILABLE")},onState:(ze,xt)=>{x.current===se&&(Te(ze),ae(xt??null))},onHeader:ze=>{x.current===se&&Ze(ze)},onStats:ze=>{x.current===se&&Tt(ze)},onWarning:ze=>{x.current===se&&Yt(ze)}});x.current=se;let Qe=v.current;Qe.id==="auto"?(k.current?.serial!==N&&(k.current={serial:N,policy:new OO}),k.current.policy.connected(performance.now()),Qe=k.current.policy.quality,R(Qe.bitRate)):k.current=null,L.current=Qe,se.connect(N,Qe)},[Sr]);b.useEffect(()=>{if(Se!=="auto"||v.current.id!=="auto"||We!=="streaming"||!Je.adaptation||document.hidden)return;const N=k.current,$=x.current;if(!N||N.serial!==re||!$?.canSetBitrate)return;const ee=m.current,se=ee?Math.max(ee.clientWidth,ee.clientHeight)*(window.devicePixelRatio||1)*le.current:1600,Qe=N.policy.sample(Je.adaptation,performance.now(),se||1600);Qe&&$.setBitrate(Qe.bitRate).then(ze=>{ze&&x.current===$&&(L.current=Qe,R(Qe.bitRate))})},[Je,Se,We,re,nn]);const Or=b.useCallback(N=>{const $={...N.quality?{quality:{id:N.quality.id,maxSize:N.quality.maxSize,bitRate:N.quality.bitRate,maxFps:N.quality.maxFps}}:{},...N.activePresetId!==void 0?{activePresetId:N.activePresetId}:{},...N.presets!==void 0?{presets:N.presets}:{},...N.docked!==void 0?{docked:N.docked}:{},...N.deviceSerial!==void 0?{deviceSerial:N.deviceSerial}:{}};wa({androidPanel:$}).catch(()=>{})},[]);b.useEffect(()=>{let N=!1;return nc().then($=>{if(N)return;const ee=$.androidPanel;if(ee?.quality){const se=w1(ee.quality);v.current=se,Ee(se.id),Ie({maxSize:se.maxSize,bitRate:se.bitRate,maxFps:se.maxFps}),j0(se)}Ne(ee?.presets??[]),He(ee?.activePresetId??null),ee?.deviceSerial&&($e.current=ee.deviceSerial,Pe(ee.deviceSerial))}).catch(()=>{}),()=>{N=!0}},[]);const ks=b.useCallback(N=>{const $=++De.current;Lt(se=>[...se,{id:$,left:N.left,top:N.top}]);const ee=window.setTimeout(()=>{Lt(se=>se.filter(Qe=>Qe.id!==$)),er.current=er.current.filter(se=>se!==ee)},300);er.current.push(ee)},[]),Pr=b.useCallback((N,$)=>{const ee=x.current,se=L.current;ee?.supportsLiveBitrate&&y.current===N&&se&&se.maxSize===$.maxSize&&se.maxFps===$.maxFps?ee.setBitrate($.bitRate).then(Qe=>{x.current===ee&&(Qe?(L.current=$,Mt(null)):Mt(ee.lastBitrateFailure??"BITRATE_REASON_UNAVAILABLE"))}):nn(N)},[nn,l]),Xr=b.useCallback(N=>{if(k.current=null,N.startsWith("user:")){const ee=Be.find(Qe=>Qe.id===N.slice(5));if(!ee)return;const se={id:"custom",maxSize:ee.maxSize,bitRate:ee.bitRate,maxFps:ee.maxFps};v.current=se,Ee("custom"),He(ee.id),Ie({maxSize:ee.maxSize,bitRate:ee.bitRate,maxFps:ee.maxFps}),Ye(!0),j0(se),Or({quality:se,activePresetId:ee.id}),re&&nn(re);return}if(N==="custom"){const ee=v.current;Ee("custom"),He(null),Ie({maxSize:ee.maxSize,bitRate:ee.bitRate,maxFps:ee.maxFps}),Ye(!0);return}const $=N==="auto"?w1({id:"auto"}):Lf.find(ee=>ee.id===N)??yd;v.current=$,Ee($.id),He(null),j0($),Or({quality:$,activePresetId:null}),re&&nn(re)},[nn,re,Be,Or]),fn=b.useCallback(()=>{const N={id:"custom",maxSize:st.maxSize,bitRate:st.bitRate,maxFps:st.maxFps};v.current=N,j0(N),Or({quality:N,activePresetId:null}),Ee("custom"),He(null),re&&Pr(re,N)},[Pr,re,st,Or]),K=b.useCallback(()=>{const N=rt.trim();if(!N)return;const $=`p${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,ee={id:$,name:N,maxSize:st.maxSize,bitRate:st.bitRate,maxFps:st.maxFps},se=[...Be.filter(ze=>ze.name!==N),ee].slice(-12),Qe={id:"custom",maxSize:st.maxSize,bitRate:st.bitRate,maxFps:st.maxFps};Ne(se),mt(""),He($),Ee("custom"),v.current=Qe,j0(Qe),Or({quality:Qe,activePresetId:$,presets:se}),re&&Pr(re,Qe)},[rt,st,Be,re,Pr,Or]),Ue=b.useCallback(()=>{if(!oe)return;const N=Be.filter($=>$.id!==oe);Ne(N),He(null),Or({activePresetId:null,presets:N})},[oe,Be,Or]);b.useEffect(()=>()=>{x.current?.disconnect(),x.current=null;for(const N of er.current)window.clearTimeout(N);er.current=[]},[]),b.useEffect(()=>{if(h==="off")return;const N=$=>{$.key==="Escape"&&p("off")};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[h,p]),b.useEffect(()=>{const N=Wr.filter(ee=>ee.state==="device");if(re||N.length!==1)return;const $=N[0].serial;$e.current!==$&&($e.current=$,Pe($))},[Wr,re]),b.useEffect(()=>{re&&nn(re)},[re,nn]),b.useEffect(()=>{if(We==="streaming"){Y.current=0,Xt(!1);return}if(We!=="error"||!re||!_F(H??""))return;const N=Math.min(8e3,700*2**Y.current);Y.current+=1,Xt(!0);const $=window.setTimeout(()=>{Xt(!1),nn(re)},N);return()=>window.clearTimeout($)},[We,H,re,nn]);const Et=b.useCallback((N,$,ee)=>{const se=m.current,Qe=ee??(se?Ah(se):null);return!se||!Qe?{x:0,y:0}:N6(N,$,Qe)},[]),kt=b.useCallback(()=>{const N=m.current;if(!N)return;const{x:$,y:ee}=xe.current,se=le.current,Qe=se===Tl&&$===0&&ee===0?"":`translate3d(${$}px, ${ee}px, 0) scale(${se})`;N.style.transform!==Qe&&(N.style.transform=Qe);const ze=fe.current;ze&&(ze.textContent=se>Tl?wF(se):"")},[]),tr=b.useCallback((N,$,ee=!0)=>{const se=m.current,Qe=le.current,ze=vF(N);if(!se||ze===Qe)return;const xt=Ah(se);if(!xt)return;const _t=$??{x:xt.cx,y:xt.cy},Fr=Rb({zoom:Qe,pan:xe.current},xt,_t,_t,ze/Qe);le.current=Fr.zoom,xe.current=Fr.pan,ee&&kt()},[kt]),Br=b.useCallback(()=>{const N=le.current;Z($=>$<=Tl+.01==N<=Tl+.01&&$>=Gh-.01==N>=Gh-.01?$:N)},[]);b.useEffect(()=>()=>{Th(te.current),Th(ke.current)},[]);const cr=()=>{let N=0,$=0;for(const se of W.current.values())N+=se.x,$+=se.y;const ee=W.current.size;return ee?{x:N/ee,y:$/ee}:null},_n=()=>{const[N,$]=Array.from(W.current.values());return N&&$?Math.hypot(N.x-$.x,N.y-$.y):0},Ls=()=>{const N=cr(),$=m.current?Ah(m.current):null;!N||!$||(F.current={startCentroid:N,startDistance:_n(),box:$})},Zn=b.useCallback(()=>{const N=F.current,$=cr();if(!N||!$)return;const ee=_n(),se=N.startDistance>0&&ee>0?ee/N.startDistance:1,Qe=Rb({zoom:le.current,pan:xe.current},N.box,N.startCentroid,$,se);le.current=Qe.zoom,xe.current=Qe.pan,N.startCentroid=$,N.startDistance=ee},[]),sn=b.useCallback(()=>{te.current||(te.current=Bb(()=>{te.current=0,Zn(),kt()}))},[Zn,kt]),ln=b.useCallback(()=>{te.current&&(Th(te.current),te.current=0,Zn(),kt())},[Zn,kt]);b.useEffect(()=>{const N=m.current;if(!N)return;const $=N.parentElement;if(!$)return;const ee=Qe=>{if(Qe.ctrlKey||Qe.metaKey){if(Qe.preventDefault(),!Qe.deltaY||F.current)return;const _t=Qe.deltaMode===1?16:Qe.deltaMode===2?N.parentElement?.clientHeight||600:1,Fr=Math.max(-600,Math.min(600,Qe.deltaY*_t));tr(le.current*Math.exp(-Fr*.002),{x:Qe.clientX,y:Qe.clientY},!1),ke.current||(ke.current=Bb(()=>{ke.current=0,kt(),Br()}));return}const ze=x.current;if(!ze||Qe.target!==N)return;Qe.preventDefault();const xt=Sh(N,Qe.clientX,Qe.clientY);ze.scroll(xt.x,xt.y,Qe.deltaX,Qe.deltaY)},se=Qe=>Qe.preventDefault();return $.addEventListener("wheel",ee,{passive:!1}),$.addEventListener("gesturestart",se,{passive:!1}),$.addEventListener("gesturechange",se,{passive:!1}),()=>{$.removeEventListener("wheel",ee),$.removeEventListener("gesturestart",se),$.removeEventListener("gesturechange",se)}},[tr,kt,Br]),b.useEffect(()=>{const N=m.current,$=N?.parentElement;if(!N||!$||typeof ResizeObserver>"u")return;const ee=new ResizeObserver(()=>{F.current&&(F.current.box=Ah(N));const se=Et(xe.current,le.current);se.x===xe.current.x&&se.y===xe.current.y||(xe.current=se,kt())});return ee.observe(N),ee.observe($),()=>ee.disconnect()},[Et,kt]),b.useLayoutEffect(()=>{kt()});const kr=N=>{const $=x.current,ee=m.current;if(!$||!ee)return;if(N.pointerType==="mouse"&&N.button!==0){N.preventDefault(),N.button===2?$.back():N.button===1&&$.home();return}N.preventDefault(),ee.closest(".android-mirror-panel")?.focus({preventScroll:!0}),kt(),Br(),ln(),AF(ee,N.pointerId),W.current.set(N.pointerId,{x:N.clientX,y:N.clientY});const se=N.pointerType==="mouse"&&N.altKey;if(W.current.size>=2||se){const xt=B.current;xt&&($.pointerCancel(xt.x,xt.y,xt.type),B.current=null,Ve.current=null,Ge(null),Vt(!1),q([])),U.current=!0,Ls();return}if(U.current)return;const Qe=Sh(ee,N.clientX,N.clientY);B.current={id:N.pointerId,type:N.pointerType,x:Qe.x,y:Qe.y},$.pointerDown(Qe.x,Qe.y,N.pointerType);const ze=$b(ee,N.clientX,N.clientY);ze&&(Ve.current={left:ze.left,top:ze.top},q([]),Vt(!1),Ge(ze))},$r=N=>{const $=x.current,ee=m.current;if(!ee||!W.current.has(N.pointerId))return;if(N.pointerType==="mouse"){const _t=ee.getBoundingClientRect(),Fr=ee.parentElement?.getBoundingClientRect()??_t;if(!(N.buttons&1)||N.clientX<Math.max(_t.left,Fr.left)||N.clientX>=Math.min(_t.right,Fr.right)||N.clientY<Math.max(_t.top,Fr.top)||N.clientY>=Math.min(_t.bottom,Fr.bottom)){Sr();return}}if(N.preventDefault(),W.current.set(N.pointerId,{x:N.clientX,y:N.clientY}),F.current){sn();return}const se=B.current;if(!$||!se||se.id!==N.pointerId)return;const Qe=Sh(ee,N.clientX,N.clientY);se.x=Qe.x,se.y=Qe.y,$.pointerMove(Qe.x,Qe.y,se.type);const ze=$b(ee,N.clientX,N.clientY),xt=Ve.current;!ze||!xt||(Ge(ze),Math.hypot(ze.left-xt.left,ze.top-xt.top)>=6&&(Vt(!0),q(_t=>{const Fr=_t[_t.length-1];if(Fr&&Math.hypot(ze.left-Fr.x,ze.top-Fr.y)<4)return _t;const jt=[..._t,{x:ze.left,y:ze.top}];return jt.length>12?jt.slice(jt.length-12):jt})))},Gn=N=>{const $=x.current,ee=m.current;if(!ee||!W.current.has(N.pointerId))return;if(ln(),W.current.delete(N.pointerId),Db(ee,N.pointerId),W.current.size===0&&(U.current=!1),F.current){W.current.size===0?(F.current=null,Z(le.current)):Ls();return}const se=B.current;if(!se||se.id!==N.pointerId)return;const Qe=Sh(ee,N.clientX,N.clientY);$?.pointerUp(Qe.x,Qe.y,se.type),pe&&ks(pe),Ge(null),Vt(!1),window.setTimeout(()=>q([]),200),B.current=null,Ve.current=null},Vn=N=>{if(Cr||et||yt)return;const $=x.current;$&&(N.key==="Backspace"?(N.preventDefault(),$.key(67)):N.key==="Escape"?(N.preventDefault(),$.back()):N.key==="Enter"&&(N.preventDefault(),$.key(66)))},dn=async()=>{const N=Nt.trim();if(N){It(!0);try{const $=await $O(N);gt(""),Ct(!1),await Vr(),Pe($.serial)}catch($){ye($ instanceof Error?$.message:"ADB_CONNECT_FAILED")}finally{It(!1)}}},Kn=()=>{const N=x.current,$=nr;!N||!$||(N.sendText($),_r(""))},Lr=b.useCallback(N=>{Ir(N),Er.current!==null&&window.clearTimeout(Er.current),Er.current=window.setTimeout(()=>{Er.current=null,Ir(null)},2500)},[]),Nr=b.useCallback(N=>{const $=le.current,ee=N==="in"?jb.find(se=>se>$+.01):[...jb].reverse().find(se=>se<$-.01);ee!==void 0&&($<=Tl&&ee>Tl&&Lr(l("android.zoomPanHint")),ln(),tr(ee),Z(ee))},[tr,ln,Lr,l]),xr=N=>{Promise.resolve().then(()=>r?.(N)).catch($=>{Gr($ instanceof Error?$.message:String($))})},os=b.useCallback(async(N,$)=>{try{if(!n)throw new Error(l("android.captureUnavailable"));await n(N),Lr($)}catch(ee){Gr(l("android.captureFailed")+(ee instanceof Error?`:${ee.message}`:""))}},[n,Lr,l]),Hn=async()=>{const N=m.current;if(!(!N||ne.current)){ne.current=!0,zt(!0),Gr(null);try{const $=await xF(N);await os($,l("android.captureInserted"))}catch($){Gr($ instanceof Error?$.message:String($))}finally{ne.current=!1,zt(!1)}}},Nn=b.useCallback(N=>{(N.status==="ready"||N.status==="error")&&Pt.current&&!Mr.current.has(N.id)&&(Mr.current.add(N.id),Pt.current?.(N))},[]),Rn=b.useCallback(async N=>{const $=on.current;if(!(!$||wt.current)){wt.current=!0,nt(!0),Gr(null);try{const ee=await WO($.id);on.current=null,dt(!1),Nn(ee)}catch(ee){Gr(ee instanceof Error?ee.message:String(ee))}finally{wt.current=!1,nt(!1)}}},[Nn]),ps=async()=>{if(!(!re||wt.current||on.current)){wt.current=!0,nt(!0),Gr(null);try{const N=await HO(re);N.status==="recording"||N.status==="starting"||N.status==="stopping"?(on.current=N,dt(!0),An(Math.max(0,Date.now()-N.startedAt))):Nn(N)}catch(N){Gr(N instanceof Error?N.message:String(N))}finally{wt.current=!1,nt(!1)}}};b.useEffect(()=>{let N=!1,$=!1;on.current=null,dt(!1);const ee=async()=>{if(!(!re||$||wt.current)){$=!0;try{const{recordings:Qe}=await zO(re);if(N||wt.current)return;const ze=Qe.find(xt=>["starting","recording","stopping"].includes(xt.status));on.current=ze??null,dt(!!ze);for(const xt of Qe)Nn(xt)}catch{}finally{$=!1}}};ee();const se=window.setInterval(()=>{ee()},2e3);return rn.current=window.setInterval(()=>{on.current&&An(Math.max(0,Date.now()-on.current.startedAt))},500),()=>{N=!0,window.clearInterval(se),rn.current!==null&&window.clearInterval(rn.current)}},[re,Nn]),b.useEffect(()=>{if(!Cr)return;const N=()=>gr(!1),$=se=>{const Qe=se.target;Qe instanceof Node&&(dr.current?.contains(Qe)||Tn.current?.contains(Qe)||N())},ee=se=>{se.key==="Escape"&&(se.preventDefault(),se.stopPropagation(),N())};return document.addEventListener("pointerdown",$,!0),document.addEventListener("keydown",ee,!0),window.addEventListener("resize",N),()=>{document.removeEventListener("pointerdown",$,!0),document.removeEventListener("keydown",ee,!0),window.removeEventListener("resize",N)}},[Cr]),b.useEffect(()=>()=>{Er.current!==null&&window.clearTimeout(Er.current)},[]);const G=We==="streaming",Le=ir,Ke=Le?"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded hover:bg-surface-2 disabled:opacity-40":"rounded p-1.5 hover:bg-surface-2 disabled:opacity-40",ct=fs?(fs.model||fs.serial)+Ub(fs,l):Wr.length?l("android.selectDevice"):l("android.noDevices"),At=(oe?Be.find(N=>N.id===oe):null)?.name??(Se==="auto"?`${l("android.qualityAuto")} · ${E/1e6} Mbps`:l(Cm[Se])),Rt=Le?"relative flex h-5 min-w-0 items-center rounded bg-surface-2 focus-within:ring-1 focus-within:ring-primary/50":"relative flex h-7 min-w-0 items-center rounded bg-surface-2 focus-within:ring-1 focus-within:ring-primary/50",Dt=Le?"pointer-events-none block min-w-0 truncate px-1 text-[10px] leading-none text-foreground":"pointer-events-none block min-w-0 truncate px-2 text-[11px] leading-none text-foreground",ot="absolute inset-0 h-full w-full cursor-pointer opacity-0",Ot=()=>{const N=dr.current?.getBoundingClientRect();N&&En({left:Math.max(8,Math.min(N.right-Tm,window.innerWidth-Tm-8)),top:Math.min(N.bottom+4,Math.max(8,window.innerHeight-yF-8))}),gr(!0)},hr=()=>{if(ir){Qr(M0,null),Or({docked:null});return}if(!Sn)return;const N={sessionId:Sn,side:"right"};Qr(M0,N),Or({docked:N})},Zt=et||ir||h!=="off",z=s.jsxs("div",{className:"android-mirror-panel flex h-full min-h-0 min-w-0 flex-col bg-surface text-foreground","data-sidebar-gesture-ignore":"true",onKeyDown:Vn,tabIndex:-1,children:[s.jsxs("div",{"data-panel-drag-title":ir?"true":void 0,className:Le?"flex h-6 min-h-6 shrink-0 flex-nowrap items-center gap-1 overflow-hidden border-b border-border/15 bg-[var(--chrome-bg)] px-1.5 cursor-grab select-none active:cursor-grabbing":"flex flex-wrap items-center gap-1.5 border-b border-border px-2 py-2",children:[ir&&s.jsx("span",{"data-panel-drag-title":"true",role:"button","aria-label":l("android.splitDrag"),title:l("android.splitDrag"),className:"flex h-4 w-4 shrink-0 cursor-grab items-center justify-center rounded text-muted-foreground hover:text-foreground active:cursor-grabbing",children:s.jsx(If,{size:12})}),s.jsx(Yw,{size:Le?12:14,className:"shrink-0 text-muted-foreground"}),s.jsxs("div",{className:`${Rt} flex-1`,children:[s.jsx("span",{"aria-hidden":"true",className:`${Dt} w-full`,children:ct}),s.jsxs("select",{value:re,onChange:N=>{const $=N.target.value;Pe($),$e.current=$,$&&Or({deviceSerial:$})},className:ot,"aria-label":l("android.device"),children:[s.jsx("option",{value:"",children:Wr.length?l("android.selectDevice"):l("android.noDevices")}),Wr.map(N=>s.jsx("option",{value:N.serial,children:(N.model||N.serial)+Ub(N,l)},N.serial))]})]}),s.jsxs("div",{className:`${Rt} max-w-[45%] shrink-0`,children:[s.jsx("span",{"aria-hidden":"true",className:Dt,children:At}),s.jsxs("select",{value:oe?`user:${oe}`:Se,onChange:N=>Xr(N.target.value),className:ot,title:l(Se==="auto"?"android.qualityAutoHint":"android.quality"),"aria-label":l("android.quality"),children:[s.jsxs("option",{value:"auto",children:[l("android.qualityAuto"),Se==="auto"?` · ${E/1e6} Mbps`:""]}),Lf.map(N=>s.jsx("option",{value:N.id,children:l(Cm[N.id])},N.id)),Be.map(N=>s.jsx("option",{value:`user:${N.id}`,children:N.name},N.id)),s.jsx("option",{value:"custom",children:l(Cm.custom)})]})]}),s.jsx("button",{type:"button",onClick:()=>{Vr()},className:`${Ke} text-muted-foreground`,title:l("android.refresh"),children:_e?s.jsx(In,{size:13,className:"animate-spin"}):s.jsx(yn,{size:13})}),G?s.jsx("button",{type:"button",onClick:Kr,className:`${Ke} text-destructive`,title:l("android.disconnect"),children:s.jsx(_3,{size:13})}):s.jsx("button",{type:"button",onClick:()=>re&&nn(re),disabled:!re,className:`${Ke} text-primary`,title:l("android.connect"),children:s.jsx($T,{size:13})}),(G||it)&&s.jsx("button",{type:"button",onClick:()=>{Hn()},disabled:!n||ht,className:`${Ke} text-muted-foreground`,title:l(n?"android.screenshot":"android.captureUnavailable"),"aria-label":l("android.screenshot"),children:ht?s.jsx(In,{size:Le?12:13,className:"animate-spin"}):s.jsx(wA,{size:Le?12:13})}),(G||it)&&s.jsx("button",{type:"button",onClick:()=>{it?Rn("manual"):ps()},disabled:Me||!it&&!a,className:`${Ke} ${it?"text-destructive":"text-muted-foreground"}`,title:l(it?"android.recordingStop":a?"android.recordingStart":"android.captureUnavailable"),"aria-label":l(it?"android.recordingStop":"android.recordingStart"),children:Me?s.jsx(In,{className:"animate-spin",size:13}):it?s.jsx(S3,{size:Le?10:11,fill:"currentColor"}):s.jsx(k3,{size:Le?12:13})}),s.jsx("button",{ref:dr,type:"button",onClick:()=>Cr?gr(!1):Ot(),"aria-haspopup":"menu","aria-expanded":Cr,className:`${Ke} ${Zt?"text-primary":"text-muted-foreground"}`,title:l("android.more"),"aria-label":l("android.more"),children:s.jsx(Qo,{size:Le?13:14})}),c&&!t&&s.jsx("button",{type:"button",onClick:()=>{gr(!1),p("off"),c()},className:`${Ke} text-muted-foreground hover:bg-destructive/20 hover:text-destructive`,title:l("android.closeTab"),"aria-label":l("android.closeTab"),children:s.jsx(Qn,{size:14})})]}),Cr&&Hr&&Li.createPortal(s.jsxs("div",{ref:Tn,role:"menu","aria-label":l("android.more"),style:{left:Hr.left,top:Hr.top,width:Tm},className:"fixed z-popover overflow-hidden rounded-md border border-border bg-surface-elevated py-1 text-[11px] shadow-lg",children:[s.jsx(Ch,{icon:s.jsx(ul,{size:13}),label:l("android.addDevice"),active:et,onSelect:()=>{Ct(N=>!N),gr(!1)}}),s.jsx(Ch,{icon:ir?s.jsx(Qn,{size:13}):s.jsx(_l,{size:13}),label:l(ir?"android.splitClose":"android.splitOpen"),active:ir,disabled:!ir&&!Sn,onSelect:()=>{hr(),gr(!1)}}),s.jsx(Ch,{icon:h==="window"?s.jsx(fT,{size:13}):s.jsx(cT,{size:13}),label:l(h==="window"?"android.exitFullscreen":"android.fullscreen"),active:h==="window",onSelect:()=>{p(h==="window"?"off":"window"),gr(!1)}}),!t&&s.jsx(Ch,{icon:h==="sidebar"?s.jsx(TT,{size:13}):s.jsx(kT,{size:13}),label:l(h==="sidebar"?"android.exitFullscreen":"android.fillSidebar"),active:h==="sidebar",onSelect:()=>{p(h==="sidebar"?"off":"sidebar"),gr(!1)}}),be&&s.jsxs("div",{className:"mt-1 border-t border-border px-3 py-2 text-[10px] leading-4 tabular-nums text-muted-foreground",children:[s.jsx("div",{className:"truncate",children:`${Je.fps} fps · ${Je.kbps} kbps`}),s.jsx("div",{className:"truncate",children:`${Je.width}×${Je.height}`})]})]}),document.body),(Se==="custom"||oe)&&s.jsxs("div",{className:"border-b border-border bg-surface-2/40 px-2 py-2 text-[11px]",children:[s.jsxs("button",{type:"button",onClick:()=>Ye(N=>!N),"aria-expanded":de,className:"flex w-full items-center gap-1 rounded text-muted-foreground hover:text-foreground",children:[s.jsx(ul,{size:12,className:`transition-transform ${de?"":"-rotate-90"}`}),s.jsxs("span",{children:[l("android.quality"),oe?` · ${Be.find(N=>N.id===oe)?.name??""}`:""]})]}),de&&s.jsxs("div",{className:"mt-2 grid gap-2",children:[s.jsx(Fb,{label:l("android.qualityResolution"),display:`${st.maxSize}px`,min:360,max:2160,step:8,value:st.maxSize,onChange:N=>Ie($=>({...$,maxSize:N}))}),s.jsx(Fb,{label:l("android.qualityBitRate"),display:`${(st.bitRate/1e6).toFixed(1)} Mbps`,min:.5,max:20,step:.5,value:st.bitRate/1e6,onChange:N=>Ie($=>({...$,bitRate:Math.round(N*1e6)}))}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-14 shrink-0 text-muted-foreground",children:l("android.qualityFrameRate")}),s.jsxs("div",{className:"flex gap-1",children:[[15,30,60].map(N=>s.jsx("button",{type:"button",onClick:()=>Ie($=>({...$,maxFps:N})),className:`rounded px-2 py-0.5 ${st.maxFps===N?"bg-surface-elevated text-primary":"text-muted-foreground hover:bg-surface-2"}`,children:N},N)),s.jsx("button",{type:"button",onClick:()=>Ie(N=>({...N,maxFps:0})),className:`rounded px-2 py-0.5 ${st.maxFps===0?"bg-surface-elevated text-primary":"text-muted-foreground hover:bg-surface-2"}`,children:l("android.qualityAuto")})]}),s.jsx("button",{type:"button",onClick:fn,disabled:!re,className:"ml-auto rounded bg-primary/15 px-2 py-1 text-primary disabled:opacity-40",children:l("android.qualityApply")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{value:rt,onChange:N=>mt(N.target.value),onKeyDown:N=>{N.key==="Enter"&&!N.nativeEvent.isComposing&&K()},placeholder:l("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"}),s.jsx("button",{type:"button",onClick:K,disabled:!rt.trim(),className:"shrink-0 rounded bg-surface-2 px-2 py-1 text-primary disabled:opacity-40",children:l("android.presetSave")}),oe&&s.jsx("button",{type:"button",onClick:Ue,className:"shrink-0 rounded px-2 py-1 text-destructive hover:bg-surface-2",children:l("android.presetDelete")})]})]})]}),et&&s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border px-2 py-2",children:[s.jsx("input",{value:Nt,onChange:N=>gt(N.target.value),onKeyDown:N=>{N.key==="Enter"&&dn()},placeholder:l("android.addressPlaceholder"),className:"min-w-0 flex-1 rounded bg-surface-2 px-2 py-1 text-[11px] outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"button",onClick:()=>{dn()},disabled:bt,className:"rounded bg-surface-2 px-2 py-1 text-[11px] text-primary disabled:opacity-40",children:bt?s.jsx(In,{size:12,className:"animate-spin"}):l("android.connect")})]}),Dr&&s.jsxs("div",{className:"flex items-start gap-2 border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:[s.jsx("span",{className:"min-w-0 flex-1",children:l("android.adbUnavailable")}),s.jsx(Pb,{label:l("android.insertFixPrompt"),onClick:()=>xr(Ob("adb",Ce??"")),enabled:!!r})]}),!Dr&&Pn&&s.jsxs("div",{className:"flex items-start gap-2 border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:[s.jsx("span",{className:"min-w-0 flex-1",children:l("android.scrcpyUnavailable")}),s.jsx(Pb,{label:l("android.insertFixPrompt"),onClick:()=>xr(Ob("scrcpy","")),enabled:!!r})]}),fs&&fs.state!=="device"&&s.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:kF(fs,l)}),Ce&&!Dr&&s.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:Cb(Ce)}),Wt&&s.jsxs("details",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:[s.jsxs("summary",{className:"cursor-pointer",children:[l("android.qualityAutoUnavailable")," ",l(Wt.startsWith("SCRCPY_VERSION")?"android.qualityAutoVersionError":Wt.startsWith("SCRCPY_BUILD")?"android.qualityAutoBuildError":/EXTENSION|SERVER_READ|PUSH/.test(Wt.split(":")[0])?"android.qualityAutoExtensionError":/TIMEOUT/.test(Wt.split(":")[0])?"android.qualityAutoTimeoutError":/ENCODER_REJECTED/.test(Wt.split(":")[0])?"android.qualityAutoEncoderError":/CHANNEL|TUNNEL|LISTEN|PROTOCOL|CONNECTION/.test(Wt.split(":")[0])?"android.qualityAutoChannelError":"android.qualityAutoUnknownError")]}),s.jsx("pre",{className:"mt-1 select-text whitespace-pre-wrap break-all text-[10px]",children:Wt})]}),vt&&s.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:vt}),me&&s.jsx("div",{role:"alert",className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:me}),s.jsxs("div",{className:"relative flex min-h-0 min-w-0 flex-1 touch-none items-center justify-center overflow-hidden bg-[var(--chrome-bg)] p-1",children:[s.jsx("canvas",{ref:m,className:"max-h-full max-w-full touch-none select-none rounded",style:{display:G||be?"block":"none",transformOrigin:"center",transition:"none"},onPointerDown:kr,onPointerMove:$r,onPointerUp:Gn,onPointerCancel:()=>Sr(),onLostPointerCapture:N=>{W.current.has(N.pointerId)&&Sr()},onPointerLeave:N=>{W.current.has(N.pointerId)&&!N.currentTarget.hasPointerCapture?.(N.pointerId)&&Sr()},onContextMenu:N=>N.preventDefault()}),pe&&s.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:pe.left,top:pe.top}}),ft.length>1&&s.jsx("svg",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 h-full w-full",style:{opacity:at?1:0,transition:"opacity 160ms linear"},children:ft.slice(1).map((N,$)=>{const ee=ft[$],se=($+1)/(ft.length-1);return s.jsx("line",{x1:ee.x,y1:ee.y,x2:N.x,y2:N.y,stroke:"var(--primary)",strokeWidth:1+1.6*se,strokeLinecap:"round",opacity:.06+.45*se},$)})}),Ut.map(N=>s.jsx("span",{"aria-hidden":"true",className:"termdock-tap-fade pointer-events-none absolute h-4 w-4 rounded-full bg-primary",style:{left:N.left,top:N.top}},N.id)),!G&&s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 text-center text-[11px] text-muted-foreground",children:[We==="connecting"&&s.jsxs(s.Fragment,{children:[s.jsx(In,{size:18,className:"animate-spin"}),s.jsx("span",{children:l("android.connecting")})]}),We==="error"&&s.jsxs(s.Fragment,{children:[s.jsx(Eu,{size:14,className:"text-destructive"}),s.jsx("span",{className:"max-w-[80%] text-destructive",children:Qt?l("android.reconnecting"):Cb(H||"")}),re&&s.jsx("button",{type:"button",onClick:()=>{Y.current=0,nn(re)},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:l("android.retry")})]}),We==="idle"&&!Dr&&!Pn&&s.jsxs(s.Fragment,{children:[s.jsx(mT,{size:22,className:"opacity-60"}),s.jsx("span",{children:Wr.length?l("android.idleHint"):l("android.noDevicesHint")})]})]})]}),s.jsxs("div",{className:`flex flex-wrap items-center gap-1 border-t border-border ${Le?"px-1.5 py-0.5":"px-2 py-1.5"}`,children:[s.jsx(Eo,{compact:Le,label:l("android.back"),onClick:()=>x.current?.back(),disabled:!G,children:s.jsx(h3,{size:14})}),s.jsx(Eo,{compact:Le,label:l("android.home"),onClick:()=>x.current?.home(),disabled:!G,children:s.jsx(rT,{size:14})}),s.jsx(Eo,{compact:Le,label:l("android.recents"),onClick:()=>x.current?.recents(),disabled:!G,children:s.jsx(w3,{size:14})}),s.jsx(Eo,{compact:Le,label:l("android.notifications"),onClick:()=>x.current?.expandNotifications(),disabled:!G,children:s.jsx(x3,{size:14})}),s.jsx(Eo,{compact:Le,label:l("android.rotate"),onClick:()=>x.current?.rotate(),disabled:!G,children:s.jsx(VT,{size:14})}),s.jsx(Eo,{compact:Le,label:l("android.volumeDown"),onClick:()=>x.current?.volumeDown(),disabled:!G,children:s.jsx(xC,{size:14})}),s.jsx(Eo,{compact:Le,label:l("android.volumeUp"),onClick:()=>x.current?.volumeUp(),disabled:!G,children:s.jsx(yC,{size:14})}),s.jsx(Eo,{compact:Le,label:l("android.power"),onClick:()=>x.current?.power(),disabled:!G,children:s.jsx(zT,{size:14})}),s.jsx(Eo,{compact:Le,label:l("android.inputText"),active:yt,onClick:()=>pr(N=>!N),disabled:!G,children:s.jsx(v3,{size:14})}),s.jsx(Eo,{compact:Le,label:l("android.zoomIn"),onClick:()=>Nr("in"),disabled:!G||V>=Gh-.01,children:s.jsx(Us,{size:14})}),s.jsx(Eo,{compact:Le,label:l("android.zoomOut"),onClick:()=>Nr("out"),disabled:!G||V<=Tl+.01,children:s.jsx(A3,{size:14})}),s.jsxs("div",{className:"relative ml-auto h-5 w-24 min-w-0 max-w-full shrink-0","data-mirror-capture-status":!0,children:[s.jsx("span",{"aria-hidden":it||!!un||ht,className:`block truncate text-right text-[10px] leading-5 tabular-nums text-muted-foreground ${it||un||ht?"invisible":""}`,children:be?s.jsx(s.Fragment,{children:s.jsx("span",{ref:fe})}):""}),s.jsx("div",{className:"absolute inset-0 flex items-center justify-end overflow-hidden",children:s.jsx(SF,{recording:it,elapsed:sr,status:ht?l("android.captureInserting"):un,stopLabel:l("android.recordingStop"),onStop:()=>{Rn("manual")}})})]})]}),yt&&s.jsxs("div",{className:"flex items-center gap-1.5 border-t border-border px-2 py-1.5",children:[s.jsx("input",{value:nr,onChange:N=>_r(N.target.value),onKeyDown:N=>{N.key==="Enter"&&!N.nativeEvent.isComposing&&(N.preventDefault(),Kn())},placeholder:l("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}),s.jsx("button",{type:"button",onClick:Kn,disabled:!nr,className:"rounded bg-surface-2 p-1.5 text-primary disabled:opacity-40",title:l("android.send"),children:s.jsx(q0,{size:13})})]})]});return h==="window"?Li.createPortal(s.jsx("div",{className:"fixed inset-0 z-modal-panel flex flex-col bg-[var(--chrome-bg)]",style:{paddingTop:"var(--safe-top-inset, env(safe-area-inset-top, 0px))",paddingBottom:"var(--safe-bottom-inset, env(safe-area-inset-bottom, 0px))"},children:z}),document.body):t?ir&&mn?Li.createPortal(z,mn):null:ir&&mn?s.jsxs(s.Fragment,{children:[Li.createPortal(z,mn),s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-[11px] text-muted-foreground",children:[s.jsx(_l,{size:18,className:"opacity-60"}),s.jsx("span",{children:l("android.splitDockedHint")}),s.jsx("button",{type:"button",onClick:()=>{Qr(M0,null),Or({docked:null})},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:l("android.splitClose")})]})]}):z}function Ch({icon:e,label:t,active:r=!1,disabled:n=!1,onSelect:a}){return s.jsxs("button",{type:"button",role:"menuitem",disabled:n,onClick:a,className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left transition hover:bg-surface-2 disabled:opacity-40 disabled:hover:bg-transparent ${r?"text-primary":"text-foreground"}`,children:[s.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:e}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:t}),r&&s.jsx(di,{size:12,className:"shrink-0"})]})}function SF({recording:e,elapsed:t,status:r,stopLabel:n,onStop:a}){return e?s.jsxs("span",{role:"status","aria-live":"polite",className:"ml-auto inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded bg-destructive/15 px-1.5 py-0.5 text-[10px] tabular-nums text-destructive",children:[s.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 animate-pulse rounded-full bg-destructive"}),Nb(t),s.jsx("button",{type:"button",onClick:a,title:n,"aria-label":`${n} · ${Nb(t)}`,className:"ml-0.5 inline-flex h-4 w-4 items-center justify-center rounded hover:bg-destructive/25",children:s.jsx(S3,{size:8,fill:"currentColor"})})]}):r?s.jsx("span",{role:"status","aria-live":"polite",title:r,className:"ml-auto truncate text-[10px] text-primary",children:r}):null}function Qb({sessionId:e}){const t=ns(x=>x.docks[H0]),r=!!t,n=t?.sessionId??e??null,c=Am(x=>x.pending)[0],l=b.useCallback(async x=>{if(!n)throw new Error("没有可接收截图的终端");const w=(await vd("/tmp",[x])).files[0]?.path;if(!w)throw new Error("截图上传未返回文件路径");await Mb(w,n)},[n]),h=b.useCallback(x=>{Am.getState().enqueue(x,n)},[n]),p=ns(x=>!!x.hosts[H0]),m=b.useRef(!1);return b.useEffect(()=>{m.current||(m.current=!0,nc().then(x=>{const y=x.androidPanel?.docked;y&&(ns.getState().docks[H0]||ns.getState().setDock(H0,y))}).catch(()=>{}))},[]),s.jsxs(s.Fragment,{children:[r&&p&&s.jsx(CF,{sessionId:n,dockOnly:!0,onInsertFile:n?l:void 0,onInsertPrompt:n?x=>R6(x,n):void 0,onRecordingComplete:h}),c&&s.jsx(bF,{file:c.file,initialPath:c.initialPath,onInsert:x=>c.insert?c.insert(x):Mb(x,c.sessionId),onDone:()=>Am.getState().remove(c.file.id)},c.file.id)]})}function Pb({label:e,onClick:t,enabled:r}){return r?s.jsx("button",{type:"button",onClick:t,className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-elevated",children:e}):null}function Ob(e,t){return[`Termdock 的“设备投屏”在当前服务端不可用:未找到 ${e==="adb"?"adb(Android platform-tools)":"scrcpy / scrcpy-server"}${t?`(错误:${t})`:""}。`,"请在本机安装并让 Termdock 恢复可用:","1) 安装依赖:"," - macOS: brew install android-platform-tools scrcpy"," - Ubuntu/Debian: sudo apt install adb scrcpy"," - Windows: winget install Google.PlatformTools && winget install Genymobile.scrcpy","2) 若不在 PATH,请在 ~/.termdock/.env 指定 TERMDOCK_ADB_BIN / TERMDOCK_SCRCPY_BIN / TERMDOCK_SCRCPY_SERVER。","3) 完成后重启 Termdock 服务,并用 adb version、scrcpy --version 验证。","边界:只做本机环境安装与配置,不要改动 Termdock 仓库代码。"].join(`
155
+ `:"")+Et)}},ref:Ir,className:w?"":"rounded-xl border border-primary/20 bg-primary/5 px-3 py-3",children:[!w&&s.jsxs("h4",{className:"truncate text-[12px] font-medium text-foreground",children:[dt.name," · 发送给成员"]}),s.jsxs("div",{className:w?"space-y-2":"mt-2 space-y-2",children:[$e&&s.jsxs("div",{className:"relative z-20 flex items-center justify-between gap-2",children:[s.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["发送给 ",s.jsx("span",{className:"text-[9px]",children:"· 可多选"})]}),s.jsxs("details",{className:"relative",onKeyDown:K=>{K.key==="Escape"&&(K.currentTarget.removeAttribute("open"),K.currentTarget.querySelector("summary")?.focus(),K.stopPropagation())},children:[s.jsx("summary",{"aria-label":"更多协作操作",className:"flex min-h-11 min-w-11 cursor-pointer list-none items-center justify-center rounded text-muted-foreground hover:bg-surface-2 sm:min-h-8 sm:min-w-8 [&::-webkit-details-marker]:hidden",children:s.jsx(Qo,{size:16})}),s.jsxs("div",{className:"absolute right-0 top-full z-30 w-44 rounded-lg border border-border/20 bg-surface-2 p-1 shadow-lg",children:[s.jsxs("button",{type:"button",className:`${Ar} min-h-11 w-full justify-start text-foreground hover:bg-surface-elevated`,onClick:K=>{K.currentTarget.closest("details")?.removeAttribute("open"),U?.(dt.id).catch(Ue=>fe(Ue instanceof Error?Ue.message:"无法打开看板"))},children:[s.jsx(Lc,{size:14}),"看板"]}),s.jsx("button",{type:"button","aria-expanded":lt,className:`${Ar} min-h-11 w-full justify-start text-foreground hover:bg-surface-elevated`,onClick:K=>{K.currentTarget.closest("details")?.removeAttribute("open"),Ce(Ue=>!Ue)},children:"成员管理"}),s.jsxs("button",{type:"button","aria-label":"组设置","aria-expanded":vt,className:`${Ar} min-h-11 w-full justify-start text-foreground hover:bg-surface-elevated`,onClick:K=>{K.currentTarget.closest("details")?.removeAttribute("open"),Xt.current=K.currentTarget,Yt(!0),fe(null),te(null)},children:[s.jsx(G0,{size:14}),"组设置"]})]})]})]}),s.jsxs("fieldset",{className:"min-w-0",children:[s.jsx("legend",{className:$e?"sr-only":"mb-1 text-[10px] text-muted-foreground",children:"接收人(可多选)"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:[{id:"*",label:"全组成员"},...dt.sessionIds.map(K=>({id:K,label:(()=>{const Ue=sr.find(Et=>Et.sessionId===K);return Ue?gu(Ue,sr):void 0})()??`${K.slice(0,8)}(离线)`}))].map(({id:K,label:Ue})=>{const Et=K==="*"?be===null:be?.includes(K)??!1,kt=L.find(tr=>tr.sessionId===K);return s.jsxs("span",{className:"inline-flex max-w-full items-center gap-0.5",children:[s.jsxs("button",{type:"button","aria-pressed":Et,onClick:()=>Ze(tr=>K==="*"?null:tr?.includes(K)?tr.filter(Br=>Br!==K):[...tr??[],K]),className:`${v1} min-h-9 min-w-0 gap-1 sm:min-h-7 ${Et?"border-primary/40 bg-primary/15 text-primary":"border-border/20 bg-surface-2 text-muted-foreground hover:text-foreground"}`,children:[Et&&s.jsx(di,{size:12,"aria-hidden":"true",className:"shrink-0"}),s.jsx("span",{className:"break-words text-left",children:Ue})]}),kt&&s.jsx("button",{type:"button","aria-label":`打开 ${Ue} 的终端`,title:`打开 ${Ue} 的终端`,className:"inline-flex h-9 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-surface-2 hover:text-primary sm:h-7 sm:w-6",onClick:()=>{W(kt).catch(tr=>fe(tr instanceof Error?tr.message:"无法打开会话"))},children:s.jsx(Lc,{size:12})})]},K)})})]})]}),s.jsxs("label",{className:"mt-2 block space-y-1 text-[9px] text-muted-foreground",children:[s.jsx("span",{className:$e?"sr-only":void 0,children:"内容"}),s.jsx("textarea",{onKeyDown:K=>{K.key==="Enter"&&(K.metaKey||K.ctrlKey)&&!K.nativeEvent.isComposing&&K.keyCode!==229&&(K.preventDefault(),Wr())},onPaste:K=>{const Ue=Array.from(K.clipboardData.files);Ue.length&&(K.preventDefault(),Pt(Ue))},className:`${Fs} min-h-16 max-h-48 resize-y`,value:Je,onChange:K=>Tt(K.target.value),placeholder:"输入消息,可粘贴引用或文件…"})]}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-3",children:[s.jsx("p",{role:"status","aria-live":"polite",title:w&&a?a:void 0,className:`min-w-0 flex-1 text-[9px] leading-relaxed ${w?"truncate":""} ${w&&a?"text-primary":"text-muted-foreground"}`,children:An>0?"正在准备文件路径…":w&&a?a:dt.federated?"消息由服务端后台投递,可查看送达结果;无需保持客户端在线。":"在线成员立即入队;离线成员上线后送达。"}),s.jsxs("button",{disabled:le!==null||An>0||!Je.trim()||!Vr.length,className:`${Ar} shrink-0 bg-primary text-primary-foreground`,title:"发送(⌘ / Ctrl + Enter)",onClick:()=>{Wr()},children:[le==="send-message"?s.jsx(yn,{size:13,className:"animate-spin"}):null,"发送"]})]})]}),s.jsxs("div",{children:[s.jsxs("details",{hidden:$e&&!lt,open:$e?lt:void 0,onToggle:K=>{$e&&Ce(K.currentTarget.open)},className:"mt-4 rounded-xl border border-border/15",children:[s.jsxs("summary",{className:"cursor-pointer px-3 py-3 text-[11px] font-medium text-foreground",children:["管理成员、角色与删除 · ",dt.sessionIds.length," 个成员"]}),s.jsxs("section",{className:"border-t border-border/15 p-3",children:[s.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h4",{className:"text-[13px] font-medium text-foreground",children:dt.name}),s.jsxs("p",{className:"mt-1 text-[10px] text-muted-foreground",children:[dt.sessionIds.length," 个成员 · 组 ID:",s.jsx("span",{className:"break-all font-mono",children:k6(dt.id)})]})]}),He?s.jsxs("div",{className:"flex flex-wrap items-center gap-1 sm:justify-end",children:[s.jsx("button",{className:`${Ar} bg-surface-2 px-2 text-foreground`,onClick:()=>rt(!1),children:"取消"}),s.jsxs("button",{disabled:le!==null,className:`${Ar} bg-destructive px-2 text-destructive-foreground`,onClick:()=>{fs()},children:[le===`delete:${dt.id}`?s.jsx(yn,{size:13,className:"animate-spin"}):null,"确认删除"]})]}):s.jsxs("div",{className:"flex flex-wrap items-center gap-1 sm:justify-end",children:[s.jsxs("button",{className:`${Ar} px-2 text-muted-foreground hover:bg-surface-2 hover:text-foreground`,onClick:()=>{q(new Set(dt.sessionIds)),Vt(dt.updatedAt);const K=!Wt;Mt(K),K&&De(Object.fromEntries(dt.sessionIds.map(Ue=>[Ue,dt.roles?.[Ue]??""]))),et(!1)},children:[s.jsx(G0,{size:13}),"管理成员"]}),s.jsxs("button",{className:`${Ar} px-2 text-primary hover:bg-primary/10`,onClick:Kr,children:[s.jsx(Us,{size:13}),"新建 Agent"]}),s.jsx("button",{"aria-label":`删除协作组 ${dt.name}`,title:"删除协作组",disabled:le!==null,className:"rounded-lg p-2 text-muted-foreground transition hover:bg-destructive/10 hover:text-destructive",onClick:()=>{de(dt.updatedAt),rt(!0)},children:s.jsx(zs,{size:14})})]})]}),He&&s.jsxs("p",{role:"alert",className:"mt-2 rounded-lg bg-destructive/10 px-3 py-2 text-[10px] leading-relaxed text-destructive",children:["将删除“",dt.name,"”协作组及其协作记录,",dt.sessionIds.length," 个成员的终端会话会保留。"]}),s.jsx("div",{className:"mt-3 grid divide-y divide-border/10 border-y border-border/10 sm:grid-cols-2 sm:divide-x sm:divide-y-0",children:dt.sessionIds.map(K=>{const Ue=L.find(tr=>tr.sessionId===K),Et=dt.roles?.[K],kt=Ue?.name??K;return s.jsxs("div",{className:`flex min-w-0 items-stretch transition ${pe===K?"bg-destructive/5":"hover:bg-surface-2"}`,children:[s.jsxs("button",{disabled:!Ue,onClick:()=>Ue&&void W(Ue).catch(tr=>fe(tr instanceof Error?tr.message:"无法打开会话")),className:"min-w-0 flex-1 px-3 py-2.5 text-left disabled:cursor-default",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`h-2 w-2 shrink-0 rounded-full ${Ue&&["ready","shell","terminal-connected","service-reachable","working","idle","done"].includes(Ue.status)&&Ue.serviceConnected!==!1?"bg-[var(--success)]":"bg-muted-foreground"}`}),s.jsx("span",{className:"truncate text-[11px] text-foreground",children:kt}),Ue&&s.jsx(mm,{session:Ue}),s.jsx("span",{className:"ml-auto shrink-0 text-[9px] text-muted-foreground",children:Ue?Wh(Ue):"已离线"})]}),s.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-[9px] text-muted-foreground",children:[Et?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"min-w-0 truncate font-medium text-primary/80",children:["定位:",Et]}),s.jsx("span",{className:"shrink-0 text-muted-foreground/50",children:"·"})]}):null,Ue?s.jsx("span",{className:"min-w-0 truncate",children:gm(Ue.currentTask)}):s.jsx("span",{className:"shrink-0",children:"重新上线后可继续接收消息"})]})]}),s.jsx("button",{"aria-label":`把 ${kt} 移出协作组`,"aria-expanded":pe===K,title:"移出协作组",disabled:le!==null,className:`mr-1 shrink-0 self-center rounded-lg p-2 transition ${pe===K?"text-destructive":"text-muted-foreground hover:bg-destructive/10 hover:text-destructive"}`,onClick:()=>Ge(pe===K?null:K),children:s.jsx(zs,{size:13})})]},K)})}),pe&&dt.sessionIds.includes(pe)&&(()=>{const K=L.find(Et=>Et.sessionId===pe)?.name??pe,Ue=le===`remove-member:${pe}`;return s.jsxs("div",{role:"group","aria-label":`确认移除成员 ${K}`,className:"flex flex-wrap items-center gap-x-3 gap-y-2 border-y border-destructive/25 bg-destructive/5 px-3 py-2.5",children:[s.jsx("p",{className:"min-w-0 flex-1 text-[10px] leading-relaxed text-destructive",children:`把“${K}”移出“${dt.name}”?移出后它不再收到这个组的消息,可以随时重新加入`}),s.jsxs("div",{className:"flex shrink-0 gap-2",children:[s.jsx("button",{className:`${Ar} min-h-8 bg-surface-2 px-2 text-[10px] text-foreground`,onClick:()=>Ge(null),children:"取消"}),s.jsxs("button",{disabled:le!==null,className:`${Ar} min-h-8 px-2 text-[10px] bg-destructive text-destructive-foreground`,onClick:()=>{Pn(pe)},children:[Ue?s.jsx(yn,{size:12,className:"animate-spin"}):s.jsx(zs,{size:12}),"移出"]})]})]})})(),Wt&&s.jsxs("div",{className:"mt-4 border-t border-border/15 pt-4",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("h5",{className:"text-[11px] font-medium text-foreground",children:"管理成员"}),s.jsx("p",{className:"mt-1 text-[9px] text-muted-foreground",children:"暂不可用的原成员会保留,只有取消勾选才会移出;定位(角色)在每行独立保存,成员收到消息时会看到自己的定位。"})]}),s.jsxs("span",{className:"text-[9px] text-muted-foreground",children:["已选 ",ft.size]})]}),s.jsx("div",{className:"mt-3 max-h-72 divide-y divide-border/10 overflow-y-auto border-y border-border/10",children:Sn.length<=1?En.map(Pr):Sn.map(K=>{const Ue=ir(K.key);return s.jsxs("div",{children:[s.jsx(xb,{label:K.label,count:K.sessions.length,collapsed:Ue,onToggle:()=>mn(K.key)}),!Ue&&s.jsx("div",{className:"divide-y divide-border/10",children:K.sessions.map(Pr)})]},K.key)})}),s.jsxs("div",{className:"mt-3 flex justify-end gap-2",children:[s.jsx("button",{className:`${Ar} bg-surface-2 text-foreground`,onClick:()=>{Mt(!1),De({})},children:"取消"}),s.jsxs("button",{disabled:le!==null||v!=="loaded",className:`${Ar} bg-primary text-primary-foreground`,onClick:()=>{Dr()},children:[le==="save-members"?s.jsx(yn,{size:13,className:"animate-spin"}):s.jsx(di,{size:13}),"保存成员"]})]})]}),er&&s.jsxs("div",{className:"mt-4 border-t border-primary/20 pt-4",children:[s.jsxs("div",{children:[s.jsx("h5",{className:"text-[11px] font-medium text-foreground",children:"创建 Agent Session"}),s.jsx("p",{className:"mt-1 text-[9px] text-muted-foreground",children:"新会话启动后自动加入本组,并收到初始任务和成员信息。"})]}),s.jsx(WP,{group:dt,value:gt,onChange:bt,disabled:le!==null}),s.jsxs("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:[s.jsxs("label",{className:"space-y-1 text-[9px] text-muted-foreground",children:["Agent / Plugin",s.jsx("select",{"aria-label":"新 Agent 类型",className:Fs,disabled:!!gt,value:dt.launchProfiles?.find(K=>K.id===gt)?.agentSlug??Ct,onChange:K=>Nt(K.target.value),children:E.map(K=>s.jsxs("option",{value:K.slug,children:[K.displayName,K.isPlugin?" · Plugin":""]},K.slug))})]}),s.jsxs("label",{className:"space-y-1 text-[9px] text-muted-foreground",children:["会话名称",s.jsx("input",{"aria-label":"新 Agent 会话名称",className:Fs,value:It,onChange:K=>yt(K.target.value),placeholder:"留空则自动命名"})]})]}),s.jsxs("label",{className:"mt-2 block space-y-1 text-[9px] text-muted-foreground",children:["工作目录",s.jsx("input",{"aria-label":"新 Agent 工作目录",className:Fs,value:pr,onChange:K=>nr(K.target.value),placeholder:"默认继承当前会话"})]}),s.jsxs("label",{className:"mt-2 block space-y-1 text-[9px] text-muted-foreground",children:["初始任务",s.jsx("textarea",{"aria-label":"新 Agent 初始任务",className:`${Fs} min-h-16 resize-y`,value:_r,onChange:K=>un(K.target.value),placeholder:"说明它加入后要先完成什么"})]}),s.jsxs("div",{className:"mt-3 flex justify-end gap-2",children:[s.jsx("button",{className:`${Ar} bg-surface-2 text-foreground`,onClick:()=>et(!1),children:"取消"}),s.jsxs("button",{disabled:le!==null||!Ct||!!gt&&!dt.launchProfiles?.some(K=>K.id===gt),className:`${Ar} bg-primary text-primary-foreground`,onClick:()=>{nn()},children:[le==="spawn-agent"?s.jsx(yn,{size:13,className:"animate-spin"}):s.jsx(Ad,{size:13}),"创建并加入"]})]})]})]})]},dt.id),s.jsxs("section",{className:"mt-4",children:[s.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[s.jsx("h4",{className:"text-[11px] font-medium text-foreground",children:"协作记录"}),s.jsxs("span",{className:"text-[9px] text-muted-foreground",children:[Or.length," 条"]})]}),s.jsxs("div",{className:"divide-y divide-border/10 border-y border-border/10 [overflow-wrap:anywhere]",children:[Or.map(K=>s.jsxs("div",{className:"px-2 py-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[9px] text-muted-foreground",children:[s.jsx("span",{className:"font-medium text-primary",children:K.responseKind==="ack"?"收到确认":K.responseKind==="progress"?"进展":K.responseKind==="result"?"结果":xO(K.kind)}),s.jsx("span",{children:K.fromName}),s.jsx("span",{children:"→"}),s.jsx("span",{className:"truncate",children:K.toNames.join("、")}),s.jsx("span",{className:"ml-auto shrink-0",children:new Date(K.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),s.jsx("p",{className:"mt-1 whitespace-pre-wrap text-[11px] leading-relaxed text-foreground",children:K.content}),s.jsx("p",{className:"mt-1 text-[9px] text-muted-foreground",children:K.status==="pending"?"已入队 · 等待投递":K.status==="failed"?"投递失败":K.status==="expired"?"消息已过期,未继续投递":K.status==="stored"?"答复已持久保存 · 供后台接收":"已写入接收方终端 · 等待接手确认"}),(K.task||K.failureReason)&&s.jsxs("details",{className:"mt-2 text-[10px] text-muted-foreground",children:[s.jsx("summary",{className:"cursor-pointer",children:"任务详情与证据"}),s.jsx("pre",{className:"mt-1 max-h-40 overflow-auto whitespace-pre-wrap break-words",children:JSON.stringify(K.task??{failure_reason:K.failureReason},null,2)})]})]},K.key)),Or.length===0&&s.jsx(_O,{text:Ie?"正在加载协作记录…":"还没有消息。可以直接给成员发送说明或问题。"})]})]})]})]})]})]})}function cO({group:e,agents:t,activeSessionId:r,sessions:n,busy:a,setBusy:c,setError:l,setNotice:h,refresh:p,onClose:m}){const x=n.filter(Y=>e.sessionIds.includes(Y.sessionId)&&!ku(Y.sessionId)),[y,w]=b.useState(()=>nO(e,r&&x.some(Y=>Y.sessionId===r)?r:"")),v=b.useRef(y),[k,L]=b.useState(null),E=Y=>{const Ae={...v.current,...Y};v.current=Ae,sO(e.id,Ae),w(Ae)},{name:R,rules:B,savedName:W,savedRules:F,rulesVersion:U,rulesMemberId:V}=y,Z=Sf(y),le=new TextEncoder().encode(B).length,xe=x.some(Y=>Y.sessionId===V),fe=async()=>{if(!(a||!R.trim())){c("group-name"),l(null),h(null);try{const Y=await Zl({id:e.id,name:R.trim(),sessionIds:y.sessionIds??e.sessionIds,expectedUpdatedAt:y.updatedAt});L(null),E({savedName:Y.group.name,name:Y.group.name,updatedAt:Y.group.updatedAt,sessionIds:Y.group.sessionIds,...B===F?{rules:Y.group.instructions?.text??"",savedRules:Y.group.instructions?.text??"",rulesVersion:Y.group.instructions?.version??""}:{}}),await p(),h("协作组名称已更新")}catch(Y){L(null),l(Y instanceof W0&&Y.status===409?"组设置已被其他人修改。请查看最新状态并确认,名称与群规草稿仍保留。":Y instanceof Error?Y.message:"改名失败")}finally{c(null)}}},te=async()=>{if(!(a||!xe||le>8192)){c("group-rules"),l(null),h(null);try{const Y=await kw(e.id,{sessionId:V,text:B,expectedVersion:U});L(null),E({savedName:Y.group.name,...R===W?{name:Y.group.name}:{},updatedAt:Y.group.updatedAt,sessionIds:Y.group.sessionIds,rules:Y.group.instructions?.text??"",savedRules:Y.group.instructions?.text??"",rulesVersion:Y.group.instructions?.version??""}),await p(),h(B.trim()?"群规已保存,变更通知已入队":"群规已清空,变更通知已入队")}catch(Y){L(null),l(Y instanceof W0&&Y.status===409?"群规已被其他人修改。请查看最新状态并确认,名称与群规草稿仍保留。":Y instanceof Error?Y.message:"群规保存失败")}finally{c(null)}}},ke=()=>{E(xg(e,V)),L(null),l(null)},$e=async()=>{if(!a){c("group-latest"),l(null),h(null),L(null);try{const Ae=(await _1()).groups.find(lt=>lt.id===e.id);if(!Ae)throw new Error("协作组已删除;草稿仍保留,请返回看板查看。");L(Ae)}catch(Y){l(Y instanceof Error?Y.message:"最新状态读取失败;草稿仍保留,请重试。")}finally{c(null)}}};return s.jsxs("section",{"aria-label":"协作组设置",onKeyDown:Y=>{Y.key!=="Escape"||Y.defaultPrevented||Y.nativeEvent.isComposing||(Y.preventDefault(),Y.stopPropagation(),a||m())},className:"mt-3 rounded-xl border border-border/20 bg-surface-2 p-3",children:[s.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[s.jsx("h4",{className:"text-[12px] font-medium text-foreground",children:"组设置"}),s.jsx("button",{type:"button",disabled:!!a,"aria-label":"关闭组设置",className:"rounded-lg p-2 text-muted-foreground hover:bg-surface-elevated",onClick:m,children:s.jsx(Qn,{size:14})})]}),s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["协作组名称",s.jsx("input",{autoFocus:!0,className:Fs,value:R,maxLength:240,disabled:!!a,onChange:Y=>E({name:Y.target.value})})]}),s.jsx("div",{className:"mt-2 flex justify-end",children:s.jsx("button",{type:"button",disabled:!!a||!!k||!R.trim()||R.trim()===W,className:`${Ar} min-h-9 bg-primary text-primary-foreground`,onClick:()=>{fe()},children:a==="group-name"?"保存中…":"保存名称"})}),s.jsx(GP,{group:e,agents:t,busy:a,setBusy:c,refresh:p}),s.jsxs("div",{className:"mt-3 space-y-2 border-t border-border/15 pt-3",children:[s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["由本组成员发布群规变更",s.jsxs("select",{className:Fs,value:V,disabled:!!a||!x.length,onChange:Y=>E({rulesMemberId:Y.target.value}),children:[s.jsx("option",{value:"",children:"选择当前服务的一个成员"}),!x.some(Y=>Y.sessionId===V)&&V&&s.jsx("option",{value:V,children:"原成员已不在组内,请重新选择"}),x.map(Y=>s.jsx("option",{value:Y.sessionId,children:Y.name},Y.sessionId))]})]}),s.jsxs("label",{className:"block space-y-1 text-[10px] text-muted-foreground",children:["群规与协作约定",s.jsx("textarea",{className:`${Fs} min-h-24 resize-y`,value:B,maxLength:8192,disabled:!!a,onChange:Y=>E({rules:Y.target.value}),placeholder:"例如:说明分工、交接要求和结果格式。清空后保存可移除群规。"})]})]}),!xe&&s.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:x.length?"选择发布变更的成员后即可保存,不需要关闭工作台。":"当前服务没有本组成员,请先添加成员或切换到成员所在的服务。已有群规可在此查看。"}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[s.jsx("p",{className:`text-[9px] ${le>8192?"text-destructive":"text-muted-foreground"}`,children:le>8192?"内容过长,请缩短群规":"保存或清空群规会通知本组其他成员"}),s.jsx("button",{type:"button",disabled:!!a||!!k||!xe||le>8192||B===F,className:`${Ar} min-h-9 shrink-0 bg-primary text-primary-foreground`,onClick:()=>{te()},children:a==="group-rules"?"保存中…":B.trim()?"保存群规":"清空群规"})]}),Z&&s.jsx("p",{role:"status",className:"mt-3 text-[11px] leading-5 text-muted-foreground",children:"有未保存修改。关闭、Escape 或切换组后,草稿仍保留在本标签页;名称与群规需分别保存。"}),Z&&s.jsx("button",{type:"button",disabled:!!a,className:`${Ar} mt-2 min-h-11 text-primary hover:bg-surface-elevated`,onClick:()=>{$e()},children:a==="group-latest"?"读取中…":"查看最新状态并保留草稿"}),k&&s.jsxs("section",{"aria-label":"最新组设置",className:"mt-3 space-y-2 rounded-lg bg-surface p-3 text-[11px] leading-5",children:[s.jsx("p",{className:"font-medium text-foreground",children:"确认最新状态后,再分别保存草稿"}),s.jsxs("p",{className:"break-words text-muted-foreground",children:["当前名称:",k.name]}),s.jsxs("p",{className:"whitespace-pre-wrap break-words text-muted-foreground",children:["当前群规:",k.instructions?.text||"未设置"]}),s.jsxs("p",{className:"break-words text-muted-foreground",children:["当前成员(",k.sessionIds.length,"):",k.sessionIds.map(Y=>n.find(Ae=>Ae.sessionId===Y)?.name??k6(Y)).join("、")||"暂无成员"]}),s.jsx("p",{className:"text-muted-foreground",children:"保留你的未保存内容;名称保存将保留以上成员,群规保存会通知当前成员。再次发生修改时仍会检查冲突。"}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx("button",{type:"button",disabled:!!a,className:`${Ar} min-h-11 bg-primary text-primary-foreground`,onClick:()=>{E(rO(v.current,k)),L(null),l(null),h("已确认最新状态,草稿仍保留;请分别保存名称与群规。")},children:"确认最新状态,保留草稿"}),s.jsx("button",{type:"button",className:`${Ar} min-h-11 text-muted-foreground`,onClick:()=>L(null),children:"取消确认"})]})]}),s.jsxs("div",{className:"mt-3 flex justify-between gap-2 border-t border-border/15 pt-2",children:[s.jsxs("button",{type:"button",disabled:!!a,className:`${Ar} min-h-9 text-muted-foreground hover:bg-surface-elevated`,onClick:ke,children:[s.jsx(yn,{size:12}),"重新载入",Z&&"(放弃草稿)"]}),s.jsx("button",{type:"button",disabled:!!a,className:`${Ar} min-h-9 bg-surface text-foreground`,onClick:m,children:Z?"关闭并保留草稿":"关闭"})]})]})}function uO({peers:e,currentGroupId:t,busy:r,setBusy:n,setError:a,setNotice:c,onSelectGroup:l}){const[h,p]=b.useState(null),[m,x]=b.useState(!1),y=e.services??[],w=e.removedServices??[],v=y.filter(E=>!E.connected),k=v.some(E=>E.groups?.some(R=>R.id===t)),L=async(E,R)=>{if(!r){n(`peer:${E}`),a(null),c(null);try{R?await Mw(E):await jw(E),p(null),x(!1),c(R?"协作连接已恢复,正在连接服务":"协作连接已移除,不会再自动重连;已有会话和消息保留")}catch(B){a(B instanceof Error?B.message:R?"重新连接失败":"移除连接失败")}finally{n(null)}}};return s.jsxs("details",{className:"mt-4 shrink-0 rounded-lg border border-border/15",open:k||void 0,children:[s.jsxs("summary",{className:"cursor-pointer px-3 py-2.5 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"font-medium text-foreground",children:"协作连接与管理"}),s.jsx("span",{className:"ml-2",children:e.state==="loading"?"正在加载…":`${y.length-v.length} 个已连接${v.length?` · ${v.length} 个离线`:""}`})]}),s.jsxs("div",{className:"max-h-64 overflow-y-auto border-t border-border/15 px-3 py-2",children:[y.length>0&&s.jsx("p",{className:"mb-1 text-[10px] leading-relaxed text-muted-foreground",children:"与以下服务进行跨服务协作,名称与服务切换器一致。"}),v.length>0&&s.jsx("p",{className:"mb-2 text-[10px] leading-relaxed text-muted-foreground",children:k?"当前协作组的部分服务不可达,消息会保留并等待重连。":"其他服务暂时离线;当前服务内的协作可以继续。不再使用的连接可移除。"}),e.error&&s.jsx("p",{role:"status",className:"mb-2 break-words text-[10px] text-destructive",children:e.error}),e.state==="unsupported"&&s.jsx("p",{className:"mb-2 text-[10px] text-muted-foreground",children:"请更新客户端以管理跨服务连接。"}),s.jsx("div",{className:"divide-y divide-border/10",children:y.map(E=>s.jsxs("div",{className:"py-2.5",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("p",{className:"text-[11px] text-foreground",children:[ec({serviceLabel:E.label,serviceOrigin:E.origin}),s.jsx("span",{className:`ml-2 text-[9px] ${E.connected?"text-[var(--success)]":"text-muted-foreground"}`,children:E.connected?"已连接":E.error==="CONNECTING"?"连接中":"暂时离线"})]}),s.jsx(dO,{service:E})]}),E.serviceId&&s.jsxs("button",{type:"button",disabled:!!r,"aria-label":`移除协作连接 ${E.origin}`,className:`${Ar} min-h-9 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,onClick:()=>p(h===E.serviceId?null:E.serviceId),children:[s.jsx(zs,{size:12}),"移除"]})]}),!!E.groups?.length&&s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1 text-[9px] text-muted-foreground",children:[s.jsx("span",{children:"用于"}),E.groups.map(R=>s.jsx("button",{type:"button",className:"rounded px-1.5 py-1 text-primary hover:bg-primary/10",onClick:()=>l(R.id),children:R.name},R.id))]}),!E.connected&&E.error&&E.error!=="CONNECTING"&&s.jsxs("details",{className:"mt-1 text-[9px] text-muted-foreground",children:[s.jsx("summary",{className:"cursor-pointer",children:yO(E.error)}),s.jsx("p",{className:"mt-1 select-text break-words",children:E.error})]}),h===E.serviceId&&s.jsxs("div",{role:"group","aria-label":"确认移除协作连接",className:"mt-2 rounded-lg bg-surface-2 p-2.5",children:[s.jsx("p",{className:"text-[10px] leading-relaxed text-foreground",children:E.groups?.length?"请先处理上方协作组的成员,再移除这条连接。":"移除后停止与该服务协作,保留已有会话和消息;以后可重新连接。"}),s.jsxs("div",{className:"mt-2 flex justify-end gap-2",children:[s.jsx("button",{type:"button",disabled:!!r,className:`${Ar} min-h-9 text-muted-foreground`,onClick:()=>p(null),children:"取消"}),s.jsx("button",{type:"button",disabled:!!r||!!E.groups?.length,className:`${Ar} min-h-9 bg-destructive text-destructive-foreground`,onClick:()=>{L(E.serviceId,!1)},children:r===`peer:${E.serviceId}`?"正在移除…":"确认移除"})]})]})]},E.serviceId||E.origin))}),y.length===0&&e.state==="ready"&&s.jsx("p",{className:"py-2 text-[10px] text-muted-foreground",children:"当前没有其他协作服务,当前服务内仍可创建协作组。"}),v.length>0&&s.jsxs("button",{type:"button",className:`${Ar} mt-1 min-h-9 text-primary hover:bg-primary/10`,onClick:Rw,children:[s.jsx(yn,{size:12}),"重试连接"]}),w.length>0&&s.jsxs("div",{className:"mt-2 border-t border-border/15 pt-1",children:[s.jsx("button",{type:"button","aria-expanded":m,className:`${Ar} min-h-9 text-muted-foreground hover:bg-surface-2`,onClick:()=>x(E=>!E),children:m?"收起恢复列表":"恢复已移除连接"}),m&&s.jsxs("section",{"aria-label":"恢复已移除连接",className:"mt-1 rounded-lg bg-surface-2 px-2.5 py-2",children:[s.jsx("p",{className:"text-[10px] leading-relaxed text-muted-foreground",children:"以下是恢复记录,连接已停用,不会自动重连。点击恢复后才会重新启用协作。"}),s.jsx("div",{className:"mt-1 divide-y divide-border/10",children:w.map(E=>s.jsxs("div",{className:"flex items-start gap-2 py-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("p",{className:"break-words text-[10px] text-foreground",children:[ec({serviceLabel:E.label,serviceOrigin:E.origin}),s.jsx("span",{className:"ml-2 text-[9px] text-muted-foreground",children:"已停用"})]}),s.jsx("p",{className:"mt-0.5 select-text break-all text-[9px] text-muted-foreground",children:E.accessUrl||E.origin})]}),s.jsx("button",{type:"button",disabled:!!r||!E.serviceId,className:`${Ar} min-h-9 shrink-0 text-primary hover:bg-primary/10`,onClick:()=>{L(E.serviceId,!0)},children:r===`peer:${E.serviceId}`?"恢复中…":"恢复连接"})]},E.serviceId||E.origin))})]})]})]})]},k?"affected":"other")}function dO({service:e}){let t=!1;try{t=["localhost","127.0.0.1","[::1]"].includes(new URL(e.origin).hostname)}catch{}const r=e.accessUrl||(t?"":e.origin);return s.jsxs("details",{className:"mt-1 text-[9px] text-muted-foreground",children:[s.jsx("summary",{className:"w-fit cursor-pointer py-1",children:"连接详情"}),s.jsxs("dl",{className:"mt-1 space-y-1 select-text break-all",children:[s.jsxs("div",{children:[s.jsx("dt",{className:"inline",children:"服务地址:"}),s.jsx("dd",{className:"inline",children:r||"暂未获取,请在服务切换器中查看"})]}),e.serviceId&&s.jsxs("div",{children:[s.jsx("dt",{className:"inline",children:"服务身份:"}),s.jsx("dd",{className:"inline",children:e.serviceId})]})]})]})}function pm(e){return!ku(e.sessionId)||e.serviceConnected!==!1}function hO(e){return e.serviceOrigin?e.serviceOrigin===window.location.origin?"":e.serviceOrigin:ku(e.sessionId)?.origin??""}function gb(e){const t=new Map;for(const r of e){const n=hO(r),a=t.get(n)??{key:n,label:n?ec(r):"本机服务",sessions:[]};n&&a.label==="远端服务"&&(a.label=ec(r)),a.sessions.push(r),t.set(n,a)}return[...t.values()].sort((r,n)=>(r.key?1:0)-(n.key?1:0)||r.label.localeCompare(n.label))}function xb({label:e,count:t,collapsed:r,onToggle:n}){return s.jsxs("button",{type:"button","aria-expanded":!r,onClick:n,className:"flex w-full items-center gap-1.5 bg-surface-2/50 px-2 py-1.5 text-left text-muted-foreground transition hover:bg-surface-elevated",children:[s.jsx(ul,{size:12,className:`shrink-0 transition-transform ${r?"-rotate-90":""}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-[10px] font-semibold uppercase tracking-wide",children:e}),s.jsx("span",{className:"shrink-0 text-[9px] text-muted-foreground/70",children:t})]})}function fO(e,t){const r=new Map(t.map(n=>[n.sessionId,n]));for(const n of e?.sessionIds??[]){if(r.has(n))continue;const a=e?.remoteSessions?.find(c=>c.sessionId===n);r.set(n,a?{...a,status:"offline",serviceConnected:!1}:{sessionId:n,name:n,backendSessionId:null,cwd:"",agent:null,status:"offline",capability:"",currentTask:"暂不可用,保留成员身份",updatedAt:0,...ku(n)?{serviceConnected:!1}:{}})}return[...r.values()]}function mm({session:e}){return!e.serviceOrigin||e.serviceOrigin===window.location.origin?null:s.jsxs("span",{className:"inline-flex max-w-28 shrink-0 items-center gap-1 rounded border border-border/20 px-1 py-0.5 text-[9px] text-muted-foreground",children:[s.jsx(Lc,{size:9}),s.jsx("span",{className:"truncate",children:ec(e)})]})}function Wh(e){return e.serviceConnected===!1?"服务不可达":e.status==="recovering"&&e.route_error==="ROUTE_NOT_CHECKED"?"投递目标未检查":gO(e.status)}function pO(e,t=[]){if(!e)return;const r=t.some(a=>a.sessionId!==e.sessionId&&a.name.trim()===e.name.trim()),n=e.sessionId.startsWith("remote:")?ec(e):"本机服务";return r?`${e.name} · ${n}`:e.name}async function mO(e){e.sessionId.startsWith("remote:")?await e6(e.sessionId):window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:e.sessionId}))}function gO(e){return{ready:"终端可达",shell:"Shell 终端",recovering:"正在检查投递目标",unchecked:"投递目标未检查","terminal-connected":"终端已连接",detached:"终端未连接","agent-exited":"Agent 已退出",offline:"已离线",ambiguous:"需确认目标终端","identity-mismatch":"终端身份已变化",unavailable:"终端暂不可达","service-reachable":"服务可达","service-unreachable":"服务不可达"}[e]??"在线"}function gm(e){if(!e)return"暂无任务摘要";try{const t=JSON.parse(e);if(typeof t.prompt=="string")return _f(t.prompt)||"暂无任务摘要"}catch{}return _f(e)||"暂无任务摘要"}function xO(e){return{message:"消息",ask:"问题",reply:"回复",task:"任务",handoff:"交接",done:"完成"}[e]}function bO(e,t){const r=new Map(t.map(a=>[a.sessionId,pO(a,t)])),n=new Map;for(const a of e){const c=`${a.threadId}:${a.createdAt}:${a.fromSessionId??a.integrationOrigin?.integrationId??"user"}:${a.kind}:${a.responseKind??""}:${JSON.stringify(a.task??null)}:${a.content}`,l=n.get(c),h=a.toPrincipalId?`后台接入 ${a.toPrincipalId}`:r.get(a.toSessionId)??a.toSessionId.slice(0,8);if(l){l.toNames.push(h);const p={failed:-2,expired:-1,pending:0,delivered:1,read:2,stored:3};p[a.status]<p[l.status]&&(l.status=a.status);continue}n.set(c,{key:c,kind:a.kind,content:a.content,createdAt:a.createdAt,fromName:a.fromSessionId?r.get(a.fromSessionId)??a.fromSessionId.slice(0,8):a.integrationOrigin?`后台接入 ${a.integrationOrigin.integrationId}`:"你",toNames:[h],status:a.status,responseKind:a.responseKind,task:a.task,failureReason:a.failureReason})}return[...n.values()].sort((a,c)=>c.createdAt-a.createdAt)}function yO(e){return/timeout|timed out|超时|operation was aborted/i.test(e)?"连接超时,暂时无法访问该服务。请确认远端服务已启动,并检查网络或 VPN 连接。":/ECONNREFUSED|connection refused/i.test(e)?"远端拒绝连接,请确认服务已启动且端口正确。":/ENOTFOUND|EHOSTUNREACH|ENETUNREACH/i.test(e)?"无法访问远端地址,请检查地址和网络连接。":/certificate|fingerprint|TLS|证书/i.test(e)?"远端证书校验失败,请检查服务连接授权。":"服务连接暂时不可用,可查看连接详情并重试。"}function xm({value:e,query:t}){const r=t.trim().toLocaleLowerCase();if(!r)return s.jsx(s.Fragment,{children:e});const n=e.toLocaleLowerCase(),a=[];let c=0,l;for(;(l=n.indexOf(r,c))>=0;)a.push(e.slice(c,l)),a.push(s.jsx("mark",{className:"rounded bg-primary/15 text-primary",children:e.slice(l,l+r.length)},l)),c=l+r.length;return a.push(e.slice(c)),s.jsx(s.Fragment,{children:a})}function vO({active:e,onClose:t,onNewSession:r,setError:n}){const[a,c]=b.useState(""),[l,h]=b.useState([]),[p,m]=b.useState(0),[x,y]=b.useState(),[w,v]=b.useState(50),[k,L]=b.useState(0),[E,R]=b.useState(!1),[B,W]=b.useState(null),[F,U]=b.useState(null),V=b.useRef(null),Z=b.useRef(0);b.useEffect(()=>{e&&V.current?.focus({preventScroll:!0})},[e]),b.useEffect(()=>{if(!e)return;const fe=++Z.current,te=new AbortController;let ke;W(null),R(!0);const $e=async()=>{try{const Y=await Dw(a.trim(),w,te.signal);if(fe!==Z.current)return;h(Y.results),m(Y.total??Y.results.length),y(Y.index),Y.index?.building&&(ke=window.setTimeout(()=>{$e()},2500))}catch(Y){fe===Z.current&&!te.signal.aborted&&W(Y instanceof Error?Y.message:"搜索失败")}finally{fe===Z.current&&R(!1)}};return ke=window.setTimeout(()=>{$e()},a.trim()?250:0),()=>{window.clearTimeout(ke),te.abort(),++Z.current}},[e,a,w,k]);const le=fe=>{n(null),c(fe),h([]),m(0),v(50)},xe=async fe=>{if(!F){if(fe.live){window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:fe.sessionId})),t();return}if(!(!fe.nativeKey&&!fe.resumeHistoryId)){U(fe.sessionId),n(null);try{const te=fe.nativeKey?await Bw(fe.nativeKey):await p3(fe.resumeHistoryId);if("sessionId"in te&&te.sessionId)window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:te.sessionId}));else if(te.command)r({mode:"shell",cwd:te.cwd,command:te.command});else throw new Error("这条会话暂时无法恢复,请重新搜索");t()}catch(te){n(te instanceof Error?te.message:"恢复失败")}finally{U(null)}}}};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"sticky -top-4 z-20 -mx-4 -mt-4 border-b border-border/15 bg-surface px-4 py-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:"历史会话搜索"}),s.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-muted-foreground",children:"搜索当前服务的 Codex、Claude 历史对话和 Termdock 终端记录,未启动的会话也能找到并恢复。"})]}),s.jsxs("label",{className:"relative mt-3 block",children:[s.jsx("span",{className:"sr-only",children:"搜索历史会话"}),s.jsx(El,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),s.jsx("input",{ref:V,maxLength:512,className:`${Fs} pl-9 pr-9`,value:a,onChange:fe=>le(fe.target.value),placeholder:"搜索会话名称、对话关键词、目录或 session ID"}),E?s.jsx(yn,{size:13,className:"absolute right-3 top-1/2 -translate-y-1/2 animate-spin text-muted-foreground"}):a&&s.jsx("button",{type:"button","aria-label":"清空搜索",className:"absolute right-1.5 top-1/2 -translate-y-1/2 rounded-md p-1.5 text-muted-foreground hover:bg-surface-2 hover:text-foreground",onClick:()=>le(""),children:s.jsx(Qn,{size:13})})]}),x?.building&&s.jsxs("div",{role:"status",className:"mt-2 text-[10px] text-muted-foreground",children:["正在建立历史索引:",x.indexed,"/",x.total," 个会话。可以先搜名称和目录,对话结果会自动补齐。"]}),x?.warning&&s.jsx("p",{role:"status",className:"mt-2 text-[10px] text-destructive",children:x.warning}),!!x?.failed&&s.jsxs("p",{role:"status",className:"mt-2 text-[10px] text-destructive",children:[x.failed," 个会话暂未完成索引,其余结果可正常使用。请稍后刷新重试。"]})]}),s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("p",{className:"text-[11px] text-foreground",children:[a.trim()?`找到 ${p} 个会话`:"最近的会话",p>l.length?` · 显示 ${l.length} 个`:""]}),s.jsxs("button",{type:"button",disabled:E,className:`${Ar} text-muted-foreground hover:bg-surface-2 hover:text-foreground`,onClick:()=>L(fe=>fe+1),children:[s.jsx(yn,{size:12}),"刷新"]})]}),!a.trim()&&s.jsx("p",{className:"text-[10px] text-muted-foreground",children:"记得之前讨论过什么?输入一句话中的关键词,就能找到对应会话。历史对话与索引保存在当前服务机器上。"}),s.jsx("div",{className:"divide-y divide-border/10 border-y border-border/10",children:l.map(fe=>{const te=fe.live||!!(fe.nativeKey||fe.resumeHistoryId),ke=F===fe.sessionId?"正在恢复…":fe.live?"打开会话":te?"恢复会话":"仅供查阅",$e=fe.source==="codex"||fe.source==="claude"?fe.snippet:wO(fe),Y=fe.source==="codex"?"Codex 历史":fe.source==="claude"?"Claude 历史":"终端记录",Ae=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"break-words text-[12px] font-medium text-foreground",children:s.jsx(xm,{value:fe.title,query:a})}),s.jsx("p",{className:"mt-0.5 break-all text-[9px] text-muted-foreground",children:s.jsx(xm,{value:fe.cwd||"项目目录待索引",query:a})})]}),s.jsx("span",{className:`shrink-0 text-[10px] ${fe.live?"text-[var(--success)]":te?"text-primary":"text-muted-foreground"}`,children:ke})]}),$e&&s.jsx("p",{className:"mt-2 line-clamp-3 break-words text-[10px] leading-relaxed text-foreground/75",children:s.jsx(xm,{value:$e,query:a})}),s.jsxs("p",{className:"mt-2 text-[9px] text-muted-foreground",children:[Y," · ",kf(fe.updatedAt),a.trim()?` · ${fe.matchCount>=999?"999+":fe.matchCount} 处匹配`:"",te?"":" · 没有可恢复记录"]}),fe.agentNativeSessionId&&s.jsx("p",{className:"mt-1 select-text break-all text-[9px] text-muted-foreground",children:fe.agentNativeSessionId})]});return te?s.jsx("button",{disabled:!!F,onClick:()=>{xe(fe)},className:"block w-full px-2 py-3 text-left transition hover:bg-surface-2 focus-visible:bg-surface-2 focus-visible:outline-none",children:Ae},fe.nativeKey||fe.sessionId):s.jsx("article",{className:"px-2 py-3",children:Ae},fe.sessionId)})}),p>l.length&&w<5e3&&s.jsx("button",{type:"button",disabled:E,className:`${Ar} w-full bg-surface-2 text-foreground`,onClick:()=>v(fe=>fe+50),children:E?"正在加载…":"加载更多会话"}),B&&s.jsxs("div",{role:"alert",className:"rounded-lg bg-destructive/10 p-3 text-[11px] text-destructive",children:["搜索失败:",B,s.jsx("button",{type:"button",className:`${Ar} ml-2`,onClick:()=>L(fe=>fe+1),children:"重试"})]}),!E&&!B&&l.length===0&&s.jsxs("div",{className:"border-y border-border/15 py-8 text-center",children:[s.jsx("p",{className:"text-[12px] text-foreground",children:x?.building?"历史对话仍在索引,请稍候":x?.warning||x?.failed?"暂未找到结果,部分历史记录尚不可搜索":a.trim()?`没有找到“${a.trim()}”`:"当前服务还没有可搜索的历史会话"}),s.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:x?.building?"新结果会自动显示,也可以先搜会话名称或目录。":"可尝试更短的关键词、项目目录或 session ID;其他机器的历史需切换到对应服务搜索。"}),a.trim()&&s.jsx("button",{className:`${Ar} mt-3 bg-surface-2 text-foreground`,onClick:()=>le(""),children:"查看最近会话"})]})]})}function _f(e){return e.replace(/\u001B\][^\u0007]*(?:\u0007|\u001B\\)/g," ").replace(/\u001B\[[0-?]*[ -/]*[@-~]/g," ").replace(/\(B/g," ").replace(/<[^>]{1,120}>/g," ").replace(/[─━│┃┄┅┆┇┈┉┊┋┌┐└┘├┤┬┴┼╭╮╯╰═║╔╗╚╝╠╣╦╩╬]+/g," ").replace(/([^\p{L}\p{N}\s])\1{3,}/gu," ").replace(/([A-Za-z])\1{12,}/g," ").replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g," ").replace(/\s+/g," ").trim().slice(0,280)}function wO(e){let t=_f(e.snippet);for(const r of[e.title,e.cwd,e.agentSlug])r&&(t=t.split(r).join(" "));return _f(t)}function AO(e){if(e.schedule.kind==="interval")return e.schedule.everyMinutes===60?"每小时":e.schedule.everyMinutes===1440?"每天":`每 ${e.schedule.everyMinutes} 分钟`;const t=["日","一","二","三","四","五","六"];return`${e.schedule.weekdays.length===7?"每天":e.schedule.weekdays.map(n=>`周${t[n]}`).join("、")} ${e.schedule.time}`}function TO(e,t=Date.now(),r=t){if(e.kind==="interval"){const c=e.everyMinutes*6e4,l=Math.max(0,t-r);return r+(Math.floor(l/c)+1)*c}const[n,a]=e.time.split(":").map(Number);for(let c=0;c<=7;c+=1){const l=new Date(t);if(l.setDate(l.getDate()+c),l.setHours(n,a,0,0),l.getTime()>t&&e.weekdays.includes(l.getDay()))return l.getTime()}return t}function kf(e){return new Intl.DateTimeFormat("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(e)}function CO(e){return e==="running"?"投递中":e==="success"?"已投递":e==="failed"?"投递失败":""}function SO(e){return e==="running"?"text-[var(--warning)]":e==="success"?"text-[var(--success)]":e==="failed"?"text-destructive":"text-muted-foreground"}function _O({text:e}){return s.jsx("div",{className:"rounded-xl border border-dashed border-border/20 px-4 py-8 text-center text-[11px] text-muted-foreground",children:e})}function kO({onOpenSettings:e,serverAttention:t,actions:r}){const{t:n}=zr(),[a,c]=b.useState(!1),l=b.useRef(null),h=b.useRef(null),p=b.useRef(null),m=b.useId();return b.useLayoutEffect(()=>{if(!a)return;const x=l.current,y=p.current;if(!x||!y)return;const w=window.visualViewport,v=()=>{const L=x.getBoundingClientRect(),E=(w?.offsetLeft??0)+8,R=(w?.offsetTop??0)+8,B=(w?.width??window.innerWidth)-16,W=(w?.offsetTop??0)+(w?.height??window.innerHeight)-8,F=Math.max(0,Math.min(256,B)),U=Math.max(0,L.top-R-4),V=Math.max(0,W-L.bottom-4),Z=U>=180||U>=V;Object.assign(y.style,{width:`${F}px`,left:`${Math.max(E,Math.min(L.right-F,E+B-F))}px`,top:`${Z?L.top-4:L.bottom+4}px`,maxHeight:`${Z?U:V}px`,transform:Z?"translateY(-100%)":"none"})};v();const k=typeof ResizeObserver>"u"?null:new ResizeObserver(v);return k?.observe(x),window.addEventListener("resize",v),window.addEventListener("scroll",v,!0),w?.addEventListener("resize",v),w?.addEventListener("scroll",v),()=>{k?.disconnect(),window.removeEventListener("resize",v),window.removeEventListener("scroll",v,!0),w?.removeEventListener("resize",v),w?.removeEventListener("scroll",v)}},[a]),b.useEffect(()=>{if(!a)return;p.current?.querySelector('[role="menuitem"]')?.focus({preventScroll:!0});const x=y=>{y.target instanceof Node&&!l.current?.contains(y.target)&&!p.current?.contains(y.target)&&c(!1)};return document.addEventListener("pointerdown",x),()=>document.removeEventListener("pointerdown",x)},[a]),s.jsxs("div",{ref:l,role:"group","data-sidebar-gesture-ignore":!0,"aria-label":n("sidebar.moreActions"),className:"relative z-20 mt-2 flex items-center justify-between gap-2",onKeyDown:x=>{a&&x.key==="Escape"&&(x.preventDefault(),x.stopPropagation(),c(!1),h.current?.focus({preventScroll:!0}))},children:[s.jsxs("button",{type:"button",onClick:e,title:t?n("sidebar.serverAttention"):void 0,className:"inline-flex min-h-9 items-center gap-1.5 whitespace-nowrap rounded-lg px-2 text-[11px] text-muted-foreground transition hover:bg-surface-2 hover:text-foreground focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",children:[s.jsx(XT,{size:14,className:t?"text-destructive":void 0}),s.jsx("span",{children:n("sidebar.settings")})]}),s.jsxs("button",{ref:h,type:"button","aria-haspopup":"menu","aria-expanded":a,"aria-controls":a?m:void 0,onClick:()=>c(x=>!x),onKeyDown:x=>{(x.key==="ArrowDown"||x.key==="ArrowUp")&&(x.preventDefault(),c(!0))},className:`inline-flex min-h-9 items-center gap-1.5 whitespace-nowrap rounded-lg px-2 text-[11px] transition focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary ${a?"bg-surface-2 text-foreground":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,children:[s.jsx(Qo,{size:15}),s.jsx("span",{children:n("sidebar.moreActions")})]}),a&&Li.createPortal(s.jsx("div",{ref:p,id:m,role:"menu","data-sidebar-gesture-ignore":!0,"data-sidebar-composer-popover":"sidebar-launch-options","aria-label":n("sidebar.moreActions"),className:"fixed z-popover overflow-y-auto overscroll-contain rounded-xl border border-border/15 bg-surface p-1 shadow-[0_12px_32px_var(--app-shadow-soft)] animate-fade-in",onKeyDown:x=>{const y=[...x.currentTarget.querySelectorAll('[role="menuitem"]')],w=y.indexOf(document.activeElement);let v;if(x.key==="ArrowDown")v=(w+1)%y.length;else if(x.key==="ArrowUp")v=(w-1+y.length)%y.length;else if(x.key==="Home")v=0;else if(x.key==="End")v=y.length-1;else if(x.key==="Tab"){c(!1);return}else return;x.preventDefault(),y[v]?.focus({preventScroll:!0})},children:r.map(({label:x,icon:y,onSelect:w,separated:v})=>s.jsxs("div",{role:"none",children:[v&&s.jsx("div",{role:"separator",className:"mx-2 my-1 h-px bg-border/40"}),s.jsxs("button",{type:"button",role:"menuitem",tabIndex:-1,onClick:()=>{c(!1),w()},className:"flex min-h-10 w-full items-center gap-2.5 whitespace-nowrap rounded-lg px-2.5 text-left text-[12px] text-foreground transition hover:bg-surface-2 focus:bg-surface-2 focus:outline-none",children:[s.jsx(y,{size:15,className:"shrink-0 text-muted-foreground"}),s.jsx("span",{children:x})]})]},x))}),document.body)]})}const L0=64,bb=10,LO=120;function IO({children:e,open:t,onOpenChange:r,onClose:n,closeLabel:a,closeTitle:c,compact:l}){const h=b.useRef(null),p=b.useRef(null),m=b.useRef(0),[x,y]=b.useState(null),w=x??(t?L0:0);return b.useEffect(()=>{if(!t)return;const v=k=>{k.target instanceof Node&&!h.current?.contains(k.target)&&r(!1)};return document.addEventListener("pointerdown",v,!0),()=>document.removeEventListener("pointerdown",v,!0)},[t,r]),s.jsxs("div",{ref:h,"data-sidebar-gesture-ignore":!0,"data-session-swipe":!0,className:`relative flex min-w-0 flex-1 items-center ${l?"":"gap-1"}`,style:{touchAction:"pan-y"},onPointerDown:v=>{if(m.current=0,!(v.pointerType!=="touch"&&v.pointerType!=="pen")){if(v.isPrimary===!1){p.current=null,y(null);return}!(v.target instanceof Element)||!v.target.closest(".sidebar-session-primary")||(p.current={pointerId:v.pointerId,x:v.clientX,y:v.clientY,startedAt:Date.now(),initialOffset:t?L0:0,offset:t?L0:0,horizontal:!1})}},onPointerMove:v=>{const k=p.current;if(!k||k.pointerId!==v.pointerId)return;const L=v.clientX-k.x,E=v.clientY-k.y;if(!k.horizontal){if(v.defaultPrevented||Date.now()-k.startedAt>=LO||Math.abs(E)>bb){p.current=null;return}if(Math.abs(L)<=bb)return;if(Math.abs(L)<Math.abs(E)*1.5||!t&&L<0){p.current=null;return}k.horizontal=!0,v.currentTarget.setPointerCapture?.(v.pointerId)}v.preventDefault(),k.offset=Math.max(0,Math.min(L0,k.initialOffset+L)),y(k.offset)},onPointerUp:v=>{const k=p.current;!k||k.pointerId!==v.pointerId||(p.current=null,k.horizontal&&(m.current=Date.now()+600,r(k.offset>=L0/2),y(null)))},onPointerCancel:()=>{p.current?.horizontal&&(m.current=Date.now()+600),p.current=null,y(null)},onClickCapture:v=>{if(Date.now()<m.current){m.current=0,v.preventDefault(),v.stopPropagation();return}t&&v.target instanceof Element&&v.target.closest(".sidebar-session-primary")&&(r(!1),v.preventDefault(),v.stopPropagation())},onKeyDown:v=>{t&&v.key==="Escape"&&(v.stopPropagation(),r(!1))},children:[s.jsx("div",{className:"shrink-0 overflow-hidden rounded-md transition-[width] duration-150 ease-out motion-reduce:transition-none",style:{width:w,transition:x===null?void 0:"none"},children:w>0&&s.jsxs("button",{type:"button",tabIndex:t?0:-1,"aria-hidden":!t,"aria-label":c,className:"flex min-h-8 w-16 flex-col items-center justify-center gap-0.5 bg-destructive py-1 text-[10px] text-destructive-foreground",onClick:v=>{v.stopPropagation(),r(!1),n(v)},children:[s.jsx(zs,{size:14}),a]})}),e]})}const yb="recoverable-tmux";function EO({sessions:e,loading:t,attachingName:r,onRefresh:n,onRestore:a,onClose:c}){const{t:l}=zr(),h=Gt(R=>R.collapsedGroups.has(yb)),p=Gt(R=>R.toggleGroupCollapsed),[m,x]=b.useState(null),[y,w]=b.useState(null),[v,k]=b.useState(null),L=b.useRef(!1),E=async R=>{if(!(!c||L.current)){L.current=!0,w(R),k(null);try{await c(R),x(null)}catch(B){k(B instanceof Error?B.message:l("sidebar.closeRecoverableSessionFailed"))}finally{L.current=!1,w(null)}}};return e.length===0?null:s.jsxs("section",{className:"mb-2 shrink-0 rounded-lg bg-[rgb(var(--tmux-rgb)_/_0.07)] p-1","aria-label":l("sidebar.recoverableSessions"),children:[s.jsxs("div",{className:"flex items-center gap-1 text-[10.5px] font-semibold text-[color:var(--tmux)]",children:[s.jsxs("button",{type:"button","aria-expanded":!h,onClick:()=>p(yb),className:"flex min-h-11 min-w-0 flex-1 items-center gap-2 rounded-md px-2 text-left hover:bg-surface-elevated md:min-h-8",children:[s.jsx(hi,{size:12,className:`shrink-0 ${h?"":"rotate-90"}`}),s.jsx(Sc,{size:12,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:l("sidebar.recoverableSessions")}),s.jsx("span",{className:"text-muted-foreground",children:e.length})]}),n&&s.jsx("button",{type:"button",onClick:n,disabled:t||y!==null,className:"inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-50 md:h-7 md:w-7","aria-label":l("sidebar.refreshRecoverableSessions"),title:l("sidebar.refreshRecoverableSessions"),children:s.jsx(yn,{size:11,className:t?"animate-spin":""})})]}),!h&&s.jsx("div",{className:"space-y-0.5",children:e.map(R=>{const B=R.friendlyName?.trim()||R.label?.trim()||R.name,W=Pu(R.cwd??null),F=r===R.name,U=m===R.name;return s.jsxs("div",{children:[s.jsxs("div",{className:"flex min-w-0 items-center",children:[s.jsxs("button",{type:"button",disabled:r!==null||y!==null||U,onClick:()=>a(R),className:"group flex min-h-11 min-w-0 flex-1 items-center gap-2 rounded-md px-2 text-left text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-60 md:min-h-10","aria-label":l("sidebar.restoreRecoverableSession",{name:B}),title:R.cwd||R.name,children:[s.jsx("span",{className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-[rgb(var(--tmux-rgb)_/_0.11)] text-[color:var(--tmux)]",children:F?s.jsx(In,{size:12,className:"animate-spin"}):s.jsx(Nu,{size:12})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-[11.5px] font-semibold text-foreground",children:B}),s.jsx("span",{className:"block truncate text-[9.5px] text-muted-foreground",children:[R.program,W].filter(Boolean).join(" · ")||`tmux:${R.name}`})]}),s.jsx("span",{className:"shrink-0 text-[10px] font-medium text-[color:var(--tmux)] group-hover:text-foreground",children:l(F?"sidebar.restoringRecoverableSession":"sidebar.restore")})]}),c&&s.jsx("button",{type:"button",disabled:r!==null||y!==null,onClick:()=>{x(R.name),k(null)},className:"inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-md text-muted-foreground transition hover:bg-destructive/15 hover:text-destructive disabled:opacity-50 md:h-7 md:w-7","aria-label":l("sidebar.closeSession",{name:B}),title:l("sidebar.closeSession",{name:B}),children:s.jsx(Qn,{size:12})})]}),U&&s.jsxs("div",{role:"group","aria-label":l("sidebar.closeSession",{name:B}),className:"space-y-2 rounded-md bg-surface px-2 py-2",children:[s.jsx("p",{className:"text-[11px] text-foreground",children:l("sidebar.confirmCloseRecoverableSession",{name:B})}),v&&s.jsx("p",{role:"alert",className:"text-[11px] text-destructive",children:v}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{type:"button",disabled:y!==null,onClick:()=>{x(null),k(null)},className:"min-h-11 rounded-md px-2 text-[11px] text-muted-foreground hover:bg-surface-elevated disabled:opacity-50 md:min-h-8",children:l("common.cancel")}),s.jsx("button",{type:"button",disabled:y!==null,onClick:()=>{E(R.name)},className:"min-h-11 rounded-md bg-destructive/15 px-2 text-[11px] text-destructive hover:bg-destructive/25 disabled:opacity-50 md:min-h-8",children:y===R.name?l("common.loading"):l("sidebar.endRecoverableSession")})]})]})]},R.name)})})]})}function NO(e,t){return E3(e,t)}function I0(e,t){const r=new Set(e),n=t.filter(c=>c.sessionIds.length>=2&&c.sessionIds.every(l=>r.has(l))),a=new Set;return e.flatMap(c=>{const l=n.find(h=>h.sessionIds.includes(c));return l?a.has(l.id)?[]:(a.add(l.id),[{sessionIds:l.sessionIds,workspace:l}]):[{sessionIds:[c]}]})}function E0(e,t,r,n=[]){const a=new Map,c=new Map,l=new Set(e.map(x=>x.id));for(const x of n){const y=x.sessionIds.filter(v=>l.has(v));if(!y.length)continue;const w=y.length===x.sessionIds.length?x:{...x,sessionIds:y};y.forEach(v=>a.set(v,w))}for(const x of t)if(!(x.sessionIds.length<2||!x.sessionIds.every(y=>l.has(y)))&&!x.sessionIds.some(y=>a.has(y)))for(const y of x.sessionIds)c.set(y,x);const h=new Set,p=new Set,m=[];for(const x of e){const y=a.get(x.id);if(y){if(h.has(y.id))continue;h.add(y.id);const k=y.sessionIds.flatMap(L=>{const E=r.get(L);return E?[E]:[]});m.push({kind:"collaboration",id:`collaboration:${y.id}`,group:y,members:k,sessionIds:y.sessionIds});continue}const w=c.get(x.id);if(!w){m.push({kind:"session",id:`session:${x.id}`,session:x,sessionIds:[x.id]});continue}if(p.has(w.id))continue;p.add(w.id);const v=w.sessionIds.flatMap(k=>{const L=r.get(k);return L?[L]:[]});m.push({kind:"workspace",id:`workspace:${w.id}`,workspace:w,members:v,sessionIds:w.sessionIds})}return m}function vb(e,t,r){const n=Math.min(e.length,Math.max(0,r)),a=e.slice(0,n).flatMap(l=>l.sessionIds.filter(h=>h!==t)),c=e.slice(n).flatMap(l=>l.sessionIds.filter(h=>h!==t));return[...a,t,...c]}function RO({status:e,detail:t,needsReview:r,inCopyMode:n}){return s.jsx(mP,{status:e,detail:t,needsReview:r,inCopyMode:n})}function wb({isOpen:e,drawerWidthPx:t,onClose:r,onOpen:n,sessions:a,activeSessionId:c,sessionStates:l,onJumpToNextAttention:h,onNewSession:p,onCloseSession:m,onSplitSession:x,onCloseSplit:y,onRemoveFromSplit:w,splitWorkspaces:v,onSetSplitLayout:k,onReorderSplitWorkspace:L,onCombineSplitSessions:E,onReorderSessions:R,onSessionMenu:B,onOpenSettings:W,onOpenQuota:F,updateState:U,updateActionPending:V=!1,onConfirmUpdateRestart:Z,onRetryUpdate:le,serverHealthState:xe,tmuxAvailable:fe=!0,defaultSessionMode:te="shell",push:ke,pinned:$e,onTogglePinned:Y,recoverableTmuxSessions:Ae=[],recoverableTmuxSessionsLoading:lt=!1,onRefreshRecoverableTmuxSessions:Ce,onCloseRecoverableTmuxSession:ye}){const{t:_e}=zr(),[,je]=b.useState(0),[re,Pe]=b.useState(null),[Se,Ee]=b.useState(!1),[Be,Ne]=b.useState(!1),[oe,He]=b.useState(null),rt=b.useRef(!1),mt=b.useRef(0),de=b.useCallback(G=>{G||(mt.current+=1),Ee(G)},[]),[Ye,st]=b.useState(!1),Ie=na(G=>G.groupId),[We,Te]=b.useState({}),H=Ye||Object.keys(We).length>0,ae=b.useRef(!1),be=b.useRef(!1),[Ze,Je]=b.useState(null);b.useEffect(()=>{let G=!1;return nc().then(Le=>{G||ae.current||Te(Object.fromEntries(M3(Le.collaborationPanels?.[Ef()]).map(Ke=>[Ke,!0])))}).catch(()=>{}),()=>{G=!0}},[]);const Tt=async(G,Le)=>{ae.current=!0,await co({floatingGroupId:Le},G),Te(Ke=>({...Ke,[G]:Le!==null}))},[Wt,Mt]=b.useState([]),[vt,Yt]=b.useState(!1),[Qt,Xt]=b.useState(null),[Ut,Lt]=b.useState(null),[pe,Ge]=b.useState(null),[ft,q]=b.useState(null),at=mu(G=>G.tasks),Vt=mu(G=>G.allTasks),[Ve,De]=b.useState(0),[er,et]=b.useState(null),Ct=b.useRef(!1),[Nt,gt]=b.useState({}),bt=mu(G=>G.error),[It,yt]=b.useState(!1);b.useEffect(()=>{const G=()=>{document.hidden||mu.getState().refresh()};G();const Le=window.setInterval(G,5e3);return document.addEventListener("visibilitychange",G),()=>{clearInterval(Le),document.removeEventListener("visibilitychange",G)}},[]);const pr=async G=>(de(!1),ae.current=!0,G?(na.getState().open(G),Or(),!0):(st(!0),Or(),!0)),nr=Xh(G=>G.collaborationGroups),_r=Xh(G=>G.setCollaborationGroups),[un,Ir]=b.useState({mode:te}),{preference:me,agents:Gr,detecting:it,refresh:dt,selectAgent:sr}=zP(),An=b.useRef(null),on=!!(U?.latestVersion&&["installing","ready","restarting","error"].includes(U.status)),Me=!!xe?.attention,nt=[_e("sidebar.moreActions"),Me?_e("sidebar.serverAttention"):null,on&&U?.latestVersion?_e("sidebar.updateAvailable",{version:U.latestVersion}):null].filter(Boolean).join(": "),wt=Gt(G=>G.groupByFolder),Mr=Gt(G=>G.collapsedGroups),rn=Gt(G=>G.toggleGroupCollapsed),Er=b.useRef(null),ne=b.useRef(null),ht=b.useRef(null),zt=b.useRef(0),Pt=b.useRef(!1),Cr=b.useRef(null),gr=b.useRef(null),[Hr,En]=b.useState(!1),dr=b.useRef([]),Tn=b.useRef(null),hn=b.useRef(null),Sn=b.useRef(new Set),ir=b.useRef(null),mn=b.useMemo(()=>new Set(v.flatMap(G=>G.sessionIds)),[v]),Qr=b.useMemo(()=>new Map(a.map(G=>[G.id,G])),[a]),Vr=b.useMemo(()=>NO(nr,new Set(Qr.keys())),[nr,Qr]),Wr=b.useCallback(async()=>{const G=++zt.current;try{const Le=await _1();if(G!==zt.current)return;_r(Array.isArray(Le.groups)?Le.groups:[])}catch{}},[]);b.useEffect(()=>f3(G=>_r(G.groups)),[]),b.useEffect(()=>{Wr();const G=window.setInterval(()=>{Wr()},1e4),Le=()=>{Wr()};return window.addEventListener("focus",Le),()=>{zt.current+=1,window.clearInterval(G),window.removeEventListener("focus",Le)}},[Wr]),b.useEffect(()=>{(e||!H)&&Wr()},[H,e,Wr]);const fs=b.useCallback(()=>{dr.current=Array.from(document.querySelectorAll("[data-collaboration-member], [data-collaboration-background]")).flatMap(G=>{const Le=G.dataset.collaborationMember??"",Ke=G.hasAttribute("data-collaboration-background"),ct=G.closest("[data-collaboration-group]")?.dataset.collaborationGroup;if(!Le&&!Ke||!ct)return[];const qe=[];for(let At=G.parentElement;At;At=At.parentElement)qe.push({element:At,top:At.scrollTop,left:At.scrollLeft});return[{element:G,sessionId:Le,groupId:ct,background:Ke,rect:G.getBoundingClientRect(),scrollParents:qe}]})},[]),Dr=b.useCallback((G,Le)=>{if(!Pt.current)return;document.querySelectorAll("[data-split-exit-drop-index]").forEach(N=>N.removeAttribute("data-active")),document.querySelectorAll("[data-drop-active]").forEach(N=>N.removeAttribute("data-drop-active"));const ct=document.elementsFromPoint(G,Le).map(N=>N.closest("[data-collaboration-background]")).find(Boolean)?.closest("[data-collaboration-group]");if(ct?.dataset.collaborationGroup){ct.dataset.dropActive="true",hn.current={kind:"collaboration",groupId:ct.dataset.collaborationGroup,background:!0};return}const qe=dr.current.find(N=>{if(N.sessionId===gr.current||!N.element.isConnected)return!1;const $=N.scrollParents.reduce((se,Qe)=>se+Qe.element.scrollLeft-Qe.left,0),ee=N.scrollParents.reduce((se,Qe)=>se+Qe.element.scrollTop-Qe.top,0);return G>=N.rect.left-$&&G<=N.rect.right-$&&Le>=N.rect.top-ee+N.rect.height*.25&&Le<=N.rect.bottom-ee-N.rect.height*.25});if(qe?.background){qe.element.closest("[data-collaboration-group]")?.setAttribute("data-drop-active","true"),hn.current={kind:"collaboration",groupId:qe.groupId,background:!0};return}if(qe&&!v.find($=>$.sessionIds.includes(qe.sessionId))?.sessionIds.includes(gr.current??"")){qe.element.dataset.dropActive="true",hn.current={kind:"split",sessionId:qe.sessionId,groupId:qe.groupId};return}const At=document.elementsFromPoint(G,Le).filter(N=>{const $=N.closest("[data-rfd-draggable-id]");return!$||!["session:","split-member:","collaboration-member:"].some(ee=>$.dataset.rfdDraggableId===`${ee}${gr.current}`)}),Rt=At.map(N=>N.closest("[data-collaboration-group]")).find(N=>N?.dataset.collaborationGroup);if(Rt?.dataset.collaborationGroup){const N=Rt.dataset.collaborationGroup,$=At.map(ze=>ze.closest("[data-collaboration-split]")).find(Boolean),ee=At.map(ze=>ze.closest("[data-collaboration-member]")).find(Boolean),se=ee?.dataset.collaborationMember??$?.dataset.splitAnchor,Qe=N===Cr.current&&v.some(ze=>ze.sessionIds.includes(se??"")&&ze.sessionIds.includes(gr.current??""));if(se&&!Qe&&(N!==Cr.current||!ee&&$)){Rt.dataset.dropActive="true";const ze=ee??$;ze&&(ze.dataset.dropActive="true"),hn.current={kind:"split",sessionId:se,groupId:N}}else{const ze=At.some(xt=>xt.closest("[data-collaboration-background]"));(N!==Cr.current||ze)&&(Rt.dataset.dropActive="true"),hn.current={kind:"collaboration",groupId:N,background:ze}}return}const ot=Array.from(document.querySelectorAll("[data-sidebar-entity-list-id]")).filter(N=>N.dataset.sidebarEntityListId===Tn.current).find(N=>{const $=N.getBoundingClientRect();return G>=$.left&&G<=$.right&&Le>=$.top-8&&Le<=$.bottom+8});if(!ot){hn.current=null;return}const Ot=Array.from(ot.children).filter(N=>N instanceof HTMLElement&&N.hasAttribute("data-sidebar-entity-index")),hr=Ot.findIndex(N=>{const $=N.getBoundingClientRect();return Le<$.top+$.height/2}),Zt=hr<0?Ot.length:hr;hn.current={kind:"list",listId:ot.dataset.sidebarEntityListId??"",index:Zt};const z=Array.from(ot.querySelectorAll(":scope > [data-sidebar-entity-index] > [data-split-exit-drop-index]")).find(N=>N.dataset.splitExitDropIndex===String(Zt));z instanceof HTMLElement&&(z.dataset.active="true")},[v]);b.useEffect(()=>{const G=Ke=>Dr(Ke.clientX,Ke.clientY),Le=Ke=>{const ct=Ke.touches[0];ct&&Dr(ct.clientX,ct.clientY)};return window.addEventListener("pointermove",G),window.addEventListener("touchmove",Le,{passive:!0}),()=>{window.removeEventListener("pointermove",G),window.removeEventListener("touchmove",Le)}},[Dr]);const Pn=b.useCallback((G,Le)=>{try{G(Le)}finally{document.querySelectorAll("[data-sidebar-dragging]").forEach(Ke=>{delete Ke.dataset.sidebarDragging}),Pt.current=!1,dr.current=[],En(!1),Cr.current=null,gr.current=null,Tn.current=null,hn.current=null,document.querySelectorAll("[data-split-exit-drop-index]").forEach(Ke=>Ke.removeAttribute("data-active")),document.querySelectorAll("[data-drop-active]").forEach(Ke=>Ke.removeAttribute("data-drop-active"))}},[]),Sr=b.useMemo(()=>a.filter(G=>!mn.has(G.id)),[a,mn]),Kr=b.useMemo(()=>{let G=0;for(const Le of a)l.get(Le.id)?.agentStatus==="working"&&(G+=1);return G},[a,l]);b.useLayoutEffect(()=>{const G=Er.current,Le=ne.current;if(!e||!G||!Le){ht.current=null;return}const Ke=Le.getBoundingClientRect(),ct=G.getBoundingClientRect(),qe={item:G,top:Math.round(ct.top-Ke.top+Le.scrollTop),height:Math.round(ct.height),viewportHeight:Le.clientHeight},At=ht.current;if(ht.current=qe,At?.item===qe.item&&At.top===qe.top&&At.height===qe.height&&At.viewportHeight===qe.viewportHeight||Pt.current||Le.clientHeight===0)return;const Rt=8,Dt=ct.top-Ke.top,ot=ct.bottom-Ke.top;Dt<Rt?Le.scrollTop+=Dt-Rt:ot>Le.clientHeight-Rt&&(Le.scrollTop+=ot-Le.clientHeight+Rt)});const nn=b.useMemo(()=>{if(!wt||!c)return null;const G=l.get(c)?.cwd??null;return CC(G)},[wt,c,l]);b.useEffect(()=>{if(!wt){ir.current=null,Sn.current.clear();return}if(!c){ir.current=null;return}const G=Gt.getState(),Le=Sn.current,Ke=ir.current,ct=nn;Ke!==null&&Ke!==ct&&Le.has(Ke)&&(G.collapsedGroups.has(Ke)||G.toggleGroupCollapsed(Ke),Le.delete(Ke)),ct!==null&&ct!==""&&G.collapsedGroups.has(ct)&&(G.toggleGroupCollapsed(ct),Le.add(ct)),ir.current=ct},[wt,c,nn]),b.useEffect(()=>{e||de(!1)},[e]),b.useEffect(()=>{Ir(G=>({...G,command:me?.command}))},[me]),b.useEffect(()=>{if(!Se)return;let G=!1;return Yt(!0),Lt(null),Yg().then(Le=>{G||Mt(Le)}).catch(()=>{G||Lt(_e("sidebar.resumeHistoryLoadFailed"))}).finally(()=>{G||Yt(!1)}),()=>{G=!0}},[Se,_e]),b.useEffect(()=>{if(!re)return;const G=Le=>{Le instanceof KeyboardEvent&&Le.key!=="Escape"||Le instanceof PointerEvent&&Le.target instanceof Node&&An.current?.contains(Le.target)||Pe(null)};return window.addEventListener("pointerdown",G),window.addEventListener("keydown",G),()=>{window.removeEventListener("pointerdown",G),window.removeEventListener("keydown",G)}},[re]);const Or=()=>{!ke&&!$e&&r()};b.useEffect(()=>{const G=Le=>{de(!1);const{groupId:Ke,dock:ct}=Le.detail;ae.current=!0,ns.getState().setDock(Ke,{...ct,preferredWidth:360}),Te(qe=>({...qe,[Ke]:!0})),na.getState().terminal(),Or()};return window.addEventListener("termdock:open-collaboration-messages",G),()=>window.removeEventListener("termdock:open-collaboration-messages",G)},[Or]);const ks=te==="tmux"&&!fe?"shell":te,Pr=(G,Le=!1)=>{if(rt.current)return;rt.current=!0,Ne(!0),He(null);const Ke=mt.current;p({...G,shouldActivate:()=>Ke===mt.current&&(G.shouldActivate?.()??!0),onResult:ct=>{if(rt.current=!1,Ne(!1),!ct.ok){He(ct.error);return}Ke===mt.current&&(Le&&de(!1),Or())}})},Xr=()=>{Pr({mode:ks})},fn=()=>{me&&Pr({mode:ks,command:me.command})},K=G=>{de(!1),Ge(G.name),p({mode:"tmux",tmuxSessionName:G.name,cwd:G.cwd??void 0}),Or()};b.useEffect(()=>{pe&&(Ae.some(G=>G.name===pe)||Ge(null))},[pe,Ae]);const Ue=(G,Le)=>{Pr({...un,cwd:un.cwd?.trim()||void 0,command:Le??G?.command},!0)},Et=async G=>{Xt(G.id),Lt(null);try{const Le=await p3(G.id);Pr({mode:"shell",cwd:Le.cwd,command:Le.command},!0)}catch(Le){const Ke=Le&&typeof Le=="object"&&"code"in Le?String(Le.code??""):"";Lt(_e(Ke==="AGENT_SESSION_ACTIVE_ELSEWHERE"?"tab.resumeAgentConflict":"sidebar.resumeHistoryFailed"))}finally{Xt(null)}},kt=async G=>{Mt(Le=>Le.filter(Ke=>Ke.id!==G));try{await Gw(G)}catch{Lt(_e("sidebar.resumeHistoryRemoveFailed")),Yg().then(Mt).catch(()=>{})}},tr=()=>{if(Se){de(!1);return}rt.current||(mt.current+=1,rt.current||He(null),Ir({mode:te==="tmux"&&!fe?"shell":te,cwd:c?l.get(c)?.cwd??void 0:void 0,command:me?.command}),de(!0))},Br=b.useCallback(G=>{const Le=l.get(G);return Le?.agentStatus==="waiting"||Le?.agentNeedsReview?"bg-[rgb(var(--warning-rgb)_/_0.10)] text-foreground":Le?.agentStatus==="working"?"bg-[rgb(var(--success-rgb)_/_0.08)] text-foreground":Le?.inCopyMode?"bg-[rgb(var(--tmux-rgb)_/_0.08)] text-foreground":null},[l]),cr=Xv(),[_n,Ls]=b.useState(null);b.useEffect(()=>{e||Ls(null)},[e]);const Zn=b.useCallback((G,Le,Ke,ct,qe)=>{const At=!Ie&&G.id===c,Rt=mn.has(G.id),Dt=!!(Ke&&Rt),ot=l.get(G.id),Ot=Pu(ot?.cwd??null),hr=ot?.shellTitle??Pw(G.id),Zt=hr===ot?.cwd||hr===Ot?null:hr,z=Ow(G,ot?.activeProgram??null,null,Fw,Zt,ot?.promptState??null),N=!!(ot?.tuiProgress&&ot.tuiProgress.state!=="remove"),ee=ot?.promptState==="running"||ot?.agentStatus==="working"||N?"bg-[var(--success)]":ot?.agentStatus==="waiting"||ot?.agentNeedsReview?"bg-[var(--warning)]":ot?.inCopyMode?"bg-[var(--tmux)]":"bg-primary";return s.jsxs(IO,{open:_n===G.id,onOpenChange:se=>Ls(Qe=>se?G.id:Qe===G.id?null:Qe),onClose:se=>m(G.id,se,{skipConfirmation:!0}),closeLabel:_e("common.close"),closeTitle:_e("sidebar.closeSession",{name:z}),compact:Ke,children:[s.jsxs("button",{ref:At?Er:null,type:"button",...Le??{},onContextMenu:se=>{B&&(se.preventDefault(),B(G.id,{x:se.clientX,y:se.clientY}))},onClick:()=>{de(!1),na.getState().terminal(),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:G.id})),Or()},className:`sidebar-session-primary relative min-w-0 flex flex-1 items-center overflow-hidden text-left ${Le?"cursor-grab active:cursor-grabbing ":""}${Ke?"gap-1.5 py-0.5 pl-1.5 pr-0.5":"gap-1.5 py-1 pl-2 pr-1"}`,title:ot?.cwd??G.name,children:[At&&s.jsx("span",{className:`absolute inset-y-2 left-0 w-0.5 rounded-full ${ee}`}),s.jsxs("span",{className:`relative inline-flex shrink-0 items-center justify-center rounded-md ${Ke?"h-5 w-[22px]":"h-[22px] w-[22px]"} ${At?G.mode==="tmux"?"bg-[rgb(var(--tmux-rgb)_/_0.15)] text-[color:var(--tmux)]":"bg-primary/15 text-primary":G.mode==="tmux"?"bg-surface text-[rgb(var(--tmux-rgb)_/_0.80)]":"bg-surface text-muted-foreground"}`,children:[ot?.isConnecting||N&&!ot?.agentStatus?s.jsx(In,{size:Ke?10:11,className:"animate-spin"}):ot?.agent??Zg(G.id)?s.jsx(Mc,{agent:ot?.agent??Zg(G.id),size:Ke?13:15}):G.mode==="tmux"?s.jsx(Nu,{size:Ke?10:11}):s.jsx(Bo,{size:Ke?10:11}),s.jsx(RO,{status:ot?.agentStatus??null,detail:ot?.agentStatusDetail,needsReview:ot?.agentNeedsReview,inCopyMode:ot?.inCopyMode})]}),s.jsx("span",{className:`min-w-0 flex-1 truncate leading-tight ${Ke?"text-[11px]":"text-[12px]"} ${At?"font-medium text-foreground":""} ${ot?.inCopyMode?"text-[color:var(--tmux)]":""}`,children:z}),s.jsx(k5,{sessionIds:[G.id]})]}),ct,s.jsx("button",{type:"button",onClick:se=>{se.stopPropagation(),Dt?w(G.id):Rt?y(G.id):x(G.id)},className:`sidebar-session-action inline-flex shrink-0 items-center justify-center rounded-md transition hover:bg-primary/15 hover:text-primary active:scale-95 ${Ke?"h-6 w-6":"h-[26px] w-[26px]"} ${Rt?"bg-primary/15 text-primary":"text-muted-foreground/70"}`,"aria-label":`${_e(Dt?"tab.splitRemovePane":Rt?"tab.splitClose":"tab.split")} ${z}`,title:_e(Dt?"tab.splitRemovePane":Rt?"tab.splitClose":"tab.split"),children:Dt?s.jsx(fC,{size:11}):s.jsx(_l,{size:12})}),qe??s.jsx("button",{type:"button",onClick:se=>{se.stopPropagation(),m(G.id,se)},className:`sidebar-session-action inline-flex shrink-0 items-center justify-center rounded-md text-muted-foreground/70 transition hover:bg-destructive/15 hover:text-destructive active:scale-95 ${Ke?"h-6 w-6":"h-[26px] w-[26px]"}`,"aria-label":_e("sidebar.closeSession",{name:z}),title:_e("common.close"),children:s.jsx(Qn,{size:Ke?11:12})})]})},[c,mn,l,m,x,y,w,B,_e,_n]),sn=b.useMemo(()=>Kh(a,G=>l.get(G.id)?.cwd??null,wt,_e("sidebar.ungrouped"),v,Vr).groups,[Vr,wt,a,l,v,_e]),ln=b.useMemo(()=>E0(a,v,Qr,Vr),[Vr,a,Qr,v]),kr=b.useCallback(G=>{En(G.draggableId.startsWith("collaboration:")||G.draggableId.startsWith("workspace:"));const Le=G.draggableId.replace(/^split-member:/,"");gr.current=G.draggableId.replace(/^(?:session|split-member|collaboration-member):/,"");const Ke=G.type==="split-member"?v.find(Dt=>Dt.sessionIds.includes(Le)):null,ct=G.type==="collaboration-member"?G.source.droppableId.replace(/^collaboration-members:/,""):null,qe=ct?Vr.find(Dt=>Dt.id===ct):null;Pt.current=!!(Ke||qe||G.type==="session"&&G.draggableId.startsWith("session:")),Pt.current&&document.querySelectorAll("[data-collaboration-group]").forEach(Dt=>{Dt.dataset.sidebarDragging="true"}),Cr.current=qe?.id??null;const At=Ke?.sessionIds??qe?.sessionIds??[],Rt=At.length>0?sn.find(Dt=>At.every(ot=>Dt.sessions.some(Ot=>Ot.id===ot))):null;Tn.current=wt?Rt?`group-sessions:${Rt.key}`:null:At.length>0?"sidebar-entities":null,hn.current=null},[Vr,sn,wt,v]),$r=b.useCallback((G,Le,Ke)=>{if(Le===Ke)return;const ct=Le?nr.find(ot=>ot.id===Le):null,qe=Ke?nr.find(ot=>ot.id===Ke):null;if(Ke&&!qe)return;if(qe){const ot=a.map(hr=>hr.id).filter(hr=>hr!==G);let Ot=-1;ot.forEach((hr,Zt)=>{qe.sessionIds.includes(hr)&&(Ot=Zt)}),Ot>=0&&(ot.splice(Ot+1,0,G),R(ot))}const At=ct?.sessionIds.filter(ot=>ot!==G)??[],Rt=qe?[...qe.sessionIds.filter(ot=>ot!==G),G]:[];_r(ot=>ot.flatMap(Ot=>Ot.id===Le?[{...Ot,sessionIds:At}]:Ot.id===Ke?[{...Ot,sessionIds:Rt}]:[Ot])),q(null),(ct&&qe?$w({sourceGroupId:ct.id,targetGroupId:qe.id,sessionId:G,expectedSourceUpdatedAt:ct.updatedAt,expectedTargetUpdatedAt:qe.updatedAt}):ct?Zl({id:ct.id,name:ct.name,sessionIds:At,expectedUpdatedAt:ct.updatedAt}):qe?Zl({id:qe.id,name:qe.name,sessionIds:Rt,expectedUpdatedAt:qe.updatedAt}):Promise.resolve()).then(()=>Wr(),ot=>(q(ot instanceof Error?ot.message:"协作成员移动失败"),Wr()))},[nr,Wr,a,R]),Gn=b.useCallback((G,Le,Ke,ct=!1)=>{const qe=nr.find($=>$.id===G);if(!qe||Le===Ke)return;const At=qe.sessionIds.filter($=>!$.startsWith("remote:")),Rt=I0(At,v).flatMap($=>$.sessionIds),Dt=S5(Vt,qe.id),ot=ct&&!Nt[qe.id]?Rt.filter($=>!Dt.has($)||$===c||mn.has($)):Rt.slice(),Ot=new Set(ot),[hr]=ot.splice(Le,1);if(!hr)return;ot.splice(Ke,0,hr);let Zt=0;const z=Rt.map($=>Ot.has($)?ot[Zt++]:$),N=v.find($=>$.sessionIds.includes(hr));if(N&&N.sessionIds.every($=>qe.sessionIds.includes($))){const $=z.filter(ee=>N.sessionIds.includes(ee));L(N.id,$)}z.push(...qe.sessionIds.filter($=>$.startsWith("remote:"))),_r($=>$.map(ee=>ee.id===G?{...ee,sessionIds:z}:ee)),q(null),Zl({id:qe.id,name:qe.name,sessionIds:z,expectedUpdatedAt:qe.updatedAt}).then(()=>Wr(),$=>(q($ instanceof Error?$.message:"成员排序失败"),Wr()))},[nr,Wr,v,L,Vt,Nt,c,mn]);b.useEffect(()=>{const G=Le=>{const{sourceId:Ke,targetId:ct}=Le.detail;if(!Ke||!ct||Ke===ct)return;const qe=Kh(a,se=>l.get(se.id)?.cwd??null,wt,"",v,Vr).arranged.map(se=>se.id),At=qe.indexOf(Ke),Rt=qe.indexOf(ct);if(At<0||Rt<0)return;const Dt=Vr.find(se=>se.sessionIds.includes(Ke));if(Dt?.sessionIds.includes(ct)){const se=I0(Dt.sessionIds,v).flatMap(Qe=>Qe.sessionIds);Gn(Dt.id,se.indexOf(Ke),se.indexOf(ct));return}const ot=v.filter(se=>se.sessionIds.length>=2&&se.sessionIds.every(Qe=>Qr.has(Qe))&&!Vr.some(Qe=>se.sessionIds.some(ze=>Qe.sessionIds.includes(ze)))),Ot=ot.find(se=>se.sessionIds.includes(Ke));if(Ot?.sessionIds.includes(ct)){const se=[...Ot.sessionIds];se.splice(se.indexOf(Ke),1),se.splice(Ot.sessionIds.indexOf(ct),0,Ke),L(Ot.id,se);return}const hr=se=>Vr.find(Qe=>Qe.sessionIds.includes(se))?.sessionIds??ot.find(Qe=>Qe.sessionIds.includes(se))?.sessionIds??[se],Zt=new Set(hr(Ke)),z=new Set(hr(ct)),N=qe.filter(se=>!Zt.has(se)),$=N.flatMap((se,Qe)=>z.has(se)?[Qe]:[]),ee=At<Rt?Math.max(...$)+1:Math.min(...$);N.splice(ee,0,...qe.filter(se=>Zt.has(se))),R(N)};return window.addEventListener("reorder-navigation-session",G),()=>window.removeEventListener("reorder-navigation-session",G)},[a,l,wt,v,Vr,Qr,Gn,L,R]);const Vn=b.useCallback(G=>{if(G.type!=="collaboration-member")return!1;if(G.reason==="CANCEL")return!0;const Le=G.source.droppableId.replace(/^collaboration-members:/,""),Ke=G.draggableId.replace(/^collaboration-member:/,""),ct=hn.current;if(ct?.kind==="split")return $r(Ke,Le,ct.groupId),E(ct.sessionId,Ke),!0;if(ct?.kind==="collaboration"&&ct.groupId!==Le)return $r(Ke,Le,ct.groupId),!0;if(ct?.kind==="collaboration"&&ct.background)return mn.has(Ke)&&w(Ke),!0;if(G.destination&&G.destination.droppableId!==G.source.droppableId){const qe=G.destination.droppableId.replace(/^collaboration-members:/,"");if(Vr.some(At=>At.id===qe))return $r(Ke,Le,qe),!0}if(G.combine){const qe=G.combine.droppableId.replace(/^collaboration-members:/,"");qe!==Le&&$r(Ke,Le,qe);const At=G.combine.draggableId.replace(/^collaboration-member:/,"");if(v.find(Dt=>Dt.sessionIds.includes(Ke))?.sessionIds.includes(At)){const Dt=Vr.find(Ot=>Ot.id===Le),ot=Dt?I0(Dt.sessionIds,v).flatMap(Ot=>Ot.sessionIds).indexOf(At):-1;ot>=0&&Dt&&Gn(Le,I0(Dt.sessionIds,v).flatMap(Ot=>Ot.sessionIds).indexOf(Ke),ot)}else Qr.has(At)&&E(At,Ke);return!0}if(G.destination?.droppableId===G.source.droppableId)return Gn(Le,G.source.index,G.destination.index,!0),!0;if(ct?.kind!=="list")return!0;if(ct?.kind==="list"){const qe=sn.find(Rt=>`group-sessions:${Rt.key}`===ct.listId),At=ct.listId==="sidebar-entities"?ln:qe?E0(qe.sessions,v,Qr,Vr):null;if(At){const Rt=vb(At,Ke,ct.index);ct.listId==="sidebar-entities"?R(Rt):qe&&R(sn.flatMap(Dt=>Dt.key===qe.key?Rt:Dt.sessions.map(ot=>ot.id)))}}return $r(Ke,Le,null),!0},[Vr,ln,sn,$r,R,Gn,Qr,v,mn,w,E]),dn=b.useCallback(G=>{if(G.type!=="split-member")return!1;if(G.reason==="CANCEL")return!0;const Le=G.draggableId.replace(/^split-member:/,""),Ke=v.find(ot=>ot.sessionIds.includes(Le));if(!Ke?.sessionIds.includes(Le))return!0;const ct=Ke.id,qe=hn.current;if(qe?.kind==="split")return $r(Le,null,qe.groupId),E(qe.sessionId,Le),!0;if(qe?.kind==="collaboration")return $r(Le,null,qe.groupId),!0;if(!G.destination&&qe?.kind==="list"){const ot=sn.find(Zt=>`group-sessions:${Zt.key}`===qe.listId),Ot=qe.listId==="sidebar-entities"?ln:ot?E0(ot.sessions,v,Qr,Vr):null;if(!Ot)return!0;const hr=vb(Ot,Le,qe.index);return w(Le),qe.listId==="sidebar-entities"?R(hr):ot&&R(sn.flatMap(Zt=>Zt.key===ot.key?hr:Zt.sessions.map(z=>z.id))),!0}if(!G.destination)return!0;const At=G.destination.droppableId.replace(/^split-members:/,"");if(At!==ct){const Ot=v.find(hr=>hr.id===At)?.sessionIds[0];return Ot&&E(Ot,Le),!0}if(G.source.index===G.destination.index)return!0;const Rt=[...Ke.sessionIds],[Dt]=Rt.splice(G.source.index,1);return Dt&&(Rt.splice(G.destination.index,0,Dt),L(ct,Rt)),!0},[Vr,ln,sn,$r,E,w,R,L,Qr,v]),Kn=(G,Le="top")=>s.jsx("div",{"data-split-exit-drop-index":G,className:`group/split-exit pointer-events-none absolute inset-x-0 z-10 h-2 ${Le==="top"?"-top-1":"-bottom-1"}`,children:s.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-1 top-1/2 h-px -translate-y-1/2 rounded-full bg-transparent transition-colors group-data-[active=true]/split-exit:bg-primary"})}),Lr=b.useCallback((G,Le,Ke)=>{if(Vn(G)||dn(G)||G.reason==="CANCEL")return;const ct=Le.find(ot=>ot.id===G.draggableId);if(!ct)return;const qe=hn.current;if(qe?.kind==="split"&&ct.kind==="session"){$r(ct.session.id,null,qe.groupId),E(qe.sessionId,ct.session.id);return}if(qe?.kind==="collaboration"&&ct.kind==="session"){$r(ct.session.id,null,qe.groupId);return}if(G.combine&&ct.kind!=="session"){const ot=Le.findIndex(Ot=>Ot.id===G.combine?.draggableId);if(ot<0)return;G={...G,combine:null,destination:{...G.source,index:ot}}}if(G.combine){const ot=Le.find(N=>N.id===G.combine?.draggableId);if(!ot)return;const Ot=ot.kind==="workspace"?ot:ct.kind==="workspace"?ct:ot,hr=Ot===ct?ot:ct,Zt=Ot.sessionIds[0],z=hr.sessionIds[0];Zt&&z&&Zt!==z&&E(Zt,z);return}if(!G.destination||G.source.index===G.destination.index)return;const At=[...Le],[Rt]=At.splice(G.source.index,1);if(!Rt)return;At.splice(G.destination.index,0,Rt);const Dt=At.flatMap(ot=>ot.sessionIds);if(Ke===void 0){R(Dt);return}R(sn.flatMap(ot=>ot.key===Ke?Dt:ot.sessions.map(Ot=>Ot.id)))},[sn,Vn,dn,$r,E,R]),Nr=b.useCallback(G=>{if(G.reason==="CANCEL"||Vn(G)||dn(G))return;if(G.type==="group"){if(!G.destination||G.source.index===G.destination.index)return;R(I3(sn,G.source.index,G.destination.index));return}const Le=G.source.droppableId.replace(/^group-sessions:/,""),Ke=sn.find(qe=>qe.key===Le);if(!Ke)return;const ct=E0(Ke.sessions,v,Qr,Vr);if(G.combine||hn.current?.kind==="collaboration"||hn.current?.kind==="split"){Lr(G,ct,Le);return}!G.destination||G.destination.droppableId!==G.source.droppableId||Lr(G,ct,Le)},[Vr,sn,Qr,v,Vn,Lr,dn,R]),xr=G=>{const Le=re===G.id,Ke=[{layout:"horizontal",label:_e("tab.splitHorizontal"),icon:_l},{layout:"vertical",label:_e("tab.splitVertical"),icon:t2},...G.sessionIds.length>=3||G.layout==="grid"?[{layout:"grid",label:_e("tab.splitGrid"),icon:e2}]:[]],ct=G.layout==="vertical"?t2:G.layout==="grid"?e2:_l,qe=Ke.find(At=>At.layout===G.layout)?.label??_e("tab.splitHorizontal");return s.jsxs("div",{ref:Le?An:void 0,className:"relative shrink-0",onPointerDown:At=>At.stopPropagation(),children:[s.jsx("button",{type:"button",className:`sidebar-session-action inline-flex h-6 w-6 items-center justify-center rounded-md transition active:scale-95 ${Le?"bg-primary/15 text-primary":"text-muted-foreground/70 hover:bg-surface-2 hover:text-foreground"}`,"aria-label":`${_e("tab.splitLayout")}: ${qe}`,"aria-haspopup":"menu","aria-expanded":Le,title:_e("tab.splitLayout"),onClick:At=>{At.stopPropagation(),Pe(Rt=>Rt===G.id?null:G.id)},children:s.jsx(ct,{size:12})}),Le&&s.jsx("div",{role:"menu","aria-label":_e("tab.splitLayout"),className:"absolute right-0 top-full z-30 mt-1 flex gap-0.5 rounded-md border border-border bg-surface-elevated p-1 shadow-lg",children:Ke.map(At=>{const Rt=At.icon,Dt=At.layout===G.layout;return s.jsx("button",{type:"button",role:"menuitemradio","aria-checked":Dt,"aria-label":At.label,title:At.label,className:`sidebar-session-action inline-flex h-7 w-7 items-center justify-center rounded-sm transition active:scale-95 ${Dt?"bg-primary/15 text-primary":"text-muted-foreground hover:bg-surface-2 hover:text-foreground"}`,onClick:ot=>{ot.stopPropagation(),k(G.sessionIds[0],At.layout),Pe(null)},children:s.jsx(Rt,{size:13})},At.layout)})})]})},os=(G,Le)=>Le&&s.jsx("button",{type:"button",...Le,"aria-label":G,title:G,onClick:Ke=>Ke.stopPropagation(),className:"absolute -left-2 inset-y-0 z-10 flex w-3 cursor-grab items-start justify-center pt-1.5 text-muted-foreground/60 transition hover:text-foreground focus-visible:text-foreground active:cursor-grabbing",children:s.jsx(If,{size:10})}),Hn=(G,Le,Ke=!1,ct=!1,qe)=>{if(Le.length<2)return null;const At=Le.some(Zt=>Zt.id===c),Rt=[],Dt=[],ot=[];for(const Zt of Le){const z=l.get(Zt.id);z?.agentStatus==="waiting"||z?.agentNeedsReview?Rt.push(Zt):z?.agentStatus==="working"?Dt.push(Zt):z?.inCopyMode&&ot.push(Zt)}const Ot=G.name?.trim()||`${_e("tab.splitWorkspace")} ${v.findIndex(Zt=>Zt.id===G.id)+1}`,hr=re===G.id;return s.jsxs("section",{"data-split-workspace":G.id,"aria-label":Ot,className:`group/split relative rounded-md p-0.5 before:pointer-events-none before:absolute before:inset-0 before:rounded-md before:border before:border-border transition-colors ${ct?"bg-primary/15 ring-1 ring-primary/40":Ke?"bg-surface-elevated opacity-90 shadow-lg":Rt.length>0?"bg-[rgb(var(--warning-rgb)_/_0.08)] hover:bg-[rgb(var(--warning-rgb)_/_0.12)]":Dt.length>0?"bg-[rgb(var(--success-rgb)_/_0.06)] hover:bg-[rgb(var(--success-rgb)_/_0.10)]":ot.length>0?"bg-[rgb(var(--tmux-rgb)_/_0.07)] hover:bg-[rgb(var(--tmux-rgb)_/_0.11)]":At?"bg-primary/[0.07]":"hover:bg-surface-2"}`,children:[os(`移动分屏组 ${Ot}`,qe),s.jsx(Sl,{droppableId:`split-members:${G.id}`,type:"split-member",direction:"vertical",children:(Zt,z)=>s.jsxs("div",{ref:Zt.innerRef,...Zt.droppableProps,"data-split-members":!0,className:z.isDraggingOver?"rounded-sm bg-primary/10 ring-1 ring-primary/40":"",children:[Le.map((N,$)=>s.jsx(Cl,{draggableId:`split-member:${N.id}`,index:$,disableInteractiveElementBlocking:!0,children:(ee,se)=>s.jsx("div",{ref:ee.innerRef,...ee.draggableProps,...B?cr(()=>B(N.id)):{},className:`${$===0&&hr?"relative z-20 ":"relative "}flex items-center rounded-sm pr-0.5 transition-colors ${se.isDragging?"bg-surface-elevated opacity-90 shadow-lg ":""}${Br(N.id)??(N.id===c?"bg-surface-elevated/80 text-foreground":"text-muted-foreground hover:bg-surface-2")}`,children:Zn(N,ee.dragHandleProps,!0,$===0?xr(G):void 0)})},N.id)),Zt.placeholder]})})]})},Nn=(G,Le,Ke,ct=!1,qe=!1)=>{const At=`collaboration:${G.id}`,Rt=Mr.has(At),Dt=`collaboration-members-${G.id}`,ot=Ie===G.id||!Ie&&Le.some(se=>se.id===c),Ot=S5(Vt,G.id),hr=G.sessionIds.filter(se=>Ot.has(se)&&se!==c&&!mn.has(se)),Zt=Nt[G.id]===!0,z=Zt?G.sessionIds:G.sessionIds.filter(se=>!hr.includes(se)),N=I0(z,v),$=N.flatMap(se=>se.sessionIds),ee=N.length===1?N[0]?.workspace:void 0;return s.jsxs("section",{"data-collaboration-group":G.id,"data-collaboration-group-name":G.name,"aria-label":`Agent 工作组:${G.name}`,className:`group/collaboration relative rounded-md ${Rt?"":"p-0.5 before:pointer-events-none before:absolute before:inset-0 before:rounded-md before:border before:border-border"} transition-colors data-[drop-active=true]:bg-primary/15 data-[drop-active=true]:ring-1 data-[drop-active=true]:ring-primary/40 ${qe?"bg-primary/15 ring-1 ring-primary/40":ct?"bg-surface-elevated opacity-90 shadow-lg":ot?"bg-primary/[0.07]":"hover:bg-surface-2"}`,children:[os(`移动工作组 ${G.name}`,Ke),s.jsxs("div",{className:"flex items-center",children:[s.jsx("button",{type:"button","aria-label":`${Rt?"展开":"收起"} ${G.name} 的成员会话`,"aria-expanded":!Rt,"aria-controls":Dt,title:`${Rt?"展开":"收起"}成员会话`,className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-surface-elevated hover:text-foreground focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary md:h-[30px] md:w-5",onClick:se=>{se.stopPropagation(),rn(At)},children:s.jsx(hi,{size:14,className:Rt?"":"rotate-90"})}),s.jsxs("button",{type:"button",className:"flex min-h-11 min-w-0 flex-1 items-center gap-1.5 rounded-sm px-1 text-left text-xs font-medium text-foreground transition hover:text-primary md:min-h-[30px]",title:`打开 ${G.name} 的协作工作区`,"aria-label":`打开协作工作区:${G.name}`,"aria-current":Ie===G.id?"page":void 0,onClick:se=>{se.stopPropagation(),pr(G.id)},children:[s.jsx(Vd,{size:14,className:"shrink-0 text-primary"}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:G.name}),at.some(se=>se.groupId===G.id)&&s.jsxs("span",{className:"shrink-0 text-[10px] font-normal text-primary",children:[at.filter(se=>se.groupId===G.id).length," 待处理"]})]}),s.jsx("button",{type:"button","aria-label":`成员与消息:${G.name}`,title:"在终端旁打开成员与消息",disabled:Ze!==null||!c&&!Le.length,"aria-busy":Ze===G.id,className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-surface-elevated hover:text-primary disabled:opacity-40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary md:h-[30px] md:w-7",onClick:se=>{se.stopPropagation(),!be.current&&(de(!1),be.current=!0,Je(G.id),q(null),QC(G.id,c??Le[0].id).catch(Qe=>q(Qe instanceof Error?Qe.message:"消息面板打开失败,请重试")).finally(()=>{be.current=!1,Je(null)}))},children:Ze===G.id?s.jsx(yn,{size:14,className:"animate-spin"}):s.jsx(Td,{size:14})})]}),s.jsx("div",{id:Dt,children:!Rt&&s.jsxs(s.Fragment,{children:[hr.length>0&&s.jsxs("button",{type:"button","aria-expanded":Zt,className:"flex min-h-11 w-full items-center gap-2 rounded-sm px-2 text-left text-[11px] text-muted-foreground hover:bg-surface-elevated md:min-h-8",title:"展开后可查看或归档执行会话,任务结果保留。",onClick:()=>gt(se=>({...se,[G.id]:!Zt})),children:[s.jsx(hi,{size:12,className:Zt?"rotate-90":""}),"已完成的执行会话 · ",hr.length]}),s.jsx(Sl,{droppableId:`collaboration-members:${G.id}`,type:"collaboration-member",direction:"vertical",isCombineEnabled:!0,children:(se,Qe)=>s.jsxs("div",{ref:se.innerRef,...se.droppableProps,"data-collaboration-members":!0,className:`${Qe.isDraggingOver?"rounded-sm bg-primary/10":""}`,children:[N.map(ze=>s.jsx("div",{"data-collaboration-split":ze.workspace?.id,"data-split-anchor":ze.workspace?.sessionIds[0],role:ze.workspace?"region":void 0,"aria-label":ze.workspace?`${_e("tab.splitWorkspace")} · ${ze.sessionIds.length}`:void 0,className:ze.workspace&&!ee?`relative my-0.5 rounded-sm before:pointer-events-none before:absolute before:inset-0 before:rounded-sm before:border before:border-border data-[drop-active=true]:ring-1 data-[drop-active=true]:ring-primary/40 ${ze.sessionIds.includes(c??"")?"bg-primary/[0.07]":"bg-surface/35"}`:void 0,children:ze.sessionIds.map(xt=>{const _t=Qr.get(xt);return _t?s.jsx(Cl,{draggableId:`collaboration-member:${_t.id}`,index:$.indexOf(_t.id),disableInteractiveElementBlocking:!0,children:(Fr,jt)=>s.jsxs("div",{ref:Fr.innerRef,...Fr.draggableProps,"data-collaboration-member":_t.id,"data-split-member":mn.has(_t.id)?"true":void 0,...B?cr(()=>B(_t.id)):{},className:`${ze.workspace&&xt===ze.sessionIds[0]&&re===ze.workspace.id?"z-20 ":""}relative flex items-center rounded-sm pr-0.5 transition-colors data-[drop-active=true]:bg-primary/15 data-[drop-active=true]:ring-1 data-[drop-active=true]:ring-primary/40 ${jt.combineTargetFor?"bg-primary/15 ring-1 ring-primary/40 ":jt.isDragging?"bg-surface-elevated opacity-90 shadow-lg ":""}${Br(_t.id)??(_t.id===c?"bg-surface-elevated/80 text-foreground":mn.has(_t.id)?"bg-primary/[0.05] text-muted-foreground hover:bg-primary/[0.09]":"text-muted-foreground hover:bg-surface-2")}`,children:[Zn(_t,Fr.dragHandleProps,!0,ze.workspace&&xt===ze.sessionIds[0]?xr(ze.workspace):void 0,Ot.has(xt)?s.jsxs("button",{type:"button","aria-label":`归档 ${_t.name}`,title:"保存 Agent 会话 ID 并停止终端;只回收干净的执行目录,结果和分支保留",disabled:er!==null,className:"sidebar-session-action inline-flex h-11 min-w-11 shrink-0 items-center justify-center gap-1 rounded-md px-2 text-muted-foreground hover:bg-primary/15 hover:text-primary disabled:opacity-40 md:h-6 md:min-w-6 md:px-1",onClick:qr=>{qr.stopPropagation(),!Ct.current&&(Ct.current=!0,et(xt),q(null),Ww(xt).then(async()=>{De(pn=>pn+1),await Wr()}).catch(pn=>q(pn instanceof Error?pn.message:"归档失败,终端已保留")).finally(()=>{Ct.current=!1,et(null)}))},children:[er===xt?s.jsx(yn,{size:13,className:"animate-spin"}):s.jsx(m3,{size:13}),s.jsx("span",{className:"text-[10px] md:sr-only",children:"归档"})]}):void 0),!ze.workspace&&mn.has(_t.id)&&s.jsx("button",{type:"button",className:"shrink-0 px-1 text-[10px] text-primary",title:`与 ${v.find(qr=>qr.sessionIds.includes(_t.id))?.sessionIds.filter(qr=>qr!==_t.id).map(qr=>Qr.get(qr)?.name??qr).join("、")} 分屏`,"aria-label":`查看 ${_t.name} 的跨组分屏`,onClick:()=>{de(!1),na.getState().terminal(),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:_t.id})),Or()},children:s.jsx(_l,{size:10})})]})},_t.id):null})},ze.workspace?.id??ze.sessionIds[0])),se.placeholder]})}),s.jsx(LB,{groupId:G.id,version:Ve,onRestore:async se=>{de(!1),window.dispatchEvent(new CustomEvent("new-terminal-session",{detail:{mode:"tmux",cwd:se.cwd,preferredFrontendSessionId:se.sessionId,requireExisting:!0}})),await Wr(),na.getState().terminal(),Or()}}),G.remoteSessions?.map(se=>s.jsxs("button",{type:"button",title:`${ec(se)} · ${se.serviceConnected===!1?"服务不可达,消息尚未送达":se.status}`,className:"flex w-full min-w-0 items-center gap-1.5 rounded-sm px-2 py-1 text-left text-[11px] text-muted-foreground hover:bg-surface-2",onClick:()=>{de(!1),e6(se.sessionId).catch(()=>{pr(G.id)})},children:[s.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${se.serviceConnected===!1?"bg-muted-foreground":"bg-primary"}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:se.name}),s.jsx("span",{className:"max-w-20 truncate rounded border border-border/20 px-1 text-[9px]",children:ec(se)}),se.serviceConnected===!1&&s.jsx("span",{className:"shrink-0 text-[9px]",children:"不可达"})]},se.sessionId))]})}),s.jsx("div",{"data-collaboration-background":!0,className:Rt?"absolute inset-0 pointer-events-none":"h-1.5"})]})},Rn=(G,Le,Ke)=>s.jsx(td,{onBeforeCapture:fs,onDragStart:kr,onDragEnd:ct=>Pn(qe=>Lr(qe,G,Ke),ct),children:s.jsx(Sl,{droppableId:Le,direction:"vertical",isCombineEnabled:!Hr,children:ct=>s.jsxs("div",{ref:ct.innerRef,...ct.droppableProps,"data-sidebar-entity-list-id":Le,className:"flex-1 space-y-0.5",children:[G.map((qe,At)=>s.jsx(Cl,{draggableId:qe.id,index:At,disableInteractiveElementBlocking:!0,children:(Rt,Dt)=>s.jsxs("div",{ref:Rt.innerRef,...Rt.draggableProps,"data-sidebar-gesture-ignore":!0,"data-sidebar-entity-index":At,className:"relative",children:[Kn(At),At===G.length-1&&Kn(G.length,"bottom"),qe.kind==="workspace"?Hn(qe.workspace,qe.members,Dt.isDragging,!!Dt.combineTargetFor,Rt.dragHandleProps):qe.kind==="collaboration"?Nn(qe.group,qe.members,Rt.dragHandleProps,Dt.isDragging,!!Dt.combineTargetFor):s.jsx("div",{...B?cr(()=>B(qe.session.id)):{},className:`group relative flex items-center gap-1 rounded-md pr-1 transition-colors ${Dt.combineTargetFor?"bg-primary/15 text-foreground ring-1 ring-primary/40":Dt.isDragging?"bg-surface-elevated text-foreground opacity-90 shadow-lg":Br(qe.session.id)??(!Ie&&qe.session.id===c?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2")} cursor-grab active:cursor-grabbing`,children:Zn(qe.session,Rt.dragHandleProps)})]})},qe.id)),ct.placeholder]})})}),ps=s.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[s.jsxs("div",{"data-session-sidebar-header":!0,className:"relative z-20 shrink-0 px-3 py-0.5",children:[s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-3 bottom-0 z-10 h-px bg-border opacity-40"}),s.jsxs("div",{className:"flex w-full items-center gap-1.5",children:[s.jsx("div",{className:"min-w-0 flex-1",children:s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-[12px] font-medium text-muted-foreground",children:_e("sidebar.sessions")}),s.jsx("span",{className:"text-[11px] text-muted-foreground",children:a.length}),Kr>0&&s.jsx("span",{className:"ml-0.5 flex items-center",children:s.jsx(g6,{count:Kr,tone:"running",title:_e("agent.aiRunning")})})]})}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsx("button",{"data-session-sidebar-header-action":!0,type:"button",onClick:()=>{de(!1),pr(null)},className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-primary/15 hover:text-primary active:scale-95","aria-label":"Agent 工作台",title:"Agent 工作台",children:s.jsx(Vd,{size:16})}),(!ke||$e)&&s.jsx("button",{"data-session-sidebar-header-action":!0,type:"button",onClick:r,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-destructive/20 hover:text-destructive active:scale-95","aria-label":_e("common.close"),children:s.jsx(Qn,{size:16})})]})]})]}),ft&&s.jsxs("div",{role:"alert",className:"mx-2 mt-2 flex items-start gap-2 rounded-lg bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:[s.jsx("span",{className:"min-w-0 flex-1",children:ft}),s.jsx("button",{type:"button","aria-label":"关闭协作错误提示",className:"shrink-0",onClick:()=>q(null),children:s.jsx(Qn,{size:14})})]}),s.jsxs("div",{ref:ne,className:"relative z-10 flex min-h-0 flex-1 flex-col overflow-y-auto overscroll-contain px-1.5 pt-0.5 pb-1.5",children:[(at.length>0||bt)&&s.jsxs("section",{className:"mb-2 rounded-lg border border-primary/20 bg-primary/5","aria-label":"协作待处理事项",children:[s.jsxs("button",{type:"button",className:"flex min-h-11 w-full items-center gap-2 px-3 text-left text-xs text-primary","aria-expanded":It,onClick:()=>yt(G=>!G),children:[s.jsx(Vd,{size:14}),s.jsx("span",{className:"min-w-0 flex-1",children:"需要你处理"}),s.jsx("span",{children:at.length}),s.jsx(hi,{size:12,className:It?"rotate-90":""})]}),It&&s.jsxs("div",{className:"space-y-1 p-1 pt-0",children:[bt&&s.jsxs("p",{role:"alert",className:"px-2 py-2 text-[11px] text-destructive",children:[bt,s.jsx("button",{type:"button",className:"ml-2 text-primary",onClick:()=>{mu.getState().refresh()},children:"重试"})]}),at.map(G=>s.jsxs("button",{type:"button",className:"min-h-11 w-full rounded-md px-2 py-2 text-left hover:bg-surface-2",onClick:()=>{_5(G.groupId,G.id),pr(G.groupId).then(Le=>{Le&&_5(G.groupId,G.id)})},children:[s.jsx("span",{className:"block truncate text-xs text-foreground",children:G.title}),s.jsxs("span",{className:"mt-1 block truncate text-[10px] text-muted-foreground",children:[nr.find(Le=>Le.id===G.groupId)?.name??"协作组"," · ",Qc(G)]})]},G.id))]})]}),s.jsx(EO,{sessions:Ae,loading:lt,attachingName:pe,onRefresh:Ce,onRestore:K,onClose:ye}),Vr.filter(G=>!G.sessionIds.length).map(G=>s.jsx(td,{onDragEnd:()=>{},children:Nn(G,[])},G.id)),a.length===0?s.jsxs("div",{className:"rounded-xl bg-surface-2/60 px-4 py-8 text-center",children:[s.jsx(Bo,{size:26,className:"mx-auto mb-2 text-muted-foreground"}),s.jsx("p",{className:"text-[12px] text-muted-foreground",children:_e("sidebar.noSessions")})]}):Sr.length===0&&v.length===0?s.jsx("div",{className:"rounded-xl bg-surface-2/60 px-4 py-6 text-center",children:s.jsx("p",{className:"text-[12px] text-muted-foreground",children:_e("sidebar.noMatchingSessions")})}):wt?s.jsx("div",{className:"flex flex-1 flex-col",children:s.jsx(td,{onBeforeCapture:fs,onDragStart:kr,onDragEnd:G=>Pn(Nr,G),children:s.jsx(Sl,{droppableId:"sidebar-groups",type:"group",direction:"vertical",children:G=>s.jsxs("div",{ref:G.innerRef,...G.droppableProps,className:"flex flex-1 flex-col space-y-1.5",children:[sn.map((Le,Ke)=>{const ct=Mr.has(Le.key),qe=!ct&&Ke===sn.length-1,At=E0(Le.sessions,v,Qr,Vr);let Rt=0,Dt=0;for(const Ot of Le.sessions){const hr=l.get(Ot.id);hr?.agentStatus==="working"&&(Rt+=1),(hr?.agentStatus==="waiting"||hr?.agentNeedsReview)&&(Dt+=1)}const ot=Le.key==="";return s.jsx(Cl,{draggableId:`sidebar-group:${Le.key||"__ungrouped__"}`,index:Ke,isDragDisabled:ot,disableInteractiveElementBlocking:!0,children:(Ot,hr)=>s.jsxs("div",{ref:Ot.innerRef,...Ot.draggableProps,className:`shrink-0 rounded-md transition-colors ${qe?"flex flex-1 flex-col ":""}${hr.isDragging?"bg-surface-elevated shadow-lg opacity-90":""}`,children:[s.jsxs("button",{type:"button",...ot?{}:Ot.dragHandleProps,onClick:()=>{rn(Le.key),Sn.current.delete(Le.key)},className:`flex w-full shrink-0 items-center gap-1.5 rounded-md px-1.5 py-1 text-left text-muted-foreground transition hover:bg-surface-2 ${ot?"":"cursor-grab active:cursor-grabbing"}`,title:Le.key||Le.label,children:[s.jsx(hi,{size:13,className:`shrink-0 transition-transform ${ct?"":"rotate-90"}`}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-[11.5px] font-semibold uppercase tracking-wide",children:Le.label}),Rt>0&&s.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--success)] animate-pulse"}),Dt>0&&s.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--warning)] animate-pulse"}),s.jsx(k5,{sessionIds:Le.sessions.map(Zt=>Zt.id)}),s.jsx("span",{className:"shrink-0 text-[10.5px] text-muted-foreground/70",children:Le.sessions.length})]}),!ct&&s.jsx("div",{className:`mt-0.5 pl-2 ${qe?"flex flex-1 flex-col":""}`,children:s.jsx(Sl,{droppableId:`group-sessions:${Le.key}`,type:"session",direction:"vertical",isCombineEnabled:!Hr,children:Zt=>s.jsxs("div",{ref:Zt.innerRef,...Zt.droppableProps,"data-sidebar-entity-list-id":`group-sessions:${Le.key}`,className:`${qe?"flex-1 ":""}space-y-0.5`,children:[At.map((z,N)=>s.jsx(Cl,{draggableId:z.id,index:N,disableInteractiveElementBlocking:!0,children:($,ee)=>s.jsxs("div",{ref:$.innerRef,...$.draggableProps,"data-sidebar-gesture-ignore":!0,"data-sidebar-entity-index":N,className:"relative",children:[Kn(N),N===At.length-1&&Kn(At.length,"bottom"),z.kind==="workspace"?Hn(z.workspace,z.members,ee.isDragging,!!ee.combineTargetFor,$.dragHandleProps):z.kind==="collaboration"?Nn(z.group,z.members,$.dragHandleProps,ee.isDragging,!!ee.combineTargetFor):s.jsx("div",{...B?cr(()=>B(z.session.id)):{},className:`group relative flex items-center gap-1 rounded-md pr-1 transition-colors ${ee.combineTargetFor?"bg-primary/15 text-foreground ring-1 ring-primary/40":ee.isDragging?"bg-surface-elevated text-foreground opacity-90 shadow-lg":Br(z.session.id)??(!Ie&&z.session.id===c?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-2")} cursor-grab active:cursor-grabbing`,children:Zn(z.session,$.dragHandleProps)})]})},z.id)),Zt.placeholder]})})})]})},Le.key||"__ungrouped__")}),G.placeholder]})})})}):Rn(ln,"sidebar-entities")]}),s.jsx(Uw,{onReselect:()=>{h&&(ht.current=null,je(G=>G+1),h())}}),Se&&s.jsx(FP,{directories:a.flatMap(G=>{const Le=l.get(G.id)?.cwd;return Le?[Le]:[]}),tmuxAvailable:fe,options:un,launchPending:Be,launchError:oe?_e(Rm(oe)):null,agents:Gr,selectedAgent:me,detecting:it,resumeHistory:Wt,resumeHistoryLoading:vt,resumeHistoryPendingId:Qt,resumeHistoryError:Ut,onRefreshAgents:()=>{dt().catch(()=>{})},onSelectAgent:G=>{sr(G).catch(()=>{})},onLaunchAgent:Ue,onResumeHistory:G=>{Et(G)},onRemoveResumeHistory:G=>{kt(G)},onClose:()=>de(!1),onOptionsChange:Ir,additionalContent:on&&U?.latestVersion&&s.jsxs("div",{className:"mb-1 rounded-lg bg-[rgb(var(--warning-rgb)_/_0.10)] px-2.5 py-2.5 text-foreground",children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"mt-0.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-[rgb(var(--warning-rgb)_/_0.16)] text-[color:var(--warning)]",children:s.jsx(yn,{size:13,className:U.status==="installing"||U.status==="restarting"?"animate-spin":""})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-semibold",children:_e("sidebar.updateAvailable",{version:U.latestVersion})}),s.jsx("span",{className:"mt-0.5 block text-[10.5px] leading-relaxed text-muted-foreground",children:U.status==="installing"?_e("sidebar.updateInstalling"):U.status==="ready"?_e("sidebar.updateReady"):U.status==="restarting"?_e("sidebar.updateRestarting"):_e("sidebar.updateFailed")})]})]}),U.status==="ready"&&Z&&s.jsx("button",{type:"button",disabled:V,onClick:Z,className:"mt-2 flex w-full items-center justify-center rounded-md bg-[var(--warning)] px-2 py-1.5 text-[11px] font-semibold text-[color:var(--bg)] transition hover:opacity-90 disabled:cursor-wait disabled:opacity-60",children:_e("sidebar.updateRestart")}),U.status==="error"&&le&&s.jsx("button",{type:"button",disabled:V,onClick:le,className:"mt-2 flex w-full items-center justify-center rounded-md bg-surface-elevated px-2 py-1.5 text-[11px] font-semibold text-foreground transition hover:bg-surface-2 disabled:cursor-wait disabled:opacity-60",children:_e("sidebar.updateRetry")})]}),footerActions:s.jsx(kO,{serverAttention:Me,onOpenSettings:()=>{de(!1),W()},actions:[...F?[{label:_e("sidebar.subscriptionQuota"),icon:TA,onSelect:()=>{de(!1),F()}}]:[],{label:"Agent 工作台",icon:Vd,onSelect:()=>{de(!1),pr(null)}},{label:"服务与设备",icon:zw,onSelect:()=>{de(!1),Hw()}},...Y?[{label:_e($e?"sidebar.unpinSidebar":"sidebar.pinSidebar"),icon:$e?od:ad,separated:!0,onSelect:()=>{de(!1),Y()}}]:[]]})}),Ye&&s.jsx(fb,{onEnterGroup:async G=>{if(!await pr(G))throw new Error("协作组已保存,打开工作区失败,请重试");st(!1)},onFloatingChange:async G=>{if(G){if(!await pr(G))throw new Error("打开协作工作区失败");st(!1)}},activeSessionId:c,defaultSessionMode:te,onClose:()=>st(!1),onNewSession:G=>p(G)}),Object.entries(We).map(([G,Le])=>s.jsx(fb,{activeSessionId:c,initialCollaborationGroupId:G,initialFloating:Le,visible:!Ie,onEnterGroup:async Ke=>{if(Ke===G){await pr(Ke);return}if(!await pr(Ke))throw new Error("协作组已保存,打开工作区失败,请重试");await co({floatingGroupId:null},G),Te(ct=>{const qe={...ct};return delete qe[G],qe})},onFloatingChange:Ke=>Tt(G,Ke),defaultSessionMode:te,onClose:()=>{ae.current=!0,Te(Ke=>{const ct={...Ke};return delete ct[G],ct})},onNewSession:Ke=>p(Ke)},G)),!Se&&s.jsxs("div",{className:"relative z-10 shrink-0 bg-[var(--chrome-bg)] px-3 pb-3 pt-1 md:border-t md:border-border md:p-2",children:[oe&&s.jsx("p",{role:"alert",className:"mb-2 text-[11px] leading-relaxed text-destructive",children:_e(Rm(oe))}),s.jsxs("div",{className:`grid gap-1.5 [&>button]:min-h-11 [&>button]:shadow-none [&>button]:ring-0 md:[&>button]:min-h-0 ${me?"grid-cols-[minmax(0,1fr)_minmax(0,1fr)_2.5rem]":"grid-cols-[minmax(0,1fr)_2.5rem]"}`,children:[s.jsxs("button",{type:"button",onClick:Xr,disabled:Be,"aria-busy":Be,className:`flex min-w-0 items-center justify-center gap-2 rounded-lg px-2 py-2.5 text-[12px] font-semibold transition active:scale-[0.99] ${me?"bg-surface-elevated text-foreground ring-1 ring-border/30 hover:bg-surface-2":"bg-primary text-primary-foreground ring-1 ring-primary/40 shadow-md shadow-primary/25 hover:bg-primary/90"}`,title:_e("sidebar.newSession"),"aria-label":_e("sidebar.newSession"),children:[s.jsx(Bo,{size:15,className:"shrink-0"}),s.jsx("span",{className:"truncate",children:Be?_e("sidebar.sessionCreating"):"Terminal"})]}),me&&s.jsxs("button",{type:"button",onClick:fn,disabled:Be,"aria-busy":Be,className:"flex min-w-0 items-center justify-center gap-2 rounded-lg bg-primary px-2 py-2.5 text-[12px] font-semibold text-primary-foreground ring-1 ring-primary/40 shadow-md shadow-primary/25 transition hover:bg-primary/90 active:scale-[0.99]",title:_e("sidebar.newSessionWithAgent",{agent:me.displayName}),"aria-label":_e("sidebar.newSessionWithAgent",{agent:me.displayName}),children:[s.jsx(Mc,{agent:me,size:15}),s.jsx("span",{className:"truncate",children:me.displayName})]}),s.jsxs("button",{type:"button",onClick:tr,disabled:Be,className:"relative inline-flex w-10 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-[0.97]",title:nt,"aria-label":nt,"aria-expanded":Se,"aria-controls":"sidebar-launch-options",children:[s.jsx(Qo,{size:15}),Me&&s.jsx("span",{className:"absolute right-0.5 top-0.5 h-2 w-2 rounded-full bg-destructive ring-2 ring-[var(--chrome-bg)]","aria-hidden":"true"}),on&&s.jsx("span",{className:`absolute top-0.5 h-2 w-2 rounded-full bg-[var(--warning)] ring-2 ring-[var(--chrome-bg)] ${Me?"right-3.5":"right-0.5"}`,"aria-hidden":"true"})]})]})]})]});return $e?s.jsx("div",{"data-session-sidebar-pinned":!0,className:"h-full flex flex-col app-chrome-bg border-r border-border",children:ps}):s.jsx(f6,{side:"left",isOpen:e,drawerWidthPx:t,onClose:r,onOpen:n,push:ke,children:ps})}function MO(){const{t:e}=zr();return s.jsxs("div",{role:"status","aria-label":e("rightSidebar.loadingGitChanges"),className:"td-loading-skeleton flex h-full min-h-0 flex-col overflow-hidden bg-surface",children:[s.jsx("span",{className:"sr-only",children:e("rightSidebar.loadingGitChanges")}),s.jsxs("div",{"aria-hidden":"true",className:"shrink-0 border-b border-border/15 px-3 py-2",children:[s.jsxs("div",{className:"mb-2 flex h-5 items-center gap-1",children:[s.jsx("div",{className:"h-4 w-16 rounded bg-surface-2"}),s.jsx("div",{className:"h-4 w-7 rounded bg-surface-2"}),s.jsx("div",{className:"h-4 w-12 rounded bg-surface-2"})]}),s.jsxs("div",{className:"flex h-[15px] items-center justify-between",children:[s.jsx("div",{className:"h-2 w-14 rounded bg-surface-2"}),s.jsx("div",{className:"h-2 w-6 rounded bg-surface-2"})]}),s.jsxs("div",{className:"mt-2 flex h-7 items-center gap-1.5",children:[s.jsx("div",{className:"h-7 w-12 rounded-full bg-surface-2"}),s.jsx("div",{className:"h-7 w-16 rounded-full bg-surface-2"}),s.jsx("div",{className:"h-3 w-24 max-w-[30%] rounded bg-surface-2"}),s.jsx("div",{className:"ml-auto h-4 w-4 rounded-full bg-surface-2"})]})]}),s.jsxs("div",{"aria-hidden":"true",className:"overflow-hidden px-3 py-2",children:[s.jsxs("div",{className:"flex h-8 items-center gap-2",children:[s.jsx("div",{className:"h-3 w-3 rounded-sm bg-surface-2"}),s.jsx("div",{className:"h-2 w-32 max-w-[55%] rounded bg-surface-2"})]}),["w-3/5","w-2/5","w-1/2","w-1/3"].map((t,r)=>s.jsxs("div",{className:"flex h-9 items-center gap-2 pl-5",style:{opacity:1-r*.15},children:[s.jsx("div",{className:"h-3 w-3 shrink-0 rounded-sm bg-surface-2"}),s.jsx("div",{className:`h-2 rounded bg-surface-2 ${t}`})]},t))]})]})}function jO({slow:e=!1}){const{t}=zr();return s.jsxs("div",{role:"status","aria-label":t("rightSidebar.loadingGitChanges"),className:"td-loading-skeleton relative h-full min-h-0 overflow-hidden bg-surface px-3",children:[s.jsx("span",{className:"sr-only",children:t("rightSidebar.loadingGitChanges")}),s.jsxs("div",{"aria-hidden":"true",children:[s.jsxs("div",{className:"flex h-[76px] items-center gap-2 border-b border-border/40 px-2",children:[s.jsx("div",{className:"h-6 w-6 rounded-md bg-surface-2"}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"h-3 w-16 rounded bg-surface-2"}),s.jsx("div",{className:"h-2 w-12 rounded bg-surface-2"})]})]}),s.jsxs("div",{className:"flex h-11 items-center gap-2 px-1 pt-3",children:[s.jsx("div",{className:"h-6 w-6 rounded-md bg-surface-2"}),s.jsx("div",{className:"h-3 w-16 rounded bg-surface-2"}),s.jsx("div",{className:"ml-auto h-4 w-12 rounded-full bg-surface-2"})]}),[!1,!0].map(r=>s.jsxs("div",{className:"border-b border-border/40 px-1 py-4",children:[s.jsxs("div",{className:"mb-2 flex h-8 items-center justify-between",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"h-3 w-14 rounded bg-surface-2"}),r&&s.jsx("div",{className:"h-2 w-28 rounded bg-surface-2"})]}),s.jsx("div",{className:"h-8 w-12 rounded-md bg-surface-2"})]}),s.jsx("div",{className:"h-10 rounded-md bg-surface-2"})]},String(r))),s.jsx("div",{className:"flex h-[69px] items-center border-b border-border/40 px-2",children:s.jsx("div",{className:"h-3 w-16 rounded bg-surface-2"})}),s.jsxs("div",{className:"space-y-2 px-1 py-4",children:[s.jsxs("div",{className:"flex h-8 items-center justify-between",children:[s.jsx("div",{className:"h-3 w-14 rounded bg-surface-2"}),s.jsx("div",{className:"h-8 w-28 rounded-md bg-surface-2"})]}),s.jsx("div",{className:"h-7 rounded-md bg-surface-2"}),s.jsx("div",{className:"h-10 rounded-md bg-surface-2"})]})]}),e&&s.jsx("div",{className:"absolute inset-x-3 bottom-3 rounded-md bg-surface-elevated px-3 py-2 text-xs text-muted-foreground",children:t("rightSidebar.loadingGitChangesSlow")})]})}const L6=()=>kc(()=>import("./RightSidebar-BoNzpS2K.js").then(e=>e.R),__vite__mapDeps([7,1,2,3,4,5,8,9,10,11,12,13,14,15,16,17])).then(e=>({default:e.RightSidebar})),DO=b.lazy(L6);function Ab(e){const t=b.useRef(!1);b.useEffect(()=>{const p=navigator.connection;if(!(p?.saveData||/2g|3g/.test(p?.effectiveType??"")))return E1(()=>{L6().catch(()=>{})},3e3)},[]);const{t:r}=zr(),n=Gt(p=>p.rootPath),a=Gt(p=>p.rightTab),c=Gt(p=>p.setRightTab),l=n?.replace(/\/+$/,"").split("/").pop()||r("rightSidebar.workspace");(e.isOpen||e.pinned)&&(t.current=!0);const h=s.jsx(f6,{side:"right",isOpen:e.isOpen,drawerWidthPx:e.drawerWidthPx,onClose:e.onClose,onOpen:e.onOpen,pinned:e.pinned,children:s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[s.jsxs("div",{className:"shrink-0 border-b border-border/15 bg-surface px-2 pt-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"min-w-0 flex-1 px-1",children:s.jsx("div",{className:"flex min-h-[1.25rem] items-baseline gap-1.5",children:s.jsx("span",{className:"truncate text-[13px] font-semibold text-foreground",children:l})})}),s.jsx("div",{"aria-hidden":"true",className:"flex items-center gap-1.5",children:[El,BT,Qo].map((p,m)=>s.jsx("span",{className:"inline-flex h-8 w-8 items-center justify-center rounded-full bg-surface-2 text-muted-foreground",children:s.jsx(p,{size:14})},m))}),s.jsx("button",{type:"button",onClick:e.onClose,"aria-label":r("common.close"),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",children:s.jsx(Qn,{size:14})})]}),s.jsx("div",{className:"mt-2 grid grid-cols-5 gap-0.5 rounded-md bg-surface-2 p-0.5",children:[["git",nA,"rightSidebar.tabGit"],["diff",iA,"rightSidebar.tabChanges"],["files",jc,"rightSidebar.tabFiles"],["architecture",wT,"architecture.tab"],["computer",Vw,"rightSidebar.tabComputer"]].map(([p,m,x])=>s.jsxs("button",{type:"button",onClick:()=>c(p),className:`flex items-center justify-center gap-1 rounded px-2 py-1.5 text-[11px] font-medium ${a===p?"bg-surface-elevated text-foreground":"text-muted-foreground"}`,children:[s.jsx(m,{size:12}),r(x)]},p))}),s.jsx("div",{className:"h-2"})]}),s.jsx("div",{className:"min-h-0 flex-1 bg-surface",children:a==="architecture"?s.jsx("div",{role:"status",className:"p-3 text-xs text-muted-foreground",children:r("architecture.loading")}):a==="computer"?s.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:r("computer.loading")}):a==="git"?s.jsx(jO,{}):s.jsx(MO,{})})]})});return t.current?s.jsx(b.Suspense,{fallback:h,children:s.jsx(DO,{...e})}):h}const Tb=rc(e=>({overlay:"off",setOverlay:t=>e({overlay:t})}));function BO(e){let t=1,r="terminal";for(;;){let n=!1;for(const a of e.values())if(a.name===r){n=!0;break}if(!n)break;r=`terminal-${t}`,t++}return r}const QO=rc((e,t)=>({sessions:new Map,activeSessionId:null,nextSessionNumber:1,createSession:r=>{const n=j3(),a=Date.now(),c=t().sessions,l=BO(c),h={id:n,cwd:r,sessionId:null,name:l,customName:!1,createdAt:a,lastActivity:a};return e(p=>{const m=new Map(p.sessions);return m.set(n,h),{sessions:m,activeSessionId:p.activeSessionId??n,nextSessionNumber:p.nextSessionNumber+1}}),n},closeSession:r=>{e(n=>{const a=new Map(n.sessions),c=n.activeSessionId===r;a.delete(r);let l=n.activeSessionId;if(c){const h=Array.from(a.keys());l=h.length>0?h[0]:null}return{sessions:a,activeSessionId:l}})},switchSession:r=>{e(n=>n.sessions.has(r)?{activeSessionId:r}:n)},updateSession:(r,n)=>{e(a=>{const c=a.sessions.get(r);if(!c)return a;const l=new Map(a.sessions);return l.set(r,{...c,...n,lastActivity:Date.now()}),{sessions:l}})},setTerminalSession:(r,n)=>{t().updateSession(r,{sessionId:n.sessionId})},getActiveSession:()=>{const r=t();if(r.activeSessionId)return r.sessions.get(r.activeSessionId)},getSessionCount:()=>t().sessions.size,clearAllSessions:()=>{e({sessions:new Map,activeSessionId:null,nextSessionNumber:1})}})),PO=[7e5,1e6,14e5,18e5,24e5,32e5,4e6,5e6,6e6,8e6,1e7,12e6].map(e=>({id:"auto",maxSize:1600,bitRate:e,maxFps:30}));class OO{level=6;badSince=null;goodSince=null;connectedAt=0;lastSample=-1/0;lastChange=-1/0;lastUpgrade=-1/0;upgradeAfter=0;failedProbes=0;baselineRtt=1/0;get quality(){return PO[this.level]}connected(t){this.connectedAt=t,this.badSince=this.goodSince=null,this.lastSample=-1/0}sample(t,r,n=1600){if(r-this.lastSample>2500&&(this.badSince=this.goodSince=null),this.lastSample=r,t.rttMs!==null&&(this.baselineRtt=Math.min(this.baselineRtt,t.rttMs)),r-this.connectedAt<3e3)return null;const a=t.rttMs!==null&&t.rttMs>this.baselineRtt+150,c=t.deliveryDelayMs>250||t.decodeQueue>=4||a&&t.frames>0&&t.deliveryDelayMs>100,l=t.deliveryDelayMs>800||t.decodeQueue>=8,h=t.rttMs!==null&&t.rttMs<this.baselineRtt+100&&t.deliveryDelayMs<80&&t.decodeQueue<=1;this.badSince=c?this.badSince??r:null,this.goodSince=h?this.goodSince??r:null;const p=n<=1080?7:n<=1600?9:11;if(this.badSince!==null&&r-this.badSince>=(l?1e3:2e3)&&r-this.lastChange>=(l?2e3:3e3)&&this.level>0){this.level=Math.max(0,this.level-(l?2:1));const m=r-this.lastUpgrade<2e4;this.failedProbes=m?this.failedProbes+1:0,this.upgradeAfter=r+(m?Math.min(3e4,8e3*2**(this.failedProbes-1)):5e3),this.lastUpgrade=-1/0}else if(this.goodSince!==null&&r-this.goodSince>=3e3&&r-this.lastChange>=4e3&&r>=this.upgradeAfter&&this.level<p)this.level++,this.lastUpgrade=r;else return null;return this.lastChange=r,this.badSince=this.goodSince=null,this.quality}}async function Fc(e,t){const r=await fetch(e,{...t,headers:{"Content-Type":"application/json",Accept:"application/json",...t?.headers??{}}}),n=await r.json().catch(()=>null);if(!r.ok||!n){const a=n?.error||n?.code||`ANDROID_REQUEST_FAILED_${r.status}`;throw new Error(a)}return n}async function FO(){return Fc("/api/android/devices")}async function $O(e){return Fc("/api/android/connect",{method:"POST",body:JSON.stringify({address:e})})}const Lf=[{id:"low",maxSize:720,bitRate:12e5,maxFps:30},{id:"medium",maxSize:1080,bitRate:4e6,maxFps:30},{id:"high",maxSize:1600,bitRate:8e6,maxFps:60}],yd=Lf[1];function w1(e){if(!e||typeof e!="object")return yd;const t=e;if(t.id==="auto")return{id:"auto",maxSize:1600,bitRate:4e6,maxFps:30};const r=Lf.find(l=>l.id===t.id);if(r)return r;if(t.id!=="custom")return yd;const n=typeof t.maxSize=="number"?Math.max(360,Math.min(2160,Math.round(t.maxSize))):1080,a=typeof t.bitRate=="number"?Math.max(3e5,Math.min(3e7,Math.round(t.bitRate))):4e6,c=typeof t.maxFps=="number"?Math.max(0,Math.min(60,Math.round(t.maxFps))):30;return{id:"custom",maxSize:n,bitRate:a,maxFps:c}}function UO(e,t){if(!/^[0-9a-zA-Z_.:\-]{1,128}$/.test(e))throw new Error("INVALID_SERIAL");const r=new URLSearchParams;t&&(r.set("max_size",String(t.maxSize)),r.set("bit_rate",String(t.bitRate)),t.maxFps>0&&r.set("max_fps",String(t.maxFps)));const n=r.toString();return`/api/android/${e}/ws${n?`?${n}`:""}`}function Cb(e){const t={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[r,n]of Object.entries(t))if(e.includes(r))return n;return e}function zO(e){return Fc(`/api/android/recordings?serial=${encodeURIComponent(e)}`)}function HO(e){return Fc("/api/android/recordings",{method:"POST",body:JSON.stringify({serial:e})})}function WO(e){return Fc(`/api/android/recordings/${encodeURIComponent(e)}/stop`,{method:"POST"})}function GO(e,t){return Fc(`/api/android/recordings/${encodeURIComponent(e)}/save`,{method:"POST",body:JSON.stringify({directory:t})})}function VO(e){return Fc(`/api/android/recordings/${encodeURIComponent(e)}`,{method:"DELETE"})}const qO=0,YO=1,ZO=2,KO=3,XO=4,JO=5,eF=7,tF=10,rF=11,nF=16,Sb=17,_b=0,bm=1,sF=2,kb=3,ym=0,Lb=1,Ib=1,uu=0xffffffffffffffffn,wh=0xfffffffffffffffen,N0={HOME:3,APP_SWITCH:187,POWER:26,VOLUME_UP:24,VOLUME_DOWN:25};function I6(e,t,r){e.setUint32(t,Math.max(0,Math.round(r.x))&4294967295),e.setUint32(t+4,Math.max(0,Math.round(r.y))&4294967295),e.setUint16(t+8,Math.min(65535,Math.round(r.screenWidth))),e.setUint16(t+10,Math.min(65535,Math.round(r.screenHeight)))}function iF(e,t,r,n,a,c){const l=new Uint8Array(32),h=new DataView(l.buffer);return h.setUint8(0,ZO),h.setUint8(1,e),h.setBigUint64(2,t),I6(h,10,r),h.setUint16(22,Math.max(0,Math.min(65535,Math.round(n*65536)))),h.setUint32(24,a>>>0),h.setUint32(28,c>>>0),l}function vm(e,t,r=0,n=0){const a=new Uint8Array(14),c=new DataView(a.buffer);return c.setUint8(0,qO),c.setUint8(1,e),c.setUint32(2,t>>>0),c.setUint32(6,r>>>0),c.setUint32(10,n>>>0),a}function aF(e,t,r,n=0){const a=new Uint8Array(21),c=new DataView(a.buffer);c.setUint8(0,KO),I6(c,1,e);const l=h=>Math.max(-32768,Math.min(32767,Math.round(Math.max(-1,Math.min(1,h/16))*32768)));return c.setInt16(13,l(t)),c.setInt16(15,l(r)),c.setUint32(17,n>>>0),a}function oF(e){const t=new TextEncoder().encode(e);if(!t.length)return null;const r=t.subarray(0,300),n=new Uint8Array(5+r.length),a=new DataView(n.buffer);return a.setUint8(0,YO),a.setUint32(1,r.length),n.set(r,5),n}function lF(e){const t=new TextEncoder().encode(e);if(!t.length||t.length>255)return null;const r=new Uint8Array(2+t.length);return r[0]=nF,r[1]=t.length,r.set(t,2),r}function R0(e){return new Uint8Array([e])}function Eb(e){return new Uint8Array([XO,e])}function cF(e){return new Uint8Array([tF,e?1:0])}function uF(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t)}function dF(e){const t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function wm(e){return e.toString(16).padStart(2,"0")}function E6(e,t,r){for(let n=0;n+4<e.length;n++){const a=e[n]===0&&e[n+1]===0&&e[n+2]===1,l=e[n]===0&&e[n+1]===0&&e[n+2]===0&&e[n+3]===1?n+4:a?n+3:-1;if(l<0||l>=e.length)continue;if((r?e[l]>>1&63:e[l]&31)!==t){n=l-1;continue}let p=l+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(l,Math.min(e.length,p))}return null}function hF(e){const t=e?E6(e,7,!1):null;return t&&t.length>=4?`avc1.${wm(t[1])}${wm(t[2])}${wm(t[3])}`:"avc1.42e01e"}function fF(e){const t=e?E6(e,32,!0):null;if(t&&t.length>=13){const r=t[1]>>6&3,n=t[1]&31,a=t[12];return`hev1.${r}.${n}.L${a}.B0`}return"hev1.1.6.L120.B0"}class pF{constructor(t,r){this.canvas=t,this.callbacks=r}canvas;callbacks;liveBitrate=!1;bitrateFailureDetail;get lastBitrateFailure(){return this.bitrateFailureDetail}bitrateRequestId=0;bitratePending=null;get supportsLiveBitrate(){return this.liveBitrate}get canSetBitrate(){return this.liveBitrate&&!this.bitratePending&&this.socket?.readyState===1}setBitrate(t){return!this.canSetBitrate||!Number.isInteger(t)||t<3e5||t>3e7?Promise.resolve(!1):new Promise(r=>{const n=++this.bitrateRequestId,a=setTimeout(()=>this.finishBitrate(!1,`BITRATE_CLIENT_TIMEOUT: requested=${t} bps; no server confirmation within 4000ms`),4e3);this.bitratePending={id:n,value:t,resolve:r,timer:a},this.send({type:"bitrate",requestId:n,bitRate:t})})}finishBitrate(t,r){const n=this.bitratePending;n&&(this.bitratePending=null,clearTimeout(n.timer),t||(this.liveBitrate=!1,this.bitrateFailureDetail=r??this.bitrateFailureDetail??"BITRATE_REASON_UNAVAILABLE: server rejected adjustment without a diagnostic",this.closedByUser||this.callbacks.onBitrateSupport?.(!1,this.bitrateFailureDetail)),n.resolve(t))}socket=null;decoder=null;configured=!1;configData=null;header=null;closedByUser=!1;lastMessageAt=0;lastFrameAt=0;lastResetAt=0;heartbeat=null;statsTimer=null;stallTimer=null;pendingConfig=null;needsKeyframe=!1;frameCount=0;receivedFrames=0;decodedFrames=0;controlsSent=0;lastSeq=0;lastType="";bytesSinceSample=0;warnedUnsupported=!1;lastSampleAt=0;serial="";autoQuality=!1;pingAt=null;rttMs=null;rttAt=0;minimumFrameOffset=1/0;deliveryDelayMs=0;peakDecodeQueue=0;sampleFrames=0;get currentHeader(){return this.header}connect(t,r){this.liveBitrate=!1,this.bitrateFailureDetail=void 0,this.serial=t,this.autoQuality=r?.id==="auto",this.closedByUser=!1,this.callbacks.onState("connecting");let n;try{n=qw(UO(t,r))}catch(a){this.callbacks.onState("error",a instanceof Error?a.message:"ANDROID_STREAM_FAILED");return}this.socket=n,n.onopen=()=>{this.lastMessageAt=Date.now()},n.onmessage=a=>{this.closedByUser||this.handleMessage(a.data)},n.onerror=()=>{this.closedByUser||this.callbacks.onState("error","SCRCPY_CONNECTION_LOST")},n.onclose=()=>{this.finishBitrate(!1,"BITRATE_CONNECTION_CLOSED: preview connection closed"),this.liveBitrate=!1,this.teardownTimers(),this.closedByUser?this.callbacks.onState("idle"):this.callbacks.onState("error","SCRCPY_CONNECTION_CLOSED")},this.startTimers()}disconnect(){this.closedByUser=!0,this.finishBitrate(!1),this.liveBitrate=!1,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.stallTimer&&clearInterval(this.stallTimer),this.heartbeat=null,this.statsTimer=null,this.stallTimer=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.pingAt===null&&(this.pingAt=performance.now(),this.send({type:"ping"}))}},this.autoQuality?2e3:15e3),this.stallTimer=setInterval(()=>{if(!this.header||this.closedByUser)return;const t=Date.now();t-this.lastFrameAt>8e3&&t-this.lastResetAt>8e3&&(this.lastResetAt=t,console.warn("[android] no frames for 8s; requesting keyframe reset"),this.sendControl(R0(Sb)))},2e3),this.statsTimer=setInterval(()=>{const t=Date.now(),r=(t-this.lastSampleAt)/1e3;r<=0||(this.callbacks.onStats({fps:Math.round(this.frameCount/r*10)/10,kbps:Math.round(this.bytesSinceSample*8/r/1e3),width:this.header?.width??0,height:this.header?.height??0,received:this.receivedFrames,decoded:this.decodedFrames,controls:this.controlsSent,last:this.lastType,adaptation:this.autoQuality?{rttMs:this.pingAt!==null&&performance.now()-this.pingAt>2e3?performance.now()-this.pingAt:performance.now()-this.rttAt<6e3?this.rttMs:null,deliveryDelayMs:this.sampleFrames?this.deliveryDelayMs:0,decodeQueue:Math.max(this.peakDecodeQueue,this.decoder?.decodeQueueSize??0),frames:this.sampleFrames}:void 0}),this.sampleFrames=0,this.peakDecodeQueue=0,this.frameCount=0,this.bytesSinceSample=0,this.lastSampleAt=t)},1e3)}send(t){if(!(!this.socket||this.socket.readyState!==1))try{this.socket.send(JSON.stringify(t))}catch{}}sendControl(t){t&&(this.controlsSent++,this.send({type:"control",data:uF(t)}))}ack(){this.send({type:"ack",seq:this.lastSeq})}handleMessage(t){if(typeof t!="string")return;this.lastMessageAt=Date.now();let r;try{r=JSON.parse(t)}catch{return}this.lastType=`${r.type??"?"}${r.config?":cfg":""}${r.key?":key":""}`;try{this.dispatchMessage(r)}catch(n){console.warn("[android] message handling failed",n),this.callbacks.onWarning(`处理消息失败:${n instanceof Error?n.message:String(n)}`)}}dispatchMessage(t){switch(t.type){case"bitrate-support":this.liveBitrate=t.supported===!0,this.bitrateFailureDetail=this.liveBitrate?void 0:typeof t.detail=="string"?t.detail.slice(0,4096):"BITRATE_REASON_UNAVAILABLE: server did not provide diagnostics",this.liveBitrate||this.finishBitrate(!1,this.bitrateFailureDetail),this.callbacks.onBitrateSupport?.(this.liveBitrate,this.bitrateFailureDetail);break;case"bitrate-result":t.requestId===this.bitratePending?.id&&this.finishBitrate(t.applied===!0&&t.bitRate===this.bitratePending?.value,typeof t.detail=="string"?t.detail.slice(0,4096):void 0);break;case"header":this.header={deviceName:t.deviceName??this.serial,codec:t.codec??"h264",width:t.width??0,height:t.height??0},this.lastFrameAt=Date.now(),this.callbacks.onHeader(this.header),this.callbacks.onState("streaming");break;case"frame":this.handleFrame(t);break;case"error":this.callbacks.onState("error",t.message||"SCRCPY_ERROR");break;case"closed":this.callbacks.onState("error","SCRCPY_SESSION_CLOSED");break;case"pong":this.pingAt!==null&&(this.rttMs=performance.now()-this.pingAt,this.rttAt=performance.now(),this.pingAt=null);break}}handleFrame(t){if(typeof t.data!="string")return;typeof t.seq=="number"&&(this.lastSeq=t.seq);const r=dF(t.data);if(this.bytesSinceSample+=t.data.length,this.receivedFrames++,this.lastFrameAt=Date.now(),this.decoder?.state==="closed"&&(this.decoder=null,this.configured=!1),t.config){this.configData=r,this.pendingConfig=r,this.configureDecoder(),this.ack();return}this.sampleFrames++;const n=Number(t.pts);if(t.pts!==void 0&&Number.isFinite(n)){const l=performance.now()-n/1e3;this.minimumFrameOffset=Math.min(this.minimumFrameOffset,l),this.deliveryDelayMs=Math.max(0,l-this.minimumFrameOffset)}this.configured||this.configureDecoder();const a=t.key===!0;if(this.needsKeyframe&&!a){this.ack();return}let c=r;this.pendingConfig&&(c=new Uint8Array(this.pendingConfig.length+r.length),c.set(this.pendingConfig,0),c.set(r,this.pendingConfig.length),this.pendingConfig=null),a&&(this.needsKeyframe=!1),this.decode(c,a,t.pts),this.ack()}configureDecoder(){const t=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(R0(Sb))}})}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 r={codec:"avc1.42e01e",optimizeForLatency:!0};let n;t==="h264"?(n=[hF(this.configData),"avc1.42e01e","avc1.4d401e","avc1.64001f"].filter((l,h,p)=>p.indexOf(l)===h),r.avc={format:"annexb"}):t==="h265"?(n=[fF(this.configData),"hev1.1.6.L120.B0","hvc1.1.6.L120.B0"],r.hevc={format:"annexb"}):n=["av01.0.04M.08"];const a=[];for(const c of n)try{this.decoder.configure({...r,codec:c}),this.configured=!0,this.needsKeyframe=!0,c!==n[0]&&console.warn("[android] decoder configured with fallback codec",c);return}catch(l){a.push(`${c}: ${l instanceof Error?l.message:String(l)}`),console.warn("[android] decoder configure failed",c,l)}this.callbacks.onWarning(`解码器配置失败(${a.join(";")})`),this.callbacks.onState("error","VIDEO_DECODER_UNSUPPORTED")}decode(t,r,n){if(!(!this.decoder||this.decoder.state!=="configured"))try{this.decoder.decode(new EncodedVideoChunk({type:r?"key":"delta",timestamp:n?Number(n):this.lastTimestamp+1,data:t})),this.peakDecodeQueue=Math.max(this.peakDecodeQueue,this.decoder.decodeQueueSize),this.lastTimestamp=n?Number(n):this.lastTimestamp+1}catch(a){this.decodeFailureCount++<3&&(console.warn("[android] decode threw",a),this.callbacks.onWarning(`送入解码器失败:${a instanceof Error?a.message:String(a)}`))}}decodeFailureCount=0;lastTimestamp=0;onDecodedFrame(t){this.frameCount++,this.decodedFrames++;const r=t.displayWidth||t.codedWidth,n=t.displayHeight||t.codedHeight,a=this.canvas;(a.width!==r||a.height!==n)&&(a.width=r,a.height=n,this.header&&(this.header={...this.header,width:r,height:n},this.callbacks.onHeader(this.header)));const c=a.getContext("2d");c&&c.drawImage(t,0,0,a.width,a.height),t.close()}pointerPoint(t,r){return{x:t,y:r,screenWidth:this.header?.width??0,screenHeight:this.header?.height??0}}touch(t,r,n,a){const c=t===bm||t===kb,l=c?0:1,h=a===uu&&!c?Ib:0,p=(t===_b||t===bm)&&a===uu?Ib:0;this.sendControl(iF(t,a,this.pointerPoint(r,n),l,p,h))}pointerDown(t,r,n){this.touch(_b,t,r,n==="mouse"?uu:wh)}pointerMove(t,r,n){this.touch(sF,t,r,n==="mouse"?uu:wh)}pointerUp(t,r,n){this.touch(bm,t,r,n==="mouse"?uu:wh)}pointerCancel(t,r,n){this.touch(kb,t,r,n==="mouse"?uu:wh)}scroll(t,r,n,a){this.sendControl(aF(this.pointerPoint(t,r),n,a))}key(t,r=ym){this.sendControl(vm(r,t))}tapKey(t){this.sendControl(vm(ym,t)),this.sendControl(vm(Lb,t))}back(){this.sendControl(Eb(ym)),this.sendControl(Eb(Lb))}home(){this.tapKey(N0.HOME)}recents(){this.tapKey(N0.APP_SWITCH)}power(){this.tapKey(N0.POWER)}volumeUp(){this.tapKey(N0.VOLUME_UP)}volumeDown(){this.tapKey(N0.VOLUME_DOWN)}rotate(){this.sendControl(R0(rF))}expandNotifications(){this.sendControl(R0(JO))}collapsePanels(){this.sendControl(R0(eF))}setDisplayPower(t){this.sendControl(cF(t))}sendText(t){this.sendControl(oF(t))}startApp(t){this.sendControl(lF(t))}}function mF(){try{return crypto.randomUUID().slice(0,8)}catch{return Math.random().toString(36).slice(2,10)}}function gF(){return`termdock-mirror-shot-${new Date().toISOString().replace(/[-:T]/g,"").slice(0,14)}-${mF()}.png`}function Nb(e){const t=Math.max(0,Math.floor(e/1e3)),r=Math.floor(t/60),n=t%60;return`${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}`}async function xF(e,t=gF()){const r=e.width,n=e.height;if(!r||!n)throw new Error("投屏画面尚未就绪");const a=document.createElement("canvas");a.width=r,a.height=n;const c=a.getContext("2d");if(!c)throw new Error("无法读取投屏画面");c.drawImage(e,0,0);const l=await new Promise(h=>a.toBlob(h,"image/png"));if(!l||l.size===0)throw new Error("截图失败,请重试");return new File([l],t,{type:"image/png"})}function N6(e,t,r){const n=r.contentWidth*(t-1)/2,a=r.contentHeight*(t-1)/2;return{x:Math.max(-n,Math.min(n,e.x)),y:Math.max(-a,Math.min(a,e.y))}}function Rb(e,t,r,n,a){const c=Math.max(1,Math.min(8,e.zoom*a)),l=c/e.zoom;return{zoom:c,pan:N6({x:n.x-t.cx-(r.x-t.cx-e.pan.x)*l,y:n.y-t.cy-(r.y-t.cy-e.pan.y)*l},c,t)}}function R6(e,t){return t?new Promise((r,n)=>{const a=crypto.randomUUID(),c=p=>{window.clearTimeout(h),window.removeEventListener("termdock-insert-reference-ack",l),p?r():n(new Error("目标终端不可用,内容尚未插入,请连接终端后重试"))},l=p=>{const m=p.detail;m?.nonce===a&&c(m.ok===!0)},h=window.setTimeout(()=>c(!1),1e4);window.addEventListener("termdock-insert-reference-ack",l),window.dispatchEvent(new CustomEvent("termdock-insert-reference",{detail:{text:e,sessionId:t,nonce:a,focus:!1,paste:!0}}))}):Promise.reject(new Error("没有可接收内容的终端"))}function Mb(e,t){return R6(Xm(e,null),t)}const Am=rc(e=>({pending:[],enqueue:(t,r,n="/",a)=>e(c=>c.pending.some(l=>l.file.id===t.id)?c:{pending:[...c.pending,{file:t,sessionId:r,initialPath:n,insert:a}]}),remove:t=>e(r=>({pending:r.pending.filter(n=>n.file.id!==t)}))}));function bF({file:e,initialPath:t,onInsert:r,onDone:n}){const{t:a}=zr(),[c,l]=b.useState(!1),[h,p]=b.useState(!1),[m,x]=b.useState(!1),[y,w]=b.useState(!1),[v,k]=b.useState(null),L=b.useRef(!1),E=b.useRef(null),R=async()=>{if(!L.current){L.current=!0,p(!0),w(!0);try{await VO(e.id),n()}catch(W){k(W instanceof Error?W.message:String(W))}finally{L.current=!1,p(!1),w(!1)}}};b.useEffect(()=>{if(c)return;E.current?.focus();const W=F=>{if(F.stopPropagation(),F.key==="Escape"&&F.preventDefault(),F.key!=="Tab")return;const U=Array.from(E.current?.querySelectorAll("button:not(:disabled)")??[]),V=U[0],Z=U.at(-1);F.shiftKey&&(document.activeElement===V||document.activeElement===E.current)?(F.preventDefault(),Z?.focus()):!F.shiftKey&&document.activeElement===Z&&(F.preventDefault(),V?.focus())};return document.addEventListener("keydown",W,!0),()=>document.removeEventListener("keydown",W,!0)},[c]);const B=async W=>{if(!L.current){L.current=!0,p(!0),x(W!==void 0),l(!1),k(null);try{const F=await GO(e.id,W);W===void 0&&await r(F.path),n()}catch(F){k(F instanceof Error?F.message:String(F))}finally{L.current=!1,p(!1)}}};return c?s.jsx(Hf,{open:!0,initialPath:t||"/",title:a("android.recordingSave"),onCancel:()=>l(!1),onConfirm:W=>{B(W)}}):Li.createPortal(s.jsx("div",{className:"fixed inset-0 z-modal-panel flex items-center justify-center bg-[var(--app-backdrop)] p-4",children:s.jsxs("div",{ref:E,role:"dialog","aria-modal":"true","aria-labelledby":"recording-save-title",tabIndex:-1,"aria-busy":h,className:"w-full max-w-sm rounded-xl border border-border bg-surface p-4 text-foreground shadow-xl outline-none",children:[s.jsx("h2",{id:"recording-save-title",className:"text-sm font-semibold",children:a("android.recordingConfirm")}),s.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:a("android.recordingSaveHint")}),s.jsxs("p",{className:"mt-2 break-all text-xs text-muted-foreground",children:[e.name," · ",(e.size/1024/1024).toFixed(1)," MB"]}),(v||e.error)&&s.jsx("p",{role:"alert",className:"mt-3 break-words text-xs text-destructive",children:v||e.error}),h&&s.jsxs("p",{role:"status",className:"mt-3 flex items-center gap-2 text-sm text-primary",children:[s.jsx(In,{size:16,className:"animate-spin"}),y?`${a("android.recordingDiscard")}…`:a(m?"android.recordingSaving":"android.captureInserting")]}),s.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[s.jsx("button",{type:"button",disabled:h||e.status!=="ready",onClick:()=>{B()},className:"min-h-10 rounded-lg bg-primary px-3 text-sm text-primary-foreground disabled:opacity-40",children:a("android.recordingInsert")}),s.jsx("button",{type:"button",disabled:h||e.status!=="ready",onClick:()=>l(!0),className:"min-h-10 rounded-lg bg-surface-2 px-3 text-sm disabled:opacity-40",children:a("android.recordingSave")}),s.jsx("button",{type:"button",disabled:h,onClick:()=>{R()},className:"min-h-10 rounded-lg px-3 text-sm text-muted-foreground disabled:opacity-40",children:a("android.recordingDiscard")})]})]})}),document.body)}const H0="android-mirror",M0=H0,M6="termdock:android:quality:v1",Tm=176,yF=204,Tl=1,Gh=8,jb=[1,1.25,1.5,2,2.5,3,4,6,8],vF=e=>Math.max(Tl,Math.min(Gh,e));function wF(e){return`${Number.isInteger(e)?e:e.toFixed(1)}×`}function Ah(e){const t=e.parentElement;if(!t)return null;const r=t.getBoundingClientRect(),n=getComputedStyle(t),a=parseFloat(n.paddingLeft)||0,c=parseFloat(n.paddingTop)||0,l=t.clientWidth-a-(parseFloat(n.paddingRight)||0),h=t.clientHeight-c-(parseFloat(n.paddingBottom)||0);return{cx:r.left+t.clientLeft+a+l/2,cy:r.top+t.clientTop+c+h/2,width:l,height:h,contentWidth:e.offsetWidth,contentHeight:e.offsetHeight}}function AF(e,t){try{e.setPointerCapture?.(t)}catch{}}function Db(e,t){try{e.releasePointerCapture?.(t)}catch{}}const Bb=e=>typeof requestAnimationFrame=="function"?requestAnimationFrame(e):window.setTimeout(e,16),Th=e=>{typeof cancelAnimationFrame=="function"?cancelAnimationFrame(e):window.clearTimeout(e)},Cm={auto:"android.qualityAuto",low:"android.qualityLow",medium:"android.qualityMedium",high:"android.qualityHigh",custom:"android.qualityCustom"},TF=()=>{try{const e=localStorage.getItem(M6);return e?w1(JSON.parse(e)):yd}catch{return yd}},j0=e=>{try{localStorage.setItem(M6,JSON.stringify(e))}catch{}};function CF({sessionId:e,dockOnly:t=!1,onInsertPrompt:r,onInsertFile:n,onRecordingComplete:a,onCloseTab:c}){const{t:l}=zr(),h=Tb(N=>N.overlay),p=Tb(N=>N.setOverlay),m=b.useRef(null),x=b.useRef(null),y=b.useRef(null),w=b.useMemo(TF,[]),v=b.useRef(w),k=b.useRef(null),L=b.useRef(null),[E,R]=b.useState(4e6),B=b.useRef(null),W=b.useRef(new Map),F=b.useRef(null),U=b.useRef(!1),[V,Z]=b.useState(Tl),le=b.useRef(V),xe=b.useRef({x:0,y:0}),fe=b.useRef(null),te=b.useRef(0),ke=b.useRef(0),$e=b.useRef(null),Y=b.useRef(0),[Ae,lt]=b.useState(null),[Ce,ye]=b.useState(null),[_e,je]=b.useState(!0),[re,Pe]=b.useState(""),[Se,Ee]=b.useState(w.id),[Be,Ne]=b.useState([]),[oe,He]=b.useState(null),[rt,mt]=b.useState(""),[de,Ye]=b.useState(!0),[st,Ie]=b.useState({maxSize:w.maxSize,bitRate:w.bitRate,maxFps:w.maxFps}),[We,Te]=b.useState("idle"),[H,ae]=b.useState(null),[be,Ze]=b.useState(null),[Je,Tt]=b.useState({fps:0,kbps:0,width:0,height:0,received:0,decoded:0,controls:0,last:""}),[Wt,Mt]=b.useState(null),[vt,Yt]=b.useState(null),[Qt,Xt]=b.useState(!1),[Ut,Lt]=b.useState([]),[pe,Ge]=b.useState(null),[ft,q]=b.useState([]),[at,Vt]=b.useState(!1),Ve=b.useRef(null),De=b.useRef(0),er=b.useRef([]),[et,Ct]=b.useState(!1),[Nt,gt]=b.useState(""),[bt,It]=b.useState(!1),[yt,pr]=b.useState(!1),[nr,_r]=b.useState(""),[un,Ir]=b.useState(null),[me,Gr]=b.useState(null),[it,dt]=b.useState(!1),[sr,An]=b.useState(0),on=b.useRef(null),[Me,nt]=b.useState(!1),wt=b.useRef(!1),Mr=b.useRef(new Set),rn=b.useRef(null),Er=b.useRef(null),ne=b.useRef(!1),[ht,zt]=b.useState(!1),Pt=b.useRef(a);Pt.current=a;const[Cr,gr]=b.useState(!1),[Hr,En]=b.useState(null),dr=b.useRef(null),Tn=b.useRef(null),hn=QO(N=>N.activeSessionId??N.sessions.keys().next().value??null),Sn=e??hn,ir=ns(N=>!!N.docks[M0]),mn=ns(N=>N.hosts[M0]),Qr=ns(N=>N.setDock),Vr=b.useCallback(async()=>{je(!0);try{const N=await FO();lt(N),ye(null)}catch(N){ye(N instanceof Error?N.message:"ADB_UNAVAILABLE")}finally{je(!1)}},[]);b.useEffect(()=>{Vr()},[Vr]);const Wr=Ae?.devices??[],fs=Wr.find(N=>N.serial===re)??null,Dr=!!(Ce&&/ADB_NOT_FOUND|ADB_UNAVAILABLE/i.test(Ce)),Pn=!!(Ae?.adbAvailable&&!Ae.scrcpyVersion),Sr=b.useCallback(()=>{const N=B.current,$=[...W.current.keys()];B.current=null,W.current.clear(),F.current=null,U.current=!1,Ve.current=null,Th(te.current),te.current=0,N&&x.current?.pointerCancel(N.x,N.y,N.type);const ee=m.current;if(ee)for(const se of $)Db(ee,se);Ge(null),Vt(!1),q([]),Z(le.current)},[]);b.useEffect(()=>{const N=se=>{W.current.has(se.pointerId)&&(se.type==="pointercancel"||se.target!==m.current)&&Sr()},$=()=>Sr(),ee=()=>{document.hidden&&Sr()};return window.addEventListener("pointerup",N,!0),window.addEventListener("pointercancel",N,!0),window.addEventListener("blur",$),document.addEventListener("visibilitychange",ee),()=>{window.removeEventListener("pointerup",N,!0),window.removeEventListener("pointercancel",N,!0),window.removeEventListener("blur",$),document.removeEventListener("visibilitychange",ee),Sr()}},[Sr]);const Kr=b.useCallback(()=>{Sr(),x.current?.disconnect(),x.current=null,Te("idle"),ae(null),Ze(null)},[Sr]),nn=b.useCallback((N,$=!1)=>{const ee=m.current;if(!ee||!N)return;Sr(),x.current?.disconnect(),ae(null),!$&&y.current!==N&&Ze(null),y.current=N,Yt(null),Mt(null);const se=new pF(ee,{onBitrateSupport:(ze,xt)=>{x.current!==se||v.current.id!=="auto"||Mt(ze?null:xt??"BITRATE_REASON_UNAVAILABLE")},onState:(ze,xt)=>{x.current===se&&(Te(ze),ae(xt??null))},onHeader:ze=>{x.current===se&&Ze(ze)},onStats:ze=>{x.current===se&&Tt(ze)},onWarning:ze=>{x.current===se&&Yt(ze)}});x.current=se;let Qe=v.current;Qe.id==="auto"?(k.current?.serial!==N&&(k.current={serial:N,policy:new OO}),k.current.policy.connected(performance.now()),Qe=k.current.policy.quality,R(Qe.bitRate)):k.current=null,L.current=Qe,se.connect(N,Qe)},[Sr]);b.useEffect(()=>{if(Se!=="auto"||v.current.id!=="auto"||We!=="streaming"||!Je.adaptation||document.hidden)return;const N=k.current,$=x.current;if(!N||N.serial!==re||!$?.canSetBitrate)return;const ee=m.current,se=ee?Math.max(ee.clientWidth,ee.clientHeight)*(window.devicePixelRatio||1)*le.current:1600,Qe=N.policy.sample(Je.adaptation,performance.now(),se||1600);Qe&&$.setBitrate(Qe.bitRate).then(ze=>{ze&&x.current===$&&(L.current=Qe,R(Qe.bitRate))})},[Je,Se,We,re,nn]);const Or=b.useCallback(N=>{const $={...N.quality?{quality:{id:N.quality.id,maxSize:N.quality.maxSize,bitRate:N.quality.bitRate,maxFps:N.quality.maxFps}}:{},...N.activePresetId!==void 0?{activePresetId:N.activePresetId}:{},...N.presets!==void 0?{presets:N.presets}:{},...N.docked!==void 0?{docked:N.docked}:{},...N.deviceSerial!==void 0?{deviceSerial:N.deviceSerial}:{}};wa({androidPanel:$}).catch(()=>{})},[]);b.useEffect(()=>{let N=!1;return nc().then($=>{if(N)return;const ee=$.androidPanel;if(ee?.quality){const se=w1(ee.quality);v.current=se,Ee(se.id),Ie({maxSize:se.maxSize,bitRate:se.bitRate,maxFps:se.maxFps}),j0(se)}Ne(ee?.presets??[]),He(ee?.activePresetId??null),ee?.deviceSerial&&($e.current=ee.deviceSerial,Pe(ee.deviceSerial))}).catch(()=>{}),()=>{N=!0}},[]);const ks=b.useCallback(N=>{const $=++De.current;Lt(se=>[...se,{id:$,left:N.left,top:N.top}]);const ee=window.setTimeout(()=>{Lt(se=>se.filter(Qe=>Qe.id!==$)),er.current=er.current.filter(se=>se!==ee)},300);er.current.push(ee)},[]),Pr=b.useCallback((N,$)=>{const ee=x.current,se=L.current;ee?.supportsLiveBitrate&&y.current===N&&se&&se.maxSize===$.maxSize&&se.maxFps===$.maxFps?ee.setBitrate($.bitRate).then(Qe=>{x.current===ee&&(Qe?(L.current=$,Mt(null)):Mt(ee.lastBitrateFailure??"BITRATE_REASON_UNAVAILABLE"))}):nn(N)},[nn,l]),Xr=b.useCallback(N=>{if(k.current=null,N.startsWith("user:")){const ee=Be.find(Qe=>Qe.id===N.slice(5));if(!ee)return;const se={id:"custom",maxSize:ee.maxSize,bitRate:ee.bitRate,maxFps:ee.maxFps};v.current=se,Ee("custom"),He(ee.id),Ie({maxSize:ee.maxSize,bitRate:ee.bitRate,maxFps:ee.maxFps}),Ye(!0),j0(se),Or({quality:se,activePresetId:ee.id}),re&&nn(re);return}if(N==="custom"){const ee=v.current;Ee("custom"),He(null),Ie({maxSize:ee.maxSize,bitRate:ee.bitRate,maxFps:ee.maxFps}),Ye(!0);return}const $=N==="auto"?w1({id:"auto"}):Lf.find(ee=>ee.id===N)??yd;v.current=$,Ee($.id),He(null),j0($),Or({quality:$,activePresetId:null}),re&&nn(re)},[nn,re,Be,Or]),fn=b.useCallback(()=>{const N={id:"custom",maxSize:st.maxSize,bitRate:st.bitRate,maxFps:st.maxFps};v.current=N,j0(N),Or({quality:N,activePresetId:null}),Ee("custom"),He(null),re&&Pr(re,N)},[Pr,re,st,Or]),K=b.useCallback(()=>{const N=rt.trim();if(!N)return;const $=`p${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,ee={id:$,name:N,maxSize:st.maxSize,bitRate:st.bitRate,maxFps:st.maxFps},se=[...Be.filter(ze=>ze.name!==N),ee].slice(-12),Qe={id:"custom",maxSize:st.maxSize,bitRate:st.bitRate,maxFps:st.maxFps};Ne(se),mt(""),He($),Ee("custom"),v.current=Qe,j0(Qe),Or({quality:Qe,activePresetId:$,presets:se}),re&&Pr(re,Qe)},[rt,st,Be,re,Pr,Or]),Ue=b.useCallback(()=>{if(!oe)return;const N=Be.filter($=>$.id!==oe);Ne(N),He(null),Or({activePresetId:null,presets:N})},[oe,Be,Or]);b.useEffect(()=>()=>{x.current?.disconnect(),x.current=null;for(const N of er.current)window.clearTimeout(N);er.current=[]},[]),b.useEffect(()=>{if(h==="off")return;const N=$=>{$.key==="Escape"&&p("off")};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[h,p]),b.useEffect(()=>{const N=Wr.filter(ee=>ee.state==="device");if(re||N.length!==1)return;const $=N[0].serial;$e.current!==$&&($e.current=$,Pe($))},[Wr,re]),b.useEffect(()=>{re&&nn(re)},[re,nn]),b.useEffect(()=>{if(We==="streaming"){Y.current=0,Xt(!1);return}if(We!=="error"||!re||!_F(H??""))return;const N=Math.min(8e3,700*2**Y.current);Y.current+=1,Xt(!0);const $=window.setTimeout(()=>{Xt(!1),nn(re)},N);return()=>window.clearTimeout($)},[We,H,re,nn]);const Et=b.useCallback((N,$,ee)=>{const se=m.current,Qe=ee??(se?Ah(se):null);return!se||!Qe?{x:0,y:0}:N6(N,$,Qe)},[]),kt=b.useCallback(()=>{const N=m.current;if(!N)return;const{x:$,y:ee}=xe.current,se=le.current,Qe=se===Tl&&$===0&&ee===0?"":`translate3d(${$}px, ${ee}px, 0) scale(${se})`;N.style.transform!==Qe&&(N.style.transform=Qe);const ze=fe.current;ze&&(ze.textContent=se>Tl?wF(se):"")},[]),tr=b.useCallback((N,$,ee=!0)=>{const se=m.current,Qe=le.current,ze=vF(N);if(!se||ze===Qe)return;const xt=Ah(se);if(!xt)return;const _t=$??{x:xt.cx,y:xt.cy},Fr=Rb({zoom:Qe,pan:xe.current},xt,_t,_t,ze/Qe);le.current=Fr.zoom,xe.current=Fr.pan,ee&&kt()},[kt]),Br=b.useCallback(()=>{const N=le.current;Z($=>$<=Tl+.01==N<=Tl+.01&&$>=Gh-.01==N>=Gh-.01?$:N)},[]);b.useEffect(()=>()=>{Th(te.current),Th(ke.current)},[]);const cr=()=>{let N=0,$=0;for(const se of W.current.values())N+=se.x,$+=se.y;const ee=W.current.size;return ee?{x:N/ee,y:$/ee}:null},_n=()=>{const[N,$]=Array.from(W.current.values());return N&&$?Math.hypot(N.x-$.x,N.y-$.y):0},Ls=()=>{const N=cr(),$=m.current?Ah(m.current):null;!N||!$||(F.current={startCentroid:N,startDistance:_n(),box:$})},Zn=b.useCallback(()=>{const N=F.current,$=cr();if(!N||!$)return;const ee=_n(),se=N.startDistance>0&&ee>0?ee/N.startDistance:1,Qe=Rb({zoom:le.current,pan:xe.current},N.box,N.startCentroid,$,se);le.current=Qe.zoom,xe.current=Qe.pan,N.startCentroid=$,N.startDistance=ee},[]),sn=b.useCallback(()=>{te.current||(te.current=Bb(()=>{te.current=0,Zn(),kt()}))},[Zn,kt]),ln=b.useCallback(()=>{te.current&&(Th(te.current),te.current=0,Zn(),kt())},[Zn,kt]);b.useEffect(()=>{const N=m.current;if(!N)return;const $=N.parentElement;if(!$)return;const ee=Qe=>{if(Qe.ctrlKey||Qe.metaKey){if(Qe.preventDefault(),!Qe.deltaY||F.current)return;const _t=Qe.deltaMode===1?16:Qe.deltaMode===2?N.parentElement?.clientHeight||600:1,Fr=Math.max(-600,Math.min(600,Qe.deltaY*_t));tr(le.current*Math.exp(-Fr*.002),{x:Qe.clientX,y:Qe.clientY},!1),ke.current||(ke.current=Bb(()=>{ke.current=0,kt(),Br()}));return}const ze=x.current;if(!ze||Qe.target!==N)return;Qe.preventDefault();const xt=Sh(N,Qe.clientX,Qe.clientY);ze.scroll(xt.x,xt.y,Qe.deltaX,Qe.deltaY)},se=Qe=>Qe.preventDefault();return $.addEventListener("wheel",ee,{passive:!1}),$.addEventListener("gesturestart",se,{passive:!1}),$.addEventListener("gesturechange",se,{passive:!1}),()=>{$.removeEventListener("wheel",ee),$.removeEventListener("gesturestart",se),$.removeEventListener("gesturechange",se)}},[tr,kt,Br]),b.useEffect(()=>{const N=m.current,$=N?.parentElement;if(!N||!$||typeof ResizeObserver>"u")return;const ee=new ResizeObserver(()=>{F.current&&(F.current.box=Ah(N));const se=Et(xe.current,le.current);se.x===xe.current.x&&se.y===xe.current.y||(xe.current=se,kt())});return ee.observe(N),ee.observe($),()=>ee.disconnect()},[Et,kt]),b.useLayoutEffect(()=>{kt()});const kr=N=>{const $=x.current,ee=m.current;if(!$||!ee)return;if(N.pointerType==="mouse"&&N.button!==0){N.preventDefault(),N.button===2?$.back():N.button===1&&$.home();return}N.preventDefault(),ee.closest(".android-mirror-panel")?.focus({preventScroll:!0}),kt(),Br(),ln(),AF(ee,N.pointerId),W.current.set(N.pointerId,{x:N.clientX,y:N.clientY});const se=N.pointerType==="mouse"&&N.altKey;if(W.current.size>=2||se){const xt=B.current;xt&&($.pointerCancel(xt.x,xt.y,xt.type),B.current=null,Ve.current=null,Ge(null),Vt(!1),q([])),U.current=!0,Ls();return}if(U.current)return;const Qe=Sh(ee,N.clientX,N.clientY);B.current={id:N.pointerId,type:N.pointerType,x:Qe.x,y:Qe.y},$.pointerDown(Qe.x,Qe.y,N.pointerType);const ze=$b(ee,N.clientX,N.clientY);ze&&(Ve.current={left:ze.left,top:ze.top},q([]),Vt(!1),Ge(ze))},$r=N=>{const $=x.current,ee=m.current;if(!ee||!W.current.has(N.pointerId))return;if(N.pointerType==="mouse"){const _t=ee.getBoundingClientRect(),Fr=ee.parentElement?.getBoundingClientRect()??_t;if(!(N.buttons&1)||N.clientX<Math.max(_t.left,Fr.left)||N.clientX>=Math.min(_t.right,Fr.right)||N.clientY<Math.max(_t.top,Fr.top)||N.clientY>=Math.min(_t.bottom,Fr.bottom)){Sr();return}}if(N.preventDefault(),W.current.set(N.pointerId,{x:N.clientX,y:N.clientY}),F.current){sn();return}const se=B.current;if(!$||!se||se.id!==N.pointerId)return;const Qe=Sh(ee,N.clientX,N.clientY);se.x=Qe.x,se.y=Qe.y,$.pointerMove(Qe.x,Qe.y,se.type);const ze=$b(ee,N.clientX,N.clientY),xt=Ve.current;!ze||!xt||(Ge(ze),Math.hypot(ze.left-xt.left,ze.top-xt.top)>=6&&(Vt(!0),q(_t=>{const Fr=_t[_t.length-1];if(Fr&&Math.hypot(ze.left-Fr.x,ze.top-Fr.y)<4)return _t;const jt=[..._t,{x:ze.left,y:ze.top}];return jt.length>12?jt.slice(jt.length-12):jt})))},Gn=N=>{const $=x.current,ee=m.current;if(!ee||!W.current.has(N.pointerId))return;if(ln(),W.current.delete(N.pointerId),Db(ee,N.pointerId),W.current.size===0&&(U.current=!1),F.current){W.current.size===0?(F.current=null,Z(le.current)):Ls();return}const se=B.current;if(!se||se.id!==N.pointerId)return;const Qe=Sh(ee,N.clientX,N.clientY);$?.pointerUp(Qe.x,Qe.y,se.type),pe&&ks(pe),Ge(null),Vt(!1),window.setTimeout(()=>q([]),200),B.current=null,Ve.current=null},Vn=N=>{if(Cr||et||yt)return;const $=x.current;$&&(N.key==="Backspace"?(N.preventDefault(),$.key(67)):N.key==="Escape"?(N.preventDefault(),$.back()):N.key==="Enter"&&(N.preventDefault(),$.key(66)))},dn=async()=>{const N=Nt.trim();if(N){It(!0);try{const $=await $O(N);gt(""),Ct(!1),await Vr(),Pe($.serial)}catch($){ye($ instanceof Error?$.message:"ADB_CONNECT_FAILED")}finally{It(!1)}}},Kn=()=>{const N=x.current,$=nr;!N||!$||(N.sendText($),_r(""))},Lr=b.useCallback(N=>{Ir(N),Er.current!==null&&window.clearTimeout(Er.current),Er.current=window.setTimeout(()=>{Er.current=null,Ir(null)},2500)},[]),Nr=b.useCallback(N=>{const $=le.current,ee=N==="in"?jb.find(se=>se>$+.01):[...jb].reverse().find(se=>se<$-.01);ee!==void 0&&($<=Tl&&ee>Tl&&Lr(l("android.zoomPanHint")),ln(),tr(ee),Z(ee))},[tr,ln,Lr,l]),xr=N=>{Promise.resolve().then(()=>r?.(N)).catch($=>{Gr($ instanceof Error?$.message:String($))})},os=b.useCallback(async(N,$)=>{try{if(!n)throw new Error(l("android.captureUnavailable"));await n(N),Lr($)}catch(ee){Gr(l("android.captureFailed")+(ee instanceof Error?`:${ee.message}`:""))}},[n,Lr,l]),Hn=async()=>{const N=m.current;if(!(!N||ne.current)){ne.current=!0,zt(!0),Gr(null);try{const $=await xF(N);await os($,l("android.captureInserted"))}catch($){Gr($ instanceof Error?$.message:String($))}finally{ne.current=!1,zt(!1)}}},Nn=b.useCallback(N=>{(N.status==="ready"||N.status==="error")&&Pt.current&&!Mr.current.has(N.id)&&(Mr.current.add(N.id),Pt.current?.(N))},[]),Rn=b.useCallback(async N=>{const $=on.current;if(!(!$||wt.current)){wt.current=!0,nt(!0),Gr(null);try{const ee=await WO($.id);on.current=null,dt(!1),Nn(ee)}catch(ee){Gr(ee instanceof Error?ee.message:String(ee))}finally{wt.current=!1,nt(!1)}}},[Nn]),ps=async()=>{if(!(!re||wt.current||on.current)){wt.current=!0,nt(!0),Gr(null);try{const N=await HO(re);N.status==="recording"||N.status==="starting"||N.status==="stopping"?(on.current=N,dt(!0),An(Math.max(0,Date.now()-N.startedAt))):Nn(N)}catch(N){Gr(N instanceof Error?N.message:String(N))}finally{wt.current=!1,nt(!1)}}};b.useEffect(()=>{let N=!1,$=!1;on.current=null,dt(!1);const ee=async()=>{if(!(!re||$||wt.current)){$=!0;try{const{recordings:Qe}=await zO(re);if(N||wt.current)return;const ze=Qe.find(xt=>["starting","recording","stopping"].includes(xt.status));on.current=ze??null,dt(!!ze);for(const xt of Qe)Nn(xt)}catch{}finally{$=!1}}};ee();const se=window.setInterval(()=>{ee()},2e3);return rn.current=window.setInterval(()=>{on.current&&An(Math.max(0,Date.now()-on.current.startedAt))},500),()=>{N=!0,window.clearInterval(se),rn.current!==null&&window.clearInterval(rn.current)}},[re,Nn]),b.useEffect(()=>{if(!Cr)return;const N=()=>gr(!1),$=se=>{const Qe=se.target;Qe instanceof Node&&(dr.current?.contains(Qe)||Tn.current?.contains(Qe)||N())},ee=se=>{se.key==="Escape"&&(se.preventDefault(),se.stopPropagation(),N())};return document.addEventListener("pointerdown",$,!0),document.addEventListener("keydown",ee,!0),window.addEventListener("resize",N),()=>{document.removeEventListener("pointerdown",$,!0),document.removeEventListener("keydown",ee,!0),window.removeEventListener("resize",N)}},[Cr]),b.useEffect(()=>()=>{Er.current!==null&&window.clearTimeout(Er.current)},[]);const G=We==="streaming",Le=ir,Ke=Le?"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded hover:bg-surface-2 disabled:opacity-40":"rounded p-1.5 hover:bg-surface-2 disabled:opacity-40",ct=fs?(fs.model||fs.serial)+Ub(fs,l):Wr.length?l("android.selectDevice"):l("android.noDevices"),At=(oe?Be.find(N=>N.id===oe):null)?.name??(Se==="auto"?`${l("android.qualityAuto")} · ${E/1e6} Mbps`:l(Cm[Se])),Rt=Le?"relative flex h-5 min-w-0 items-center rounded bg-surface-2 focus-within:ring-1 focus-within:ring-primary/50":"relative flex h-7 min-w-0 items-center rounded bg-surface-2 focus-within:ring-1 focus-within:ring-primary/50",Dt=Le?"pointer-events-none block min-w-0 truncate px-1 text-[10px] leading-none text-foreground":"pointer-events-none block min-w-0 truncate px-2 text-[11px] leading-none text-foreground",ot="absolute inset-0 h-full w-full cursor-pointer opacity-0",Ot=()=>{const N=dr.current?.getBoundingClientRect();N&&En({left:Math.max(8,Math.min(N.right-Tm,window.innerWidth-Tm-8)),top:Math.min(N.bottom+4,Math.max(8,window.innerHeight-yF-8))}),gr(!0)},hr=()=>{if(ir){Qr(M0,null),Or({docked:null});return}if(!Sn)return;const N={sessionId:Sn,side:"right"};Qr(M0,N),Or({docked:N})},Zt=et||ir||h!=="off",z=s.jsxs("div",{className:"android-mirror-panel flex h-full min-h-0 min-w-0 flex-col bg-surface text-foreground","data-sidebar-gesture-ignore":"true",onKeyDown:Vn,tabIndex:-1,children:[s.jsxs("div",{"data-panel-drag-title":ir?"true":void 0,className:Le?"flex h-6 min-h-6 shrink-0 flex-nowrap items-center gap-1 overflow-hidden border-b border-border/15 bg-[var(--chrome-bg)] px-1.5 cursor-grab select-none active:cursor-grabbing":"flex flex-wrap items-center gap-1.5 border-b border-border px-2 py-2",children:[ir&&s.jsx("span",{"data-panel-drag-title":"true",role:"button","aria-label":l("android.splitDrag"),title:l("android.splitDrag"),className:"flex h-4 w-4 shrink-0 cursor-grab items-center justify-center rounded text-muted-foreground hover:text-foreground active:cursor-grabbing",children:s.jsx(If,{size:12})}),s.jsx(Yw,{size:Le?12:14,className:"shrink-0 text-muted-foreground"}),s.jsxs("div",{className:`${Rt} flex-1`,children:[s.jsx("span",{"aria-hidden":"true",className:`${Dt} w-full`,children:ct}),s.jsxs("select",{value:re,onChange:N=>{const $=N.target.value;Pe($),$e.current=$,$&&Or({deviceSerial:$})},className:ot,"aria-label":l("android.device"),children:[s.jsx("option",{value:"",children:Wr.length?l("android.selectDevice"):l("android.noDevices")}),Wr.map(N=>s.jsx("option",{value:N.serial,children:(N.model||N.serial)+Ub(N,l)},N.serial))]})]}),s.jsxs("div",{className:`${Rt} max-w-[45%] shrink-0`,children:[s.jsx("span",{"aria-hidden":"true",className:Dt,children:At}),s.jsxs("select",{value:oe?`user:${oe}`:Se,onChange:N=>Xr(N.target.value),className:ot,title:l(Se==="auto"?"android.qualityAutoHint":"android.quality"),"aria-label":l("android.quality"),children:[s.jsxs("option",{value:"auto",children:[l("android.qualityAuto"),Se==="auto"?` · ${E/1e6} Mbps`:""]}),Lf.map(N=>s.jsx("option",{value:N.id,children:l(Cm[N.id])},N.id)),Be.map(N=>s.jsx("option",{value:`user:${N.id}`,children:N.name},N.id)),s.jsx("option",{value:"custom",children:l(Cm.custom)})]})]}),s.jsx("button",{type:"button",onClick:()=>{Vr()},className:`${Ke} text-muted-foreground`,title:l("android.refresh"),children:_e?s.jsx(In,{size:13,className:"animate-spin"}):s.jsx(yn,{size:13})}),G?s.jsx("button",{type:"button",onClick:Kr,className:`${Ke} text-destructive`,title:l("android.disconnect"),children:s.jsx(_3,{size:13})}):s.jsx("button",{type:"button",onClick:()=>re&&nn(re),disabled:!re,className:`${Ke} text-primary`,title:l("android.connect"),children:s.jsx($T,{size:13})}),(G||it)&&s.jsx("button",{type:"button",onClick:()=>{Hn()},disabled:!n||ht,className:`${Ke} text-muted-foreground`,title:l(n?"android.screenshot":"android.captureUnavailable"),"aria-label":l("android.screenshot"),children:ht?s.jsx(In,{size:Le?12:13,className:"animate-spin"}):s.jsx(wA,{size:Le?12:13})}),(G||it)&&s.jsx("button",{type:"button",onClick:()=>{it?Rn("manual"):ps()},disabled:Me||!it&&!a,className:`${Ke} ${it?"text-destructive":"text-muted-foreground"}`,title:l(it?"android.recordingStop":a?"android.recordingStart":"android.captureUnavailable"),"aria-label":l(it?"android.recordingStop":"android.recordingStart"),children:Me?s.jsx(In,{className:"animate-spin",size:13}):it?s.jsx(S3,{size:Le?10:11,fill:"currentColor"}):s.jsx(k3,{size:Le?12:13})}),s.jsx("button",{ref:dr,type:"button",onClick:()=>Cr?gr(!1):Ot(),"aria-haspopup":"menu","aria-expanded":Cr,className:`${Ke} ${Zt?"text-primary":"text-muted-foreground"}`,title:l("android.more"),"aria-label":l("android.more"),children:s.jsx(Qo,{size:Le?13:14})}),c&&!t&&s.jsx("button",{type:"button",onClick:()=>{gr(!1),p("off"),c()},className:`${Ke} text-muted-foreground hover:bg-destructive/20 hover:text-destructive`,title:l("android.closeTab"),"aria-label":l("android.closeTab"),children:s.jsx(Qn,{size:14})})]}),Cr&&Hr&&Li.createPortal(s.jsxs("div",{ref:Tn,role:"menu","aria-label":l("android.more"),style:{left:Hr.left,top:Hr.top,width:Tm},className:"fixed z-popover overflow-hidden rounded-md border border-border bg-surface-elevated py-1 text-[11px] shadow-lg",children:[s.jsx(Ch,{icon:s.jsx(ul,{size:13}),label:l("android.addDevice"),active:et,onSelect:()=>{Ct(N=>!N),gr(!1)}}),s.jsx(Ch,{icon:ir?s.jsx(Qn,{size:13}):s.jsx(_l,{size:13}),label:l(ir?"android.splitClose":"android.splitOpen"),active:ir,disabled:!ir&&!Sn,onSelect:()=>{hr(),gr(!1)}}),s.jsx(Ch,{icon:h==="window"?s.jsx(fT,{size:13}):s.jsx(cT,{size:13}),label:l(h==="window"?"android.exitFullscreen":"android.fullscreen"),active:h==="window",onSelect:()=>{p(h==="window"?"off":"window"),gr(!1)}}),!t&&s.jsx(Ch,{icon:h==="sidebar"?s.jsx(TT,{size:13}):s.jsx(kT,{size:13}),label:l(h==="sidebar"?"android.exitFullscreen":"android.fillSidebar"),active:h==="sidebar",onSelect:()=>{p(h==="sidebar"?"off":"sidebar"),gr(!1)}}),be&&s.jsxs("div",{className:"mt-1 border-t border-border px-3 py-2 text-[10px] leading-4 tabular-nums text-muted-foreground",children:[s.jsx("div",{className:"truncate",children:`${Je.fps} fps · ${Je.kbps} kbps`}),s.jsx("div",{className:"truncate",children:`${Je.width}×${Je.height}`})]})]}),document.body),(Se==="custom"||oe)&&s.jsxs("div",{className:"border-b border-border bg-surface-2/40 px-2 py-2 text-[11px]",children:[s.jsxs("button",{type:"button",onClick:()=>Ye(N=>!N),"aria-expanded":de,className:"flex w-full items-center gap-1 rounded text-muted-foreground hover:text-foreground",children:[s.jsx(ul,{size:12,className:`transition-transform ${de?"":"-rotate-90"}`}),s.jsxs("span",{children:[l("android.quality"),oe?` · ${Be.find(N=>N.id===oe)?.name??""}`:""]})]}),de&&s.jsxs("div",{className:"mt-2 grid gap-2",children:[s.jsx(Fb,{label:l("android.qualityResolution"),display:`${st.maxSize}px`,min:360,max:2160,step:8,value:st.maxSize,onChange:N=>Ie($=>({...$,maxSize:N}))}),s.jsx(Fb,{label:l("android.qualityBitRate"),display:`${(st.bitRate/1e6).toFixed(1)} Mbps`,min:.5,max:20,step:.5,value:st.bitRate/1e6,onChange:N=>Ie($=>({...$,bitRate:Math.round(N*1e6)}))}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-14 shrink-0 text-muted-foreground",children:l("android.qualityFrameRate")}),s.jsxs("div",{className:"flex gap-1",children:[[15,30,60].map(N=>s.jsx("button",{type:"button",onClick:()=>Ie($=>({...$,maxFps:N})),className:`rounded px-2 py-0.5 ${st.maxFps===N?"bg-surface-elevated text-primary":"text-muted-foreground hover:bg-surface-2"}`,children:N},N)),s.jsx("button",{type:"button",onClick:()=>Ie(N=>({...N,maxFps:0})),className:`rounded px-2 py-0.5 ${st.maxFps===0?"bg-surface-elevated text-primary":"text-muted-foreground hover:bg-surface-2"}`,children:l("android.qualityAuto")})]}),s.jsx("button",{type:"button",onClick:fn,disabled:!re,className:"ml-auto rounded bg-primary/15 px-2 py-1 text-primary disabled:opacity-40",children:l("android.qualityApply")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{value:rt,onChange:N=>mt(N.target.value),onKeyDown:N=>{N.key==="Enter"&&!N.nativeEvent.isComposing&&K()},placeholder:l("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"}),s.jsx("button",{type:"button",onClick:K,disabled:!rt.trim(),className:"shrink-0 rounded bg-surface-2 px-2 py-1 text-primary disabled:opacity-40",children:l("android.presetSave")}),oe&&s.jsx("button",{type:"button",onClick:Ue,className:"shrink-0 rounded px-2 py-1 text-destructive hover:bg-surface-2",children:l("android.presetDelete")})]})]})]}),et&&s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border px-2 py-2",children:[s.jsx("input",{value:Nt,onChange:N=>gt(N.target.value),onKeyDown:N=>{N.key==="Enter"&&dn()},placeholder:l("android.addressPlaceholder"),className:"min-w-0 flex-1 rounded bg-surface-2 px-2 py-1 text-[11px] outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"button",onClick:()=>{dn()},disabled:bt,className:"rounded bg-surface-2 px-2 py-1 text-[11px] text-primary disabled:opacity-40",children:bt?s.jsx(In,{size:12,className:"animate-spin"}):l("android.connect")})]}),Dr&&s.jsxs("div",{className:"flex items-start gap-2 border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:[s.jsx("span",{className:"min-w-0 flex-1",children:l("android.adbUnavailable")}),s.jsx(Pb,{label:l("android.insertFixPrompt"),onClick:()=>xr(Ob("adb",Ce??"")),enabled:!!r})]}),!Dr&&Pn&&s.jsxs("div",{className:"flex items-start gap-2 border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:[s.jsx("span",{className:"min-w-0 flex-1",children:l("android.scrcpyUnavailable")}),s.jsx(Pb,{label:l("android.insertFixPrompt"),onClick:()=>xr(Ob("scrcpy","")),enabled:!!r})]}),fs&&fs.state!=="device"&&s.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:kF(fs,l)}),Ce&&!Dr&&s.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:Cb(Ce)}),Wt&&s.jsxs("details",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:[s.jsxs("summary",{className:"cursor-pointer",children:[l("android.qualityAutoUnavailable")," ",l(Wt.startsWith("SCRCPY_VERSION")?"android.qualityAutoVersionError":Wt.startsWith("SCRCPY_BUILD")?"android.qualityAutoBuildError":/EXTENSION|SERVER_READ|PUSH/.test(Wt.split(":")[0])?"android.qualityAutoExtensionError":/TIMEOUT/.test(Wt.split(":")[0])?"android.qualityAutoTimeoutError":/ENCODER_REJECTED/.test(Wt.split(":")[0])?"android.qualityAutoEncoderError":/CHANNEL|TUNNEL|LISTEN|PROTOCOL|CONNECTION/.test(Wt.split(":")[0])?"android.qualityAutoChannelError":"android.qualityAutoUnknownError")]}),s.jsx("pre",{className:"mt-1 select-text whitespace-pre-wrap break-all text-[10px]",children:Wt})]}),vt&&s.jsx("div",{className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-warning",children:vt}),me&&s.jsx("div",{role:"alert",className:"border-b border-border bg-surface-2 px-2 py-1.5 text-[11px] text-destructive",children:me}),s.jsxs("div",{className:"relative flex min-h-0 min-w-0 flex-1 touch-none items-center justify-center overflow-hidden bg-[var(--chrome-bg)] p-1",children:[s.jsx("canvas",{ref:m,className:"max-h-full max-w-full touch-none select-none rounded",style:{display:G||be?"block":"none",transformOrigin:"center",transition:"none"},onPointerDown:kr,onPointerMove:$r,onPointerUp:Gn,onPointerCancel:()=>Sr(),onLostPointerCapture:N=>{W.current.has(N.pointerId)&&Sr()},onPointerLeave:N=>{W.current.has(N.pointerId)&&!N.currentTarget.hasPointerCapture?.(N.pointerId)&&Sr()},onContextMenu:N=>N.preventDefault()}),pe&&s.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:pe.left,top:pe.top}}),ft.length>1&&s.jsx("svg",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 h-full w-full",style:{opacity:at?1:0,transition:"opacity 160ms linear"},children:ft.slice(1).map((N,$)=>{const ee=ft[$],se=($+1)/(ft.length-1);return s.jsx("line",{x1:ee.x,y1:ee.y,x2:N.x,y2:N.y,stroke:"var(--primary)",strokeWidth:1+1.6*se,strokeLinecap:"round",opacity:.06+.45*se},$)})}),Ut.map(N=>s.jsx("span",{"aria-hidden":"true",className:"termdock-tap-fade pointer-events-none absolute h-4 w-4 rounded-full bg-primary",style:{left:N.left,top:N.top}},N.id)),!G&&s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 text-center text-[11px] text-muted-foreground",children:[We==="connecting"&&s.jsxs(s.Fragment,{children:[s.jsx(In,{size:18,className:"animate-spin"}),s.jsx("span",{children:l("android.connecting")})]}),We==="error"&&s.jsxs(s.Fragment,{children:[s.jsx(Eu,{size:14,className:"text-destructive"}),s.jsx("span",{className:"max-w-[80%] text-destructive",children:Qt?l("android.reconnecting"):Cb(H||"")}),re&&s.jsx("button",{type:"button",onClick:()=>{Y.current=0,nn(re)},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:l("android.retry")})]}),We==="idle"&&!Dr&&!Pn&&s.jsxs(s.Fragment,{children:[s.jsx(mT,{size:22,className:"opacity-60"}),s.jsx("span",{children:Wr.length?l("android.idleHint"):l("android.noDevicesHint")})]})]})]}),s.jsxs("div",{className:`flex flex-wrap items-center gap-1 border-t border-border ${Le?"px-1.5 py-0.5":"px-2 py-1.5"}`,children:[s.jsx(Eo,{compact:Le,label:l("android.back"),onClick:()=>x.current?.back(),disabled:!G,children:s.jsx(h3,{size:14})}),s.jsx(Eo,{compact:Le,label:l("android.home"),onClick:()=>x.current?.home(),disabled:!G,children:s.jsx(rT,{size:14})}),s.jsx(Eo,{compact:Le,label:l("android.recents"),onClick:()=>x.current?.recents(),disabled:!G,children:s.jsx(w3,{size:14})}),s.jsx(Eo,{compact:Le,label:l("android.notifications"),onClick:()=>x.current?.expandNotifications(),disabled:!G,children:s.jsx(x3,{size:14})}),s.jsx(Eo,{compact:Le,label:l("android.rotate"),onClick:()=>x.current?.rotate(),disabled:!G,children:s.jsx(VT,{size:14})}),s.jsx(Eo,{compact:Le,label:l("android.volumeDown"),onClick:()=>x.current?.volumeDown(),disabled:!G,children:s.jsx(xC,{size:14})}),s.jsx(Eo,{compact:Le,label:l("android.volumeUp"),onClick:()=>x.current?.volumeUp(),disabled:!G,children:s.jsx(yC,{size:14})}),s.jsx(Eo,{compact:Le,label:l("android.power"),onClick:()=>x.current?.power(),disabled:!G,children:s.jsx(zT,{size:14})}),s.jsx(Eo,{compact:Le,label:l("android.inputText"),active:yt,onClick:()=>pr(N=>!N),disabled:!G,children:s.jsx(v3,{size:14})}),s.jsx(Eo,{compact:Le,label:l("android.zoomIn"),onClick:()=>Nr("in"),disabled:!G||V>=Gh-.01,children:s.jsx(Us,{size:14})}),s.jsx(Eo,{compact:Le,label:l("android.zoomOut"),onClick:()=>Nr("out"),disabled:!G||V<=Tl+.01,children:s.jsx(A3,{size:14})}),s.jsxs("div",{className:"relative ml-auto h-5 w-24 min-w-0 max-w-full shrink-0","data-mirror-capture-status":!0,children:[s.jsx("span",{"aria-hidden":it||!!un||ht,className:`block truncate text-right text-[10px] leading-5 tabular-nums text-muted-foreground ${it||un||ht?"invisible":""}`,children:be?s.jsx(s.Fragment,{children:s.jsx("span",{ref:fe})}):""}),s.jsx("div",{className:"absolute inset-0 flex items-center justify-end overflow-hidden",children:s.jsx(SF,{recording:it,elapsed:sr,status:ht?l("android.captureInserting"):un,stopLabel:l("android.recordingStop"),onStop:()=>{Rn("manual")}})})]})]}),yt&&s.jsxs("div",{className:"flex items-center gap-1.5 border-t border-border px-2 py-1.5",children:[s.jsx("input",{value:nr,onChange:N=>_r(N.target.value),onKeyDown:N=>{N.key==="Enter"&&!N.nativeEvent.isComposing&&(N.preventDefault(),Kn())},placeholder:l("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}),s.jsx("button",{type:"button",onClick:Kn,disabled:!nr,className:"rounded bg-surface-2 p-1.5 text-primary disabled:opacity-40",title:l("android.send"),children:s.jsx(q0,{size:13})})]})]});return h==="window"?Li.createPortal(s.jsx("div",{className:"fixed inset-0 z-modal-panel flex flex-col bg-[var(--chrome-bg)]",style:{paddingTop:"var(--safe-top-inset, env(safe-area-inset-top, 0px))",paddingBottom:"var(--safe-bottom-inset, env(safe-area-inset-bottom, 0px))"},children:z}),document.body):t?ir&&mn?Li.createPortal(z,mn):null:ir&&mn?s.jsxs(s.Fragment,{children:[Li.createPortal(z,mn),s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-[11px] text-muted-foreground",children:[s.jsx(_l,{size:18,className:"opacity-60"}),s.jsx("span",{children:l("android.splitDockedHint")}),s.jsx("button",{type:"button",onClick:()=>{Qr(M0,null),Or({docked:null})},className:"rounded bg-surface-2 px-2 py-1 text-foreground",children:l("android.splitClose")})]})]}):z}function Ch({icon:e,label:t,active:r=!1,disabled:n=!1,onSelect:a}){return s.jsxs("button",{type:"button",role:"menuitem",disabled:n,onClick:a,className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left transition hover:bg-surface-2 disabled:opacity-40 disabled:hover:bg-transparent ${r?"text-primary":"text-foreground"}`,children:[s.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:e}),s.jsx("span",{className:"min-w-0 flex-1 truncate",children:t}),r&&s.jsx(di,{size:12,className:"shrink-0"})]})}function SF({recording:e,elapsed:t,status:r,stopLabel:n,onStop:a}){return e?s.jsxs("span",{role:"status","aria-live":"polite",className:"ml-auto inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded bg-destructive/15 px-1.5 py-0.5 text-[10px] tabular-nums text-destructive",children:[s.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 animate-pulse rounded-full bg-destructive"}),Nb(t),s.jsx("button",{type:"button",onClick:a,title:n,"aria-label":`${n} · ${Nb(t)}`,className:"ml-0.5 inline-flex h-4 w-4 items-center justify-center rounded hover:bg-destructive/25",children:s.jsx(S3,{size:8,fill:"currentColor"})})]}):r?s.jsx("span",{role:"status","aria-live":"polite",title:r,className:"ml-auto truncate text-[10px] text-primary",children:r}):null}function Qb({sessionId:e}){const t=ns(x=>x.docks[H0]),r=!!t,n=t?.sessionId??e??null,c=Am(x=>x.pending)[0],l=b.useCallback(async x=>{if(!n)throw new Error("没有可接收截图的终端");const w=(await vd("/tmp",[x])).files[0]?.path;if(!w)throw new Error("截图上传未返回文件路径");await Mb(w,n)},[n]),h=b.useCallback(x=>{Am.getState().enqueue(x,n)},[n]),p=ns(x=>!!x.hosts[H0]),m=b.useRef(!1);return b.useEffect(()=>{m.current||(m.current=!0,nc().then(x=>{const y=x.androidPanel?.docked;y&&(ns.getState().docks[H0]||ns.getState().setDock(H0,y))}).catch(()=>{}))},[]),s.jsxs(s.Fragment,{children:[r&&p&&s.jsx(CF,{sessionId:n,dockOnly:!0,onInsertFile:n?l:void 0,onInsertPrompt:n?x=>R6(x,n):void 0,onRecordingComplete:h}),c&&s.jsx(bF,{file:c.file,initialPath:c.initialPath,onInsert:x=>c.insert?c.insert(x):Mb(x,c.sessionId),onDone:()=>Am.getState().remove(c.file.id)},c.file.id)]})}function Pb({label:e,onClick:t,enabled:r}){return r?s.jsx("button",{type:"button",onClick:t,className:"shrink-0 rounded bg-surface px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-elevated",children:e}):null}function Ob(e,t){return[`Termdock 的“设备投屏”在当前服务端不可用:未找到 ${e==="adb"?"adb(Android platform-tools)":"scrcpy / scrcpy-server"}${t?`(错误:${t})`:""}。`,"请在本机安装并让 Termdock 恢复可用:","1) 安装依赖:"," - macOS: brew install android-platform-tools scrcpy"," - Ubuntu/Debian: sudo apt install adb scrcpy"," - Windows: winget install Google.PlatformTools && winget install Genymobile.scrcpy","2) 若不在 PATH,请在 ~/.termdock/.env 指定 TERMDOCK_ADB_BIN / TERMDOCK_SCRCPY_BIN / TERMDOCK_SCRCPY_SERVER。","3) 完成后重启 Termdock 服务,并用 adb version、scrcpy --version 验证。","边界:只做本机环境安装与配置,不要改动 Termdock 仓库代码。"].join(`
156
156
  `)}function Fb({label:e,display:t,min:r,max:n,step:a,value:c,onChange:l}){return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-14 shrink-0 text-muted-foreground",children:e}),s.jsx("input",{type:"range",min:r,max:n,step:a,value:c,onChange:h=>l(Number(h.target.value)),className:"h-1 min-w-0 flex-1 accent-primary","aria-label":e}),s.jsx("span",{className:"w-16 shrink-0 text-right tabular-nums text-muted-foreground",children:t})]})}function Eo({label:e,onClick:t,disabled:r,active:n,compact:a,children:c}){return s.jsx("button",{type:"button",onClick:t,disabled:r,title:e,"aria-label":e,className:`${a?"inline-flex h-5 w-5 items-center justify-center":"p-1.5"} rounded transition active:scale-95 disabled:opacity-30 ${n?"bg-surface-elevated text-primary":"text-muted-foreground hover:bg-surface-2"}`,children:c})}function $b(e,t,r){const n=e.parentElement;if(!n)return null;const a=e.getBoundingClientRect(),c=n.getBoundingClientRect();return{left:a.left-c.left+(t-a.left),top:a.top-c.top+(r-a.top)}}function Sh(e,t,r){const n=e.getBoundingClientRect(),a=e.width||n.width,c=e.height||n.height,l=n.width?(t-n.left)/n.width*a:0,h=n.height?(r-n.top)/n.height*c:0;return{x:Math.max(0,Math.min(a,l)),y:Math.max(0,Math.min(c,h))}}function _F(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 Ub(e,t){return e.state==="device"?e.androidVersion?` · Android ${e.androidVersion}`:"":e.state==="unauthorized"?` · ${t("android.stateUnauthorized")}`:e.state==="offline"?` · ${t("android.stateOffline")}`:` · ${t("android.stateUnknown")}`}function kF(e,t){return e.state==="unauthorized"?t("android.unauthorizedHint"):e.state==="offline"?t("android.offlineHint"):t("android.stateUnknown")}function LF(e){return e>=90?"var(--destructive)":e>=70?"var(--warning)":"var(--success)"}function IF(e){return e>=90?"var(--destructive)/0.15":e>=70?"var(--warning)/0.15":"var(--success)/0.12"}function EF(e){if(!e)return"";const t=new Date(e),r=Date.now(),n=t.getTime()-r;if(n<=0)return"";const a=Math.floor(n/6e4),c=Math.floor(a/60),l=Math.floor(c/24),h=c%24,p=a%60,m=t.toLocaleDateString(void 0,{month:"short",day:"numeric"}),x=t.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"});let y;return l>0?y=`${l}d ${h}h`:h>0?y=`${h}h ${p}m`:p>0?y=`${p}m`:y="soon",`resets in ${y} (${m} ${x})`}function NF(e){return{claude:"🧠",codex:"✨",kimi:"🌙",copilot:"🐙",grok:"🚀",gemini:"💎"}[e]||"📊"}function RF({result:e}){const{t}=zr(),r=e.windows.filter(h=>h.percent===0&&!h.resetAt),n=e.windows.filter(h=>h.percent>0||h.resetAt),a=r.length>0?r.map(h=>h.label).join(" · "):"",c=!!e.error;let l=null;return!c&&e.entitlement&&(e.usagePercent>=90?l=t("quota.exhausted"):e.remaining!==void 0&&e.remaining<e.entitlement?l=t("quota.left",{n:e.remaining}):l=`${Math.round(e.usagePercent)}%`),s.jsxs("div",{className:"rounded-xl border border-border/15 bg-surface-2 p-3 sm:p-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[13px] font-semibold text-foreground",children:[s.jsx("span",{className:"shrink-0",children:NF(e.slug)}),s.jsx("span",{className:"truncate",children:e.displayName}),a&&s.jsx("span",{className:"shrink-0 rounded-full bg-surface-elevated px-2 py-0.5 text-[10px] font-normal text-muted-foreground",children:a})]}),l&&s.jsx("span",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground",children:l})]}),n.length>0?s.jsx("div",{className:"mt-2.5 space-y-2",children:n.map(h=>{const p=Math.max(0,Math.min(100,h.percent));return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 text-[12px]",children:[s.jsx("span",{className:"w-14 shrink-0 truncate text-muted-foreground sm:w-16",children:h.label}),s.jsx("div",{className:"flex-1",children:s.jsx("div",{className:"h-2 rounded-full",style:{background:IF(h.percent)},children:s.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${p}%`,background:LF(h.percent)}})})}),s.jsxs("span",{className:"w-9 shrink-0 text-right tabular-nums font-medium text-foreground",children:[Math.round(h.percent),"%"]})]}),h.resetAt&&s.jsx("p",{className:"mt-1 pl-14 text-[10px] text-muted-foreground sm:pl-16",children:EF(h.resetAt)})]},h.label)})}):c?s.jsx("p",{className:"mt-2 text-[11px] text-muted-foreground",children:e.error}):null]})}function MF({isOpen:e,onClose:t}){const{t:r}=zr(),[n,a]=b.useState([]),[c,l]=b.useState(!1),h=async(x=!1)=>{l(!0);try{const y=x?await Zw():await Kw();a(y.providers||[])}catch{}finally{l(!1)}};if(b.useEffect(()=>{e&&h()},[e]),b.useEffect(()=>{if(!e)return;const x=y=>{const w=y.detail;Array.isArray(w)&&a(w)};return window.addEventListener("termdock:quota-update",x),()=>{window.removeEventListener("termdock:quota-update",x)}},[e]),!e)return null;const p=n.filter(x=>!x.error),m=p.length>0?new Date(Math.max(...p.map(x=>x.fetchedAt||0))):null;return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm cursor-default",onClick:t}),s.jsxs("div",{className:"fixed inset-x-3 z-modal-panel mx-auto flex max-w-lg flex-col overflow-hidden rounded-2xl bg-surface border border-border/15 shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)]",style:{top:"max(1.5rem, env(safe-area-inset-top, 0px))",bottom:"max(1.5rem, env(safe-area-inset-bottom, 0px))"},children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/15 px-3 py-2.5 sm:px-6 sm:py-3",children:[s.jsx("h2",{className:"text-[14px] font-semibold text-foreground sm:text-base",children:r("quota.title")}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("button",{type:"button",onClick:()=>h(!0),disabled:c,className:"shrink-0 rounded-full bg-surface-2 p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-50","aria-label":r("quota.refresh"),children:s.jsx(yn,{size:15,className:c?"animate-spin":""})}),s.jsx("button",{type:"button",onClick:t,className:"shrink-0 rounded-full bg-surface-2 p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":r("quota.close"),children:s.jsx(Qn,{size:17})})]})]}),s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-3 sm:p-5",children:[c&&p.length===0?s.jsx(nd,{label:r("common.loading"),className:"py-12"}):p.length===0?s.jsxs("div",{className:"py-8 text-center text-[13px] text-muted-foreground",children:[s.jsx("p",{children:r("quota.noProviders")}),s.jsx("p",{className:"mt-1.5 text-[11px]",children:r("quota.noProvidersHint")})]}):s.jsx("div",{className:"space-y-2.5",children:p.map(x=>s.jsx(RF,{result:x},x.slug))}),m&&s.jsx("p",{className:"mt-3 text-center text-[10px] text-muted-foreground",children:r("quota.updated",{time:m.toLocaleTimeString()})})]})]})]})}const zb=[{label:"Esc",sequence:"\\u001b"},{label:"Tab",sequence:"\\t"},{label:"Enter",sequence:"\\r"},{label:"S-Tab",sequence:"\\u001b[Z"},{label:"C-c",sequence:"\\u0003"},{label:"C-d",sequence:"\\u0004"},{label:"C-l",sequence:"\\u000c"},{label:"C-r",sequence:"\\u0012"},{label:"C-z",sequence:"\\u001a"},{label:"C-w",sequence:"\\u0017"},{label:"Up",sequence:"\\u001b[A"},{label:"Down",sequence:"\\u001b[B"},{label:"Left",sequence:"\\u001b[D"},{label:"Right",sequence:"\\u001b[C"},{label:"PgUp",sequence:"\\u001b[5~"},{label:"PgDn",sequence:"\\u001b[6~"}],jF=2,DF=20;function BF({label:e}){return s.jsx("div",{className:"h-7 rounded-full bg-surface-2 px-3 text-[11px] leading-7 text-center text-muted-foreground truncate",children:e})}function QF({value:e,onChange:t,placeholder:r}){const{t:n}=zr(),[a,c]=_.useState(""),l=y=>{const w=[];let v="",k=!1;const L=()=>{const R=v.trim();R&&w.push(R),v=""};for(let R=0;R<y.length;R+=1){const B=y[R];if(!k&&B==="/"&&v.trim().length===0){k=!0,v+=B;continue}if(k){if(v+=B,B==="/"&&y[R-1]!=="\\"&&v.length>1){for(;R+1<y.length&&/[gimsuy]/.test(y[R+1]??"");)R+=1,v+=y[R];L(),k=!1}continue}if(B===","||/\s/.test(B)){L();continue}v+=B}if(L(),w.length===0)return;const E=[...e];for(const R of w){const B=Iy(R);B&&(E.includes(B)||E.push(B))}t(E),c("")},h=y=>{t(e.filter(w=>w!==y))},p=a.trim(),m=p.length>0&&vx(p),x=m&&!of(p);return s.jsx("div",{className:"rounded-2xl bg-surface px-3 py-2 ring-1 ring-border/15 focus-within:ring-accent/40",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.map(y=>{const w=vx(y),v=w&&!of(y);return s.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-[11px] ${v?"bg-destructive/15 text-destructive":w?"bg-accent/15 font-mono text-accent":"bg-surface-elevated text-foreground"}`,title:w?v?n("settings.invalidRegex"):"Regex match":"Substring match (case-insensitive)",children:[w&&s.jsx("span",{className:"text-[10px] opacity-70",children:"re"}),y,s.jsx("button",{type:"button",onClick:()=>h(y),className:"rounded-full p-0.5 text-muted-foreground hover:bg-destructive/20 hover:text-destructive","aria-label":n("toolbarPresets.removeAction",{name:y}),children:s.jsx(Qn,{size:12})})]},y)}),s.jsx("input",{type:"text",value:a,onChange:y=>c(y.target.value),onKeyDown:y=>{y.key==="Enter"||y.key===","&&!m?(y.preventDefault(),l(a)):y.key==="Backspace"&&a.length===0&&e.length>0&&h(e[e.length-1])},onBlur:()=>l(a),placeholder:e.length===0?r:"",className:`min-w-[8ch] flex-1 bg-transparent py-1 text-sm outline-none placeholder:text-muted/60 ${m?"font-mono":""} ${x?"text-destructive":""}`,autoCapitalize:"off",autoCorrect:"off",autoComplete:"off"})]})})}function PF({value:e,min:t,max:r,onChange:n}){const{t:a}=zr();return s.jsxs("div",{className:"inline-flex items-center gap-1 rounded-full bg-surface px-1 py-1 ring-1 ring-border/15",children:[s.jsx("button",{type:"button",onClick:()=>n(Math.max(t,e-1)),disabled:e<=t,className:"h-7 w-7 rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated disabled:opacity-40 inline-flex items-center justify-center","aria-label":a("common.decrease"),children:s.jsx(A3,{size:14})}),s.jsx("span",{className:"w-6 text-center text-sm font-medium tabular-nums text-foreground",children:e}),s.jsx("button",{type:"button",onClick:()=>n(Math.min(r,e+1)),disabled:e>=r,className:"h-7 w-7 rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated disabled:opacity-40 inline-flex items-center justify-center","aria-label":a("common.increase"),children:s.jsx(Us,{size:14})})]})}const OF=({presets:e,selectedPresetId:t,onSelectPreset:r,onUpdatePreset:n,onAddPreset:a,onRemovePreset:c,onResetDefaults:l})=>{const{t:h}=zr(),p=e.find(R=>R.id===t)??e[0]??null,[m,x]=_.useState(null);if(!p)return null;const y=p.actions.length>0,w=[{id:"preview-auto",label:p.label,kind:"preset"},...p.includeAlt?[{id:"preview-alt",label:"Alt"}]:[],...y?p.actions.map((R,B)=>({id:R.id,label:Zm(R,B)})):["Enter","Home","End","Ctrl-C","Ctrl-D"].map(R=>({id:R,label:R}))],v=Ey(w,p.rowLayout),k=(R,B)=>{n(p.id,W=>{const F=W.actions.findIndex(Z=>Z.id===R);if(F===-1)return W;const U=F+B;if(U<0||U>=W.actions.length)return W;const V=[...W.actions];return[V[F],V[U]]=[V[U],V[F]],{...W,actions:V}})},L=p.rowLayout.reduce((R,B)=>R+B,0),E=1+(p.includeAlt?1:0);return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"sticky top-[-1rem] sm:top-[-1.5rem] z-10 -mx-4 -mt-4 sm:-mx-6 sm:-mt-6 border-b border-border/15 bg-surface/95 backdrop-blur px-4 py-3 sm:px-6",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[s.jsx("span",{className:"ui-kicker",children:h("toolbarPresets.preview")}),s.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[p.actions.length," button",p.actions.length===1?"":"s"," · ",L," slot",L===1?"":"s"]})]}),s.jsx("div",{className:"space-y-1 rounded-2xl bg-surface-2/60 p-2",children:v.map((R,B)=>{const W=R.items[0]?.kind==="preset",F=Math.max(2,R.columns),U=W?`${Ny}px repeat(${Math.max(1,F-1)}, minmax(0, 1fr))`:`repeat(${F}, minmax(0, 1fr))`;return s.jsx("div",{className:"grid gap-1",style:{gridTemplateColumns:U},children:R.items.map(V=>V.kind==="preset"?s.jsx(Ry,{mode:"auto",presetLabel:V.label,title:`Auto preset · ${V.label}`,disabled:!0},V.id):s.jsx(BF,{label:V.label},V.id))},`preview-row-${B}`)})}),p.actions.length>L-E&&s.jsx("p",{className:"mt-1.5 text-[10px] text-muted-foreground",children:h("toolbarPresets.overCapacityHint")})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"ui-kicker",children:h("toolbarPresets.presets")}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("button",{type:"button",onClick:a,className:"inline-flex items-center gap-1 rounded-full bg-surface-2 px-3 py-2 text-xs font-medium hover:bg-surface-elevated transition",children:[s.jsx(Us,{size:14}),h("toolbarPresets.new")]}),s.jsxs("button",{type:"button",onClick:l,className:"inline-flex items-center gap-1 rounded-full bg-surface-2 px-3 py-2 text-xs font-medium hover:bg-surface-elevated transition",children:[s.jsx(yn,{size:14}),h("toolbarPresets.reset")]})]})]}),s.jsx("div",{className:"-mx-1 flex flex-wrap gap-1.5 px-1",children:e.map(R=>s.jsxs("button",{type:"button",onClick:()=>r(R.id),className:`rounded-full px-3 py-2 text-xs font-medium transition ${R.id===p.id?"bg-primary/20 text-primary ring-1 ring-primary/30":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated"}`,children:[R.label,R.actions.length>0&&s.jsx("span",{className:"ml-1.5 text-[10px] text-muted-foreground",children:R.actions.length})]},R.id))})]}),s.jsxs("div",{className:"space-y-4 rounded-2xl bg-surface p-4 ring-1 ring-border/10",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:"ui-kicker",children:h("toolbarPresets.label")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"text",value:p.label,onChange:R=>n(p.id,B=>({...B,label:R.target.value})),className:"flex-1 rounded-full bg-surface-2 px-4 py-2.5 text-sm placeholder:text-muted/60 outline-none ring-1 ring-transparent focus:ring-accent/40",placeholder:h("toolbarPresets.presetLabelPlaceholder"),autoCapitalize:"off",autoCorrect:"off"}),p.id!=="default"&&s.jsx("button",{type:"button",onClick:()=>c(p.id),className:"shrink-0 rounded-full bg-surface-2 px-3 py-2.5 text-destructive hover:bg-destructive/15","aria-label":h("toolbarPresets.deletePreset",{name:p.label}),children:s.jsx(zs,{size:14})})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"ui-kicker",children:h("toolbarPresets.matchPrograms")}),s.jsx("span",{className:"text-[10px] text-muted-foreground",children:h("toolbarPresets.typeEnterHint")})]}),s.jsx(QF,{value:p.programs,onChange:R=>n(p.id,B=>({...B,programs:R})),placeholder:h("toolbarPresets.programsPlaceholder")}),s.jsx("p",{className:"text-[10px] text-muted-foreground",children:h("toolbarPresets.programsHelp")})]}),s.jsxs("button",{type:"button",onClick:()=>n(p.id,R=>({...R,includeAlt:!R.includeAlt})),className:"flex w-full items-center justify-between rounded-2xl bg-surface-2 px-4 py-3 text-sm transition hover:bg-surface-elevated",children:[s.jsxs("span",{children:[s.jsx("span",{className:"block font-medium text-foreground",children:h("toolbarPresets.altSlot")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:h("toolbarPresets.altSlotHint")})]}),s.jsx(ll,{checked:p.includeAlt})]}),s.jsxs("button",{type:"button",onClick:()=>n(p.id,R=>({...R,showOnDesktop:!R.showOnDesktop})),className:"flex w-full items-center justify-between rounded-2xl bg-surface-2 px-4 py-3 text-sm transition hover:bg-surface-elevated",children:[s.jsxs("span",{children:[s.jsx("span",{className:"block font-medium text-foreground",children:h("toolbarPresets.desktopVisibility")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:h("toolbarPresets.desktopVisibilityHint")})]}),s.jsx(ll,{checked:p.showOnDesktop===!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("span",{className:"ui-kicker",children:h("toolbarPresets.rowLayout")}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:h("toolbarPresets.rowLayoutHint")})]}),s.jsxs("button",{type:"button",onClick:()=>n(p.id,R=>({...R,rowLayout:[...$1(R.rowLayout),3]})),className:"inline-flex items-center gap-1 rounded-full bg-surface-2 px-3 py-1.5 text-xs font-medium hover:bg-surface-elevated",children:[s.jsx(Us,{size:12}),h("toolbarPresets.addRow")]})]}),s.jsx("div",{className:"space-y-2",children:p.rowLayout.map((R,B)=>s.jsxs("div",{className:"flex items-center gap-3 rounded-2xl bg-surface-2 px-3 py-2",children:[s.jsx("span",{className:"w-12 shrink-0 text-xs text-muted-foreground",children:h("toolbarPresets.rowN",{n:B+1})}),s.jsx("div",{className:"flex-1"}),s.jsx(PF,{value:R,min:jF,max:DF,onChange:W=>n(p.id,F=>({...F,rowLayout:F.rowLayout.map((U,V)=>V===B?W:U)}))}),p.rowLayout.length>1&&s.jsx("button",{type:"button",onClick:()=>n(p.id,W=>({...W,rowLayout:W.rowLayout.filter((F,U)=>U!==B)})),className:"rounded-full bg-surface px-2.5 py-1 text-[11px] text-muted-foreground hover:bg-destructive/15 hover:text-destructive","aria-label":h("toolbarPresets.removeRow",{n:B+1}),children:h("toolbarPresets.del")})]},`row-${B}`))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("span",{className:"ui-kicker",children:h("toolbarPresets.buttons")}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:h("toolbarPresets.buttonsHint")})]}),s.jsxs("button",{type:"button",onClick:()=>{const R=`${p.id}-action-${Date.now()}`;n(p.id,B=>({...B,actions:[...B.actions,{id:R,label:`Key ${B.actions.length+1}`,sequence:""}]})),x(R)},className:"inline-flex items-center gap-1 rounded-full bg-primary/15 px-3 py-1.5 text-xs font-medium text-primary hover:bg-primary/25",children:[s.jsx(Us,{size:12}),h("toolbarPresets.addButton")]})]}),p.actions.length===0&&s.jsx("div",{className:"rounded-2xl bg-surface-2/60 px-4 py-6 text-center text-[11px] text-muted-foreground",children:h("toolbarPresets.noCustomButtons")}),p.actions.map((R,B)=>{const W=m===R.id;return s.jsxs("div",{className:`rounded-2xl bg-surface-2 transition ${W?"ring-1 ring-accent/40":""}`,children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[s.jsxs("div",{className:"flex flex-col gap-0.5",children:[s.jsx("button",{type:"button",onClick:()=>k(R.id,-1),disabled:B===0,className:"h-6 w-6 rounded-full bg-surface text-muted-foreground hover:bg-surface-elevated disabled:opacity-30 inline-flex items-center justify-center","aria-label":h("toolbarPresets.moveUp"),children:s.jsx(g3,{size:12})}),s.jsx("button",{type:"button",onClick:()=>k(R.id,1),disabled:B===p.actions.length-1,className:"h-6 w-6 rounded-full bg-surface text-muted-foreground hover:bg-surface-elevated disabled:opacity-30 inline-flex items-center justify-center","aria-label":h("toolbarPresets.moveDown"),children:s.jsx(uA,{size:12})})]}),s.jsxs("button",{type:"button",onClick:()=>x(W?null:R.id),className:"min-w-0 flex-1 text-left",children:[s.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:Zm(R,B)}),s.jsxs("div",{className:"truncate text-[11px] text-muted-foreground",children:[R.sequence?R.sequence:h("toolbarPresets.noSequence"),R.doubleTapSequence&&s.jsxs("span",{className:"ml-1 text-accent/70",children:["· 2× ",R.doubleTapSequence]})]})]}),s.jsx("button",{type:"button",onClick:()=>n(p.id,F=>({...F,actions:F.actions.filter(U=>U.id!==R.id)})),className:"shrink-0 rounded-full bg-surface p-2 text-muted-foreground hover:bg-destructive/15 hover:text-destructive","aria-label":h("toolbarPresets.removeAction",{name:R.label}),children:s.jsx(zs,{size:14})})]}),W&&s.jsxs("div",{className:"space-y-3 border-t border-border/10 px-3 py-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:h("toolbarPresets.labelField")}),s.jsx("input",{type:"text",value:R.label,onChange:F=>n(p.id,U=>({...U,actions:U.actions.map(V=>V.id===R.id?{...V,label:F.target.value}:V)})),className:"w-full rounded-full bg-surface px-4 py-2.5 text-sm outline-none ring-1 ring-transparent focus:ring-accent/40",placeholder:h("toolbarPresets.labelPlaceholder"),autoCapitalize:"off",autoCorrect:"off"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:h("toolbarPresets.sequence")}),s.jsx("input",{type:"text",value:R.sequence,onChange:F=>n(p.id,U=>({...U,actions:U.actions.map(V=>V.id===R.id?{...V,sequence:F.target.value}:V)})),className:"w-full rounded-full bg-surface px-4 py-2.5 font-mono text-sm outline-none ring-1 ring-transparent focus:ring-accent/40",placeholder:h("toolbarPresets.sequencePlaceholder"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),s.jsx("div",{className:"flex flex-wrap gap-1.5 pt-1",children:zb.map(F=>s.jsx("button",{type:"button",onClick:()=>n(p.id,U=>({...U,actions:U.actions.map(V=>V.id===R.id?{...V,sequence:F.sequence}:V)})),className:"rounded-full bg-surface px-2.5 py-1 text-[11px] font-medium text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:F.label},F.label))})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[11px] uppercase tracking-wider text-muted-foreground",children:h("toolbarPresets.doubleTap")}),!R.doubleTapSequence&&s.jsx("button",{type:"button",onClick:()=>n(p.id,F=>({...F,actions:F.actions.map(U=>U.id===R.id?{...U,doubleTapSequence:""}:U)})),className:"text-[10px] text-accent hover:text-accent/80",children:h("toolbarPresets.doubleTapAdd")})]}),R.doubleTapSequence!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("input",{type:"text",value:R.doubleTapSequence,onChange:F=>n(p.id,U=>({...U,actions:U.actions.map(V=>V.id===R.id?{...V,doubleTapSequence:F.target.value}:V)})),className:"w-full rounded-full bg-surface px-4 py-2.5 font-mono text-sm outline-none ring-1 ring-transparent focus:ring-accent/40",placeholder:h("toolbarPresets.doubleTapPlaceholder"),autoCapitalize:"off",autoCorrect:"off",spellCheck:!1}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[zb.map(F=>s.jsx("button",{type:"button",onClick:()=>n(p.id,U=>({...U,actions:U.actions.map(V=>V.id===R.id?{...V,doubleTapSequence:(V.doubleTapSequence??"")+F.sequence}:V)})),className:"rounded-full bg-surface px-2.5 py-1 text-[11px] font-medium text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:F.label},F.label)),s.jsx("button",{type:"button",onClick:()=>n(p.id,F=>({...F,actions:F.actions.map(U=>{if(U.id!==R.id)return U;const{doubleTapSequence:V,...Z}=U;return Z})})),className:"rounded-full bg-destructive/10 px-2.5 py-1 text-[11px] font-medium text-destructive/70 hover:bg-destructive/20 hover:text-destructive",children:h("toolbarPresets.remove")})]})]})]})]})]},R.id)})]})]})]})},FF={installed:"text-[color:var(--success)]",outdated:"text-[color:var(--warning)]","needs-approval":"text-[color:var(--warning)]","not-installed":"text-muted-foreground"};function $F(){const{t:e}=zr(),[t,r]=_.useState(null),[n,a]=_.useState(null),[c,l]=_.useState(null),[h,p]=_.useState(null),[m,x]=_.useState(!1),[y,w]=_.useState(!1),[v,k]=_.useState(""),[L,E]=_.useState(""),[R,B]=_.useState(null),[W,F]=_.useState([]),[U,V]=_.useState([]),[Z,le]=_.useState(null),[xe,fe]=_.useState(new Set),[te,ke]=_.useState(null),[$e,Y]=_.useState("auto"),[Ae,lt]=_.useState({}),[Ce,ye]=_.useState(null),[_e,je]=_.useState(null),[re,Pe]=_.useState(10),[Se,Ee]=_.useState(""),[Be,Ne]=_.useState(""),[oe,He]=_.useState(12e3),[rt,mt]=_.useState(null),[de,Ye]=_.useState(null),st=_.useCallback(async()=>{const[pe,Ge,ft,q]=await Promise.allSettled([Xw(),Jw(),nc(),e0()]);if(r(pe.status==="fulfilled"?pe.value:[]),Ge.status==="fulfilled"){const at=Ge.value;F(at.plugins??[]),V(at.errors??[])}else F([]),V([]);if(ft.status==="fulfilled"){const at=ft.value;fe(new Set(at.autoRenameAgents??[])),Y(at.autoRenameNamer??"auto"),lt(at.autoRenameModels??{}),Pe(at.autoRenameIntervalMinutes??10),Ee(at.autoRenamePromptPreference??""),Ne(at.autoRenamePromptPreference??""),He(at.autoRenamePromptPayloadChars??12e3)}else fe(new Set);ye(q.status==="fulfilled"?q.value:[])},[]);_.useEffect(()=>{st()},[st]);const Ie=async(pe,Ge)=>{a(pe),l(null);try{Ge==="install"?(await e9(pe)).devMode&&p(pe):(await t9(pe),h===pe&&p(null)),await st()}catch(ft){l(ft instanceof Error?ft.message:String(ft))}finally{a(null)}},We=pe=>e(pe==="installed"?"settings.agentHooksInstalled":pe==="outdated"?"settings.agentHooksOutdated":pe==="needs-approval"?"settings.agentHooksNeedsApproval":"settings.agentHooksNotInstalled"),Te=async()=>{B(null);let pe;try{pe=JSON.parse(L)}catch{B("Invalid JSON");return}try{await o9(pe),E(""),x(!1),await st()}catch(Ge){if(Ge instanceof l9&&Ge.migration){V(ft=>[{slug:typeof pe.slug=="string"?pe.slug:"manifest.json",errors:Ge.message.split(`
157
157
  `),code:Ge.code,migration:Ge.migration},...ft.filter(q=>q.slug!==pe.slug)]);return}B(Ge instanceof Error?Ge.message:String(Ge))}},H=async()=>{const pe=v.trim();if(pe){mt("install"),B(null);try{await r9(pe),k(""),w(!1),await st()}catch(Ge){B(Ge instanceof Error?Ge.message:String(Ge))}finally{mt(null)}}},ae=async pe=>{mt(`remove:${pe}`);try{await a9(pe),Ye(Ge=>Ge?.slug===pe?null:Ge),await st()}catch(Ge){l(Ge instanceof Error?Ge.message:String(Ge))}finally{mt(null)}},be=async pe=>{mt(`check:${pe}`),l(null);try{await i9(pe),await st()}catch(Ge){l(Ge instanceof Error?Ge.message:String(Ge))}finally{mt(null)}},Ze=async pe=>{mt(`update:${pe}`),l(null);try{const Ge=await s9(pe),ft=[Ge.hookWarning,Ge.titleWarning].filter(Boolean).join(" ");ft&&l(ft),Ye(q=>q?.slug===pe?null:q),await st()}catch(Ge){l(Ge instanceof Error?Ge.message:String(Ge))}finally{mt(null)}},Je=async pe=>{mt(`doctor:${pe}`),l(null),Ye(null);try{const Ge=await n9(pe);Ye(Ge),ye(await e0())}catch(Ge){l(Ge instanceof Error?Ge.message:String(Ge))}finally{mt(null)}},Tt=async pe=>{const Ge=pe.migration?.aiPrompt??pe.errors.join(`
158
158
  `);try{await navigator.clipboard.writeText(Ge),le(pe.slug),window.setTimeout(()=>le(ft=>ft===pe.slug?null:ft),1800)}catch{B(Ge)}},Wt=async pe=>{if(te)return;const Ge=xe,ft=new Set(Ge);ft.has(pe)?ft.delete(pe):ft.add(pe),fe(ft),ke(pe),l(null);try{const q=await wa({autoRenameAgents:[...ft]});fe(new Set(q.autoRenameAgents??[])),ye(await e0(!0))}catch(q){fe(Ge),l(q instanceof Error?q.message:String(q))}finally{ke(null)}},Mt=async pe=>{const Ge=$e;Y(pe),je("namer"),l(null);try{const ft=await wa({autoRenameNamer:pe});Y(ft.autoRenameNamer??"auto"),ye(await e0(!0))}catch(ft){Y(Ge),l(ft instanceof Error?ft.message:String(ft))}finally{je(null)}},vt=async(pe,Ge)=>{const ft=Ae,q={...ft};Ge?q[pe]=Ge:delete q[pe],lt(q),je(pe),l(null);try{const at=await wa({autoRenameModels:q});lt(at.autoRenameModels??{})}catch(at){lt(ft),l(at instanceof Error?at.message:String(at))}finally{je(null)}},Yt=async pe=>{const Ge=re;Pe(pe),je("interval"),l(null);try{const ft=await wa({autoRenameIntervalMinutes:pe});Pe(ft.autoRenameIntervalMinutes??10)}catch(ft){Pe(Ge),l(ft instanceof Error?ft.message:String(ft))}finally{je(null)}},Qt=async()=>{const pe=Se.trim();if(pe!==Be){je("preference"),l(null);try{const ft=(await wa({autoRenamePromptPreference:pe})).autoRenamePromptPreference??"";Ee(ft),Ne(ft)}catch(Ge){Ee(Be),l(Ge instanceof Error?Ge.message:String(Ge))}finally{je(null)}}},Xt=async pe=>{const Ge=Math.max(1e3,Math.min(64e3,Math.round(pe||12e3))),ft=oe;He(Ge),je("payload-limit"),l(null);try{const q=await wa({autoRenamePromptPayloadChars:Ge});He(q.autoRenamePromptPayloadChars??12e3)}catch(q){He(ft),l(q instanceof Error?q.message:String(q))}finally{je(null)}},Ut=new Set(W.map(pe=>pe.slug)),Lt=de?{ok:e("settings.agentPluginDoctorStatusOk"),"missing-title-namer":e("settings.agentPluginDoctorStatusMissing"),"cli-default":e("settings.agentPluginDoctorStatusCliDefault"),"no-models":e("settings.agentPluginDoctorStatusNoModels"),"probe-failed":e("settings.agentPluginDoctorStatusFailed")}[de.status]:"";return s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"rounded-xl bg-surface-2 px-3 py-2.5",children:[s.jsx("div",{className:"text-[12px] font-medium text-foreground",children:e("settings.agentAutoRename")}),s.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:e("settings.agentAutoRenameHint")}),s.jsxs("label",{className:"mt-2 flex items-center justify-between gap-3",children:[s.jsx("span",{className:"text-[11px] text-muted-foreground",children:e("settings.agentAutoRenameNamer")}),s.jsxs("select",{value:$e,disabled:_e!==null,onChange:pe=>{Mt(pe.target.value)},className:"min-w-0 rounded-lg bg-surface px-2.5 py-1.5 text-[11px] text-foreground outline-none disabled:opacity-50",children:[s.jsx("option",{value:"auto",children:e("settings.agentAutoRenameFollow")}),Ce?.filter(pe=>pe.available).map(pe=>s.jsx("option",{value:pe.slug,children:pe.displayName},pe.slug))]})]}),s.jsxs("label",{className:"mt-2 flex items-center justify-between gap-3",children:[s.jsx("span",{className:"text-[11px] text-muted-foreground",children:e("settings.agentAutoRenameInterval")}),s.jsx("select",{value:re,disabled:_e!==null,onChange:pe=>{Yt(Number(pe.target.value))},className:"min-w-0 rounded-lg bg-surface px-2.5 py-1.5 text-[11px] text-foreground outline-none disabled:opacity-50",children:[5,10,30,60].map(pe=>s.jsxs("option",{value:pe,children:[pe," ",e("settings.agentAutoRenameMinutes")]},pe))})]}),s.jsxs("details",{className:"mt-2 border-t border-border/40 pt-2",children:[s.jsx("summary",{className:"cursor-pointer select-none text-[11px] text-muted-foreground transition hover:text-foreground",children:e("settings.agentAutoRenameAdvanced")}),s.jsxs("label",{className:"mt-2 block",children:[s.jsx("span",{className:"text-[11px] font-medium text-foreground",children:e("settings.agentAutoRenamePreference")}),s.jsx("span",{className:"mt-0.5 block text-[10px] text-muted-foreground",children:e("settings.agentAutoRenamePreferenceHint")}),s.jsx("textarea",{value:Se,maxLength:2e3,rows:3,disabled:_e!==null,placeholder:e("settings.agentAutoRenamePreferencePlaceholder"),onChange:pe=>Ee(pe.target.value),onBlur:()=>{Qt()},className:"mt-1.5 w-full resize-y rounded-lg bg-surface px-2.5 py-2 text-[11px] text-foreground outline-none placeholder:text-muted-foreground/70 focus:ring-1 focus:ring-primary/50 disabled:opacity-50"}),s.jsx("span",{className:"mt-1 block text-right text-[10px] text-muted-foreground",children:_e==="preference"?e("settings.saving"):`${Se.length}/2000`})]}),s.jsxs("label",{className:"mt-2 block",children:[s.jsx("span",{className:"text-[11px] font-medium text-foreground",children:e("settings.agentAutoRenamePayloadLimit")}),s.jsx("span",{className:"mt-0.5 block text-[10px] text-muted-foreground",children:e("settings.agentAutoRenamePayloadLimitHint")}),s.jsx("input",{type:"number",min:1e3,max:64e3,step:1e3,value:oe,disabled:_e!==null,onChange:pe=>He(Number(pe.target.value)),onBlur:pe=>{Xt(Number(pe.target.value))},className:"mt-1.5 w-full rounded-lg bg-surface px-2.5 py-2 text-[11px] text-foreground outline-none focus:ring-1 focus:ring-primary/50 disabled:opacity-50"})]})]}),s.jsxs("div",{className:"mt-2 space-y-1.5 border-t border-border/40 pt-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-[10px] text-muted-foreground",children:e("settings.agentAutoRenameModelsFromCli")}),s.jsx("button",{type:"button",onClick:async()=>{ye(null);try{ye(await e0(!0))}catch{ye([])}},className:"rounded p-1 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",title:e("settings.agentAutoRenameRefreshModels"),children:s.jsx(yn,{size:11,className:Ce===null?"animate-spin":""})})]}),Ce?.filter(pe=>pe.available).map(pe=>{const Ge=pe.models.find(ft=>ft.id===pe.recommendedModel);return s.jsxs("label",{className:"flex items-center justify-between gap-3",children:[s.jsx("span",{className:"text-[11px] text-muted-foreground",children:pe.displayName}),s.jsxs("select",{value:Ae[pe.slug]??"",disabled:_e!==null,onChange:ft=>{vt(pe.slug,ft.target.value)},className:"min-w-0 max-w-[68%] rounded-lg bg-surface px-2.5 py-1.5 text-[11px] text-foreground outline-none disabled:opacity-50",children:[s.jsx("option",{value:"",children:Ge?`${e("settings.agentAutoRenameAutomatic")} · ${Ge.displayName}`:e("settings.agentAutoRenameCliDefault")}),pe.models.map(ft=>s.jsx("option",{value:ft.id,children:ft.displayName},ft.id))]})]},pe.slug)}),Ce?.length===0&&s.jsx("div",{className:"text-[10px] text-[color:var(--warning)]",children:e("settings.agentAutoRenameNoCli")})]})]}),t===null&&s.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[s.jsx(In,{size:12,className:"animate-spin"})," …"]}),t?.map(pe=>{const Ge=n===pe.slug,ft=pe.state!=="not-installed",q=Ut.has(pe.slug);return s.jsxs("div",{className:"flex items-center gap-3 rounded-xl bg-surface-2 px-3 py-2.5",children:[s.jsx(Mc,{agent:{slug:pe.slug,displayName:pe.displayName,accentColor:pe.accentColor??"#878580",icon:pe.icon,isPlugin:q,iconMode:pe.iconMode,iconVersion:pe.iconVersion??void 0},size:18}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[13px] font-medium text-foreground",children:pe.displayName}),q&&s.jsx("span",{className:"rounded bg-[rgb(var(--success-rgb)_/_0.12)] px-1 py-px text-[9px] font-medium text-[color:var(--success)]",children:"plugin"}),s.jsxs("span",{className:`text-[10px] ${FF[pe.state]}`,children:[pe.state==="installed"&&s.jsx(Iu,{size:10,className:"mr-0.5 inline"}),(pe.state==="outdated"||pe.state==="needs-approval")&&s.jsx(k1,{size:10,className:"mr-0.5 inline"}),We(pe.state)]})]}),s.jsxs("div",{className:"truncate text-[10px] text-muted-foreground",title:pe.targetDisplay,children:[e("settings.agentHooksTarget")," ",pe.targetDisplay]}),h===pe.slug&&s.jsx("div",{className:"mt-0.5 text-[10px] text-[color:var(--warning)]",children:e("settings.agentHooksDevMode")}),pe.state==="needs-approval"&&s.jsx("div",{className:"mt-0.5 text-[10px] text-[color:var(--warning)]",children:e("settings.agentHooksApprovalHint")})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("button",{type:"button",disabled:te!==null,onClick:()=>{Wt(pe.slug)},className:"flex shrink-0 items-center gap-1.5 rounded-full px-2 py-1 text-[10px] text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-50","aria-pressed":xe.has(pe.slug),title:e("settings.agentAutoRenameToggle"),children:[s.jsx("span",{children:e("settings.agentAutoRenameShort")}),s.jsx(ll,{checked:xe.has(pe.slug),disabled:te!==null,size:"sm"})]}),s.jsxs("button",{type:"button",disabled:Ge,onClick:()=>{Ie(pe.slug,ft?"uninstall":"install")},className:`flex shrink-0 items-center gap-1 rounded-full px-2.5 py-1 text-[11px] font-medium transition ${ft?"bg-surface text-muted-foreground hover:bg-surface-elevated hover:text-foreground":"bg-[rgb(var(--success-rgb)_/_0.14)] text-[color:var(--success)] hover:bg-[rgb(var(--success-rgb)_/_0.22)]"} disabled:opacity-50`,children:[Ge?s.jsx(In,{size:11,className:"animate-spin"}):ft?s.jsx(zs,{size:11}):pe.state==="outdated"?s.jsx(yn,{size:11}):s.jsx(id,{size:11}),Ge?"…":ft?e("settings.agentHooksUninstall"):pe.state==="outdated"?e("settings.agentHooksReinstall"):e("settings.agentHooksInstall")]})]})]},pe.slug)}),c&&s.jsx("div",{className:"rounded-xl bg-[rgb(var(--warning-rgb)_/_0.10)] px-3 py-2 text-[11px] text-[color:var(--warning)]",children:c}),s.jsxs("div",{className:"rounded-xl bg-surface-2 px-3 py-2.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[12px] font-medium text-foreground",children:e("settings.agentPlugins")}),s.jsxs("button",{type:"button",onClick:()=>w(!y),className:"flex items-center gap-1 rounded-full bg-[rgb(var(--success-rgb)_/_0.14)] px-2.5 py-1 text-[11px] font-medium text-[color:var(--success)] hover:bg-[rgb(var(--success-rgb)_/_0.22)] transition",children:[s.jsx(Us,{size:11}),e("settings.agentPluginAdd")]})]}),s.jsx("p",{className:"mt-1 text-[10px] text-muted-foreground",children:e("settings.agentPluginHint")}),y&&s.jsxs("div",{className:"mt-2 space-y-2",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{value:v,onChange:pe=>k(pe.target.value),onKeyDown:pe=>{pe.key==="Enter"&&H()},className:"min-w-0 flex-1 rounded-lg bg-surface px-3 py-2 font-mono text-[11px] text-foreground placeholder:text-muted-foreground outline-none",placeholder:e("settings.agentPluginSourcePlaceholder")}),s.jsxs("button",{type:"button",disabled:!v.trim()||rt!==null,onClick:()=>{H()},className:"flex items-center gap-1 rounded-full bg-[rgb(var(--success-rgb)_/_0.14)] px-3 py-1 text-[11px] font-medium text-[color:var(--success)] transition hover:bg-[rgb(var(--success-rgb)_/_0.22)] disabled:opacity-50",children:[rt==="install"?s.jsx(In,{size:11,className:"animate-spin"}):s.jsx(id,{size:11}),e("settings.agentPluginInstallPackage")]})]}),s.jsx("button",{type:"button",onClick:()=>x(!m),className:"text-[10px] text-muted-foreground transition hover:text-foreground",children:e("settings.agentPluginAdvancedManifest")})]}),W.map(pe=>{const Ge=pe.revision?.slice(0,8),ft=rt?.endsWith(`:${pe.slug}`)===!0;return s.jsxs("div",{className:"mt-2 flex items-center gap-2 border-t border-border/40 pt-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium text-foreground",children:[s.jsx("span",{className:"truncate",children:pe.displayName}),pe.updateAvailable&&s.jsx("span",{className:"text-[9px] text-[color:var(--warning)]",children:e("settings.agentPluginUpdateAvailable")})]}),s.jsxs("div",{className:"truncate text-[9px] text-muted-foreground",title:pe.source??void 0,children:[pe.source??e("settings.agentPluginManualSource"),Ge?` · ${Ge}`:""]})]}),s.jsxs("button",{type:"button",disabled:rt!==null,onClick:()=>{Je(pe.slug)},className:"flex items-center gap-1 rounded-full bg-surface px-2 py-1 text-[10px] text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-50",title:e("settings.agentPluginDoctorHint"),children:[rt===`doctor:${pe.slug}`?s.jsx(In,{size:10,className:"animate-spin"}):s.jsx(aC,{size:10}),e("settings.agentPluginDoctor")]}),pe.updateSupported&&s.jsxs("button",{type:"button",disabled:rt!==null,onClick:()=>{pe.updateAvailable?Ze(pe.slug):be(pe.slug)},className:"flex items-center gap-1 rounded-full bg-surface px-2 py-1 text-[10px] text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-50",children:[ft?s.jsx(In,{size:10,className:"animate-spin"}):s.jsx(yn,{size:10}),pe.updateAvailable?e("settings.agentPluginUpdate"):e("settings.agentPluginCheck")]}),s.jsx("button",{type:"button",disabled:rt!==null,onClick:()=>{ae(pe.slug)},className:"rounded-full p-1 text-muted-foreground transition hover:bg-surface-elevated hover:text-[color:var(--warning)] disabled:opacity-50",title:e("settings.agentPluginDelete"),children:s.jsx(zs,{size:11})})]},pe.slug)}),de&&s.jsxs("div",{className:`mt-2 rounded-lg px-3 py-2 text-[10px] ${de.status==="ok"||de.status==="cli-default"?"bg-[rgb(var(--success-rgb)_/_0.10)] text-[color:var(--success)]":"bg-[rgb(var(--warning-rgb)_/_0.10)] text-[color:var(--warning)]"}`,children:[s.jsxs("div",{className:"font-medium",children:[de.displayName,": ",Lt]}),s.jsx("div",{className:"mt-1 text-muted-foreground",children:de.models.length>0?`${de.models.length} ${e("settings.agentPluginDoctorModels")}${de.recommendedModel?` · ${e("settings.agentPluginDoctorAutomatic")} ${de.recommendedModel}`:""}`:e("settings.agentPluginDoctorCliDefault")}),de.error&&s.jsx("div",{className:"mt-1 break-words",children:de.error}),de.warnings.length>0&&s.jsx("div",{className:"mt-1 space-y-0.5 text-muted-foreground",children:de.warnings.map(pe=>s.jsxs("div",{children:["• ",pe]},pe))}),de.nextSteps.length>0&&s.jsx("div",{className:"mt-1 space-y-0.5 text-muted-foreground",children:de.nextSteps.map(pe=>s.jsxs("div",{children:["→ ",pe]},pe))})]}),U.map(pe=>s.jsxs("div",{className:"mt-2 rounded-lg bg-[rgb(var(--warning-rgb)_/_0.10)] px-3 py-2 text-[10px] text-[color:var(--warning)]",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("span",{className:"font-medium",children:[pe.slug,": ",pe.code??e("settings.agentPluginInvalid")]}),s.jsxs("button",{type:"button",onClick:()=>{Tt(pe)},className:"flex shrink-0 items-center gap-1 rounded-full bg-[rgb(var(--warning-rgb)_/_0.14)] px-2 py-1 font-medium transition hover:bg-[rgb(var(--warning-rgb)_/_0.22)]",children:[Z===pe.slug?s.jsx(Iu,{size:10}):s.jsx(b3,{size:10}),Z===pe.slug?e("settings.agentPluginCopied"):e("settings.agentPluginCopyAiPrompt")]})]}),s.jsx("div",{className:"mt-1 whitespace-pre-wrap break-words text-muted-foreground",children:pe.errors.join(`
@@ -175,5 +175,5 @@ ${Ye.map(q=>`待回答:${q.question}`).join(`
175
175
  { "hook": "Stop", "event": "stop", "status": "complete" }
176
176
  ]
177
177
  }
178
- }`}),R&&s.jsx("div",{className:"whitespace-pre-wrap break-words text-[10px] text-[color:var(--warning)]",children:R}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>{Te()},className:"flex items-center gap-1 rounded-full bg-[rgb(var(--success-rgb)_/_0.14)] px-3 py-1 text-[11px] font-medium text-[color:var(--success)] hover:bg-[rgb(var(--success-rgb)_/_0.22)] transition",children:[s.jsx(DA,{size:11}),e("settings.agentPluginCreate")]}),s.jsx("button",{type:"button",onClick:()=>{x(!1),E(""),B(null)},className:"rounded-full px-3 py-1 text-[11px] text-muted-foreground hover:text-foreground transition",children:e("common.cancel")})]})]})]})]})}function UF({state:e,pending:t,onCheck:r,onConfirmRestart:n,desktopState:a,desktopPending:c=!1,desktopSnapshot:l,desktopActions:h,onCheckDesktop:p,onInstallDesktop:m}){const{t:x}=zr(),y=e?.status??"idle",w=t||y==="checking"||y==="installing"||y==="restarting",v=y==="ready"&&!!e?.latestVersion,k=y==="checking"?x("settings.updateChecking"):y==="installing"?x("sidebar.updateInstalling"):y==="ready"?x("sidebar.updateReady"):y==="restarting"?x("sidebar.updateRestarting"):y==="current"?x("settings.updateCurrent"):y==="error"?e?.error||x("sidebar.updateFailed"):x("settings.updateHint"),L=a?.currentVersion||l?.appVersion,E=a?.status??"idle",R=c||E==="checking"||E==="downloading"||E==="installing",B=E==="ready",W=a?.error||(E==="unsupported"?x("settings.desktopUpdateUnsupported"):E==="checking"?x("settings.desktopUpdateChecking"):E==="current"?x("settings.desktopUpdateCurrent"):E==="downloading"?x("settings.desktopUpdateDownloading"):E==="ready"?x("settings.desktopUpdateReady"):E==="installing"?x("settings.desktopUpdateInstalling"):E==="error"&&a?.error||x("settings.desktopUpdateHint"));return s.jsxs("section",{className:"mt-3 overflow-hidden rounded-xl bg-surface-2","aria-labelledby":"termdock-update-title",children:[s.jsx("div",{id:"termdock-update-title",className:"px-3 pt-3 text-[12px] font-semibold text-foreground",children:x("settings.updateTitle")}),s.jsxs("div",{className:"flex items-start justify-between gap-3 px-3 py-3",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2.5",children:[s.jsx("span",{className:`mt-0.5 inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg ${v?"bg-[rgb(var(--warning-rgb)_/_0.16)] text-[color:var(--warning)]":"bg-primary/15 text-primary"}`,children:s.jsx(yn,{size:15,className:w?"animate-spin":""})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[12px] font-medium text-foreground",children:x("settings.updateRuntimeTitle")}),s.jsx("div",{className:"mt-0.5 text-[10px] leading-relaxed text-muted-foreground",children:k}),e&&s.jsx("div",{className:"mt-1 text-[10px] tabular-nums text-muted-foreground/75",children:v&&e.latestVersion?`${e.currentVersion} → ${e.latestVersion}`:`v${e.currentVersion}`})]})]}),v?s.jsx("button",{type:"button",disabled:w,onClick:n,className:"shrink-0 rounded-full bg-[var(--warning)] px-3 py-1.5 text-[11px] font-semibold text-[color:var(--bg)] transition hover:opacity-90 disabled:cursor-wait disabled:opacity-60",children:x("sidebar.updateRestart")}):s.jsx("button",{type:"button",disabled:w,onClick:r,className:"shrink-0 rounded-full bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground transition hover:bg-surface-elevated disabled:cursor-wait disabled:opacity-60",children:x(y==="checking"?"settings.updateCheckingShort":y==="installing"?"settings.updateInstallingShort":y==="error"?"sidebar.updateRetry":y==="current"?"settings.updateCheckAgain":"settings.updateCheck")})]}),(a||h)&&s.jsxs("div",{className:"flex items-start justify-between gap-3 border-t border-border/10 px-3 py-3",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2.5",children:[s.jsx("span",{className:`mt-0.5 inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg ${B?"bg-[rgb(var(--warning-rgb)_/_0.16)] text-[color:var(--warning)]":"bg-primary/15 text-primary"}`,children:s.jsx(yn,{size:15,className:R?"animate-spin":""})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[12px] font-medium text-foreground",children:x("settings.desktopUpdateTitle")}),s.jsx("div",{className:`mt-0.5 text-[10px] leading-relaxed ${a?.error?"text-destructive":"text-muted-foreground"}`,role:a?.error?"alert":void 0,children:a?W:x(p?"settings.desktopStatusLoading":"settings.desktopUpdateUnsupported")}),s.jsx("div",{className:"mt-1 text-[10px] tabular-nums text-muted-foreground/75",children:B&&a?.latestVersion?`${a.currentVersion} → ${a.latestVersion}`:L?`v${L}`:null})]})]}),B?s.jsx("button",{type:"button",disabled:R||!m,onClick:m,className:"shrink-0 rounded-full bg-[var(--warning)] px-3 py-1.5 text-[11px] font-semibold text-[color:var(--bg)] transition hover:opacity-90 disabled:cursor-wait disabled:opacity-60",children:x("settings.desktopUpdateRestart")}):s.jsx("button",{type:"button",disabled:!a||R||E==="unsupported"||!p,onClick:p,className:"shrink-0 rounded-full bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground transition hover:bg-surface-elevated disabled:cursor-wait disabled:opacity-60",children:x(E==="installing"?"settings.updateInstallingShort":E==="downloading"?"settings.desktopUpdateDownloadingShort":E==="checking"?"settings.updateCheckingShort":E==="current"||E==="error"?"settings.desktopUpdateCheckAgain":"settings.desktopUpdateCheck")})]}),h]})}function zF({quality:e}){const{locale:t}=zr(),r=(h,p)=>t==="zh"?h:p,n=h=>h==null||!Number.isFinite(h)?"—":`${h.toFixed(1)} ms`,a=e?.diagnostics,c=h=>s.jsx("dl",{className:"grid grid-cols-[minmax(0,1fr)_auto] gap-x-3 gap-y-1.5 tabular-nums",children:h.map(([p,m])=>s.jsxs(_.Fragment,{children:[s.jsx("dt",{children:p}),s.jsx("dd",{className:"text-right text-foreground break-all",children:m})]},p))}),l=(h,p)=>s.jsxs("section",{className:"mt-3 border-t border-border/30 pt-3",children:[s.jsx("h3",{className:"mb-2 font-medium text-foreground",children:h}),p]});return s.jsxs("div",{className:"text-[11px] leading-relaxed",children:[l(r("往返统计","Round-trip statistics"),s.jsxs(s.Fragment,{children:[c([[r("平均延迟","Average latency"),n(e?.average)],["P95",n(e?.p95)],[r("服务端回包处理","Server reply handler"),n(e?.handlerMs)]]),s.jsx("p",{className:"mt-2",children:r("8 秒未响应计为超时,不等于网络丢包。回包处理仅含消息解析至构造回复,不含解密、排队和发包。","A probe times out after 8s; this is not packet loss. Handler timing covers parsing through reply creation, excluding decryption, queues and transmission.")})]})),l(r("当前发送与排队","Current buffers and queues"),a?s.jsxs(s.Fragment,{children:[c([[r("传输层发送缓冲","Transport send buffer"),`${a.bufferedBytes} B`],[r("加密通道待发送","Channel writes pending"),a.pendingWrites?r("有","Yes"):r("无","No")],[r("进行中的非终端请求","Active non-terminal requests"),a.activeRequests],[r("等待通道的请求","Requests waiting for capacity"),a.waitingRequests]]),s.jsx("p",{className:"mt-2",children:r("属于此服务共用的连接,包含文件等其他请求。","Shared by this service, including file transfers and other requests.")})]}):s.jsx("p",{children:r("尚无连接记录。","No connection record yet.")})),l(r("本次连接建立 · 历史耗时","Connection setup · recorded timings"),s.jsxs(s.Fragment,{children:[c([[r("传输通道就绪","Transport ready"),n(a?.transportOpenMs)],...a?.relay?[[r("其中:连上入口 WebSocket","Within transport: entry WebSocket"),n(a.relay.entryOpenMs)],[r("其中:请求中转至通道打开","Within transport: relay open request"),n(a.relay.routeOpenMs)]]:[],[r("Noise 加密握手","Noise handshake"),n(a?.handshakeMs)],[r("终端逻辑通道就绪","Terminal logical channel ready"),n(a?.socketOpenMs)],[r("其中:等待本地通道名额","Within logical open: local capacity wait"),n(a?.socketQueueMs)]]),s.jsx("p",{className:"mt-2",children:r("这是建链时的历史耗时,不代表当前延迟。“其中”为子项,不能重复相加;中转耗时含处理和建链,不含之前的授权。","Recorded setup timings, not live latency. “Within” rows are subsets, not additive. Relay timing includes processing and setup, excluding earlier authorization.")})]}))]})}function HF({backendSessionId:e}){const{locale:t}=zr(),r=t==="zh",[n,a]=_.useState(null),[c,l]=_.useState(!1);_.useEffect(()=>{if(a(null),!c||!e)return;const y=()=>a(c9(e));y();const w=setInterval(y,1e3);return document.addEventListener("visibilitychange",y),()=>{clearInterval(w),document.removeEventListener("visibilitychange",y)}},[e,c]);const h=n?.diagnostics,p=n?.rtt,m=n?.connected?n.waiting?r?"等待响应…":"Waiting for reply…":p==null?r?"测量中…":"Measuring…":`${p} ms · ${p<150?r?"流畅":"Low latency":p<300?r?"有延迟":"Moderate latency":r?"高延迟":"High latency"}`:r?"未连接":"Disconnected",x=y=>y==null?"—":`${Math.round(y)} ms`;return s.jsxs("div",{className:"mt-3 rounded-xl bg-surface-2 px-3 text-muted-foreground",children:[s.jsxs("button",{type:"button","aria-expanded":c,onClick:()=>l(y=>!y),className:"flex min-h-11 w-full items-center gap-2 py-2 text-[12px] tabular-nums hover:text-foreground","aria-label":`${r?"连接质量":"Connection quality"}${c?`: ${m}`:""}`,children:[s.jsx("span",{"aria-hidden":"true",className:`h-1.5 w-1.5 rounded-full ${c&&n&&(!n.connected||n.waiting||p!=null&&p>=300)?"bg-destructive":"bg-current"}`}),s.jsxs("span",{className:"flex-1 text-left",children:[r?"连接质量":"Connection quality",c?` · ${m}`:""]}),s.jsx("span",{"aria-hidden":"true",children:c?"▾":"▸"})]}),c&&s.jsxs("div",{className:"pb-3 text-[11px] leading-relaxed",children:[!e&&s.jsx("p",{children:r?"请先打开一个终端会话,再查看连接质量。":"Open a terminal session to measure connection quality."}),s.jsxs("dl",{className:"grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-2 tabular-nums",children:[s.jsx("dt",{children:r?"近期延迟":"Recent latency"}),s.jsx("dd",{className:"text-right text-foreground",children:n?.minimum==null?"—":`${Math.round(n.minimum)}–${Math.round(n.maximum??n.minimum)} ms`}),s.jsx("dt",{children:r?"波动":"Jitter"}),s.jsx("dd",{className:"text-right text-foreground",children:x(n?.jitter)}),s.jsx("dt",{children:r?"探测超时":"Probe timeouts"}),s.jsx("dd",{className:"text-right text-foreground",children:n?.samples?`${n.timeouts} / ${n.samples}`:"—"}),s.jsx("dt",{children:r?"连接路径":"Connection route"}),s.jsx("dd",{className:"text-right text-foreground break-words",children:h?`${h.path==="relay"?r?"经入口中转":"Via relay":r?"直连":"Direct"} · ${h.endpoint}`:"—"})]}),s.jsx("p",{className:"mt-2",children:r?"每 5 秒更新,统计最近 20 次;波动越小越稳定。":"Updates every 5s, using the last 20 probes. Lower jitter means more consistent latency."}),s.jsxs("details",{className:"mt-3 border-t border-border/30 pt-2",children:[s.jsx("summary",{className:"cursor-pointer py-1 hover:text-foreground",children:r?"诊断详情":"Diagnostics"}),s.jsx(zF,{quality:n})]})]})]})}const Hb={"startup-failure":"settings.serverHealthEventStartupFailure",crash:"settings.serverHealthEventCrash","crash-native":"settings.serverHealthEventCrashNative",killed:"settings.serverHealthEventKilled",wedge:"settings.serverHealthEventWedge","port-conflict":"settings.serverHealthEventPortConflict","gave-up":"settings.serverHealthEventGaveUp","exit-zero-unexpected":"settings.serverHealthEventExitZero","terminated-externally":"settings.serverHealthEventTerminated","supervisor-lost":"settings.serverHealthEventSupervisorLost","uncaught-exception":"settings.serverHealthEventUncaughtException","unhandled-rejection":"settings.serverHealthEventUnhandledRejection","exit-nonzero":"settings.serverHealthEventExitNonzero"};function WF(e){return e<1e3?`${e}ms`:e<6e4?`${Math.round(e/1e3)}s`:e<36e5?`${Math.round(e/6e4)}m`:`${Math.round(e/36e5)}h`}function GF({state:e,onDismiss:t}){const{t:r}=zr(),[n,a]=b.useState(!1),[c,l]=b.useState(!1),h=b.useRef(!1),p=b.useRef(!0);b.useEffect(()=>(p.current=!0,()=>{p.current=!1}),[]),b.useEffect(()=>{e?.supervised&&(h.current=!1,a(!1),l(!1))},[e?.supervised]),b.useEffect(()=>{if(!n)return;const W=window.setTimeout(()=>{h.current=!1,a(!1),l(!0)},45e3);return()=>window.clearTimeout(W)},[n]);const m=async()=>{if(!h.current){h.current=!0,l(!1),a(!0);try{await u9()}catch{if(!p.current)return;h.current=!1,a(!1),l(!0)}}};if(!e)return null;const x=e.incident,y=!e.supervised&&e.supervisor?.phase==="gave-up",w=!e.supervised&&e.supervisor!==null&&!e.supervisor.alive,v=y||w||e.attention,k=e.supervised&&e.supervisor?.alive&&e.supervisor.phase==="running",L=y?r("settings.serverHealthGaveUp",{count:e.supervisor?.consecutiveCrashes??0}):w?r("settings.serverHealthSupervisorLost"):e.supervised?r("settings.serverHealthSupervised"):r("settings.serverHealthUnsupervised"),E=x?r(Hb[x.event]??"settings.serverHealthUnknownEvent"):"",R=x?.causeEvent?r(Hb[x.causeEvent]??"settings.serverHealthUnknownEvent"):"",B=x?[new Date(x.at).toLocaleString(),x.uptimeMs!==null?r("settings.serverHealthUptime",{duration:WF(x.uptimeMs)}):null,x.signal?`signal ${x.signal}`:null,x.exitCode!==null?`exit ${x.exitCode}`:null].filter(Boolean).join(" · "):"";return s.jsxs("section",{className:"mt-3 overflow-hidden rounded-xl bg-surface-2","aria-labelledby":"server-health-title",children:[s.jsx("div",{id:"server-health-title",className:"px-3 pt-3 text-[12px] font-semibold text-foreground",children:r("settings.serverHealthTitle")}),s.jsxs("div",{className:"flex items-start justify-between gap-3 px-3 py-3",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2.5",children:[s.jsx("span",{className:`mt-0.5 inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg ${v?"bg-destructive/15 text-destructive":"bg-primary/15 text-primary"}`,children:v?s.jsx(eC,{size:15}):s.jsx(rC,{size:15})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[12px] font-medium text-foreground",children:L}),s.jsx("div",{className:"mt-0.5 text-[10px] leading-relaxed text-muted-foreground",children:x?`${r(k?"settings.serverHealthHistory":"settings.serverHealthLastIncident")}: ${E}${R?` · ${R}`:""}`:r("settings.serverHealthClean")}),x&&k&&s.jsx("div",{className:"mt-1 text-[11px] text-primary",children:r("settings.serverHealthRunningNow")}),x&&s.jsx("div",{className:"mt-1 text-[10px] tabular-nums text-muted-foreground/75",children:B}),x?.detail&&s.jsx("div",{className:"mt-1 break-words text-[10px] text-muted-foreground/75",children:x.detail}),x?.oomSuspect&&s.jsx("div",{className:"mt-1 text-[10px] text-[color:var(--warning)]",children:r("settings.serverHealthOomNote")}),e.supervisor&&e.supervisor.restarts>0&&!y&&s.jsx("div",{className:"mt-1 text-[10px] tabular-nums text-muted-foreground/75",children:r("settings.serverHealthRestarted",{count:e.supervisor.restarts})})]})]}),e.attention&&s.jsx("button",{type:"button",onClick:t,className:"shrink-0 rounded-full bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground transition hover:bg-surface-elevated",children:r("settings.serverHealthDismiss")})]}),!e.supervised&&s.jsxs("div",{className:"border-t border-border px-3 py-3",children:[s.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground",children:e.canEnableSupervision?r("settings.serverHealthEnableHint"):r("settings.serverHealthEnableUnavailable")}),e.canEnableSupervision&&s.jsx("button",{type:"button",onClick:m,disabled:n,className:"mt-2 min-h-11 rounded-lg bg-primary px-3 text-[12px] font-medium text-primary-foreground disabled:opacity-60",children:r(n?"settings.serverHealthEnabling":"settings.serverHealthEnable")}),n&&s.jsx("p",{role:"status",className:"mt-2 text-[11px] text-muted-foreground",children:r("settings.serverHealthEnablePending")}),c&&s.jsx("p",{role:"alert",className:"mt-2 text-[11px] text-destructive",children:r("settings.serverHealthEnableError")})]})]})}const VF=()=>()=>{},qF=()=>1/0;function YF(){const{t:e}=zr(),t=b.useId(),r=ol(),n=b.useSyncExternalStore(r?.subscribe??VF,r?.retentionLimit??qF);if(!r)return null;const a=d9+1,c=n===1/0?e("settings.workspaceUnlimited"):String(n);return s.jsxs("div",{className:"space-y-1.5 rounded-xl bg-surface-2 px-2.5 py-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{htmlFor:t,className:"shrink-0 text-[12px] font-medium text-foreground/90",children:e("settings.workspaceLimit")}),s.jsx("input",{id:t,type:"range",min:3,max:a,step:1,value:n===1/0?a:n,"aria-valuetext":c,"aria-describedby":`${t}-hint`,onChange:l=>{const h=Number(l.target.value);r.setRetentionLimit(h===a?1/0:h)},className:"h-8 min-w-0 flex-1"}),s.jsx("output",{htmlFor:t,className:"min-w-12 shrink-0 text-right text-[11px] tabular-nums text-muted-foreground",children:c})]}),s.jsx("p",{id:`${t}-hint`,className:"text-[11px] leading-relaxed text-muted-foreground",children:e("settings.workspaceLimitHint")})]})}const A1="mobile-session-destroy";function ZF(e,t){return t&&e.type==="session"&&e.destination?.droppableId===A1}const ba="termdock-program-rules-cache",_h="termdock-toolbar-presets-cache",D0="termdock-settings-cache",Wb="termdock-color-theme",Gb="termdock:right-sidebar:file-preview-open-by-session:v2",B0="termdock:running-session-button-enabled:v1",Q0="termdock:attention-button-enabled:v1",KF=60,Vb=320,qb=420,No=8;function Yb(e,t,r){return Math.min(Math.max(e,t),r)}function Zb(e){if(typeof window>"u")return{left:No,top:No};const t=window.innerWidth/2,r=Math.min(64,window.innerHeight/4),n=e?.x??t,a=e?.y??r,c=Math.max(No,window.innerWidth-Vb-No),l=Math.max(No,window.innerHeight-qb-No);return{left:Yb(n+No,No,c),top:Yb(a+No,No,l),width:Vb,maxHeight:`min(${qb}px, calc(100vh - ${No*2}px))`}}function XF(e){return e==="dark"||e==="light"}function JF(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.entries(e).every(([t,r])=>{if(!t||!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.updatedAt=="number"&&Number.isFinite(n.updatedAt)})}function Sm(e){const t=Object.entries(e).filter(([r,n])=>r&&Number.isFinite(n.updatedAt)).sort(([,r],[,n])=>n.updatedAt-r.updatedAt).slice(0,KF);return Object.fromEntries(t)}function e$(e){return Array.isArray(e)&&e.every(t=>{if(!t||typeof t!="object")return!1;const r=t;return typeof r.id=="string"&&typeof r.pattern=="string"&&typeof r.output=="string"&&(r.matchType==="exact"||r.matchType==="includes"||r.matchType==="prefix"||r.matchType==="regex")})}function t$(e){return typeof e=="object"&&e!==null&&typeof e.version=="number"&&Array.isArray(e.presets)}function r$(e,t){const r=ud(),n=new Set(zI()),a=Array.isArray(e)?e:[],c=yu(a),l=t<$0;if(c.length===0)return r;if(l){const p=new Map(c.map(w=>[w.id,w])),m=new Map(a.map(w=>[typeof w.id=="string"?w.id.trim().toLowerCase().replace(/[^a-z0-9_-]/g,"-"):"",w])),x=c.filter(w=>!n.has(w.id));return[...r.map(w=>{const v=p.get(w.id),k=m.get(w.id);return v?{...w,rowLayout:v.rowLayout,showOnDesktop:typeof k?.showOnDesktop=="boolean"?k.showOnDesktop:w.showOnDesktop}:w}),...x]}const h=new Set(c.map(p=>p.id));return[...c,...r.filter(p=>!h.has(p.id))]}function n$(e){return typeof e=="object"&&e!==null&&typeof e.preventSleep=="boolean"&&typeof e.networkAvailable=="boolean"}const s$={name:"",source:"auto",hostname:"",fallbackHostname:"",url:"",fallbackUrl:"",onboardingUrl:null,status:"disabled",reason:null,httpsEnabled:!1,caAvailable:!1,lanAddresses:[],interfaces:[]},Wf="__termdockOverlay",Gf="__termdockBaseAnchor",Vf="__termdockBaseGuard",i$=3,Kb=250,a$="termdock-notification-target-v1",Xb="/__termdock-notification-target",Jb=3e4;function o$(e){return e==="left-sidebar"||e==="right-sidebar"||e==="right-sidebar-repo-picker"||e==="right-sidebar-file-preview"||e==="settings"||e==="markdown-outline"||e==="markdown-image-lightbox"}function du(e){if(!e||typeof e!="object")return null;const t=e[Wf];return o$(t)?t:null}function bg(e){return e&&typeof e=="object"?{...e}:{}}function j6(e){const t=bg(e);return delete t[Wf],t}function l$(e){const t=j6(e);return delete t[Vf],{...t,[Gf]:!0}}function c$(){typeof window>"u"||window.history.pushState({...j6(window.history.state),[Gf]:!0,[Vf]:!0},"",window.location.href)}function D6(){for(let e=0;e<i$;e+=1)c$()}function kh(){typeof window>"u"||(window.history.replaceState(l$(window.history.state),"",window.location.href),D6())}function P0(e){typeof window>"u"||window.history.pushState({...bg(window.history.state),[Gf]:!0,[Wf]:e,[Vf]:!1},"",window.location.href)}function u$(e){typeof window>"u"||window.history.replaceState({...bg(window.history.state),[Gf]:!0,[Wf]:e,[Vf]:!1},"",window.location.href)}const B6=["bash","zsh","fish","sh","dash","ksh","tcsh","csh","nu"];let ya=new Set(B6);function e3(e){const t=new Map;for(const[r,n]of e)t.set(r,{cwd:n.cwd,activeProgram:n.activeProgram,activeProgramRaw:n.activeProgramRaw,inCopyMode:n.inCopyMode,isConnecting:n.isConnecting,agentStatus:n.agentStatus,agentIndicator:n.agentIndicator,agentStatusDetail:n.agentStatusDetail,agent:n.agent,agentMessage:n.agentMessage,agentNativeSessionId:n.agentNativeSessionId,agentResumeRecovered:n.agentResumeRecovered,terminalSessionId:n.terminalSessionId,agentNeedsReview:n.agentNeedsReview,gitStatus:n.gitStatus,shellTitle:n.shellTitle,promptState:n.promptState,tuiProgress:n.tuiProgress});return t}function d$(e,t){if(e.size!==t.size)return!1;for(const[r,n]of t){const a=e.get(r);if(!a||a.cwd!==n.cwd||a.activeProgram!==n.activeProgram||a.activeProgramRaw!==n.activeProgramRaw||a.inCopyMode!==n.inCopyMode||a.isConnecting!==n.isConnecting||a.agentStatus!==n.agentStatus||a.agentIndicator!==n.agentIndicator||a.agentStatusDetail!==n.agentStatusDetail||a.agent!==n.agent||a.agentMessage!==n.agentMessage||a.agentNativeSessionId!==n.agentNativeSessionId||a.agentResumeRecovered!==n.agentResumeRecovered||a.terminalSessionId!==n.terminalSessionId||a.agentNeedsReview!==n.agentNeedsReview||a.gitStatus!==n.gitStatus||a.shellTitle!==n.shellTitle||a.promptState!==n.promptState||a.tuiProgress?.state!==n.tuiProgress?.state||a.tuiProgress?.progress!==n.tuiProgress?.progress)return!1}return!0}function t3(e,t){return s.jsx(pP,{sessionMode:e,state:t})}function h$(e,t){const r=new Map(e.map(l=>[l.id,l])),n=t.map(l=>r.get(l)).filter(l=>l!==void 0),a=new Set(t),c=e.filter(l=>!a.has(l.id));return[...n,...c]}const f$=_.lazy(()=>kc(()=>import("./CollaborationMainWorkspace-DuEeKQKZ.js"),__vite__mapDeps([18,1,2,3,4,5,8,9,15,13])));function p$(){const{t:e,locale:t,setLocale:r}=zr(),n="env(safe-area-inset-top, 0px)",a="env(safe-area-inset-bottom, 0px)";h9();const c=_.useMemo(()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1,[]),[l,h]=_.useState(!1),[p,m]=_.useState(()=>fc(Wb,XF)??"dark"),x=_.useRef(fc(D0,n$)).current,[y,w]=_.useState(x?.preventSleep??!1),[v,k]=_.useState(x?.networkAvailable??!0),[L,E]=_.useState(f9),[R,B]=_.useState(p9),[W,F]=_.useState(m9),[U,V]=_.useState(g9),[Z,le]=_.useState(hp),[xe,fe]=_.useState(x?.localAccess??s$),[te,ke]=_.useState(x?.localAccess?.name??""),[$e,Y]=_.useState(!1),[Ae,lt]=_.useState(null),[Ce,ye]=_.useState(null),[_e,je]=_.useState(null),[re,Pe]=_.useState(!1),[Se,Ee]=_.useState(null),Be=_.useMemo(()=>lo(),[]),Ne=!!(Be?.desktopUpdateState&&Be.checkDesktopUpdate&&Be.installDesktopUpdate),[oe,He]=_.useState(null),[rt,mt]=_.useState(null),[de,Ye]=_.useState(!1),[st,Ie]=_.useState(null),[We,Te]=_.useState(!1),[H,ae]=_.useState(()=>Sm(fc(Gb,JF)??{})),[be,Ze]=_.useState(0),[Je,Tt]=_.useState(!1),[Wt,Mt]=_.useState(0),[vt,Yt]=_.useState(!1),[Qt,Xt]=_.useState(0),[Ut,Lt]=_.useState(!1),[pe,Ge]=_.useState(0),ft=_.useRef(null),[q,at]=_.useState({}),{terminalSettings:Vt,updateTerminalSettings:Ve}=wB(),De=Vt.fontSize,er=Vt.rendererMode,[et,Ct]=_.useState(!1),Nt=_.useRef(x9()).current,[gt,bt]=b.useState(()=>Nt.sessions.map(S=>({id:S.sessionId,name:S.name,customName:S.customName,mode:S.mode,tmuxSessionName:S.tmuxSessionName}))),It=na(S=>S.groupId);_.useEffect(()=>{const S=()=>na.getState().terminal();return window.addEventListener("switch-terminal-session",S),()=>window.removeEventListener("switch-terminal-session",S)},[]);const[yt,pr]=_.useState(Nt.activeSessionId),[nr,_r]=_.useState(!1);_.useEffect(()=>{nr&&b9({rendered:!0})},[nr]);const[un,Ir]=_.useState(null),[me,Gr]=_.useState(null),[it,dt]=_.useState([]),[sr,An]=b.useState(()=>{const S=Yr.getState();return Nt.sessions.forEach(P=>{P.backendSessionId&&S.setTerminalSession(P.sessionId,{sessionId:P.backendSessionId,cols:80,rows:24,mode:P.mode,tmuxSessionName:P.tmuxSessionName}),P.activeProgram!=null&&S.setSessionActiveProgram(P.sessionId,P.activeProgram),P.cwd!=null&&S.setSessionCwd(P.sessionId,P.cwd),P.shellTitle!=null&&S.setSessionShellTitle(P.sessionId,P.shellTitle)}),vu("session-chrome-hydrated"),e3(Yr.getState().sessions)});b.useEffect(()=>{!Be||!et||Promise.all([Be.snapshot(),Be.desktopUpdateState?.()??Promise.resolve(null)]).then(([S,P])=>{He(S),mt(P)}).catch(S=>Ie(S instanceof Error?S.message:String(S)))},[Be,et]),b.useEffect(()=>{Be?.onDesktopUpdateState&&Be.onDesktopUpdateState(mt)},[Be]),b.useEffect(()=>Yr.subscribe(S=>{const P=e3(S.sessions);An(ue=>d$(ue,P)?ue:P)}),[]);const on=b.useCallback(async(S,P)=>{Gr(null),Ir({sessionId:S,status:"submitting",error:null});try{await y9(P),Ir(ue=>ue?.sessionId===S?{...ue,status:"waiting",error:null}:ue)}catch(ue){const St=(ue&&typeof ue=="object"&&"code"in ue?String(ue.code??""):"")==="AGENT_SESSION_ACTIVE_ELSEWHERE"?e("tab.resumeAgentConflict"):ue instanceof Error&&/busy/i.test(ue.message)?e("tab.resumeAgentBusy"):e("tab.resumeAgentFailed");Ir(Kt=>Kt?.sessionId===S?{...Kt,error:St}:Kt),Gr({tone:"error",message:St})}},[e]);b.useEffect(()=>{if(!un||un.status!=="waiting")return;const S=sr.get(un.sessionId);if(!S||S.agentResumeRecovered||S.agentStatus===null&&!S.agent)return;const P=S.agent?.displayName??"Agent";Ir(null),Gr({tone:"success",message:e("tab.resumeAgentSuccess",{agent:P})})},[un,sr,e]),b.useEffect(()=>{if(!un||un.status!=="waiting"||un.error)return;const S=un.sessionId,P=window.setTimeout(()=>{const ue=e("tab.resumeAgentTimeout");Ir(tt=>tt?.sessionId===S&&tt.status==="waiting"?{...tt,error:ue}:tt),Gr({tone:"error",message:ue})},15e3);return()=>window.clearTimeout(P)},[un,e]),b.useEffect(()=>{if(me?.tone!=="success")return;const S=window.setTimeout(()=>Gr(null),3200);return()=>window.clearTimeout(S)},[me]),b.useEffect(()=>{let S=!1;v9().then(ue=>{S||je(ue)}).catch(()=>{}),w9().then(ue=>{S||Ee(ue)}).catch(()=>{});const P=Kg(ue=>{S||(ue.type==="update-state"?je(ue.state):ue.type==="server-health"&&Ee(ue.state))});return()=>{S=!0,P()}},[]);const Me=b.useCallback(async()=>{try{Ee(await A9())}catch(S){window.alert(S instanceof Error?S.message:String(S))}},[]),nt=b.useCallback(async()=>{const S=_e?.latestVersion;if(!(!S||re)&&window.confirm(e("sidebar.updateRestartConfirm",{version:S}))){Pe(!0);try{je(await T9())}catch(P){window.alert(P instanceof Error?P.message:String(P))}finally{Pe(!1)}}},[_e?.latestVersion,e,re]),wt=b.useCallback(async()=>{if(!re){Pe(!0);try{je(await C9())}catch(S){window.alert(S instanceof Error?S.message:String(S))}finally{Pe(!1)}}},[re]),Mr=b.useCallback(async()=>{if(!(!Be?.checkDesktopUpdate||de)){Ye(!0);try{mt(await Be.checkDesktopUpdate())}catch(S){Ie(S instanceof Error?S.message:String(S))}finally{Ye(!1)}}},[Be,de]),rn=b.useCallback(async()=>{if(!(!Be?.installDesktopUpdate||de||rt?.status!=="ready")&&window.confirm(e("settings.desktopUpdateRestartConfirm"))){Ye(!0);try{mt(await Be.installDesktopUpdate())}catch(S){Ie(S instanceof Error?S.message:String(S))}finally{Ye(!1)}}},[Be,de,rt?.status,e]);b.useEffect(()=>{document.documentElement.dataset.theme=p,S9(p),Un(Wb,p)},[p]),b.useEffect(()=>{Un(Gb,Sm(H))},[H]);const Er=Gt(S=>S.leftOpen),ne=Gt(S=>S.rightOpen),ht=Gt(S=>S.leftPinned),zt=Gt(S=>S.leftSidebarWidth),Pt=Gt(S=>S.rightPinned),Cr=Gt(S=>S.rightSidebarWidth),gr=Gt(S=>S.rootPath),Hr=Gt(S=>S.contextKey),En=Gt(S=>S.selectedFilePath),dr=Gt(S=>S.groupByFolder),Tn=Xh(S=>S.collaborationGroups),hn=Gt(S=>S.collapsedGroups),Sn=Gt(S=>S.toggleGroupCollapsed),[ir,mn]=b.useState(()=>typeof window>"u"?!0:window.matchMedia("(min-width: 1024px)").matches),[Qr,Vr]=b.useState(()=>typeof window>"u"?1024:window.innerWidth),[Wr,fs]=b.useState(()=>typeof window>"u"?!1:window.matchMedia("(orientation: landscape)").matches),[Dr,Pn]=b.useState([]),[Sr,Kr]=b.useState({available:!0,version:null,reason:null}),[nn,Or]=b.useState(!1),[ks,Pr]=b.useState(null),[Xr,fn]=b.useState(null),[K,Ue]=b.useState(null),[Et,kt]=b.useState(null),[tr,Br]=b.useState(null),[cr,_n]=b.useState(null),[Ls,Zn]=b.useState(null),[,sn]=b.useState(0),[ln,kr]=b.useState(null),[$r,Gn]=b.useState(null),[Vn,dn]=b.useState(null),[Kn,Lr]=b.useState(!1),[Nr,xr]=b.useState(()=>fc(B0,S=>typeof S=="boolean")??!1),os=b.useCallback(async S=>{const P=Nr;xr(S),Un(B0,S);try{const ue=await wa({runningSessionButtonEnabled:S});xr(ue.runningSessionButtonEnabled),Un(B0,ue.runningSessionButtonEnabled)}catch{xr(P),Un(B0,P)}},[Nr]),[Hn,Nn]=b.useState(()=>fc(Q0,S=>typeof S=="boolean")??!0),Rn=b.useCallback(async S=>{const P=Hn;Nn(S),Un(Q0,S);try{const ue=await wa({attentionButtonEnabled:S});Nn(ue.attentionButtonEnabled),Un(Q0,ue.attentionButtonEnabled)}catch{Nn(P),Un(Q0,P)}},[Hn]),[ps,G]=b.useState(null),Le=b.useCallback(S=>{G(S)},[]),Ke=b.useRef(!1),[ct,qe]=b.useState(null),[At,Rt]=b.useState(null),Dt=_.useRef(null),ot=_.useRef(!1),Ot=_.useRef(null),hr=_.useRef(!1),Zt=b.useCallback(()=>{_n(null),Zn(null)},[]),z=_.useRef(typeof window>"u"?null:new URLSearchParams(window.location.search).get("session")),[N,$]=_.useState(z.current),[ee,se]=_.useState(!0),Qe=_.useRef(z.current),ze=_.useRef(typeof window>"u"?null:new URLSearchParams(window.location.search).get("_notifTrace"));b.useEffect(()=>{if(typeof window>"u")return;const S=window.matchMedia("(min-width: 1024px)"),P=()=>{mn(S.matches),Vr(window.innerWidth)};return P(),S.addEventListener("change",P),window.addEventListener("resize",P),()=>{S.removeEventListener("change",P),window.removeEventListener("resize",P)}},[]),b.useEffect(()=>{if(typeof window>"u")return;const S=window.matchMedia("(orientation: landscape)"),P=()=>fs(S.matches);return P(),S.addEventListener("change",P),()=>S.removeEventListener("change",P)},[]);const xt=_.useMemo(()=>yt?it.find(S=>S.sessionIds.includes(yt))??null:null,[yt,it]),_t=xt?.id??null,Fr=xt?.sessionIds[0]??yt,jt=_.useRef([]);_.useLayoutEffect(()=>{const S=jt.current;if(jt.current=it,S.length===0)return;const P=new Set(it.flatMap(ue=>ue.sessionIds));for(const ue of S){const tt=ue.sessionIds.filter(St=>!P.has(St)).map(St=>({sessionId:St,rootPath:Yr.getState().sessions.get(St)?.cwd??null}));tt.length>0&&Gt.getState().inheritRightSidebarStateFromSplitWorkspace(ue.id,tt)}},[it]),_.useLayoutEffect(()=>((()=>{const P=Fr?Yr.getState().sessions.get(Fr)?.cwd??null:null;Gt.getState().setRootPath(P,Fr,_t)})(),Yr.subscribe((P,ue)=>{const tt=Fr?P.sessions.get(Fr)?.cwd??null:null,St=Fr?ue.sessions.get(Fr)?.cwd??null:null;tt!==St&&Gt.getState().setRootPath(tt,Fr,_t)})),[_t,Fr]);const qr=ir||Wr,pn=Qr*.95,Xn=qr?Math.min(Math.max(Qr*.22,280),340):Math.min(Qr*.86,380),vn=yt&&gr?`${yt}\0${gr}`:"",kn=!!(vn&&En&&H[vn]),ar=b.useCallback(S=>{vn&&(S&&!Gt.getState().selectedFilePath||ae(P=>{if(!!P[vn]===S)return P;if(S)return Sm({...P,[vn]:{updatedAt:Date.now()}});const tt={...P};return delete tt[vn],tt}))},[vn]);b.useEffect(()=>{kB(vn,Hr,En)&&ae(S=>{if(!S[vn])return S;const P={...S};return delete P[vn],P})},[vn,Hr,En]);const cn=Ut?"markdown-image-lightbox":vt?"markdown-outline":Je?"right-sidebar-repo-picker":ne&&kn?"right-sidebar-file-preview":et?"settings":ne&&!(Pt&&ir)?"right-sidebar":Er&&!(ht&&ir)?"left-sidebar":null,an=_.useRef(cn),Hs=_.useRef(cn),Is=_.useRef(!1),Ks=_.useRef(!1),Po=b.useCallback(()=>{if(typeof window>"u")return;const S=window.matchMedia("(hover: hover) and (pointer: fine)").matches;!ir||!S||navigator.maxTouchPoints>0||window.setTimeout(()=>{window.dispatchEvent(new CustomEvent("focus-active-terminal-session"))},0)},[ir]),Aa=b.useCallback(S=>{if(S==="markdown-image-lightbox"){Lt(!1),Ge(P=>P+1);return}if(S==="markdown-outline"){Yt(!1),Xt(P=>P+1);return}if(S==="right-sidebar-file-preview"){Yt(!1),Xt(P=>P+1),ar(!1),Ze(P=>P+1);return}if(S==="right-sidebar-repo-picker"){Tt(!1),Mt(P=>P+1);return}if(S==="settings"){Ct(!1),zi(!1),js(!1),$a(!1);return}if(S==="left-sidebar"){Gt.getState().closeLeft();return}Yt(!1),Xt(P=>P+1),Tt(!1),Mt(P=>P+1),Lt(!1),Ge(P=>P+1),Gt.getState().closeRight()},[ar]),Ln=b.useCallback(S=>{if(!c&&typeof window<"u"&&an.current===S&&du(window.history.state)===S){window.history.back();return}Aa(S)},[Aa,c]),ia=b.useCallback(()=>{Ct(!1);const S=Gt.getState();S.closeRight(),S.openLeft()},[]),fo=b.useCallback(()=>{Ct(!1);const S=Gt.getState();S.closeLeft(),S.openRight()},[]),Ba=b.useCallback(()=>{Ct(!1);const S=Gt.getState();S.closeLeft(),S.openRight(),S.setRightTab("files"),S.openRightSearch()},[]),Ei=b.useCallback(()=>{const S=Gt.getState();if(S.leftPinned){S.setLeftPinned(!1),S.closeLeft();return}if(Er){Ln("left-sidebar");return}ia()},[ia,Ln,Er]),ws=b.useCallback(()=>{const S=Gt.getState();S.leftPinned?(S.setLeftPinned(!1),S.openLeft()):(S.setLeftPinned(!0),S.openLeft())},[]),Qa=b.useCallback(()=>{const S=Gt.getState();S.setLeftPinned(!1),S.closeLeft()},[]),Es=b.useCallback(()=>{const S=Gt.getState();S.rightPinned?(S.setRightPinned(!1),S.openRight()):(S.setRightPinned(!0),S.openRight())},[]),po=b.useCallback(()=>{const S=Gt.getState();S.setRightPinned(!1),S.closeRight()},[]),Ws=b.useRef(0),Xs=b.useRef(0),ms=b.useRef(null),mo=b.useCallback(S=>{S.preventDefault(),Ws.current=S.clientX,Xs.current=Gt.getState().leftSidebarWidth;const P=tt=>{ms.current===null&&(ms.current=requestAnimationFrame(()=>{ms.current=null;const St=tt.clientX-Ws.current;Gt.getState().setLeftSidebarWidth(Xs.current+St)}))},ue=()=>{window.removeEventListener("mousemove",P),window.removeEventListener("mouseup",ue),ms.current!==null&&(cancelAnimationFrame(ms.current),ms.current=null),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",P),window.addEventListener("mouseup",ue)},[]),Ns=b.useRef(0),Oo=b.useRef(0),aa=b.useRef(null),go=b.useCallback(S=>{S.preventDefault(),Ns.current=S.clientX;const P=Gt.getState(),ue=P.leftPinned?P.leftSidebarWidth:0;Oo.current=Ih(P.rightSidebarWidth,window.innerWidth,ue);const tt=Kt=>{aa.current===null&&(aa.current=requestAnimationFrame(()=>{aa.current=null;const wr=Ns.current-Kt.clientX,xn=Gt.getState(),Dn=xn.leftPinned?xn.leftSidebarWidth:0;xn.setRightSidebarWidth(Ih(Oo.current+wr,window.innerWidth,Dn))}))},St=()=>{window.removeEventListener("mousemove",tt),window.removeEventListener("mouseup",St),aa.current!==null&&(cancelAnimationFrame(aa.current),aa.current=null),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",tt),window.addEventListener("mouseup",St)},[]),On=b.useCallback(()=>{const S=Gt.getState();if(S.rightPinned){S.setRightPinned(!1),S.closeRight();return}if(ne){Ln("right-sidebar");return}fo()},[fo,Ln,ne]),Ni=b.useCallback(()=>{!kn&&!c&&typeof window<"u"&&an.current==="right-sidebar"&&du(window.history.state)==="right-sidebar"&&(P0("right-sidebar-file-preview"),Hs.current="right-sidebar-file-preview"),ar(!0)},[kn,c,ar]),Ri=b.useCallback(()=>{Ln("right-sidebar-file-preview")},[Ln]),Pa=b.useCallback(()=>{!Je&&!c&&typeof window<"u"&&an.current==="right-sidebar"&&du(window.history.state)==="right-sidebar"&&(P0("right-sidebar-repo-picker"),Hs.current="right-sidebar-repo-picker"),Tt(!0)},[Je,c]),mi=b.useCallback(()=>{Ln("right-sidebar-repo-picker")},[Ln]),dl=b.useCallback(()=>{!vt&&!c&&typeof window<"u"&&an.current&&du(window.history.state)===an.current&&(P0("markdown-outline"),Hs.current="markdown-outline"),Yt(!0)},[vt,c]),Js=b.useCallback(()=>{Ln("markdown-outline")},[Ln]),Fo=b.useCallback(()=>{!c&&typeof window<"u"&&an.current&&du(window.history.state)===an.current&&(P0("markdown-image-lightbox"),Hs.current="markdown-image-lightbox"),Lt(!0)},[c]),oa=b.useCallback(()=>{Ln("markdown-image-lightbox")},[Ln]),xo=b.useCallback(()=>{!c&&typeof window<"u"&&an.current&&du(window.history.state)===an.current&&(u$("settings"),Hs.current="settings"),Gt.getState().closeAll(),Ct(!0)},[c]),Ta=b.useCallback(()=>{Ln("settings")},[Ln]);b.useEffect(()=>{if(!Be)return;const S=()=>xo();return window.addEventListener("termdock:open-settings",S),()=>window.removeEventListener("termdock:open-settings",S)},[Be,xo]);const ls=b.useCallback(()=>{Te(!0),ft.current!==null&&(window.clearTimeout(ft.current),ft.current=null)},[]),gi=b.useCallback(()=>{ft.current!==null&&(window.clearTimeout(ft.current),ft.current=null),Te(!1),Ks.current=!0,kh(),Ks.current},[]);b.useEffect(()=>()=>{ft.current!==null&&window.clearTimeout(ft.current)},[]),b.useEffect(()=>{c||kh()},[c]),b.useEffect(()=>{if(typeof window>"u"||c)return;let S=null;const P=()=>{S!==null&&(window.clearTimeout(S),S=null)},ue=xn=>{if(an.current,Ks.current,an.current){an.current;return}!xn?.force&&Ks.current||(xn?.userActivated&&(Ks.current=!0),kh(),Ks.current,void 0)},tt=()=>{P(),S=window.setTimeout(()=>{S=null,ue({force:!0})},Kb)},St=()=>{ue({userActivated:!0})},Kt=()=>{tt()},wr=()=>{document.visibilityState==="visible"&&tt()};return window.addEventListener("pointerdown",St,{capture:!0,passive:!0}),window.addEventListener("touchstart",St,{capture:!0,passive:!0}),window.addEventListener("keydown",St,{capture:!0}),window.addEventListener("pageshow",Kt),document.addEventListener("visibilitychange",wr),()=>{P(),window.removeEventListener("pointerdown",St,{capture:!0}),window.removeEventListener("touchstart",St,{capture:!0}),window.removeEventListener("keydown",St,{capture:!0}),window.removeEventListener("pageshow",Kt),document.removeEventListener("visibilitychange",wr)}},[c]),b.useEffect(()=>{an.current=cn},[cn]),b.useEffect(()=>{if(typeof window>"u"||cn||c)return;const S=window.setTimeout(()=>{an.current?(an.current,void 0):kh()},Kb);return()=>window.clearTimeout(S)},[cn,c]),b.useEffect(()=>{if(typeof window>"u"||c)return;const S=Hs.current;Is.current,cn&&cn!==S&&!Is.current&&P0(cn),!cn&&S&&Po(),Hs.current=cn,!cn&&Is.current&&window.setTimeout(()=>{Is.current=!1},0)},[cn,c,Po]),b.useEffect(()=>{if(typeof window>"u"||c)return;const S=()=>{const P=an.current;if(Ks.current,!P){Ks.current=!1,Ks.current,ls(),D6();return}Is.current=!0,Aa(P)};return window.addEventListener("popstate",S),()=>window.removeEventListener("popstate",S)},[Aa,ls,c]),b.useEffect(()=>{const S=P=>{const ue=P.metaKey||P.ctrlKey;if(ue&&P.key==="b"&&!P.shiftKey&&(P.preventDefault(),Ei()),ue&&P.shiftKey&&P.key==="E"&&(P.preventDefault(),On()),ue&&P.shiftKey&&P.key==="P"&&(P.preventDefault(),Ba()),ue&&!P.shiftKey&&P.altKey&&(P.key==="ArrowLeft"||P.key==="ArrowRight")){P.preventDefault();const tt=P.key==="ArrowRight"?"next":"prev";window.dispatchEvent(new CustomEvent("cycle-terminal-session",{detail:{direction:tt}}));return}if(ue&&P.shiftKey&&!P.altKey&&(P.code==="BracketLeft"||P.code==="BracketRight")){P.preventDefault();const tt=P.code==="BracketRight"?"next":"prev";window.dispatchEvent(new CustomEvent("cycle-terminal-session",{detail:{direction:tt}}));return}};return document.addEventListener("keydown",S),()=>{document.removeEventListener("keydown",S)}},[Ei,On,Ba]);const bo=b.useCallback(async()=>{Y(!0),lt(null);try{const S=await wa({localAccess:{name:te}});fe(S.localAccess),ke(S.localAccess.name),Un(D0,{preventSleep:S.preventSleep,networkAvailable:S.networkAvailable,localAccess:S.localAccess})}catch(S){lt(S instanceof Error?S.message:"Failed to save local access name")}finally{Y(!1)}},[te]),hl=b.useCallback(async()=>{Y(!0),lt(null);try{const S=await wa({localAccess:{reset:!0}});fe(S.localAccess),ke(S.localAccess.name),Un(D0,{preventSleep:S.preventSleep,networkAvailable:S.networkAvailable,localAccess:S.localAccess})}catch(S){lt(S instanceof Error?S.message:"Failed to reset local access name")}finally{Y(!1)}},[]),$o=b.useCallback(async(S,P="url")=>{if(S)try{if(typeof navigator<"u"&&navigator.clipboard)await navigator.clipboard.writeText(S);else{const ue=document.createElement("textarea");ue.value=S,ue.style.position="fixed",ue.style.left="-9999px",document.body.appendChild(ue),ue.focus(),ue.select(),document.execCommand("copy"),document.body.removeChild(ue)}ye(P),window.setTimeout(()=>ye(ue=>ue===P?null:ue),1600)}catch{ye(null)}},[]),gs=b.useCallback(S=>{const P=h$(gt,S);P.map(ue=>ue.id).join("\0")!==gt.map(ue=>ue.id).join("\0")&&(bt(P),window.dispatchEvent(new CustomEvent("reorder-terminal-session",{detail:{sessionIds:P.map(ue=>ue.id)}})))},[gt]),la=b.useCallback(S=>{ir||S.type!=="session"||(Ke.current=!1,Lr(!1),dn(S.draggableId))},[ir]),Nl=b.useCallback(S=>{if(ir||S.type!=="session")return;const P=S.destination?.droppableId===A1;P!==Ke.current&&(Ke.current=P,Lr(P),P&&navigator.vibrate?.(20))},[ir]),Jn=b.useCallback(S=>{const P=ZF(S,!ir);if(Ke.current=!1,Lr(!1),dn(null),!P)return!1;const ue=gt.find(St=>St.id===S.draggableId),tt=ue?sr.get(ue.id):null;return ue&&C5({mode:ue.mode,activeProgram:tt?.activeProgram??null,promptState:tt?.promptState??null,shellNames:ya})?(Rt(null),qe(ue.id),Ue(null)):ue&&window.dispatchEvent(new CustomEvent("close-terminal-session",{detail:{sessionId:ue.id,source:"other",closeMode:ue.mode==="tmux"?"destroy":"auto"}})),!0},[ir,gt,sr]),{groups:xi,arranged:ss}=_.useMemo(()=>Kh(gt,S=>sr.get(S.id)?.cwd??null,dr,e("sidebar.ungrouped"),it,Tn),[gt,sr,dr,e,it,Tn]),Oa=b.useCallback(S=>{Jn(S)||!S.destination||S.source.index===S.destination.index||window.dispatchEvent(new CustomEvent("reorder-navigation-session",{detail:{sourceId:ss[S.source.index]?.id,targetId:ss[S.destination.index]?.id}}))},[Jn,ss]),ys=b.useCallback((S,P)=>{const ue=P.trim();ue&&window.dispatchEvent(new CustomEvent("rename-terminal-session",{detail:{sessionId:S,name:ue}}))},[]),Uo=b.useCallback(S=>{window.dispatchEvent(new CustomEvent("reset-terminal-session-name",{detail:{sessionId:S}}))},[]),{newSessionMode:Gs,newSessionTmuxName:Ui,userSelectedNewSessionMode:ca,setNewSessionMode:jn}=CB(),[bi,Mi]=b.useState(null),[Ca,zi]=_.useState(!1),[yi,ei]=_.useState(!1),[Rs,js]=_.useState(!1),[ti,Fa]=_.useState("idle"),ji=_.useRef(fc(_h,t$)).current,[es,ua]=_.useState(()=>{const S=ji?.presets;if(S&&S.length>0){const P=yu(S);if(P.length>0)return P}return ud()}),[yo,Sa]=_.useState(!1),[zo,Ho]=_.useState("default"),Hi=_.useRef(typeof ji?.updatedAt=="number"?ji.updatedAt:null),vo=_.useRef(!1),[da,$a]=_.useState(!1),[wo,ha]=_.useState(!1),As=_.useRef(fc(ba,e$)).current,[Di,xs]=_.useState(As??[]),[Rl,ce]=_.useState(As!==null),[T,j]=_.useState(!1),Q=!It&&!cn&&!yi&&!Rs&&!Ca&&!da&&!wo&&!cr&&!ct&&!bi,O=_.useCallback(S=>{const P=typeof S.version=="number"?S.version:0,ue=r$(Array.isArray(S.presets)?S.presets:[],P);Hi.current=typeof S.updatedAt=="number"?S.updatedAt:null,ua(tt=>_9(tt,ue)?tt:(vo.current=!0,ue)),Un(_h,{version:$0,presets:ue,updatedAt:Hi.current??void 0})},[]);b.useEffect(()=>{const S=P=>{if(P.key!=="Escape"||P.defaultPrevented||P.isComposing||S1())return;if(yi){P.preventDefault(),ei(!1);return}if(Rs){P.preventDefault(),js(!1);return}if(Ca){P.preventDefault(),zi(!1);return}if(da){P.preventDefault(),$a(!1);return}if(wo){P.preventDefault(),ha(!1);return}if(cr){P.preventDefault(),Zt();return}if(ln){P.preventDefault(),Br(null),kr(null);return}if(et){P.preventDefault(),Ta();return}if(ne&&!(Pt&&ir)){P.preventDefault(),Ln("right-sidebar");return}Er&&!(ht&&ir)&&(P.preventDefault(),Ln("left-sidebar"))};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[yi,Rs,Ca,da,cr,Zt,et,ne,Pt,Er,ht,ir,Ta,Ln]),b.useEffect(()=>{ce(!0)},[]);const[ge,ve]=_.useState({genericProgramNames:[],wrapperScriptNames:[],shellNames:B6}),[,Oe]=_.useState(!1),Xe=_.useCallback(()=>k9().then(S=>{ve(S),ya=new Set(S.shellNames),Oe(!0)}).catch(()=>{}),[]);b.useEffect(()=>{Xe()},[Xe]),b.useEffect(()=>Kg(S=>{if(S.type==="config-updated"){if(S.key==="toolbar-presets"){Xg().then(P=>O(P)).catch(P=>{console.warn("[toolbar-presets] Failed to refresh after remote update:",P)});return}S.key==="program-detection"&&Xe()}}),[O,Xe]),b.useEffect(()=>{let S=!1;return(async()=>{try{const P=await Xg();if(S)return;O(P)}catch(P){console.warn("[toolbar-presets] Failed to load from server:",P)}finally{S||Sa(!0)}})(),()=>{S=!0}},[O]),b.useEffect(()=>{if(yo){if(vo.current){vo.current=!1;return}Un(_h,{version:$0,presets:es,updatedAt:Hi.current??void 0}),L9({version:$0,presets:es,baseUpdatedAt:Hi.current??void 0}).then(S=>{Hi.current=typeof S.updatedAt=="number"?S.updatedAt:null,Un(_h,{version:$0,presets:es,updatedAt:Hi.current??void 0})}).catch(S=>{const P=S instanceof Error&&"current"in S?S.current:null;P&&typeof P=="object"&&O(P),console.warn("[toolbar-presets] Failed to save to server:",S)})}},[O,es,yo]),b.useEffect(()=>{nc().then(S=>{w(P=>P===S.preventSleep?P:S.preventSleep),k(P=>P===S.networkAvailable?P:S.networkAvailable),fe(S.localAccess),ke(S.localAccess.name),xr(S.runningSessionButtonEnabled),Un(B0,S.runningSessionButtonEnabled),Nn(S.attentionButtonEnabled),Un(Q0,S.attentionButtonEnabled),Un(D0,{preventSleep:S.preventSleep,networkAvailable:S.networkAvailable,localAccess:S.localAccess})}).catch(()=>{})},[]),b.useEffect(()=>{if(!L)return;const S=hp();le(S),S!=="granted"&&(E(!1),Wd(!1))},[L]),b.useEffect(()=>{if(!L)return;t0();const S=()=>{document.visibilityState==="visible"&&(t0(),$9())},P=window.setInterval(()=>{t0()},360*60*1e3);return document.addEventListener("visibilitychange",S),window.addEventListener("focus",S),()=>{window.clearInterval(P),document.removeEventListener("visibilitychange",S),window.removeEventListener("focus",S)}},[L]);const pt=b.useCallback(async()=>{if(L){E(!1),Wd(!1),I9(),le(hp());return}const S=await E9();if(le(S),S!=="granted"){E(!1),Wd(!1);return}E(!0),Wd(!0),await t0(!0,!0),Fa("idle")},[L]),Jt=b.useCallback(async()=>{Fa("checking"),await lo()?.prepareNotificationTest?.();const S=await N9({title:"Termdock",body:e("settings.notificationsTestBody"),tag:"termdock-notification-test",requireHidden:!1,data:{url:"/"}});Fa(S?"delivered":"failed")},[e]),fr=b.useCallback(S=>{B(S),R9(S),fp()},[]),Ur=b.useCallback(S=>{F(S),M9(S),fp()},[]),Jr=b.useCallback(S=>{V(S),j9(S),fp()},[]);b.useEffect(()=>{es.some(S=>S.id===zo)||Ho(es[0]?.id??"default")},[zo,es]),b.useEffect(()=>{if(!Sr.available&&Gs==="tmux"){jn("shell",{userInitiated:!1});return}Sr.available&&ca!=="shell"&&Gs!=="tmux"&&jn("tmux",{userInitiated:!1})},[Gs,Sr.available,ca,jn]),b.useEffect(()=>{Mi(null)},[et,Gs,Sr.available]),b.useEffect(()=>{const S={};typeof navigator<"u"&&(S.userAgent=navigator.userAgent,S.platform=navigator.platform,S.maxTouchPoints=navigator.maxTouchPoints,S.hasTouch=navigator.maxTouchPoints>0||"ontouchstart"in window,S.vendor=navigator.vendor),typeof window<"u"&&(S.screenWidth=window.innerWidth,S.screenHeight=window.innerHeight,S.pixelRatio=window.devicePixelRatio,S.orientation=window.screen?.orientation?.type||"unknown",S.hasVisualViewport=!!window.visualViewport,S.visualViewportHeight=window.visualViewport?.height,S.visualViewportWidth=window.visualViewport?.width,S.location=window.location.href),S.timestamp=new Date().toISOString(),S.isIOS=/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1,S.isAndroid=/Android/.test(navigator.userAgent),at(S)},[]);const Fn=b.useCallback(S=>{if(Jn(S)||!S.destination)return;if(S.type==="group"){if(S.source.index===S.destination.index)return;gs(I3(xi,S.source.index,S.destination.index));return}if(S.source.droppableId!==S.destination.droppableId||S.source.index===S.destination.index)return;const P=S.source.droppableId.replace(/^group-sessions:/,""),ue=xi.find(tt=>tt.key===P);ue&&window.dispatchEvent(new CustomEvent("reorder-navigation-session",{detail:{sourceId:ue.sessions[S.source.index]?.id,targetId:ue.sessions[S.destination.index]?.id}}))},[xi,gs,Jn]),mr=_.useMemo(()=>ss.flatMap(S=>{const P=sr.get(S.id);if(P?.agentStatus!=="working")return[];const{primary:ue,secondary:tt}=sl(S,P?.activeProgram??null,P?.cwd??null,ya,P?.shellTitle??null,P?.promptState??null);return[{id:S.id,label:ue,detail:tt}]}),[ss,sr]),gn=yt?ss.findIndex(S=>S.id===yt):-1,cs=ss.length>0&&gn>=0?`${gn+1}/${ss.length}`:`${ss.length}`,is=_.useMemo(()=>{let S=0;for(const P of gt){const ue=sr.get(P.id);(ue?.agentStatus==="waiting"||ue?.agentNeedsReview)&&(S+=1)}return{running:mr.length,review:S}},[mr.length,gt,sr]),Hu=_.useMemo(()=>ss.flatMap(S=>{const P=sr.get(S.id);if(P?.agentStatus!=="waiting"&&!P?.agentNeedsReview)return[];const{primary:ue}=sl(S,P.activeProgram,P.cwd,ya,P.shellTitle,P.promptState);return[{id:P.terminalSessionId??S.id,label:ue,waiting:P.agentStatus==="waiting"}]}),[ss,sr]);D9(is.running,is.review,Hu);const ts=yt?gt.find(S=>S.id===yt)??null:null,Ua=ts?sr.get(ts.id):void 0,Ao=!!(ts&&Ua?.agentResumeRecovered&&Ua.agentNativeSessionId&&Ua.terminalSessionId),Vs=ts&&un?.sessionId===ts.id?un:null;_.useLayoutEffect(()=>{if(!ee)return;const S=Ot.current;if(!S)return;const P=!hr.current;S.scrollIntoView({inline:"nearest",block:"nearest",behavior:P?"auto":"smooth"}),hr.current=!0,P&&vu("active-tab-positioned")},[yt,ee]),b.useEffect(()=>{tr&&Dt.current&&(Dt.current.scrollIntoView({block:"nearest",inline:"nearest"}),Dt.current.focus(),Dt.current.select()),tr||(ot.current=!1)},[tr]);const sc=b.useCallback(S=>{window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:S}))},[]),Ml=b.useCallback((S,P)=>{Zn(P??null),_n(S)},[]),ic=Xv(),za=b.useCallback(S=>{if(!S)return;$(S),ze.current&&va("info","PWA_NOTIFICATION_CLICK app-focus-request",{traceId:ze.current,requestedSessionId:S,activeSessionId:yt,sessions:gt.map(ue=>({id:ue.id,terminalSessionId:sr.get(ue.id)?.terminalSessionId??null}))}),B9(S);const P=gt.find(ue=>ue.id===S||sr.get(ue.id)?.terminalSessionId===S);P?(Qe.current=null,ze.current&&va("info","PWA_NOTIFICATION_CLICK app-focus-dispatch",{traceId:ze.current,requestedSessionId:S,targetSessionId:P.id}),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:P.id}))):(Qe.current=S,ze.current&&va("info","PWA_NOTIFICATION_CLICK app-focus-pending",{traceId:ze.current,requestedSessionId:S}))},[yt,gt,sr]);b.useEffect(()=>{if(typeof window>"u"||typeof caches>"u")return;let S=!1;const P=async()=>{if(window.parent!==window&&ol()){se(!0);return}try{const tt=await caches.open(a$),St=await tt.match(Xb);if(!St)return;await tt.delete(Xb);const Kt=await St.json();if(S)return;const wr=typeof Kt.sessionId=="string"?Kt.sessionId:null,xn=typeof Kt.traceId=="string"?Kt.traceId:null,Dn=typeof Kt.clickedAt=="number"?Kt.clickedAt:0,Mn=Date.now()-Dn;va("info","PWA_NOTIFICATION_CLICK app-cache-consumed",{traceId:xn,sessionId:wr,ageMs:Mn,valid:!!(wr&&Mn>=0&&Mn<=Jb),visibilityState:document.visibilityState}),wr&&Mn>=0&&Mn<=Jb&&(ze.current=xn,typeof Kt.targetPeerId=="string"&&Kt.targetPeerId!==r0()?.targetPeerId?ol()?.focusSession(Kt.targetPeerId,wr):za(wr))}catch(tt){va("warn","PWA_NOTIFICATION_CLICK app-cache-failed",{error:tt instanceof Error?tt.message:String(tt)})}finally{S||se(!0)}},ue=()=>{document.visibilityState==="visible"&&P()};return P(),document.addEventListener("visibilitychange",ue),window.addEventListener("pageshow",P),()=>{S=!0,document.removeEventListener("visibilitychange",ue),window.removeEventListener("pageshow",P)}},[za]),b.useEffect(()=>{if(typeof window>"u")return;const S=new URLSearchParams(window.location.search),P=S.get("session");if(!P)return;va("info","PWA_NOTIFICATION_CLICK app-url-received",{traceId:ze.current,targetSessionId:P,href:window.location.href,visibilityState:document.visibilityState});const ue=S.get("service");ue&&ue!==r0()?.targetPeerId?ol()?.focusSession(ue,P):Qe.current=P,S.delete("service"),S.delete("session"),S.delete("_notifTrace");const tt=S.toString(),St=`${window.location.pathname}${tt?`?${tt}`:""}${window.location.hash}`;window.history.replaceState(window.history.state,"",St)},[]),b.useEffect(()=>{if(typeof window>"u")return;const S=new URLSearchParams(window.location.search);if(S.get("_notif")!=="1")return;const P=S.get("session");S.delete("_notif");const ue=S.toString(),tt=`${window.location.pathname}${ue?`?${ue}`:""}${window.location.hash}`;if(window.history.replaceState(window.history.state,"",tt),window.parent!==window&&ol())return;const St=new BroadcastChannel("termdock:notif");let Kt=!1;const wr=Dn=>{Dn.data?.type==="termdock:notif-pong"&&!Kt&&(Kt=!0,St.close(),window.close())};St.addEventListener("message",wr),St.postMessage({type:"termdock:notif-ping",sessionId:P,targetPeerId:S.get("service")});const xn=setTimeout(()=>{Kt||St.close()},500);return()=>{clearTimeout(xn),Kt||St.close()}},[]),b.useEffect(()=>{if(typeof window>"u"||window.parent!==window&&ol())return;const S=new BroadcastChannel("termdock:notif"),P=ue=>{ue.data?.type==="termdock:notif-ping"&&(S.postMessage({type:"termdock:notif-pong"}),typeof ue.data.sessionId=="string"&&(typeof ue.data.targetPeerId=="string"&&ue.data.targetPeerId!==r0()?.targetPeerId?ol()?.focusSession(ue.data.targetPeerId,ue.data.sessionId):za(ue.data.sessionId)))};return S.addEventListener("message",P),()=>S.close()},[za]),b.useEffect(()=>{if(typeof navigator>"u"||!("serviceWorker"in navigator))return;const S=P=>{const ue=P.data;if(ue&&ue.type==="termdock:focus-session"&&typeof ue.sessionId=="string"){if(typeof ue.targetPeerId=="string"&&ue.targetPeerId!==r0()?.targetPeerId){ol()?.focusSession(ue.targetPeerId,ue.sessionId)&&P.ports[0]?.postMessage({type:"termdock:focus-session-ack"});return}P.ports[0]?.postMessage({type:"termdock:focus-session-ack"}),za(ue.sessionId)}else ue?.type==="termdock:push-subscription-changed"?t0(!0):ue?.type};return navigator.serviceWorker.addEventListener("message",S),()=>navigator.serviceWorker.removeEventListener("message",S)},[za]),b.useEffect(()=>{const S=P=>{const ue=P.detail;typeof ue=="string"&&za(ue)};return window.addEventListener("termdock:focus-session",S),()=>window.removeEventListener("termdock:focus-session",S)},[za]),b.useEffect(()=>{const S=()=>{const P=U9(r0()?.targetPeerId);P&&za(P)};return S(),window.addEventListener("termdock:workspace-session",S),()=>window.removeEventListener("termdock:workspace-session",S)},[za]),b.useEffect(()=>{const S=Qe.current;if(!S)return;const P=gt.find(ue=>ue.id===S||sr.get(ue.id)?.terminalSessionId===S);P?(Qe.current=null,ze.current&&va("info","PWA_NOTIFICATION_CLICK app-pending-dispatch",{traceId:ze.current,requestedSessionId:S,targetSessionId:P.id,activeSessionId:yt}),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:P.id}))):ze.current&&va("info","PWA_NOTIFICATION_CLICK app-pending-unmatched",{traceId:ze.current,requestedSessionId:S,activeSessionId:yt,sessions:gt.map(ue=>({id:ue.id,terminalSessionId:sr.get(ue.id)?.terminalSessionId??null}))})},[yt,gt,sr]);const us=_.useMemo(()=>{const S=[];for(const P of gt){const ue=sr.get(P.id);(ue?.agentStatus==="waiting"||ue?.agentNeedsReview)&&S.push(P.id)}return S},[gt,sr]),Wo=b.useCallback(()=>{if(us.length===0)return;yt&&Yr.getState().clearAgentNeedsReview(yt);const S=yt?gt.findIndex(ue=>ue.id===yt):-1,P=us.find(ue=>gt.findIndex(tt=>tt.id===ue)>S)??us[0];P&&window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:P}))},[us,gt,yt]),$c=b.useCallback(()=>{if(us.length===0)return;yt&&Yr.getState().clearAgentNeedsReview(yt);const S=yt?gt.findIndex(ue=>ue.id===yt):gt.length,P=[...us].reverse().find(ue=>gt.findIndex(tt=>tt.id===ue)<S)??us[us.length-1];P&&window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:P}))},[us,gt,yt]);b.useEffect(()=>{const S=P=>{!P.altKey||!P.shiftKey||P.metaKey||P.ctrlKey||P.key!=="ArrowUp"&&P.key!=="ArrowDown"||(P.preventDefault(),P.key==="ArrowUp"?$c():Wo())};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[Wo,$c]);const Nd=b.useCallback(async S=>{const ue=Yr.getState().sessions.get(S)?.cwd;if(ue)try{await navigator.clipboard?.writeText(ue),Gn(ue),window.setTimeout(()=>{Gn(tt=>tt===ue?null:tt)},1400)}catch{}},[]),qf=b.useCallback(S=>{bt(S.sessions),pr(S.activeSessionId),dt(S.splitWorkspaces),Yr.getState().setActiveSessionId(S.activeSessionId)},[]),Yf=b.useCallback(()=>{_r(!0)},[]),Zf=b.useCallback(()=>{_r(!0),window.requestAnimationFrame(()=>{window.dispatchEvent(new Event("termdock:initial-viewport-presented"))})},[]);b.useEffect(()=>{if(!N||!yt)return;gt.find(P=>P.id===N||sr.get(P.id)?.terminalSessionId===N)?.id===yt&&$(null)},[yt,N,gt,sr]);const Wu=b.useRef(!1),[Uc,Rd]=b.useState(!1),To=b.useCallback(S=>{const P=!S?.onResult;if(P&&Wu.current)return;P&&(Wu.current=!0,Rd(!0));const ue=S?.mode??Gs,tt=ue==="tmux"&&(S?.tmuxSessionName?.trim()||Ui.trim())||void 0,St=S?.cwd||(yt?Yr.getState().sessions.get(yt)?.cwd:void 0);window.dispatchEvent(new CustomEvent("new-terminal-session",{detail:{mode:ue,tmuxSessionName:tt,cwd:St,command:S?.command,shouldActivate:S?.shouldActivate,onResult:S?.onResult??(Kt=>{Wu.current=!1,Rd(!1),Kt.ok||Gr({tone:"error",message:e(Rm(Kt.error))})})}}))},[Gs,Ui,yt,e]),fl=b.useCallback(async()=>{Or(!0);try{const S=await _m();if(Kr(S),!S.available){Pn([]);return}const P=await km();Pn(P)}catch{Kr({available:!1,version:null,reason:"tmux integration is unavailable with the current server build."}),Pn([])}finally{Or(!1)}},[]),zc=b.useCallback(async S=>{const{cleanedSessions:P}=await a3(S);for(const ue of P)window.dispatchEvent(new CustomEvent("close-terminal-session-by-backend",{detail:ue}));await fl()},[fl]),Gu=b.useCallback(async S=>{fn(S),Ue(null);try{await zc(S),Pr(null)}catch(P){Ue(P instanceof Error?P.message:"Failed to kill tmux session")}finally{fn(null)}},[zc]);b.useEffect(()=>{if(!Et)return;if(Dr.find(ue=>ue.name===Et&&(ue.connected||ue.boundFrontendSessionId))){kt(null);return}const P=setTimeout(()=>kt(null),1e4);return()=>clearTimeout(P)},[Et,Dr]);const jl=b.useCallback(S=>{window.dispatchEvent(new CustomEvent("close-terminal-session",{detail:S}))},[]),Vu=b.useCallback(S=>{const P=S??yt;P&&window.dispatchEvent(new CustomEvent("open-terminal-split-chooser",{detail:P}))},[yt]),ac=b.useCallback((S,P)=>{window.dispatchEvent(new CustomEvent("set-terminal-split-direction",{detail:{sessionId:S,layout:P}}))},[]),Md=b.useCallback((S,P)=>{window.dispatchEvent(new CustomEvent("reorder-terminal-split-workspace",{detail:{workspaceId:S,sessionIds:P}}))},[]),Hc=b.useCallback((S,P)=>{window.dispatchEvent(new CustomEvent("rename-terminal-split-workspace",{detail:{workspaceId:S,name:P}}))},[]),qu=b.useCallback((S,P)=>{window.dispatchEvent(new CustomEvent("combine-terminal-split-sessions",{detail:{primaryId:S,secondaryId:P}}))},[]),oc=b.useCallback((S,P,ue)=>{const tt=gt.find(Kt=>Kt.id===S);if(!tt)return;const St=sr.get(S);if(ue?.skipConfirmation||!C5({mode:tt.mode,activeProgram:St?.activeProgram??null,promptState:St?.promptState??null,shellNames:ya})){jl({sessionId:S,source:"sidebar",closeMode:tt.mode==="tmux"?"destroy":"auto"});return}Rt(P?{x:P.clientX,y:P.clientY}:null),qe(S),Ue(null)},[gt,sr,jl]);b.useEffect(()=>{if(!Be)return;const S=P=>{const ue=P.detail;ue==="new-session"?To():ue==="close-session"?yt&&oc(yt):ue==="previous-session"||ue==="next-session"?window.dispatchEvent(new CustomEvent("cycle-terminal-session",{detail:{direction:ue==="next-session"?"next":"prev"}})):ue==="toggle-left-sidebar"?Ei():ue==="toggle-right-sidebar"?On():ue==="previous-attention"?$c():ue==="next-attention"&&Wo()};return window.addEventListener("termdock:native-command",S),()=>window.removeEventListener("termdock:native-command",S)},[yt,Be,To,oc,Ei,On,Wo,$c]);const Ha=_.useMemo(()=>gt.find(S=>S.id===ct)??null,[gt,ct]),Yu=b.useCallback(()=>{Ha&&(jl({sessionId:Ha.id,source:"sidebar",closeMode:"destroy"}),qe(null),Rt(null))},[Ha,jl]);b.useEffect(()=>{if(!Ha)return;const S=P=>{if(P.key==="Escape"){P.preventDefault(),P.stopImmediatePropagation(),qe(null),Rt(null),Ue(null);return}P.key!=="Enter"||P.isComposing||P.keyCode===229||P.altKey||P.ctrlKey||P.metaKey||P.shiftKey||(P.preventDefault(),P.stopImmediatePropagation(),P.repeat||Yu())};return window.addEventListener("keydown",S,!0),()=>window.removeEventListener("keydown",S,!0)},[Ha,Yu]);const jd=_.useMemo(()=>{if(!Ha)return"";const S=sr.get(Ha.id);return sl(Ha,S?.activeProgram??null,S?.cwd??null,ya,S?.shellTitle??null,S?.promptState??null).primary},[Ha,sr]);b.useEffect(()=>{if(!et)return;let S=!1,P=!1;const ue=async()=>{if(!P)try{const St=await _m();if(S||Kr(St),!St.available){S||Pn([]);return}const Kt=await km();S||Pn(Kt)}catch{P=!0,S||(Kr({available:!1,version:null,reason:"tmux integration is unavailable with the current server build."}),Pn([]))}};ue();const tt=setInterval(()=>{ue()},4e3);return()=>{S=!0,clearInterval(tt)}},[et]);const Dd=bi??Gs,Zu=Dd==="shell",Wc=Dd==="tmux"&&Sr.available,Gc=_.useMemo(()=>L3(Dr.map(S=>({...S,id:S.name})),S=>S.cwd??null,e("sidebar.ungrouped")),[Dr,e]),lc=_.useMemo(()=>Dr.filter(S=>S.recoveryCandidate===!0&&!S.connected&&!S.boundFrontendSessionId).sort((S,P)=>(P.lastActiveAt??P.createdAt??0)-(S.lastActiveAt??S.createdAt??0)),[Dr]);b.useEffect(()=>{!Er&&!(ht&&ir)||fl()},[Er,ht,ir,gt.length,fl]);const Vc=(S,P,ue,tt=!1)=>{const St=S.id===yt,Kt=S.id===tr,wr=sr.get(S.id),{primary:xn,secondary:Dn}=sl(S,wr?.activeProgram??null,wr?.cwd??null,ya,wr?.shellTitle??null,wr?.promptState??null),Mn=Pu(wr?.cwd??null),vi=P?Dn??(Mn&&Mn!==xn?Mn:null):null,wn=wr?.gitStatus,Bi=`${wr?.cwd||S.name}${wn?`
178
+ }`}),R&&s.jsx("div",{className:"whitespace-pre-wrap break-words text-[10px] text-[color:var(--warning)]",children:R}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>{Te()},className:"flex items-center gap-1 rounded-full bg-[rgb(var(--success-rgb)_/_0.14)] px-3 py-1 text-[11px] font-medium text-[color:var(--success)] hover:bg-[rgb(var(--success-rgb)_/_0.22)] transition",children:[s.jsx(DA,{size:11}),e("settings.agentPluginCreate")]}),s.jsx("button",{type:"button",onClick:()=>{x(!1),E(""),B(null)},className:"rounded-full px-3 py-1 text-[11px] text-muted-foreground hover:text-foreground transition",children:e("common.cancel")})]})]})]})]})}function UF({state:e,pending:t,onCheck:r,onConfirmRestart:n,desktopState:a,desktopPending:c=!1,desktopSnapshot:l,desktopActions:h,onCheckDesktop:p,onInstallDesktop:m}){const{t:x}=zr(),y=e?.status??"idle",w=t||y==="checking"||y==="installing"||y==="restarting",v=y==="ready"&&!!e?.latestVersion,k=y==="checking"?x("settings.updateChecking"):y==="installing"?x("sidebar.updateInstalling"):y==="ready"?x("sidebar.updateReady"):y==="restarting"?x("sidebar.updateRestarting"):y==="current"?x("settings.updateCurrent"):y==="error"?e?.error||x("sidebar.updateFailed"):x("settings.updateHint"),L=a?.currentVersion||l?.appVersion,E=a?.status??"idle",R=c||E==="checking"||E==="downloading"||E==="installing",B=E==="ready",W=a?.error||(E==="unsupported"?x("settings.desktopUpdateUnsupported"):E==="checking"?x("settings.desktopUpdateChecking"):E==="current"?x("settings.desktopUpdateCurrent"):E==="downloading"?x("settings.desktopUpdateDownloading"):E==="ready"?x("settings.desktopUpdateReady"):E==="installing"?x("settings.desktopUpdateInstalling"):E==="error"&&a?.error||x("settings.desktopUpdateHint"));return s.jsxs("section",{className:"mt-3 overflow-hidden rounded-xl bg-surface-2","aria-labelledby":"termdock-update-title",children:[s.jsx("div",{id:"termdock-update-title",className:"px-3 pt-3 text-[12px] font-semibold text-foreground",children:x("settings.updateTitle")}),s.jsxs("div",{className:"flex items-start justify-between gap-3 px-3 py-3",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2.5",children:[s.jsx("span",{className:`mt-0.5 inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg ${v?"bg-[rgb(var(--warning-rgb)_/_0.16)] text-[color:var(--warning)]":"bg-primary/15 text-primary"}`,children:s.jsx(yn,{size:15,className:w?"animate-spin":""})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[12px] font-medium text-foreground",children:x("settings.updateRuntimeTitle")}),s.jsx("div",{className:"mt-0.5 text-[10px] leading-relaxed text-muted-foreground",children:k}),e&&s.jsx("div",{className:"mt-1 text-[10px] tabular-nums text-muted-foreground/75",children:v&&e.latestVersion?`${e.currentVersion} → ${e.latestVersion}`:`v${e.currentVersion}`})]})]}),v?s.jsx("button",{type:"button",disabled:w,onClick:n,className:"shrink-0 rounded-full bg-[var(--warning)] px-3 py-1.5 text-[11px] font-semibold text-[color:var(--bg)] transition hover:opacity-90 disabled:cursor-wait disabled:opacity-60",children:x("sidebar.updateRestart")}):s.jsx("button",{type:"button",disabled:w,onClick:r,className:"shrink-0 rounded-full bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground transition hover:bg-surface-elevated disabled:cursor-wait disabled:opacity-60",children:x(y==="checking"?"settings.updateCheckingShort":y==="installing"?"settings.updateInstallingShort":y==="error"?"sidebar.updateRetry":y==="current"?"settings.updateCheckAgain":"settings.updateCheck")})]}),(a||h)&&s.jsxs("div",{className:"flex items-start justify-between gap-3 border-t border-border/10 px-3 py-3",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2.5",children:[s.jsx("span",{className:`mt-0.5 inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg ${B?"bg-[rgb(var(--warning-rgb)_/_0.16)] text-[color:var(--warning)]":"bg-primary/15 text-primary"}`,children:s.jsx(yn,{size:15,className:R?"animate-spin":""})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[12px] font-medium text-foreground",children:x("settings.desktopUpdateTitle")}),s.jsx("div",{className:`mt-0.5 text-[10px] leading-relaxed ${a?.error?"text-destructive":"text-muted-foreground"}`,role:a?.error?"alert":void 0,children:a?W:x(p?"settings.desktopStatusLoading":"settings.desktopUpdateUnsupported")}),s.jsx("div",{className:"mt-1 text-[10px] tabular-nums text-muted-foreground/75",children:B&&a?.latestVersion?`${a.currentVersion} → ${a.latestVersion}`:L?`v${L}`:null})]})]}),B?s.jsx("button",{type:"button",disabled:R||!m,onClick:m,className:"shrink-0 rounded-full bg-[var(--warning)] px-3 py-1.5 text-[11px] font-semibold text-[color:var(--bg)] transition hover:opacity-90 disabled:cursor-wait disabled:opacity-60",children:x("settings.desktopUpdateRestart")}):s.jsx("button",{type:"button",disabled:!a||R||E==="unsupported"||!p,onClick:p,className:"shrink-0 rounded-full bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground transition hover:bg-surface-elevated disabled:cursor-wait disabled:opacity-60",children:x(E==="installing"?"settings.updateInstallingShort":E==="downloading"?"settings.desktopUpdateDownloadingShort":E==="checking"?"settings.updateCheckingShort":E==="current"||E==="error"?"settings.desktopUpdateCheckAgain":"settings.desktopUpdateCheck")})]}),h]})}function zF({quality:e}){const{locale:t}=zr(),r=(h,p)=>t==="zh"?h:p,n=h=>h==null||!Number.isFinite(h)?"—":`${h.toFixed(1)} ms`,a=e?.diagnostics,c=h=>s.jsx("dl",{className:"grid grid-cols-[minmax(0,1fr)_auto] gap-x-3 gap-y-1.5 tabular-nums",children:h.map(([p,m])=>s.jsxs(_.Fragment,{children:[s.jsx("dt",{children:p}),s.jsx("dd",{className:"text-right text-foreground break-all",children:m})]},p))}),l=(h,p)=>s.jsxs("section",{className:"mt-3 border-t border-border/30 pt-3",children:[s.jsx("h3",{className:"mb-2 font-medium text-foreground",children:h}),p]});return s.jsxs("div",{className:"text-[11px] leading-relaxed",children:[l(r("往返统计","Round-trip statistics"),s.jsxs(s.Fragment,{children:[c([[r("平均延迟","Average latency"),n(e?.average)],["P95",n(e?.p95)],[r("服务端回包处理","Server reply handler"),n(e?.handlerMs)]]),s.jsx("p",{className:"mt-2",children:r("8 秒未响应计为超时,不等于网络丢包。回包处理仅含消息解析至构造回复,不含解密、排队和发包。","A probe times out after 8s; this is not packet loss. Handler timing covers parsing through reply creation, excluding decryption, queues and transmission.")})]})),l(r("当前发送与排队","Current buffers and queues"),a?s.jsxs(s.Fragment,{children:[c([[r("传输层发送缓冲","Transport send buffer"),`${a.bufferedBytes} B`],[r("加密通道待发送","Channel writes pending"),a.pendingWrites?r("有","Yes"):r("无","No")],[r("进行中的非终端请求","Active non-terminal requests"),a.activeRequests],[r("等待通道的请求","Requests waiting for capacity"),a.waitingRequests]]),s.jsx("p",{className:"mt-2",children:r("属于此服务共用的连接,包含文件等其他请求。","Shared by this service, including file transfers and other requests.")})]}):s.jsx("p",{children:r("尚无连接记录。","No connection record yet.")})),l(r("本次连接建立 · 历史耗时","Connection setup · recorded timings"),s.jsxs(s.Fragment,{children:[c([[r("传输通道就绪","Transport ready"),n(a?.transportOpenMs)],...a?.relay?[[r("其中:连上入口 WebSocket","Within transport: entry WebSocket"),n(a.relay.entryOpenMs)],[r("其中:请求中转至通道打开","Within transport: relay open request"),n(a.relay.routeOpenMs)]]:[],[r("Noise 加密握手","Noise handshake"),n(a?.handshakeMs)],[r("终端逻辑通道就绪","Terminal logical channel ready"),n(a?.socketOpenMs)],[r("其中:等待本地通道名额","Within logical open: local capacity wait"),n(a?.socketQueueMs)]]),s.jsx("p",{className:"mt-2",children:r("这是建链时的历史耗时,不代表当前延迟。“其中”为子项,不能重复相加;中转耗时含处理和建链,不含之前的授权。","Recorded setup timings, not live latency. “Within” rows are subsets, not additive. Relay timing includes processing and setup, excluding earlier authorization.")})]}))]})}function HF({backendSessionId:e}){const{locale:t}=zr(),r=t==="zh",[n,a]=_.useState(null),[c,l]=_.useState(!1);_.useEffect(()=>{if(a(null),!c||!e)return;const y=()=>a(c9(e));y();const w=setInterval(y,1e3);return document.addEventListener("visibilitychange",y),()=>{clearInterval(w),document.removeEventListener("visibilitychange",y)}},[e,c]);const h=n?.diagnostics,p=n?.rtt,m=n?.connected?n.waiting?r?"等待响应…":"Waiting for reply…":p==null?r?"测量中…":"Measuring…":`${p} ms · ${p<150?r?"流畅":"Low latency":p<300?r?"有延迟":"Moderate latency":r?"高延迟":"High latency"}`:r?"未连接":"Disconnected",x=y=>y==null?"—":`${Math.round(y)} ms`;return s.jsxs("div",{className:"mt-3 rounded-xl bg-surface-2 px-3 text-muted-foreground",children:[s.jsxs("button",{type:"button","aria-expanded":c,onClick:()=>l(y=>!y),className:"flex min-h-11 w-full items-center gap-2 py-2 text-[12px] tabular-nums hover:text-foreground","aria-label":`${r?"连接质量":"Connection quality"}${c?`: ${m}`:""}`,children:[s.jsx("span",{"aria-hidden":"true",className:`h-1.5 w-1.5 rounded-full ${c&&n&&(!n.connected||n.waiting||p!=null&&p>=300)?"bg-destructive":"bg-current"}`}),s.jsxs("span",{className:"flex-1 text-left",children:[r?"连接质量":"Connection quality",c?` · ${m}`:""]}),s.jsx("span",{"aria-hidden":"true",children:c?"▾":"▸"})]}),c&&s.jsxs("div",{className:"pb-3 text-[11px] leading-relaxed",children:[!e&&s.jsx("p",{children:r?"请先打开一个终端会话,再查看连接质量。":"Open a terminal session to measure connection quality."}),s.jsxs("dl",{className:"grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-2 tabular-nums",children:[s.jsx("dt",{children:r?"近期延迟":"Recent latency"}),s.jsx("dd",{className:"text-right text-foreground",children:n?.minimum==null?"—":`${Math.round(n.minimum)}–${Math.round(n.maximum??n.minimum)} ms`}),s.jsx("dt",{children:r?"波动":"Jitter"}),s.jsx("dd",{className:"text-right text-foreground",children:x(n?.jitter)}),s.jsx("dt",{children:r?"探测超时":"Probe timeouts"}),s.jsx("dd",{className:"text-right text-foreground",children:n?.samples?`${n.timeouts} / ${n.samples}`:"—"}),s.jsx("dt",{children:r?"连接路径":"Connection route"}),s.jsx("dd",{className:"text-right text-foreground break-words",children:h?`${h.path==="relay"?r?"经入口中转":"Via relay":r?"直连":"Direct"} · ${h.endpoint}`:"—"})]}),s.jsx("p",{className:"mt-2",children:r?"每 5 秒更新,统计最近 20 次;波动越小越稳定。":"Updates every 5s, using the last 20 probes. Lower jitter means more consistent latency."}),s.jsxs("details",{className:"mt-3 border-t border-border/30 pt-2",children:[s.jsx("summary",{className:"cursor-pointer py-1 hover:text-foreground",children:r?"诊断详情":"Diagnostics"}),s.jsx(zF,{quality:n})]})]})]})}const Hb={"startup-failure":"settings.serverHealthEventStartupFailure",crash:"settings.serverHealthEventCrash","crash-native":"settings.serverHealthEventCrashNative",killed:"settings.serverHealthEventKilled",wedge:"settings.serverHealthEventWedge","port-conflict":"settings.serverHealthEventPortConflict","gave-up":"settings.serverHealthEventGaveUp","exit-zero-unexpected":"settings.serverHealthEventExitZero","terminated-externally":"settings.serverHealthEventTerminated","supervisor-lost":"settings.serverHealthEventSupervisorLost","uncaught-exception":"settings.serverHealthEventUncaughtException","unhandled-rejection":"settings.serverHealthEventUnhandledRejection","exit-nonzero":"settings.serverHealthEventExitNonzero"};function WF(e){return e<1e3?`${e}ms`:e<6e4?`${Math.round(e/1e3)}s`:e<36e5?`${Math.round(e/6e4)}m`:`${Math.round(e/36e5)}h`}function GF({state:e,onDismiss:t}){const{t:r}=zr(),[n,a]=b.useState(!1),[c,l]=b.useState(!1),h=b.useRef(!1),p=b.useRef(!0);b.useEffect(()=>(p.current=!0,()=>{p.current=!1}),[]),b.useEffect(()=>{e?.supervised&&(h.current=!1,a(!1),l(!1))},[e?.supervised]),b.useEffect(()=>{if(!n)return;const W=window.setTimeout(()=>{h.current=!1,a(!1),l(!0)},45e3);return()=>window.clearTimeout(W)},[n]);const m=async()=>{if(!h.current){h.current=!0,l(!1),a(!0);try{await u9()}catch{if(!p.current)return;h.current=!1,a(!1),l(!0)}}};if(!e)return null;const x=e.incident,y=!e.supervised&&e.supervisor?.phase==="gave-up",w=!e.supervised&&e.supervisor!==null&&!e.supervisor.alive,v=y||w||e.attention,k=e.supervised&&e.supervisor?.alive&&e.supervisor.phase==="running",L=y?r("settings.serverHealthGaveUp",{count:e.supervisor?.consecutiveCrashes??0}):w?r("settings.serverHealthSupervisorLost"):e.supervised?r("settings.serverHealthSupervised"):r("settings.serverHealthUnsupervised"),E=x?r(Hb[x.event]??"settings.serverHealthUnknownEvent"):"",R=x?.causeEvent?r(Hb[x.causeEvent]??"settings.serverHealthUnknownEvent"):"",B=x?[new Date(x.at).toLocaleString(),x.uptimeMs!==null?r("settings.serverHealthUptime",{duration:WF(x.uptimeMs)}):null,x.signal?`signal ${x.signal}`:null,x.exitCode!==null?`exit ${x.exitCode}`:null].filter(Boolean).join(" · "):"";return s.jsxs("section",{className:"mt-3 overflow-hidden rounded-xl bg-surface-2","aria-labelledby":"server-health-title",children:[s.jsx("div",{id:"server-health-title",className:"px-3 pt-3 text-[12px] font-semibold text-foreground",children:r("settings.serverHealthTitle")}),s.jsxs("div",{className:"flex items-start justify-between gap-3 px-3 py-3",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2.5",children:[s.jsx("span",{className:`mt-0.5 inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg ${v?"bg-destructive/15 text-destructive":"bg-primary/15 text-primary"}`,children:v?s.jsx(eC,{size:15}):s.jsx(rC,{size:15})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[12px] font-medium text-foreground",children:L}),s.jsx("div",{className:"mt-0.5 text-[10px] leading-relaxed text-muted-foreground",children:x?`${r(k?"settings.serverHealthHistory":"settings.serverHealthLastIncident")}: ${E}${R?` · ${R}`:""}`:r("settings.serverHealthClean")}),x&&k&&s.jsx("div",{className:"mt-1 text-[11px] text-primary",children:r("settings.serverHealthRunningNow")}),x&&s.jsx("div",{className:"mt-1 text-[10px] tabular-nums text-muted-foreground/75",children:B}),x?.detail&&s.jsx("div",{className:"mt-1 break-words text-[10px] text-muted-foreground/75",children:x.detail}),x?.oomSuspect&&s.jsx("div",{className:"mt-1 text-[10px] text-[color:var(--warning)]",children:r("settings.serverHealthOomNote")}),e.supervisor&&e.supervisor.restarts>0&&!y&&s.jsx("div",{className:"mt-1 text-[10px] tabular-nums text-muted-foreground/75",children:r("settings.serverHealthRestarted",{count:e.supervisor.restarts})})]})]}),e.attention&&s.jsx("button",{type:"button",onClick:t,className:"shrink-0 rounded-full bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground transition hover:bg-surface-elevated",children:r("settings.serverHealthDismiss")})]}),!e.supervised&&s.jsxs("div",{className:"border-t border-border px-3 py-3",children:[s.jsx("p",{className:"text-[11px] leading-relaxed text-muted-foreground",children:e.canEnableSupervision?r("settings.serverHealthEnableHint"):r("settings.serverHealthEnableUnavailable")}),e.canEnableSupervision&&s.jsx("button",{type:"button",onClick:m,disabled:n,className:"mt-2 min-h-11 rounded-lg bg-primary px-3 text-[12px] font-medium text-primary-foreground disabled:opacity-60",children:r(n?"settings.serverHealthEnabling":"settings.serverHealthEnable")}),n&&s.jsx("p",{role:"status",className:"mt-2 text-[11px] text-muted-foreground",children:r("settings.serverHealthEnablePending")}),c&&s.jsx("p",{role:"alert",className:"mt-2 text-[11px] text-destructive",children:r("settings.serverHealthEnableError")})]})]})}const VF=()=>()=>{},qF=()=>1/0;function YF(){const{t:e}=zr(),t=b.useId(),r=ol(),n=b.useSyncExternalStore(r?.subscribe??VF,r?.retentionLimit??qF);if(!r)return null;const a=d9+1,c=n===1/0?e("settings.workspaceUnlimited"):String(n);return s.jsxs("div",{className:"space-y-1.5 rounded-xl bg-surface-2 px-2.5 py-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{htmlFor:t,className:"shrink-0 text-[12px] font-medium text-foreground/90",children:e("settings.workspaceLimit")}),s.jsx("input",{id:t,type:"range",min:3,max:a,step:1,value:n===1/0?a:n,"aria-valuetext":c,"aria-describedby":`${t}-hint`,onChange:l=>{const h=Number(l.target.value);r.setRetentionLimit(h===a?1/0:h)},className:"h-8 min-w-0 flex-1"}),s.jsx("output",{htmlFor:t,className:"min-w-12 shrink-0 text-right text-[11px] tabular-nums text-muted-foreground",children:c})]}),s.jsx("p",{id:`${t}-hint`,className:"text-[11px] leading-relaxed text-muted-foreground",children:e("settings.workspaceLimitHint")})]})}const A1="mobile-session-destroy";function ZF(e,t){return t&&e.type==="session"&&e.destination?.droppableId===A1}const ba="termdock-program-rules-cache",_h="termdock-toolbar-presets-cache",D0="termdock-settings-cache",Wb="termdock-color-theme",Gb="termdock:right-sidebar:file-preview-open-by-session:v2",B0="termdock:running-session-button-enabled:v1",Q0="termdock:attention-button-enabled:v1",KF=60,Vb=320,qb=420,No=8;function Yb(e,t,r){return Math.min(Math.max(e,t),r)}function Zb(e){if(typeof window>"u")return{left:No,top:No};const t=window.innerWidth/2,r=Math.min(64,window.innerHeight/4),n=e?.x??t,a=e?.y??r,c=Math.max(No,window.innerWidth-Vb-No),l=Math.max(No,window.innerHeight-qb-No);return{left:Yb(n+No,No,c),top:Yb(a+No,No,l),width:Vb,maxHeight:`min(${qb}px, calc(100vh - ${No*2}px))`}}function XF(e){return e==="dark"||e==="light"}function JF(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.entries(e).every(([t,r])=>{if(!t||!r||typeof r!="object"||Array.isArray(r))return!1;const n=r;return typeof n.updatedAt=="number"&&Number.isFinite(n.updatedAt)})}function Sm(e){const t=Object.entries(e).filter(([r,n])=>r&&Number.isFinite(n.updatedAt)).sort(([,r],[,n])=>n.updatedAt-r.updatedAt).slice(0,KF);return Object.fromEntries(t)}function e$(e){return Array.isArray(e)&&e.every(t=>{if(!t||typeof t!="object")return!1;const r=t;return typeof r.id=="string"&&typeof r.pattern=="string"&&typeof r.output=="string"&&(r.matchType==="exact"||r.matchType==="includes"||r.matchType==="prefix"||r.matchType==="regex")})}function t$(e){return typeof e=="object"&&e!==null&&typeof e.version=="number"&&Array.isArray(e.presets)}function r$(e,t){const r=ud(),n=new Set(zI()),a=Array.isArray(e)?e:[],c=yu(a),l=t<$0;if(c.length===0)return r;if(l){const p=new Map(c.map(w=>[w.id,w])),m=new Map(a.map(w=>[typeof w.id=="string"?w.id.trim().toLowerCase().replace(/[^a-z0-9_-]/g,"-"):"",w])),x=c.filter(w=>!n.has(w.id));return[...r.map(w=>{const v=p.get(w.id),k=m.get(w.id);return v?{...w,rowLayout:v.rowLayout,showOnDesktop:typeof k?.showOnDesktop=="boolean"?k.showOnDesktop:w.showOnDesktop}:w}),...x]}const h=new Set(c.map(p=>p.id));return[...c,...r.filter(p=>!h.has(p.id))]}function n$(e){return typeof e=="object"&&e!==null&&typeof e.preventSleep=="boolean"&&typeof e.networkAvailable=="boolean"}const s$={name:"",source:"auto",hostname:"",fallbackHostname:"",url:"",fallbackUrl:"",onboardingUrl:null,status:"disabled",reason:null,httpsEnabled:!1,caAvailable:!1,lanAddresses:[],interfaces:[]},Wf="__termdockOverlay",Gf="__termdockBaseAnchor",Vf="__termdockBaseGuard",i$=3,Kb=250,a$="termdock-notification-target-v1",Xb="/__termdock-notification-target",Jb=3e4;function o$(e){return e==="left-sidebar"||e==="right-sidebar"||e==="right-sidebar-repo-picker"||e==="right-sidebar-file-preview"||e==="settings"||e==="markdown-outline"||e==="markdown-image-lightbox"}function du(e){if(!e||typeof e!="object")return null;const t=e[Wf];return o$(t)?t:null}function bg(e){return e&&typeof e=="object"?{...e}:{}}function j6(e){const t=bg(e);return delete t[Wf],t}function l$(e){const t=j6(e);return delete t[Vf],{...t,[Gf]:!0}}function c$(){typeof window>"u"||window.history.pushState({...j6(window.history.state),[Gf]:!0,[Vf]:!0},"",window.location.href)}function D6(){for(let e=0;e<i$;e+=1)c$()}function kh(){typeof window>"u"||(window.history.replaceState(l$(window.history.state),"",window.location.href),D6())}function P0(e){typeof window>"u"||window.history.pushState({...bg(window.history.state),[Gf]:!0,[Wf]:e,[Vf]:!1},"",window.location.href)}function u$(e){typeof window>"u"||window.history.replaceState({...bg(window.history.state),[Gf]:!0,[Wf]:e,[Vf]:!1},"",window.location.href)}const B6=["bash","zsh","fish","sh","dash","ksh","tcsh","csh","nu"];let ya=new Set(B6);function e3(e){const t=new Map;for(const[r,n]of e)t.set(r,{cwd:n.cwd,activeProgram:n.activeProgram,activeProgramRaw:n.activeProgramRaw,inCopyMode:n.inCopyMode,isConnecting:n.isConnecting,agentStatus:n.agentStatus,agentIndicator:n.agentIndicator,agentStatusDetail:n.agentStatusDetail,agent:n.agent,agentMessage:n.agentMessage,agentNativeSessionId:n.agentNativeSessionId,agentResumeRecovered:n.agentResumeRecovered,terminalSessionId:n.terminalSessionId,agentNeedsReview:n.agentNeedsReview,gitStatus:n.gitStatus,shellTitle:n.shellTitle,promptState:n.promptState,tuiProgress:n.tuiProgress});return t}function d$(e,t){if(e.size!==t.size)return!1;for(const[r,n]of t){const a=e.get(r);if(!a||a.cwd!==n.cwd||a.activeProgram!==n.activeProgram||a.activeProgramRaw!==n.activeProgramRaw||a.inCopyMode!==n.inCopyMode||a.isConnecting!==n.isConnecting||a.agentStatus!==n.agentStatus||a.agentIndicator!==n.agentIndicator||a.agentStatusDetail!==n.agentStatusDetail||a.agent!==n.agent||a.agentMessage!==n.agentMessage||a.agentNativeSessionId!==n.agentNativeSessionId||a.agentResumeRecovered!==n.agentResumeRecovered||a.terminalSessionId!==n.terminalSessionId||a.agentNeedsReview!==n.agentNeedsReview||a.gitStatus!==n.gitStatus||a.shellTitle!==n.shellTitle||a.promptState!==n.promptState||a.tuiProgress?.state!==n.tuiProgress?.state||a.tuiProgress?.progress!==n.tuiProgress?.progress)return!1}return!0}function t3(e,t){return s.jsx(pP,{sessionMode:e,state:t})}function h$(e,t){const r=new Map(e.map(l=>[l.id,l])),n=t.map(l=>r.get(l)).filter(l=>l!==void 0),a=new Set(t),c=e.filter(l=>!a.has(l.id));return[...n,...c]}const f$=_.lazy(()=>kc(()=>import("./CollaborationMainWorkspace-BPyK5Xs8.js"),__vite__mapDeps([18,1,2,3,4,5,8,9,15,13])));function p$(){const{t:e,locale:t,setLocale:r}=zr(),n="env(safe-area-inset-top, 0px)",a="env(safe-area-inset-bottom, 0px)";h9();const c=_.useMemo(()=>typeof window>"u"?!1:/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1,[]),[l,h]=_.useState(!1),[p,m]=_.useState(()=>fc(Wb,XF)??"dark"),x=_.useRef(fc(D0,n$)).current,[y,w]=_.useState(x?.preventSleep??!1),[v,k]=_.useState(x?.networkAvailable??!0),[L,E]=_.useState(f9),[R,B]=_.useState(p9),[W,F]=_.useState(m9),[U,V]=_.useState(g9),[Z,le]=_.useState(hp),[xe,fe]=_.useState(x?.localAccess??s$),[te,ke]=_.useState(x?.localAccess?.name??""),[$e,Y]=_.useState(!1),[Ae,lt]=_.useState(null),[Ce,ye]=_.useState(null),[_e,je]=_.useState(null),[re,Pe]=_.useState(!1),[Se,Ee]=_.useState(null),Be=_.useMemo(()=>lo(),[]),Ne=!!(Be?.desktopUpdateState&&Be.checkDesktopUpdate&&Be.installDesktopUpdate),[oe,He]=_.useState(null),[rt,mt]=_.useState(null),[de,Ye]=_.useState(!1),[st,Ie]=_.useState(null),[We,Te]=_.useState(!1),[H,ae]=_.useState(()=>Sm(fc(Gb,JF)??{})),[be,Ze]=_.useState(0),[Je,Tt]=_.useState(!1),[Wt,Mt]=_.useState(0),[vt,Yt]=_.useState(!1),[Qt,Xt]=_.useState(0),[Ut,Lt]=_.useState(!1),[pe,Ge]=_.useState(0),ft=_.useRef(null),[q,at]=_.useState({}),{terminalSettings:Vt,updateTerminalSettings:Ve}=wB(),De=Vt.fontSize,er=Vt.rendererMode,[et,Ct]=_.useState(!1),Nt=_.useRef(x9()).current,[gt,bt]=b.useState(()=>Nt.sessions.map(S=>({id:S.sessionId,name:S.name,customName:S.customName,mode:S.mode,tmuxSessionName:S.tmuxSessionName}))),It=na(S=>S.groupId);_.useEffect(()=>{const S=()=>na.getState().terminal();return window.addEventListener("switch-terminal-session",S),()=>window.removeEventListener("switch-terminal-session",S)},[]);const[yt,pr]=_.useState(Nt.activeSessionId),[nr,_r]=_.useState(!1);_.useEffect(()=>{nr&&b9({rendered:!0})},[nr]);const[un,Ir]=_.useState(null),[me,Gr]=_.useState(null),[it,dt]=_.useState([]),[sr,An]=b.useState(()=>{const S=Yr.getState();return Nt.sessions.forEach(P=>{P.backendSessionId&&S.setTerminalSession(P.sessionId,{sessionId:P.backendSessionId,cols:80,rows:24,mode:P.mode,tmuxSessionName:P.tmuxSessionName}),P.activeProgram!=null&&S.setSessionActiveProgram(P.sessionId,P.activeProgram),P.cwd!=null&&S.setSessionCwd(P.sessionId,P.cwd),P.shellTitle!=null&&S.setSessionShellTitle(P.sessionId,P.shellTitle)}),vu("session-chrome-hydrated"),e3(Yr.getState().sessions)});b.useEffect(()=>{!Be||!et||Promise.all([Be.snapshot(),Be.desktopUpdateState?.()??Promise.resolve(null)]).then(([S,P])=>{He(S),mt(P)}).catch(S=>Ie(S instanceof Error?S.message:String(S)))},[Be,et]),b.useEffect(()=>{Be?.onDesktopUpdateState&&Be.onDesktopUpdateState(mt)},[Be]),b.useEffect(()=>Yr.subscribe(S=>{const P=e3(S.sessions);An(ue=>d$(ue,P)?ue:P)}),[]);const on=b.useCallback(async(S,P)=>{Gr(null),Ir({sessionId:S,status:"submitting",error:null});try{await y9(P),Ir(ue=>ue?.sessionId===S?{...ue,status:"waiting",error:null}:ue)}catch(ue){const St=(ue&&typeof ue=="object"&&"code"in ue?String(ue.code??""):"")==="AGENT_SESSION_ACTIVE_ELSEWHERE"?e("tab.resumeAgentConflict"):ue instanceof Error&&/busy/i.test(ue.message)?e("tab.resumeAgentBusy"):e("tab.resumeAgentFailed");Ir(Kt=>Kt?.sessionId===S?{...Kt,error:St}:Kt),Gr({tone:"error",message:St})}},[e]);b.useEffect(()=>{if(!un||un.status!=="waiting")return;const S=sr.get(un.sessionId);if(!S||S.agentResumeRecovered||S.agentStatus===null&&!S.agent)return;const P=S.agent?.displayName??"Agent";Ir(null),Gr({tone:"success",message:e("tab.resumeAgentSuccess",{agent:P})})},[un,sr,e]),b.useEffect(()=>{if(!un||un.status!=="waiting"||un.error)return;const S=un.sessionId,P=window.setTimeout(()=>{const ue=e("tab.resumeAgentTimeout");Ir(tt=>tt?.sessionId===S&&tt.status==="waiting"?{...tt,error:ue}:tt),Gr({tone:"error",message:ue})},15e3);return()=>window.clearTimeout(P)},[un,e]),b.useEffect(()=>{if(me?.tone!=="success")return;const S=window.setTimeout(()=>Gr(null),3200);return()=>window.clearTimeout(S)},[me]),b.useEffect(()=>{let S=!1;v9().then(ue=>{S||je(ue)}).catch(()=>{}),w9().then(ue=>{S||Ee(ue)}).catch(()=>{});const P=Kg(ue=>{S||(ue.type==="update-state"?je(ue.state):ue.type==="server-health"&&Ee(ue.state))});return()=>{S=!0,P()}},[]);const Me=b.useCallback(async()=>{try{Ee(await A9())}catch(S){window.alert(S instanceof Error?S.message:String(S))}},[]),nt=b.useCallback(async()=>{const S=_e?.latestVersion;if(!(!S||re)&&window.confirm(e("sidebar.updateRestartConfirm",{version:S}))){Pe(!0);try{je(await T9())}catch(P){window.alert(P instanceof Error?P.message:String(P))}finally{Pe(!1)}}},[_e?.latestVersion,e,re]),wt=b.useCallback(async()=>{if(!re){Pe(!0);try{je(await C9())}catch(S){window.alert(S instanceof Error?S.message:String(S))}finally{Pe(!1)}}},[re]),Mr=b.useCallback(async()=>{if(!(!Be?.checkDesktopUpdate||de)){Ye(!0);try{mt(await Be.checkDesktopUpdate())}catch(S){Ie(S instanceof Error?S.message:String(S))}finally{Ye(!1)}}},[Be,de]),rn=b.useCallback(async()=>{if(!(!Be?.installDesktopUpdate||de||rt?.status!=="ready")&&window.confirm(e("settings.desktopUpdateRestartConfirm"))){Ye(!0);try{mt(await Be.installDesktopUpdate())}catch(S){Ie(S instanceof Error?S.message:String(S))}finally{Ye(!1)}}},[Be,de,rt?.status,e]);b.useEffect(()=>{document.documentElement.dataset.theme=p,S9(p),Un(Wb,p)},[p]),b.useEffect(()=>{Un(Gb,Sm(H))},[H]);const Er=Gt(S=>S.leftOpen),ne=Gt(S=>S.rightOpen),ht=Gt(S=>S.leftPinned),zt=Gt(S=>S.leftSidebarWidth),Pt=Gt(S=>S.rightPinned),Cr=Gt(S=>S.rightSidebarWidth),gr=Gt(S=>S.rootPath),Hr=Gt(S=>S.contextKey),En=Gt(S=>S.selectedFilePath),dr=Gt(S=>S.groupByFolder),Tn=Xh(S=>S.collaborationGroups),hn=Gt(S=>S.collapsedGroups),Sn=Gt(S=>S.toggleGroupCollapsed),[ir,mn]=b.useState(()=>typeof window>"u"?!0:window.matchMedia("(min-width: 1024px)").matches),[Qr,Vr]=b.useState(()=>typeof window>"u"?1024:window.innerWidth),[Wr,fs]=b.useState(()=>typeof window>"u"?!1:window.matchMedia("(orientation: landscape)").matches),[Dr,Pn]=b.useState([]),[Sr,Kr]=b.useState({available:!0,version:null,reason:null}),[nn,Or]=b.useState(!1),[ks,Pr]=b.useState(null),[Xr,fn]=b.useState(null),[K,Ue]=b.useState(null),[Et,kt]=b.useState(null),[tr,Br]=b.useState(null),[cr,_n]=b.useState(null),[Ls,Zn]=b.useState(null),[,sn]=b.useState(0),[ln,kr]=b.useState(null),[$r,Gn]=b.useState(null),[Vn,dn]=b.useState(null),[Kn,Lr]=b.useState(!1),[Nr,xr]=b.useState(()=>fc(B0,S=>typeof S=="boolean")??!1),os=b.useCallback(async S=>{const P=Nr;xr(S),Un(B0,S);try{const ue=await wa({runningSessionButtonEnabled:S});xr(ue.runningSessionButtonEnabled),Un(B0,ue.runningSessionButtonEnabled)}catch{xr(P),Un(B0,P)}},[Nr]),[Hn,Nn]=b.useState(()=>fc(Q0,S=>typeof S=="boolean")??!0),Rn=b.useCallback(async S=>{const P=Hn;Nn(S),Un(Q0,S);try{const ue=await wa({attentionButtonEnabled:S});Nn(ue.attentionButtonEnabled),Un(Q0,ue.attentionButtonEnabled)}catch{Nn(P),Un(Q0,P)}},[Hn]),[ps,G]=b.useState(null),Le=b.useCallback(S=>{G(S)},[]),Ke=b.useRef(!1),[ct,qe]=b.useState(null),[At,Rt]=b.useState(null),Dt=_.useRef(null),ot=_.useRef(!1),Ot=_.useRef(null),hr=_.useRef(!1),Zt=b.useCallback(()=>{_n(null),Zn(null)},[]),z=_.useRef(typeof window>"u"?null:new URLSearchParams(window.location.search).get("session")),[N,$]=_.useState(z.current),[ee,se]=_.useState(!0),Qe=_.useRef(z.current),ze=_.useRef(typeof window>"u"?null:new URLSearchParams(window.location.search).get("_notifTrace"));b.useEffect(()=>{if(typeof window>"u")return;const S=window.matchMedia("(min-width: 1024px)"),P=()=>{mn(S.matches),Vr(window.innerWidth)};return P(),S.addEventListener("change",P),window.addEventListener("resize",P),()=>{S.removeEventListener("change",P),window.removeEventListener("resize",P)}},[]),b.useEffect(()=>{if(typeof window>"u")return;const S=window.matchMedia("(orientation: landscape)"),P=()=>fs(S.matches);return P(),S.addEventListener("change",P),()=>S.removeEventListener("change",P)},[]);const xt=_.useMemo(()=>yt?it.find(S=>S.sessionIds.includes(yt))??null:null,[yt,it]),_t=xt?.id??null,Fr=xt?.sessionIds[0]??yt,jt=_.useRef([]);_.useLayoutEffect(()=>{const S=jt.current;if(jt.current=it,S.length===0)return;const P=new Set(it.flatMap(ue=>ue.sessionIds));for(const ue of S){const tt=ue.sessionIds.filter(St=>!P.has(St)).map(St=>({sessionId:St,rootPath:Yr.getState().sessions.get(St)?.cwd??null}));tt.length>0&&Gt.getState().inheritRightSidebarStateFromSplitWorkspace(ue.id,tt)}},[it]),_.useLayoutEffect(()=>((()=>{const P=Fr?Yr.getState().sessions.get(Fr)?.cwd??null:null;Gt.getState().setRootPath(P,Fr,_t)})(),Yr.subscribe((P,ue)=>{const tt=Fr?P.sessions.get(Fr)?.cwd??null:null,St=Fr?ue.sessions.get(Fr)?.cwd??null:null;tt!==St&&Gt.getState().setRootPath(tt,Fr,_t)})),[_t,Fr]);const qr=ir||Wr,pn=Qr*.95,Xn=qr?Math.min(Math.max(Qr*.22,280),340):Math.min(Qr*.86,380),vn=yt&&gr?`${yt}\0${gr}`:"",kn=!!(vn&&En&&H[vn]),ar=b.useCallback(S=>{vn&&(S&&!Gt.getState().selectedFilePath||ae(P=>{if(!!P[vn]===S)return P;if(S)return Sm({...P,[vn]:{updatedAt:Date.now()}});const tt={...P};return delete tt[vn],tt}))},[vn]);b.useEffect(()=>{kB(vn,Hr,En)&&ae(S=>{if(!S[vn])return S;const P={...S};return delete P[vn],P})},[vn,Hr,En]);const cn=Ut?"markdown-image-lightbox":vt?"markdown-outline":Je?"right-sidebar-repo-picker":ne&&kn?"right-sidebar-file-preview":et?"settings":ne&&!(Pt&&ir)?"right-sidebar":Er&&!(ht&&ir)?"left-sidebar":null,an=_.useRef(cn),Hs=_.useRef(cn),Is=_.useRef(!1),Ks=_.useRef(!1),Po=b.useCallback(()=>{if(typeof window>"u")return;const S=window.matchMedia("(hover: hover) and (pointer: fine)").matches;!ir||!S||navigator.maxTouchPoints>0||window.setTimeout(()=>{window.dispatchEvent(new CustomEvent("focus-active-terminal-session"))},0)},[ir]),Aa=b.useCallback(S=>{if(S==="markdown-image-lightbox"){Lt(!1),Ge(P=>P+1);return}if(S==="markdown-outline"){Yt(!1),Xt(P=>P+1);return}if(S==="right-sidebar-file-preview"){Yt(!1),Xt(P=>P+1),ar(!1),Ze(P=>P+1);return}if(S==="right-sidebar-repo-picker"){Tt(!1),Mt(P=>P+1);return}if(S==="settings"){Ct(!1),zi(!1),js(!1),$a(!1);return}if(S==="left-sidebar"){Gt.getState().closeLeft();return}Yt(!1),Xt(P=>P+1),Tt(!1),Mt(P=>P+1),Lt(!1),Ge(P=>P+1),Gt.getState().closeRight()},[ar]),Ln=b.useCallback(S=>{if(!c&&typeof window<"u"&&an.current===S&&du(window.history.state)===S){window.history.back();return}Aa(S)},[Aa,c]),ia=b.useCallback(()=>{Ct(!1);const S=Gt.getState();S.closeRight(),S.openLeft()},[]),fo=b.useCallback(()=>{Ct(!1);const S=Gt.getState();S.closeLeft(),S.openRight()},[]),Ba=b.useCallback(()=>{Ct(!1);const S=Gt.getState();S.closeLeft(),S.openRight(),S.setRightTab("files"),S.openRightSearch()},[]),Ei=b.useCallback(()=>{const S=Gt.getState();if(S.leftPinned){S.setLeftPinned(!1),S.closeLeft();return}if(Er){Ln("left-sidebar");return}ia()},[ia,Ln,Er]),ws=b.useCallback(()=>{const S=Gt.getState();S.leftPinned?(S.setLeftPinned(!1),S.openLeft()):(S.setLeftPinned(!0),S.openLeft())},[]),Qa=b.useCallback(()=>{const S=Gt.getState();S.setLeftPinned(!1),S.closeLeft()},[]),Es=b.useCallback(()=>{const S=Gt.getState();S.rightPinned?(S.setRightPinned(!1),S.openRight()):(S.setRightPinned(!0),S.openRight())},[]),po=b.useCallback(()=>{const S=Gt.getState();S.setRightPinned(!1),S.closeRight()},[]),Ws=b.useRef(0),Xs=b.useRef(0),ms=b.useRef(null),mo=b.useCallback(S=>{S.preventDefault(),Ws.current=S.clientX,Xs.current=Gt.getState().leftSidebarWidth;const P=tt=>{ms.current===null&&(ms.current=requestAnimationFrame(()=>{ms.current=null;const St=tt.clientX-Ws.current;Gt.getState().setLeftSidebarWidth(Xs.current+St)}))},ue=()=>{window.removeEventListener("mousemove",P),window.removeEventListener("mouseup",ue),ms.current!==null&&(cancelAnimationFrame(ms.current),ms.current=null),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",P),window.addEventListener("mouseup",ue)},[]),Ns=b.useRef(0),Oo=b.useRef(0),aa=b.useRef(null),go=b.useCallback(S=>{S.preventDefault(),Ns.current=S.clientX;const P=Gt.getState(),ue=P.leftPinned?P.leftSidebarWidth:0;Oo.current=Ih(P.rightSidebarWidth,window.innerWidth,ue);const tt=Kt=>{aa.current===null&&(aa.current=requestAnimationFrame(()=>{aa.current=null;const wr=Ns.current-Kt.clientX,xn=Gt.getState(),Dn=xn.leftPinned?xn.leftSidebarWidth:0;xn.setRightSidebarWidth(Ih(Oo.current+wr,window.innerWidth,Dn))}))},St=()=>{window.removeEventListener("mousemove",tt),window.removeEventListener("mouseup",St),aa.current!==null&&(cancelAnimationFrame(aa.current),aa.current=null),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",tt),window.addEventListener("mouseup",St)},[]),On=b.useCallback(()=>{const S=Gt.getState();if(S.rightPinned){S.setRightPinned(!1),S.closeRight();return}if(ne){Ln("right-sidebar");return}fo()},[fo,Ln,ne]),Ni=b.useCallback(()=>{!kn&&!c&&typeof window<"u"&&an.current==="right-sidebar"&&du(window.history.state)==="right-sidebar"&&(P0("right-sidebar-file-preview"),Hs.current="right-sidebar-file-preview"),ar(!0)},[kn,c,ar]),Ri=b.useCallback(()=>{Ln("right-sidebar-file-preview")},[Ln]),Pa=b.useCallback(()=>{!Je&&!c&&typeof window<"u"&&an.current==="right-sidebar"&&du(window.history.state)==="right-sidebar"&&(P0("right-sidebar-repo-picker"),Hs.current="right-sidebar-repo-picker"),Tt(!0)},[Je,c]),mi=b.useCallback(()=>{Ln("right-sidebar-repo-picker")},[Ln]),dl=b.useCallback(()=>{!vt&&!c&&typeof window<"u"&&an.current&&du(window.history.state)===an.current&&(P0("markdown-outline"),Hs.current="markdown-outline"),Yt(!0)},[vt,c]),Js=b.useCallback(()=>{Ln("markdown-outline")},[Ln]),Fo=b.useCallback(()=>{!c&&typeof window<"u"&&an.current&&du(window.history.state)===an.current&&(P0("markdown-image-lightbox"),Hs.current="markdown-image-lightbox"),Lt(!0)},[c]),oa=b.useCallback(()=>{Ln("markdown-image-lightbox")},[Ln]),xo=b.useCallback(()=>{!c&&typeof window<"u"&&an.current&&du(window.history.state)===an.current&&(u$("settings"),Hs.current="settings"),Gt.getState().closeAll(),Ct(!0)},[c]),Ta=b.useCallback(()=>{Ln("settings")},[Ln]);b.useEffect(()=>{if(!Be)return;const S=()=>xo();return window.addEventListener("termdock:open-settings",S),()=>window.removeEventListener("termdock:open-settings",S)},[Be,xo]);const ls=b.useCallback(()=>{Te(!0),ft.current!==null&&(window.clearTimeout(ft.current),ft.current=null)},[]),gi=b.useCallback(()=>{ft.current!==null&&(window.clearTimeout(ft.current),ft.current=null),Te(!1),Ks.current=!0,kh(),Ks.current},[]);b.useEffect(()=>()=>{ft.current!==null&&window.clearTimeout(ft.current)},[]),b.useEffect(()=>{c||kh()},[c]),b.useEffect(()=>{if(typeof window>"u"||c)return;let S=null;const P=()=>{S!==null&&(window.clearTimeout(S),S=null)},ue=xn=>{if(an.current,Ks.current,an.current){an.current;return}!xn?.force&&Ks.current||(xn?.userActivated&&(Ks.current=!0),kh(),Ks.current,void 0)},tt=()=>{P(),S=window.setTimeout(()=>{S=null,ue({force:!0})},Kb)},St=()=>{ue({userActivated:!0})},Kt=()=>{tt()},wr=()=>{document.visibilityState==="visible"&&tt()};return window.addEventListener("pointerdown",St,{capture:!0,passive:!0}),window.addEventListener("touchstart",St,{capture:!0,passive:!0}),window.addEventListener("keydown",St,{capture:!0}),window.addEventListener("pageshow",Kt),document.addEventListener("visibilitychange",wr),()=>{P(),window.removeEventListener("pointerdown",St,{capture:!0}),window.removeEventListener("touchstart",St,{capture:!0}),window.removeEventListener("keydown",St,{capture:!0}),window.removeEventListener("pageshow",Kt),document.removeEventListener("visibilitychange",wr)}},[c]),b.useEffect(()=>{an.current=cn},[cn]),b.useEffect(()=>{if(typeof window>"u"||cn||c)return;const S=window.setTimeout(()=>{an.current?(an.current,void 0):kh()},Kb);return()=>window.clearTimeout(S)},[cn,c]),b.useEffect(()=>{if(typeof window>"u"||c)return;const S=Hs.current;Is.current,cn&&cn!==S&&!Is.current&&P0(cn),!cn&&S&&Po(),Hs.current=cn,!cn&&Is.current&&window.setTimeout(()=>{Is.current=!1},0)},[cn,c,Po]),b.useEffect(()=>{if(typeof window>"u"||c)return;const S=()=>{const P=an.current;if(Ks.current,!P){Ks.current=!1,Ks.current,ls(),D6();return}Is.current=!0,Aa(P)};return window.addEventListener("popstate",S),()=>window.removeEventListener("popstate",S)},[Aa,ls,c]),b.useEffect(()=>{const S=P=>{const ue=P.metaKey||P.ctrlKey;if(ue&&P.key==="b"&&!P.shiftKey&&(P.preventDefault(),Ei()),ue&&P.shiftKey&&P.key==="E"&&(P.preventDefault(),On()),ue&&P.shiftKey&&P.key==="P"&&(P.preventDefault(),Ba()),ue&&!P.shiftKey&&P.altKey&&(P.key==="ArrowLeft"||P.key==="ArrowRight")){P.preventDefault();const tt=P.key==="ArrowRight"?"next":"prev";window.dispatchEvent(new CustomEvent("cycle-terminal-session",{detail:{direction:tt}}));return}if(ue&&P.shiftKey&&!P.altKey&&(P.code==="BracketLeft"||P.code==="BracketRight")){P.preventDefault();const tt=P.code==="BracketRight"?"next":"prev";window.dispatchEvent(new CustomEvent("cycle-terminal-session",{detail:{direction:tt}}));return}};return document.addEventListener("keydown",S),()=>{document.removeEventListener("keydown",S)}},[Ei,On,Ba]);const bo=b.useCallback(async()=>{Y(!0),lt(null);try{const S=await wa({localAccess:{name:te}});fe(S.localAccess),ke(S.localAccess.name),Un(D0,{preventSleep:S.preventSleep,networkAvailable:S.networkAvailable,localAccess:S.localAccess})}catch(S){lt(S instanceof Error?S.message:"Failed to save local access name")}finally{Y(!1)}},[te]),hl=b.useCallback(async()=>{Y(!0),lt(null);try{const S=await wa({localAccess:{reset:!0}});fe(S.localAccess),ke(S.localAccess.name),Un(D0,{preventSleep:S.preventSleep,networkAvailable:S.networkAvailable,localAccess:S.localAccess})}catch(S){lt(S instanceof Error?S.message:"Failed to reset local access name")}finally{Y(!1)}},[]),$o=b.useCallback(async(S,P="url")=>{if(S)try{if(typeof navigator<"u"&&navigator.clipboard)await navigator.clipboard.writeText(S);else{const ue=document.createElement("textarea");ue.value=S,ue.style.position="fixed",ue.style.left="-9999px",document.body.appendChild(ue),ue.focus(),ue.select(),document.execCommand("copy"),document.body.removeChild(ue)}ye(P),window.setTimeout(()=>ye(ue=>ue===P?null:ue),1600)}catch{ye(null)}},[]),gs=b.useCallback(S=>{const P=h$(gt,S);P.map(ue=>ue.id).join("\0")!==gt.map(ue=>ue.id).join("\0")&&(bt(P),window.dispatchEvent(new CustomEvent("reorder-terminal-session",{detail:{sessionIds:P.map(ue=>ue.id)}})))},[gt]),la=b.useCallback(S=>{ir||S.type!=="session"||(Ke.current=!1,Lr(!1),dn(S.draggableId))},[ir]),Nl=b.useCallback(S=>{if(ir||S.type!=="session")return;const P=S.destination?.droppableId===A1;P!==Ke.current&&(Ke.current=P,Lr(P),P&&navigator.vibrate?.(20))},[ir]),Jn=b.useCallback(S=>{const P=ZF(S,!ir);if(Ke.current=!1,Lr(!1),dn(null),!P)return!1;const ue=gt.find(St=>St.id===S.draggableId),tt=ue?sr.get(ue.id):null;return ue&&C5({mode:ue.mode,activeProgram:tt?.activeProgram??null,promptState:tt?.promptState??null,shellNames:ya})?(Rt(null),qe(ue.id),Ue(null)):ue&&window.dispatchEvent(new CustomEvent("close-terminal-session",{detail:{sessionId:ue.id,source:"other",closeMode:ue.mode==="tmux"?"destroy":"auto"}})),!0},[ir,gt,sr]),{groups:xi,arranged:ss}=_.useMemo(()=>Kh(gt,S=>sr.get(S.id)?.cwd??null,dr,e("sidebar.ungrouped"),it,Tn),[gt,sr,dr,e,it,Tn]),Oa=b.useCallback(S=>{Jn(S)||!S.destination||S.source.index===S.destination.index||window.dispatchEvent(new CustomEvent("reorder-navigation-session",{detail:{sourceId:ss[S.source.index]?.id,targetId:ss[S.destination.index]?.id}}))},[Jn,ss]),ys=b.useCallback((S,P)=>{const ue=P.trim();ue&&window.dispatchEvent(new CustomEvent("rename-terminal-session",{detail:{sessionId:S,name:ue}}))},[]),Uo=b.useCallback(S=>{window.dispatchEvent(new CustomEvent("reset-terminal-session-name",{detail:{sessionId:S}}))},[]),{newSessionMode:Gs,newSessionTmuxName:Ui,userSelectedNewSessionMode:ca,setNewSessionMode:jn}=CB(),[bi,Mi]=b.useState(null),[Ca,zi]=_.useState(!1),[yi,ei]=_.useState(!1),[Rs,js]=_.useState(!1),[ti,Fa]=_.useState("idle"),ji=_.useRef(fc(_h,t$)).current,[es,ua]=_.useState(()=>{const S=ji?.presets;if(S&&S.length>0){const P=yu(S);if(P.length>0)return P}return ud()}),[yo,Sa]=_.useState(!1),[zo,Ho]=_.useState("default"),Hi=_.useRef(typeof ji?.updatedAt=="number"?ji.updatedAt:null),vo=_.useRef(!1),[da,$a]=_.useState(!1),[wo,ha]=_.useState(!1),As=_.useRef(fc(ba,e$)).current,[Di,xs]=_.useState(As??[]),[Rl,ce]=_.useState(As!==null),[T,j]=_.useState(!1),Q=!It&&!cn&&!yi&&!Rs&&!Ca&&!da&&!wo&&!cr&&!ct&&!bi,O=_.useCallback(S=>{const P=typeof S.version=="number"?S.version:0,ue=r$(Array.isArray(S.presets)?S.presets:[],P);Hi.current=typeof S.updatedAt=="number"?S.updatedAt:null,ua(tt=>_9(tt,ue)?tt:(vo.current=!0,ue)),Un(_h,{version:$0,presets:ue,updatedAt:Hi.current??void 0})},[]);b.useEffect(()=>{const S=P=>{if(P.key!=="Escape"||P.defaultPrevented||P.isComposing||S1())return;if(yi){P.preventDefault(),ei(!1);return}if(Rs){P.preventDefault(),js(!1);return}if(Ca){P.preventDefault(),zi(!1);return}if(da){P.preventDefault(),$a(!1);return}if(wo){P.preventDefault(),ha(!1);return}if(cr){P.preventDefault(),Zt();return}if(ln){P.preventDefault(),Br(null),kr(null);return}if(et){P.preventDefault(),Ta();return}if(ne&&!(Pt&&ir)){P.preventDefault(),Ln("right-sidebar");return}Er&&!(ht&&ir)&&(P.preventDefault(),Ln("left-sidebar"))};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[yi,Rs,Ca,da,cr,Zt,et,ne,Pt,Er,ht,ir,Ta,Ln]),b.useEffect(()=>{ce(!0)},[]);const[ge,ve]=_.useState({genericProgramNames:[],wrapperScriptNames:[],shellNames:B6}),[,Oe]=_.useState(!1),Xe=_.useCallback(()=>k9().then(S=>{ve(S),ya=new Set(S.shellNames),Oe(!0)}).catch(()=>{}),[]);b.useEffect(()=>{Xe()},[Xe]),b.useEffect(()=>Kg(S=>{if(S.type==="config-updated"){if(S.key==="toolbar-presets"){Xg().then(P=>O(P)).catch(P=>{console.warn("[toolbar-presets] Failed to refresh after remote update:",P)});return}S.key==="program-detection"&&Xe()}}),[O,Xe]),b.useEffect(()=>{let S=!1;return(async()=>{try{const P=await Xg();if(S)return;O(P)}catch(P){console.warn("[toolbar-presets] Failed to load from server:",P)}finally{S||Sa(!0)}})(),()=>{S=!0}},[O]),b.useEffect(()=>{if(yo){if(vo.current){vo.current=!1;return}Un(_h,{version:$0,presets:es,updatedAt:Hi.current??void 0}),L9({version:$0,presets:es,baseUpdatedAt:Hi.current??void 0}).then(S=>{Hi.current=typeof S.updatedAt=="number"?S.updatedAt:null,Un(_h,{version:$0,presets:es,updatedAt:Hi.current??void 0})}).catch(S=>{const P=S instanceof Error&&"current"in S?S.current:null;P&&typeof P=="object"&&O(P),console.warn("[toolbar-presets] Failed to save to server:",S)})}},[O,es,yo]),b.useEffect(()=>{nc().then(S=>{w(P=>P===S.preventSleep?P:S.preventSleep),k(P=>P===S.networkAvailable?P:S.networkAvailable),fe(S.localAccess),ke(S.localAccess.name),xr(S.runningSessionButtonEnabled),Un(B0,S.runningSessionButtonEnabled),Nn(S.attentionButtonEnabled),Un(Q0,S.attentionButtonEnabled),Un(D0,{preventSleep:S.preventSleep,networkAvailable:S.networkAvailable,localAccess:S.localAccess})}).catch(()=>{})},[]),b.useEffect(()=>{if(!L)return;const S=hp();le(S),S!=="granted"&&(E(!1),Wd(!1))},[L]),b.useEffect(()=>{if(!L)return;t0();const S=()=>{document.visibilityState==="visible"&&(t0(),$9())},P=window.setInterval(()=>{t0()},360*60*1e3);return document.addEventListener("visibilitychange",S),window.addEventListener("focus",S),()=>{window.clearInterval(P),document.removeEventListener("visibilitychange",S),window.removeEventListener("focus",S)}},[L]);const pt=b.useCallback(async()=>{if(L){E(!1),Wd(!1),I9(),le(hp());return}const S=await E9();if(le(S),S!=="granted"){E(!1),Wd(!1);return}E(!0),Wd(!0),await t0(!0,!0),Fa("idle")},[L]),Jt=b.useCallback(async()=>{Fa("checking"),await lo()?.prepareNotificationTest?.();const S=await N9({title:"Termdock",body:e("settings.notificationsTestBody"),tag:"termdock-notification-test",requireHidden:!1,data:{url:"/"}});Fa(S?"delivered":"failed")},[e]),fr=b.useCallback(S=>{B(S),R9(S),fp()},[]),Ur=b.useCallback(S=>{F(S),M9(S),fp()},[]),Jr=b.useCallback(S=>{V(S),j9(S),fp()},[]);b.useEffect(()=>{es.some(S=>S.id===zo)||Ho(es[0]?.id??"default")},[zo,es]),b.useEffect(()=>{if(!Sr.available&&Gs==="tmux"){jn("shell",{userInitiated:!1});return}Sr.available&&ca!=="shell"&&Gs!=="tmux"&&jn("tmux",{userInitiated:!1})},[Gs,Sr.available,ca,jn]),b.useEffect(()=>{Mi(null)},[et,Gs,Sr.available]),b.useEffect(()=>{const S={};typeof navigator<"u"&&(S.userAgent=navigator.userAgent,S.platform=navigator.platform,S.maxTouchPoints=navigator.maxTouchPoints,S.hasTouch=navigator.maxTouchPoints>0||"ontouchstart"in window,S.vendor=navigator.vendor),typeof window<"u"&&(S.screenWidth=window.innerWidth,S.screenHeight=window.innerHeight,S.pixelRatio=window.devicePixelRatio,S.orientation=window.screen?.orientation?.type||"unknown",S.hasVisualViewport=!!window.visualViewport,S.visualViewportHeight=window.visualViewport?.height,S.visualViewportWidth=window.visualViewport?.width,S.location=window.location.href),S.timestamp=new Date().toISOString(),S.isIOS=/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1,S.isAndroid=/Android/.test(navigator.userAgent),at(S)},[]);const Fn=b.useCallback(S=>{if(Jn(S)||!S.destination)return;if(S.type==="group"){if(S.source.index===S.destination.index)return;gs(I3(xi,S.source.index,S.destination.index));return}if(S.source.droppableId!==S.destination.droppableId||S.source.index===S.destination.index)return;const P=S.source.droppableId.replace(/^group-sessions:/,""),ue=xi.find(tt=>tt.key===P);ue&&window.dispatchEvent(new CustomEvent("reorder-navigation-session",{detail:{sourceId:ue.sessions[S.source.index]?.id,targetId:ue.sessions[S.destination.index]?.id}}))},[xi,gs,Jn]),mr=_.useMemo(()=>ss.flatMap(S=>{const P=sr.get(S.id);if(P?.agentStatus!=="working")return[];const{primary:ue,secondary:tt}=sl(S,P?.activeProgram??null,P?.cwd??null,ya,P?.shellTitle??null,P?.promptState??null);return[{id:S.id,label:ue,detail:tt}]}),[ss,sr]),gn=yt?ss.findIndex(S=>S.id===yt):-1,cs=ss.length>0&&gn>=0?`${gn+1}/${ss.length}`:`${ss.length}`,is=_.useMemo(()=>{let S=0;for(const P of gt){const ue=sr.get(P.id);(ue?.agentStatus==="waiting"||ue?.agentNeedsReview)&&(S+=1)}return{running:mr.length,review:S}},[mr.length,gt,sr]),Hu=_.useMemo(()=>ss.flatMap(S=>{const P=sr.get(S.id);if(P?.agentStatus!=="waiting"&&!P?.agentNeedsReview)return[];const{primary:ue}=sl(S,P.activeProgram,P.cwd,ya,P.shellTitle,P.promptState);return[{id:P.terminalSessionId??S.id,label:ue,waiting:P.agentStatus==="waiting"}]}),[ss,sr]);D9(is.running,is.review,Hu);const ts=yt?gt.find(S=>S.id===yt)??null:null,Ua=ts?sr.get(ts.id):void 0,Ao=!!(ts&&Ua?.agentResumeRecovered&&Ua.agentNativeSessionId&&Ua.terminalSessionId),Vs=ts&&un?.sessionId===ts.id?un:null;_.useLayoutEffect(()=>{if(!ee)return;const S=Ot.current;if(!S)return;const P=!hr.current;S.scrollIntoView({inline:"nearest",block:"nearest",behavior:P?"auto":"smooth"}),hr.current=!0,P&&vu("active-tab-positioned")},[yt,ee]),b.useEffect(()=>{tr&&Dt.current&&(Dt.current.scrollIntoView({block:"nearest",inline:"nearest"}),Dt.current.focus(),Dt.current.select()),tr||(ot.current=!1)},[tr]);const sc=b.useCallback(S=>{window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:S}))},[]),Ml=b.useCallback((S,P)=>{Zn(P??null),_n(S)},[]),ic=Xv(),za=b.useCallback(S=>{if(!S)return;$(S),ze.current&&va("info","PWA_NOTIFICATION_CLICK app-focus-request",{traceId:ze.current,requestedSessionId:S,activeSessionId:yt,sessions:gt.map(ue=>({id:ue.id,terminalSessionId:sr.get(ue.id)?.terminalSessionId??null}))}),B9(S);const P=gt.find(ue=>ue.id===S||sr.get(ue.id)?.terminalSessionId===S);P?(Qe.current=null,ze.current&&va("info","PWA_NOTIFICATION_CLICK app-focus-dispatch",{traceId:ze.current,requestedSessionId:S,targetSessionId:P.id}),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:P.id}))):(Qe.current=S,ze.current&&va("info","PWA_NOTIFICATION_CLICK app-focus-pending",{traceId:ze.current,requestedSessionId:S}))},[yt,gt,sr]);b.useEffect(()=>{if(typeof window>"u"||typeof caches>"u")return;let S=!1;const P=async()=>{if(window.parent!==window&&ol()){se(!0);return}try{const tt=await caches.open(a$),St=await tt.match(Xb);if(!St)return;await tt.delete(Xb);const Kt=await St.json();if(S)return;const wr=typeof Kt.sessionId=="string"?Kt.sessionId:null,xn=typeof Kt.traceId=="string"?Kt.traceId:null,Dn=typeof Kt.clickedAt=="number"?Kt.clickedAt:0,Mn=Date.now()-Dn;va("info","PWA_NOTIFICATION_CLICK app-cache-consumed",{traceId:xn,sessionId:wr,ageMs:Mn,valid:!!(wr&&Mn>=0&&Mn<=Jb),visibilityState:document.visibilityState}),wr&&Mn>=0&&Mn<=Jb&&(ze.current=xn,typeof Kt.targetPeerId=="string"&&Kt.targetPeerId!==r0()?.targetPeerId?ol()?.focusSession(Kt.targetPeerId,wr):za(wr))}catch(tt){va("warn","PWA_NOTIFICATION_CLICK app-cache-failed",{error:tt instanceof Error?tt.message:String(tt)})}finally{S||se(!0)}},ue=()=>{document.visibilityState==="visible"&&P()};return P(),document.addEventListener("visibilitychange",ue),window.addEventListener("pageshow",P),()=>{S=!0,document.removeEventListener("visibilitychange",ue),window.removeEventListener("pageshow",P)}},[za]),b.useEffect(()=>{if(typeof window>"u")return;const S=new URLSearchParams(window.location.search),P=S.get("session");if(!P)return;va("info","PWA_NOTIFICATION_CLICK app-url-received",{traceId:ze.current,targetSessionId:P,href:window.location.href,visibilityState:document.visibilityState});const ue=S.get("service");ue&&ue!==r0()?.targetPeerId?ol()?.focusSession(ue,P):Qe.current=P,S.delete("service"),S.delete("session"),S.delete("_notifTrace");const tt=S.toString(),St=`${window.location.pathname}${tt?`?${tt}`:""}${window.location.hash}`;window.history.replaceState(window.history.state,"",St)},[]),b.useEffect(()=>{if(typeof window>"u")return;const S=new URLSearchParams(window.location.search);if(S.get("_notif")!=="1")return;const P=S.get("session");S.delete("_notif");const ue=S.toString(),tt=`${window.location.pathname}${ue?`?${ue}`:""}${window.location.hash}`;if(window.history.replaceState(window.history.state,"",tt),window.parent!==window&&ol())return;const St=new BroadcastChannel("termdock:notif");let Kt=!1;const wr=Dn=>{Dn.data?.type==="termdock:notif-pong"&&!Kt&&(Kt=!0,St.close(),window.close())};St.addEventListener("message",wr),St.postMessage({type:"termdock:notif-ping",sessionId:P,targetPeerId:S.get("service")});const xn=setTimeout(()=>{Kt||St.close()},500);return()=>{clearTimeout(xn),Kt||St.close()}},[]),b.useEffect(()=>{if(typeof window>"u"||window.parent!==window&&ol())return;const S=new BroadcastChannel("termdock:notif"),P=ue=>{ue.data?.type==="termdock:notif-ping"&&(S.postMessage({type:"termdock:notif-pong"}),typeof ue.data.sessionId=="string"&&(typeof ue.data.targetPeerId=="string"&&ue.data.targetPeerId!==r0()?.targetPeerId?ol()?.focusSession(ue.data.targetPeerId,ue.data.sessionId):za(ue.data.sessionId)))};return S.addEventListener("message",P),()=>S.close()},[za]),b.useEffect(()=>{if(typeof navigator>"u"||!("serviceWorker"in navigator))return;const S=P=>{const ue=P.data;if(ue&&ue.type==="termdock:focus-session"&&typeof ue.sessionId=="string"){if(typeof ue.targetPeerId=="string"&&ue.targetPeerId!==r0()?.targetPeerId){ol()?.focusSession(ue.targetPeerId,ue.sessionId)&&P.ports[0]?.postMessage({type:"termdock:focus-session-ack"});return}P.ports[0]?.postMessage({type:"termdock:focus-session-ack"}),za(ue.sessionId)}else ue?.type==="termdock:push-subscription-changed"?t0(!0):ue?.type};return navigator.serviceWorker.addEventListener("message",S),()=>navigator.serviceWorker.removeEventListener("message",S)},[za]),b.useEffect(()=>{const S=P=>{const ue=P.detail;typeof ue=="string"&&za(ue)};return window.addEventListener("termdock:focus-session",S),()=>window.removeEventListener("termdock:focus-session",S)},[za]),b.useEffect(()=>{const S=()=>{const P=U9(r0()?.targetPeerId);P&&za(P)};return S(),window.addEventListener("termdock:workspace-session",S),()=>window.removeEventListener("termdock:workspace-session",S)},[za]),b.useEffect(()=>{const S=Qe.current;if(!S)return;const P=gt.find(ue=>ue.id===S||sr.get(ue.id)?.terminalSessionId===S);P?(Qe.current=null,ze.current&&va("info","PWA_NOTIFICATION_CLICK app-pending-dispatch",{traceId:ze.current,requestedSessionId:S,targetSessionId:P.id,activeSessionId:yt}),window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:P.id}))):ze.current&&va("info","PWA_NOTIFICATION_CLICK app-pending-unmatched",{traceId:ze.current,requestedSessionId:S,activeSessionId:yt,sessions:gt.map(ue=>({id:ue.id,terminalSessionId:sr.get(ue.id)?.terminalSessionId??null}))})},[yt,gt,sr]);const us=_.useMemo(()=>{const S=[];for(const P of gt){const ue=sr.get(P.id);(ue?.agentStatus==="waiting"||ue?.agentNeedsReview)&&S.push(P.id)}return S},[gt,sr]),Wo=b.useCallback(()=>{if(us.length===0)return;yt&&Yr.getState().clearAgentNeedsReview(yt);const S=yt?gt.findIndex(ue=>ue.id===yt):-1,P=us.find(ue=>gt.findIndex(tt=>tt.id===ue)>S)??us[0];P&&window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:P}))},[us,gt,yt]),$c=b.useCallback(()=>{if(us.length===0)return;yt&&Yr.getState().clearAgentNeedsReview(yt);const S=yt?gt.findIndex(ue=>ue.id===yt):gt.length,P=[...us].reverse().find(ue=>gt.findIndex(tt=>tt.id===ue)<S)??us[us.length-1];P&&window.dispatchEvent(new CustomEvent("switch-terminal-session",{detail:P}))},[us,gt,yt]);b.useEffect(()=>{const S=P=>{!P.altKey||!P.shiftKey||P.metaKey||P.ctrlKey||P.key!=="ArrowUp"&&P.key!=="ArrowDown"||(P.preventDefault(),P.key==="ArrowUp"?$c():Wo())};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[Wo,$c]);const Nd=b.useCallback(async S=>{const ue=Yr.getState().sessions.get(S)?.cwd;if(ue)try{await navigator.clipboard?.writeText(ue),Gn(ue),window.setTimeout(()=>{Gn(tt=>tt===ue?null:tt)},1400)}catch{}},[]),qf=b.useCallback(S=>{bt(S.sessions),pr(S.activeSessionId),dt(S.splitWorkspaces),Yr.getState().setActiveSessionId(S.activeSessionId)},[]),Yf=b.useCallback(()=>{_r(!0)},[]),Zf=b.useCallback(()=>{_r(!0),window.requestAnimationFrame(()=>{window.dispatchEvent(new Event("termdock:initial-viewport-presented"))})},[]);b.useEffect(()=>{if(!N||!yt)return;gt.find(P=>P.id===N||sr.get(P.id)?.terminalSessionId===N)?.id===yt&&$(null)},[yt,N,gt,sr]);const Wu=b.useRef(!1),[Uc,Rd]=b.useState(!1),To=b.useCallback(S=>{const P=!S?.onResult;if(P&&Wu.current)return;P&&(Wu.current=!0,Rd(!0));const ue=S?.mode??Gs,tt=ue==="tmux"&&(S?.tmuxSessionName?.trim()||Ui.trim())||void 0,St=S?.cwd||(yt?Yr.getState().sessions.get(yt)?.cwd:void 0);window.dispatchEvent(new CustomEvent("new-terminal-session",{detail:{mode:ue,tmuxSessionName:tt,cwd:St,command:S?.command,shouldActivate:S?.shouldActivate,onResult:S?.onResult??(Kt=>{Wu.current=!1,Rd(!1),Kt.ok||Gr({tone:"error",message:e(Rm(Kt.error))})})}}))},[Gs,Ui,yt,e]),fl=b.useCallback(async()=>{Or(!0);try{const S=await _m();if(Kr(S),!S.available){Pn([]);return}const P=await km();Pn(P)}catch{Kr({available:!1,version:null,reason:"tmux integration is unavailable with the current server build."}),Pn([])}finally{Or(!1)}},[]),zc=b.useCallback(async S=>{const{cleanedSessions:P}=await a3(S);for(const ue of P)window.dispatchEvent(new CustomEvent("close-terminal-session-by-backend",{detail:ue}));await fl()},[fl]),Gu=b.useCallback(async S=>{fn(S),Ue(null);try{await zc(S),Pr(null)}catch(P){Ue(P instanceof Error?P.message:"Failed to kill tmux session")}finally{fn(null)}},[zc]);b.useEffect(()=>{if(!Et)return;if(Dr.find(ue=>ue.name===Et&&(ue.connected||ue.boundFrontendSessionId))){kt(null);return}const P=setTimeout(()=>kt(null),1e4);return()=>clearTimeout(P)},[Et,Dr]);const jl=b.useCallback(S=>{window.dispatchEvent(new CustomEvent("close-terminal-session",{detail:S}))},[]),Vu=b.useCallback(S=>{const P=S??yt;P&&window.dispatchEvent(new CustomEvent("open-terminal-split-chooser",{detail:P}))},[yt]),ac=b.useCallback((S,P)=>{window.dispatchEvent(new CustomEvent("set-terminal-split-direction",{detail:{sessionId:S,layout:P}}))},[]),Md=b.useCallback((S,P)=>{window.dispatchEvent(new CustomEvent("reorder-terminal-split-workspace",{detail:{workspaceId:S,sessionIds:P}}))},[]),Hc=b.useCallback((S,P)=>{window.dispatchEvent(new CustomEvent("rename-terminal-split-workspace",{detail:{workspaceId:S,name:P}}))},[]),qu=b.useCallback((S,P)=>{window.dispatchEvent(new CustomEvent("combine-terminal-split-sessions",{detail:{primaryId:S,secondaryId:P}}))},[]),oc=b.useCallback((S,P,ue)=>{const tt=gt.find(Kt=>Kt.id===S);if(!tt)return;const St=sr.get(S);if(ue?.skipConfirmation||!C5({mode:tt.mode,activeProgram:St?.activeProgram??null,promptState:St?.promptState??null,shellNames:ya})){jl({sessionId:S,source:"sidebar",closeMode:tt.mode==="tmux"?"destroy":"auto"});return}Rt(P?{x:P.clientX,y:P.clientY}:null),qe(S),Ue(null)},[gt,sr,jl]);b.useEffect(()=>{if(!Be)return;const S=P=>{const ue=P.detail;ue==="new-session"?To():ue==="close-session"?yt&&oc(yt):ue==="previous-session"||ue==="next-session"?window.dispatchEvent(new CustomEvent("cycle-terminal-session",{detail:{direction:ue==="next-session"?"next":"prev"}})):ue==="toggle-left-sidebar"?Ei():ue==="toggle-right-sidebar"?On():ue==="previous-attention"?$c():ue==="next-attention"&&Wo()};return window.addEventListener("termdock:native-command",S),()=>window.removeEventListener("termdock:native-command",S)},[yt,Be,To,oc,Ei,On,Wo,$c]);const Ha=_.useMemo(()=>gt.find(S=>S.id===ct)??null,[gt,ct]),Yu=b.useCallback(()=>{Ha&&(jl({sessionId:Ha.id,source:"sidebar",closeMode:"destroy"}),qe(null),Rt(null))},[Ha,jl]);b.useEffect(()=>{if(!Ha)return;const S=P=>{if(P.key==="Escape"){P.preventDefault(),P.stopImmediatePropagation(),qe(null),Rt(null),Ue(null);return}P.key!=="Enter"||P.isComposing||P.keyCode===229||P.altKey||P.ctrlKey||P.metaKey||P.shiftKey||(P.preventDefault(),P.stopImmediatePropagation(),P.repeat||Yu())};return window.addEventListener("keydown",S,!0),()=>window.removeEventListener("keydown",S,!0)},[Ha,Yu]);const jd=_.useMemo(()=>{if(!Ha)return"";const S=sr.get(Ha.id);return sl(Ha,S?.activeProgram??null,S?.cwd??null,ya,S?.shellTitle??null,S?.promptState??null).primary},[Ha,sr]);b.useEffect(()=>{if(!et)return;let S=!1,P=!1;const ue=async()=>{if(!P)try{const St=await _m();if(S||Kr(St),!St.available){S||Pn([]);return}const Kt=await km();S||Pn(Kt)}catch{P=!0,S||(Kr({available:!1,version:null,reason:"tmux integration is unavailable with the current server build."}),Pn([]))}};ue();const tt=setInterval(()=>{ue()},4e3);return()=>{S=!0,clearInterval(tt)}},[et]);const Dd=bi??Gs,Zu=Dd==="shell",Wc=Dd==="tmux"&&Sr.available,Gc=_.useMemo(()=>L3(Dr.map(S=>({...S,id:S.name})),S=>S.cwd??null,e("sidebar.ungrouped")),[Dr,e]),lc=_.useMemo(()=>Dr.filter(S=>S.recoveryCandidate===!0&&!S.connected&&!S.boundFrontendSessionId).sort((S,P)=>(P.lastActiveAt??P.createdAt??0)-(S.lastActiveAt??S.createdAt??0)),[Dr]);b.useEffect(()=>{!Er&&!(ht&&ir)||fl()},[Er,ht,ir,gt.length,fl]);const Vc=(S,P,ue,tt=!1)=>{const St=S.id===yt,Kt=S.id===tr,wr=sr.get(S.id),{primary:xn,secondary:Dn}=sl(S,wr?.activeProgram??null,wr?.cwd??null,ya,wr?.shellTitle??null,wr?.promptState??null),Mn=Pu(wr?.cwd??null),vi=P?Dn??(Mn&&Mn!==xn?Mn:null):null,wn=wr?.gitStatus,Bi=`${wr?.cwd||S.name}${wn?`
179
179
  ⎇ ${wn.branch} +${wn.added} −${wn.removed}`:""}`,Wa=!!(wr?.tuiProgress&&wr.tuiProgress.state!=="remove"),Co=wr?.agentStatus==="working"||Wa?"var(--success)":wr?.agentStatus==="waiting"||wr?.agentNeedsReview?"var(--warning)":wr?.inCopyMode?"var(--tmux)":null;if(Kt&&ir&&!ln){const ka=S.customName?S.name:xn,Qi=(Ga,Jf)=>{const Xu=Jf.trim();Xu?Xu!==ka&&ys(Ga,Xu):Uo(Ga),Br(null)};return s.jsx("input",{ref:Ga=>{Dt.current=Ga},type:"text",defaultValue:ka,className:"h-8 shrink-0 rounded-md bg-surface-elevated px-2 text-[12px] leading-none text-foreground outline-none ring-1 ring-primary/50 sm:h-8 min-w-[5rem]",style:{width:`${Math.max(ka.length,5)}ch`},onKeyDown:Ga=>{Ga.key==="Enter"?Qi(S.id,Ga.target.value):Ga.key==="Escape"&&Br(null)},onBlur:Ga=>Qi(S.id,Ga.target.value)})}return s.jsx("div",{ref:St?Ot:null,onContextMenu:ka=>{ka.preventDefault(),Zn({x:ka.clientX,y:ka.clientY}),_n(S.id)},...ic(()=>Ml(S.id)),className:tt?`group relative inline-flex h-5 shrink-0 items-center rounded-sm text-[11px] leading-none transition ${St?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:bg-surface-elevated/40 hover:text-foreground"}`:`group relative inline-flex h-8 shrink-0 items-center rounded-md text-[12px] leading-none transition sm:h-8 ${St?"bg-surface-elevated text-foreground shadow-sm":"text-muted-foreground hover:bg-surface-elevated/50 hover:text-foreground"}`,style:!tt&&St&&Co?{boxShadow:`inset 2px 0 0 0 ${Co}`}:!tt&&St?{boxShadow:"inset 2px 0 0 0 rgb(var(--primary-rgb, 99 102 241))"}:void 0,title:Bi,children:s.jsx("button",{type:"button",...ue??{},onClick:()=>sc(S.id),className:`inline-flex min-w-0 flex-1 items-center gap-1 overflow-hidden text-left ${tt?"px-1":"py-1 pl-1 pr-1.5 sm:pl-1.5 sm:pr-2"} ${ue?"cursor-grab active:cursor-grabbing":""}`,title:Bi,children:s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 overflow-hidden",children:[s.jsxs("span",{className:"inline-flex shrink-0 items-center",children:[t3(S.mode,wr),wr?.agentResumeRecovered&&s.jsx(Sc,{size:tt?9:10,className:"-ml-0.5 shrink-0 text-[color:var(--warning)]","aria-label":e("tab.resumeAgentAvailable")}),Wa&&!wr?.agentStatus&&s.jsx(In,{size:tt?9:10,className:"-ml-0.5 shrink-0 animate-spin text-[color:var(--success)]"})]}),vi?s.jsxs("span",{className:"flex min-w-0 flex-col justify-center leading-[0.82rem] sm:leading-[0.85rem]",children:[s.jsx("span",{className:`whitespace-nowrap text-[11px] sm:text-[12px] ${wr?.inCopyMode?"text-[color:var(--tmux)]":""}`,children:xn}),s.jsx("span",{className:"truncate text-[9px] text-muted-foreground/80 sm:text-[9.5px]",children:vi})]}):s.jsx("span",{className:`whitespace-nowrap text-[11px] sm:text-[12px] ${wr?.inCopyMode?"text-[color:var(--tmux)]":""}`,children:xn})]})})})},Go=()=>s.jsx(Sl,{droppableId:A1,type:"session",isDropDisabled:ir,children:(S,P)=>{const ue=Kn||P.isDraggingOver;return s.jsxs("div",{ref:S.innerRef,...S.droppableProps,className:"pointer-events-none fixed left-1/2 top-[42%] z-toast flex h-32 w-32 -translate-x-1/2 -translate-y-1/2 items-center justify-center",role:"status","aria-live":"polite","aria-hidden":!Vn,"data-mobile-session-destroy-target":"","data-active":ue?"true":"false",children:[s.jsxs("div",{className:`flex h-28 w-28 flex-col items-center justify-center gap-2 rounded-full border bg-surface-elevated/95 shadow-2xl backdrop-blur transition duration-200 ${Vn?ue?"scale-110 border-destructive bg-destructive text-destructive-foreground opacity-100":"scale-100 border-destructive/50 text-destructive opacity-100":"scale-75 border-transparent opacity-0"}`,children:[s.jsx(zs,{size:28,strokeWidth:1.8}),s.jsx("span",{className:"px-2 text-center text-[11px] font-semibold leading-tight",children:e(ue?"tab.releaseToClose":"tab.dragToClose")})]}),S.placeholder]})}}),Wi=ht&&ir,pl=Pt&&ir,qc=Ih(Cr,Qr,Wi?zt:0),cc=pl?qc+i3:0,ml=Wi?gt.find(S=>S.id===yt):null,Ds=ml?sr.get(ml.id):void 0,Kf=ml?sl(ml,Ds?.activeProgram??null,Ds?.cwd??null,ya,Ds?.shellTitle??null,Ds?.promptState??null).primary:"",Bd=ir?xt:null,Xf=Wi&&!Bd&&Ds?Ds.agentStatus==="working"?"bg-gradient-to-r from-[rgb(var(--success-rgb)_/_0.08)] to-transparent":Ds.agentStatus==="waiting"?"bg-gradient-to-r from-[rgb(var(--warning-rgb)_/_0.14)] to-transparent":Ds.agentNeedsReview?"bg-gradient-to-r from-[rgb(var(--warning-rgb)_/_0.08)] to-transparent":Ds.inCopyMode?"bg-gradient-to-r from-[rgb(var(--tmux-rgb)_/_0.07)] to-transparent":"":"",Ku=s.jsxs("div",{className:"w-full h-full flex flex-col app-chrome-bg text-foreground",children:[s.jsx("main",{className:"relative min-h-0 flex-1 overflow-visible px-0 pb-0 pt-0",children:s.jsxs(EC,{rightInset:cc,workspace:It&&s.jsx(_.Suspense,{fallback:s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-[var(--chrome-bg)] text-sm text-muted-foreground",children:"正在打开协作工作区…"}),children:s.jsx(f$,{groupId:It,activeSessionId:yt,defaultSessionMode:Gs,onOpenSidebar:Ei,leftSidebarVisible:Er||Wi,onToggleRightSidebar:On,rightSidebarOpen:ne||pl},It)}),children:[s.jsxs("div",{className:`${ir?"absolute inset-x-0 top-0 z-20":"relative"} shrink-0 items-center gap-1 app-chrome-bg px-1 sm:px-1.5 transition-colors duration-500 ${Wi?"flex justify-end":"flex justify-between"} ${dr?"h-10 sm:h-10":"h-9 sm:h-10"} ${Xf}`,style:{position:ir?"absolute":void 0,marginRight:cc||void 0,display:Bd?"none":void 0},children:[!Wi&&s.jsxs("button",{type:"button",onClick:Ei,className:"relative inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground ring-1 ring-border/10 transition hover:bg-surface-elevated hover:text-foreground sm:h-8 sm:w-8","aria-label":e("tab.sessionsTitle"),title:`${e("tab.sessionsTitle")} · ${e("agent.aiRunning")}: ${is.running} · ${e("agent.needsReview")}: ${is.review}`,children:[s.jsx(ST,{size:14}),s.jsx(gP,{runningCount:is.running,reviewCount:is.review,className:"sm:hidden"})]}),Wi?s.jsx("div",{className:"absolute left-1/2 flex max-w-[40%] min-w-0 -translate-x-1/2 items-center justify-center gap-1.5 overflow-hidden",children:ml?s.jsxs(s.Fragment,{children:[t3(ml.mode,Ds),s.jsx("span",{className:`truncate text-[12px] font-medium ${Ds?.inCopyMode?"text-[color:var(--tmux)]":"text-foreground"}`,children:Kf}),Ds?.agentStatus==="working"&&s.jsx("span",{title:Ds?.agentMessage??void 0,children:s.jsx(In,{size:12,className:"shrink-0 animate-spin text-[color:var(--success)]"})}),Ds?.agentStatus==="waiting"&&s.jsx("span",{title:Ds?.agentMessage??void 0,children:s.jsx(Yh,{size:12,className:"shrink-0 animate-bounce-y text-[color:var(--warning)]"})}),!Ds?.agentStatus&&Ds?.agentNeedsReview&&s.jsx("span",{title:Ds?.agentMessage??void 0,children:s.jsx(Jl,{size:13,className:"shrink-0 animate-pulse text-[color:var(--warning)]"})})]}):s.jsx("span",{className:"truncate px-2 text-[12px] text-muted-foreground",children:e("sidebar.sessions")})}):dr?s.jsxs(td,{onDragStart:la,onDragUpdate:Nl,onDragEnd:Fn,children:[Go(),s.jsx(Sl,{droppableId:"groups",type:"group",direction:"horizontal",children:S=>s.jsxs("div",{ref:S.innerRef,...S.droppableProps,className:"scrollbar-hidden flex h-full min-w-0 flex-1 items-center gap-1 overflow-x-auto overflow-y-hidden whitespace-nowrap px-0.5 py-0.5",style:{touchAction:"pan-x"},children:[xi.map((P,ue)=>{let tt=0,St=0;for(const Dn of P.sessions){const Mn=sr.get(Dn.id);Mn?.agentStatus==="working"&&(tt+=1),(Mn?.agentStatus==="waiting"||Mn?.agentNeedsReview)&&(St+=1)}const Kt=P.sessions.some(Dn=>Dn.id===yt),wr=hn.has(P.key),xn=P.key==="";return s.jsx(Cl,{draggableId:`group-${P.key||"__ungrouped__"}`,index:ue,isDragDisabled:xn,disableInteractiveElementBlocking:!0,children:(Dn,Mn)=>s.jsxs("div",{ref:Dn.innerRef,...Dn.draggableProps,className:`flex w-fit shrink-0 flex-col justify-center gap-px rounded-md py-0.5 px-1 ring-1 transition-colors ${Mn.isDragging?"bg-surface-elevated ring-primary/30 shadow-lg opacity-90":Kt?"bg-primary/[0.06] ring-primary/20":"bg-surface-2/40 ring-border/10"}`,children:[s.jsxs("button",{type:"button",...xn?{}:Dn.dragHandleProps,onClick:()=>Sn(P.key),className:`flex ${wr?"":P.sessions.length>1?"w-0 min-w-full":""} items-center gap-0.5 rounded text-[9px] font-semibold uppercase tracking-[0.08em] leading-none transition hover:bg-surface-elevated/40 ${xn?"":"cursor-grab active:cursor-grabbing"} ${Kt?"text-primary/80":"text-muted-foreground/55"}`,title:P.key||P.label,children:[s.jsx(hi,{size:9,className:`shrink-0 opacity-70 transition-transform ${wr?"":"rotate-90"}`}),s.jsx("span",{className:"min-w-0 truncate",children:P.label}),tt>0&&s.jsx("span",{className:"ml-auto h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--success)]"}),St>0&&s.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--warning)] ${tt>0?"":"ml-auto"}`})]}),wr?s.jsx("span",{className:"flex h-5 items-center text-[10px] leading-none text-muted-foreground/50",children:e("tab.sessionCount",{count:P.sessions.length})}):s.jsx(Sl,{droppableId:`group-sessions:${P.key}`,type:"session",direction:"horizontal",children:vi=>s.jsxs("div",{ref:vi.innerRef,...vi.droppableProps,className:"flex items-center gap-px",children:[P.sessions.map((wn,Bi)=>s.jsx(Cl,{draggableId:wn.id,index:Bi,disableInteractiveElementBlocking:!0,children:(Wa,Co)=>s.jsx("div",{ref:Wa.innerRef,...Wa.draggableProps,className:`flex shrink-0 items-center ${Co.isDragging?"opacity-70":""}`,children:Vc(wn,!1,Wa.dragHandleProps,!0)})},wn.id)),vi.placeholder]})})]})},P.key||"__ungrouped__")}),S.placeholder,s.jsx("button",{type:"button",onClick:()=>To(),disabled:Uc,"aria-busy":Uc,className:"my-auto inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-surface-2 text-muted-foreground ring-1 ring-border/10 transition hover:bg-primary/15 hover:text-primary active:scale-95","aria-label":e("tab.new"),title:e("tab.new"),children:s.jsx(Us,{size:14})})]})})]}):s.jsxs(td,{onDragStart:la,onDragUpdate:Nl,onDragEnd:Oa,children:[Go(),s.jsx(Sl,{droppableId:"tabs",type:"session",direction:"horizontal",children:S=>s.jsxs("div",{ref:S.innerRef,...S.droppableProps,className:"scrollbar-hidden flex h-full min-w-0 flex-1 items-center gap-1 overflow-x-auto overflow-y-hidden whitespace-nowrap",style:{touchAction:"pan-x"},children:[ss.map((P,ue)=>P.id===tr?s.jsx(_.Fragment,{children:s.jsx(Cl,{draggableId:P.id,index:ue,isDragDisabled:!0,children:St=>s.jsx("div",{ref:St.innerRef,...St.draggableProps,className:"flex h-full items-center",children:Vc(P,!0)})})},P.id):s.jsx(_.Fragment,{children:s.jsx(Cl,{draggableId:P.id,index:ue,disableInteractiveElementBlocking:!0,children:(St,Kt)=>s.jsx("div",{ref:St.innerRef,...St.draggableProps,className:`flex h-full shrink-0 items-center ${Kt.isDragging?"opacity-70":""}`,children:Vc(P,!0,St.dragHandleProps)})})},P.id)),s.jsx("button",{type:"button",onClick:()=>To(),disabled:Uc,"aria-busy":Uc,className:"ml-1 inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground ring-1 ring-border/10 transition hover:bg-primary/15 hover:text-primary active:scale-95","aria-label":e("tab.new"),title:e("tab.new"),children:s.jsx(Us,{size:14})}),S.placeholder]})})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[!Wi&&is.running>0&&s.jsx("span",{className:"hidden items-center gap-1 sm:inline-flex",children:s.jsx(g6,{count:is.running,tone:"running",title:e("agent.aiRunning")})}),!Wi&&gt.length>0&&s.jsx("span",{className:"inline-flex shrink-0 items-center px-1 text-[10px] uppercase tracking-[0.16em] text-muted-foreground sm:text-[11px]",title:`Session ${gn+1} of ${gt.length}`,children:cs}),!pl&&s.jsx("button",{type:"button",onClick:On,className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface-2 text-muted-foreground ring-1 ring-border/10 transition hover:bg-surface-elevated hover:text-foreground sm:h-8 sm:w-8","aria-label":e("tab.explorerTitle"),title:e("tab.explorerTitle"),children:s.jsx(T3,{size:14})})]})]}),Ao&&ts&&Ua?.terminalSessionId&&s.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border/15 bg-surface/80 px-3 py-2 animate-fade-in sm:px-4",style:{marginRight:cc||void 0},role:"status","data-testid":"agent-resume-recovery-banner",children:[s.jsx("span",{className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-[rgb(var(--warning-rgb)_/_0.14)] text-[color:var(--warning)]",children:!Vs?.error&&(Vs?.status==="submitting"||Vs?.status==="waiting")?s.jsx(In,{size:14,className:"animate-spin"}):s.jsx(Sc,{size:14})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate text-[12px] font-medium text-foreground",children:e("tab.resumeAgentRecoveredTitle",{agent:Ua.agent?.displayName??"Agent"})}),s.jsx("div",{className:`truncate text-[10px] sm:text-[11px] ${Vs?.error?"text-destructive":"text-muted-foreground"}`,children:Vs?.error??(Vs?.status==="submitting"?e("tab.resumeAgentSubmitting"):Vs?.status==="waiting"?e("tab.resumeAgentWaiting"):e("tab.resumeAgentRecoveredHint"))})]}),s.jsx("button",{type:"button",disabled:!Vs?.error&&(Vs?.status==="submitting"||Vs?.status==="waiting"),onClick:()=>{on(ts.id,Ua.terminalSessionId)},className:"shrink-0 rounded-full bg-primary px-3 py-1.5 text-[11px] font-semibold text-primary-foreground transition hover:opacity-90 active:scale-95 disabled:cursor-wait disabled:opacity-60 sm:text-[12px]",children:Vs?.error?e("common.retry"):e("tab.resumeAgentNow")}),s.jsx("button",{type:"button",onClick:()=>{Yr.getState().setAgentResumeRecovered(ts.id,!1),Ir(S=>S?.sessionId===ts.id?null:S)},className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-muted-foreground transition hover:bg-surface-2 hover:text-foreground","aria-label":e("tab.resumeAgentLater"),title:e("tab.resumeAgentLater"),children:s.jsx(Qn,{size:13})})]}),s.jsx("div",{ref:Le,className:"min-h-0 flex-1 flex overflow-hidden app-chrome-bg",children:s.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:s.jsx(tN,{terminalSettings:Vt,colorTheme:p,toolbarPresets:es,showDebug:l&&ir,terminalFocusAvailable:Q,defaultSessionMode:Gs,defaultTmuxSessionName:Ui,connectionPrioritySessionId:N,connectionPriorityReady:ee,desktopRightSidebarEnabled:ir,onToggleRightSidebar:On,desktopFloatingTitle:ir,desktopPinnedLeftSidebarWidth:Wi?zt:0,desktopViewportWidth:Qr,onSessionDataUpdate:qf,onInitialViewportReady:Zf,onInitialRecoveryRequired:Yf})})})]})}),!It&&s.jsx(wP,{reviewCount:is.review,runningSessions:mr,activeSessionId:yt,runningButtonEnabled:Nr,attentionButtonEnabled:Hn,isDesktopLayout:ir,containerElement:ps,occlusionInsets:{right:cc}}),et&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-drawer-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm animate-fade-in cursor-default",onClick:Ta,"aria-label":e("settings.closeSettings")}),s.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"settings-dialog-title",className:"pointer-events-none fixed inset-0 z-drawer-panel flex items-stretch justify-center p-0 animate-fade-in sm:p-4 md:p-6",children:s.jsxs("div",{className:"pointer-events-auto flex h-full w-full max-w-5xl flex-col overflow-hidden bg-surface shadow-[0_28px_90px_var(--app-shadow-strong),0_14px_34px_var(--app-shadow-soft)] sm:max-h-[calc(100dvh-3rem)] sm:rounded-3xl sm:border sm:border-border/15",style:{paddingTop:n,paddingBottom:a},children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 border-b border-border/15 px-4 py-3 sm:px-6 sm:py-4",children:[s.jsxs("div",{className:"min-w-0 flex items-center gap-2",children:[s.jsx("span",{className:"inline-flex h-8 w-8 items-center justify-center rounded-full bg-primary/15 text-primary sm:h-9 sm:w-9",children:s.jsx(Nm,{size:15})}),s.jsx("h2",{id:"settings-dialog-title",className:"text-[15px] font-semibold text-foreground sm:text-[16px]",children:e("settings.title")})]}),s.jsx("button",{type:"button",onClick:Ta,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","aria-label":e("common.close"),children:s.jsx(Qn,{size:16})})]}),s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto bg-background/25 px-3 py-3 sm:px-6 sm:py-5 md:px-8",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 rounded-xl bg-surface-2 px-2.5 py-2",children:[s.jsx("span",{className:"text-[12px] font-medium text-foreground/90 w-14 shrink-0",children:e("settings.font")}),s.jsx("button",{type:"button",onClick:()=>Ve({fontSize:Math.max(8,De-1)}),className:"h-8 w-8 shrink-0 rounded-md bg-surface text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:"−"}),s.jsx("input",{type:"range",min:"8",max:"32",value:De,onChange:S=>Ve({fontSize:parseInt(S.target.value,10)}),className:"min-w-0 flex-1","aria-label":e("settings.font")}),s.jsx("button",{type:"button",onClick:()=>Ve({fontSize:Math.min(32,De+1)}),className:"h-8 w-8 shrink-0 rounded-md bg-surface text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",children:"+"}),s.jsxs("span",{className:"w-8 shrink-0 text-right text-[11px] tabular-nums text-muted-foreground",children:[De,"px"]})]}),s.jsx(YF,{}),s.jsx("div",{className:"space-y-1.5 rounded-xl bg-surface-2 px-2.5 py-2",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[12px] font-medium text-foreground/90 w-14 shrink-0",children:e("settings.render")}),s.jsx("div",{className:"flex flex-1 items-center gap-1 rounded-md bg-surface p-0.5",children:["auto","webgl","canvas"].map(S=>{const P=er===S;return s.jsx("button",{type:"button",onClick:()=>Ve({rendererMode:S}),className:`flex-1 rounded px-2 py-1 text-[11px] font-medium transition ${P?"bg-primary/20 text-primary":"text-muted-foreground hover:bg-surface-elevated"}`,children:e(S==="auto"?"settings.auto":S==="webgl"?"settings.webgl":"settings.canvas")},S)})})]})}),s.jsx("div",{className:"space-y-1.5 rounded-xl bg-surface-2 px-2.5 py-2",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[12px] font-medium text-foreground/90 w-14 shrink-0",children:e("settings.theme")}),s.jsx("div",{className:"flex flex-1 items-center gap-1 rounded-md bg-surface p-0.5",children:[["dark",xT,e("settings.darkTheme")],["light",lC,e("settings.lightTheme")]].map(([S,P,ue])=>{const tt=p===S;return s.jsxs("button",{type:"button",onClick:()=>m(S),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 text-[11px] font-medium transition ${tt?"bg-primary/20 text-primary":"text-muted-foreground hover:bg-surface-elevated"}`,children:[s.jsx(P,{size:12}),s.jsx("span",{children:ue})]},S)})})]})}),s.jsxs("div",{className:"flex items-center gap-2 rounded-xl bg-surface-2 px-2.5 py-2",children:[s.jsx("span",{className:"text-[12px] font-medium text-foreground/90 w-14 shrink-0",children:e("settings.newTab")}),s.jsx("div",{className:"flex flex-1 items-center gap-1 rounded-md bg-surface p-0.5",children:["shell","tmux"].map(S=>{const P=Gs===S,ue=S==="tmux"&&!Sr.available;return s.jsx("button",{type:"button",disabled:ue,onClick:()=>jn(S,{userInitiated:!0}),className:`flex-1 rounded px-2 py-1 text-[11px] font-medium transition ${P?"bg-primary/20 text-primary":ue?"cursor-not-allowed text-muted-foreground/40":"text-muted-foreground hover:bg-surface-elevated"}`,title:ue?Sr.reason||e("settings.installTmuxHint"):void 0,children:e(S==="shell"?"settings.shell":"settings.tmux")},S)})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>h(!l),className:`flex items-center justify-between rounded-xl px-3 py-2 text-[12px] transition ${l?"bg-primary/15 text-primary":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,children:[s.jsx("span",{className:"font-medium",children:e("settings.debug")}),s.jsx(ll,{checked:l,size:"sm"})]}),s.jsxs("button",{type:"button",onClick:async()=>{const S=!y;w(S);try{const P=await wa({preventSleep:S});w(P.preventSleep),k(P.networkAvailable),fe(P.localAccess),Un(D0,{preventSleep:P.preventSleep,networkAvailable:P.networkAvailable,localAccess:P.localAccess})}catch{w(!S)}},className:`flex items-center justify-between rounded-xl px-3 py-2 text-[12px] transition ${y?"bg-[rgb(var(--success-rgb)_/_0.15)] text-[color:var(--success)]":"bg-surface-2 text-foreground hover:bg-surface-elevated"}`,title:!v&&y?e("settings.noSleepUnavailable"):void 0,children:[s.jsx("span",{className:"font-medium truncate",children:e("settings.noSleep")}),s.jsx(ll,{checked:y,size:"sm"})]})]})]}),s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsxs("button",{type:"button",role:"switch","aria-checked":Nr,"aria-label":e("sidebar.runningSessionButton"),onClick:()=>{os(!Nr)},className:"flex w-full items-center gap-2 rounded-xl bg-surface-2 px-3 py-2.5 text-left text-[13px] transition hover:bg-surface-elevated",children:[s.jsx(Zh,{size:14,className:Nr?"shrink-0 text-[color:var(--success)]":"shrink-0 text-muted-foreground"}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium text-foreground",children:e("sidebar.runningSessionButton")}),s.jsx("span",{className:"mt-0.5 block text-[10px] leading-tight text-muted-foreground",children:e("sidebar.runningSessionButtonHint")})]}),s.jsx(ll,{checked:Nr,size:"sm"})]}),s.jsxs("button",{type:"button",role:"switch","aria-checked":Hn,"aria-label":e("sidebar.attentionButton"),onClick:()=>{Rn(!Hn)},className:"flex w-full items-center gap-2 rounded-xl bg-surface-2 px-3 py-2.5 text-left text-[13px] transition hover:bg-surface-elevated",children:[s.jsx(Jl,{size:14,className:Hn?"shrink-0 text-[color:var(--warning)]":"shrink-0 text-muted-foreground"}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium text-foreground",children:e("sidebar.attentionButton")}),s.jsx("span",{className:"mt-0.5 block text-[10px] leading-tight text-muted-foreground",children:e("sidebar.attentionButtonHint")})]}),s.jsx(ll,{checked:Hn,size:"sm"})]})]}),s.jsxs("button",{type:"button",onClick:()=>js(!0),className:"mt-3 flex w-full items-center justify-between gap-2 rounded-xl bg-surface-2 px-3 py-2.5 text-left text-[13px] transition hover:bg-surface-elevated",children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(x3,{size:14,className:L?"shrink-0 text-primary":"shrink-0 text-muted-foreground"}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block font-medium text-foreground",children:e("settings.notifications")}),s.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:e(L?R&&W?"settings.notificationsBothOnSummary":R?"settings.notificationsAiOnSummary":W?"settings.notificationsExitOnSummary":"settings.notificationsNoEventsSummary":"settings.notificationsOffSummary")})]})]}),s.jsxs("span",{className:"flex shrink-0 items-center gap-1.5 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:e(L?"common.on":"common.off")}),s.jsx("span",{children:"›"})]})]}),s.jsxs("button",{type:"button",onClick:()=>ei(!0),className:"mt-3 flex w-full items-center justify-between gap-3 rounded-xl bg-surface-2 px-3 py-3 text-left transition hover:bg-surface-elevated",children:[s.jsxs("span",{children:[s.jsx("span",{className:"block text-[12px] font-medium text-foreground/90",children:e("settings.localAccess")}),s.jsx("span",{className:"mt-0.5 block text-[10px] text-muted-foreground",children:e("settings.localAccessHint")})]}),s.jsx(hi,{size:16,className:"shrink-0 text-muted-foreground"})]}),s.jsx(UF,{state:_e,pending:re,onCheck:()=>{wt()},onConfirmRestart:()=>{nt()},desktopState:Ne?rt:void 0,desktopPending:de,onCheckDesktop:Ne?()=>{Mr()}:void 0,onInstallDesktop:()=>{rn()},desktopSnapshot:oe,desktopActions:Be?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-1 gap-px border-t border-border/10 bg-border/10 sm:grid-cols-2",children:[s.jsxs("button",{type:"button",onClick:()=>{Be.showConnectionCenter()},className:"flex items-center gap-2 bg-surface-2 px-3 py-2.5 text-left text-[11px] text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",children:[s.jsx(xA,{size:13,className:"shrink-0 text-primary"}),e("settings.desktopSwitchService")]}),s.jsxs("button",{type:"button",onClick:()=>{Ie(null),Be.revealDataDirectory().catch(S=>Ie(S instanceof Error?S.message:String(S)))},className:"flex items-center gap-2 bg-surface-2 px-3 py-2.5 text-left text-[11px] text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",children:[s.jsx(wu,{size:13,className:"shrink-0 text-primary"}),e("settings.desktopOpenDataDirectory")]})]}),st&&s.jsx("div",{className:"border-t border-border/10 px-3 py-2 text-[10px] text-muted-foreground",children:st})]}):void 0}),s.jsx(HF,{backendSessionId:yt?sr.get(yt)?.terminalSessionId??null:null}),s.jsx(GF,{state:Se,onDismiss:()=>{Me()}}),s.jsxs("div",{className:"mt-3 flex gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>{Mi(null),To({mode:"shell"}),Ta()},className:`flex min-w-0 items-center justify-center gap-1.5 rounded-xl text-[13px] font-semibold transition active:scale-[0.98] ${Zu?"flex-[2.7] bg-primary px-3 py-2.5 text-primary-foreground ring-1 ring-primary/40 shadow-md shadow-primary/25 hover:bg-primary/90":"flex-[0.78] bg-surface-2 px-2 py-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,title:e(bi==="shell"?"sidebar.confirmNewShell":"settings.shell"),children:[s.jsx(Us,{size:14,className:Zu?"shrink-0":"hidden"}),s.jsx(Bo,{size:12}),s.jsx("span",{className:Zu?"whitespace-nowrap":"hidden",children:e(bi==="shell"?"sidebar.confirmNewShell":"settings.shell")})]}),s.jsxs("button",{type:"button",disabled:!Sr.available,onClick:()=>{Sr.available&&(Mi(null),To({mode:"tmux"}),Ta())},className:`flex min-w-0 items-center justify-center gap-1.5 rounded-xl text-[13px] font-semibold transition active:scale-[0.98] ${Sr.available?Wc?"flex-[2.7] bg-primary px-3 py-2.5 text-primary-foreground ring-1 ring-primary/40 shadow-md shadow-primary/25 hover:bg-primary/90":"flex-[0.78] bg-surface-2 px-2 py-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground":"flex-1 bg-surface-2/50 text-muted-foreground/50 cursor-not-allowed"}`,title:Sr.available?e(bi==="tmux"?"sidebar.confirmNewTmux":"settings.tmux"):Sr.reason||e("settings.installTmuxHint"),children:[s.jsx(Us,{size:14,className:Wc?"shrink-0":"hidden"}),s.jsx(Nu,{size:12}),s.jsx("span",{className:Wc?"whitespace-nowrap":"hidden",children:e(bi==="tmux"?"sidebar.confirmNewTmux":"settings.tmux")})]})]}),(Sr.available||Dr.length>0)&&s.jsxs("details",{className:"mt-3 group rounded-xl bg-surface-2 [&[open]]:bg-surface-2",children:[s.jsxs("summary",{className:"flex cursor-pointer items-center justify-between rounded-xl px-3 py-2.5 text-[13px] hover:bg-surface-elevated",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`inline-flex h-2 w-2 rounded-full ${Sr.available?"bg-primary":"bg-destructive"}`}),s.jsx("span",{className:"font-medium",children:e("settings.tmuxServer")}),s.jsx("span",{className:"text-[11px] text-muted-foreground",children:Sr.available?e("settings.sessions",{n:Dr.length}):e("settings.tmuxUnavailable")})]}),s.jsx("button",{type:"button",onClick:S=>{S.preventDefault(),fl()},disabled:nn,className:"inline-flex h-7 w-7 items-center justify-center rounded-full text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:opacity-50","aria-label":e("settings.refresh"),children:s.jsx(yn,{size:12,className:nn?"animate-spin":""})})]}),s.jsx("div",{className:"px-2 pb-2",children:Sr.available?Dr.length===0?s.jsx("p",{className:"px-2 py-1.5 text-[11px] text-muted-foreground",children:e("settings.noTmuxSessions")}):s.jsxs("div",{className:"space-y-2",children:[Gc.map(S=>s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-1.5 py-1 text-[10px] text-muted-foreground",children:[s.jsx(jc,{size:11,className:"shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"shrink-0 font-medium text-foreground/75",children:S.label}),s.jsx("span",{className:"shrink-0 text-muted-foreground/70",children:e("settings.sessions",{n:S.sessions.length})}),S.key&&s.jsx("span",{className:"min-w-0 truncate text-muted-foreground/60",children:S.key})]}),S.sessions.map(P=>{const ue=P.boundFrontendSessionId??null,tt=!!(P.connected||ue),St=ue?gt.find(Qi=>Qi.id===ue)??null:null,Kt=P.friendlyName?.trim()||null,wr=P.label&&P.label!==P.name?P.label:null,xn=Kt||wr||P.name,Dn=Kt||wr?`tmux:${P.name}`:null,Mn=P.clientCount&&P.clientCount>0?t==="zh"?`网页连接 ${P.clientCount}`:`Web clients ${P.clientCount}`:null,vi=P.attached>0?t==="zh"?`原生 tmux ${P.attached}`:`Native tmux ${P.attached}`:null,wn=[Dn,tt?P.restorable?e("settings.restorable"):e("settings.attached"):null,Mn,vi].filter(Qi=>!!Qi),Bi=[e("settings.windows",{n:P.windows}),P.createdAt?new Date(P.createdAt).toLocaleDateString():null].filter(Qi=>!!Qi),Wa=ks===P.name,Co=Xr===P.name,ka=Et===P.name;return s.jsxs("div",{className:`flex items-start gap-2 rounded-lg px-2.5 py-2 ${Wa?"bg-destructive/10 ring-1 ring-destructive/40":"bg-surface"}`,children:[s.jsx(Nu,{size:13,className:tt?"mt-0.5 shrink-0 text-primary":"mt-0.5 shrink-0 text-muted-foreground"}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx("div",{className:"truncate text-[12px] font-semibold text-foreground",children:xn}),P.friendlyName&&s.jsx("span",{className:"shrink-0 rounded-full bg-primary/10 px-1.5 py-0.5 text-[9px] font-medium text-primary",children:t==="zh"?"自定义":"custom"})]}),wn.length>0&&s.jsx("div",{className:"flex min-w-0 flex-wrap gap-x-2 gap-y-0.5 text-[10px] text-muted-foreground",children:wn.map(Qi=>s.jsx("span",{className:"max-w-full truncate",children:Qi},Qi))}),(P.program||P.cwd)&&s.jsxs("div",{className:"grid min-w-0 gap-0.5 text-[10px] text-muted-foreground",children:[P.program&&s.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[s.jsx(JA,{size:10,className:"shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate text-foreground/75",children:P.program})]}),P.cwd&&s.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[s.jsx(jc,{size:10,className:"shrink-0 text-muted-foreground/70"}),s.jsx("span",{className:"truncate",children:P.cwd})]})]}),s.jsx("div",{className:"flex min-w-0 flex-wrap gap-x-2 gap-y-0.5 text-[10px] text-muted-foreground/80",children:Bi.map(Qi=>s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(MA,{size:10,className:"shrink-0 text-muted-foreground/60"}),Qi]},Qi))})]}),Wa?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",disabled:Co,onClick:()=>{Gu(P.name)},className:"shrink-0 rounded-full bg-destructive/90 px-2.5 py-1 text-[11px] font-medium text-destructive-foreground transition hover:bg-destructive disabled:opacity-50",children:Co?"…":e("settings.destroy")}),s.jsx("button",{type:"button",disabled:Co,onClick:()=>{Pr(null),Ue(null)},className:"shrink-0 rounded-full bg-surface-2 px-2.5 py-1 text-[11px] font-medium text-foreground transition hover:bg-surface-elevated",children:e("common.cancel")})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:()=>{St?sc(St.id):(kt(P.name),To({mode:"tmux",tmuxSessionName:P.name}))},disabled:ka,className:`shrink-0 inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-[11px] font-medium transition disabled:opacity-50 ${tt?"bg-surface text-foreground hover:bg-surface-elevated":ka?"bg-primary/10 text-primary":"bg-primary/15 text-primary hover:bg-primary/25"}`,children:ka?s.jsxs(s.Fragment,{children:[s.jsx(In,{size:10,className:"animate-spin"}),e("settings.attaching")]}):e(tt?"settings.attached":"settings.attach")}),s.jsx("button",{type:"button",disabled:Co,onClick:()=>{Ue(null),Pr(P.name)},className:"shrink-0 inline-flex h-7 w-7 items-center justify-center rounded-full text-muted-foreground transition hover:bg-destructive/15 hover:text-destructive","aria-label":`Kill tmux session ${P.name}`,children:s.jsx(zs,{size:12})})]})]},P.name)})]},S.key||"__ungrouped_tmux__")),K&&s.jsx("p",{className:"px-2 text-[11px] text-destructive",children:K})]}):s.jsx("p",{className:"px-2 py-1.5 text-[11px] text-muted-foreground",children:Sr.reason||e("settings.installTmuxHint")})})]}),s.jsxs("button",{type:"button",onClick:()=>zi(!0),className:"mt-2 flex w-full items-center justify-between gap-2 rounded-xl bg-surface-2 px-3 py-2.5 text-left text-[13px] transition hover:bg-surface-elevated",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(v3,{size:14,className:"text-muted-foreground"}),s.jsx("span",{className:"font-medium text-foreground",children:e("settings.keyboardToolbar")})]}),s.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:e("settings.sessions",{n:es.length})}),s.jsx("span",{children:"›"})]})]}),s.jsxs("button",{type:"button",onClick:()=>$a(!0),className:"mt-2 flex w-full items-center justify-between gap-2 rounded-xl bg-surface-2 px-3 py-2.5 text-left text-[13px] transition hover:bg-surface-elevated",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(Ad,{size:14,className:"text-muted-foreground"}),s.jsx("span",{className:"font-medium text-foreground",children:e("settings.aiAgentDetection")})]}),s.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:"hooks"}),s.jsx("span",{children:"›"})]})]}),s.jsxs("div",{className:"mt-3 flex items-center gap-2 rounded-xl bg-surface-2 px-2.5 py-2",children:[s.jsx("span",{className:"text-[12px] font-medium text-foreground/90 w-14 shrink-0",children:e("settings.language")}),s.jsx("div",{className:"flex flex-1 items-center gap-1 rounded-md bg-surface p-0.5",children:[{code:"en",label:"English"},{code:"zh",label:"中文"}].map(S=>{const P=t===S.code;return s.jsx("button",{type:"button",onClick:()=>r(S.code),className:`flex-1 rounded px-2 py-1 text-[11px] font-medium transition ${P?"bg-primary/20 text-primary":"text-muted-foreground hover:bg-surface-elevated"}`,children:S.label},S.code)})})]}),s.jsxs("button",{type:"button",onClick:async()=>{try{await Q9()}catch{}window.dispatchEvent(new CustomEvent("auth:unauthorized"))},className:"mt-3 flex w-full items-center justify-center gap-2 rounded-xl bg-destructive/10 px-3 py-2.5 text-[13px] font-medium text-destructive transition hover:bg-destructive/20 active:scale-[0.98]",children:[s.jsx(_3,{size:14}),e("settings.signOut")]})]})]})})]}),Ha&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-menu-backdrop bg-[var(--app-backdrop-soft)] backdrop-blur-sm cursor-default animate-fade-in",onClick:()=>{qe(null),Rt(null),Ue(null)},"aria-label":e("common.close")}),s.jsxs("div",{className:`fixed z-menu-panel rounded-2xl bg-surface-elevated border border-border/15 shadow-[0_18px_48px_var(--app-shadow-soft)] animate-fade-in ${At&&ir?"":"inset-x-3 bottom-6 mx-auto max-w-sm sm:bottom-auto sm:top-[15%]"}`,style:At&&ir?{...Zb(At),paddingBottom:a}:{paddingBottom:a},children:[s.jsxs("div",{className:"border-b border-border/15 px-4 py-3",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-muted-foreground",children:e("tab.closeChooserTitle")}),s.jsx("div",{className:"mt-0.5 truncate text-[14px] font-medium text-foreground",children:jd}),s.jsx("div",{className:"mt-0.5 text-[11px] text-muted-foreground/80",children:e("tab.closeChooserDescription")})]}),s.jsxs("div",{className:"flex flex-col py-1",children:[s.jsxs("button",{type:"button",onClick:Yu,className:"flex items-center gap-3 px-4 py-3 text-left text-[13px] text-destructive transition hover:bg-destructive/10",children:[s.jsx("span",{className:"inline-flex h-7 w-7 items-center justify-center rounded-full bg-destructive/15 text-destructive",children:s.jsx(zs,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium",children:e("tab.confirmDestroySession")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.destroySessionHint")})]})]}),K&&s.jsx("p",{className:"px-4 py-2 text-[11px] text-destructive",children:K})]}),s.jsx("div",{className:"border-t border-border/15 px-3 py-2",children:s.jsx("button",{type:"button",onClick:()=>{qe(null),Rt(null),Ue(null)},className:"w-full rounded-full bg-surface-2 px-3 py-2 text-[12px] font-medium text-muted-foreground transition hover:bg-surface hover:text-foreground",children:e("common.cancel")})})]})]}),cr&&(()=>{const S=gt.find(Mn=>Mn.id===cr);if(!S)return null;const P=sr.get(S.id),{primary:ue}=sl(S,P?.activeProgram??null,P?.cwd??null,ya),tt=ir,St=tt?Zb(Ls):{paddingBottom:a},Kt=tt?"fixed z-menu-panel overflow-y-auto overflow-x-hidden rounded-lg bg-surface-elevated border border-border/15 shadow-[0_18px_48px_var(--app-shadow-soft)] animate-fade-in":"fixed inset-x-3 bottom-6 z-menu-panel mx-auto max-w-sm rounded-2xl bg-surface-elevated border border-border/15 shadow-[0_18px_48px_var(--app-shadow-soft)] animate-fade-in sm:bottom-auto sm:top-[15%]",wr=tt?"border-b border-border/15 px-3 py-2":"border-b border-border/15 px-4 py-3",xn=tt?"flex items-center gap-2 px-3 py-2 text-left text-[12px] transition":"flex items-center gap-3 px-4 py-3 text-left text-[13px] transition",Dn=tt?"inline-flex h-6 w-6 items-center justify-center rounded-md":"inline-flex h-7 w-7 items-center justify-center rounded-full";return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:`fixed inset-0 z-menu-backdrop cursor-default animate-fade-in ${tt?"bg-transparent":"bg-[var(--app-backdrop-soft)] backdrop-blur-sm"}`,onClick:Zt,"aria-label":"Close menu"}),s.jsxs("div",{className:Kt,style:St,children:[s.jsxs("div",{className:wr,children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-muted-foreground",children:e("tab.session")}),s.jsx("div",{className:"mt-0.5 truncate text-[14px] font-medium text-foreground",children:ue}),P?.cwd&&s.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground/80",children:P.cwd})]}),s.jsxs("div",{className:"flex flex-col py-1",children:[s.jsxs("button",{type:"button",onClick:()=>{const Mn=Ls;Zt(),kr(Mn),Br(S.id)},className:`${xn} text-foreground hover:bg-surface-2`,children:[s.jsx("span",{className:`${Dn} bg-primary/15 text-primary`,children:s.jsx(jT,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium",children:e("tab.rename")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.renameHint")})]})]}),s.jsxs("button",{type:"button",disabled:!P?.cwd,onClick:()=>{Nd(S.id),Zt()},className:`${xn} ${P?.cwd?"text-foreground hover:bg-surface-2":"text-muted-foreground/50 cursor-not-allowed"}`,children:[s.jsx("span",{className:`${Dn} bg-surface-2 text-muted-foreground`,children:s.jsx(w3,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium",children:e("tab.copyCwd")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.copyCwdHint")})]}),$r&&$r===P?.cwd&&s.jsx("span",{className:"ml-auto text-[11px] text-primary",children:e("tab.copied")})]}),(()=>{const Mn=Lm(S.id),vi=Mn??De;return s.jsxs("div",{className:`${xn} text-foreground`,children:[s.jsx("span",{className:`${Dn} bg-surface-2 text-muted-foreground`,children:s.jsx(dC,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium",children:e("tab.fontSize")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.fontSizeHint")})]}),s.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[s.jsx("button",{type:"button",onClick:()=>{Lh(S.id,vi-1),sn(wn=>wn+1)},className:"h-7 w-7 shrink-0 rounded-md bg-surface text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":`${e("tab.fontSize")} -1`,children:"−"}),s.jsxs("span",{className:"w-8 text-center text-[11px] tabular-nums text-muted-foreground",children:[vi,"px"]}),s.jsx("button",{type:"button",onClick:()=>{Lh(S.id,vi+1),sn(wn=>wn+1)},className:"h-7 w-7 shrink-0 rounded-md bg-surface text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95","aria-label":`${e("tab.fontSize")} +1`,children:"+"}),Mn!==null&&s.jsx("button",{type:"button",onClick:()=>{Lh(S.id,null),sn(wn=>wn+1)},className:"ml-1 shrink-0 rounded-md px-1.5 py-1 text-[11px] text-primary transition hover:bg-primary/10",children:e("tab.fontSizeReset")})]})]})})(),P?.agentNativeSessionId&&P.agentStatus!=="working"&&P.agentStatus!=="waiting"&&P.terminalSessionId&&s.jsxs("button",{type:"button",onClick:()=>{const Mn=P.terminalSessionId;Mn&&(Zt(),on(S.id,Mn))},className:`${xn} text-foreground hover:bg-surface-2`,children:[s.jsx("span",{className:`${Dn} bg-[rgb(var(--success-rgb)_/_0.14)] text-[color:var(--success)]`,children:s.jsx(Sc,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"block font-medium",children:[e("tab.resumeAgent"),P.agent?.displayName?` · ${P.agent.displayName}`:""]}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.resumeAgentHint")})]})]}),s.jsx("div",{className:"my-1 border-t border-border/15"}),S.mode==="tmux"?s.jsxs("button",{type:"button",onClick:()=>{Zt(),oc(S.id)},className:`${xn} text-destructive hover:bg-destructive/10`,children:[s.jsx("span",{className:`${Dn} bg-destructive/15 text-destructive`,children:s.jsx(zs,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium",children:e("tab.destroySession")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.destroySessionHint")})]})]}):s.jsxs("button",{type:"button",onClick:()=>{Zt(),jl({sessionId:S.id,source:"tab-menu",closeMode:"auto"})},className:`${xn} text-destructive hover:bg-destructive/10`,children:[s.jsx("span",{className:`${Dn} bg-destructive/15 text-destructive`,children:s.jsx(Qn,{size:14})}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block font-medium",children:e("tab.close")}),s.jsx("span",{className:"block text-[11px] text-muted-foreground",children:e("tab.closeHint")})]})]}),!tt&&s.jsx("button",{type:"button",className:"flex items-center justify-center px-4 py-2 text-[11px] text-muted-foreground/80 transition hover:text-foreground",onClick:()=>{Zt()},children:e("tab.longPressTip")})]}),!tt&&s.jsx("div",{className:"border-t border-border/15 px-3 py-2",children:s.jsx("button",{type:"button",onClick:Zt,className:"w-full rounded-full bg-surface-2 px-3 py-2 text-[12px] font-medium text-muted-foreground transition hover:bg-surface hover:text-foreground",children:e("common.cancel")})})]})]})})(),tr&&ln&&ir&&(()=>{const S=gt.find(wn=>wn.id===tr);if(!S)return null;const P=sr.get(S.id),{primary:ue}=sl(S,P?.activeProgram??null,P?.cwd??null,ya,P?.shellTitle??null,P?.promptState??null),tt=S.customName?S.name:ue,St=wn=>{const Bi=wn.trim();Bi?Bi!==tt&&ys(S.id,Bi):Uo(S.id),Br(null),kr(null)},Kt=300,wr=160,xn=ln.x,Dn=ln.y,Mn=Math.min(Math.max(xn-Kt/2,12),window.innerWidth-Kt-12),vi=Dn+wr+20>window.innerHeight?Math.max(Dn-wr-12,12):Dn+12;return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-menu-backdrop cursor-default animate-fade-in bg-transparent",onClick:()=>{Br(null),kr(null)},"aria-label":e("common.cancel")}),s.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":e("tab.rename"),className:"fixed z-menu-panel w-[300px] rounded-xl bg-surface-elevated border border-border/15 shadow-[0_12px_36px_var(--app-shadow-soft)] animate-fade-in",style:{left:`${Mn}px`,top:`${vi}px`},children:[s.jsxs("div",{className:"border-b border-border/15 px-3 py-2.5",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-muted-foreground",children:e("tab.rename")}),s.jsx("div",{className:"mt-0.5 truncate text-[13px] font-medium text-foreground",children:ue}),P?.cwd&&s.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground/70",children:P.cwd})]}),s.jsxs("form",{className:"px-3 py-2.5",onSubmit:wn=>{wn.preventDefault();const Bi=new FormData(wn.currentTarget).get("session-name");St(typeof Bi=="string"?Bi:"")},children:[s.jsx("input",{ref:wn=>{Dt.current=wn,wn&&!ot.current&&(ot.current=!0,wn.focus({preventScroll:!0}),wn.select())},type:"text",name:"session-name",defaultValue:tt,placeholder:e("tab.renamePlaceholder"),autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,className:"w-full rounded-lg bg-surface-2 px-3 py-2 text-[13px] leading-snug text-foreground outline-none ring-1 ring-primary/40 placeholder:text-muted-foreground/60 focus:ring-primary/70",onKeyDown:wn=>{wn.key==="Escape"&&(wn.stopPropagation(),Br(null),kr(null))}}),s.jsxs("div",{className:"mt-2.5 flex gap-2",children:[s.jsx("button",{type:"button",onClick:()=>{Br(null),kr(null)},className:"flex-1 rounded-full bg-surface-2 px-3 py-1.5 text-[12px] font-medium text-muted-foreground transition hover:bg-surface hover:text-foreground",children:e("common.cancel")}),s.jsx("button",{type:"submit",className:"flex-1 rounded-full bg-primary px-3 py-1.5 text-[12px] font-semibold text-primary-foreground transition hover:bg-primary/90 active:scale-[0.97]",children:e("common.save")})]})]})]})]})})(),tr&&!ir&&(()=>{const S=gt.find(Kt=>Kt.id===tr);if(!S)return null;const P=sr.get(S.id),{primary:ue}=sl(S,P?.activeProgram??null,P?.cwd??null,ya,P?.shellTitle??null,P?.promptState??null),tt=S.customName?S.name:ue,St=Kt=>{const wr=Kt.trim();wr?wr!==tt&&ys(S.id,wr):Uo(S.id),Br(null)};return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-menu-backdrop cursor-default animate-fade-in bg-[var(--app-backdrop-soft)] backdrop-blur-sm",onClick:()=>Br(null),"aria-label":e("common.cancel")}),s.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":e("tab.rename"),className:"fixed inset-x-3 z-menu-panel mx-auto max-w-sm rounded-2xl bg-surface-elevated border border-border/15 shadow-[0_18px_48px_var(--app-shadow-soft)] animate-fade-in",style:{top:`calc(${n} + 3.5rem)`},children:[s.jsxs("div",{className:"border-b border-border/15 px-4 py-3",children:[s.jsx("div",{className:"text-[11px] uppercase tracking-[0.14em] text-muted-foreground",children:e("tab.session")}),s.jsx("div",{className:"mt-0.5 text-[14px] font-medium text-foreground",children:e("tab.rename")})]}),s.jsxs("form",{className:"px-4 py-3",onSubmit:Kt=>{Kt.preventDefault();const wr=new FormData(Kt.currentTarget).get("session-name");St(typeof wr=="string"?wr:"")},children:[s.jsx("input",{ref:Kt=>{Dt.current=Kt,Kt&&!ot.current&&(ot.current=!0,Kt.focus({preventScroll:!0}),Kt.select())},type:"text",name:"session-name",defaultValue:tt,placeholder:e("tab.renamePlaceholder"),autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,enterKeyHint:"done",className:"w-full rounded-lg bg-surface-2 px-3 py-2.5 text-[16px] leading-snug text-foreground outline-none ring-1 ring-primary/40 placeholder:text-muted-foreground/60 focus:ring-primary/70",onKeyDown:Kt=>{Kt.key==="Escape"&&(Kt.stopPropagation(),Br(null))}}),s.jsxs("div",{className:"mt-3 flex gap-2",children:[s.jsx("button",{type:"button",onClick:()=>Br(null),className:"flex-1 rounded-full bg-surface-2 px-3 py-2 text-[12px] font-medium text-muted-foreground transition hover:bg-surface hover:text-foreground",children:e("common.cancel")}),s.jsx("button",{type:"submit",className:"flex-1 rounded-full bg-primary/20 px-3 py-2 text-[12px] font-medium text-primary transition hover:bg-primary/30",children:e("common.save")})]})]})]})]})})(),yi&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button","aria-label":e("common.close"),className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm",onClick:()=>ei(!1)}),s.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"local-access-title",className:"fixed inset-x-3 top-[max(1.5rem,env(safe-area-inset-top,0px))] bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto flex max-w-xl flex-col overflow-hidden rounded-2xl border border-border/15 bg-surface sm:top-[10%] sm:bottom-auto sm:max-h-[80vh]",children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/15 p-4",children:[s.jsx("h2",{id:"local-access-title",className:"section-title",children:e("settings.localAccess")}),s.jsx("button",{autoFocus:!0,type:"button","aria-label":e("common.close"),onClick:()=>ei(!1),className:"rounded-full bg-surface-2 p-2 text-muted-foreground",children:s.jsx(Qn,{size:18})})]}),s.jsxs("div",{className:"overflow-y-auto overscroll-contain p-4",children:[s.jsx(NC,{state:xe,onCopy:S=>{$o(S,"setup")},copied:Ce==="setup"}),s.jsxs("div",{className:"mt-3 flex items-center overflow-hidden rounded-lg bg-surface ring-1 ring-border/10 focus-within:ring-primary/40",children:[s.jsx("input",{value:te,onChange:S=>ke(S.target.value.toLowerCase()),className:"min-w-0 flex-1 bg-transparent px-2.5 py-2 text-[12px] text-foreground outline-none",placeholder:"jovn",spellCheck:!1}),s.jsx("span",{className:"shrink-0 border-l border-border/10 px-2.5 py-2 text-[11px] text-muted-foreground",children:".termdock.local"})]}),s.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[s.jsx("button",{type:"button",disabled:$e,onClick:()=>{bo()},className:"rounded-full bg-primary/15 px-3 py-1.5 text-[11px] font-medium text-primary transition hover:bg-primary/25 disabled:opacity-50",children:e($e?"settings.saving":"common.save")}),s.jsx("button",{type:"button",disabled:$e,onClick:()=>{hl()},className:"rounded-full bg-surface px-3 py-1.5 text-[11px] font-medium text-muted-foreground transition hover:bg-surface-elevated disabled:opacity-50",children:e("settings.resetAutoName")})]}),s.jsxs("div",{className:"mt-3 space-y-1.5 text-[11px]",children:[xe.url&&s.jsxs("button",{type:"button",onClick:()=>{$o(xe.url,"lan")},className:"flex w-full items-center justify-between gap-2 rounded-lg bg-surface px-2.5 py-2 text-left text-muted-foreground transition hover:bg-surface-elevated",children:[s.jsxs("span",{className:"min-w-0 truncate",children:["Branded: ",xe.url]}),s.jsx("span",{className:"shrink-0 rounded-full bg-primary/10 px-2 py-0.5 text-[10px] font-medium",children:Ce==="lan"?"Copied":e("common.copy")})]}),xe.interfaces.length>0&&s.jsxs("details",{className:"rounded-lg bg-surface px-2.5 py-2 text-muted-foreground",open:!1,children:[s.jsx("summary",{className:"cursor-pointer text-[11px] font-medium text-foreground/80",children:"IP fallback addresses"}),s.jsx("div",{className:"mt-2 grid grid-cols-1 gap-2 sm:grid-cols-2",children:xe.interfaces.map(S=>{const P=S.url??`${xe.httpsEnabled?"https":"http"}://${S.address}:9834`;return s.jsxs("div",{className:"rounded-lg bg-surface-2 p-2",children:[s.jsxs("div",{className:"text-[11px] font-medium text-foreground/85",children:[S.label," (",S.name,")"]}),s.jsx("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:S.address}),S.qrDataUrl&&s.jsx("div",{className:"mt-2 inline-block rounded-lg bg-[var(--background)] p-1.5",children:s.jsx("img",{src:S.qrDataUrl,alt:`QR code for ${P}`,className:"h-28 w-28"})}),s.jsxs("button",{type:"button",onClick:()=>{$o(P,`ip-${S.address}`)},className:"mt-2 flex w-full items-center justify-between gap-2 rounded-md bg-surface px-2 py-1.5 text-left text-[11px] transition hover:bg-surface-elevated",children:[s.jsx("span",{className:"min-w-0 truncate",children:P}),s.jsx("span",{className:"shrink-0 text-[10px]",children:Ce===`ip-${S.address}`?"Copied":e("common.copy")})]})]},`${S.name}-${S.address}`)})})]}),s.jsxs("div",{className:"text-muted-foreground",children:[xe.httpsEnabled?e("settings.httpsActive"):e("settings.httpsInactive"),!xe.caAvailable&&` · ${e("settings.caMissing")}`]}),xe.reason&&s.jsx("div",{className:"text-[color:var(--warning)]",children:xe.reason}),Ae&&s.jsx("div",{className:"text-destructive",children:Ae})]})]})]})]}),Rs&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm cursor-default",onClick:()=>js(!1)}),s.jsxs("div",{className:"fixed left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] top-[max(1.5rem,env(safe-area-inset-top,0px))] bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto flex max-w-xl flex-col overflow-hidden rounded-2xl bg-surface border border-border/15 shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)] sm:top-[10%] sm:bottom-auto sm:max-h-[80vh]",children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/15 px-4 py-4 sm:px-6",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"ui-kicker",children:e("settings.notifications")}),s.jsx("h2",{className:"section-title mt-1",children:e("settings.notificationsTitle")})]}),s.jsx("button",{type:"button",onClick:()=>js(!1),className:"shrink-0 rounded-full bg-surface-2 p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":"Close notifications settings",children:s.jsx(Qn,{size:18})})]}),s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-4 sm:p-6",children:[s.jsx("p",{className:"text-[12px] leading-relaxed text-muted-foreground",children:e("settings.notificationsPageHint")}),s.jsxs("div",{className:"mt-4 rounded-2xl bg-surface-2 p-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:e("settings.notificationsMaster")}),s.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:Z==="denied"?e("settings.notificationsDenied"):Gd()?e("settings.notificationsMasterHint"):e("settings.notificationsUnsupported")}),Gd()&&!P9()&&s.jsx("div",{className:"mt-1.5 text-[11px] leading-relaxed text-[var(--warning)]",children:e("settings.notificationsIOSInstallHint")})]}),s.jsx("button",{type:"button",onClick:()=>{pt()},disabled:!Gd()||Z==="denied",className:"shrink-0 transition disabled:cursor-not-allowed","aria-pressed":L,children:s.jsx(ll,{checked:L,disabled:!Gd()||Z==="denied"})})]}),s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-[11px]",children:[s.jsxs("span",{className:`rounded-full px-2 py-0.5 ${Z==="granted"?"bg-primary/15 text-primary":"bg-surface text-muted-foreground"}`,children:[e("settings.notificationsPermission"),": ",lo()?e("settings.notificationsPermissionSystem"):Z]}),s.jsx("button",{type:"button",disabled:!L||Z!=="granted"||ti==="checking",onClick:()=>{Jt()},className:"rounded-full bg-surface px-3 py-1.5 font-medium text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:e(ti==="checking"?"settings.notificationsTestChecking":"settings.notificationsTest")}),lo()?.openNotificationSettings&&s.jsx("button",{type:"button",onClick:()=>{lo()?.openNotificationSettings?.()},className:"rounded-full bg-surface px-3 py-1.5 font-medium text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground",children:e("settings.notificationsOpenSystemSettings")})]}),ti!=="idle"&&ti!=="checking"&&s.jsx("div",{className:`mt-2 text-[11px] leading-relaxed ${ti==="delivered"?"text-primary":"text-[var(--warning)]"}`,children:e(ti==="delivered"?"settings.notificationsTestDelivered":"settings.notificationsTestFailed")})]}),s.jsxs("div",{className:"mt-4 rounded-2xl bg-surface-2 p-3",children:[s.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:e("settings.notificationsAlertStyle")}),s.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:e("settings.notificationsAlertStyleHint")}),s.jsx("div",{className:"mt-3 grid grid-cols-3 gap-1 rounded-xl bg-surface p-1",children:[["normal",e("settings.notificationsStyleNormal"),e("settings.notificationsStyleNormalHint")],["quiet",e("settings.notificationsStyleQuiet"),e("settings.notificationsStyleQuietHint")],["persistent",e("settings.notificationsStylePersistent"),e("settings.notificationsStylePersistentHint")]].map(([S,P,ue])=>{const tt=U===S;return s.jsxs("button",{type:"button",disabled:!L,onClick:()=>Jr(S),className:`min-w-0 rounded-lg px-2 py-2 text-left transition ${tt&&L?"bg-primary/15 text-primary":L?"text-muted-foreground hover:bg-surface-elevated hover:text-foreground":"cursor-not-allowed text-muted-foreground/40"}`,title:ue,children:[s.jsx("span",{className:"block truncate text-[11px] font-semibold",children:P}),s.jsx("span",{className:"mt-0.5 block truncate text-[9px] opacity-80",children:ue})]},S)})})]}),s.jsxs("div",{className:"mt-4",children:[s.jsx("div",{className:"ui-kicker",children:e("settings.notificationsEvents")}),s.jsxs("div",{className:"mt-2 rounded-2xl bg-surface-2 p-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:e("settings.notificationsAiFinished")}),s.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:e("settings.notificationsAiFinishedHint")})]}),s.jsx("button",{type:"button",disabled:!L,onClick:()=>fr(!R),className:"shrink-0 transition disabled:cursor-not-allowed","aria-pressed":R&&L,children:s.jsx(ll,{checked:R&&L,disabled:!L})})]}),s.jsxs("div",{className:"mt-3 flex items-start justify-between gap-3 border-t border-border/10 pt-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:e("settings.notificationsSessionExited")}),s.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:e("settings.notificationsSessionExitedHint")})]}),s.jsx("button",{type:"button",disabled:!L,onClick:()=>Ur(!W),className:"shrink-0 transition disabled:cursor-not-allowed","aria-pressed":W&&L,children:s.jsx(ll,{checked:W&&L,disabled:!L})})]})]}),s.jsx("p",{className:"mt-2 text-[10px] text-muted-foreground",children:e("settings.notificationsFutureHint")})]})]})]})]}),Ca&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm cursor-default",onClick:()=>zi(!1)}),s.jsxs("div",{className:"fixed left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] top-[max(1.5rem,env(safe-area-inset-top,0px))] bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto flex max-w-4xl flex-col overflow-hidden rounded-2xl bg-surface border border-border/15 shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)]",children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/15 px-4 py-4 sm:px-6",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"ui-kicker",children:e("settings.mobileKeyboard")}),s.jsx("h2",{className:"section-title mt-1",children:e("settings.toolbarPresets")})]}),s.jsx("button",{type:"button",onClick:()=>zi(!1),className:"shrink-0 rounded-full bg-surface-2 p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":"Close toolbar presets",children:s.jsx(Qn,{size:18})})]}),s.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-4 sm:p-6",children:s.jsx(OF,{presets:es,selectedPresetId:zo,onSelectPreset:Ho,onUpdatePreset:(S,P)=>{ua(ue=>yu(ue.map(tt=>tt.id===S?P(tt):tt)))},onAddPreset:()=>{const S=`preset-${Date.now()}`;ua(P=>yu([...P,{id:S,label:`Preset ${P.length}`,programs:[],includeAlt:!1,rowLayout:[3,3],actions:[],showOnDesktop:!1}])),Ho(S)},onRemovePreset:S=>{ua(P=>yu(P.filter(ue=>ue.id!==S)))},onResetDefaults:()=>{ua(ud()),Ho("default")}})})]})]}),da&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-modal-backdrop bg-[var(--app-backdrop)] backdrop-blur-sm cursor-default",onClick:()=>$a(!1)}),s.jsxs("div",{className:"fixed left-[max(0.75rem,env(safe-area-inset-left,0px))] right-[max(0.75rem,env(safe-area-inset-right,0px))] top-[max(1.5rem,env(safe-area-inset-top,0px))] bottom-[max(1.5rem,env(safe-area-inset-bottom,0px))] z-modal-panel mx-auto flex max-w-4xl flex-col overflow-hidden rounded-2xl bg-surface border border-border/15 shadow-[0_28px_70px_var(--app-shadow-strong),0_14px_32px_var(--app-shadow-soft)]",children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-border/15 px-4 py-4 sm:px-6",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"ui-kicker",children:e("settings.aiAgentDetection")}),s.jsx("h2",{className:"section-title mt-1",children:e("settings.detectionRules")})]}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("button",{type:"button",onClick:()=>$a(!1),className:"shrink-0 rounded-full bg-surface-2 p-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground","aria-label":"Close agent rules",children:s.jsx(Qn,{size:18})})})]}),s.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-4 sm:p-6",children:[s.jsx("p",{className:"mb-4 text-[11px] text-muted-foreground",children:e("settings.agentHooksHint")}),s.jsx($F,{}),s.jsxs("div",{className:"mt-6 border-t border-border/15 pt-4",children:[s.jsx("div",{className:"ui-kicker",children:e("settings.programLabelResolution")}),s.jsx("h3",{className:"mt-1 text-sm font-semibold text-foreground",children:e("settings.rawCommandMapping")}),s.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:e("settings.rawCommandMappingHint")}),s.jsx("div",{className:"mt-3 space-y-2 rounded-xl bg-surface-2 p-3",children:gt.map(S=>{const P=sr.get(S.id),ue=P?.activeProgramRaw??null,tt=P?.activeProgram??null;return s.jsxs("div",{className:"rounded-lg bg-surface/60 px-2.5 py-2",children:[s.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:S.name}),s.jsxs("div",{className:"mt-0.5 text-[11px] text-foreground",children:[s.jsx("span",{className:"text-muted-foreground",children:"display:"})," ",tt||"—"]}),s.jsxs("div",{className:"mt-0.5 break-all font-mono text-[10px] text-muted-foreground",children:[s.jsx("span",{className:"text-muted-foreground/80",children:"raw:"})," ",ue||"—"]})]},`raw-${S.id}`)})}),s.jsxs("div",{className:"mt-3 space-y-3",children:[[{key:"genericProgramNames",label:e("settings.genericProgramNames"),hint:e("settings.genericProgramNamesHint")},{key:"wrapperScriptNames",label:e("settings.wrapperScriptNames"),hint:e("settings.wrapperScriptNamesHint")},{key:"shellNames",label:e("settings.shellNamesConfig"),hint:e("settings.shellNamesHint")}].map(({key:S,label:P,hint:ue})=>s.jsxs("div",{children:[s.jsx("div",{className:"mb-0.5 text-[11px] font-medium text-foreground",children:P}),s.jsx("div",{className:"text-[10px] text-muted-foreground",children:ue}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1",children:[ge[S].map(tt=>s.jsxs("span",{className:"inline-flex items-center gap-0.5 rounded-full bg-surface-2 px-2 py-0.5 text-[11px] font-mono text-foreground",children:[tt,s.jsx("button",{type:"button",onClick:()=>{const St={...ge,[S]:ge[S].filter(Kt=>Kt!==tt)};ve(St),S==="shellNames"&&(ya=new Set(St.shellNames)),Jg(St).catch(()=>{})},className:"ml-0.5 text-muted-foreground hover:text-destructive",children:"×"})]},tt)),s.jsx("input",{placeholder:e("settings.addTag"),className:"w-16 rounded bg-surface px-1.5 py-0.5 text-[11px] font-mono",onKeyDown:tt=>{if(tt.key!=="Enter")return;const St=tt.target.value.trim().toLowerCase();if(!St||ge[S].includes(St))return;const Kt={...ge,[S]:[...ge[S],St]};ve(Kt),S==="shellNames"&&(ya=new Set(Kt.shellNames)),tt.target.value="",Jg(Kt).catch(()=>{})}})]})]},S)),s.jsx("button",{type:"button",onClick:()=>{O9().then(S=>{ve(S),ya=new Set(S.shellNames)}).catch(()=>{})},className:"rounded-full bg-surface-2 px-3 py-1 text-[11px] text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:e("settings.resetDefaults")})]}),s.jsxs("div",{className:"mt-3",children:[s.jsx("div",{className:"mb-1 text-[11px] font-medium text-foreground",children:e("settings.customRules")}),Di.map((S,P)=>s.jsx("div",{className:"mb-2 rounded-lg bg-surface-2 p-2.5",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("input",{type:"checkbox",checked:S.enabled!==!1,onChange:ue=>{const tt=Di.map((St,Kt)=>Kt===P?{...St,enabled:ue.target.checked}:St);xs(tt),Un(ba,tt),j(!0),Xc(tt).then(St=>{xs(St),Un(ba,St)}).catch(()=>{}).finally(()=>j(!1))}}),s.jsxs("select",{value:S.matchType,onChange:ue=>{const tt=Di.map((St,Kt)=>Kt===P?{...St,matchType:ue.target.value}:St);xs(tt),Un(ba,tt),j(!0),Xc(tt).then(St=>{xs(St),Un(ba,St)}).catch(()=>{}).finally(()=>j(!1))},className:"rounded bg-surface px-2 py-1 text-[11px]",children:[s.jsx("option",{value:"includes",children:"includes"}),s.jsx("option",{value:"exact",children:"exact"}),s.jsx("option",{value:"prefix",children:"prefix"}),s.jsx("option",{value:"regex",children:"regex"})]}),s.jsx("input",{value:S.pattern,onChange:ue=>{const tt=Di.map((St,Kt)=>Kt===P?{...St,pattern:ue.target.value}:St);xs(tt),Un(ba,tt)},onBlur:()=>{j(!0),Xc(Di).then(ue=>{xs(ue),Un(ba,ue)}).catch(()=>{}).finally(()=>j(!1))},placeholder:"pattern",className:"min-w-[180px] flex-1 rounded bg-surface px-2 py-1 text-[11px] font-mono"}),s.jsx("input",{value:S.output,onChange:ue=>{const tt=Di.map((St,Kt)=>Kt===P?{...St,output:ue.target.value}:St);xs(tt),Un(ba,tt)},onBlur:()=>{j(!0),Xc(Di).then(ue=>{xs(ue),Un(ba,ue)}).catch(()=>{}).finally(()=>j(!1))},placeholder:"output",className:"w-28 rounded bg-surface px-2 py-1 text-[11px]"}),s.jsx("button",{type:"button",onClick:()=>{const ue=Di.filter((tt,St)=>St!==P);xs(ue),Un(ba,ue),j(!0),Xc(ue).then(tt=>{xs(tt),Un(ba,tt)}).catch(()=>{}).finally(()=>j(!1))},className:"rounded bg-surface px-2 py-1 text-[11px] text-muted-foreground hover:text-destructive",children:e("common.delete")})]})},S.id)),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>{const S=[...Di,{id:`rule-${Date.now()}`,enabled:!0,priority:100,matchType:"includes",pattern:"",output:""}];xs(S),Un(ba,S),j(!0),Xc(S).then(P=>{xs(P),Un(ba,P)}).catch(()=>{}).finally(()=>j(!1))},className:"rounded-full bg-primary/15 px-3 py-1.5 text-[11px] font-medium text-primary hover:bg-primary/25",children:e("settings.addRule")}),s.jsx("button",{type:"button",onClick:()=>{j(!0),F9().then(S=>{xs(S),Un(ba,S)}).catch(()=>{}).finally(()=>j(!1))},className:"rounded-full bg-surface-2 px-3 py-1.5 text-[11px] font-medium text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:e("settings.resetDefaults")}),s.jsx("span",{className:"text-[11px] text-muted-foreground",children:T?e("settings.saving"):Rl?`${Di.length} rules`:"…"})]})]})]})]})]})]}),wo&&s.jsx(MF,{isOpen:wo,onClose:()=>ha(!1)}),!Wi&&s.jsx(wb,{isOpen:Er,drawerWidthPx:Xn,onClose:()=>Ln("left-sidebar"),onOpen:ia,sessions:gt,activeSessionId:yt,sessionStates:sr,onNewSession:S=>To(S),recoverableTmuxSessions:lc,recoverableTmuxSessionsLoading:nn,onRefreshRecoverableTmuxSessions:()=>{fl()},onCloseRecoverableTmuxSession:zc,onCloseSession:oc,onSplitSession:Vu,onCloseSplit:S=>window.dispatchEvent(new CustomEvent("close-terminal-split",{detail:S})),onRemoveFromSplit:S=>window.dispatchEvent(new CustomEvent("remove-terminal-split-pane",{detail:S})),splitWorkspaces:it,onSetSplitLayout:ac,onReorderSplitWorkspace:Md,onRenameSplitWorkspace:Hc,onCombineSplitSessions:qu,onReorderSessions:gs,onSessionMenu:Ml,onOpenSettings:xo,onJumpToNextAttention:us.length>0?Wo:void 0,onOpenQuota:()=>ha(!0),updateState:_e,updateActionPending:re,onConfirmUpdateRestart:nt,onRetryUpdate:wt,serverHealthState:Se,tmuxAvailable:Sr.available,defaultSessionMode:Gs,onTogglePinned:ir?ws:void 0}),!pl&&s.jsx(Ab,{isOpen:ne,sessionId:yt,drawerWidthPx:pn,onClose:()=>Ln("right-sidebar"),onOpen:fo,rightSidebarFilePreviewOpen:kn,rightSidebarFilePreviewCloseSignal:be,onOpenRightSidebarFilePreview:Ni,onCloseRightSidebarFilePreview:Ri,rightSidebarRepoPickerOpen:Je,rightSidebarRepoPickerCloseSignal:Wt,onOpenRightSidebarRepoPicker:Pa,onCloseRightSidebarRepoPicker:mi,markdownOutlineOpen:vt,markdownOutlineCloseSignal:Qt,onOpenMarkdownOutline:dl,onCloseMarkdownOutline:Js,markdownImageLightboxOpen:Ut,markdownImageLightboxCloseSignal:pe,onOpenMarkdownImageLightbox:Fo,onCloseMarkdownImageLightbox:oa,onTogglePinned:ir?Es:void 0}),We&&!c&&s.jsx("button",{type:"button",onClick:gi,className:"fixed inset-0 z-toast flex cursor-default items-center justify-center bg-[var(--app-backdrop-soft)] px-6 text-left backdrop-blur-[1px]","aria-label":t==="zh"?"继续使用 Termdock":"Continue using Termdock",children:s.jsxs("div",{className:"max-w-[18rem] rounded-2xl border border-border/15 bg-surface/95 px-5 py-4 text-center shadow-[0_18px_50px_var(--app-shadow-strong)] backdrop-blur animate-fade-in",children:[s.jsx("div",{className:"text-[14px] font-semibold text-foreground",children:t==="zh"?"建议使用 Home":"Use Home instead"}),s.jsx("div",{className:"mt-1.5 text-[12px] leading-relaxed text-muted-foreground",children:t==="zh"?"按 Home 退后台,点任意位置继续。":"Use Home to leave. Tap anywhere to continue."}),s.jsx("div",{className:"mt-3 text-[11px] font-medium text-muted-foreground/80",children:t==="zh"?"轻点关闭提示":"Tap to dismiss"})]})}),me&&s.jsxs("div",{className:`fixed inset-x-3 bottom-4 z-toast mx-auto flex max-w-md items-center gap-2 rounded-xl border px-4 py-3 text-[12px] shadow-lg animate-fade-in ${me.tone==="success"?"border-[rgb(var(--success-rgb)_/_0.24)] bg-surface-elevated text-foreground":"border-destructive/30 bg-surface-elevated text-destructive"}`,role:me.tone==="error"?"alert":"status",children:[me.tone==="success"?s.jsx(Sc,{size:14,className:"shrink-0 text-[color:var(--success)]"}):s.jsx(Yh,{size:14,className:"shrink-0"}),s.jsx("span",{className:"min-w-0 flex-1",children:me.message}),s.jsx("button",{type:"button",onClick:()=>Gr(null),className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-muted-foreground transition hover:bg-surface-2 hover:text-foreground","aria-label":e("common.close"),children:s.jsx(Qn,{size:12})})]}),l&&s.jsxs(s.Fragment,{children:[!ir&&s.jsx(RC,{onClose:()=>h(!1)}),s.jsxs("div",{className:"fixed bottom-0 left-0 right-0 z-toast hidden max-h-48 overflow-y-auto border-t border-border/15 bg-surface p-3 animate-fade-in md:block",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("h4",{className:"ui-kicker",children:"Debug Info"}),s.jsx("button",{type:"button",onClick:()=>h(!1),className:"text-xs text-muted-foreground hover:text-foreground",children:"Close"})]}),s.jsx("pre",{className:"text-xs font-mono whitespace-pre-wrap break-all",children:JSON.stringify(q,null,2)})]})]})]}),_a=nr?null:s.jsx(z9,{className:"z-modal-panel",status:"正在恢复终端…"});return ir?s.jsxs("div",{className:"w-screen h-full flex flex-row",children:[Wi&&s.jsxs(s.Fragment,{children:[s.jsx("div",{style:{width:zt,flexShrink:0,height:"100%"},children:s.jsx(wb,{isOpen:Er,drawerWidthPx:zt,onClose:Qa,onOpen:ia,sessions:gt,activeSessionId:yt,sessionStates:sr,onNewSession:S=>To(S),recoverableTmuxSessions:lc,recoverableTmuxSessionsLoading:nn,onRefreshRecoverableTmuxSessions:()=>{fl()},onCloseRecoverableTmuxSession:zc,onCloseSession:oc,onSplitSession:Vu,onCloseSplit:S=>window.dispatchEvent(new CustomEvent("close-terminal-split",{detail:S})),onRemoveFromSplit:S=>window.dispatchEvent(new CustomEvent("remove-terminal-split-pane",{detail:S})),splitWorkspaces:it,onSetSplitLayout:ac,onReorderSplitWorkspace:Md,onRenameSplitWorkspace:Hc,onCombineSplitSessions:qu,onReorderSessions:gs,onSessionMenu:Ml,onOpenSettings:xo,onJumpToNextAttention:us.length>0?Wo:void 0,onOpenQuota:()=>ha(!0),updateState:_e,updateActionPending:re,onConfirmUpdateRestart:nt,onRetryUpdate:wt,serverHealthState:Se,tmuxAvailable:Sr.available,defaultSessionMode:Gs,pinned:!0,onTogglePinned:ws})}),s.jsx("div",{role:"separator",tabIndex:-1,className:"shrink-0 w-[5px] h-full cursor-col-resize bg-border/10 hover:bg-primary/30 active:bg-primary/50 transition-colors",onMouseDown:mo})]}),s.jsxs("div",{className:"relative flex-1 min-w-0 h-full overflow-hidden",children:[Ku,pl&&s.jsxs("div",{className:"absolute inset-y-0 right-0 z-20 flex",style:{width:cc},children:[s.jsx("div",{role:"separator",tabIndex:-1,className:"h-full w-[5px] shrink-0 cursor-col-resize bg-border/10 transition-colors hover:bg-primary/30 active:bg-primary/50",onMouseDown:go}),s.jsx("div",{style:{width:qc,flexShrink:0,height:"100%"},children:s.jsx(Ab,{isOpen:!0,sessionId:yt,drawerWidthPx:qc,onClose:po,onOpen:fo,pinned:!0,onTogglePinned:Es,rightSidebarFilePreviewOpen:kn,rightSidebarFilePreviewCloseSignal:be,onOpenRightSidebarFilePreview:Ni,onCloseRightSidebarFilePreview:Ri,rightSidebarRepoPickerOpen:Je,rightSidebarRepoPickerCloseSignal:Wt,onOpenRightSidebarRepoPicker:Pa,onCloseRightSidebarRepoPicker:mi,markdownOutlineOpen:vt,markdownOutlineCloseSignal:Qt,onOpenMarkdownOutline:dl,onCloseMarkdownOutline:Js,markdownImageLightboxOpen:Ut,markdownImageLightboxCloseSignal:pe,onOpenMarkdownImageLightbox:Fo,onCloseMarkdownImageLightbox:oa})})]})]}),s.jsx(Qb,{sessionId:yt}),_a]}):s.jsxs(s.Fragment,{children:[Ku,s.jsx(Qb,{sessionId:yt}),_a]})}const rU=Object.freeze(Object.defineProperty({__proto__:null,default:p$},Symbol.toStringTag,{value:"Module"}));export{QC as $,H0 as A,f6 as B,MO as C,id as D,Nm as E,y3 as F,jO as G,rT as H,lC as I,zs as J,v3 as K,w3 as L,cT as M,wT as N,jy as O,ST as P,eU as Q,yn as R,El as S,XL as T,_3 as U,yC as V,Vd as W,_x as X,Xm as Y,Ef as Z,Mb as _,CF as a,mO as a0,kx as a1,CE as a2,Tb as a3,Am as a4,na as a5,tU as a6,j3 as a7,rU as b,m3 as c,uA as d,lA as e,g3 as f,b3 as g,sd as h,lO as i,PA as j,QP as k,wu as l,I1 as m,fT as n,A3 as o,xT as p,T3 as q,RT as r,jT as s,BT as t,ad as u,od as v,Zh as w,C3 as x,VT as y,q0 as z};