@hienlh/ppm 0.23.8 → 0.23.9

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 (314) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/assets/skills/ppm/SKILL.md +1 -1
  3. package/assets/skills/ppm/references/cli-reference.md +4 -4
  4. package/assets/skills/ppm/references/http-api.md +1 -1
  5. package/dist/web/assets/{accounts-settings-section-BNcPvEq1.js → accounts-settings-section-hxemqOZw.js} +1 -1
  6. package/dist/web/assets/accounts-settings-section-hxemqOZw.js.br +0 -0
  7. package/dist/web/assets/accounts-settings-section-hxemqOZw.js.gz +0 -0
  8. package/dist/web/assets/{ai-resource-editor-DfVRMUHS.js → ai-resource-editor-uI76obDR.js} +1 -1
  9. package/dist/web/assets/ai-resource-editor-uI76obDR.js.br +0 -0
  10. package/dist/web/assets/ai-resource-editor-uI76obDR.js.gz +0 -0
  11. package/dist/web/assets/{ai-settings-section-Ezhw4Fef.js → ai-settings-section-Bmy9p9l-.js} +1 -1
  12. package/dist/web/assets/ai-settings-section-Bmy9p9l-.js.br +0 -0
  13. package/dist/web/assets/ai-settings-section-Bmy9p9l-.js.gz +0 -0
  14. package/dist/web/assets/{ai-settings-section-B_0-P8jx.js → ai-settings-section-CF39jnOD.js} +1 -1
  15. package/dist/web/assets/{appearance-settings-section-CPOAp0fY.js → appearance-settings-section-BCJK8_N6.js} +1 -1
  16. package/dist/web/assets/appearance-settings-section-BCJK8_N6.js.br +0 -0
  17. package/dist/web/assets/appearance-settings-section-BCJK8_N6.js.gz +0 -0
  18. package/dist/web/assets/{apps-panel-Cz7_o-M4.js → apps-panel-Dcu2wMIn.js} +1 -1
  19. package/dist/web/assets/apps-panel-Dcu2wMIn.js.br +0 -0
  20. package/dist/web/assets/apps-panel-Dcu2wMIn.js.gz +0 -0
  21. package/dist/web/assets/{branch-review-tab-BPx3kHrM.js → branch-review-tab-DEkdGqaE.js} +1 -1
  22. package/dist/web/assets/branch-review-tab-DEkdGqaE.js.br +0 -0
  23. package/dist/web/assets/branch-review-tab-DEkdGqaE.js.gz +0 -0
  24. package/dist/web/assets/{chat-tab-BadDM_j8.js → chat-tab-BVyBR3yR.js} +1 -1
  25. package/dist/web/assets/chat-tab-BVyBR3yR.js.br +5 -0
  26. package/dist/web/assets/chat-tab-BVyBR3yR.js.gz +0 -0
  27. package/dist/web/assets/{chat-tab-IqAY4c7p.js → chat-tab-Dj8kFoUi.js} +3 -3
  28. package/dist/web/assets/chat-tab-Dj8kFoUi.js.br +0 -0
  29. package/dist/web/assets/chat-tab-Dj8kFoUi.js.gz +0 -0
  30. package/dist/web/assets/{code-editor-Dmitw9QS.js → code-editor-BKpaBc8f.js} +3 -3
  31. package/dist/web/assets/code-editor-BKpaBc8f.js.br +0 -0
  32. package/dist/web/assets/code-editor-BKpaBc8f.js.gz +0 -0
  33. package/dist/web/assets/{codex-reset-credit-button-D2hal4bG.js → codex-reset-credit-button-Xt1ttURe.js} +1 -1
  34. package/dist/web/assets/codex-reset-credit-button-Xt1ttURe.js.br +0 -0
  35. package/dist/web/assets/codex-reset-credit-button-Xt1ttURe.js.gz +0 -0
  36. package/dist/web/assets/{conflict-editor-Cj_gUncw.js → conflict-editor-C9TZTGN2.js} +1 -1
  37. package/dist/web/assets/conflict-editor-C9TZTGN2.js.br +0 -0
  38. package/dist/web/assets/conflict-editor-C9TZTGN2.js.gz +0 -0
  39. package/dist/web/assets/{csv-preview-Be3ODNj0.js → csv-preview-BfX8PrGn.js} +1 -1
  40. package/dist/web/assets/csv-preview-BfX8PrGn.js.br +0 -0
  41. package/dist/web/assets/csv-preview-BfX8PrGn.js.gz +0 -0
  42. package/dist/web/assets/{database-viewer-B1b--4y8.js → database-viewer-DVHa4Mw7.js} +1 -1
  43. package/dist/web/assets/database-viewer-DVHa4Mw7.js.br +0 -0
  44. package/dist/web/assets/database-viewer-DVHa4Mw7.js.gz +0 -0
  45. package/dist/web/assets/{design-tab-8wi0IHss.js → design-tab-Dc8RIIMj.js} +1 -1
  46. package/dist/web/assets/design-tab-Dc8RIIMj.js.br +0 -0
  47. package/dist/web/assets/design-tab-Dc8RIIMj.js.gz +0 -0
  48. package/dist/web/assets/{designs-sidebar-panel-D5-1Q8zQ.js → designs-sidebar-panel-BDEgeNCO.js} +1 -1
  49. package/dist/web/assets/designs-sidebar-panel-BDEgeNCO.js.br +0 -0
  50. package/dist/web/assets/designs-sidebar-panel-BDEgeNCO.js.gz +0 -0
  51. package/dist/web/assets/{diff-viewer-Dcxk6UTG.js → diff-viewer-DYAwueSh.js} +1 -1
  52. package/dist/web/assets/diff-viewer-DYAwueSh.js.br +0 -0
  53. package/dist/web/assets/diff-viewer-DYAwueSh.js.gz +0 -0
  54. package/dist/web/assets/{editor-language-service-BVJQnTSV.js → editor-language-service-DufWCv_b.js} +1 -1
  55. package/dist/web/assets/editor-language-service-DufWCv_b.js.br +0 -0
  56. package/dist/web/assets/editor-language-service-DufWCv_b.js.gz +0 -0
  57. package/dist/web/assets/{explorer-body-CTkrlrI3.js → explorer-body-DW838S7p.js} +1 -1
  58. package/dist/web/assets/explorer-body-DW838S7p.js.br +0 -0
  59. package/dist/web/assets/explorer-body-DW838S7p.js.gz +0 -0
  60. package/dist/web/assets/{explorer-window-content-DH5AD3Ng.js → explorer-window-content-Cw4njYF9.js} +1 -1
  61. package/dist/web/assets/explorer-window-content-Cw4njYF9.js.br +0 -0
  62. package/dist/web/assets/explorer-window-content-Cw4njYF9.js.gz +0 -0
  63. package/dist/web/assets/{extension-manager-section-BJr6ccWw.js → extension-manager-section-CsudP-cF.js} +1 -1
  64. package/dist/web/assets/extension-manager-section-CsudP-cF.js.br +0 -0
  65. package/dist/web/assets/extension-manager-section-CsudP-cF.js.gz +0 -0
  66. package/dist/web/assets/{extension-webview-CYNXHd8D.js → extension-webview-BoeNtrL9.js} +1 -1
  67. package/dist/web/assets/extension-webview-BoeNtrL9.js.br +0 -0
  68. package/dist/web/assets/extension-webview-BoeNtrL9.js.gz +0 -0
  69. package/dist/web/assets/{files-settings-section-JX7o4lex.js → files-settings-section-C998uv6a.js} +1 -1
  70. package/dist/web/assets/files-settings-section-C998uv6a.js.br +0 -0
  71. package/dist/web/assets/files-settings-section-C998uv6a.js.gz +0 -0
  72. package/dist/web/assets/{general-settings-section-kF94Mz5q.js → general-settings-section-Dm0NPoo2.js} +1 -1
  73. package/dist/web/assets/general-settings-section-Dm0NPoo2.js.br +0 -0
  74. package/dist/web/assets/general-settings-section-Dm0NPoo2.js.gz +0 -0
  75. package/dist/web/assets/{git-log-panel-Crlp9ofM.js → git-log-panel-ZMLU_QWd.js} +1 -1
  76. package/dist/web/assets/git-log-panel-ZMLU_QWd.js.br +0 -0
  77. package/dist/web/assets/git-log-panel-ZMLU_QWd.js.gz +0 -0
  78. package/dist/web/assets/{glide-data-grid-O6MO5dKU.js → glide-data-grid-BuVHCdOY.js} +1 -1
  79. package/dist/web/assets/glide-data-grid-BuVHCdOY.js.br +0 -0
  80. package/dist/web/assets/glide-data-grid-BuVHCdOY.js.gz +0 -0
  81. package/dist/web/assets/{group-chat-tab-DGLSGf37.js → group-chat-tab-B2wk54Kb.js} +1 -1
  82. package/dist/web/assets/group-chat-tab-B2wk54Kb.js.br +0 -0
  83. package/dist/web/assets/group-chat-tab-B2wk54Kb.js.gz +0 -0
  84. package/dist/web/assets/{index-DQCw6d-2.js → index-D41mthBS.js} +5 -5
  85. package/dist/web/assets/index-D41mthBS.js.br +0 -0
  86. package/dist/web/assets/index-D41mthBS.js.gz +0 -0
  87. package/dist/web/assets/{jira-watcher-section-DwM7gqHT.js → jira-watcher-section-C1vWzVZJ.js} +1 -1
  88. package/dist/web/assets/{keybindings-store-CJtEHFIQ.js → keybindings-store-XUcWE5_j.js} +1 -1
  89. package/dist/web/assets/{keyboard-shortcuts-section-CewWGwiF.js → keyboard-shortcuts-section-CDYzFVbt.js} +1 -1
  90. package/dist/web/assets/keyboard-shortcuts-section-CDYzFVbt.js.br +0 -0
  91. package/dist/web/assets/keyboard-shortcuts-section-CDYzFVbt.js.gz +0 -0
  92. package/dist/web/assets/{language-servers-section-nricdxke.js → language-servers-section-DQH0qqem.js} +2 -2
  93. package/dist/web/assets/language-servers-section-DQH0qqem.js.br +0 -0
  94. package/dist/web/assets/language-servers-section-DQH0qqem.js.gz +0 -0
  95. package/dist/web/assets/{lsp-client-DRMEWb-z.js → lsp-client-Ce_E8lQ7.js} +1 -1
  96. package/dist/web/assets/lsp-client-Ce_E8lQ7.js.br +0 -0
  97. package/dist/web/assets/lsp-client-Ce_E8lQ7.js.gz +0 -0
  98. package/dist/web/assets/{markdown-renderer-Dab9Us6u.js → markdown-renderer-C9inQ_Z3.js} +1 -1
  99. package/dist/web/assets/markdown-renderer-C9inQ_Z3.js.br +0 -0
  100. package/dist/web/assets/markdown-renderer-C9inQ_Z3.js.gz +0 -0
  101. package/dist/web/assets/{markdown-renderer-D5-xliE9.js → markdown-renderer-CS193h6D.js} +1 -1
  102. package/dist/web/assets/{mobile-explorer-sheet-DtgdpvJ9.js → mobile-explorer-sheet-Dp5-b059.js} +1 -1
  103. package/dist/web/assets/mobile-explorer-sheet-Dp5-b059.js.br +0 -0
  104. package/dist/web/assets/mobile-explorer-sheet-Dp5-b059.js.gz +0 -0
  105. package/dist/web/assets/{new-design-dialog-Dd5KDB_p.js → new-design-dialog-Bw3xciYg.js} +1 -1
  106. package/dist/web/assets/new-design-dialog-Bw3xciYg.js.br +0 -0
  107. package/dist/web/assets/new-design-dialog-Bw3xciYg.js.gz +0 -0
  108. package/dist/web/assets/{notification-store-D2vTyp_Q.js → notification-store-3PN0fYtT.js} +1 -1
  109. package/dist/web/assets/{performance-panel-LMGefOQ2.js → performance-panel-Bl3RwJGZ.js} +1 -1
  110. package/dist/web/assets/performance-panel-Bl3RwJGZ.js.br +0 -0
  111. package/dist/web/assets/performance-panel-Bl3RwJGZ.js.gz +0 -0
  112. package/dist/web/assets/{ppmbot-settings-section-D67u6gPi.js → ppmbot-settings-section-BtKmsfqX.js} +1 -1
  113. package/dist/web/assets/ppmbot-settings-section-BtKmsfqX.js.br +0 -0
  114. package/dist/web/assets/ppmbot-settings-section-BtKmsfqX.js.gz +0 -0
  115. package/dist/web/assets/{problems-panel-DKgIw4uZ.js → problems-panel-dzNhRTnM.js} +1 -1
  116. package/dist/web/assets/problems-panel-dzNhRTnM.js.br +0 -0
  117. package/dist/web/assets/problems-panel-dzNhRTnM.js.gz +0 -0
  118. package/dist/web/assets/{process-table-BIAgC_jG.js → process-table-B9rXN1NM.js} +1 -1
  119. package/dist/web/assets/process-table-B9rXN1NM.js.br +0 -0
  120. package/dist/web/assets/process-table-B9rXN1NM.js.gz +0 -0
  121. package/dist/web/assets/{proxy-settings-section-CFiYcTBA.js → proxy-settings-section-BAFgwYyD.js} +1 -1
  122. package/dist/web/assets/proxy-settings-section-BAFgwYyD.js.br +0 -0
  123. package/dist/web/assets/proxy-settings-section-BAFgwYyD.js.gz +0 -0
  124. package/dist/web/assets/{remote-desktop-clipboard-notice-Bs3fZSRw.js → remote-desktop-clipboard-notice-C6tt5SDH.js} +1 -1
  125. package/dist/web/assets/remote-desktop-clipboard-notice-C6tt5SDH.js.br +0 -0
  126. package/dist/web/assets/remote-desktop-clipboard-notice-C6tt5SDH.js.gz +0 -0
  127. package/dist/web/assets/{remote-desktop-mobile-sheet-DgxTdWMh.js → remote-desktop-mobile-sheet-C6gFMzXV.js} +2 -2
  128. package/dist/web/assets/remote-desktop-mobile-sheet-C6gFMzXV.js.br +0 -0
  129. package/dist/web/assets/remote-desktop-mobile-sheet-C6gFMzXV.js.gz +0 -0
  130. package/dist/web/assets/{remote-desktop-mobile-view-DgGOfPVY.js → remote-desktop-mobile-view-kD5Q339l.js} +1 -1
  131. package/dist/web/assets/remote-desktop-mobile-view-kD5Q339l.js.br +0 -0
  132. package/dist/web/assets/remote-desktop-mobile-view-kD5Q339l.js.gz +0 -0
  133. package/dist/web/assets/{remote-desktop-readiness-gate-DOWryrQx.js → remote-desktop-readiness-gate-CqnG8BlK.js} +1 -1
  134. package/dist/web/assets/remote-desktop-readiness-gate-CqnG8BlK.js.br +0 -0
  135. package/dist/web/assets/remote-desktop-readiness-gate-CqnG8BlK.js.gz +0 -0
  136. package/dist/web/assets/{remote-desktop-window-content-7t0wQsHx.js → remote-desktop-window-content-BjZdvaQX.js} +1 -1
  137. package/dist/web/assets/remote-desktop-window-content-BjZdvaQX.js.br +0 -0
  138. package/dist/web/assets/remote-desktop-window-content-BjZdvaQX.js.gz +0 -0
  139. package/dist/web/assets/{schedules-settings-section-DGhG-b5O.js → schedules-settings-section-BrsGPl6j.js} +1 -1
  140. package/dist/web/assets/schedules-settings-section-BrsGPl6j.js.br +0 -0
  141. package/dist/web/assets/schedules-settings-section-BrsGPl6j.js.gz +0 -0
  142. package/dist/web/assets/{services-panel-0klE3O4g.js → services-panel-mDvWNRkg.js} +1 -1
  143. package/dist/web/assets/services-panel-mDvWNRkg.js.br +0 -0
  144. package/dist/web/assets/services-panel-mDvWNRkg.js.gz +0 -0
  145. package/dist/web/assets/{settings-body-CfqpqFfq.js → settings-body-DJKHimA7.js} +2 -2
  146. package/dist/web/assets/settings-body-DJKHimA7.js.br +0 -0
  147. package/dist/web/assets/settings-body-DJKHimA7.js.gz +0 -0
  148. package/dist/web/assets/{settings-tab-CHweH5Nh.js → settings-tab-DyLehsVr.js} +1 -1
  149. package/dist/web/assets/{settings-window-content-C6Od3qV7.js → settings-window-content-BMbDb3BQ.js} +1 -1
  150. package/dist/web/assets/{sql-query-editor-ALQ5_X0j.js → sql-query-editor-Ci0vTqmC.js} +1 -1
  151. package/dist/web/assets/sql-query-editor-Ci0vTqmC.js.br +0 -0
  152. package/dist/web/assets/sql-query-editor-Ci0vTqmC.js.gz +0 -0
  153. package/dist/web/assets/{sqlite-viewer-DKTty_jR.js → sqlite-viewer-kOyrMUsW.js} +1 -1
  154. package/dist/web/assets/sqlite-viewer-kOyrMUsW.js.br +0 -0
  155. package/dist/web/assets/sqlite-viewer-kOyrMUsW.js.gz +0 -0
  156. package/dist/web/assets/{system-monitor-body-D6J6lq7-.js → system-monitor-body-D1lzquYw.js} +2 -2
  157. package/dist/web/assets/system-monitor-body-D1lzquYw.js.br +0 -0
  158. package/dist/web/assets/system-monitor-body-D1lzquYw.js.gz +0 -0
  159. package/dist/web/assets/{system-monitor-tab-Di18zNNS.js → system-monitor-tab-anJ6hmrA.js} +1 -1
  160. package/dist/web/assets/{system-monitor-window-content-D1t30f32.js → system-monitor-window-content-BcV01XgX.js} +1 -1
  161. package/dist/web/assets/{tab-host-window-content-DTcx2D0O.js → tab-host-window-content-4kbVMd0b.js} +1 -1
  162. package/dist/web/assets/tab-host-window-content-4kbVMd0b.js.br +0 -0
  163. package/dist/web/assets/tab-host-window-content-4kbVMd0b.js.gz +0 -0
  164. package/dist/web/assets/{team-member-sheet-CFSbPG6n.js → team-member-sheet-K3MMar1L.js} +2 -2
  165. package/dist/web/assets/team-member-sheet-K3MMar1L.js.br +0 -0
  166. package/dist/web/assets/team-member-sheet-K3MMar1L.js.gz +0 -0
  167. package/dist/web/assets/{team-member-window-content-VeI6DGeM.js → team-member-window-content-DidC04eW.js} +1 -1
  168. package/dist/web/assets/team-member-window-content-DidC04eW.js.br +0 -0
  169. package/dist/web/assets/team-member-window-content-DidC04eW.js.gz +0 -0
  170. package/dist/web/assets/{terminal-tab-DgTfQKBI.js → terminal-tab-BlYiIu9A.js} +1 -1
  171. package/dist/web/assets/terminal-tab-BlYiIu9A.js.br +0 -0
  172. package/dist/web/assets/terminal-tab-BlYiIu9A.js.gz +0 -0
  173. package/dist/web/assets/{tool-cards-_fpYI1hB.js → tool-cards-BoW8_vQb.js} +2 -2
  174. package/dist/web/assets/tool-cards-BoW8_vQb.js.br +0 -0
  175. package/dist/web/assets/tool-cards-BoW8_vQb.js.gz +0 -0
  176. package/dist/web/assets/{use-inline-blame-Dv111BKY.js → use-inline-blame-I6_SHzP0.js} +1 -1
  177. package/dist/web/assets/use-inline-blame-I6_SHzP0.js.br +0 -0
  178. package/dist/web/assets/use-inline-blame-I6_SHzP0.js.gz +0 -0
  179. package/dist/web/assets/{use-lsp-CZTFJIXX.js → use-lsp-D6skvdIp.js} +1 -1
  180. package/dist/web/assets/use-lsp-D6skvdIp.js.br +0 -0
  181. package/dist/web/assets/use-lsp-D6skvdIp.js.gz +0 -0
  182. package/dist/web/assets/{use-monaco-theme-DL2dIG5L.js → use-monaco-theme-08OELBic.js} +1 -1
  183. package/dist/web/assets/{use-process-kill-D7D9QvJG.js → use-process-kill-4gRMygIV.js} +1 -1
  184. package/dist/web/assets/use-process-kill-4gRMygIV.js.br +0 -0
  185. package/dist/web/assets/use-process-kill-4gRMygIV.js.gz +0 -0
  186. package/dist/web/assets/{use-websocket-ziY-Gz_B.js → use-websocket-C1dxvoVt.js} +1 -1
  187. package/dist/web/assets/{video-preview-DzwY3q9W.js → video-preview-08dogvSP.js} +1 -1
  188. package/dist/web/assets/video-preview-08dogvSP.js.br +0 -0
  189. package/dist/web/assets/video-preview-08dogvSP.js.gz +0 -0
  190. package/dist/web/index.html +1 -1
  191. package/dist/web/index.html.br +0 -0
  192. package/dist/web/index.html.gz +0 -0
  193. package/dist/web/sw.js +1 -1
  194. package/dist/web/sw.js.br +0 -0
  195. package/dist/web/sw.js.gz +0 -0
  196. package/package.json +1 -1
  197. package/src/server/routes/chat.ts +12 -4
  198. package/src/web/components/chat/codex-usage-panel.tsx +26 -8
  199. package/dist/web/assets/accounts-settings-section-BNcPvEq1.js.br +0 -0
  200. package/dist/web/assets/accounts-settings-section-BNcPvEq1.js.gz +0 -0
  201. package/dist/web/assets/ai-resource-editor-DfVRMUHS.js.br +0 -0
  202. package/dist/web/assets/ai-resource-editor-DfVRMUHS.js.gz +0 -0
  203. package/dist/web/assets/ai-settings-section-Ezhw4Fef.js.br +0 -0
  204. package/dist/web/assets/ai-settings-section-Ezhw4Fef.js.gz +0 -0
  205. package/dist/web/assets/appearance-settings-section-CPOAp0fY.js.br +0 -0
  206. package/dist/web/assets/appearance-settings-section-CPOAp0fY.js.gz +0 -0
  207. package/dist/web/assets/apps-panel-Cz7_o-M4.js.br +0 -0
  208. package/dist/web/assets/apps-panel-Cz7_o-M4.js.gz +0 -0
  209. package/dist/web/assets/branch-review-tab-BPx3kHrM.js.br +0 -0
  210. package/dist/web/assets/branch-review-tab-BPx3kHrM.js.gz +0 -0
  211. package/dist/web/assets/chat-tab-BadDM_j8.js.br +0 -0
  212. package/dist/web/assets/chat-tab-BadDM_j8.js.gz +0 -0
  213. package/dist/web/assets/chat-tab-IqAY4c7p.js.br +0 -0
  214. package/dist/web/assets/chat-tab-IqAY4c7p.js.gz +0 -0
  215. package/dist/web/assets/code-editor-Dmitw9QS.js.br +0 -0
  216. package/dist/web/assets/code-editor-Dmitw9QS.js.gz +0 -0
  217. package/dist/web/assets/codex-reset-credit-button-D2hal4bG.js.br +0 -0
  218. package/dist/web/assets/codex-reset-credit-button-D2hal4bG.js.gz +0 -0
  219. package/dist/web/assets/conflict-editor-Cj_gUncw.js.br +0 -0
  220. package/dist/web/assets/conflict-editor-Cj_gUncw.js.gz +0 -0
  221. package/dist/web/assets/csv-preview-Be3ODNj0.js.br +0 -0
  222. package/dist/web/assets/csv-preview-Be3ODNj0.js.gz +0 -0
  223. package/dist/web/assets/database-viewer-B1b--4y8.js.br +0 -0
  224. package/dist/web/assets/database-viewer-B1b--4y8.js.gz +0 -0
  225. package/dist/web/assets/design-tab-8wi0IHss.js.br +0 -0
  226. package/dist/web/assets/design-tab-8wi0IHss.js.gz +0 -0
  227. package/dist/web/assets/designs-sidebar-panel-D5-1Q8zQ.js.br +0 -0
  228. package/dist/web/assets/designs-sidebar-panel-D5-1Q8zQ.js.gz +0 -0
  229. package/dist/web/assets/diff-viewer-Dcxk6UTG.js.br +0 -0
  230. package/dist/web/assets/diff-viewer-Dcxk6UTG.js.gz +0 -0
  231. package/dist/web/assets/editor-language-service-BVJQnTSV.js.br +0 -0
  232. package/dist/web/assets/editor-language-service-BVJQnTSV.js.gz +0 -0
  233. package/dist/web/assets/explorer-body-CTkrlrI3.js.br +0 -0
  234. package/dist/web/assets/explorer-body-CTkrlrI3.js.gz +0 -0
  235. package/dist/web/assets/explorer-window-content-DH5AD3Ng.js.br +0 -0
  236. package/dist/web/assets/explorer-window-content-DH5AD3Ng.js.gz +0 -0
  237. package/dist/web/assets/extension-manager-section-BJr6ccWw.js.br +0 -0
  238. package/dist/web/assets/extension-manager-section-BJr6ccWw.js.gz +0 -0
  239. package/dist/web/assets/extension-webview-CYNXHd8D.js.br +0 -0
  240. package/dist/web/assets/extension-webview-CYNXHd8D.js.gz +0 -0
  241. package/dist/web/assets/files-settings-section-JX7o4lex.js.br +0 -0
  242. package/dist/web/assets/files-settings-section-JX7o4lex.js.gz +0 -0
  243. package/dist/web/assets/general-settings-section-kF94Mz5q.js.br +0 -0
  244. package/dist/web/assets/general-settings-section-kF94Mz5q.js.gz +0 -0
  245. package/dist/web/assets/git-log-panel-Crlp9ofM.js.br +0 -0
  246. package/dist/web/assets/git-log-panel-Crlp9ofM.js.gz +0 -0
  247. package/dist/web/assets/glide-data-grid-O6MO5dKU.js.br +0 -0
  248. package/dist/web/assets/glide-data-grid-O6MO5dKU.js.gz +0 -0
  249. package/dist/web/assets/group-chat-tab-DGLSGf37.js.br +0 -0
  250. package/dist/web/assets/group-chat-tab-DGLSGf37.js.gz +0 -0
  251. package/dist/web/assets/index-DQCw6d-2.js.br +0 -0
  252. package/dist/web/assets/index-DQCw6d-2.js.gz +0 -0
  253. package/dist/web/assets/keyboard-shortcuts-section-CewWGwiF.js.br +0 -0
  254. package/dist/web/assets/keyboard-shortcuts-section-CewWGwiF.js.gz +0 -0
  255. package/dist/web/assets/language-servers-section-nricdxke.js.br +0 -0
  256. package/dist/web/assets/language-servers-section-nricdxke.js.gz +0 -0
  257. package/dist/web/assets/lsp-client-DRMEWb-z.js.br +0 -0
  258. package/dist/web/assets/lsp-client-DRMEWb-z.js.gz +0 -0
  259. package/dist/web/assets/markdown-renderer-Dab9Us6u.js.br +0 -0
  260. package/dist/web/assets/markdown-renderer-Dab9Us6u.js.gz +0 -0
  261. package/dist/web/assets/mobile-explorer-sheet-DtgdpvJ9.js.br +0 -0
  262. package/dist/web/assets/mobile-explorer-sheet-DtgdpvJ9.js.gz +0 -0
  263. package/dist/web/assets/new-design-dialog-Dd5KDB_p.js.br +0 -0
  264. package/dist/web/assets/new-design-dialog-Dd5KDB_p.js.gz +0 -0
  265. package/dist/web/assets/performance-panel-LMGefOQ2.js.br +0 -0
  266. package/dist/web/assets/performance-panel-LMGefOQ2.js.gz +0 -0
  267. package/dist/web/assets/ppmbot-settings-section-D67u6gPi.js.br +0 -0
  268. package/dist/web/assets/ppmbot-settings-section-D67u6gPi.js.gz +0 -0
  269. package/dist/web/assets/problems-panel-DKgIw4uZ.js.br +0 -0
  270. package/dist/web/assets/problems-panel-DKgIw4uZ.js.gz +0 -0
  271. package/dist/web/assets/process-table-BIAgC_jG.js.br +0 -0
  272. package/dist/web/assets/process-table-BIAgC_jG.js.gz +0 -0
  273. package/dist/web/assets/proxy-settings-section-CFiYcTBA.js.br +0 -0
  274. package/dist/web/assets/proxy-settings-section-CFiYcTBA.js.gz +0 -0
  275. package/dist/web/assets/remote-desktop-clipboard-notice-Bs3fZSRw.js.br +0 -0
  276. package/dist/web/assets/remote-desktop-clipboard-notice-Bs3fZSRw.js.gz +0 -0
  277. package/dist/web/assets/remote-desktop-mobile-sheet-DgxTdWMh.js.br +0 -0
  278. package/dist/web/assets/remote-desktop-mobile-sheet-DgxTdWMh.js.gz +0 -0
  279. package/dist/web/assets/remote-desktop-mobile-view-DgGOfPVY.js.br +0 -0
  280. package/dist/web/assets/remote-desktop-mobile-view-DgGOfPVY.js.gz +0 -0
  281. package/dist/web/assets/remote-desktop-readiness-gate-DOWryrQx.js.br +0 -0
  282. package/dist/web/assets/remote-desktop-readiness-gate-DOWryrQx.js.gz +0 -0
  283. package/dist/web/assets/remote-desktop-window-content-7t0wQsHx.js.br +0 -0
  284. package/dist/web/assets/remote-desktop-window-content-7t0wQsHx.js.gz +0 -0
  285. package/dist/web/assets/schedules-settings-section-DGhG-b5O.js.br +0 -0
  286. package/dist/web/assets/schedules-settings-section-DGhG-b5O.js.gz +0 -0
  287. package/dist/web/assets/services-panel-0klE3O4g.js.br +0 -0
  288. package/dist/web/assets/services-panel-0klE3O4g.js.gz +0 -0
  289. package/dist/web/assets/settings-body-CfqpqFfq.js.br +0 -0
  290. package/dist/web/assets/settings-body-CfqpqFfq.js.gz +0 -0
  291. package/dist/web/assets/sql-query-editor-ALQ5_X0j.js.br +0 -0
  292. package/dist/web/assets/sql-query-editor-ALQ5_X0j.js.gz +0 -0
  293. package/dist/web/assets/sqlite-viewer-DKTty_jR.js.br +0 -0
  294. package/dist/web/assets/sqlite-viewer-DKTty_jR.js.gz +0 -0
  295. package/dist/web/assets/system-monitor-body-D6J6lq7-.js.br +0 -0
  296. package/dist/web/assets/system-monitor-body-D6J6lq7-.js.gz +0 -0
  297. package/dist/web/assets/tab-host-window-content-DTcx2D0O.js.br +0 -0
  298. package/dist/web/assets/tab-host-window-content-DTcx2D0O.js.gz +0 -0
  299. package/dist/web/assets/team-member-sheet-CFSbPG6n.js.br +0 -0
  300. package/dist/web/assets/team-member-sheet-CFSbPG6n.js.gz +0 -0
  301. package/dist/web/assets/team-member-window-content-VeI6DGeM.js.br +0 -0
  302. package/dist/web/assets/team-member-window-content-VeI6DGeM.js.gz +0 -0
  303. package/dist/web/assets/terminal-tab-DgTfQKBI.js.br +0 -0
  304. package/dist/web/assets/terminal-tab-DgTfQKBI.js.gz +0 -0
  305. package/dist/web/assets/tool-cards-_fpYI1hB.js.br +0 -0
  306. package/dist/web/assets/tool-cards-_fpYI1hB.js.gz +0 -0
  307. package/dist/web/assets/use-inline-blame-Dv111BKY.js.br +0 -0
  308. package/dist/web/assets/use-inline-blame-Dv111BKY.js.gz +0 -0
  309. package/dist/web/assets/use-lsp-CZTFJIXX.js.br +0 -0
  310. package/dist/web/assets/use-lsp-CZTFJIXX.js.gz +0 -0
  311. package/dist/web/assets/use-process-kill-D7D9QvJG.js.br +0 -0
  312. package/dist/web/assets/use-process-kill-D7D9QvJG.js.gz +0 -0
  313. package/dist/web/assets/video-preview-DzwY3q9W.js.br +0 -0
  314. package/dist/web/assets/video-preview-DzwY3q9W.js.gz +0 -0
@@ -1 +1 @@
1
- import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import"./vendor-ui-P9Ym7hCv.js";import"./icons-CO_II6D-.js";import{t as r}from"./explorer-body-CTkrlrI3.js";import"./api-client-F5Zi1sR0.js";import"./settings-store-3jIBB8gx.js";import"./portal-container-context-NFSuymMu.js";import"./panel-store-DrSH3Nhp.js";import"./window-store-B4cbZ5rr.js";import"./project-store-CCimwgGF.js";import"./tab-store-CUPgQIQz.js";import"./context-menu-CH1mvCwA.js";import"./file-store-DCU7_YyB.js";import"./use-is-mobile-CkO33jqU.js";import"./window-pip-registry-dxrBFfkP.js";import"./button-CsmGH5xa.js";import"./dialog-z8PLkL8n.js";import"./file-icons-Ed_yLyef.js";import{t as i}from"./mobile-bottom-sheet-CLic9ovp.js";import"./use-visual-viewport-C307OVeV.js";import"./fs-api-vF_bQoeL.js";import"./format-file-meta-B0ZpqzSM.js";import{Gt as a,Wt as o,nn as s}from"./index-DQCw6d-2.js";var c=e(t(),1),l=n();function u(){let e=a(e=>e.isOpen),t=a(e=>e.close),n=a(e=>e.setSelectMode),u=s(e=>e.slices[o]?.path),d=s(e=>e.slices[o]?.inlineEdit?.kind===`rename`);(0,c.useEffect)(()=>{n(!1)},[u,n]);let f=e=>{d&&e.stopPropagation()};return e?(0,l.jsx)(i,{open:e,onClose:t,zIndex:45,className:`flex h-[var(--sheet-vh)] flex-col p-0`,children:(0,l.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,onTouchStart:f,onTouchMove:f,children:u?(0,l.jsx)(r,{windowId:o,initialPath:u,variant:`sheet`}):(0,l.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-text-2`,children:`Loading…`})})}):null}export{u as MobileExplorerSheet};
1
+ import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import"./vendor-ui-P9Ym7hCv.js";import"./icons-CO_II6D-.js";import{t as r}from"./explorer-body-DW838S7p.js";import"./api-client-F5Zi1sR0.js";import"./settings-store-3jIBB8gx.js";import"./portal-container-context-NFSuymMu.js";import"./panel-store-DrSH3Nhp.js";import"./window-store-B4cbZ5rr.js";import"./project-store-CCimwgGF.js";import"./tab-store-CUPgQIQz.js";import"./context-menu-CH1mvCwA.js";import"./file-store-DCU7_YyB.js";import"./use-is-mobile-CkO33jqU.js";import"./window-pip-registry-dxrBFfkP.js";import"./button-CsmGH5xa.js";import"./dialog-z8PLkL8n.js";import"./file-icons-Ed_yLyef.js";import{t as i}from"./mobile-bottom-sheet-CLic9ovp.js";import"./use-visual-viewport-C307OVeV.js";import"./fs-api-vF_bQoeL.js";import"./format-file-meta-B0ZpqzSM.js";import{Gt as a,Wt as o,nn as s}from"./index-D41mthBS.js";var c=e(t(),1),l=n();function u(){let e=a(e=>e.isOpen),t=a(e=>e.close),n=a(e=>e.setSelectMode),u=s(e=>e.slices[o]?.path),d=s(e=>e.slices[o]?.inlineEdit?.kind===`rename`);(0,c.useEffect)(()=>{n(!1)},[u,n]);let f=e=>{d&&e.stopPropagation()};return e?(0,l.jsx)(i,{open:e,onClose:t,zIndex:45,className:`flex h-[var(--sheet-vh)] flex-col p-0`,children:(0,l.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,onTouchStart:f,onTouchMove:f,children:u?(0,l.jsx)(r,{windowId:o,initialPath:u,variant:`sheet`}):(0,l.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-text-2`,children:`Loading…`})})}):null}export{u as MobileExplorerSheet};
@@ -1 +1 @@
1
- import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import"./vendor-ui-P9Ym7hCv.js";import{$n as r,pt as i,un as a}from"./icons-CO_II6D-.js";import"./api-client-F5Zi1sR0.js";import{n as o}from"./utils-btZ8C8-R.js";import"./portal-container-context-NFSuymMu.js";import{p as s}from"./panel-store-DrSH3Nhp.js";import"./window-store-B4cbZ5rr.js";import"./project-store-CCimwgGF.js";import"./chat-preparation-cache-DoS7sdal.js";import"./use-is-mobile-CkO33jqU.js";import{t as c}from"./button-CsmGH5xa.js";import"./dialog-z8PLkL8n.js";import"./mobile-bottom-sheet-CLic9ovp.js";import"./use-visual-viewport-C307OVeV.js";import{An as l,a as u,d,s as f}from"./index-DQCw6d-2.js";import{a as p}from"./api-settings-BeINN5Dy.js";import{t as m}from"./design-responsive-dialog-BhyR-zhE.js";var h=e(t(),1),g=n(),_=120,v=[{id:`page`,label:`Page`,hint:`A page, screen or prototype`,icon:i},{id:`slides`,label:`Slides`,hint:`A 1280×720 slide deck`,icon:r}];function y({projectName:e,onClose:t}){let[n,r]=(0,h.useState)(``),[i,y]=(0,h.useState)(`page`),[b,x]=(0,h.useState)(null),[S,C]=(0,h.useState)(``),[w,T]=(0,h.useState)(null),[E,D]=(0,h.useState)(!1);(0,h.useEffect)(()=>{let t=!1;return Promise.all([d(e),p().catch(()=>null)]).then(([e,n])=>{if(t)return;x(e);let r=n?s(n):void 0;C((e.find(e=>e.id===r)??e[0])?.id??``)}).catch(e=>{t||(x([]),T(e.message||`Could not load providers`))}),()=>{t=!0}},[e]);let O=n.trim(),k=!!O&&!!S&&!E,A=async()=>{if(k){D(!0),T(null);try{let n=await f(e,{title:O,kind:i});u(e),l({projectName:e,slug:n.slug,title:n.title,providerId:S,fresh:!0}),t()}catch(e){T(e.message||`Could not create the design`),D(!1)}}};return(0,g.jsx)(m,{open:!0,onClose:()=>{E||t()},title:`New design`,description:`The AI builds it in designs/ in this project, with a live preview beside the chat.`,footer:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(c,{variant:`outline`,onClick:t,disabled:E,children:`Cancel`}),(0,g.jsxs)(c,{onClick:A,disabled:!k,children:[E&&(0,g.jsx)(a,{className:`size-4 animate-spin`}),` Create`]})]}),children:(0,g.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),A()},children:[(0,g.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-text-secondary`,children:[`Title`,(0,g.jsx)(`input`,{autoFocus:!0,value:n,maxLength:_,onChange:e=>r(e.target.value),placeholder:`e.g. Pricing page`,className:`min-h-11 w-full rounded-md border border-border bg-background px-3 text-sm text-foreground placeholder:text-text-subtle focus:outline-none focus:ring-1 focus:ring-primary md:min-h-9`})]}),(0,g.jsx)(`div`,{role:`radiogroup`,"aria-label":`Kind`,className:`grid grid-cols-2 gap-2`,children:v.map(e=>(0,g.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":i===e.id,onClick:()=>y(e.id),className:o(`flex min-h-14 flex-col items-start gap-0.5 rounded-md border p-2 text-left`,i===e.id?`border-primary`:`border-border`),children:[(0,g.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[(0,g.jsx)(e.icon,{className:`size-4`}),` `,e.label]}),(0,g.jsx)(`span`,{className:`text-xs text-text-subtle`,children:e.hint})]},e.id))}),(0,g.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-text-secondary`,children:[`AI provider`,b===null?(0,g.jsxs)(`span`,{className:`flex min-h-11 items-center gap-2 text-sm text-text-subtle`,children:[(0,g.jsx)(a,{className:`size-4 animate-spin`}),` Loading…`]}):b.length===0?(0,g.jsx)(`span`,{className:`text-sm text-text-subtle`,children:`No configured provider can run design sessions. Enable Claude or Codex in Settings.`}):(0,g.jsx)(`select`,{value:S,onChange:e=>C(e.target.value),className:`min-h-11 w-full rounded-md border border-border bg-background px-2 text-sm text-foreground md:min-h-9`,children:b.map(e=>(0,g.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),w&&(0,g.jsx)(`p`,{className:`text-xs text-destructive`,role:`alert`,children:w})]})})}export{y as NewDesignDialog};
1
+ import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import"./vendor-ui-P9Ym7hCv.js";import{$n as r,pt as i,un as a}from"./icons-CO_II6D-.js";import"./api-client-F5Zi1sR0.js";import{n as o}from"./utils-btZ8C8-R.js";import"./portal-container-context-NFSuymMu.js";import{p as s}from"./panel-store-DrSH3Nhp.js";import"./window-store-B4cbZ5rr.js";import"./project-store-CCimwgGF.js";import"./chat-preparation-cache-DoS7sdal.js";import"./use-is-mobile-CkO33jqU.js";import{t as c}from"./button-CsmGH5xa.js";import"./dialog-z8PLkL8n.js";import"./mobile-bottom-sheet-CLic9ovp.js";import"./use-visual-viewport-C307OVeV.js";import{An as l,a as u,d,s as f}from"./index-D41mthBS.js";import{a as p}from"./api-settings-BeINN5Dy.js";import{t as m}from"./design-responsive-dialog-BhyR-zhE.js";var h=e(t(),1),g=n(),_=120,v=[{id:`page`,label:`Page`,hint:`A page, screen or prototype`,icon:i},{id:`slides`,label:`Slides`,hint:`A 1280×720 slide deck`,icon:r}];function y({projectName:e,onClose:t}){let[n,r]=(0,h.useState)(``),[i,y]=(0,h.useState)(`page`),[b,x]=(0,h.useState)(null),[S,C]=(0,h.useState)(``),[w,T]=(0,h.useState)(null),[E,D]=(0,h.useState)(!1);(0,h.useEffect)(()=>{let t=!1;return Promise.all([d(e),p().catch(()=>null)]).then(([e,n])=>{if(t)return;x(e);let r=n?s(n):void 0;C((e.find(e=>e.id===r)??e[0])?.id??``)}).catch(e=>{t||(x([]),T(e.message||`Could not load providers`))}),()=>{t=!0}},[e]);let O=n.trim(),k=!!O&&!!S&&!E,A=async()=>{if(k){D(!0),T(null);try{let n=await f(e,{title:O,kind:i});u(e),l({projectName:e,slug:n.slug,title:n.title,providerId:S,fresh:!0}),t()}catch(e){T(e.message||`Could not create the design`),D(!1)}}};return(0,g.jsx)(m,{open:!0,onClose:()=>{E||t()},title:`New design`,description:`The AI builds it in designs/ in this project, with a live preview beside the chat.`,footer:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(c,{variant:`outline`,onClick:t,disabled:E,children:`Cancel`}),(0,g.jsxs)(c,{onClick:A,disabled:!k,children:[E&&(0,g.jsx)(a,{className:`size-4 animate-spin`}),` Create`]})]}),children:(0,g.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),A()},children:[(0,g.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-text-secondary`,children:[`Title`,(0,g.jsx)(`input`,{autoFocus:!0,value:n,maxLength:_,onChange:e=>r(e.target.value),placeholder:`e.g. Pricing page`,className:`min-h-11 w-full rounded-md border border-border bg-background px-3 text-sm text-foreground placeholder:text-text-subtle focus:outline-none focus:ring-1 focus:ring-primary md:min-h-9`})]}),(0,g.jsx)(`div`,{role:`radiogroup`,"aria-label":`Kind`,className:`grid grid-cols-2 gap-2`,children:v.map(e=>(0,g.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":i===e.id,onClick:()=>y(e.id),className:o(`flex min-h-14 flex-col items-start gap-0.5 rounded-md border p-2 text-left`,i===e.id?`border-primary`:`border-border`),children:[(0,g.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[(0,g.jsx)(e.icon,{className:`size-4`}),` `,e.label]}),(0,g.jsx)(`span`,{className:`text-xs text-text-subtle`,children:e.hint})]},e.id))}),(0,g.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-text-secondary`,children:[`AI provider`,b===null?(0,g.jsxs)(`span`,{className:`flex min-h-11 items-center gap-2 text-sm text-text-subtle`,children:[(0,g.jsx)(a,{className:`size-4 animate-spin`}),` Loading…`]}):b.length===0?(0,g.jsx)(`span`,{className:`text-sm text-text-subtle`,children:`No configured provider can run design sessions. Enable Claude or Codex in Settings.`}):(0,g.jsx)(`select`,{value:S,onChange:e=>C(e.target.value),className:`min-h-11 w-full rounded-md border border-border bg-background px-2 text-sm text-foreground md:min-h-9`,children:b.map(e=>(0,g.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),w&&(0,g.jsx)(`p`,{className:`text-xs text-destructive`,role:`alert`,children:w})]})})}export{y as NewDesignDialog};
@@ -1 +1 @@
1
- import"./vendor-markdown-QKPNiWEd.js";import"./vendor-ui-P9Ym7hCv.js";import"./api-client-F5Zi1sR0.js";import{or as e}from"./index-DQCw6d-2.js";export{e as useNotificationStore};
1
+ import"./vendor-markdown-QKPNiWEd.js";import"./vendor-ui-P9Ym7hCv.js";import"./api-client-F5Zi1sR0.js";import{or as e}from"./index-D41mthBS.js";export{e as useNotificationStore};
@@ -1,3 +1,3 @@
1
- import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import"./vendor-ui-P9Ym7hCv.js";import{$t as r,A as i,Bt as a,En as o,Gr as s,j as c,rt as l,t as u}from"./icons-CO_II6D-.js";import{r as d}from"./api-client-F5Zi1sR0.js";import{_ as f,b as p,g as m,h,t as g,v as _,x as v,y}from"./settings-store-3jIBB8gx.js";import{n as b}from"./utils-btZ8C8-R.js";import"./portal-container-context-NFSuymMu.js";import"./context-menu-CH1mvCwA.js";import{n as x}from"./use-is-mobile-CkO33jqU.js";import"./mobile-bottom-sheet-CLic9ovp.js";import"./use-visual-viewport-C307OVeV.js";import{an as S,cn as C,dn as w,fn as T,ln as E,mn as D,on as O,pn as k,sn as ee,un as te}from"./index-DQCw6d-2.js";import{n as A,r as j,t as M}from"./format-bytes-DZ8bW_uF.js";import{n as N,t as P}from"./metric-chart-canvas-CVd7LO3m.js";var F=e(t(),1),I={wired:`Ethernet`,wireless:`Wi-Fi`,bluetooth:`Bluetooth`,bridge:`Bridge`,docker:`Docker`,infiniband:`InfiniBand`,multipass:`Multipass`,virtual:`Virtual`,vpn:`VPN`,other:`Other`},L=1024,R=e=>Math.round(e);function z(e){return I[e?.kind??`other`]}function B(e,t,n){if(!n||n<=0)return null;let r=(e+t)*8/1e6;return Math.min(100,Math.max(0,r/n*100))}function V(e,t){return`${(e/L).toFixed(1)}/${(t/L).toFixed(1)} GB`}function ne(e,t){let n=new Map((t?.disks??[]).map(e=>[e.id,e])),r=new Map((t?.nics??[]).map(e=>[e.id,e])),i=[{key:`cpu`,kind:`cpu`,label:`CPU`,sublabel:e.cpu.model,id:null,detail:`${R(e.cpu.total)}%`,percent:e.cpu.total},{key:`memory`,kind:`memory`,label:`Memory`,sublabel:V(e.mem.usedMB,e.mem.totalMB),id:null,detail:`${R(e.mem.percent)}%`,percent:e.mem.percent}];(e.disks??[]).forEach((e,t)=>{i.push({key:`disk:${e.id}`,kind:`disk`,label:`Disk ${t}`,sublabel:n.get(e.id)?.model??e.id,id:e.id,detail:e.available?`${R(e.busyPercent)}%`:`—`,percent:e.available?e.busyPercent:null})}),(e.nics??[]).forEach(e=>{let t=r.get(e.id);i.push({key:`nic:${e.id}`,kind:`nic`,label:z(t),sublabel:e.id,id:e.id,detail:e.available?M(e.rxBps+e.txBps):`—`,percent:e.available?B(e.rxBps,e.txBps,e.linkMbps):null})}),e.gpus.forEach((e,t)=>{i.push({key:`gpu:${e.id??t}`,kind:`gpu`,label:`GPU ${t}`,sublabel:e.name,id:e.id??null,detail:`${R(e.utilPercent)}%`,percent:e.utilPercent})});let a=e.fans??[];if(a.length>0){let e=Math.max(...a.map(e=>e.rpm));i.push({key:`fans`,kind:`fans`,label:`Fans`,sublabel:`${a.length} sensor${a.length===1?``:`s`}`,id:null,detail:`${e} RPM`,percent:null})}return i}function re(e,t){return t&&e.some(e=>e.key===t)?t:e[0]?.key??`cpu`}function ie(e){let[t,n]=(0,F.useState)(null),r=(0,F.useRef)(!1),i=(0,F.useCallback)(async()=>{if(!r.current){r.current=!0;try{n(await d.get(`/api/system/hardware`))}catch{}finally{r.current=!1}}},[]);return(0,F.useEffect)(()=>{i()},[i]),(0,F.useEffect)(()=>{if(!t)return;let n=new Set([...t.disks.map(e=>e.id),...t.nics.map(e=>e.id),...t.gpus.map(e=>e.id)]);e.split(`,`).filter(Boolean).some(e=>!n.has(e))&&i()},[t,e,i]),t}var H=n();function U({title:e,subtitle:t,value:n,valueClassName:r}){return(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`h3`,{className:`text-base font-semibold truncate`,children:e}),t&&(0,H.jsx)(`p`,{className:`text-xs text-text-subtle truncate`,title:t,children:t})]}),n!==void 0&&(0,H.jsx)(`span`,{className:b(`text-2xl font-semibold tabular-nums shrink-0`,r),children:n})]})}function W({children:e}){return(0,H.jsx)(`dl`,{className:`grid grid-cols-2 @2xl:grid-cols-4 gap-x-4 gap-y-3`,children:e})}function G({label:e,value:t,title:n}){let r=t==null||t===``?`—`:String(t);return(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`dt`,{className:`text-[11px] text-text-subtle truncate`,children:e}),(0,H.jsx)(`dd`,{className:`text-sm tabular-nums truncate`,title:n??r,children:r})]})}function K({series:e,maxValue:t,height:n=120,legend:r,caption:i,ceiling:a,grid:o,stacked:s}){return(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(i||a)&&(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-[11px] text-text-subtle`,children:[(0,H.jsx)(`span`,{className:`truncate`,children:i}),(0,H.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:a})]}),(0,H.jsx)(P,{series:e,height:n,maxValue:t,grid:o,stacked:s}),r&&r.length>0&&(0,H.jsx)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1`,children:r.map((t,n)=>(0,H.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-text-subtle`,children:[(0,H.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:e[n]?.color}}),t]},t))})]})}function q(e,t,n=200){return(0,F.useMemo)(()=>e.slice(-n).map(e=>t(e)??0),[e,n])}function J({segments:e}){let t=e.reduce((e,t)=>e+Math.max(0,t.value),0);return t<=0?null:(0,H.jsx)(`div`,{className:`flex h-3 w-full overflow-hidden rounded-sm bg-surface-hover`,role:`img`,"aria-label":e.map(e=>e.label).join(`, `),children:e.map(e=>(0,H.jsx)(`div`,{className:`h-full`,style:{width:`${Math.max(0,e.value)/t*100}%`,background:e.color},title:e.label},e.label))})}var Y={primary:`var(--color-primary)`,secondary:`var(--color-warning)`,success:`var(--color-success)`,error:`var(--color-error)`};function ae({cores:e,history:t,points:n=200,height:r=260}){let i=(0,F.useRef)(null),a=N(i),{cols:o,rows:s}=y(e.length,a),c=(0,F.useMemo)(()=>{let r=t.slice(-n),i=Array.from({length:e.length},()=>[]);for(let e of r){let t=e.system.cpu.cores;for(let e=0;e<i.length;e++)i[e].push(t[e]??0)}return i},[t,n,e.length]);if(e.length===0)return null;let l=Math.max(28,Math.floor(r/Math.max(1,s))-6);return(0,H.jsx)(`div`,{ref:i,className:`grid gap-1.5`,style:{gridTemplateColumns:`repeat(${Math.max(1,o)}, minmax(0, 1fr))`},"data-testid":`sysmon-core-grid`,"data-core-count":e.length,"data-cols":o,children:c.map((t,n)=>(0,H.jsx)(`div`,{className:`rounded-sm border border-border/70 overflow-hidden px-0.5`,title:`CPU ${n}: ${(e[n]??0).toFixed(0)}%`,children:(0,H.jsx)(P,{series:[{data:t,color:Y.primary}],height:l,maxValue:100})},n))})}function oe(e){if(e===void 0)return;let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return t>0?`${t}d ${n}h ${r}m`:`${n}h ${r}m`}var X=e=>e===void 0?void 0:`${(e/1e3).toFixed(2)} GHz`;function se({cpu:e,info:t,history:n,processCount:r}){let i=g(e=>e.sysmonTempUnit),a=g(e=>e.sysmonKernelTimes),o=g(e=>e.setSysmonKernelTimes),s=g(e=>e.sysmonCpuGraph),c=g(e=>e.setSysmonCpuGraph),l=g(e=>e.sysmonCpuBottomGraph),u=g(e=>e.setSysmonCpuBottomGraph),d=q(n,e=>e.system.cpu.total),y=q(n,e=>e.system.cpu.kernelPercent),b=q(n,e=>e.system.cpu.tempC),x=q(n,e=>e.system.cpu.powerW),j=q(n,e=>e.system.cpu.currentMHz),M=a&&e.kernelPercent!==void 0,N=p(n.map(e=>e.ts)),P=e=>N?`${e} ${N}`:e,I=(0,F.useMemo)(()=>{let t=n.slice(-200),r=e.cores.length,i=Array.from({length:r},()=>[]);for(let e of t){let t=e.system.cpu.cores;for(let e=0;e<r;e++)i[e].push(t[e]??0)}return i},[n,e.cores.length]),L=I.map(e=>({data:e,color:Y.primary})),R=I.map(e=>({data:e.map(e=>e/Math.max(1,I.length)),color:Y.primary})),z=()=>l===`none`?null:l===`temperature`?e.tempC===void 0?null:(0,H.jsx)(K,{grid:!0,height:100,caption:P(`Temperature`),ceiling:v(Math.max(...b,1),i),series:[{data:b,color:Y.error}]}):l===`power`?e.powerW===void 0?null:(0,H.jsx)(K,{grid:!0,height:100,caption:P(`Power draw`),ceiling:`${Math.max(...x,1).toFixed(1)} W`,series:[{data:x,color:Y.secondary}]}):e.currentMHz===void 0?null:(0,H.jsx)(K,{grid:!0,height:100,caption:P(`Clock speed`),ceiling:X(t?.maxMHz??Math.max(...j,1)),maxValue:t?.maxMHz,series:[{data:j,color:Y.success}]});return(0,H.jsxs)(`div`,{className:`space-y-4`,"data-testid":`sysmon-detail-cpu`,children:[(0,H.jsx)(U,{title:`CPU`,subtitle:t?.name??e.model,value:`${e.total.toFixed(1)}%`}),(0,H.jsxs)(S,{children:[(0,H.jsx)(D,{children:(0,H.jsxs)(`div`,{className:`space-y-3 select-none`,"data-testid":`sysmon-cpu-graphs`,children:[s===`logical`?(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-[11px] text-text-subtle`,children:[(0,H.jsx)(`span`,{className:`truncate`,children:P(`Utilisation`)}),(0,H.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:`100%`})]}),(0,H.jsx)(ae,{cores:e.cores,history:n})]}):(0,H.jsx)(K,{grid:!0,maxValue:100,caption:P(`Utilisation`),ceiling:`100%`,stacked:s===`threads-stacked`,legend:s===`overall`&&M?[`Utilisation`,`Kernel`]:void 0,series:s===`threads`?L:s===`threads-stacked`?R:M?[{data:d,color:Y.primary},{data:y,color:Y.secondary}]:[{data:d,color:Y.primary}]}),z()]})}),(0,H.jsxs)(O,{children:[(0,H.jsxs)(w,{children:[(0,H.jsx)(k,{children:`Change top graph to`}),(0,H.jsx)(T,{children:(0,H.jsx)(C,{value:s,onValueChange:e=>c(e),children:_.map(e=>(0,H.jsx)(E,{value:e,"data-testid":`sysmon-cpu-graph-${e}`,children:f[e]},e))})})]}),(0,H.jsxs)(w,{children:[(0,H.jsx)(k,{children:`Change bottom graph to`}),(0,H.jsx)(T,{children:(0,H.jsx)(C,{value:l,onValueChange:e=>u(e),children:h.map(e=>(0,H.jsx)(E,{value:e,"data-testid":`sysmon-cpu-bottom-${e}`,children:m[e]},e))})})]}),(0,H.jsx)(te,{}),(0,H.jsx)(ee,{onSelect:()=>o(!a),"data-testid":`sysmon-cpu-kernel-toggle`,children:a?`Hide kernel times`:`Show kernel times`})]})]}),(0,H.jsxs)(W,{children:[(0,H.jsx)(G,{label:`Speed`,value:X(e.currentMHz)}),(0,H.jsx)(G,{label:`Base speed`,value:X(t?.baseMHz)}),(0,H.jsx)(G,{label:`Max speed`,value:X(t?.maxMHz)}),(0,H.jsx)(G,{label:`Temperature`,value:v(e.tempC,i)}),(0,H.jsx)(G,{label:`Power`,value:e.powerW===void 0?void 0:`${e.powerW.toFixed(1)} W`}),(0,H.jsx)(G,{label:`Processes`,value:r}),(0,H.jsx)(G,{label:`Threads running`,value:e.threadCount}),(0,H.jsx)(G,{label:`Open handles`,value:e.handleCount}),(0,H.jsx)(G,{label:`Up time`,value:oe(e.uptimeSec)}),(0,H.jsx)(G,{label:`Sockets`,value:t?.sockets}),(0,H.jsx)(G,{label:`Cores`,value:t?.physicalCores}),(0,H.jsx)(G,{label:`Logical processors`,value:t?.logicalCores??e.cores.length}),(0,H.jsx)(G,{label:`Virtualisation`,value:t?.isVirtualMachine?`Running in a VM`:t?.virtualization}),(0,H.jsx)(G,{label:`L1 cache`,value:t?.l1CacheBytes===void 0?void 0:A(t.l1CacheBytes)}),(0,H.jsx)(G,{label:`L2 cache`,value:t?.l2CacheBytes===void 0?void 0:A(t.l2CacheBytes)}),(0,H.jsx)(G,{label:`L3 cache`,value:t?.l3CacheBytes===void 0?void 0:A(t.l3CacheBytes)}),(0,H.jsx)(G,{label:`Cpufreq driver`,value:t?.freqDriver}),(0,H.jsx)(G,{label:`Governor`,value:t?.freqGovernor}),(0,H.jsx)(G,{label:`Power preference`,value:t?.powerPreference})]})]})}function ce({mem:e,info:t,history:n}){let r=q(n,e=>e.system.mem.percent),i=q(n,e=>{let t=e.system.mem.swapTotalMB??0;return t>0?(e.system.mem.swapUsedMB??0)/t*100:0}),a=e.inUseBytes!==void 0,o=p(n.map(e=>e.ts)),s=e=>o?`${e} ${o}`:e,c=(e.swapTotalMB??0)>0;return(0,H.jsxs)(`div`,{className:`space-y-4`,"data-testid":`sysmon-detail-memory`,children:[(0,H.jsx)(U,{title:`Memory`,subtitle:`${j(e.usedMB)} of ${j(e.totalMB)} in use`,value:`${e.percent.toFixed(1)}%`}),(0,H.jsx)(K,{grid:!0,maxValue:100,caption:s(`Memory usage`),ceiling:j(e.totalMB),series:[{data:r,color:Y.primary}]}),c&&(0,H.jsx)(K,{grid:!0,height:90,maxValue:100,caption:s(`Swap usage`),ceiling:j(e.swapTotalMB??0),series:[{data:i,color:Y.success}]}),a&&(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(J,{segments:[{label:`In use`,value:e.inUseBytes??0,color:`var(--color-primary)`},{label:`Modified`,value:e.modifiedBytes??0,color:`var(--color-warning)`},{label:`Standby`,value:e.standbyBytes??0,color:`var(--color-success)`},{label:`Free`,value:e.freeBytes??0,color:`var(--color-border)`}]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-[11px] text-text-subtle`,children:[(0,H.jsxs)(`span`,{children:[`In use `,A(e.inUseBytes??0)]}),(0,H.jsxs)(`span`,{children:[`Modified `,A(e.modifiedBytes??0)]}),(0,H.jsxs)(`span`,{children:[`Standby `,A(e.standbyBytes??0)]}),(0,H.jsxs)(`span`,{children:[`Free `,A(e.freeBytes??0)]})]})]}),(0,H.jsxs)(W,{children:[(0,H.jsx)(G,{label:`Available`,value:j(e.availableMB)}),(0,H.jsx)(G,{label:`Cached`,value:e.cachedMB===void 0?void 0:j(e.cachedMB)}),(0,H.jsx)(G,{label:`Committed`,value:e.committedMB===void 0?void 0:`${j(e.committedMB)} / ${e.commitLimitMB===void 0?`?`:j(e.commitLimitMB)}`}),(0,H.jsx)(G,{label:`Swap`,value:e.swapTotalMB===void 0?void 0:`${j(e.swapUsedMB??0)} / ${j(e.swapTotalMB)}`}),(0,H.jsx)(G,{label:`Compressed (zram)`,value:e.zramCompressedMB===void 0?void 0:j(e.zramCompressedMB)}),(0,H.jsx)(G,{label:`Savings (zram)`,value:e.zramSavingsMB===void 0?void 0:j(e.zramSavingsMB)}),(0,H.jsx)(G,{label:`Slots used`,value:t===void 0?void 0:`${t.devices.length}${t.slotsTotal?` of ${t.slotsTotal}`:``}`}),(0,H.jsx)(G,{label:`Maximum capacity`,value:t?.maxCapacityBytes===void 0?void 0:A(t.maxCapacityBytes)})]}),t&&t.devices.length>0&&(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`h4`,{className:`text-xs font-medium text-text-secondary`,children:`Slots`}),(0,H.jsx)(`div`,{className:`rounded-md border border-border divide-y divide-border`,children:t.devices.map(e=>(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 py-2 text-xs`,children:[(0,H.jsx)(`span`,{className:`font-medium shrink-0`,children:e.locator}),(0,H.jsx)(`span`,{className:`text-text-subtle truncate`,children:[e.manufacturer,e.ramType,e.formFactor,e.speedMts?`${e.speedMts} MT/s`:null].filter(Boolean).join(` · `)}),(0,H.jsx)(`span`,{className:`tabular-nums shrink-0`,children:A(e.sizeBytes)})]},e.locator))})]})]})}var le=90,ue=75;function de(e){return e>=le?`bg-error`:e>=ue?`bg-warning`:`bg-primary`}function fe({partitions:e}){return e.length===0?null:(0,H.jsxs)(`section`,{className:`space-y-2`,"data-testid":`sysmon-partitions`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium`,children:`Partitions`}),(0,H.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>(0,H.jsx)(pe,{part:e},e.id))})]})}function pe({part:e}){let t=e.mounts.find(e=>e.usedBytes!==void 0&&e.totalBytes),n=t?Math.min(100,t.usedBytes/t.totalBytes*100):void 0;return(0,H.jsxs)(`li`,{className:`rounded-md border border-border px-3 py-2 space-y-1.5`,"data-testid":`sysmon-partition`,children:[(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium truncate`,title:e.devicePath,children:e.devicePath}),(0,H.jsxs)(`span`,{className:`text-[11px] text-text-subtle shrink-0 tabular-nums`,children:[e.filesystem??`—`,` · `,A(e.sizeBytes)]})]}),e.mounts.length===0?(0,H.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:`Not mounted`}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`p`,{className:`text-[11px] text-text-subtle truncate`,title:e.mounts.map(e=>e.mountPoint).join(`, `),children:e.mounts.map(e=>e.mountPoint).join(`, `)}),n===void 0?(0,H.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:`Usage unavailable`}):(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`div`,{className:`h-1.5 w-full rounded-full bg-surface-hover overflow-hidden`,children:(0,H.jsx)(`div`,{className:b(`h-full rounded-full`,de(n)),style:{width:`${n}%`}})}),(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-[11px] text-text-subtle tabular-nums`,children:[(0,H.jsxs)(`span`,{children:[A(t.usedBytes),` of `,A(t.totalBytes)]}),(0,H.jsxs)(`span`,{children:[n.toFixed(0),`%`]})]})]})]})]})}var me={hdd:`Hard disk`,ssd:`SSD`,nvme:`NVMe`,emmc:`eMMC`,sd:`SD card`,optical:`Optical`,thumb:`Removable`,unknown:`Unknown`};function he({disk:e,info:t,index:n,history:r}){let i=g(e=>e.sysmonTempUnit),a=t=>t.system.disks?.find(t=>t.id===e.id),o=q(r,e=>a(e)?.busyPercent),s=q(r,e=>a(e)?.readBps),c=q(r,e=>a(e)?.writeBps);return(0,H.jsxs)(`div`,{className:`space-y-4`,"data-testid":`sysmon-detail-disk`,"data-disk-id":e.id,children:[(0,H.jsx)(U,{title:`Disk ${n}`,subtitle:t?.model??e.id,value:e.available?`${e.busyPercent.toFixed(0)}%`:`—`}),(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:`Active time`}),(0,H.jsx)(K,{maxValue:100,series:[{data:o,color:Y.primary}],height:90})]}),(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:`Transfer rate`}),(0,H.jsx)(K,{height:90,legend:[`Read`,`Write`],series:[{data:s,color:Y.success},{data:c,color:Y.secondary}]})]}),(0,H.jsxs)(W,{children:[(0,H.jsx)(G,{label:`Read speed`,value:e.available?M(e.readBps):void 0}),(0,H.jsx)(G,{label:`Write speed`,value:e.available?M(e.writeBps):void 0}),(0,H.jsx)(G,{label:`Avg. response time`,value:e.available?`${e.responseMs.toFixed(2)} ms`:void 0}),(0,H.jsx)(G,{label:`Temperature`,value:v(e.tempC,i)}),(0,H.jsx)(G,{label:`Total read`,value:A(e.readTotal)}),(0,H.jsx)(G,{label:`Total written`,value:A(e.writeTotal)}),(0,H.jsx)(G,{label:`Capacity`,value:t===void 0?void 0:A(t.capacityBytes)}),(0,H.jsx)(G,{label:`Type`,value:t===void 0?void 0:me[t.kind]??t.kind}),(0,H.jsx)(G,{label:`System disk`,value:t===void 0?void 0:t.systemDisk?`Yes`:`No`}),(0,H.jsx)(G,{label:`Removable`,value:t===void 0?void 0:t.removable?`Yes`:`No`}),(0,H.jsx)(G,{label:`Rotation`,value:t?.rotationRpm===void 0?void 0:`${t.rotationRpm} RPM`}),(0,H.jsx)(G,{label:`Serial`,value:t?.serial})]}),(0,H.jsx)(fe,{partitions:t?.partitions??[]})]})}var ge={connected:`Connected`,connecting:`Connecting`,disconnected:`Disconnected`,unavailable:`Unavailable`,unknown:`Unknown`};function Z({nic:e,info:t,history:n}){let r=t=>t.system.nics?.find(t=>t.id===e.id),i=q(n,e=>r(e)?.rxBps),a=q(n,e=>r(e)?.txBps);return(0,H.jsxs)(`div`,{className:`space-y-4`,"data-testid":`sysmon-detail-nic`,"data-nic-id":e.id,children:[(0,H.jsx)(U,{title:I[t?.kind??`other`],subtitle:[e.id,t?.deviceName].filter(Boolean).join(` · `),value:e.available?M(e.rxBps+e.txBps):`—`}),(0,H.jsx)(K,{legend:[`Receive`,`Send`],series:[{data:i,color:Y.primary},{data:a,color:Y.secondary}]}),(0,H.jsxs)(W,{children:[(0,H.jsx)(G,{label:`State`,value:ge[e.state]}),(0,H.jsx)(G,{label:`Receive`,value:e.available?M(e.rxBps):void 0}),(0,H.jsx)(G,{label:`Send`,value:e.available?M(e.txBps):void 0}),(0,H.jsx)(G,{label:`Maximum bitrate`,value:e.linkMbps===void 0?void 0:`${e.linkMbps} Mbps`}),(0,H.jsx)(G,{label:`Total received`,value:A(e.rxTotal)}),(0,H.jsx)(G,{label:`Total sent`,value:A(e.txTotal)}),(0,H.jsx)(G,{label:`Network name`,value:e.ssid}),(0,H.jsx)(G,{label:`Signal`,value:e.signalPercent===void 0?void 0:`${e.signalPercent}%`}),(0,H.jsx)(G,{label:`Frequency`,value:e.frequencyMHz===void 0?void 0:`${(e.frequencyMHz/1e3).toFixed(1)} GHz`}),(0,H.jsx)(G,{label:`Driver`,value:t?.driver}),(0,H.jsx)(G,{label:`Hardware address`,value:t?.mac}),(0,H.jsx)(G,{label:`IPv4`,value:t?.ipv4.join(`, `),title:t?.ipv4.join(`
1
+ import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import"./vendor-ui-P9Ym7hCv.js";import{$t as r,A as i,Bt as a,En as o,Gr as s,j as c,rt as l,t as u}from"./icons-CO_II6D-.js";import{r as d}from"./api-client-F5Zi1sR0.js";import{_ as f,b as p,g as m,h,t as g,v as _,x as v,y}from"./settings-store-3jIBB8gx.js";import{n as b}from"./utils-btZ8C8-R.js";import"./portal-container-context-NFSuymMu.js";import"./context-menu-CH1mvCwA.js";import{n as x}from"./use-is-mobile-CkO33jqU.js";import"./mobile-bottom-sheet-CLic9ovp.js";import"./use-visual-viewport-C307OVeV.js";import{an as S,cn as C,dn as w,fn as T,ln as E,mn as D,on as O,pn as k,sn as ee,un as te}from"./index-D41mthBS.js";import{n as A,r as j,t as M}from"./format-bytes-DZ8bW_uF.js";import{n as N,t as P}from"./metric-chart-canvas-CVd7LO3m.js";var F=e(t(),1),I={wired:`Ethernet`,wireless:`Wi-Fi`,bluetooth:`Bluetooth`,bridge:`Bridge`,docker:`Docker`,infiniband:`InfiniBand`,multipass:`Multipass`,virtual:`Virtual`,vpn:`VPN`,other:`Other`},L=1024,R=e=>Math.round(e);function z(e){return I[e?.kind??`other`]}function B(e,t,n){if(!n||n<=0)return null;let r=(e+t)*8/1e6;return Math.min(100,Math.max(0,r/n*100))}function V(e,t){return`${(e/L).toFixed(1)}/${(t/L).toFixed(1)} GB`}function ne(e,t){let n=new Map((t?.disks??[]).map(e=>[e.id,e])),r=new Map((t?.nics??[]).map(e=>[e.id,e])),i=[{key:`cpu`,kind:`cpu`,label:`CPU`,sublabel:e.cpu.model,id:null,detail:`${R(e.cpu.total)}%`,percent:e.cpu.total},{key:`memory`,kind:`memory`,label:`Memory`,sublabel:V(e.mem.usedMB,e.mem.totalMB),id:null,detail:`${R(e.mem.percent)}%`,percent:e.mem.percent}];(e.disks??[]).forEach((e,t)=>{i.push({key:`disk:${e.id}`,kind:`disk`,label:`Disk ${t}`,sublabel:n.get(e.id)?.model??e.id,id:e.id,detail:e.available?`${R(e.busyPercent)}%`:`—`,percent:e.available?e.busyPercent:null})}),(e.nics??[]).forEach(e=>{let t=r.get(e.id);i.push({key:`nic:${e.id}`,kind:`nic`,label:z(t),sublabel:e.id,id:e.id,detail:e.available?M(e.rxBps+e.txBps):`—`,percent:e.available?B(e.rxBps,e.txBps,e.linkMbps):null})}),e.gpus.forEach((e,t)=>{i.push({key:`gpu:${e.id??t}`,kind:`gpu`,label:`GPU ${t}`,sublabel:e.name,id:e.id??null,detail:`${R(e.utilPercent)}%`,percent:e.utilPercent})});let a=e.fans??[];if(a.length>0){let e=Math.max(...a.map(e=>e.rpm));i.push({key:`fans`,kind:`fans`,label:`Fans`,sublabel:`${a.length} sensor${a.length===1?``:`s`}`,id:null,detail:`${e} RPM`,percent:null})}return i}function re(e,t){return t&&e.some(e=>e.key===t)?t:e[0]?.key??`cpu`}function ie(e){let[t,n]=(0,F.useState)(null),r=(0,F.useRef)(!1),i=(0,F.useCallback)(async()=>{if(!r.current){r.current=!0;try{n(await d.get(`/api/system/hardware`))}catch{}finally{r.current=!1}}},[]);return(0,F.useEffect)(()=>{i()},[i]),(0,F.useEffect)(()=>{if(!t)return;let n=new Set([...t.disks.map(e=>e.id),...t.nics.map(e=>e.id),...t.gpus.map(e=>e.id)]);e.split(`,`).filter(Boolean).some(e=>!n.has(e))&&i()},[t,e,i]),t}var H=n();function U({title:e,subtitle:t,value:n,valueClassName:r}){return(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`h3`,{className:`text-base font-semibold truncate`,children:e}),t&&(0,H.jsx)(`p`,{className:`text-xs text-text-subtle truncate`,title:t,children:t})]}),n!==void 0&&(0,H.jsx)(`span`,{className:b(`text-2xl font-semibold tabular-nums shrink-0`,r),children:n})]})}function W({children:e}){return(0,H.jsx)(`dl`,{className:`grid grid-cols-2 @2xl:grid-cols-4 gap-x-4 gap-y-3`,children:e})}function G({label:e,value:t,title:n}){let r=t==null||t===``?`—`:String(t);return(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`dt`,{className:`text-[11px] text-text-subtle truncate`,children:e}),(0,H.jsx)(`dd`,{className:`text-sm tabular-nums truncate`,title:n??r,children:r})]})}function K({series:e,maxValue:t,height:n=120,legend:r,caption:i,ceiling:a,grid:o,stacked:s}){return(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(i||a)&&(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-[11px] text-text-subtle`,children:[(0,H.jsx)(`span`,{className:`truncate`,children:i}),(0,H.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:a})]}),(0,H.jsx)(P,{series:e,height:n,maxValue:t,grid:o,stacked:s}),r&&r.length>0&&(0,H.jsx)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1`,children:r.map((t,n)=>(0,H.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-text-subtle`,children:[(0,H.jsx)(`span`,{className:`size-2 rounded-full`,style:{background:e[n]?.color}}),t]},t))})]})}function q(e,t,n=200){return(0,F.useMemo)(()=>e.slice(-n).map(e=>t(e)??0),[e,n])}function J({segments:e}){let t=e.reduce((e,t)=>e+Math.max(0,t.value),0);return t<=0?null:(0,H.jsx)(`div`,{className:`flex h-3 w-full overflow-hidden rounded-sm bg-surface-hover`,role:`img`,"aria-label":e.map(e=>e.label).join(`, `),children:e.map(e=>(0,H.jsx)(`div`,{className:`h-full`,style:{width:`${Math.max(0,e.value)/t*100}%`,background:e.color},title:e.label},e.label))})}var Y={primary:`var(--color-primary)`,secondary:`var(--color-warning)`,success:`var(--color-success)`,error:`var(--color-error)`};function ae({cores:e,history:t,points:n=200,height:r=260}){let i=(0,F.useRef)(null),a=N(i),{cols:o,rows:s}=y(e.length,a),c=(0,F.useMemo)(()=>{let r=t.slice(-n),i=Array.from({length:e.length},()=>[]);for(let e of r){let t=e.system.cpu.cores;for(let e=0;e<i.length;e++)i[e].push(t[e]??0)}return i},[t,n,e.length]);if(e.length===0)return null;let l=Math.max(28,Math.floor(r/Math.max(1,s))-6);return(0,H.jsx)(`div`,{ref:i,className:`grid gap-1.5`,style:{gridTemplateColumns:`repeat(${Math.max(1,o)}, minmax(0, 1fr))`},"data-testid":`sysmon-core-grid`,"data-core-count":e.length,"data-cols":o,children:c.map((t,n)=>(0,H.jsx)(`div`,{className:`rounded-sm border border-border/70 overflow-hidden px-0.5`,title:`CPU ${n}: ${(e[n]??0).toFixed(0)}%`,children:(0,H.jsx)(P,{series:[{data:t,color:Y.primary}],height:l,maxValue:100})},n))})}function oe(e){if(e===void 0)return;let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return t>0?`${t}d ${n}h ${r}m`:`${n}h ${r}m`}var X=e=>e===void 0?void 0:`${(e/1e3).toFixed(2)} GHz`;function se({cpu:e,info:t,history:n,processCount:r}){let i=g(e=>e.sysmonTempUnit),a=g(e=>e.sysmonKernelTimes),o=g(e=>e.setSysmonKernelTimes),s=g(e=>e.sysmonCpuGraph),c=g(e=>e.setSysmonCpuGraph),l=g(e=>e.sysmonCpuBottomGraph),u=g(e=>e.setSysmonCpuBottomGraph),d=q(n,e=>e.system.cpu.total),y=q(n,e=>e.system.cpu.kernelPercent),b=q(n,e=>e.system.cpu.tempC),x=q(n,e=>e.system.cpu.powerW),j=q(n,e=>e.system.cpu.currentMHz),M=a&&e.kernelPercent!==void 0,N=p(n.map(e=>e.ts)),P=e=>N?`${e} ${N}`:e,I=(0,F.useMemo)(()=>{let t=n.slice(-200),r=e.cores.length,i=Array.from({length:r},()=>[]);for(let e of t){let t=e.system.cpu.cores;for(let e=0;e<r;e++)i[e].push(t[e]??0)}return i},[n,e.cores.length]),L=I.map(e=>({data:e,color:Y.primary})),R=I.map(e=>({data:e.map(e=>e/Math.max(1,I.length)),color:Y.primary})),z=()=>l===`none`?null:l===`temperature`?e.tempC===void 0?null:(0,H.jsx)(K,{grid:!0,height:100,caption:P(`Temperature`),ceiling:v(Math.max(...b,1),i),series:[{data:b,color:Y.error}]}):l===`power`?e.powerW===void 0?null:(0,H.jsx)(K,{grid:!0,height:100,caption:P(`Power draw`),ceiling:`${Math.max(...x,1).toFixed(1)} W`,series:[{data:x,color:Y.secondary}]}):e.currentMHz===void 0?null:(0,H.jsx)(K,{grid:!0,height:100,caption:P(`Clock speed`),ceiling:X(t?.maxMHz??Math.max(...j,1)),maxValue:t?.maxMHz,series:[{data:j,color:Y.success}]});return(0,H.jsxs)(`div`,{className:`space-y-4`,"data-testid":`sysmon-detail-cpu`,children:[(0,H.jsx)(U,{title:`CPU`,subtitle:t?.name??e.model,value:`${e.total.toFixed(1)}%`}),(0,H.jsxs)(S,{children:[(0,H.jsx)(D,{children:(0,H.jsxs)(`div`,{className:`space-y-3 select-none`,"data-testid":`sysmon-cpu-graphs`,children:[s===`logical`?(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-[11px] text-text-subtle`,children:[(0,H.jsx)(`span`,{className:`truncate`,children:P(`Utilisation`)}),(0,H.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:`100%`})]}),(0,H.jsx)(ae,{cores:e.cores,history:n})]}):(0,H.jsx)(K,{grid:!0,maxValue:100,caption:P(`Utilisation`),ceiling:`100%`,stacked:s===`threads-stacked`,legend:s===`overall`&&M?[`Utilisation`,`Kernel`]:void 0,series:s===`threads`?L:s===`threads-stacked`?R:M?[{data:d,color:Y.primary},{data:y,color:Y.secondary}]:[{data:d,color:Y.primary}]}),z()]})}),(0,H.jsxs)(O,{children:[(0,H.jsxs)(w,{children:[(0,H.jsx)(k,{children:`Change top graph to`}),(0,H.jsx)(T,{children:(0,H.jsx)(C,{value:s,onValueChange:e=>c(e),children:_.map(e=>(0,H.jsx)(E,{value:e,"data-testid":`sysmon-cpu-graph-${e}`,children:f[e]},e))})})]}),(0,H.jsxs)(w,{children:[(0,H.jsx)(k,{children:`Change bottom graph to`}),(0,H.jsx)(T,{children:(0,H.jsx)(C,{value:l,onValueChange:e=>u(e),children:h.map(e=>(0,H.jsx)(E,{value:e,"data-testid":`sysmon-cpu-bottom-${e}`,children:m[e]},e))})})]}),(0,H.jsx)(te,{}),(0,H.jsx)(ee,{onSelect:()=>o(!a),"data-testid":`sysmon-cpu-kernel-toggle`,children:a?`Hide kernel times`:`Show kernel times`})]})]}),(0,H.jsxs)(W,{children:[(0,H.jsx)(G,{label:`Speed`,value:X(e.currentMHz)}),(0,H.jsx)(G,{label:`Base speed`,value:X(t?.baseMHz)}),(0,H.jsx)(G,{label:`Max speed`,value:X(t?.maxMHz)}),(0,H.jsx)(G,{label:`Temperature`,value:v(e.tempC,i)}),(0,H.jsx)(G,{label:`Power`,value:e.powerW===void 0?void 0:`${e.powerW.toFixed(1)} W`}),(0,H.jsx)(G,{label:`Processes`,value:r}),(0,H.jsx)(G,{label:`Threads running`,value:e.threadCount}),(0,H.jsx)(G,{label:`Open handles`,value:e.handleCount}),(0,H.jsx)(G,{label:`Up time`,value:oe(e.uptimeSec)}),(0,H.jsx)(G,{label:`Sockets`,value:t?.sockets}),(0,H.jsx)(G,{label:`Cores`,value:t?.physicalCores}),(0,H.jsx)(G,{label:`Logical processors`,value:t?.logicalCores??e.cores.length}),(0,H.jsx)(G,{label:`Virtualisation`,value:t?.isVirtualMachine?`Running in a VM`:t?.virtualization}),(0,H.jsx)(G,{label:`L1 cache`,value:t?.l1CacheBytes===void 0?void 0:A(t.l1CacheBytes)}),(0,H.jsx)(G,{label:`L2 cache`,value:t?.l2CacheBytes===void 0?void 0:A(t.l2CacheBytes)}),(0,H.jsx)(G,{label:`L3 cache`,value:t?.l3CacheBytes===void 0?void 0:A(t.l3CacheBytes)}),(0,H.jsx)(G,{label:`Cpufreq driver`,value:t?.freqDriver}),(0,H.jsx)(G,{label:`Governor`,value:t?.freqGovernor}),(0,H.jsx)(G,{label:`Power preference`,value:t?.powerPreference})]})]})}function ce({mem:e,info:t,history:n}){let r=q(n,e=>e.system.mem.percent),i=q(n,e=>{let t=e.system.mem.swapTotalMB??0;return t>0?(e.system.mem.swapUsedMB??0)/t*100:0}),a=e.inUseBytes!==void 0,o=p(n.map(e=>e.ts)),s=e=>o?`${e} ${o}`:e,c=(e.swapTotalMB??0)>0;return(0,H.jsxs)(`div`,{className:`space-y-4`,"data-testid":`sysmon-detail-memory`,children:[(0,H.jsx)(U,{title:`Memory`,subtitle:`${j(e.usedMB)} of ${j(e.totalMB)} in use`,value:`${e.percent.toFixed(1)}%`}),(0,H.jsx)(K,{grid:!0,maxValue:100,caption:s(`Memory usage`),ceiling:j(e.totalMB),series:[{data:r,color:Y.primary}]}),c&&(0,H.jsx)(K,{grid:!0,height:90,maxValue:100,caption:s(`Swap usage`),ceiling:j(e.swapTotalMB??0),series:[{data:i,color:Y.success}]}),a&&(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(J,{segments:[{label:`In use`,value:e.inUseBytes??0,color:`var(--color-primary)`},{label:`Modified`,value:e.modifiedBytes??0,color:`var(--color-warning)`},{label:`Standby`,value:e.standbyBytes??0,color:`var(--color-success)`},{label:`Free`,value:e.freeBytes??0,color:`var(--color-border)`}]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-[11px] text-text-subtle`,children:[(0,H.jsxs)(`span`,{children:[`In use `,A(e.inUseBytes??0)]}),(0,H.jsxs)(`span`,{children:[`Modified `,A(e.modifiedBytes??0)]}),(0,H.jsxs)(`span`,{children:[`Standby `,A(e.standbyBytes??0)]}),(0,H.jsxs)(`span`,{children:[`Free `,A(e.freeBytes??0)]})]})]}),(0,H.jsxs)(W,{children:[(0,H.jsx)(G,{label:`Available`,value:j(e.availableMB)}),(0,H.jsx)(G,{label:`Cached`,value:e.cachedMB===void 0?void 0:j(e.cachedMB)}),(0,H.jsx)(G,{label:`Committed`,value:e.committedMB===void 0?void 0:`${j(e.committedMB)} / ${e.commitLimitMB===void 0?`?`:j(e.commitLimitMB)}`}),(0,H.jsx)(G,{label:`Swap`,value:e.swapTotalMB===void 0?void 0:`${j(e.swapUsedMB??0)} / ${j(e.swapTotalMB)}`}),(0,H.jsx)(G,{label:`Compressed (zram)`,value:e.zramCompressedMB===void 0?void 0:j(e.zramCompressedMB)}),(0,H.jsx)(G,{label:`Savings (zram)`,value:e.zramSavingsMB===void 0?void 0:j(e.zramSavingsMB)}),(0,H.jsx)(G,{label:`Slots used`,value:t===void 0?void 0:`${t.devices.length}${t.slotsTotal?` of ${t.slotsTotal}`:``}`}),(0,H.jsx)(G,{label:`Maximum capacity`,value:t?.maxCapacityBytes===void 0?void 0:A(t.maxCapacityBytes)})]}),t&&t.devices.length>0&&(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`h4`,{className:`text-xs font-medium text-text-secondary`,children:`Slots`}),(0,H.jsx)(`div`,{className:`rounded-md border border-border divide-y divide-border`,children:t.devices.map(e=>(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 py-2 text-xs`,children:[(0,H.jsx)(`span`,{className:`font-medium shrink-0`,children:e.locator}),(0,H.jsx)(`span`,{className:`text-text-subtle truncate`,children:[e.manufacturer,e.ramType,e.formFactor,e.speedMts?`${e.speedMts} MT/s`:null].filter(Boolean).join(` · `)}),(0,H.jsx)(`span`,{className:`tabular-nums shrink-0`,children:A(e.sizeBytes)})]},e.locator))})]})]})}var le=90,ue=75;function de(e){return e>=le?`bg-error`:e>=ue?`bg-warning`:`bg-primary`}function fe({partitions:e}){return e.length===0?null:(0,H.jsxs)(`section`,{className:`space-y-2`,"data-testid":`sysmon-partitions`,children:[(0,H.jsx)(`h4`,{className:`text-sm font-medium`,children:`Partitions`}),(0,H.jsx)(`ul`,{className:`space-y-2`,children:e.map(e=>(0,H.jsx)(pe,{part:e},e.id))})]})}function pe({part:e}){let t=e.mounts.find(e=>e.usedBytes!==void 0&&e.totalBytes),n=t?Math.min(100,t.usedBytes/t.totalBytes*100):void 0;return(0,H.jsxs)(`li`,{className:`rounded-md border border-border px-3 py-2 space-y-1.5`,"data-testid":`sysmon-partition`,children:[(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium truncate`,title:e.devicePath,children:e.devicePath}),(0,H.jsxs)(`span`,{className:`text-[11px] text-text-subtle shrink-0 tabular-nums`,children:[e.filesystem??`—`,` · `,A(e.sizeBytes)]})]}),e.mounts.length===0?(0,H.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:`Not mounted`}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`p`,{className:`text-[11px] text-text-subtle truncate`,title:e.mounts.map(e=>e.mountPoint).join(`, `),children:e.mounts.map(e=>e.mountPoint).join(`, `)}),n===void 0?(0,H.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:`Usage unavailable`}):(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`div`,{className:`h-1.5 w-full rounded-full bg-surface-hover overflow-hidden`,children:(0,H.jsx)(`div`,{className:b(`h-full rounded-full`,de(n)),style:{width:`${n}%`}})}),(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-[11px] text-text-subtle tabular-nums`,children:[(0,H.jsxs)(`span`,{children:[A(t.usedBytes),` of `,A(t.totalBytes)]}),(0,H.jsxs)(`span`,{children:[n.toFixed(0),`%`]})]})]})]})]})}var me={hdd:`Hard disk`,ssd:`SSD`,nvme:`NVMe`,emmc:`eMMC`,sd:`SD card`,optical:`Optical`,thumb:`Removable`,unknown:`Unknown`};function he({disk:e,info:t,index:n,history:r}){let i=g(e=>e.sysmonTempUnit),a=t=>t.system.disks?.find(t=>t.id===e.id),o=q(r,e=>a(e)?.busyPercent),s=q(r,e=>a(e)?.readBps),c=q(r,e=>a(e)?.writeBps);return(0,H.jsxs)(`div`,{className:`space-y-4`,"data-testid":`sysmon-detail-disk`,"data-disk-id":e.id,children:[(0,H.jsx)(U,{title:`Disk ${n}`,subtitle:t?.model??e.id,value:e.available?`${e.busyPercent.toFixed(0)}%`:`—`}),(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:`Active time`}),(0,H.jsx)(K,{maxValue:100,series:[{data:o,color:Y.primary}],height:90})]}),(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:`Transfer rate`}),(0,H.jsx)(K,{height:90,legend:[`Read`,`Write`],series:[{data:s,color:Y.success},{data:c,color:Y.secondary}]})]}),(0,H.jsxs)(W,{children:[(0,H.jsx)(G,{label:`Read speed`,value:e.available?M(e.readBps):void 0}),(0,H.jsx)(G,{label:`Write speed`,value:e.available?M(e.writeBps):void 0}),(0,H.jsx)(G,{label:`Avg. response time`,value:e.available?`${e.responseMs.toFixed(2)} ms`:void 0}),(0,H.jsx)(G,{label:`Temperature`,value:v(e.tempC,i)}),(0,H.jsx)(G,{label:`Total read`,value:A(e.readTotal)}),(0,H.jsx)(G,{label:`Total written`,value:A(e.writeTotal)}),(0,H.jsx)(G,{label:`Capacity`,value:t===void 0?void 0:A(t.capacityBytes)}),(0,H.jsx)(G,{label:`Type`,value:t===void 0?void 0:me[t.kind]??t.kind}),(0,H.jsx)(G,{label:`System disk`,value:t===void 0?void 0:t.systemDisk?`Yes`:`No`}),(0,H.jsx)(G,{label:`Removable`,value:t===void 0?void 0:t.removable?`Yes`:`No`}),(0,H.jsx)(G,{label:`Rotation`,value:t?.rotationRpm===void 0?void 0:`${t.rotationRpm} RPM`}),(0,H.jsx)(G,{label:`Serial`,value:t?.serial})]}),(0,H.jsx)(fe,{partitions:t?.partitions??[]})]})}var ge={connected:`Connected`,connecting:`Connecting`,disconnected:`Disconnected`,unavailable:`Unavailable`,unknown:`Unknown`};function Z({nic:e,info:t,history:n}){let r=t=>t.system.nics?.find(t=>t.id===e.id),i=q(n,e=>r(e)?.rxBps),a=q(n,e=>r(e)?.txBps);return(0,H.jsxs)(`div`,{className:`space-y-4`,"data-testid":`sysmon-detail-nic`,"data-nic-id":e.id,children:[(0,H.jsx)(U,{title:I[t?.kind??`other`],subtitle:[e.id,t?.deviceName].filter(Boolean).join(` · `),value:e.available?M(e.rxBps+e.txBps):`—`}),(0,H.jsx)(K,{legend:[`Receive`,`Send`],series:[{data:i,color:Y.primary},{data:a,color:Y.secondary}]}),(0,H.jsxs)(W,{children:[(0,H.jsx)(G,{label:`State`,value:ge[e.state]}),(0,H.jsx)(G,{label:`Receive`,value:e.available?M(e.rxBps):void 0}),(0,H.jsx)(G,{label:`Send`,value:e.available?M(e.txBps):void 0}),(0,H.jsx)(G,{label:`Maximum bitrate`,value:e.linkMbps===void 0?void 0:`${e.linkMbps} Mbps`}),(0,H.jsx)(G,{label:`Total received`,value:A(e.rxTotal)}),(0,H.jsx)(G,{label:`Total sent`,value:A(e.txTotal)}),(0,H.jsx)(G,{label:`Network name`,value:e.ssid}),(0,H.jsx)(G,{label:`Signal`,value:e.signalPercent===void 0?void 0:`${e.signalPercent}%`}),(0,H.jsx)(G,{label:`Frequency`,value:e.frequencyMHz===void 0?void 0:`${(e.frequencyMHz/1e3).toFixed(1)} GHz`}),(0,H.jsx)(G,{label:`Driver`,value:t?.driver}),(0,H.jsx)(G,{label:`Hardware address`,value:t?.mac}),(0,H.jsx)(G,{label:`IPv4`,value:t?.ipv4.join(`, `),title:t?.ipv4.join(`
2
2
  `)}),(0,H.jsx)(G,{label:`IPv6`,value:t?.ipv6.join(`, `),title:t?.ipv6.join(`
3
3
  `)})]})]})}function Q(e,t){if(!(e===void 0&&t===void 0))return`${e===void 0?`?`:`Gen ${e}`} x${t??`?`}`}function _e({gpu:e,info:t,index:n,history:r}){let i=g(e=>e.sysmonTempUnit),a=t=>t.system.gpus.find(t=>e.id?t.id===e.id:t.name===e.name),o=q(r,e=>a(e)?.utilPercent),s=q(r,e=>a(e)?.encodePercent),c=q(r,e=>a(e)?.decodePercent),l=e.vramTotalMB>0,u=!l&&e.sharedTotalMB!==void 0,d=q(r,e=>{let t=a(e);return l?t?.vramUsedMB:t?.sharedUsedMB}),f=l?e.vramTotalMB:e.sharedTotalMB??0,m=e.encodePercent!==void 0||e.decodePercent!==void 0,h=t?.encodeDecodeShared===!0,_=p(r.map(e=>e.ts)),y=e=>_?`${e} ${_}`:e;return(0,H.jsxs)(`div`,{className:`space-y-4`,"data-testid":`sysmon-detail-gpu`,"data-gpu-id":e.id??n,children:[(0,H.jsx)(U,{title:`GPU ${n}`,subtitle:e.name,value:`${e.utilPercent.toFixed(0)}%`}),(0,H.jsx)(K,{grid:!0,maxValue:100,caption:y(`Utilisation`),ceiling:`100%`,series:[{data:o,color:Y.primary}]}),m&&(0,H.jsx)(K,{grid:!0,height:90,maxValue:100,caption:y(h?`Video encode/decode utilisation`:`Video encode and decode utilisation`),ceiling:`100%`,legend:h?void 0:[`Encode`,`Decode`],series:h?[{data:s,color:Y.secondary}]:[{data:s,color:Y.secondary},{data:c,color:Y.error}]}),(l||u)&&(0,H.jsx)(K,{grid:!0,height:90,maxValue:f,caption:y(l?`Video memory usage`:`Memory usage`),ceiling:j(f),series:[{data:d,color:Y.success}]}),(0,H.jsxs)(W,{children:[(0,H.jsx)(G,{label:`Video memory`,value:l?`${j(e.vramUsedMB)} / ${j(e.vramTotalMB)}`:void 0}),(0,H.jsx)(G,{label:l?`Shared memory`:`Memory usage`,value:e.sharedTotalMB===void 0?void 0:`${j(e.sharedUsedMB??0)} / ${j(e.sharedTotalMB)}`}),(0,H.jsx)(G,{label:h?`Video encode/decode`:`Video encode`,value:e.encodePercent===void 0?void 0:`${e.encodePercent.toFixed(0)}%`}),!h&&(0,H.jsx)(G,{label:`Video decode`,value:e.decodePercent===void 0?void 0:`${e.decodePercent.toFixed(0)}%`}),(0,H.jsx)(G,{label:`Clock`,value:e.clockMHz===void 0?void 0:`${e.clockMHz} MHz${e.clockMaxMHz?` / ${e.clockMaxMHz}`:``}`}),(0,H.jsx)(G,{label:`Memory clock`,value:e.memClockMHz===void 0?void 0:`${e.memClockMHz} MHz${e.memClockMaxMHz?` / ${e.memClockMaxMHz}`:``}`}),(0,H.jsx)(G,{label:`Power`,value:e.powerW===void 0?void 0:`${e.powerW.toFixed(1)} W${e.powerMaxW?` / ${e.powerMaxW}`:``}`}),(0,H.jsx)(G,{label:`Temperature`,value:v(e.tempC,i)}),(0,H.jsx)(G,{label:`Vendor`,value:t?.vendor}),(0,H.jsx)(G,{label:`Driver`,value:t?.driver===void 0?void 0:[t.driver,t.driverVersion].filter(Boolean).join(` `)}),(0,H.jsx)(G,{label:`OpenGL`,value:t?.openglVersion}),(0,H.jsx)(G,{label:`Vulkan`,value:t?.vulkanVersion}),(0,H.jsx)(G,{label:`PCI bus address`,value:e.id}),(0,H.jsx)(G,{label:`PCIe link`,value:Q(t?.pcieGen,t?.pcieLanes)}),(0,H.jsx)(G,{label:`PCIe maximum`,value:Q(t?.pcieMaxGen,t?.pcieMaxLanes)})]})]})}function ve({fans:e}){let t=g(e=>e.sysmonTempUnit),n=e.length>0?Math.max(...e.map(e=>e.rpm)):0;return(0,H.jsxs)(`div`,{className:`space-y-4`,"data-testid":`sysmon-detail-fans`,"data-fan-count":e.length,children:[(0,H.jsx)(U,{title:`Fans`,subtitle:`${e.length} sensor${e.length===1?``:`s`}`,value:`${n} RPM`}),(0,H.jsx)(`div`,{className:`rounded-md border border-border divide-y divide-border`,children:e.map(e=>(0,H.jsxs)(`div`,{className:`px-3 py-2 space-y-2`,"data-testid":`sysmon-fan-row`,children:[(0,H.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium truncate`,title:e.id,children:e.label}),(0,H.jsxs)(`span`,{className:`text-sm tabular-nums shrink-0`,children:[e.rpm,` RPM`]})]}),(0,H.jsxs)(W,{children:[(0,H.jsx)(G,{label:`Duty cycle`,value:e.pwmPercent===void 0?void 0:`${e.pwmPercent.toFixed(0)}%`}),(0,H.jsx)(G,{label:e.tempName??`Temperature`,value:v(e.tempC,t)})]})]},e.id))})]})}var ye={cpu:l,memory:r,disk:a,nic:s,gpu:o,fans:u};function be(e){return e>80?`bg-error`:e>50?`bg-warning`:`bg-primary`}function xe({entry:e,selected:t,showChevron:n,onSelect:r}){let i=ye[e.kind];return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>r(e.key),"aria-current":t,"data-testid":`sysmon-device-row`,"data-device-key":e.key,className:b(`w-full min-h-11 px-3 py-2 flex items-center gap-3 text-left transition-colors`,t?`bg-primary/10 text-text-primary`:`hover:bg-surface-hover`),children:[(0,H.jsx)(i,{className:`size-4 shrink-0 text-text-subtle`}),(0,H.jsxs)(`span`,{className:`flex-1 min-w-0`,children:[(0,H.jsx)(`span`,{className:`block text-sm truncate`,children:e.label}),(0,H.jsx)(`span`,{className:`block text-[11px] text-text-subtle truncate`,title:e.sublabel,children:e.sublabel}),e.percent!==null&&(0,H.jsx)(`span`,{className:`mt-1 block h-1 w-full rounded-full bg-surface-hover overflow-hidden`,children:(0,H.jsx)(`span`,{className:b(`block h-full transition-[width]`,be(e.percent)),style:{width:`${Math.max(1,Math.min(100,e.percent))}%`}})})]}),(0,H.jsx)(`span`,{className:`text-xs tabular-nums text-text-secondary shrink-0`,children:e.detail}),n&&(0,H.jsx)(c,{className:`size-4 shrink-0 text-text-subtle`})]})}function $({entry:e,system:t,inventory:n,history:r}){switch(e.kind){case`cpu`:return(0,H.jsx)(se,{cpu:t.cpu,info:n?.cpu,history:r,processCount:t.processCount});case`memory`:return(0,H.jsx)(ce,{mem:t.mem,info:n?.memory,history:r});case`disk`:{let i=(t.disks??[]).findIndex(t=>t.id===e.id),a=i>=0?t.disks?.[i]:void 0;return a?(0,H.jsx)(he,{disk:a,index:i,info:n?.disks.find(e=>e.id===a.id),history:r}):null}case`nic`:{let i=(t.nics??[]).find(t=>t.id===e.id);return i?(0,H.jsx)(Z,{nic:i,info:n?.nics.find(e=>e.id===i.id),history:r}):null}case`gpu`:{let i=t.gpus.findIndex(t=>e.id?t.id===e.id:!0),a=i>=0?t.gpus[i]:void 0;return a?(0,H.jsx)(_e,{gpu:a,index:i,info:n?.gpus.find(e=>e.id===a.id),history:r}):null}case`fans`:return(0,H.jsx)(ve,{fans:t.fans??[]});default:return null}}function Se({system:e,history:t,device:n,onDeviceChange:r}){let a=x(),o=ie((0,F.useMemo)(()=>[...(e.disks??[]).map(e=>e.id),...(e.nics??[]).map(e=>e.id),...e.gpus.map(e=>e.id).filter(e=>!!e)].join(`,`),[e.disks,e.nics,e.gpus])),s=(0,F.useMemo)(()=>ne(e,o),[e,o]),c=re(s,n),l=s.find(e=>e.key===c),u=(0,H.jsx)(`div`,{className:`divide-y divide-border`,role:`list`,"data-testid":`sysmon-device-list`,children:s.map(e=>(0,H.jsx)(xe,{entry:e,selected:!a&&e.key===c,showChevron:a,onSelect:r},e.key))});return a?n===null||!l||c!==n?(0,H.jsx)(`div`,{className:`h-full overflow-y-auto`,"data-testid":`sysmon-performance`,children:u}):(0,H.jsxs)(`div`,{className:`h-full flex flex-col`,"data-testid":`sysmon-performance`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>r(null),className:`shrink-0 min-h-11 px-3 flex items-center gap-2 text-sm border-b border-border`,children:[(0,H.jsx)(i,{className:`size-4`}),`Devices`]}),(0,H.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 @container`,children:(0,H.jsx)($,{entry:l,system:e,inventory:o,history:t})})]}):(0,H.jsxs)(`div`,{className:`h-full flex min-h-0`,"data-testid":`sysmon-performance`,children:[(0,H.jsx)(`div`,{className:`w-56 shrink-0 border-r border-border overflow-y-auto`,children:u}),(0,H.jsx)(`div`,{className:`flex-1 min-w-0 overflow-y-auto p-4 @container`,children:l&&(0,H.jsx)($,{entry:l,system:e,inventory:o,history:t})})]})}export{Se as PerformancePanel};
@@ -1 +1 @@
1
- import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import"./vendor-ui-P9Ym7hCv.js";import{J as r,Mr as i,T as a,b as o,dr as s,ir as c}from"./icons-CO_II6D-.js";import{r as l}from"./api-client-F5Zi1sR0.js";import{t as u}from"./button-CsmGH5xa.js";import{t as d}from"./input-CP31LZnN.js";import{Ct as f}from"./index-DQCw6d-2.js";import{t as p}from"./separator-B0xYRplF.js";var m=e(t(),1),h=n();function g(){let[e,t]=(0,m.useState)(null),[n,g]=(0,m.useState)(!1),[_,v]=(0,m.useState)(null),[y,b]=(0,m.useState)(``),[x,S]=(0,m.useState)(!1),[C,w]=(0,m.useState)(!1),[T,E]=(0,m.useState)(!1),[D,O]=(0,m.useState)(``),[k,A]=(0,m.useState)(!0),[j,M]=(0,m.useState)(!1),[N,P]=(0,m.useState)(2e3),[F,I]=(0,m.useState)([]),[L,R]=(0,m.useState)(``),[z,B]=(0,m.useState)(!1),[V,H]=(0,m.useState)(!1),[U,W]=(0,m.useState)([]),[G,ee]=(0,m.useState)(`_global`),[K,q]=(0,m.useState)([]),J=(0,m.useRef)(void 0),Y=(0,m.useCallback)(async()=>{try{I(await l.get(`/api/settings/clawbot/paired`))}catch{}},[]),X=(0,m.useCallback)(async(e=G)=>{try{W(await l.get(`/api/settings/clawbot/memories?project=${encodeURIComponent(e)}`))}catch{}},[G]),Z=(0,m.useCallback)(async()=>{try{q(await l.get(`/api/settings/clawbot/tasks?limit=20`))}catch{}},[]),Q=async e=>{try{await l.del(`/api/settings/clawbot/memories/${e}`),W(t=>t.filter(t=>t.id!==e))}catch{}};(0,m.useEffect)(()=>(l.get(`/api/settings/clawbot`).then(e=>{t(e),E(e.enabled),O(e.system_prompt),A(e.show_tool_calls),M(e.show_thinking),P(e.debounce_ms)}).catch(()=>{}),l.get(`/api/settings/telegram`).then(e=>{S(!!e.bot_token)}).catch(()=>{}),Y(),X(`_global`),Z(),J.current=setInterval(Z,1e4),()=>{J.current&&clearInterval(J.current)}),[Y,X,Z]);let $=async()=>{if(y.trim()){w(!0),v(null);try{await l.put(`/api/settings/telegram`,{bot_token:y}),S(!0),b(``),v({type:`ok`,msg:`Bot token saved`})}catch(e){v({type:`err`,msg:e.message})}finally{w(!1)}}},te=async()=>{g(!0),v(null);try{let e={enabled:T,system_prompt:D,show_tool_calls:k,show_thinking:j,debounce_ms:N};t(await l.put(`/api/settings/clawbot`,e)),v({type:`ok`,msg:T?`Saved — bot started`:`Saved — bot stopped`})}catch(e){v({type:`err`,msg:e.message})}finally{g(!1)}},ne=async()=>{if(L.trim()){B(!0);try{await l.post(`/api/settings/clawbot/paired/approve`,{code:L.trim().toUpperCase()}),R(``),await Y(),v({type:`ok`,msg:`Device approved`})}catch(e){v({type:`err`,msg:e.message})}finally{B(!1)}}},re=async e=>{try{await l.del(`/api/settings/clawbot/paired/${e}`),await Y(),v({type:`ok`,msg:`Device revoked`})}catch(e){v({type:`err`,msg:e.message})}},ie=async()=>{H(!0),v(null);try{await l.post(`/api/settings/telegram/test`,{}),v({type:`ok`,msg:`Test notification sent to all paired devices!`})}catch(e){v({type:`err`,msg:e.message})}finally{H(!1)}};if(!e)return(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading...`});let ae=F.filter(e=>e.status===`approved`).length,oe={pending:`⏳`,running:`🔄`,completed:`✅`,failed:`❌`,timeout:`⏱`},se={running:`text-primary`,completed:`text-success`,failed:`text-destructive`,timeout:`text-warning`};return(0,h.jsxs)(`div`,{className:`space-y-4`,children:[(0,h.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,h.jsx)(`label`,{className:`text-[11px] text-muted-foreground`,children:`Telegram Bot Token`}),(0,h.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,h.jsx)(d,{type:`password`,placeholder:x?`•••••• (saved)`:`123456:ABC-DEF...`,value:y,onChange:e=>b(e.target.value),className:`h-7 text-xs flex-1`}),(0,h.jsx)(u,{variant:`outline`,size:`sm`,className:`h-7 text-xs shrink-0 cursor-pointer`,disabled:C||!y.trim(),onClick:$,children:C?`...`:`Save`})]}),(0,h.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[`Create a bot via `,(0,h.jsx)(`b`,{children:`@BotFather`}),` on Telegram. Used for both chat and notifications.`]})]}),(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`p`,{className:`text-xs font-medium`,children:`Enable PPMBot`}),(0,h.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`AI coordinator on Telegram — delegates tasks to your projects`})]}),(0,h.jsx)(f,{checked:T,onCheckedChange:E})]}),(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(`p`,{className:`text-xs font-medium`,children:`Paired Devices`}),(0,h.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Send any message to the bot on Telegram to get a pairing code. Enter it below to approve. Notifications are sent to all approved devices.`}),(0,h.jsxs)(`div`,{className:`flex gap-2`,children:[(0,h.jsx)(d,{placeholder:`Enter pairing code (e.g. A3K7WR)`,value:L,onChange:e=>R(e.target.value.toUpperCase()),className:`h-8 text-xs font-mono tracking-wider uppercase`,maxLength:6}),(0,h.jsx)(u,{variant:`outline`,size:`sm`,className:`h-8 text-xs shrink-0 cursor-pointer`,disabled:z||L.length<6,onClick:ne,children:z?`...`:`Approve`})]}),F.length===0?(0,h.jsx)(`p`,{className:`text-[10px] text-muted-foreground italic`,children:`No paired devices yet.`}):(0,h.jsx)(`div`,{className:`space-y-1`,children:F.map(e=>(0,h.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border p-2`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[e.status===`approved`?(0,h.jsx)(a,{className:`size-3.5 text-success shrink-0`}):(0,h.jsx)(r,{className:`size-3.5 text-warning shrink-0`}),(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(`p`,{className:`text-xs truncate`,children:e.display_name||`Chat ${e.telegram_chat_id}`}),(0,h.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:e.status===`pending`&&e.pairing_code?`Code: ${e.pairing_code}`:e.status})]})]}),(0,h.jsx)(u,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 text-destructive hover:text-destructive cursor-pointer`,onClick:()=>re(e.telegram_chat_id),children:(0,h.jsx)(i,{className:`size-3.5`})})]},e.id))}),x&&ae>0&&(0,h.jsxs)(u,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1 w-full cursor-pointer`,disabled:V,onClick:ie,children:[(0,h.jsx)(s,{className:`size-3`}),V?`Sending...`:`Test Notification`]})]}),(0,h.jsx)(p,{}),(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsx)(`p`,{className:`text-xs font-medium`,children:`Delegated Tasks`}),(0,h.jsx)(u,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 cursor-pointer`,onClick:Z,children:(0,h.jsx)(c,{className:`size-3`})})]}),K.length===0?(0,h.jsx)(`p`,{className:`text-[10px] text-muted-foreground italic`,children:`No delegated tasks yet. The coordinator will create tasks when you ask it to work on a project.`}):(0,h.jsx)(`div`,{className:`space-y-1 max-h-[200px] overflow-y-auto`,children:K.map(e=>{let t=e.completed_at?`${Math.round((e.completed_at-e.created_at)/60)}m`:`${Math.round((Date.now()/1e3-e.created_at)/60)}m`;return(0,h.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border p-2 text-[11px]`,children:[(0,h.jsx)(`span`,{className:se[e.status]??``,children:oe[e.status]??`?`}),(0,h.jsx)(`span`,{className:`font-medium shrink-0`,children:e.project_name}),(0,h.jsx)(`span`,{className:`truncate text-muted-foreground flex-1`,children:e.prompt.slice(0,60)}),(0,h.jsx)(`span`,{className:`text-[10px] text-muted-foreground shrink-0`,children:t})]},e.id)})})]}),(0,h.jsx)(p,{}),(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,h.jsx)(o,{className:`size-3.5 text-muted-foreground`}),(0,h.jsx)(`p`,{className:`text-xs font-medium`,children:`Memory & Identity`})]}),(0,h.jsx)(u,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 cursor-pointer`,onClick:()=>X(G),children:(0,h.jsx)(c,{className:`size-3`})})]}),(0,h.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Facts the bot remembers across sessions. Use /remember on Telegram to add, or delete here.`}),U.length===0?(0,h.jsx)(`p`,{className:`text-[10px] text-muted-foreground italic`,children:`No memories stored yet. Send /start on Telegram and introduce yourself.`}):(0,h.jsx)(`div`,{className:`space-y-1 max-h-[200px] overflow-y-auto`,children:U.map(e=>(0,h.jsxs)(`div`,{className:`flex items-start justify-between rounded-md border p-2 gap-1`,children:[(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`p`,{className:`text-[11px] break-words`,children:e.content}),(0,h.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[e.category,` · `,e.project]})]}),(0,h.jsx)(u,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-destructive hover:text-destructive cursor-pointer shrink-0`,onClick:()=>Q(e.id),children:(0,h.jsx)(i,{className:`size-3`})})]},e.id))})]}),(0,h.jsx)(p,{}),(0,h.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,h.jsx)(`label`,{className:`text-[11px] text-muted-foreground`,children:`Custom Instructions`}),(0,h.jsx)(`textarea`,{placeholder:`Additional instructions for the coordinator (optional)...`,value:D,onChange:e=>O(e.target.value),className:`flex w-full rounded-md border border-input bg-background px-3 py-2 text-xs min-h-[60px] resize-y ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,rows:3}),(0,h.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Extra instructions added to the coordinator identity. Leave empty to use defaults from coordinator.md.`})]}),(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsx)(`p`,{className:`text-xs`,children:`Show tool calls`}),(0,h.jsx)(f,{checked:k,onCheckedChange:A})]}),(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsx)(`p`,{className:`text-xs`,children:`Show thinking`}),(0,h.jsx)(f,{checked:j,onCheckedChange:M})]})]}),(0,h.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,h.jsx)(`label`,{className:`text-[11px] text-muted-foreground`,children:`Debounce (ms)`}),(0,h.jsx)(d,{type:`number`,min:0,max:3e4,step:500,value:N,onChange:e=>P(Number(e.target.value)),className:`h-7 text-xs w-24`}),(0,h.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Merge rapid messages within this window. 0 = no debounce.`})]}),(0,h.jsx)(u,{variant:`default`,size:`sm`,className:`h-8 text-xs w-full cursor-pointer`,disabled:n,onClick:te,children:n?`Saving...`:`Save`}),_&&(0,h.jsx)(`p`,{className:`text-[11px] ${_.type===`ok`?`text-success`:`text-destructive`}`,children:_.msg})]})}export{g as PPMBotSettingsSection};
1
+ import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import"./vendor-ui-P9Ym7hCv.js";import{J as r,Mr as i,T as a,b as o,dr as s,ir as c}from"./icons-CO_II6D-.js";import{r as l}from"./api-client-F5Zi1sR0.js";import{t as u}from"./button-CsmGH5xa.js";import{t as d}from"./input-CP31LZnN.js";import{Ct as f}from"./index-D41mthBS.js";import{t as p}from"./separator-B0xYRplF.js";var m=e(t(),1),h=n();function g(){let[e,t]=(0,m.useState)(null),[n,g]=(0,m.useState)(!1),[_,v]=(0,m.useState)(null),[y,b]=(0,m.useState)(``),[x,S]=(0,m.useState)(!1),[C,w]=(0,m.useState)(!1),[T,E]=(0,m.useState)(!1),[D,O]=(0,m.useState)(``),[k,A]=(0,m.useState)(!0),[j,M]=(0,m.useState)(!1),[N,P]=(0,m.useState)(2e3),[F,I]=(0,m.useState)([]),[L,R]=(0,m.useState)(``),[z,B]=(0,m.useState)(!1),[V,H]=(0,m.useState)(!1),[U,W]=(0,m.useState)([]),[G,ee]=(0,m.useState)(`_global`),[K,q]=(0,m.useState)([]),J=(0,m.useRef)(void 0),Y=(0,m.useCallback)(async()=>{try{I(await l.get(`/api/settings/clawbot/paired`))}catch{}},[]),X=(0,m.useCallback)(async(e=G)=>{try{W(await l.get(`/api/settings/clawbot/memories?project=${encodeURIComponent(e)}`))}catch{}},[G]),Z=(0,m.useCallback)(async()=>{try{q(await l.get(`/api/settings/clawbot/tasks?limit=20`))}catch{}},[]),Q=async e=>{try{await l.del(`/api/settings/clawbot/memories/${e}`),W(t=>t.filter(t=>t.id!==e))}catch{}};(0,m.useEffect)(()=>(l.get(`/api/settings/clawbot`).then(e=>{t(e),E(e.enabled),O(e.system_prompt),A(e.show_tool_calls),M(e.show_thinking),P(e.debounce_ms)}).catch(()=>{}),l.get(`/api/settings/telegram`).then(e=>{S(!!e.bot_token)}).catch(()=>{}),Y(),X(`_global`),Z(),J.current=setInterval(Z,1e4),()=>{J.current&&clearInterval(J.current)}),[Y,X,Z]);let $=async()=>{if(y.trim()){w(!0),v(null);try{await l.put(`/api/settings/telegram`,{bot_token:y}),S(!0),b(``),v({type:`ok`,msg:`Bot token saved`})}catch(e){v({type:`err`,msg:e.message})}finally{w(!1)}}},te=async()=>{g(!0),v(null);try{let e={enabled:T,system_prompt:D,show_tool_calls:k,show_thinking:j,debounce_ms:N};t(await l.put(`/api/settings/clawbot`,e)),v({type:`ok`,msg:T?`Saved — bot started`:`Saved — bot stopped`})}catch(e){v({type:`err`,msg:e.message})}finally{g(!1)}},ne=async()=>{if(L.trim()){B(!0);try{await l.post(`/api/settings/clawbot/paired/approve`,{code:L.trim().toUpperCase()}),R(``),await Y(),v({type:`ok`,msg:`Device approved`})}catch(e){v({type:`err`,msg:e.message})}finally{B(!1)}}},re=async e=>{try{await l.del(`/api/settings/clawbot/paired/${e}`),await Y(),v({type:`ok`,msg:`Device revoked`})}catch(e){v({type:`err`,msg:e.message})}},ie=async()=>{H(!0),v(null);try{await l.post(`/api/settings/telegram/test`,{}),v({type:`ok`,msg:`Test notification sent to all paired devices!`})}catch(e){v({type:`err`,msg:e.message})}finally{H(!1)}};if(!e)return(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading...`});let ae=F.filter(e=>e.status===`approved`).length,oe={pending:`⏳`,running:`🔄`,completed:`✅`,failed:`❌`,timeout:`⏱`},se={running:`text-primary`,completed:`text-success`,failed:`text-destructive`,timeout:`text-warning`};return(0,h.jsxs)(`div`,{className:`space-y-4`,children:[(0,h.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,h.jsx)(`label`,{className:`text-[11px] text-muted-foreground`,children:`Telegram Bot Token`}),(0,h.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,h.jsx)(d,{type:`password`,placeholder:x?`•••••• (saved)`:`123456:ABC-DEF...`,value:y,onChange:e=>b(e.target.value),className:`h-7 text-xs flex-1`}),(0,h.jsx)(u,{variant:`outline`,size:`sm`,className:`h-7 text-xs shrink-0 cursor-pointer`,disabled:C||!y.trim(),onClick:$,children:C?`...`:`Save`})]}),(0,h.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[`Create a bot via `,(0,h.jsx)(`b`,{children:`@BotFather`}),` on Telegram. Used for both chat and notifications.`]})]}),(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`p`,{className:`text-xs font-medium`,children:`Enable PPMBot`}),(0,h.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`AI coordinator on Telegram — delegates tasks to your projects`})]}),(0,h.jsx)(f,{checked:T,onCheckedChange:E})]}),(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(`p`,{className:`text-xs font-medium`,children:`Paired Devices`}),(0,h.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Send any message to the bot on Telegram to get a pairing code. Enter it below to approve. Notifications are sent to all approved devices.`}),(0,h.jsxs)(`div`,{className:`flex gap-2`,children:[(0,h.jsx)(d,{placeholder:`Enter pairing code (e.g. A3K7WR)`,value:L,onChange:e=>R(e.target.value.toUpperCase()),className:`h-8 text-xs font-mono tracking-wider uppercase`,maxLength:6}),(0,h.jsx)(u,{variant:`outline`,size:`sm`,className:`h-8 text-xs shrink-0 cursor-pointer`,disabled:z||L.length<6,onClick:ne,children:z?`...`:`Approve`})]}),F.length===0?(0,h.jsx)(`p`,{className:`text-[10px] text-muted-foreground italic`,children:`No paired devices yet.`}):(0,h.jsx)(`div`,{className:`space-y-1`,children:F.map(e=>(0,h.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border p-2`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[e.status===`approved`?(0,h.jsx)(a,{className:`size-3.5 text-success shrink-0`}):(0,h.jsx)(r,{className:`size-3.5 text-warning shrink-0`}),(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(`p`,{className:`text-xs truncate`,children:e.display_name||`Chat ${e.telegram_chat_id}`}),(0,h.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:e.status===`pending`&&e.pairing_code?`Code: ${e.pairing_code}`:e.status})]})]}),(0,h.jsx)(u,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 text-destructive hover:text-destructive cursor-pointer`,onClick:()=>re(e.telegram_chat_id),children:(0,h.jsx)(i,{className:`size-3.5`})})]},e.id))}),x&&ae>0&&(0,h.jsxs)(u,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1 w-full cursor-pointer`,disabled:V,onClick:ie,children:[(0,h.jsx)(s,{className:`size-3`}),V?`Sending...`:`Test Notification`]})]}),(0,h.jsx)(p,{}),(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsx)(`p`,{className:`text-xs font-medium`,children:`Delegated Tasks`}),(0,h.jsx)(u,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 cursor-pointer`,onClick:Z,children:(0,h.jsx)(c,{className:`size-3`})})]}),K.length===0?(0,h.jsx)(`p`,{className:`text-[10px] text-muted-foreground italic`,children:`No delegated tasks yet. The coordinator will create tasks when you ask it to work on a project.`}):(0,h.jsx)(`div`,{className:`space-y-1 max-h-[200px] overflow-y-auto`,children:K.map(e=>{let t=e.completed_at?`${Math.round((e.completed_at-e.created_at)/60)}m`:`${Math.round((Date.now()/1e3-e.created_at)/60)}m`;return(0,h.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border p-2 text-[11px]`,children:[(0,h.jsx)(`span`,{className:se[e.status]??``,children:oe[e.status]??`?`}),(0,h.jsx)(`span`,{className:`font-medium shrink-0`,children:e.project_name}),(0,h.jsx)(`span`,{className:`truncate text-muted-foreground flex-1`,children:e.prompt.slice(0,60)}),(0,h.jsx)(`span`,{className:`text-[10px] text-muted-foreground shrink-0`,children:t})]},e.id)})})]}),(0,h.jsx)(p,{}),(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,h.jsx)(o,{className:`size-3.5 text-muted-foreground`}),(0,h.jsx)(`p`,{className:`text-xs font-medium`,children:`Memory & Identity`})]}),(0,h.jsx)(u,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 cursor-pointer`,onClick:()=>X(G),children:(0,h.jsx)(c,{className:`size-3`})})]}),(0,h.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Facts the bot remembers across sessions. Use /remember on Telegram to add, or delete here.`}),U.length===0?(0,h.jsx)(`p`,{className:`text-[10px] text-muted-foreground italic`,children:`No memories stored yet. Send /start on Telegram and introduce yourself.`}):(0,h.jsx)(`div`,{className:`space-y-1 max-h-[200px] overflow-y-auto`,children:U.map(e=>(0,h.jsxs)(`div`,{className:`flex items-start justify-between rounded-md border p-2 gap-1`,children:[(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`p`,{className:`text-[11px] break-words`,children:e.content}),(0,h.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[e.category,` · `,e.project]})]}),(0,h.jsx)(u,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-destructive hover:text-destructive cursor-pointer shrink-0`,onClick:()=>Q(e.id),children:(0,h.jsx)(i,{className:`size-3`})})]},e.id))})]}),(0,h.jsx)(p,{}),(0,h.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,h.jsx)(`label`,{className:`text-[11px] text-muted-foreground`,children:`Custom Instructions`}),(0,h.jsx)(`textarea`,{placeholder:`Additional instructions for the coordinator (optional)...`,value:D,onChange:e=>O(e.target.value),className:`flex w-full rounded-md border border-input bg-background px-3 py-2 text-xs min-h-[60px] resize-y ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,rows:3}),(0,h.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Extra instructions added to the coordinator identity. Leave empty to use defaults from coordinator.md.`})]}),(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsx)(`p`,{className:`text-xs`,children:`Show tool calls`}),(0,h.jsx)(f,{checked:k,onCheckedChange:A})]}),(0,h.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,h.jsx)(`p`,{className:`text-xs`,children:`Show thinking`}),(0,h.jsx)(f,{checked:j,onCheckedChange:M})]})]}),(0,h.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,h.jsx)(`label`,{className:`text-[11px] text-muted-foreground`,children:`Debounce (ms)`}),(0,h.jsx)(d,{type:`number`,min:0,max:3e4,step:500,value:N,onChange:e=>P(Number(e.target.value)),className:`h-7 text-xs w-24`}),(0,h.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Merge rapid messages within this window. 0 = no debounce.`})]}),(0,h.jsx)(u,{variant:`default`,size:`sm`,className:`h-8 text-xs w-full cursor-pointer`,disabled:n,onClick:te,children:n?`Saving...`:`Save`}),_&&(0,h.jsx)(`p`,{className:`text-[11px] ${_.type===`ok`?`text-success`:`text-destructive`}`,children:_.msg})]})}export{g as PPMBotSettingsSection};
@@ -1 +1 @@
1
- import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import"./vendor-ui-P9Ym7hCv.js";import{Jt as r,O as i,U as a,j as o,r as s,tn as c}from"./icons-CO_II6D-.js";import"./api-client-F5Zi1sR0.js";import{n as l}from"./utils-btZ8C8-R.js";import{t as u}from"./panel-store-DrSH3Nhp.js";import"./window-store-B4cbZ5rr.js";import{i as d}from"./project-store-CCimwgGF.js";import{n as f}from"./use-is-mobile-CkO33jqU.js";import{t as p}from"./file-icons-Ed_yLyef.js";import{G as m,J as h,K as g,W as _,gn as v,q as y}from"./index-DQCw6d-2.js";var b=e(t(),1),x=n();function S(){let e=h(v(e=>e.files)),t=d(e=>e.activeProject?.name??null),n=f(),[r,c]=(0,b.useState)(new Set),[S,D]=(0,b.useState)(``),O=(0,b.useMemo)(()=>_(e,t),[e,t]),k=(0,b.useMemo)(()=>{let e=y(O),t=S.trim().toLowerCase();return t?e.map(e=>({...e,diagnostics:e.filePath.toLowerCase().includes(t)?e.diagnostics:e.diagnostics.filter(e=>C(e,t))})).filter(e=>e.diagnostics.length>0):e},[O,S]),A=(0,b.useMemo)(()=>m(O),[O]),j=k.reduce((e,t)=>e+t.diagnostics.length,0);function M(e,t){let{grid:n,focusedPanelId:r,openTab:i}=u.getState(),a=n.flat(),o=a.includes(r)?r:a[0];i({type:`editor`,title:e.filePath.split(`/`).pop()??e.filePath,metadata:{filePath:e.filePath,projectName:e.projectName,lineNumber:t.range.start.line+1},projectId:e.projectName,closable:!0},o)}function N(e){c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return Object.keys(O).length===0?(0,x.jsxs)(`div`,{className:`p-4 space-y-2`,children:[(0,x.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`No problems have been detected in the open files.`}),(0,x.jsx)(`p`,{className:`text-[11px] text-text-subtle/70 leading-relaxed`,children:`Diagnostics come from the language server for each file you open, so a file that has never been opened is not checked.`})]}):(0,x.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,x.jsxs)(`div`,{className:`shrink-0 p-2 space-y-2 border-b border-border-soft`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-text-3`,children:[(0,x.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,x.jsx)(a,{className:`size-3 text-error`}),A.errors]}),(0,x.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,x.jsx)(s,{className:`size-3 text-warning`}),A.warnings]}),(0,x.jsxs)(`span`,{className:`ml-auto text-text-subtle`,children:[k.length,` file`,k.length===1?``:`s`]})]}),(0,x.jsx)(`input`,{value:S,onChange:e=>D(e.target.value),placeholder:`Filter problems`,className:l(`w-full rounded border border-border bg-surface px-2 text-xs outline-none focus:border-primary`,n?`min-h-11`:`py-1`)})]}),(0,x.jsxs)(`div`,{className:`flex-1 overflow-y-auto min-h-0`,children:[j===0&&(0,x.jsxs)(`p`,{className:`p-4 text-xs text-text-subtle`,children:[`No problems match “`,S.trim(),`”.`]}),k.map(e=>{let t=g(e.projectName,e.filePath),a=r.has(t);return(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`button`,{type:`button`,onClick:()=>N(t),className:l(`w-full flex items-center gap-1 px-2 text-left hover:bg-surface-elevated transition-colors`,n?`min-h-11`:`py-1`),children:[a?(0,x.jsx)(o,{className:`size-3 shrink-0 text-text-subtle`}):(0,x.jsx)(i,{className:`size-3 shrink-0 text-text-subtle`}),(0,x.jsx)(p,{name:e.filePath,className:`size-3.5`}),(0,x.jsx)(`span`,{className:`text-xs truncate`,children:e.filePath.split(`/`).pop()}),(0,x.jsx)(`span`,{className:`text-[10px] text-text-subtle truncate min-w-0`,children:E(e.filePath)}),(0,x.jsx)(`span`,{className:`ml-auto shrink-0 rounded-full bg-surface-elevated px-1.5 text-[10px] text-text-3`,children:e.diagnostics.length})]}),!a&&e.diagnostics.map((t,r)=>(0,x.jsxs)(`button`,{type:`button`,onClick:()=>M(e,t),title:t.message,className:l(`w-full flex items-start gap-1.5 pl-6 pr-2 text-left hover:bg-surface-elevated transition-colors`,n?`min-h-11 py-2`:`py-0.5`),children:[(0,x.jsx)(w,{severity:t.severity}),(0,x.jsx)(`span`,{className:l(`flex-1 min-w-0 text-xs text-text-2`,n?`break-words`:`truncate`),children:t.message}),(0,x.jsxs)(`span`,{className:`shrink-0 text-[10px] text-text-subtle font-mono pt-px`,children:[T(t),t.range.start.line+1,`:`,t.range.start.character+1]})]},`${t.range.start.line}:${t.range.start.character}:${r}`))]},t)})]})]})}function C(e,t){return e.message.toLowerCase().includes(t)||(e.source?.toLowerCase().includes(t)??!1)||String(e.code??``).toLowerCase().includes(t)}function w({severity:e}){return e===2?(0,x.jsx)(s,{className:`size-3 shrink-0 text-warning mt-px`}):e===3?(0,x.jsx)(r,{className:`size-3 shrink-0 text-info mt-px`}):e===4?(0,x.jsx)(c,{className:`size-3 shrink-0 text-text-subtle mt-px`}):(0,x.jsx)(a,{className:`size-3 shrink-0 text-error mt-px`})}function T(e){return e.source?e.code===void 0?`${e.source} `:`${e.source}(${e.code}) `:``}function E(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}export{S as ProblemsPanel};
1
+ import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import"./vendor-ui-P9Ym7hCv.js";import{Jt as r,O as i,U as a,j as o,r as s,tn as c}from"./icons-CO_II6D-.js";import"./api-client-F5Zi1sR0.js";import{n as l}from"./utils-btZ8C8-R.js";import{t as u}from"./panel-store-DrSH3Nhp.js";import"./window-store-B4cbZ5rr.js";import{i as d}from"./project-store-CCimwgGF.js";import{n as f}from"./use-is-mobile-CkO33jqU.js";import{t as p}from"./file-icons-Ed_yLyef.js";import{G as m,J as h,K as g,W as _,gn as v,q as y}from"./index-D41mthBS.js";var b=e(t(),1),x=n();function S(){let e=h(v(e=>e.files)),t=d(e=>e.activeProject?.name??null),n=f(),[r,c]=(0,b.useState)(new Set),[S,D]=(0,b.useState)(``),O=(0,b.useMemo)(()=>_(e,t),[e,t]),k=(0,b.useMemo)(()=>{let e=y(O),t=S.trim().toLowerCase();return t?e.map(e=>({...e,diagnostics:e.filePath.toLowerCase().includes(t)?e.diagnostics:e.diagnostics.filter(e=>C(e,t))})).filter(e=>e.diagnostics.length>0):e},[O,S]),A=(0,b.useMemo)(()=>m(O),[O]),j=k.reduce((e,t)=>e+t.diagnostics.length,0);function M(e,t){let{grid:n,focusedPanelId:r,openTab:i}=u.getState(),a=n.flat(),o=a.includes(r)?r:a[0];i({type:`editor`,title:e.filePath.split(`/`).pop()??e.filePath,metadata:{filePath:e.filePath,projectName:e.projectName,lineNumber:t.range.start.line+1},projectId:e.projectName,closable:!0},o)}function N(e){c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return Object.keys(O).length===0?(0,x.jsxs)(`div`,{className:`p-4 space-y-2`,children:[(0,x.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`No problems have been detected in the open files.`}),(0,x.jsx)(`p`,{className:`text-[11px] text-text-subtle/70 leading-relaxed`,children:`Diagnostics come from the language server for each file you open, so a file that has never been opened is not checked.`})]}):(0,x.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,x.jsxs)(`div`,{className:`shrink-0 p-2 space-y-2 border-b border-border-soft`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-text-3`,children:[(0,x.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,x.jsx)(a,{className:`size-3 text-error`}),A.errors]}),(0,x.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,x.jsx)(s,{className:`size-3 text-warning`}),A.warnings]}),(0,x.jsxs)(`span`,{className:`ml-auto text-text-subtle`,children:[k.length,` file`,k.length===1?``:`s`]})]}),(0,x.jsx)(`input`,{value:S,onChange:e=>D(e.target.value),placeholder:`Filter problems`,className:l(`w-full rounded border border-border bg-surface px-2 text-xs outline-none focus:border-primary`,n?`min-h-11`:`py-1`)})]}),(0,x.jsxs)(`div`,{className:`flex-1 overflow-y-auto min-h-0`,children:[j===0&&(0,x.jsxs)(`p`,{className:`p-4 text-xs text-text-subtle`,children:[`No problems match “`,S.trim(),`”.`]}),k.map(e=>{let t=g(e.projectName,e.filePath),a=r.has(t);return(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`button`,{type:`button`,onClick:()=>N(t),className:l(`w-full flex items-center gap-1 px-2 text-left hover:bg-surface-elevated transition-colors`,n?`min-h-11`:`py-1`),children:[a?(0,x.jsx)(o,{className:`size-3 shrink-0 text-text-subtle`}):(0,x.jsx)(i,{className:`size-3 shrink-0 text-text-subtle`}),(0,x.jsx)(p,{name:e.filePath,className:`size-3.5`}),(0,x.jsx)(`span`,{className:`text-xs truncate`,children:e.filePath.split(`/`).pop()}),(0,x.jsx)(`span`,{className:`text-[10px] text-text-subtle truncate min-w-0`,children:E(e.filePath)}),(0,x.jsx)(`span`,{className:`ml-auto shrink-0 rounded-full bg-surface-elevated px-1.5 text-[10px] text-text-3`,children:e.diagnostics.length})]}),!a&&e.diagnostics.map((t,r)=>(0,x.jsxs)(`button`,{type:`button`,onClick:()=>M(e,t),title:t.message,className:l(`w-full flex items-start gap-1.5 pl-6 pr-2 text-left hover:bg-surface-elevated transition-colors`,n?`min-h-11 py-2`:`py-0.5`),children:[(0,x.jsx)(w,{severity:t.severity}),(0,x.jsx)(`span`,{className:l(`flex-1 min-w-0 text-xs text-text-2`,n?`break-words`:`truncate`),children:t.message}),(0,x.jsxs)(`span`,{className:`shrink-0 text-[10px] text-text-subtle font-mono pt-px`,children:[T(t),t.range.start.line+1,`:`,t.range.start.character+1]})]},`${t.range.start.line}:${t.range.start.character}:${r}`))]},t)})]})]})}function C(e,t){return e.message.toLowerCase().includes(t)||(e.source?.toLowerCase().includes(t)??!1)||String(e.code??``).toLowerCase().includes(t)}function w({severity:e}){return e===2?(0,x.jsx)(s,{className:`size-3 shrink-0 text-warning mt-px`}):e===3?(0,x.jsx)(r,{className:`size-3 shrink-0 text-info mt-px`}):e===4?(0,x.jsx)(c,{className:`size-3 shrink-0 text-text-subtle mt-px`}):(0,x.jsx)(a,{className:`size-3 shrink-0 text-error mt-px`})}function T(e){return e.source?e.code===void 0?`${e.source} `:`${e.source}(${e.code}) `:``}function E(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}export{S as ProblemsPanel};
@@ -1 +1 @@
1
- import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import"./vendor-ui-P9Ym7hCv.js";import{Jr as r,O as i,j as a,ur as o}from"./icons-CO_II6D-.js";import{O as s,a as c,r as l}from"./api-client-F5Zi1sR0.js";import{n as u}from"./utils-btZ8C8-R.js";import"./portal-container-context-NFSuymMu.js";import"./context-menu-CH1mvCwA.js";import{n as d}from"./use-is-mobile-CkO33jqU.js";import"./button-CsmGH5xa.js";import{a as f,n as p,o as m,t as h}from"./dialog-z8PLkL8n.js";import{t as g}from"./mobile-bottom-sheet-CLic9ovp.js";import"./use-visual-viewport-C307OVeV.js";import{an as _,dn as v,fn as y,hn as ee,mn as b,on as x,pn as S,sn as C,un as w}from"./index-DQCw6d-2.js";import{r as T}from"./format-bytes-DZ8bW_uF.js";import{a as E,i as D,n as O,o as k,r as A,s as j,t as M}from"./process-row-format-Dbs_tAZ2.js";import{r as N,t as P}from"./use-process-kill-D7D9QvJG.js";import{n as te,r as ne,t as F}from"./sortable-header-IH47XuRI.js";var I=e(t(),1),L=[`swap`,`disk`,`gpu`,`net`],R={cpu:64,ram:80,swap:80,disk:120,gpu:90,net:120},z=`minmax(0,1fr)`,B=`44px`;function V(e){return e===`swap`||e===`disk`||e===`gpu`||e===`net`}function H(e){return Math.round(Math.min(400,Math.max(48,e)))}function U(e,t){let n=t[e];return typeof n==`number`&&Number.isFinite(n)?H(n):R[e]}function re(e,t,n={}){let r=L.filter(t=>e[t]),i=V(t)&&e[t]?t:null,a=e=>`${U(e,n)}px`,o=[z,a(`cpu`),a(`ram`)];return{wideTemplate:[...o,...r.map(a),B].join(` `),narrowTemplate:[...o,...i?[a(i)]:[],B].join(` `),columns:e,narrowExtra:i}}var W=`grid-cols-[var(--sysmon-grid-n)] @lg:grid-cols-[var(--sysmon-grid-w)]`;function G(e){return{"--sysmon-grid-n":e.narrowTemplate,"--sysmon-grid-w":e.wideTemplate}}function K(e,t){return e.narrowExtra===t?`block`:`hidden @lg:block`}var q=n(),J=150;function Y({mode:e,onModeChange:t,ppmOnly:n,onPpmOnlyChange:r,onQueryChange:i}){let[a,s]=(0,I.useState)(``),c=(0,I.useRef)(null);return(0,I.useEffect)(()=>(c.current&&clearTimeout(c.current),c.current=setTimeout(()=>i(a),J),()=>{c.current&&clearTimeout(c.current)}),[a]),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 p-2 border-b border-border shrink-0`,children:[(0,q.jsxs)(`div`,{className:`relative flex-1 min-w-[140px]`,children:[(0,q.jsx)(o,{className:`absolute left-2 top-1/2 -translate-y-1/2 size-3.5 text-text-subtle`}),(0,q.jsx)(`input`,{type:`text`,value:a,onChange:e=>s(e.target.value),placeholder:`Search processes`,"aria-label":`Search processes`,"data-testid":`sysmon-process-search`,className:`w-full min-h-11 md:min-h-8 pl-7 pr-2 text-sm rounded-md border border-border bg-transparent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>t(e===`grouped`?`flat`:`grouped`),"aria-pressed":e===`flat`,"data-testid":`sysmon-toggle-flat`,className:`min-h-11 md:min-h-8 px-3 text-xs rounded-md border border-border hover:bg-surface-hover transition-colors`,children:e===`flat`?`Flat`:`Grouped`}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>r(!n),"aria-pressed":n,"data-testid":`sysmon-filter-ppm`,className:u(`min-h-11 md:min-h-8 px-3 text-xs rounded-md border transition-colors`,n?`border-primary bg-primary/10 text-primary`:`border-border hover:bg-surface-hover`),children:`PPM only`})]})}function ie({sortKey:e,sortDir:t,grid:n,onSort:r,resize:i}){let a={activeKey:e,activeDir:t,onClick:r,resize:i};return(0,q.jsxs)(`div`,{role:`row`,className:u(`grid gap-1 px-3 py-1.5 text-[11px] text-text-subtle border-b border-border sticky top-0 bg-background z-10`,W),children:[(0,q.jsx)(F,{label:`Process`,field:`name`,...a,resize:void 0,align:`left`,testId:`sysmon-sort-name`}),(0,q.jsx)(F,{label:`CPU`,field:`cpu`,...a,resizeKey:`cpu`,testId:`sysmon-sort-cpu`}),(0,q.jsx)(F,{label:`RAM`,field:`ram`,...a,resizeKey:`ram`,testId:`sysmon-sort-ram`}),n.columns.swap&&(0,q.jsx)(F,{label:`Swap`,field:`swap`,...a,resizeKey:`swap`,testId:`sysmon-col-swap`,className:K(n,`swap`)}),n.columns.disk&&(0,q.jsx)(F,{label:`Disk`,field:`disk`,...a,resizeKey:`disk`,testId:`sysmon-col-disk`,className:K(n,`disk`)}),n.columns.gpu&&(0,q.jsx)(F,{label:`GPU`,field:`gpu`,...a,resizeKey:`gpu`,testId:`sysmon-col-gpu`,className:K(n,`gpu`)}),n.columns.net&&(0,q.jsx)(F,{label:`Net`,field:`net`,...a,resizeKey:`net`,testId:`sysmon-col-net`,className:K(n,`net`)}),(0,q.jsx)(`span`,{})]})}function ae({totals:e,grid:t,gpuUtilPercent:n}){return(0,q.jsxs)(`div`,{className:u(`grid gap-1 px-3 py-1.5 text-xs font-medium border-t border-border shrink-0`,W),"data-testid":`sysmon-total`,"data-process-count":e.count,children:[(0,q.jsxs)(`span`,{className:`truncate`,children:[`Total (`,e.count,` processes)`]}),(0,q.jsxs)(`span`,{className:u(`text-right`,M(e.cpu)),children:[e.cpu.toFixed(1),`%`]}),(0,q.jsx)(`span`,{className:`text-right text-text-secondary`,children:T(e.ramMB)}),t.columns.swap&&(0,q.jsx)(`span`,{className:u(`text-right text-text-secondary tabular-nums truncate`,K(t,`swap`)),children:k(e.swapMB)}),t.columns.disk&&(0,q.jsx)(`span`,{className:u(`text-right text-text-secondary tabular-nums truncate`,K(t,`disk`)),children:A(e.diskReadBps,e.diskWriteBps)}),t.columns.gpu&&(0,q.jsx)(`span`,{className:u(`text-right text-text-secondary tabular-nums truncate`,K(t,`gpu`)),children:D(n,e.gpuMemMB)}),t.columns.net&&(0,q.jsx)(`span`,{className:u(`text-right text-text-secondary tabular-nums truncate`,K(t,`net`)),children:E(e.netInBps,e.netOutBps)}),(0,q.jsx)(`span`,{})]})}var oe=`Protected: this app contains a PPM or OS-critical process — cannot be ended as a whole.`;function se({group:e,expanded:t,grid:n,killProtected:o,onToggle:s,onKillClick:c}){let l=t?i:a;return(0,q.jsxs)(`div`,{className:`grid items-center gap-1 min-h-11 md:min-h-7 px-3 text-xs cursor-pointer hover:bg-surface-hover transition-colors group/proc grid-cols-[var(--sysmon-grid-n)] @lg:grid-cols-[var(--sysmon-grid-w)]`,onClick:()=>s(e.key),"data-testid":`sysmon-group-row`,"data-group-key":e.key,"data-count":e.count,"data-disk-bps":j(e.diskReadBps,e.diskWriteBps),"data-gpu-pct":e.gpuPct,"data-net-bps":j(e.netInBps,e.netOutBps),children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),s(e.key)},"aria-expanded":t,"aria-label":`${t?`Collapse`:`Expand`} ${e.label}`,"data-testid":`sysmon-group-expand`,className:`flex items-center justify-center size-11 md:size-7 -ml-2 shrink-0`,children:(0,q.jsx)(l,{className:`size-3.5 text-text-subtle`})}),(0,q.jsx)(`span`,{className:`truncate font-medium`,children:e.label}),(0,q.jsxs)(`span`,{className:`text-text-subtle shrink-0`,children:[`(`,e.count,`)`]})]}),(0,q.jsxs)(`span`,{className:u(`text-right`,M(e.cpu)),children:[e.cpu.toFixed(1),`%`]}),(0,q.jsx)(`span`,{className:`text-right text-text-secondary`,children:T(e.ramMB)}),n.columns.swap&&(0,q.jsx)(`span`,{className:u(`text-right text-text-secondary tabular-nums truncate`,K(n,`swap`)),children:k(e.swapMB)}),n.columns.disk&&(0,q.jsx)(`span`,{className:u(`text-right text-text-secondary tabular-nums truncate`,K(n,`disk`)),children:A(e.diskReadBps,e.diskWriteBps)}),n.columns.gpu&&(0,q.jsx)(`span`,{className:u(`text-right text-text-secondary tabular-nums truncate`,K(n,`gpu`)),children:D(e.gpuPct,e.gpuMemMB)}),n.columns.net&&(0,q.jsx)(`span`,{className:u(`text-right text-text-secondary tabular-nums truncate`,K(n,`net`)),children:E(e.netInBps,e.netOutBps)}),(0,q.jsx)(`div`,{className:`flex justify-end`,children:(0,q.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),c(e)},disabled:o,"aria-label":`End ${e.label} and its ${e.count} processes`,title:o?oe:`End ${e.label} (${e.count} processes)`,"data-testid":`sysmon-group-kill-btn`,className:u(`flex items-center justify-center size-11 md:size-7 rounded transition-all`,`can-hover:opacity-0 can-hover:group-hover/proc:opacity-100`,o?`opacity-40 cursor-not-allowed`:`hover:bg-error/20 hover:text-error active:bg-error/30`),children:(0,q.jsx)(r,{className:`size-3.5`})})})]})}var ce=`Protected: PPM or OS-critical process — cannot be ended.`;function le({proc:e,indent:t,grid:n,onKillClick:i}){return(0,q.jsxs)(`div`,{className:`grid items-center gap-1 min-h-11 md:min-h-7 px-3 text-xs group/proc hover:bg-surface-hover transition-colors grid-cols-[var(--sysmon-grid-n)] @lg:grid-cols-[var(--sysmon-grid-w)]`,"data-testid":`sysmon-process-row`,"data-pid":e.pid,"data-ppm":e.ppm,"data-protected":e.protected,"data-swap-mb":e.swapMB,"data-disk-bps":j(e.diskReadBps,e.diskWriteBps),"data-gpu-pct":e.gpuPct,"data-net-bps":j(e.netInBps,e.netOutBps),children:[(0,q.jsxs)(`div`,{className:u(`flex items-start gap-1.5 min-w-0`,t&&`pl-6`),children:[(0,q.jsx)(`span`,{className:`text-text-subtle shrink-0`,children:e.pid}),(0,q.jsx)(`span`,{className:`truncate text-text-secondary`,title:e.startedAt?`${e.command}\nRunning ${O(e.startedAt)}`:e.command,children:e.command})]}),(0,q.jsxs)(`span`,{className:u(`text-right`,M(e.cpu)),children:[e.cpu.toFixed(1),`%`]}),(0,q.jsx)(`span`,{className:`text-right text-text-secondary`,children:T(e.ramMB)}),n.columns.swap&&(0,q.jsx)(`span`,{className:u(`text-right text-text-secondary tabular-nums truncate`,K(n,`swap`)),children:k(e.swapMB)}),n.columns.disk&&(0,q.jsx)(`span`,{className:u(`text-right text-text-secondary tabular-nums truncate`,K(n,`disk`)),children:A(e.diskReadBps,e.diskWriteBps)}),n.columns.gpu&&(0,q.jsx)(`span`,{className:u(`text-right text-text-secondary tabular-nums truncate`,K(n,`gpu`)),children:D(e.gpuPct,e.gpuMemMB)}),n.columns.net&&(0,q.jsx)(`span`,{className:u(`text-right text-text-secondary tabular-nums truncate`,K(n,`net`)),children:E(e.netInBps,e.netOutBps)}),(0,q.jsx)(`div`,{className:`flex justify-end`,children:(0,q.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),i(e)},disabled:e.protected,"aria-label":`End process ${e.name} (${e.pid})`,title:e.protected?ce:`End process ${e.name}`,"data-testid":`sysmon-kill-btn`,className:u(`flex items-center justify-center size-11 md:size-7 rounded transition-all`,`can-hover:opacity-0 can-hover:group-hover/proc:opacity-100`,e.protected?`opacity-40 cursor-not-allowed`:`hover:bg-error/20 hover:text-error active:bg-error/30`),children:(0,q.jsx)(r,{className:`size-3.5`})})})]})}var ue={STOP:`Suspend (SIGSTOP)`,CONT:`Continue (SIGCONT)`,TERM:`Terminate (SIGTERM)`,KILL:`Kill (SIGKILL)`,HUP:`Hang up (SIGHUP)`,INT:`Interrupt (SIGINT)`,USR1:`User signal 1`,USR2:`User signal 2`},de=[`KILL`,`STOP`];async function fe(e){let t=c(),n={"Content-Type":`application/json`,"X-PPM-Request":`1`};t&&(n.Authorization=`Bearer ${t}`);let r=await fetch(`/api/system/resources/signal`,{method:`POST`,headers:n,body:JSON.stringify(e)}),i;try{i=await r.json()}catch{throw Error(r.ok?`Empty response from server`:`Server error (HTTP ${r.status})`)}if(i.ok===!1)throw Error(i.error??`HTTP ${r.status}`);return i.data}function pe(e,t,n){return{pid:e.pid,startedAt:e.startedAt,signal:t,tree:n}}function me(){let[e,t]=(0,I.useState)(null);return{send:(0,I.useCallback)(async(e,n,r=!1)=>{t(e.pid);try{let t=(await fe(pe(e,n,r))).signalled.length;s.success(t>1?`Sent SIG${n} to ${e.name} and ${t-1} child processes`:`Sent SIG${n} to ${e.name} (${e.pid})`)}catch(t){s.error(t instanceof Error?t.message:`Could not signal ${e.name}`)}finally{t(null)}},[]),pending:e}}function he({proc:e,signals:t,onDetails:n,onKill:r,onSignal:i,children:a}){return(0,q.jsxs)(_,{children:[(0,q.jsx)(b,{asChild:!0,children:(0,q.jsx)(`div`,{className:`select-none`,children:a})}),(0,q.jsxs)(x,{children:[(0,q.jsx)(C,{onSelect:()=>n(e),children:`Details…`}),t.length>0&&(0,q.jsxs)(v,{children:[(0,q.jsx)(S,{children:`Send signal`}),(0,q.jsx)(y,{children:t.map(t=>(0,q.jsx)(C,{variant:de.includes(t)?`destructive`:void 0,disabled:e.protected,onSelect:()=>{e.protected||i(e,t,!1)},children:ue[t]},t))})]}),(0,q.jsx)(w,{}),(0,q.jsx)(C,{variant:`destructive`,disabled:e.protected,onSelect:()=>{e.protected||r(e)},children:`End process`}),e.protected&&(0,q.jsx)(`p`,{className:`px-2 py-1.5 text-[11px] text-text-subtle max-w-64`,children:`PPM or OS-critical process — it cannot be ended or signalled.`})]})]})}function ge(e){return e>0?new Date(e).toLocaleString():`—`}function _e({pid:e,name:t,onClose:n}){let r=d(),[i,a]=(0,I.useState)(null),[o,s]=(0,I.useState)(null);if((0,I.useEffect)(()=>{if(e===null){a(null),s(null);return}let t=!0;return a(null),s(null),l.get(`/api/system/resources/process/${e}`).then(e=>{t&&a(e)}).catch(e=>{t&&s(e instanceof Error?e.message:`Could not read the process`)}),()=>{t=!1}},[e]),e===null)return null;let c=(0,q.jsxs)(`div`,{className:`space-y-3`,"data-testid":`sysmon-process-details`,"data-pid":e,children:[o&&(0,q.jsx)(`p`,{className:`text-sm text-error`,children:o}),!o&&i===null&&(0,q.jsx)(`p`,{className:`text-sm text-text-subtle`,children:`Reading /proc…`}),i&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-4 gap-y-2 text-xs`,children:[(0,q.jsx)(X,{label:`PID`,value:i.pid}),(0,q.jsx)(X,{label:`Parent PID`,value:i.ppid}),(0,q.jsx)(X,{label:`User`,value:i.user}),(0,q.jsx)(X,{label:`State`,value:i.state}),(0,q.jsx)(X,{label:`Threads`,value:i.threads}),(0,q.jsx)(X,{label:`Nice`,value:i.nice}),(0,q.jsx)(X,{label:`Started`,value:ge(i.startedAt)}),(0,q.jsx)(X,{label:`Control group`,value:i.cgroup})]}),(0,q.jsx)(Z,{label:`Executable`,value:i.exe}),(0,q.jsx)(Z,{label:`Working directory`,value:i.cwd}),(0,q.jsx)(Z,{label:`Command line`,value:i.command,mono:!0})]})]});return r?(0,q.jsx)(g,{open:!0,onClose:n,children:(0,q.jsxs)(`div`,{className:`px-4 pb-4 space-y-3`,children:[(0,q.jsx)(`h2`,{className:`text-base font-semibold break-all`,children:t}),c]})}):(0,q.jsx)(h,{open:!0,onOpenChange:e=>!e&&n(),children:(0,q.jsxs)(p,{className:`sm:max-w-xl`,children:[(0,q.jsx)(f,{children:(0,q.jsx)(m,{className:`break-all`,children:t})}),c]})})}function X({label:e,value:t}){let n=t===null||t===``?`—`:String(t);return(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`dt`,{className:`text-text-subtle`,children:e}),(0,q.jsx)(`dd`,{className:`truncate`,title:n,children:n})]})}function Z({label:e,value:t,mono:n}){return(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:e}),(0,q.jsx)(`p`,{className:`text-xs break-all ${n?`font-mono`:``}`,children:t??`—`})]})}var Q=`ppm-sysmon-col-widths`;function ve(){try{let e=localStorage.getItem(Q);if(!e)return{};let t=JSON.parse(e),n={};for(let e of[`cpu`,`ram`,`disk`,`gpu`,`net`]){let r=t[e];typeof r==`number`&&Number.isFinite(r)&&(n[e]=H(r))}return n}catch{return{}}}function $(e){try{Object.keys(e).length===0?localStorage.removeItem(Q):localStorage.setItem(Q,JSON.stringify(e))}catch{}}function ye(){let[e,t]=(0,I.useState)(()=>typeof localStorage>`u`?{}:ve()),n=(0,I.useRef)(null);return(0,I.useEffect)(()=>{let e=e=>{let r=n.current;if(!r)return;let i=H(r.startWidth+(e.clientX-r.startX));t(e=>e[r.key]===i?e:{...e,[r.key]:i})},r=()=>{n.current&&(n.current=null,document.body.style.cursor=``,t(e=>($(e),e)))};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,r),window.addEventListener(`pointercancel`,r),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,r)}},[]),{widths:e,begin:(0,I.useCallback)((t,r)=>{r.preventDefault(),n.current={key:t,startX:r.clientX,startWidth:U(t,e)},document.body.style.cursor=`col-resize`},[e]),reset:(0,I.useCallback)(e=>{t(t=>{if(!(e in t))return t;let{[e]:n,...r}=t;return $(r),r})},[])}}var be={disk:!1,gpu:!1,net:!1};function xe({snapshot:e}){let t=d(),n=(0,I.useRef)(null),[r,i]=(0,I.useState)(`grouped`),[a,o]=(0,I.useState)(!1),[s,c]=(0,I.useState)(``),[l,u]=(0,I.useState)(null),[f,p]=(0,I.useState)(`desc`),[m,h]=(0,I.useState)(()=>new Set),{pendingKill:g,groupProtected:_,requestKillProcess:v,requestKillGroup:y,confirmKill:b,cancelKill:x}=P(e),{send:S}=me(),[C,w]=(0,I.useState)(null),T=e.signals??[],{widths:E,begin:D,reset:O}=ye(),{rows:k,totals:A}=(0,I.useMemo)(()=>te({processes:e.processes,groups:e.groups,mode:r,ppmOnly:a,query:s,sortKey:l,sortDir:f,expanded:m}),[e.processes,e.groups,r,a,s,l,f,m]),j=e.processColumns??be,M=(0,I.useMemo)(()=>re(j,l,E),[j,l,E]),F=e.system.gpus[0]?.utilPercent,L=ee({count:k.length,getScrollElement:()=>n.current,estimateSize:()=>t?44:28,overscan:12}),R=(0,I.useCallback)(e=>{let[t,n]=ne(l,f,e);u(t),p(n)},[l,f]),z=(0,I.useCallback)(e=>{h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);return(0,q.jsxs)(`div`,{className:`h-full flex flex-col min-h-0 @container`,style:G(M),"data-testid":`sysmon-processes`,"data-row-count":k.length,children:[(0,q.jsx)(Y,{mode:r,onModeChange:i,ppmOnly:a,onPpmOnlyChange:o,onQueryChange:c}),(0,q.jsx)(ie,{sortKey:l,sortDir:f,grid:M,onSort:R,resize:{onResizeStart:D,onResizeReset:O}}),(0,q.jsx)(`div`,{ref:n,className:`flex-1 min-h-0 overflow-y-auto`,children:(0,q.jsx)(`div`,{style:{height:L.getTotalSize(),position:`relative`},children:L.getVirtualItems().map(e=>{let t=k[e.index];return t?(0,q.jsx)(`div`,{style:{position:`absolute`,top:0,left:0,right:0,transform:`translateY(${e.start}px)`},children:t.kind===`group`?(0,q.jsx)(se,{group:t.group,expanded:t.expanded,grid:M,killProtected:_.get(t.group.key)??!0,onToggle:z,onKillClick:y}):(0,q.jsx)(he,{proc:t.proc,signals:T,onDetails:w,onKill:v,onSignal:(e,t,n)=>void S(e,t,n),children:(0,q.jsx)(le,{proc:t.proc,indent:t.indent,grid:M,onKillClick:v})})},t.kind===`group`?t.group.key:`p:${t.proc.pid}`):null})})}),(0,q.jsx)(ae,{totals:A,grid:M,gpuUtilPercent:F}),(0,q.jsx)(N,{target:g,onConfirm:b,onCancel:x}),(0,q.jsx)(_e,{pid:C?.pid??null,name:C?.name??``,onClose:()=>w(null)})]})}export{xe as ProcessTable};
1
+ import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import"./vendor-ui-P9Ym7hCv.js";import{Jr as r,O as i,j as a,ur as o}from"./icons-CO_II6D-.js";import{O as s,a as c,r as l}from"./api-client-F5Zi1sR0.js";import{n as u}from"./utils-btZ8C8-R.js";import"./portal-container-context-NFSuymMu.js";import"./context-menu-CH1mvCwA.js";import{n as d}from"./use-is-mobile-CkO33jqU.js";import"./button-CsmGH5xa.js";import{a as f,n as p,o as m,t as h}from"./dialog-z8PLkL8n.js";import{t as g}from"./mobile-bottom-sheet-CLic9ovp.js";import"./use-visual-viewport-C307OVeV.js";import{an as _,dn as v,fn as y,hn as ee,mn as b,on as x,pn as S,sn as C,un as w}from"./index-D41mthBS.js";import{r as T}from"./format-bytes-DZ8bW_uF.js";import{a as E,i as D,n as O,o as k,r as A,s as j,t as M}from"./process-row-format-Dbs_tAZ2.js";import{r as N,t as P}from"./use-process-kill-4gRMygIV.js";import{n as te,r as ne,t as F}from"./sortable-header-IH47XuRI.js";var I=e(t(),1),L=[`swap`,`disk`,`gpu`,`net`],R={cpu:64,ram:80,swap:80,disk:120,gpu:90,net:120},z=`minmax(0,1fr)`,B=`44px`;function V(e){return e===`swap`||e===`disk`||e===`gpu`||e===`net`}function H(e){return Math.round(Math.min(400,Math.max(48,e)))}function U(e,t){let n=t[e];return typeof n==`number`&&Number.isFinite(n)?H(n):R[e]}function re(e,t,n={}){let r=L.filter(t=>e[t]),i=V(t)&&e[t]?t:null,a=e=>`${U(e,n)}px`,o=[z,a(`cpu`),a(`ram`)];return{wideTemplate:[...o,...r.map(a),B].join(` `),narrowTemplate:[...o,...i?[a(i)]:[],B].join(` `),columns:e,narrowExtra:i}}var W=`grid-cols-[var(--sysmon-grid-n)] @lg:grid-cols-[var(--sysmon-grid-w)]`;function G(e){return{"--sysmon-grid-n":e.narrowTemplate,"--sysmon-grid-w":e.wideTemplate}}function K(e,t){return e.narrowExtra===t?`block`:`hidden @lg:block`}var q=n(),J=150;function Y({mode:e,onModeChange:t,ppmOnly:n,onPpmOnlyChange:r,onQueryChange:i}){let[a,s]=(0,I.useState)(``),c=(0,I.useRef)(null);return(0,I.useEffect)(()=>(c.current&&clearTimeout(c.current),c.current=setTimeout(()=>i(a),J),()=>{c.current&&clearTimeout(c.current)}),[a]),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 p-2 border-b border-border shrink-0`,children:[(0,q.jsxs)(`div`,{className:`relative flex-1 min-w-[140px]`,children:[(0,q.jsx)(o,{className:`absolute left-2 top-1/2 -translate-y-1/2 size-3.5 text-text-subtle`}),(0,q.jsx)(`input`,{type:`text`,value:a,onChange:e=>s(e.target.value),placeholder:`Search processes`,"aria-label":`Search processes`,"data-testid":`sysmon-process-search`,className:`w-full min-h-11 md:min-h-8 pl-7 pr-2 text-sm rounded-md border border-border bg-transparent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>t(e===`grouped`?`flat`:`grouped`),"aria-pressed":e===`flat`,"data-testid":`sysmon-toggle-flat`,className:`min-h-11 md:min-h-8 px-3 text-xs rounded-md border border-border hover:bg-surface-hover transition-colors`,children:e===`flat`?`Flat`:`Grouped`}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>r(!n),"aria-pressed":n,"data-testid":`sysmon-filter-ppm`,className:u(`min-h-11 md:min-h-8 px-3 text-xs rounded-md border transition-colors`,n?`border-primary bg-primary/10 text-primary`:`border-border hover:bg-surface-hover`),children:`PPM only`})]})}function ie({sortKey:e,sortDir:t,grid:n,onSort:r,resize:i}){let a={activeKey:e,activeDir:t,onClick:r,resize:i};return(0,q.jsxs)(`div`,{role:`row`,className:u(`grid gap-1 px-3 py-1.5 text-[11px] text-text-subtle border-b border-border sticky top-0 bg-background z-10`,W),children:[(0,q.jsx)(F,{label:`Process`,field:`name`,...a,resize:void 0,align:`left`,testId:`sysmon-sort-name`}),(0,q.jsx)(F,{label:`CPU`,field:`cpu`,...a,resizeKey:`cpu`,testId:`sysmon-sort-cpu`}),(0,q.jsx)(F,{label:`RAM`,field:`ram`,...a,resizeKey:`ram`,testId:`sysmon-sort-ram`}),n.columns.swap&&(0,q.jsx)(F,{label:`Swap`,field:`swap`,...a,resizeKey:`swap`,testId:`sysmon-col-swap`,className:K(n,`swap`)}),n.columns.disk&&(0,q.jsx)(F,{label:`Disk`,field:`disk`,...a,resizeKey:`disk`,testId:`sysmon-col-disk`,className:K(n,`disk`)}),n.columns.gpu&&(0,q.jsx)(F,{label:`GPU`,field:`gpu`,...a,resizeKey:`gpu`,testId:`sysmon-col-gpu`,className:K(n,`gpu`)}),n.columns.net&&(0,q.jsx)(F,{label:`Net`,field:`net`,...a,resizeKey:`net`,testId:`sysmon-col-net`,className:K(n,`net`)}),(0,q.jsx)(`span`,{})]})}function ae({totals:e,grid:t,gpuUtilPercent:n}){return(0,q.jsxs)(`div`,{className:u(`grid gap-1 px-3 py-1.5 text-xs font-medium border-t border-border shrink-0`,W),"data-testid":`sysmon-total`,"data-process-count":e.count,children:[(0,q.jsxs)(`span`,{className:`truncate`,children:[`Total (`,e.count,` processes)`]}),(0,q.jsxs)(`span`,{className:u(`text-right`,M(e.cpu)),children:[e.cpu.toFixed(1),`%`]}),(0,q.jsx)(`span`,{className:`text-right text-text-secondary`,children:T(e.ramMB)}),t.columns.swap&&(0,q.jsx)(`span`,{className:u(`text-right text-text-secondary tabular-nums truncate`,K(t,`swap`)),children:k(e.swapMB)}),t.columns.disk&&(0,q.jsx)(`span`,{className:u(`text-right text-text-secondary tabular-nums truncate`,K(t,`disk`)),children:A(e.diskReadBps,e.diskWriteBps)}),t.columns.gpu&&(0,q.jsx)(`span`,{className:u(`text-right text-text-secondary tabular-nums truncate`,K(t,`gpu`)),children:D(n,e.gpuMemMB)}),t.columns.net&&(0,q.jsx)(`span`,{className:u(`text-right text-text-secondary tabular-nums truncate`,K(t,`net`)),children:E(e.netInBps,e.netOutBps)}),(0,q.jsx)(`span`,{})]})}var oe=`Protected: this app contains a PPM or OS-critical process — cannot be ended as a whole.`;function se({group:e,expanded:t,grid:n,killProtected:o,onToggle:s,onKillClick:c}){let l=t?i:a;return(0,q.jsxs)(`div`,{className:`grid items-center gap-1 min-h-11 md:min-h-7 px-3 text-xs cursor-pointer hover:bg-surface-hover transition-colors group/proc grid-cols-[var(--sysmon-grid-n)] @lg:grid-cols-[var(--sysmon-grid-w)]`,onClick:()=>s(e.key),"data-testid":`sysmon-group-row`,"data-group-key":e.key,"data-count":e.count,"data-disk-bps":j(e.diskReadBps,e.diskWriteBps),"data-gpu-pct":e.gpuPct,"data-net-bps":j(e.netInBps,e.netOutBps),children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),s(e.key)},"aria-expanded":t,"aria-label":`${t?`Collapse`:`Expand`} ${e.label}`,"data-testid":`sysmon-group-expand`,className:`flex items-center justify-center size-11 md:size-7 -ml-2 shrink-0`,children:(0,q.jsx)(l,{className:`size-3.5 text-text-subtle`})}),(0,q.jsx)(`span`,{className:`truncate font-medium`,children:e.label}),(0,q.jsxs)(`span`,{className:`text-text-subtle shrink-0`,children:[`(`,e.count,`)`]})]}),(0,q.jsxs)(`span`,{className:u(`text-right`,M(e.cpu)),children:[e.cpu.toFixed(1),`%`]}),(0,q.jsx)(`span`,{className:`text-right text-text-secondary`,children:T(e.ramMB)}),n.columns.swap&&(0,q.jsx)(`span`,{className:u(`text-right text-text-secondary tabular-nums truncate`,K(n,`swap`)),children:k(e.swapMB)}),n.columns.disk&&(0,q.jsx)(`span`,{className:u(`text-right text-text-secondary tabular-nums truncate`,K(n,`disk`)),children:A(e.diskReadBps,e.diskWriteBps)}),n.columns.gpu&&(0,q.jsx)(`span`,{className:u(`text-right text-text-secondary tabular-nums truncate`,K(n,`gpu`)),children:D(e.gpuPct,e.gpuMemMB)}),n.columns.net&&(0,q.jsx)(`span`,{className:u(`text-right text-text-secondary tabular-nums truncate`,K(n,`net`)),children:E(e.netInBps,e.netOutBps)}),(0,q.jsx)(`div`,{className:`flex justify-end`,children:(0,q.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),c(e)},disabled:o,"aria-label":`End ${e.label} and its ${e.count} processes`,title:o?oe:`End ${e.label} (${e.count} processes)`,"data-testid":`sysmon-group-kill-btn`,className:u(`flex items-center justify-center size-11 md:size-7 rounded transition-all`,`can-hover:opacity-0 can-hover:group-hover/proc:opacity-100`,o?`opacity-40 cursor-not-allowed`:`hover:bg-error/20 hover:text-error active:bg-error/30`),children:(0,q.jsx)(r,{className:`size-3.5`})})})]})}var ce=`Protected: PPM or OS-critical process — cannot be ended.`;function le({proc:e,indent:t,grid:n,onKillClick:i}){return(0,q.jsxs)(`div`,{className:`grid items-center gap-1 min-h-11 md:min-h-7 px-3 text-xs group/proc hover:bg-surface-hover transition-colors grid-cols-[var(--sysmon-grid-n)] @lg:grid-cols-[var(--sysmon-grid-w)]`,"data-testid":`sysmon-process-row`,"data-pid":e.pid,"data-ppm":e.ppm,"data-protected":e.protected,"data-swap-mb":e.swapMB,"data-disk-bps":j(e.diskReadBps,e.diskWriteBps),"data-gpu-pct":e.gpuPct,"data-net-bps":j(e.netInBps,e.netOutBps),children:[(0,q.jsxs)(`div`,{className:u(`flex items-start gap-1.5 min-w-0`,t&&`pl-6`),children:[(0,q.jsx)(`span`,{className:`text-text-subtle shrink-0`,children:e.pid}),(0,q.jsx)(`span`,{className:`truncate text-text-secondary`,title:e.startedAt?`${e.command}\nRunning ${O(e.startedAt)}`:e.command,children:e.command})]}),(0,q.jsxs)(`span`,{className:u(`text-right`,M(e.cpu)),children:[e.cpu.toFixed(1),`%`]}),(0,q.jsx)(`span`,{className:`text-right text-text-secondary`,children:T(e.ramMB)}),n.columns.swap&&(0,q.jsx)(`span`,{className:u(`text-right text-text-secondary tabular-nums truncate`,K(n,`swap`)),children:k(e.swapMB)}),n.columns.disk&&(0,q.jsx)(`span`,{className:u(`text-right text-text-secondary tabular-nums truncate`,K(n,`disk`)),children:A(e.diskReadBps,e.diskWriteBps)}),n.columns.gpu&&(0,q.jsx)(`span`,{className:u(`text-right text-text-secondary tabular-nums truncate`,K(n,`gpu`)),children:D(e.gpuPct,e.gpuMemMB)}),n.columns.net&&(0,q.jsx)(`span`,{className:u(`text-right text-text-secondary tabular-nums truncate`,K(n,`net`)),children:E(e.netInBps,e.netOutBps)}),(0,q.jsx)(`div`,{className:`flex justify-end`,children:(0,q.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),i(e)},disabled:e.protected,"aria-label":`End process ${e.name} (${e.pid})`,title:e.protected?ce:`End process ${e.name}`,"data-testid":`sysmon-kill-btn`,className:u(`flex items-center justify-center size-11 md:size-7 rounded transition-all`,`can-hover:opacity-0 can-hover:group-hover/proc:opacity-100`,e.protected?`opacity-40 cursor-not-allowed`:`hover:bg-error/20 hover:text-error active:bg-error/30`),children:(0,q.jsx)(r,{className:`size-3.5`})})})]})}var ue={STOP:`Suspend (SIGSTOP)`,CONT:`Continue (SIGCONT)`,TERM:`Terminate (SIGTERM)`,KILL:`Kill (SIGKILL)`,HUP:`Hang up (SIGHUP)`,INT:`Interrupt (SIGINT)`,USR1:`User signal 1`,USR2:`User signal 2`},de=[`KILL`,`STOP`];async function fe(e){let t=c(),n={"Content-Type":`application/json`,"X-PPM-Request":`1`};t&&(n.Authorization=`Bearer ${t}`);let r=await fetch(`/api/system/resources/signal`,{method:`POST`,headers:n,body:JSON.stringify(e)}),i;try{i=await r.json()}catch{throw Error(r.ok?`Empty response from server`:`Server error (HTTP ${r.status})`)}if(i.ok===!1)throw Error(i.error??`HTTP ${r.status}`);return i.data}function pe(e,t,n){return{pid:e.pid,startedAt:e.startedAt,signal:t,tree:n}}function me(){let[e,t]=(0,I.useState)(null);return{send:(0,I.useCallback)(async(e,n,r=!1)=>{t(e.pid);try{let t=(await fe(pe(e,n,r))).signalled.length;s.success(t>1?`Sent SIG${n} to ${e.name} and ${t-1} child processes`:`Sent SIG${n} to ${e.name} (${e.pid})`)}catch(t){s.error(t instanceof Error?t.message:`Could not signal ${e.name}`)}finally{t(null)}},[]),pending:e}}function he({proc:e,signals:t,onDetails:n,onKill:r,onSignal:i,children:a}){return(0,q.jsxs)(_,{children:[(0,q.jsx)(b,{asChild:!0,children:(0,q.jsx)(`div`,{className:`select-none`,children:a})}),(0,q.jsxs)(x,{children:[(0,q.jsx)(C,{onSelect:()=>n(e),children:`Details…`}),t.length>0&&(0,q.jsxs)(v,{children:[(0,q.jsx)(S,{children:`Send signal`}),(0,q.jsx)(y,{children:t.map(t=>(0,q.jsx)(C,{variant:de.includes(t)?`destructive`:void 0,disabled:e.protected,onSelect:()=>{e.protected||i(e,t,!1)},children:ue[t]},t))})]}),(0,q.jsx)(w,{}),(0,q.jsx)(C,{variant:`destructive`,disabled:e.protected,onSelect:()=>{e.protected||r(e)},children:`End process`}),e.protected&&(0,q.jsx)(`p`,{className:`px-2 py-1.5 text-[11px] text-text-subtle max-w-64`,children:`PPM or OS-critical process — it cannot be ended or signalled.`})]})]})}function ge(e){return e>0?new Date(e).toLocaleString():`—`}function _e({pid:e,name:t,onClose:n}){let r=d(),[i,a]=(0,I.useState)(null),[o,s]=(0,I.useState)(null);if((0,I.useEffect)(()=>{if(e===null){a(null),s(null);return}let t=!0;return a(null),s(null),l.get(`/api/system/resources/process/${e}`).then(e=>{t&&a(e)}).catch(e=>{t&&s(e instanceof Error?e.message:`Could not read the process`)}),()=>{t=!1}},[e]),e===null)return null;let c=(0,q.jsxs)(`div`,{className:`space-y-3`,"data-testid":`sysmon-process-details`,"data-pid":e,children:[o&&(0,q.jsx)(`p`,{className:`text-sm text-error`,children:o}),!o&&i===null&&(0,q.jsx)(`p`,{className:`text-sm text-text-subtle`,children:`Reading /proc…`}),i&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-4 gap-y-2 text-xs`,children:[(0,q.jsx)(X,{label:`PID`,value:i.pid}),(0,q.jsx)(X,{label:`Parent PID`,value:i.ppid}),(0,q.jsx)(X,{label:`User`,value:i.user}),(0,q.jsx)(X,{label:`State`,value:i.state}),(0,q.jsx)(X,{label:`Threads`,value:i.threads}),(0,q.jsx)(X,{label:`Nice`,value:i.nice}),(0,q.jsx)(X,{label:`Started`,value:ge(i.startedAt)}),(0,q.jsx)(X,{label:`Control group`,value:i.cgroup})]}),(0,q.jsx)(Z,{label:`Executable`,value:i.exe}),(0,q.jsx)(Z,{label:`Working directory`,value:i.cwd}),(0,q.jsx)(Z,{label:`Command line`,value:i.command,mono:!0})]})]});return r?(0,q.jsx)(g,{open:!0,onClose:n,children:(0,q.jsxs)(`div`,{className:`px-4 pb-4 space-y-3`,children:[(0,q.jsx)(`h2`,{className:`text-base font-semibold break-all`,children:t}),c]})}):(0,q.jsx)(h,{open:!0,onOpenChange:e=>!e&&n(),children:(0,q.jsxs)(p,{className:`sm:max-w-xl`,children:[(0,q.jsx)(f,{children:(0,q.jsx)(m,{className:`break-all`,children:t})}),c]})})}function X({label:e,value:t}){let n=t===null||t===``?`—`:String(t);return(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`dt`,{className:`text-text-subtle`,children:e}),(0,q.jsx)(`dd`,{className:`truncate`,title:n,children:n})]})}function Z({label:e,value:t,mono:n}){return(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:e}),(0,q.jsx)(`p`,{className:`text-xs break-all ${n?`font-mono`:``}`,children:t??`—`})]})}var Q=`ppm-sysmon-col-widths`;function ve(){try{let e=localStorage.getItem(Q);if(!e)return{};let t=JSON.parse(e),n={};for(let e of[`cpu`,`ram`,`disk`,`gpu`,`net`]){let r=t[e];typeof r==`number`&&Number.isFinite(r)&&(n[e]=H(r))}return n}catch{return{}}}function $(e){try{Object.keys(e).length===0?localStorage.removeItem(Q):localStorage.setItem(Q,JSON.stringify(e))}catch{}}function ye(){let[e,t]=(0,I.useState)(()=>typeof localStorage>`u`?{}:ve()),n=(0,I.useRef)(null);return(0,I.useEffect)(()=>{let e=e=>{let r=n.current;if(!r)return;let i=H(r.startWidth+(e.clientX-r.startX));t(e=>e[r.key]===i?e:{...e,[r.key]:i})},r=()=>{n.current&&(n.current=null,document.body.style.cursor=``,t(e=>($(e),e)))};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,r),window.addEventListener(`pointercancel`,r),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,r)}},[]),{widths:e,begin:(0,I.useCallback)((t,r)=>{r.preventDefault(),n.current={key:t,startX:r.clientX,startWidth:U(t,e)},document.body.style.cursor=`col-resize`},[e]),reset:(0,I.useCallback)(e=>{t(t=>{if(!(e in t))return t;let{[e]:n,...r}=t;return $(r),r})},[])}}var be={disk:!1,gpu:!1,net:!1};function xe({snapshot:e}){let t=d(),n=(0,I.useRef)(null),[r,i]=(0,I.useState)(`grouped`),[a,o]=(0,I.useState)(!1),[s,c]=(0,I.useState)(``),[l,u]=(0,I.useState)(null),[f,p]=(0,I.useState)(`desc`),[m,h]=(0,I.useState)(()=>new Set),{pendingKill:g,groupProtected:_,requestKillProcess:v,requestKillGroup:y,confirmKill:b,cancelKill:x}=P(e),{send:S}=me(),[C,w]=(0,I.useState)(null),T=e.signals??[],{widths:E,begin:D,reset:O}=ye(),{rows:k,totals:A}=(0,I.useMemo)(()=>te({processes:e.processes,groups:e.groups,mode:r,ppmOnly:a,query:s,sortKey:l,sortDir:f,expanded:m}),[e.processes,e.groups,r,a,s,l,f,m]),j=e.processColumns??be,M=(0,I.useMemo)(()=>re(j,l,E),[j,l,E]),F=e.system.gpus[0]?.utilPercent,L=ee({count:k.length,getScrollElement:()=>n.current,estimateSize:()=>t?44:28,overscan:12}),R=(0,I.useCallback)(e=>{let[t,n]=ne(l,f,e);u(t),p(n)},[l,f]),z=(0,I.useCallback)(e=>{h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);return(0,q.jsxs)(`div`,{className:`h-full flex flex-col min-h-0 @container`,style:G(M),"data-testid":`sysmon-processes`,"data-row-count":k.length,children:[(0,q.jsx)(Y,{mode:r,onModeChange:i,ppmOnly:a,onPpmOnlyChange:o,onQueryChange:c}),(0,q.jsx)(ie,{sortKey:l,sortDir:f,grid:M,onSort:R,resize:{onResizeStart:D,onResizeReset:O}}),(0,q.jsx)(`div`,{ref:n,className:`flex-1 min-h-0 overflow-y-auto`,children:(0,q.jsx)(`div`,{style:{height:L.getTotalSize(),position:`relative`},children:L.getVirtualItems().map(e=>{let t=k[e.index];return t?(0,q.jsx)(`div`,{style:{position:`absolute`,top:0,left:0,right:0,transform:`translateY(${e.start}px)`},children:t.kind===`group`?(0,q.jsx)(se,{group:t.group,expanded:t.expanded,grid:M,killProtected:_.get(t.group.key)??!0,onToggle:z,onKillClick:y}):(0,q.jsx)(he,{proc:t.proc,signals:T,onDetails:w,onKill:v,onSignal:(e,t,n)=>void S(e,t,n),children:(0,q.jsx)(le,{proc:t.proc,indent:t.indent,grid:M,onKillClick:v})})},t.kind===`group`?t.group.key:`p:${t.proc.pid}`):null})})}),(0,q.jsx)(ae,{totals:A,grid:M,gpuUtilPercent:F}),(0,q.jsx)(N,{target:g,onConfirm:b,onCancel:x}),(0,q.jsx)(_e,{pid:C?.pid??null,name:C?.name??``,onClose:()=>w(null)})]})}export{xe as ProcessTable};
@@ -1 +1 @@
1
- import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import"./vendor-ui-P9Ym7hCv.js";import{St as r,Yn as i,ir as a,nt as o,un as s}from"./icons-CO_II6D-.js";import"./api-client-F5Zi1sR0.js";import"./portal-container-context-NFSuymMu.js";import"./chat-preparation-cache-DoS7sdal.js";import{t as c}from"./button-CsmGH5xa.js";import{a as l,n as u,o as d,r as f,s as p,t as m}from"./dialog-z8PLkL8n.js";import{t as h}from"./input-CP31LZnN.js";import{Ct as g,In as _,Nt as v}from"./index-DQCw6d-2.js";import{C as y,a as b,d as x}from"./api-settings-BeINN5Dy.js";var S=e(t(),1),C=[{value:`claude-opus-5-5`,label:`Claude Opus 5.5`,hint:`balanced, recommended`},{value:`claude-fable-5-1`,label:`Claude Fable 5.1`,hint:`flagship`},{value:`claude-opus-5`,label:`Claude Opus 5`,hint:`most powerful`},{value:`claude-fable-5`,label:`Claude Fable 5`,hint:`flagship`},{value:`claude-opus-4-8`,label:`Claude Opus 4.8`,hint:`powerful`},{value:`claude-opus-4-7`,label:`Claude Opus 4.7`,hint:`powerful`},{value:`claude-opus-4-6`,label:`Claude Opus 4.6`,hint:`powerful`},{value:`claude-sonnet-5`,label:`Claude Sonnet 5`,hint:`fast`},{value:`claude-sonnet-4-6`,label:`Claude Sonnet 4.6`,hint:`fast`},{value:`claude-haiku-4-5`,label:`Claude Haiku 4.5`,hint:`cheap`}];C.map(e=>e.value);function w(e,t){return`${e}/proxy${t?`/${t}`:``}`}function T(e,t){let n=w(e,t);return{anthropicBase:n,openAiBase:`${n}/v1`,anthropicMessages:`${n}/v1/messages`,openAiChatCompletions:`${n}/v1/chat/completions`,models:`${n}/v1/models`,imagesGenerations:t?`${n}/v1/images/generations`:null,imagesEdits:t?`${n}/v1/images/edits`:null}}var E=n(),D=`Hello! Reply briefly.`,O=`claude-opus-5-5`;function k(e){let[t,n]=(0,S.useState)(!1);return(0,E.jsxs)(m,{open:t,onOpenChange:n,children:[(0,E.jsx)(p,{asChild:!0,children:(0,E.jsxs)(c,{variant:`outline`,size:`sm`,className:`h-7 text-[11px] gap-1.5 cursor-pointer`,children:[(0,E.jsx)(r,{className:`size-3`}),`Test`]})}),(0,E.jsxs)(u,{className:`sm:max-w-md max-h-[85vh] overflow-y-auto`,children:[(0,E.jsxs)(l,{children:[(0,E.jsx)(d,{className:`text-sm`,children:`Test Proxy`}),(0,E.jsx)(f,{className:`text-[11px]`,children:`Send a test request and inspect the raw response.`})]}),t&&(0,E.jsx)(A,{...e})]})]})}function A({authKey:e,baseUrl:t,provider:n}){let[r,a]=(0,S.useState)(`anthropic`),[o,l]=(0,S.useState)(D),[u,d]=(0,S.useState)(n?``:O),[f,p]=(0,S.useState)(!0),[m,g]=(0,S.useState)(!1),[_,y]=(0,S.useState)(null),[b,x]=(0,S.useState)(null),[w,k]=(0,S.useState)(null),A=(0,S.useRef)(null),j=(0,S.useRef)(null);(0,S.useEffect)(()=>{A.current?.select()},[]),(0,S.useEffect)(()=>{j.current&&(j.current.scrollTop=j.current.scrollHeight)},[_]);let M=e=>{a(e),y(null),x(null),k(null)},N=async()=>{g(!0),y(null),x(null),k(null);let i=Date.now(),a=r===`openai`,s=T(t,n),c=a?s.openAiChatCompletions:s.anthropicMessages,l=JSON.stringify({...u?{model:u}:{},max_tokens:256,stream:f,messages:[{role:`user`,content:o}]}),d={"Content-Type":`application/json`};a?d.Authorization=`Bearer ${e}`:(d[`x-api-key`]=e,d[`anthropic-version`]=`2023-06-01`);try{let e=await fetch(c,{method:`POST`,headers:d,body:l});if(!e.ok){let t=await e.text();x(`HTTP ${e.status}: ${t}`),g(!1),k(Date.now()-i);return}if(f){let t=e.body?.getReader();if(!t){x(`No response body`),g(!1);return}let n=new TextDecoder,r=``;for(;;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0}),y(r)}k(Date.now()-i)}else{let t=await e.text();try{y(JSON.stringify(JSON.parse(t),null,2))}catch{y(t)}k(Date.now()-i)}}catch(e){x(e.message)}finally{g(!1),k(e=>e??Date.now()-i)}};return(0,E.jsxs)(`div`,{className:`space-y-3 min-w-0`,children:[(0,E.jsxs)(`div`,{className:`space-y-1.5 min-w-0`,children:[(0,E.jsx)(v,{className:`text-[11px]`,children:`Auth Style`}),(0,E.jsx)(`div`,{className:`flex gap-1`,children:[`anthropic`,`openai`].map(e=>(0,E.jsx)(`button`,{onClick:()=>M(e),className:`flex-1 h-8 rounded-md text-[11px] font-medium border transition-colors cursor-pointer ${r===e?`bg-primary text-primary-foreground border-primary`:`bg-muted text-muted-foreground border-transparent hover:bg-muted/80`}`,children:e===`anthropic`?`Anthropic`:`OpenAI`},e))}),(0,E.jsxs)(`p`,{className:`text-[9px] text-muted-foreground break-all`,children:[r===`anthropic`?`x-api-key header`:`Authorization: Bearer header`,` · `,(0,E.jsx)(`code`,{children:`/proxy${n?`/${n}`:``}/v1/${r===`anthropic`?`messages`:`chat/completions`}`})]})]}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(v,{className:`text-[11px]`,children:`Model`}),n?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(h,{value:u,onChange:e=>d(e.target.value),placeholder:`leave empty to let the provider choose`,className:`h-8 text-[11px] font-mono`}),(0,E.jsxs)(`p`,{className:`text-[9px] text-muted-foreground`,children:[`Names come from `,(0,E.jsxs)(`code`,{children:[`GET /proxy/`,n,`/v1/models`]}),`.`]})]}):(0,E.jsx)(`select`,{value:u,onChange:e=>d(e.target.value),className:`h-8 w-full rounded-md border bg-background px-2 text-[11px]`,children:C.map(e=>(0,E.jsx)(`option`,{value:e.value,children:e.value},e.value))})]}),(0,E.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,E.jsx)(v,{className:`text-[11px]`,children:`Streaming`}),(0,E.jsx)(`div`,{className:`flex gap-1`,children:[!0,!1].map(e=>(0,E.jsx)(`button`,{onClick:()=>p(e),className:`h-7 px-3 rounded-md text-[11px] font-medium border transition-colors cursor-pointer ${f===e?`bg-primary text-primary-foreground border-primary`:`bg-muted text-muted-foreground border-transparent hover:bg-muted/80`}`,children:e?`Stream`:`JSON`},String(e)))})]}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(v,{className:`text-[11px]`,children:`Message`}),(0,E.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,E.jsx)(h,{ref:A,value:o,onChange:e=>l(e.target.value),placeholder:`Type a test message...`,className:`h-9 text-[11px] flex-1 min-w-0`,onKeyDown:e=>{e.key===`Enter`&&!m&&N()}}),(0,E.jsxs)(c,{size:`sm`,className:`h-9 px-3 cursor-pointer shrink-0`,onClick:N,disabled:m||!o.trim(),children:[m?(0,E.jsx)(s,{className:`size-3.5 animate-spin`}):(0,E.jsx)(i,{className:`size-3.5`}),(0,E.jsx)(`span`,{className:`ml-1 text-[11px]`,children:m?`...`:`Send`})]})]})]}),(_||b)&&(0,E.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,E.jsx)(v,{className:`text-[10px] text-muted-foreground`,children:`Raw Response`}),w!=null&&(0,E.jsxs)(`span`,{className:`text-[9px] font-mono text-muted-foreground`,children:[(w/1e3).toFixed(1),`s`]})]}),b?(0,E.jsx)(`pre`,{className:`text-[9px] font-mono bg-error/10 text-error p-2 rounded overflow-auto max-h-52 whitespace-pre-wrap break-all`,children:b}):(0,E.jsx)(`pre`,{ref:j,className:`text-[9px] font-mono bg-muted p-2 rounded overflow-auto max-h-52 whitespace-pre-wrap break-all`,children:_})]})]})}function j(){let[e,t]=(0,S.useState)(``),[n,r]=(0,S.useState)([]);(0,S.useEffect)(()=>{b().then(e=>r(Object.keys(e.providers??{}).filter(e=>e!==`mock`&&e!==`claude`))).catch(()=>r([]))},[]);let[i,s]=(0,S.useState)(null),[l,u]=(0,S.useState)(!0),[d,f]=(0,S.useState)(!1),[p,m]=(0,S.useState)(null),[C,w]=(0,S.useState)(null);(0,S.useEffect)(()=>{u(!0),x().then(s).catch(e=>m(e.message)).finally(()=>u(!1))},[]);let D=async e=>{f(!0),m(null);try{s(await y(e))}catch(e){m(e.message)}finally{f(!1)}},O=(e,t)=>{_(e),w(t),setTimeout(()=>w(null),2e3)};if(l||!i)return(0,E.jsxs)(`div`,{className:`space-y-2`,children:[(0,E.jsx)(`h3`,{className:`text-xs font-medium text-text-secondary`,children:`API Proxy`}),(0,E.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:p?`Error: ${p}`:`Loading...`})]});let A=!!i.authKey,j=!!i.tunnelUrl,M=i.localEndpoint.replace(/\/proxy\/v1\/messages$/,``),N=T(j?i.tunnelUrl:M,e),P=N.anthropicMessages,F=N.openAiChatCompletions,I=`ANTHROPIC_BASE_URL=${N.anthropicBase}\nANTHROPIC_API_KEY=${i.authKey}`,L=`OPENAI_BASE_URL=${N.openAiBase}\nOPENAI_API_KEY=${i.authKey}`;return(0,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.jsx)(`div`,{className:`space-y-1.5`,children:(0,E.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Expose your accounts as an API that speaks both the Anthropic and OpenAI formats, so most SDKs need only a new base URL. The default path answers from your Claude accounts; pick a provider below to run its agent instead, which also unlocks image generation.`})}),(0,E.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,E.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,E.jsx)(v,{className:`text-xs`,children:`Enable Proxy`}),(0,E.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Accept API requests under /proxy`})]}),(0,E.jsx)(g,{checked:i.enabled,onCheckedChange:e=>D({enabled:e}),disabled:d})]}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(v,{className:`text-[11px]`,children:`Auth Key`}),A?(0,E.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,E.jsx)(h,{readOnly:!0,value:i.authKey,className:`h-7 text-[11px] font-mono flex-1`}),(0,E.jsx)(c,{variant:`outline`,size:`sm`,className:`h-7 px-2 cursor-pointer shrink-0`,onClick:()=>O(i.authKey,`key`),children:C===`key`?`Copied!`:(0,E.jsx)(o,{className:`size-3`})}),(0,E.jsx)(c,{variant:`outline`,size:`sm`,className:`h-7 px-2 cursor-pointer shrink-0`,onClick:()=>D({generateKey:!0}),disabled:d,children:(0,E.jsx)(a,{className:`size-3`})})]}):(0,E.jsx)(c,{variant:`outline`,size:`sm`,className:`h-7 text-xs cursor-pointer`,onClick:()=>D({generateKey:!0}),disabled:d,children:`Generate Auth Key`}),(0,E.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Use as Bearer token or x-api-key when calling the proxy.`})]}),i.enabled&&A&&(0,E.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3 bg-muted/30`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,E.jsx)(`h4`,{className:`text-[11px] font-medium`,children:`Connection Info`}),(0,E.jsx)(k,{authKey:i.authKey,baseUrl:window.location.origin,provider:e})]}),(0,E.jsxs)(`div`,{className:`space-y-1`,children:[(0,E.jsx)(v,{className:`text-[10px] text-muted-foreground`,children:`Provider`}),(0,E.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:[{id:``,label:`Claude (default)`},...n.map(e=>({id:e,label:e}))].map(n=>(0,E.jsx)(`button`,{type:`button`,onClick:()=>t(n.id),className:`text-[10px] px-2.5 min-h-[36px] rounded-md border transition-colors cursor-pointer ${e===n.id?`border-primary bg-primary/15`:`border-border bg-muted/40 hover:bg-muted`}`,children:n.label},n.id||`default`))}),e&&(0,E.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[`Runs the `,e,` agent per request (read-only sandbox, one turn). Slower than the default path.`]})]}),(0,E.jsxs)(`div`,{className:`space-y-1`,children:[(0,E.jsx)(v,{className:`text-[10px] text-muted-foreground`,children:`Anthropic Endpoint`}),(0,E.jsxs)(`div`,{className:`flex gap-1.5 items-center`,children:[(0,E.jsx)(`code`,{className:`text-[10px] font-mono bg-muted px-1.5 py-0.5 rounded flex-1 truncate`,children:P}),(0,E.jsx)(c,{variant:`ghost`,size:`sm`,className:`h-6 px-1.5 cursor-pointer shrink-0`,onClick:()=>O(P,`anthropic`),children:C===`anthropic`?`Copied!`:(0,E.jsx)(o,{className:`size-3`})})]})]}),(0,E.jsxs)(`div`,{className:`space-y-1`,children:[(0,E.jsx)(v,{className:`text-[10px] text-muted-foreground`,children:`OpenAI-Compatible Endpoint`}),(0,E.jsxs)(`div`,{className:`flex gap-1.5 items-center`,children:[(0,E.jsx)(`code`,{className:`text-[10px] font-mono bg-muted px-1.5 py-0.5 rounded flex-1 truncate`,children:F}),(0,E.jsx)(c,{variant:`ghost`,size:`sm`,className:`h-6 px-1.5 cursor-pointer shrink-0`,onClick:()=>O(F,`openai`),children:C===`openai`?`Copied!`:(0,E.jsx)(o,{className:`size-3`})})]})]}),N.imagesGenerations&&N.imagesEdits&&(0,E.jsxs)(`div`,{className:`space-y-1`,children:[(0,E.jsx)(v,{className:`text-[10px] text-muted-foreground`,children:`Image Endpoints`}),(0,E.jsx)(`code`,{className:`block text-[10px] font-mono bg-muted px-1.5 py-0.5 rounded truncate`,children:N.imagesGenerations}),(0,E.jsx)(`code`,{className:`block text-[10px] font-mono bg-muted px-1.5 py-0.5 rounded truncate`,children:N.imagesEdits})]}),!j&&(0,E.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Start a Cloudflare tunnel (Share) to get a public URL.`}),(0,E.jsxs)(`div`,{className:`space-y-1 pt-1`,children:[(0,E.jsx)(v,{className:`text-[10px] text-muted-foreground`,children:`Anthropic Format`}),(0,E.jsxs)(`div`,{className:`relative`,children:[(0,E.jsx)(`pre`,{className:`text-[9px] font-mono bg-muted p-2 rounded overflow-x-auto whitespace-pre`,children:I}),(0,E.jsx)(c,{variant:`ghost`,size:`sm`,className:`absolute top-1 right-1 h-5 px-1 cursor-pointer`,onClick:()=>O(I,`anthropic-env`),children:C===`anthropic-env`?`Copied!`:(0,E.jsx)(o,{className:`size-2.5`})})]})]}),(0,E.jsxs)(`div`,{className:`space-y-1`,children:[(0,E.jsx)(v,{className:`text-[10px] text-muted-foreground`,children:`OpenAI Format`}),(0,E.jsxs)(`div`,{className:`relative`,children:[(0,E.jsx)(`pre`,{className:`text-[9px] font-mono bg-muted p-2 rounded overflow-x-auto whitespace-pre`,children:L}),(0,E.jsx)(c,{variant:`ghost`,size:`sm`,className:`absolute top-1 right-1 h-5 px-1 cursor-pointer`,onClick:()=>O(L,`openai-env`),children:C===`openai-env`?`Copied!`:(0,E.jsx)(o,{className:`size-2.5`})})]})]}),(0,E.jsx)(`div`,{className:`flex items-center gap-3 pt-1`,children:(0,E.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`Requests served: `,(0,E.jsx)(`span`,{className:`font-mono`,children:i.requestCount})]})})]}),d&&(0,E.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:`Saving...`}),p&&(0,E.jsx)(`p`,{className:`text-[11px] text-error`,children:p})]})}export{j as ProxySettingsSection};
1
+ import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import"./vendor-ui-P9Ym7hCv.js";import{St as r,Yn as i,ir as a,nt as o,un as s}from"./icons-CO_II6D-.js";import"./api-client-F5Zi1sR0.js";import"./portal-container-context-NFSuymMu.js";import"./chat-preparation-cache-DoS7sdal.js";import{t as c}from"./button-CsmGH5xa.js";import{a as l,n as u,o as d,r as f,s as p,t as m}from"./dialog-z8PLkL8n.js";import{t as h}from"./input-CP31LZnN.js";import{Ct as g,In as _,Nt as v}from"./index-D41mthBS.js";import{C as y,a as b,d as x}from"./api-settings-BeINN5Dy.js";var S=e(t(),1),C=[{value:`claude-opus-5-5`,label:`Claude Opus 5.5`,hint:`balanced, recommended`},{value:`claude-fable-5-1`,label:`Claude Fable 5.1`,hint:`flagship`},{value:`claude-opus-5`,label:`Claude Opus 5`,hint:`most powerful`},{value:`claude-fable-5`,label:`Claude Fable 5`,hint:`flagship`},{value:`claude-opus-4-8`,label:`Claude Opus 4.8`,hint:`powerful`},{value:`claude-opus-4-7`,label:`Claude Opus 4.7`,hint:`powerful`},{value:`claude-opus-4-6`,label:`Claude Opus 4.6`,hint:`powerful`},{value:`claude-sonnet-5`,label:`Claude Sonnet 5`,hint:`fast`},{value:`claude-sonnet-4-6`,label:`Claude Sonnet 4.6`,hint:`fast`},{value:`claude-haiku-4-5`,label:`Claude Haiku 4.5`,hint:`cheap`}];C.map(e=>e.value);function w(e,t){return`${e}/proxy${t?`/${t}`:``}`}function T(e,t){let n=w(e,t);return{anthropicBase:n,openAiBase:`${n}/v1`,anthropicMessages:`${n}/v1/messages`,openAiChatCompletions:`${n}/v1/chat/completions`,models:`${n}/v1/models`,imagesGenerations:t?`${n}/v1/images/generations`:null,imagesEdits:t?`${n}/v1/images/edits`:null}}var E=n(),D=`Hello! Reply briefly.`,O=`claude-opus-5-5`;function k(e){let[t,n]=(0,S.useState)(!1);return(0,E.jsxs)(m,{open:t,onOpenChange:n,children:[(0,E.jsx)(p,{asChild:!0,children:(0,E.jsxs)(c,{variant:`outline`,size:`sm`,className:`h-7 text-[11px] gap-1.5 cursor-pointer`,children:[(0,E.jsx)(r,{className:`size-3`}),`Test`]})}),(0,E.jsxs)(u,{className:`sm:max-w-md max-h-[85vh] overflow-y-auto`,children:[(0,E.jsxs)(l,{children:[(0,E.jsx)(d,{className:`text-sm`,children:`Test Proxy`}),(0,E.jsx)(f,{className:`text-[11px]`,children:`Send a test request and inspect the raw response.`})]}),t&&(0,E.jsx)(A,{...e})]})]})}function A({authKey:e,baseUrl:t,provider:n}){let[r,a]=(0,S.useState)(`anthropic`),[o,l]=(0,S.useState)(D),[u,d]=(0,S.useState)(n?``:O),[f,p]=(0,S.useState)(!0),[m,g]=(0,S.useState)(!1),[_,y]=(0,S.useState)(null),[b,x]=(0,S.useState)(null),[w,k]=(0,S.useState)(null),A=(0,S.useRef)(null),j=(0,S.useRef)(null);(0,S.useEffect)(()=>{A.current?.select()},[]),(0,S.useEffect)(()=>{j.current&&(j.current.scrollTop=j.current.scrollHeight)},[_]);let M=e=>{a(e),y(null),x(null),k(null)},N=async()=>{g(!0),y(null),x(null),k(null);let i=Date.now(),a=r===`openai`,s=T(t,n),c=a?s.openAiChatCompletions:s.anthropicMessages,l=JSON.stringify({...u?{model:u}:{},max_tokens:256,stream:f,messages:[{role:`user`,content:o}]}),d={"Content-Type":`application/json`};a?d.Authorization=`Bearer ${e}`:(d[`x-api-key`]=e,d[`anthropic-version`]=`2023-06-01`);try{let e=await fetch(c,{method:`POST`,headers:d,body:l});if(!e.ok){let t=await e.text();x(`HTTP ${e.status}: ${t}`),g(!1),k(Date.now()-i);return}if(f){let t=e.body?.getReader();if(!t){x(`No response body`),g(!1);return}let n=new TextDecoder,r=``;for(;;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0}),y(r)}k(Date.now()-i)}else{let t=await e.text();try{y(JSON.stringify(JSON.parse(t),null,2))}catch{y(t)}k(Date.now()-i)}}catch(e){x(e.message)}finally{g(!1),k(e=>e??Date.now()-i)}};return(0,E.jsxs)(`div`,{className:`space-y-3 min-w-0`,children:[(0,E.jsxs)(`div`,{className:`space-y-1.5 min-w-0`,children:[(0,E.jsx)(v,{className:`text-[11px]`,children:`Auth Style`}),(0,E.jsx)(`div`,{className:`flex gap-1`,children:[`anthropic`,`openai`].map(e=>(0,E.jsx)(`button`,{onClick:()=>M(e),className:`flex-1 h-8 rounded-md text-[11px] font-medium border transition-colors cursor-pointer ${r===e?`bg-primary text-primary-foreground border-primary`:`bg-muted text-muted-foreground border-transparent hover:bg-muted/80`}`,children:e===`anthropic`?`Anthropic`:`OpenAI`},e))}),(0,E.jsxs)(`p`,{className:`text-[9px] text-muted-foreground break-all`,children:[r===`anthropic`?`x-api-key header`:`Authorization: Bearer header`,` · `,(0,E.jsx)(`code`,{children:`/proxy${n?`/${n}`:``}/v1/${r===`anthropic`?`messages`:`chat/completions`}`})]})]}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(v,{className:`text-[11px]`,children:`Model`}),n?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(h,{value:u,onChange:e=>d(e.target.value),placeholder:`leave empty to let the provider choose`,className:`h-8 text-[11px] font-mono`}),(0,E.jsxs)(`p`,{className:`text-[9px] text-muted-foreground`,children:[`Names come from `,(0,E.jsxs)(`code`,{children:[`GET /proxy/`,n,`/v1/models`]}),`.`]})]}):(0,E.jsx)(`select`,{value:u,onChange:e=>d(e.target.value),className:`h-8 w-full rounded-md border bg-background px-2 text-[11px]`,children:C.map(e=>(0,E.jsx)(`option`,{value:e.value,children:e.value},e.value))})]}),(0,E.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,E.jsx)(v,{className:`text-[11px]`,children:`Streaming`}),(0,E.jsx)(`div`,{className:`flex gap-1`,children:[!0,!1].map(e=>(0,E.jsx)(`button`,{onClick:()=>p(e),className:`h-7 px-3 rounded-md text-[11px] font-medium border transition-colors cursor-pointer ${f===e?`bg-primary text-primary-foreground border-primary`:`bg-muted text-muted-foreground border-transparent hover:bg-muted/80`}`,children:e?`Stream`:`JSON`},String(e)))})]}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(v,{className:`text-[11px]`,children:`Message`}),(0,E.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,E.jsx)(h,{ref:A,value:o,onChange:e=>l(e.target.value),placeholder:`Type a test message...`,className:`h-9 text-[11px] flex-1 min-w-0`,onKeyDown:e=>{e.key===`Enter`&&!m&&N()}}),(0,E.jsxs)(c,{size:`sm`,className:`h-9 px-3 cursor-pointer shrink-0`,onClick:N,disabled:m||!o.trim(),children:[m?(0,E.jsx)(s,{className:`size-3.5 animate-spin`}):(0,E.jsx)(i,{className:`size-3.5`}),(0,E.jsx)(`span`,{className:`ml-1 text-[11px]`,children:m?`...`:`Send`})]})]})]}),(_||b)&&(0,E.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,E.jsx)(v,{className:`text-[10px] text-muted-foreground`,children:`Raw Response`}),w!=null&&(0,E.jsxs)(`span`,{className:`text-[9px] font-mono text-muted-foreground`,children:[(w/1e3).toFixed(1),`s`]})]}),b?(0,E.jsx)(`pre`,{className:`text-[9px] font-mono bg-error/10 text-error p-2 rounded overflow-auto max-h-52 whitespace-pre-wrap break-all`,children:b}):(0,E.jsx)(`pre`,{ref:j,className:`text-[9px] font-mono bg-muted p-2 rounded overflow-auto max-h-52 whitespace-pre-wrap break-all`,children:_})]})]})}function j(){let[e,t]=(0,S.useState)(``),[n,r]=(0,S.useState)([]);(0,S.useEffect)(()=>{b().then(e=>r(Object.keys(e.providers??{}).filter(e=>e!==`mock`&&e!==`claude`))).catch(()=>r([]))},[]);let[i,s]=(0,S.useState)(null),[l,u]=(0,S.useState)(!0),[d,f]=(0,S.useState)(!1),[p,m]=(0,S.useState)(null),[C,w]=(0,S.useState)(null);(0,S.useEffect)(()=>{u(!0),x().then(s).catch(e=>m(e.message)).finally(()=>u(!1))},[]);let D=async e=>{f(!0),m(null);try{s(await y(e))}catch(e){m(e.message)}finally{f(!1)}},O=(e,t)=>{_(e),w(t),setTimeout(()=>w(null),2e3)};if(l||!i)return(0,E.jsxs)(`div`,{className:`space-y-2`,children:[(0,E.jsx)(`h3`,{className:`text-xs font-medium text-text-secondary`,children:`API Proxy`}),(0,E.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:p?`Error: ${p}`:`Loading...`})]});let A=!!i.authKey,j=!!i.tunnelUrl,M=i.localEndpoint.replace(/\/proxy\/v1\/messages$/,``),N=T(j?i.tunnelUrl:M,e),P=N.anthropicMessages,F=N.openAiChatCompletions,I=`ANTHROPIC_BASE_URL=${N.anthropicBase}\nANTHROPIC_API_KEY=${i.authKey}`,L=`OPENAI_BASE_URL=${N.openAiBase}\nOPENAI_API_KEY=${i.authKey}`;return(0,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.jsx)(`div`,{className:`space-y-1.5`,children:(0,E.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Expose your accounts as an API that speaks both the Anthropic and OpenAI formats, so most SDKs need only a new base URL. The default path answers from your Claude accounts; pick a provider below to run its agent instead, which also unlocks image generation.`})}),(0,E.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,E.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,E.jsx)(v,{className:`text-xs`,children:`Enable Proxy`}),(0,E.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Accept API requests under /proxy`})]}),(0,E.jsx)(g,{checked:i.enabled,onCheckedChange:e=>D({enabled:e}),disabled:d})]}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(v,{className:`text-[11px]`,children:`Auth Key`}),A?(0,E.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,E.jsx)(h,{readOnly:!0,value:i.authKey,className:`h-7 text-[11px] font-mono flex-1`}),(0,E.jsx)(c,{variant:`outline`,size:`sm`,className:`h-7 px-2 cursor-pointer shrink-0`,onClick:()=>O(i.authKey,`key`),children:C===`key`?`Copied!`:(0,E.jsx)(o,{className:`size-3`})}),(0,E.jsx)(c,{variant:`outline`,size:`sm`,className:`h-7 px-2 cursor-pointer shrink-0`,onClick:()=>D({generateKey:!0}),disabled:d,children:(0,E.jsx)(a,{className:`size-3`})})]}):(0,E.jsx)(c,{variant:`outline`,size:`sm`,className:`h-7 text-xs cursor-pointer`,onClick:()=>D({generateKey:!0}),disabled:d,children:`Generate Auth Key`}),(0,E.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Use as Bearer token or x-api-key when calling the proxy.`})]}),i.enabled&&A&&(0,E.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3 bg-muted/30`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,E.jsx)(`h4`,{className:`text-[11px] font-medium`,children:`Connection Info`}),(0,E.jsx)(k,{authKey:i.authKey,baseUrl:window.location.origin,provider:e})]}),(0,E.jsxs)(`div`,{className:`space-y-1`,children:[(0,E.jsx)(v,{className:`text-[10px] text-muted-foreground`,children:`Provider`}),(0,E.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:[{id:``,label:`Claude (default)`},...n.map(e=>({id:e,label:e}))].map(n=>(0,E.jsx)(`button`,{type:`button`,onClick:()=>t(n.id),className:`text-[10px] px-2.5 min-h-[36px] rounded-md border transition-colors cursor-pointer ${e===n.id?`border-primary bg-primary/15`:`border-border bg-muted/40 hover:bg-muted`}`,children:n.label},n.id||`default`))}),e&&(0,E.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[`Runs the `,e,` agent per request (read-only sandbox, one turn). Slower than the default path.`]})]}),(0,E.jsxs)(`div`,{className:`space-y-1`,children:[(0,E.jsx)(v,{className:`text-[10px] text-muted-foreground`,children:`Anthropic Endpoint`}),(0,E.jsxs)(`div`,{className:`flex gap-1.5 items-center`,children:[(0,E.jsx)(`code`,{className:`text-[10px] font-mono bg-muted px-1.5 py-0.5 rounded flex-1 truncate`,children:P}),(0,E.jsx)(c,{variant:`ghost`,size:`sm`,className:`h-6 px-1.5 cursor-pointer shrink-0`,onClick:()=>O(P,`anthropic`),children:C===`anthropic`?`Copied!`:(0,E.jsx)(o,{className:`size-3`})})]})]}),(0,E.jsxs)(`div`,{className:`space-y-1`,children:[(0,E.jsx)(v,{className:`text-[10px] text-muted-foreground`,children:`OpenAI-Compatible Endpoint`}),(0,E.jsxs)(`div`,{className:`flex gap-1.5 items-center`,children:[(0,E.jsx)(`code`,{className:`text-[10px] font-mono bg-muted px-1.5 py-0.5 rounded flex-1 truncate`,children:F}),(0,E.jsx)(c,{variant:`ghost`,size:`sm`,className:`h-6 px-1.5 cursor-pointer shrink-0`,onClick:()=>O(F,`openai`),children:C===`openai`?`Copied!`:(0,E.jsx)(o,{className:`size-3`})})]})]}),N.imagesGenerations&&N.imagesEdits&&(0,E.jsxs)(`div`,{className:`space-y-1`,children:[(0,E.jsx)(v,{className:`text-[10px] text-muted-foreground`,children:`Image Endpoints`}),(0,E.jsx)(`code`,{className:`block text-[10px] font-mono bg-muted px-1.5 py-0.5 rounded truncate`,children:N.imagesGenerations}),(0,E.jsx)(`code`,{className:`block text-[10px] font-mono bg-muted px-1.5 py-0.5 rounded truncate`,children:N.imagesEdits})]}),!j&&(0,E.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Start a Cloudflare tunnel (Share) to get a public URL.`}),(0,E.jsxs)(`div`,{className:`space-y-1 pt-1`,children:[(0,E.jsx)(v,{className:`text-[10px] text-muted-foreground`,children:`Anthropic Format`}),(0,E.jsxs)(`div`,{className:`relative`,children:[(0,E.jsx)(`pre`,{className:`text-[9px] font-mono bg-muted p-2 rounded overflow-x-auto whitespace-pre`,children:I}),(0,E.jsx)(c,{variant:`ghost`,size:`sm`,className:`absolute top-1 right-1 h-5 px-1 cursor-pointer`,onClick:()=>O(I,`anthropic-env`),children:C===`anthropic-env`?`Copied!`:(0,E.jsx)(o,{className:`size-2.5`})})]})]}),(0,E.jsxs)(`div`,{className:`space-y-1`,children:[(0,E.jsx)(v,{className:`text-[10px] text-muted-foreground`,children:`OpenAI Format`}),(0,E.jsxs)(`div`,{className:`relative`,children:[(0,E.jsx)(`pre`,{className:`text-[9px] font-mono bg-muted p-2 rounded overflow-x-auto whitespace-pre`,children:L}),(0,E.jsx)(c,{variant:`ghost`,size:`sm`,className:`absolute top-1 right-1 h-5 px-1 cursor-pointer`,onClick:()=>O(L,`openai-env`),children:C===`openai-env`?`Copied!`:(0,E.jsx)(o,{className:`size-2.5`})})]})]}),(0,E.jsx)(`div`,{className:`flex items-center gap-3 pt-1`,children:(0,E.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`Requests served: `,(0,E.jsx)(`span`,{className:`font-mono`,children:i.requestCount})]})})]}),d&&(0,E.jsx)(`p`,{className:`text-[11px] text-text-subtle`,children:`Saving...`}),p&&(0,E.jsx)(`p`,{className:`text-[11px] text-error`,children:p})]})}export{j as ProxySettingsSection};
@@ -1 +1 @@
1
- import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import{Ar as r,G as i,Jr as a,W as o}from"./icons-CO_II6D-.js";import{r as s}from"./api-client-F5Zi1sR0.js";import{E as c,t as l}from"./settings-store-3jIBB8gx.js";import{n as u}from"./utils-btZ8C8-R.js";import{t as d}from"./ws-auth-J3hw0Mhc.js";import{Z as f}from"./index-DQCw6d-2.js";import{r as p}from"./run-in-terminal-Cdn9PaAl.js";function m(e,t,n=`8081`){let r=d(`/ws/remote-desktop`),i=e.protocol===`https:`?`wss:`:`ws:`;return t&&e.protocol!==`https:`?`ws://${e.hostname}:${n}${r}`:`${i}//${e.host}${r}`}var h=30;function g(e,t=h){return Math.round(e*1e6/t)}var _=e(t(),1);function v(e,t){return t||e}function y(e){let[t,n]=(0,_.useState)(`idle`),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)({width:0,height:0}),s=(0,_.useRef)(null),c=(0,_.useRef)(null),l=(0,_.useRef)(!1),u=(0,_.useRef)(0),d=(0,_.useRef)(0),f=(0,_.useRef)(null),p=(0,_.useRef)(!1),m=(0,_.useCallback)(e=>{n(`error`),i(e)},[]),h=(0,_.useCallback)(async t=>{if(f.current=t,typeof VideoDecoder>`u`){n(`unsupported`),i(`This browser has no WebCodecs VideoDecoder — try Chrome, Edge, or Safari 16.4+.`);return}let r={codec:t,optimizeForLatency:!0};try{if(!(await VideoDecoder.isConfigSupported(r)).supported){n(`unsupported`),i(`This browser's decoder does not support ${t}.`);return}}catch(e){m(e.message);return}s.current?.close(),l.current=!1,d.current=0;let a=new VideoDecoder({output:t=>{u.current+=1;let n=e.current;n&&((n.width!==t.displayWidth||n.height!==t.displayHeight)&&(n.width=t.displayWidth,n.height=t.displayHeight,o({width:t.displayWidth,height:t.displayHeight})),c.current||=n.getContext(`2d`),c.current?.drawImage(t,0,0,n.width,n.height)),t.close()},error:e=>y(e.message)});try{a.configure(r)}catch(e){m(e.message);return}s.current=a,p.current=!0,n(`ready`),i(null)},[e,m]),y=(0,_.useCallback)(e=>{if(!p.current)return;let t=f.current;if(!t){m(e);return}try{s.current?.close()}catch{}s.current=null,h(t)},[h,m]);return{status:t,errorMessage:r,configure:h,decodeAccessUnit:(0,_.useCallback)((e,t)=>{let n=s.current;if(!(!n||n.state!==`configured`)&&v(l.current,t)){t&&(l.current=!0);try{n.decode(new EncodedVideoChunk({type:t?`key`:`delta`,timestamp:g(d.current++),data:e}))}catch(e){y(e.message)}}},[y]),reset:(0,_.useCallback)(()=>{p.current=!1;try{s.current?.close()}catch{}s.current=null,l.current=!1,u.current=0,d.current=0,n(`idle`),i(null)},[]),getFrameCount:(0,_.useCallback)(()=>u.current,[]),frameSize:a}}function b(e){return e.code===`KeyV`&&(e.ctrlKey||e.metaKey)}function x(e){return(e.code===`KeyC`||e.code===`KeyX`)&&(e.ctrlKey||e.metaKey)}function S(e){let t=document.createElement(`textarea`);t.value=e,t.style.cssText=`position:fixed;top:0;left:-9999px;opacity:0`,t.setAttribute(`aria-hidden`,`true`),document.body.appendChild(t);let n=document.activeElement,r=!1;try{t.focus({preventScroll:!0}),t.setSelectionRange(0,e.length),t.select(),r=document.execCommand(`copy`)}catch{r=!1}t.remove();try{n?.focus({preventScroll:!0})}catch{}return r}async function C(e){try{return navigator.clipboard?.writeText?(await navigator.clipboard.writeText(e),!0):!1}catch{return!1}}var w=120,T=400;function ee(){let e=(0,_.useRef)(null),t=(0,_.useRef)(null),n=(0,_.useRef)(null),r=(0,_.useRef)(0),i=(0,_.useRef)(0),[a,o]=(0,_.useState)(`idle`),s=(0,_.useCallback)(()=>{try{t.current?.close()}catch{}t.current=null,n.current=null;let a=e.current;e.current=null,a&&a.close().catch(()=>{}),r.current=0,i.current=0,o(e=>e===`unsupported`?e:`idle`)},[]),c=(0,_.useCallback)(t=>{let i=e.current;if(!i){t.close();return}let a=t.numberOfFrames,o=t.numberOfChannels,s=i.createBuffer(o,a,t.sampleRate);for(let e=0;e<o;e++){let n=new Float32Array(a);t.copyTo(n,{planeIndex:e,format:`f32-planar`}),s.copyToChannel(n,e)}t.close();let c=i.currentTime,l=(r.current-c)*1e3;(l<0||l>T)&&(r.current=c+w/1e3);let u=i.createBufferSource();u.buffer=s,u.connect(i.destination),n.current&&u.connect(n.current),u.start(r.current),r.current+=s.duration},[]),l=(0,_.useCallback)(async(a,l)=>{if(typeof AudioDecoder>`u`||typeof AudioContext>`u`){o(`unsupported`);return}s();let u=new AudioContext({sampleRate:l,latencyHint:`interactive`});e.current=u,u.state===`suspended`&&await u.resume().catch(()=>{}),n.current=u.createMediaStreamDestination();let d=new AudioDecoder({output:c,error:()=>{try{t.current?.reset()}catch{}}});try{d.configure({codec:`opus`,sampleRate:l,numberOfChannels:a})}catch{o(`unsupported`);return}t.current=d,r.current=0,i.current=0,o(`playing`)},[c,s]),u=(0,_.useCallback)(e=>{let n=t.current;if(!n||n.state!==`configured`)return;let r=i.current;i.current+=2e4;try{n.decode(new EncodedAudioChunk({type:`key`,timestamp:r,data:e}))}catch{}},[]),d=(0,_.useCallback)(()=>n.current?n.current.stream.getAudioTracks():[],[]);return(0,_.useEffect)(()=>()=>s(),[s]),{status:a,configure:l,decodePacket:u,reset:s,getTracks:d}}var E=5e3,D=2;function O(e,{displayId:t}={}){let n=(0,_.useRef)(null),r=(0,_.useRef)(0),[i,a]=(0,_.useState)(`connecting`),[o,u]=(0,_.useState)(null),[d,f]=(0,_.useState)(0),[p,h]=(0,_.useState)(()=>({preset:c(l.getState().remoteDesktopQuality)??`balanced`,held:1})),g=(0,_.useRef)(c(l.getState().remoteDesktopQuality)),[v,b]=(0,_.useState)(null),x=(0,_.useRef)(null),S=l(e=>e.remoteDesktopShowCursor),w=l(e=>e.remoteDesktopClipboardSync),T=(0,_.useRef)(S),O=(0,_.useRef)(w);(0,_.useEffect)(()=>{T.current=S},[S]),(0,_.useEffect)(()=>{O.current=w},[w]);let k=(0,_.useRef)(l.getState().remoteDesktopCodec),[A,j]=(0,_.useState)(k.current),M=y(e),N=ee(),[P,F]=(0,_.useState)(!1),[I,L]=(0,_.useState)(!1),[R,z]=(0,_.useState)(null),[B,V]=(0,_.useState)(null),[H,U]=(0,_.useState)(null),[W,G]=(0,_.useState)(null),K=(0,_.useCallback)(e=>{let t=n.current;t?.readyState===WebSocket.OPEN&&t.send(JSON.stringify(e))},[]),q=(0,_.useCallback)(e=>{let t=c(e.preset);t&&h({preset:t,held:typeof e.held==`number`&&e.held>0&&e.held<1?e.held:1})},[]),J=(0,_.useCallback)(e=>{if(e!==`custom`)return{type:`quality`,preset:e};let t=l.getState();return{type:`quality`,preset:`custom`,percent:t.remoteDesktopCustomQualityPercent,fps:t.remoteDesktopCustomFps}},[]),Y=(0,_.useCallback)(e=>{g.current=e,l.getState().setRemoteDesktopQuality(e),K(J(e))},[J,K]),X=(0,_.useCallback)((e,t)=>{let n=l.getState();n.setRemoteDesktopCustomQuality(e,t),n.setRemoteDesktopQuality(`custom`),g.current=`custom`,K(J(`custom`))},[J,K]),Z=(0,_.useCallback)(e=>{z(null),K({type:`privacy`,enabled:e})},[K]),Q=(0,_.useCallback)(e=>{F(e),e||N.reset(),K({type:`audio`,enabled:e})},[N,K]),$=(0,_.useCallback)(e=>{k.current=e,l.getState().setRemoteDesktopCodec(e),j(e),e&&K({type:`codec`,encoder:e})},[K]),te=(0,_.useCallback)(e=>{G(null),K({type:`resolution`,modeId:e})},[K]),ne=(0,_.useCallback)(e=>{T.current=e,l.getState().setRemoteDesktopShowCursor(e),K({type:`cursor`,show:e})},[K]),re=(0,_.useCallback)((e,t,n=!1)=>{K({type:`clipboard`,text:e,paste:t,shift:n})},[K]),ie=(0,_.useCallback)(()=>{x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{x.current=null,K({type:`clipboardRead`})},350)},[K]),ae=(0,_.useCallback)(()=>b(null),[]);(0,_.useEffect)(()=>()=>{x.current&&clearTimeout(x.current)},[]),(0,_.useEffect)(()=>{let e=!1,i=null;a(`connecting`),u(null),L(!1),z(null),r.current=0,M.reset(),(async()=>{let o;try{o=(await s.post(`/api/remote-desktop/session`)).nonce}catch(t){e||(a(`error`),u(t.message));return}if(e)return;let c=m(window.location,!1,void 0),l=new WebSocket(c);l.binaryType=`arraybuffer`,n.current=l,l.onopen=()=>{l.send(JSON.stringify({type:`auth`,nonce:o,...t?{displayId:t}:{},cursor:T.current,...k.current?{codec:k.current}:{}})),g.current&&l.send(JSON.stringify(J(g.current))),i=setInterval(()=>K({type:`ping`}),E)},l.onmessage=t=>{if(typeof t.data==`string`){let n;try{n=JSON.parse(t.data)}catch{return}if(n.type===`config`&&typeof n.codec==`string`)q(n),j(typeof n.encoder==`string`?n.encoder:null),M.configure(n.codec).then(()=>{e||a(`streaming`)});else if(n.type===`quality`)q(n);else if(n.type===`codec`)j(typeof n.encoder==`string`?n.encoder:null);else if(n.type===`resolution`)V(typeof n.modeId==`string`?n.modeId:null),U(typeof n.original==`string`?n.original:null),G(null);else if(n.type===`resolutionError`)G(typeof n.message==`string`?n.message:`The host refused the mode.`);else if(n.type===`privacy`)L(n.enabled===!0),z(typeof n.reason==`string`?n.reason:null);else if(n.type===`audio`){let e=n.enabled===!0;if(F(e),!e){N.reset();return}let t=typeof n.channels==`number`?n.channels:2,r=typeof n.sampleRate==`number`?n.sampleRate:48e3;N.configure(t,r)}else if(n.type===`clipboard`&&typeof n.text==`string`){if(!O.current)return;let t=n.text;C(t).then(n=>{!n&&!e&&b(t)})}else n.type===`error`&&(a(`error`),u(typeof n.message==`string`?n.message:`Server error`));return}let n=new Uint8Array(t.data);if(!(n.length<1)){if(r.current+=n.length,n[0]===D){N.decodePacket(n.subarray(1));return}M.decodeAccessUnit(n.subarray(1),n[0]===1)}},l.onerror=()=>{e||(a(`error`),u(`WebSocket error`))},l.onclose=()=>{e||a(e=>e===`error`?e:`closed`)}})();let o=()=>{if(document.hidden||e)return;let t=n.current;t&&t.readyState===WebSocket.OPEN?t.send(JSON.stringify({type:`ping`})):f(e=>e+1)};return document.addEventListener(`visibilitychange`,o),()=>{e=!0,document.removeEventListener(`visibilitychange`,o),i&&clearInterval(i);try{n.current?.close()}catch{}n.current=null;try{M.reset()}catch{}try{N.reset()}catch{}}},[d,t]);let oe=(0,_.useCallback)(()=>f(e=>e+1),[]),se=(0,_.useCallback)(()=>r.current,[]);return{connState:i,errorMessage:o,decoderStatus:M.status,decoderErrorMessage:M.errorMessage,sendMessage:K,reconnect:oe,getTotalBytes:se,getFrameCount:M.getFrameCount,frameSize:M.frameSize,quality:p,setQuality:Y,setCustomQuality:X,showCursor:S,setShowCursor:ne,codec:A,setCodec:$,audioOn:P,setAudioOn:Q,getAudioTracks:N.getTracks,privacyOn:I,privacyError:R,setPrivacyOn:Z,hostModeId:B,hostOriginalModeId:H,resolutionError:W,setHostMode:te,pendingHostClipboard:v,clearHostClipboard:ae,sendClipboard:re,requestHostClipboard:ie}}function k(e){return Math.min(Math.max(e,0),1)}function A(e,t,n){let r=n.width>0?(e-n.left)/n.width:0,i=n.height>0?(t-n.top)/n.height:0;return{xFrac:k(r),yFrac:k(i)}}function j(e,t,n,r){let i=r.scale||1,a=n.left+n.width/2,o=n.top+n.height/2;return A(a+(e-a-r.panX)/i,o+(t-o-r.panY)/i,n)}function M(e,t,n){if(t<=0||n<=0||e.width<=0||e.height<=0)return e;let r=e.width/e.height,i=t/n;if(i>r){let t=e.width/i;return{left:e.left,top:e.top+(e.height-t)/2,width:e.width,height:t}}let a=e.height*i;return{left:e.left+(e.width-a)/2,top:e.top,width:a,height:e.height}}function N(e){let t=new Map;for(let n of e){if(n.width<=0||n.height<=0)continue;let e=`${n.width}x${n.height}`,r=t.get(e);(!r||P(n,r))&&t.set(e,n)}return[...t.values()].sort((e,t)=>t.width*t.height-e.width*e.height||t.refresh-e.refresh).map(e=>({id:e.id,width:e.width,height:e.height,refresh:e.refresh,current:e.current,preferred:e.preferred}))}function P(e,t){return e.current===t.current?e.preferred===t.preferred?e.refresh>t.refresh:e.preferred:e.current}function F(e,t,n){if(!t||t.width<=0||t.height<=0)return null;let r=e.filter(e=>e.width===t.width&&e.height===t.height);if(r.length===0)return null;let i=e.find(e=>e.id===n)??e.find(e=>e.current)??null;return i&&i.width===t.width&&i.height===t.height?null:r.reduce((e,t)=>P(t,e)?t:e)}function I(){if(typeof window>`u`||!window.screen)return null;let e=Math.round(window.screen.width),t=Math.round(window.screen.height);return e>0&&t>0?{width:e,height:t}:null}function L(e){let t=`${e.width} × ${e.height}`;return e.refresh>0?`${t} · ${e.refresh} Hz`:t}var R=[`video/mp4;codecs=avc1.42E01E,mp4a.40.2`,`video/mp4`,`video/webm;codecs=vp9,opus`,`video/webm;codecs=vp8,opus`,`video/webm`];function z(e=e=>typeof MediaRecorder<`u`&&MediaRecorder.isTypeSupported(e)){return typeof MediaRecorder>`u`?null:R.find(e)??null}function B(e){return e.startsWith(`video/mp4`)?`mp4`:`webm`}function V(e,t=new Date){let n=e=>String(e).padStart(2,`0`);return`ppm-remote-${`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}_${n(t.getHours())}-${n(t.getMinutes())}-${n(t.getSeconds())}`}.${e}`}function H(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.rel=`noopener`,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4)}async function U(e){if(!e||e.width===0||e.height===0)return!1;let t=await new Promise(t=>e.toBlob(t,`image/png`));return t?(H(t,V(`png`)),!0):!1}function W(e,t){let n=(0,_.useRef)(null),r=(0,_.useRef)([]),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(0),c=(0,_.useRef)(null);c.current===null&&(c.current=z());let l=(0,_.useCallback)(()=>{n.current?.stop()},[]),u=(0,_.useCallback)(()=>{let i=e.current,o=c.current;if(!i||!o||n.current)return;let l=i.captureStream();for(let e of t?.()??[])l.addTrack(e);let u;try{u=new MediaRecorder(l,{mimeType:o})}catch{return}r.current=[],u.ondataavailable=e=>{e.data.size>0&&r.current.push(e.data)},u.onstop=()=>{let e=new Blob(r.current,{type:o});r.current=[],n.current=null,a(!1),s(0),e.size>0&&H(e,V(B(o)))},u.start(1e3),n.current=u,a(!0),s(0)},[e,t]),d=(0,_.useCallback)(()=>{n.current?l():u()},[u,l]);return(0,_.useEffect)(()=>{if(!i)return;let e=Date.now(),t=setInterval(()=>{let t=Date.now()-e;s(Math.floor(t/1e3)),t>=72e5&&l()},1e3);return()=>clearInterval(t)},[i,l]),(0,_.useEffect)(()=>()=>{n.current?.stop()},[]),{recording:i,elapsedSec:o,supported:c.current!==null,toggle:d}}var G={fps:0,kbps:0};function K(e,t){let n=t.atMs-e.atMs;if(n<=0)return G;let r=n/1e3,i=Math.max(0,t.frameCount-e.frameCount),a=Math.max(0,t.totalBytes-e.totalBytes);return{fps:i/r,kbps:a/1024/r}}var q=n(),J=500;function Y({canvasRef:e,getFrameCount:t,getTotalBytes:n,positionClassName:r=`left-1 top-1`}){let i=l(e=>e.remoteDesktopStatsVisible),[a,o]=(0,_.useState)({fps:0,kbps:0,width:0,height:0}),s=(0,_.useRef)({frameCount:0,totalBytes:0,atMs:0});return(0,_.useEffect)(()=>{if(!i)return;s.current={frameCount:t(),totalBytes:n(),atMs:performance.now()};let r=setInterval(()=>{let r={frameCount:t(),totalBytes:n(),atMs:performance.now()},{fps:i,kbps:a}=K(s.current,r);s.current=r;let c=e.current;o({fps:i,kbps:a,width:c?.width??0,height:c?.height??0})},J);return()=>clearInterval(r)},[i,e,t,n]),i?(0,q.jsxs)(`div`,{className:`pointer-events-none absolute z-40 rounded bg-black/60 px-1.5 py-0.5 font-mono text-[10px] text-white/80 ${r}`,"data-testid":`remote-desktop-stats-overlay`,children:[Math.round(a.fps),` fps · `,Math.round(a.kbps),` KB/s · `,a.width,`×`,a.height]}):null}function X(){let{caps:e}=f(!1),t=e?.displays??[],[n,r]=(0,_.useState)(void 0),i=t.find(e=>e.id===n)??t.find(e=>e.primary)??t[0];return{displays:t,displayId:n,current:i,select:r,next:(0,_.useCallback)(()=>{t.length<2||r(t[(t.findIndex(e=>e.id===i?.id)+1)%t.length]?.id)},[t,i])}}function Z({pendingText:e,onDismiss:t,missingToolAction:n,onDismissMissingTool:a,positionClassName:s=`absolute bottom-2 left-1/2 max-w-[92%] -translate-x-1/2`}){let[c,l]=(0,_.useState)(!1);return e===null?n==null?null:(0,q.jsxs)(Q,{onDismiss:a??(()=>{}),testId:`remote-desktop-clipboard-missing-tool`,positionClassName:s,children:[(0,q.jsx)(o,{className:`size-4 shrink-0 text-amber-300`}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1`,children:`The host has no clipboard tool installed.`}),n.kind===`terminal`&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>p(n.command),title:n.command,className:`inline-flex min-h-8 shrink-0 items-center gap-1.5 rounded bg-white/15 px-2.5 text-xs hover:bg-white/25`,children:[(0,q.jsx)(r,{className:`size-3.5`}),` `,n.label]})]}):(0,q.jsxs)(Q,{onDismiss:t,testId:`remote-desktop-clipboard-pending`,positionClassName:s,children:[(0,q.jsx)(i,{className:`size-4 shrink-0 text-emerald-400`}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[c?`Could not copy — select the text manually:`:`Copied on the host:`,(0,q.jsx)(`span`,{className:`ml-1 text-white/60`,children:$(e)})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>{S(e)?t():l(!0)},className:`min-h-8 shrink-0 rounded bg-white/15 px-2.5 text-xs hover:bg-white/25`,"data-testid":`remote-desktop-clipboard-copy`,children:`Copy here`})]})}function Q({children:e,onDismiss:t,testId:n,positionClassName:r}){return(0,q.jsxs)(`div`,{className:u(`z-50 flex items-center gap-2 rounded-lg border border-white/10 bg-black/85 px-3 py-2 text-xs text-white shadow-lg`,r),"data-testid":n,children:[e,(0,q.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Dismiss`,className:`flex size-8 shrink-0 items-center justify-center rounded text-white/60 hover:bg-white/10 hover:text-white`,children:(0,q.jsx)(a,{className:`size-3.5`})})]})}function $(e){let t=e.replace(/\s+/g,` `).trim();return t.length>60?`${t.slice(0,60)}…`:t}export{U as a,N as c,j as d,M as f,b as h,W as i,L as l,x as m,X as n,F as o,O as p,Y as r,I as s,Z as t,A as u};
1
+ import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import{Ar as r,G as i,Jr as a,W as o}from"./icons-CO_II6D-.js";import{r as s}from"./api-client-F5Zi1sR0.js";import{E as c,t as l}from"./settings-store-3jIBB8gx.js";import{n as u}from"./utils-btZ8C8-R.js";import{t as d}from"./ws-auth-J3hw0Mhc.js";import{Z as f}from"./index-D41mthBS.js";import{r as p}from"./run-in-terminal-Cdn9PaAl.js";function m(e,t,n=`8081`){let r=d(`/ws/remote-desktop`),i=e.protocol===`https:`?`wss:`:`ws:`;return t&&e.protocol!==`https:`?`ws://${e.hostname}:${n}${r}`:`${i}//${e.host}${r}`}var h=30;function g(e,t=h){return Math.round(e*1e6/t)}var _=e(t(),1);function v(e,t){return t||e}function y(e){let[t,n]=(0,_.useState)(`idle`),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)({width:0,height:0}),s=(0,_.useRef)(null),c=(0,_.useRef)(null),l=(0,_.useRef)(!1),u=(0,_.useRef)(0),d=(0,_.useRef)(0),f=(0,_.useRef)(null),p=(0,_.useRef)(!1),m=(0,_.useCallback)(e=>{n(`error`),i(e)},[]),h=(0,_.useCallback)(async t=>{if(f.current=t,typeof VideoDecoder>`u`){n(`unsupported`),i(`This browser has no WebCodecs VideoDecoder — try Chrome, Edge, or Safari 16.4+.`);return}let r={codec:t,optimizeForLatency:!0};try{if(!(await VideoDecoder.isConfigSupported(r)).supported){n(`unsupported`),i(`This browser's decoder does not support ${t}.`);return}}catch(e){m(e.message);return}s.current?.close(),l.current=!1,d.current=0;let a=new VideoDecoder({output:t=>{u.current+=1;let n=e.current;n&&((n.width!==t.displayWidth||n.height!==t.displayHeight)&&(n.width=t.displayWidth,n.height=t.displayHeight,o({width:t.displayWidth,height:t.displayHeight})),c.current||=n.getContext(`2d`),c.current?.drawImage(t,0,0,n.width,n.height)),t.close()},error:e=>y(e.message)});try{a.configure(r)}catch(e){m(e.message);return}s.current=a,p.current=!0,n(`ready`),i(null)},[e,m]),y=(0,_.useCallback)(e=>{if(!p.current)return;let t=f.current;if(!t){m(e);return}try{s.current?.close()}catch{}s.current=null,h(t)},[h,m]);return{status:t,errorMessage:r,configure:h,decodeAccessUnit:(0,_.useCallback)((e,t)=>{let n=s.current;if(!(!n||n.state!==`configured`)&&v(l.current,t)){t&&(l.current=!0);try{n.decode(new EncodedVideoChunk({type:t?`key`:`delta`,timestamp:g(d.current++),data:e}))}catch(e){y(e.message)}}},[y]),reset:(0,_.useCallback)(()=>{p.current=!1;try{s.current?.close()}catch{}s.current=null,l.current=!1,u.current=0,d.current=0,n(`idle`),i(null)},[]),getFrameCount:(0,_.useCallback)(()=>u.current,[]),frameSize:a}}function b(e){return e.code===`KeyV`&&(e.ctrlKey||e.metaKey)}function x(e){return(e.code===`KeyC`||e.code===`KeyX`)&&(e.ctrlKey||e.metaKey)}function S(e){let t=document.createElement(`textarea`);t.value=e,t.style.cssText=`position:fixed;top:0;left:-9999px;opacity:0`,t.setAttribute(`aria-hidden`,`true`),document.body.appendChild(t);let n=document.activeElement,r=!1;try{t.focus({preventScroll:!0}),t.setSelectionRange(0,e.length),t.select(),r=document.execCommand(`copy`)}catch{r=!1}t.remove();try{n?.focus({preventScroll:!0})}catch{}return r}async function C(e){try{return navigator.clipboard?.writeText?(await navigator.clipboard.writeText(e),!0):!1}catch{return!1}}var w=120,T=400;function ee(){let e=(0,_.useRef)(null),t=(0,_.useRef)(null),n=(0,_.useRef)(null),r=(0,_.useRef)(0),i=(0,_.useRef)(0),[a,o]=(0,_.useState)(`idle`),s=(0,_.useCallback)(()=>{try{t.current?.close()}catch{}t.current=null,n.current=null;let a=e.current;e.current=null,a&&a.close().catch(()=>{}),r.current=0,i.current=0,o(e=>e===`unsupported`?e:`idle`)},[]),c=(0,_.useCallback)(t=>{let i=e.current;if(!i){t.close();return}let a=t.numberOfFrames,o=t.numberOfChannels,s=i.createBuffer(o,a,t.sampleRate);for(let e=0;e<o;e++){let n=new Float32Array(a);t.copyTo(n,{planeIndex:e,format:`f32-planar`}),s.copyToChannel(n,e)}t.close();let c=i.currentTime,l=(r.current-c)*1e3;(l<0||l>T)&&(r.current=c+w/1e3);let u=i.createBufferSource();u.buffer=s,u.connect(i.destination),n.current&&u.connect(n.current),u.start(r.current),r.current+=s.duration},[]),l=(0,_.useCallback)(async(a,l)=>{if(typeof AudioDecoder>`u`||typeof AudioContext>`u`){o(`unsupported`);return}s();let u=new AudioContext({sampleRate:l,latencyHint:`interactive`});e.current=u,u.state===`suspended`&&await u.resume().catch(()=>{}),n.current=u.createMediaStreamDestination();let d=new AudioDecoder({output:c,error:()=>{try{t.current?.reset()}catch{}}});try{d.configure({codec:`opus`,sampleRate:l,numberOfChannels:a})}catch{o(`unsupported`);return}t.current=d,r.current=0,i.current=0,o(`playing`)},[c,s]),u=(0,_.useCallback)(e=>{let n=t.current;if(!n||n.state!==`configured`)return;let r=i.current;i.current+=2e4;try{n.decode(new EncodedAudioChunk({type:`key`,timestamp:r,data:e}))}catch{}},[]),d=(0,_.useCallback)(()=>n.current?n.current.stream.getAudioTracks():[],[]);return(0,_.useEffect)(()=>()=>s(),[s]),{status:a,configure:l,decodePacket:u,reset:s,getTracks:d}}var E=5e3,D=2;function O(e,{displayId:t}={}){let n=(0,_.useRef)(null),r=(0,_.useRef)(0),[i,a]=(0,_.useState)(`connecting`),[o,u]=(0,_.useState)(null),[d,f]=(0,_.useState)(0),[p,h]=(0,_.useState)(()=>({preset:c(l.getState().remoteDesktopQuality)??`balanced`,held:1})),g=(0,_.useRef)(c(l.getState().remoteDesktopQuality)),[v,b]=(0,_.useState)(null),x=(0,_.useRef)(null),S=l(e=>e.remoteDesktopShowCursor),w=l(e=>e.remoteDesktopClipboardSync),T=(0,_.useRef)(S),O=(0,_.useRef)(w);(0,_.useEffect)(()=>{T.current=S},[S]),(0,_.useEffect)(()=>{O.current=w},[w]);let k=(0,_.useRef)(l.getState().remoteDesktopCodec),[A,j]=(0,_.useState)(k.current),M=y(e),N=ee(),[P,F]=(0,_.useState)(!1),[I,L]=(0,_.useState)(!1),[R,z]=(0,_.useState)(null),[B,V]=(0,_.useState)(null),[H,U]=(0,_.useState)(null),[W,G]=(0,_.useState)(null),K=(0,_.useCallback)(e=>{let t=n.current;t?.readyState===WebSocket.OPEN&&t.send(JSON.stringify(e))},[]),q=(0,_.useCallback)(e=>{let t=c(e.preset);t&&h({preset:t,held:typeof e.held==`number`&&e.held>0&&e.held<1?e.held:1})},[]),J=(0,_.useCallback)(e=>{if(e!==`custom`)return{type:`quality`,preset:e};let t=l.getState();return{type:`quality`,preset:`custom`,percent:t.remoteDesktopCustomQualityPercent,fps:t.remoteDesktopCustomFps}},[]),Y=(0,_.useCallback)(e=>{g.current=e,l.getState().setRemoteDesktopQuality(e),K(J(e))},[J,K]),X=(0,_.useCallback)((e,t)=>{let n=l.getState();n.setRemoteDesktopCustomQuality(e,t),n.setRemoteDesktopQuality(`custom`),g.current=`custom`,K(J(`custom`))},[J,K]),Z=(0,_.useCallback)(e=>{z(null),K({type:`privacy`,enabled:e})},[K]),Q=(0,_.useCallback)(e=>{F(e),e||N.reset(),K({type:`audio`,enabled:e})},[N,K]),$=(0,_.useCallback)(e=>{k.current=e,l.getState().setRemoteDesktopCodec(e),j(e),e&&K({type:`codec`,encoder:e})},[K]),te=(0,_.useCallback)(e=>{G(null),K({type:`resolution`,modeId:e})},[K]),ne=(0,_.useCallback)(e=>{T.current=e,l.getState().setRemoteDesktopShowCursor(e),K({type:`cursor`,show:e})},[K]),re=(0,_.useCallback)((e,t,n=!1)=>{K({type:`clipboard`,text:e,paste:t,shift:n})},[K]),ie=(0,_.useCallback)(()=>{x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{x.current=null,K({type:`clipboardRead`})},350)},[K]),ae=(0,_.useCallback)(()=>b(null),[]);(0,_.useEffect)(()=>()=>{x.current&&clearTimeout(x.current)},[]),(0,_.useEffect)(()=>{let e=!1,i=null;a(`connecting`),u(null),L(!1),z(null),r.current=0,M.reset(),(async()=>{let o;try{o=(await s.post(`/api/remote-desktop/session`)).nonce}catch(t){e||(a(`error`),u(t.message));return}if(e)return;let c=m(window.location,!1,void 0),l=new WebSocket(c);l.binaryType=`arraybuffer`,n.current=l,l.onopen=()=>{l.send(JSON.stringify({type:`auth`,nonce:o,...t?{displayId:t}:{},cursor:T.current,...k.current?{codec:k.current}:{}})),g.current&&l.send(JSON.stringify(J(g.current))),i=setInterval(()=>K({type:`ping`}),E)},l.onmessage=t=>{if(typeof t.data==`string`){let n;try{n=JSON.parse(t.data)}catch{return}if(n.type===`config`&&typeof n.codec==`string`)q(n),j(typeof n.encoder==`string`?n.encoder:null),M.configure(n.codec).then(()=>{e||a(`streaming`)});else if(n.type===`quality`)q(n);else if(n.type===`codec`)j(typeof n.encoder==`string`?n.encoder:null);else if(n.type===`resolution`)V(typeof n.modeId==`string`?n.modeId:null),U(typeof n.original==`string`?n.original:null),G(null);else if(n.type===`resolutionError`)G(typeof n.message==`string`?n.message:`The host refused the mode.`);else if(n.type===`privacy`)L(n.enabled===!0),z(typeof n.reason==`string`?n.reason:null);else if(n.type===`audio`){let e=n.enabled===!0;if(F(e),!e){N.reset();return}let t=typeof n.channels==`number`?n.channels:2,r=typeof n.sampleRate==`number`?n.sampleRate:48e3;N.configure(t,r)}else if(n.type===`clipboard`&&typeof n.text==`string`){if(!O.current)return;let t=n.text;C(t).then(n=>{!n&&!e&&b(t)})}else n.type===`error`&&(a(`error`),u(typeof n.message==`string`?n.message:`Server error`));return}let n=new Uint8Array(t.data);if(!(n.length<1)){if(r.current+=n.length,n[0]===D){N.decodePacket(n.subarray(1));return}M.decodeAccessUnit(n.subarray(1),n[0]===1)}},l.onerror=()=>{e||(a(`error`),u(`WebSocket error`))},l.onclose=()=>{e||a(e=>e===`error`?e:`closed`)}})();let o=()=>{if(document.hidden||e)return;let t=n.current;t&&t.readyState===WebSocket.OPEN?t.send(JSON.stringify({type:`ping`})):f(e=>e+1)};return document.addEventListener(`visibilitychange`,o),()=>{e=!0,document.removeEventListener(`visibilitychange`,o),i&&clearInterval(i);try{n.current?.close()}catch{}n.current=null;try{M.reset()}catch{}try{N.reset()}catch{}}},[d,t]);let oe=(0,_.useCallback)(()=>f(e=>e+1),[]),se=(0,_.useCallback)(()=>r.current,[]);return{connState:i,errorMessage:o,decoderStatus:M.status,decoderErrorMessage:M.errorMessage,sendMessage:K,reconnect:oe,getTotalBytes:se,getFrameCount:M.getFrameCount,frameSize:M.frameSize,quality:p,setQuality:Y,setCustomQuality:X,showCursor:S,setShowCursor:ne,codec:A,setCodec:$,audioOn:P,setAudioOn:Q,getAudioTracks:N.getTracks,privacyOn:I,privacyError:R,setPrivacyOn:Z,hostModeId:B,hostOriginalModeId:H,resolutionError:W,setHostMode:te,pendingHostClipboard:v,clearHostClipboard:ae,sendClipboard:re,requestHostClipboard:ie}}function k(e){return Math.min(Math.max(e,0),1)}function A(e,t,n){let r=n.width>0?(e-n.left)/n.width:0,i=n.height>0?(t-n.top)/n.height:0;return{xFrac:k(r),yFrac:k(i)}}function j(e,t,n,r){let i=r.scale||1,a=n.left+n.width/2,o=n.top+n.height/2;return A(a+(e-a-r.panX)/i,o+(t-o-r.panY)/i,n)}function M(e,t,n){if(t<=0||n<=0||e.width<=0||e.height<=0)return e;let r=e.width/e.height,i=t/n;if(i>r){let t=e.width/i;return{left:e.left,top:e.top+(e.height-t)/2,width:e.width,height:t}}let a=e.height*i;return{left:e.left+(e.width-a)/2,top:e.top,width:a,height:e.height}}function N(e){let t=new Map;for(let n of e){if(n.width<=0||n.height<=0)continue;let e=`${n.width}x${n.height}`,r=t.get(e);(!r||P(n,r))&&t.set(e,n)}return[...t.values()].sort((e,t)=>t.width*t.height-e.width*e.height||t.refresh-e.refresh).map(e=>({id:e.id,width:e.width,height:e.height,refresh:e.refresh,current:e.current,preferred:e.preferred}))}function P(e,t){return e.current===t.current?e.preferred===t.preferred?e.refresh>t.refresh:e.preferred:e.current}function F(e,t,n){if(!t||t.width<=0||t.height<=0)return null;let r=e.filter(e=>e.width===t.width&&e.height===t.height);if(r.length===0)return null;let i=e.find(e=>e.id===n)??e.find(e=>e.current)??null;return i&&i.width===t.width&&i.height===t.height?null:r.reduce((e,t)=>P(t,e)?t:e)}function I(){if(typeof window>`u`||!window.screen)return null;let e=Math.round(window.screen.width),t=Math.round(window.screen.height);return e>0&&t>0?{width:e,height:t}:null}function L(e){let t=`${e.width} × ${e.height}`;return e.refresh>0?`${t} · ${e.refresh} Hz`:t}var R=[`video/mp4;codecs=avc1.42E01E,mp4a.40.2`,`video/mp4`,`video/webm;codecs=vp9,opus`,`video/webm;codecs=vp8,opus`,`video/webm`];function z(e=e=>typeof MediaRecorder<`u`&&MediaRecorder.isTypeSupported(e)){return typeof MediaRecorder>`u`?null:R.find(e)??null}function B(e){return e.startsWith(`video/mp4`)?`mp4`:`webm`}function V(e,t=new Date){let n=e=>String(e).padStart(2,`0`);return`ppm-remote-${`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}_${n(t.getHours())}-${n(t.getMinutes())}-${n(t.getSeconds())}`}.${e}`}function H(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.rel=`noopener`,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4)}async function U(e){if(!e||e.width===0||e.height===0)return!1;let t=await new Promise(t=>e.toBlob(t,`image/png`));return t?(H(t,V(`png`)),!0):!1}function W(e,t){let n=(0,_.useRef)(null),r=(0,_.useRef)([]),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(0),c=(0,_.useRef)(null);c.current===null&&(c.current=z());let l=(0,_.useCallback)(()=>{n.current?.stop()},[]),u=(0,_.useCallback)(()=>{let i=e.current,o=c.current;if(!i||!o||n.current)return;let l=i.captureStream();for(let e of t?.()??[])l.addTrack(e);let u;try{u=new MediaRecorder(l,{mimeType:o})}catch{return}r.current=[],u.ondataavailable=e=>{e.data.size>0&&r.current.push(e.data)},u.onstop=()=>{let e=new Blob(r.current,{type:o});r.current=[],n.current=null,a(!1),s(0),e.size>0&&H(e,V(B(o)))},u.start(1e3),n.current=u,a(!0),s(0)},[e,t]),d=(0,_.useCallback)(()=>{n.current?l():u()},[u,l]);return(0,_.useEffect)(()=>{if(!i)return;let e=Date.now(),t=setInterval(()=>{let t=Date.now()-e;s(Math.floor(t/1e3)),t>=72e5&&l()},1e3);return()=>clearInterval(t)},[i,l]),(0,_.useEffect)(()=>()=>{n.current?.stop()},[]),{recording:i,elapsedSec:o,supported:c.current!==null,toggle:d}}var G={fps:0,kbps:0};function K(e,t){let n=t.atMs-e.atMs;if(n<=0)return G;let r=n/1e3,i=Math.max(0,t.frameCount-e.frameCount),a=Math.max(0,t.totalBytes-e.totalBytes);return{fps:i/r,kbps:a/1024/r}}var q=n(),J=500;function Y({canvasRef:e,getFrameCount:t,getTotalBytes:n,positionClassName:r=`left-1 top-1`}){let i=l(e=>e.remoteDesktopStatsVisible),[a,o]=(0,_.useState)({fps:0,kbps:0,width:0,height:0}),s=(0,_.useRef)({frameCount:0,totalBytes:0,atMs:0});return(0,_.useEffect)(()=>{if(!i)return;s.current={frameCount:t(),totalBytes:n(),atMs:performance.now()};let r=setInterval(()=>{let r={frameCount:t(),totalBytes:n(),atMs:performance.now()},{fps:i,kbps:a}=K(s.current,r);s.current=r;let c=e.current;o({fps:i,kbps:a,width:c?.width??0,height:c?.height??0})},J);return()=>clearInterval(r)},[i,e,t,n]),i?(0,q.jsxs)(`div`,{className:`pointer-events-none absolute z-40 rounded bg-black/60 px-1.5 py-0.5 font-mono text-[10px] text-white/80 ${r}`,"data-testid":`remote-desktop-stats-overlay`,children:[Math.round(a.fps),` fps · `,Math.round(a.kbps),` KB/s · `,a.width,`×`,a.height]}):null}function X(){let{caps:e}=f(!1),t=e?.displays??[],[n,r]=(0,_.useState)(void 0),i=t.find(e=>e.id===n)??t.find(e=>e.primary)??t[0];return{displays:t,displayId:n,current:i,select:r,next:(0,_.useCallback)(()=>{t.length<2||r(t[(t.findIndex(e=>e.id===i?.id)+1)%t.length]?.id)},[t,i])}}function Z({pendingText:e,onDismiss:t,missingToolAction:n,onDismissMissingTool:a,positionClassName:s=`absolute bottom-2 left-1/2 max-w-[92%] -translate-x-1/2`}){let[c,l]=(0,_.useState)(!1);return e===null?n==null?null:(0,q.jsxs)(Q,{onDismiss:a??(()=>{}),testId:`remote-desktop-clipboard-missing-tool`,positionClassName:s,children:[(0,q.jsx)(o,{className:`size-4 shrink-0 text-amber-300`}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1`,children:`The host has no clipboard tool installed.`}),n.kind===`terminal`&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>p(n.command),title:n.command,className:`inline-flex min-h-8 shrink-0 items-center gap-1.5 rounded bg-white/15 px-2.5 text-xs hover:bg-white/25`,children:[(0,q.jsx)(r,{className:`size-3.5`}),` `,n.label]})]}):(0,q.jsxs)(Q,{onDismiss:t,testId:`remote-desktop-clipboard-pending`,positionClassName:s,children:[(0,q.jsx)(i,{className:`size-4 shrink-0 text-emerald-400`}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[c?`Could not copy — select the text manually:`:`Copied on the host:`,(0,q.jsx)(`span`,{className:`ml-1 text-white/60`,children:$(e)})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>{S(e)?t():l(!0)},className:`min-h-8 shrink-0 rounded bg-white/15 px-2.5 text-xs hover:bg-white/25`,"data-testid":`remote-desktop-clipboard-copy`,children:`Copy here`})]})}function Q({children:e,onDismiss:t,testId:n,positionClassName:r}){return(0,q.jsxs)(`div`,{className:u(`z-50 flex items-center gap-2 rounded-lg border border-white/10 bg-black/85 px-3 py-2 text-xs text-white shadow-lg`,r),"data-testid":n,children:[e,(0,q.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Dismiss`,className:`flex size-8 shrink-0 items-center justify-center rounded text-white/60 hover:bg-white/10 hover:text-white`,children:(0,q.jsx)(a,{className:`size-3.5`})})]})}function $(e){let t=e.replace(/\s+/g,` `).trim();return t.length>60?`${t.slice(0,60)}…`:t}export{U as a,N as c,j as d,M as f,b as h,W as i,L as l,x as m,X as n,F as o,O as p,Y as r,I as s,Z as t,A as u};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/remote-desktop-mobile-view-DgGOfPVY.js","assets/rolldown-runtime-C5c2KzVm.js","assets/index-DQCw6d-2.js","assets/preload-helper-BEFjQwLd.js","assets/vendor-ui-P9Ym7hCv.js","assets/vendor-markdown-QKPNiWEd.js","assets/button-CsmGH5xa.js","assets/utils-btZ8C8-R.js","assets/createLucideIcon-DBXq3G0e.js","assets/api-client-F5Zi1sR0.js","assets/react-CzUPVyyG.js","assets/panel-store-DrSH3Nhp.js","assets/window-store-B4cbZ5rr.js","assets/project-store-CCimwgGF.js","assets/settings-store-3jIBB8gx.js","assets/file-store-DCU7_YyB.js","assets/window-pip-registry-dxrBFfkP.js","assets/onboarding-quick-orientation-WLKI95GY.js","assets/dialog-z8PLkL8n.js","assets/portal-container-context-NFSuymMu.js","assets/icons-CO_II6D-.js","assets/use-is-mobile-CkO33jqU.js","assets/format-file-meta-B0ZpqzSM.js","assets/fs-api-vF_bQoeL.js","assets/context-menu-CH1mvCwA.js","assets/input-CP31LZnN.js","assets/mobile-bottom-sheet-CLic9ovp.js","assets/use-visual-viewport-C307OVeV.js","assets/scroll-area-Dp-P38kg.js","assets/chat-preparation-cache-DoS7sdal.js","assets/file-icons-Ed_yLyef.js","assets/format-date-Fd9tpNaw.js","assets/git-repo-store-CdoOpvmf.js","assets/ws-auth-J3hw0Mhc.js","assets/tab-store-CUPgQIQz.js","assets/apply-theme-aVoqSG0I.js","assets/resolve-theme-B87m6l4i.js","assets/index-BmsPSBtF.css","assets/remote-desktop-clipboard-notice-Bs3fZSRw.js","assets/run-in-terminal-Cdn9PaAl.js"])))=>i.map(i=>d[i]);
2
- import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import{_t as r}from"./vendor-ui-P9Ym7hCv.js";import"./icons-CO_II6D-.js";import"./api-client-F5Zi1sR0.js";import"./settings-store-3jIBB8gx.js";import{t as i}from"./preload-helper-BEFjQwLd.js";import{n as a}from"./portal-container-context-NFSuymMu.js";import"./panel-store-DrSH3Nhp.js";import"./window-store-B4cbZ5rr.js";import"./project-store-CCimwgGF.js";import{Q as o}from"./index-DQCw6d-2.js";import"./run-in-terminal-Cdn9PaAl.js";import{n as s,t as c}from"./remote-desktop-readiness-gate-DOWryrQx.js";var l=e(t(),1),u=e(r(),1),d=n(),f=(0,l.lazy)(()=>i(()=>import(`./remote-desktop-mobile-view-DgGOfPVY.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39])));function p(){let e=o(e=>e.isOpen),t=o(e=>e.close),n=a();return e?(0,u.createPortal)((0,d.jsx)(`div`,{className:`fixed inset-0 z-[45] bg-black`,"data-testid":`remote-desktop-mobile-sheet`,children:(0,d.jsx)(s,{onCancel:t,children:(0,d.jsx)(c,{onCancel:t,children:(0,d.jsx)(l.Suspense,{fallback:(0,d.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-text-2`,children:`Loading…`}),children:(0,d.jsx)(f,{onClose:t})})})})}),n??document.getElementById(`root`)??document.body):null}export{p as RemoteDesktopMobileSheet};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/remote-desktop-mobile-view-kD5Q339l.js","assets/rolldown-runtime-C5c2KzVm.js","assets/index-D41mthBS.js","assets/preload-helper-BEFjQwLd.js","assets/vendor-ui-P9Ym7hCv.js","assets/vendor-markdown-QKPNiWEd.js","assets/button-CsmGH5xa.js","assets/utils-btZ8C8-R.js","assets/createLucideIcon-DBXq3G0e.js","assets/api-client-F5Zi1sR0.js","assets/react-CzUPVyyG.js","assets/panel-store-DrSH3Nhp.js","assets/window-store-B4cbZ5rr.js","assets/project-store-CCimwgGF.js","assets/settings-store-3jIBB8gx.js","assets/file-store-DCU7_YyB.js","assets/window-pip-registry-dxrBFfkP.js","assets/onboarding-quick-orientation-WLKI95GY.js","assets/dialog-z8PLkL8n.js","assets/portal-container-context-NFSuymMu.js","assets/icons-CO_II6D-.js","assets/use-is-mobile-CkO33jqU.js","assets/format-file-meta-B0ZpqzSM.js","assets/fs-api-vF_bQoeL.js","assets/context-menu-CH1mvCwA.js","assets/input-CP31LZnN.js","assets/mobile-bottom-sheet-CLic9ovp.js","assets/use-visual-viewport-C307OVeV.js","assets/scroll-area-Dp-P38kg.js","assets/chat-preparation-cache-DoS7sdal.js","assets/file-icons-Ed_yLyef.js","assets/format-date-Fd9tpNaw.js","assets/git-repo-store-CdoOpvmf.js","assets/ws-auth-J3hw0Mhc.js","assets/tab-store-CUPgQIQz.js","assets/apply-theme-aVoqSG0I.js","assets/resolve-theme-B87m6l4i.js","assets/index-BmsPSBtF.css","assets/remote-desktop-clipboard-notice-C6tt5SDH.js","assets/run-in-terminal-Cdn9PaAl.js"])))=>i.map(i=>d[i]);
2
+ import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{C as t,S as n}from"./vendor-markdown-QKPNiWEd.js";import{_t as r}from"./vendor-ui-P9Ym7hCv.js";import"./icons-CO_II6D-.js";import"./api-client-F5Zi1sR0.js";import"./settings-store-3jIBB8gx.js";import{t as i}from"./preload-helper-BEFjQwLd.js";import{n as a}from"./portal-container-context-NFSuymMu.js";import"./panel-store-DrSH3Nhp.js";import"./window-store-B4cbZ5rr.js";import"./project-store-CCimwgGF.js";import{Q as o}from"./index-D41mthBS.js";import"./run-in-terminal-Cdn9PaAl.js";import{n as s,t as c}from"./remote-desktop-readiness-gate-CqnG8BlK.js";var l=e(t(),1),u=e(r(),1),d=n(),f=(0,l.lazy)(()=>i(()=>import(`./remote-desktop-mobile-view-kD5Q339l.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39])));function p(){let e=o(e=>e.isOpen),t=o(e=>e.close),n=a();return e?(0,u.createPortal)((0,d.jsx)(`div`,{className:`fixed inset-0 z-[45] bg-black`,"data-testid":`remote-desktop-mobile-sheet`,children:(0,d.jsx)(s,{onCancel:t,children:(0,d.jsx)(c,{onCancel:t,children:(0,d.jsx)(l.Suspense,{fallback:(0,d.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-text-2`,children:`Loading…`}),children:(0,d.jsx)(f,{onClose:t})})})})}),n??document.getElementById(`root`)??document.body):null}export{p as RemoteDesktopMobileSheet};