@hienlh/ppm 0.23.0 → 0.23.2

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 (382) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/CLAUDE.md +1 -0
  3. package/assets/skills/ppm/SKILL.md +1 -1
  4. package/assets/skills/ppm/references/http-api.md +1 -1
  5. package/dist/web/assets/accounts-settings-section-Cs7BC5O1.js +1 -0
  6. package/dist/web/assets/accounts-settings-section-Cs7BC5O1.js.br +0 -0
  7. package/dist/web/assets/accounts-settings-section-Cs7BC5O1.js.gz +0 -0
  8. package/dist/web/assets/{ai-resource-editor-DoCiQDKY.js → ai-resource-editor-TCREp5Ml.js} +1 -1
  9. package/dist/web/assets/ai-resource-editor-TCREp5Ml.js.br +0 -0
  10. package/dist/web/assets/ai-resource-editor-TCREp5Ml.js.gz +0 -0
  11. package/dist/web/assets/{ai-settings-section-0x6GFJ56.js → ai-settings-section-B7Un4KiW.js} +1 -1
  12. package/dist/web/assets/ai-settings-section-B7Un4KiW.js.br +0 -0
  13. package/dist/web/assets/ai-settings-section-B7Un4KiW.js.gz +0 -0
  14. package/dist/web/assets/{ai-settings-section-Cp6jcnTn.js → ai-settings-section-BlKlcihJ.js} +1 -1
  15. package/dist/web/assets/{appearance-settings-section-mRiGj3_g.js → appearance-settings-section-DACtiDor.js} +1 -1
  16. package/dist/web/assets/appearance-settings-section-DACtiDor.js.br +0 -0
  17. package/dist/web/assets/appearance-settings-section-DACtiDor.js.gz +0 -0
  18. package/dist/web/assets/{audio-preview-CO7Ia2N5.js → audio-preview-DXtE1Lpz.js} +1 -1
  19. package/dist/web/assets/audio-preview-DXtE1Lpz.js.br +0 -0
  20. package/dist/web/assets/audio-preview-DXtE1Lpz.js.gz +0 -0
  21. package/dist/web/assets/{branch-review-tab-F3CALiEa.js → branch-review-tab-vHJuFXtB.js} +1 -1
  22. package/dist/web/assets/branch-review-tab-vHJuFXtB.js.br +0 -0
  23. package/dist/web/assets/branch-review-tab-vHJuFXtB.js.gz +0 -0
  24. package/dist/web/assets/chat-tab-Ba3NvUgt.js +1 -0
  25. package/dist/web/assets/chat-tab-Ba3NvUgt.js.br +0 -0
  26. package/dist/web/assets/chat-tab-Ba3NvUgt.js.gz +0 -0
  27. package/dist/web/assets/chat-tab-DeISufm0.js +15 -0
  28. package/dist/web/assets/chat-tab-DeISufm0.js.br +0 -0
  29. package/dist/web/assets/chat-tab-DeISufm0.js.gz +0 -0
  30. package/dist/web/assets/{code-editor-FsR6KpZa.js → code-editor-BCwiLVyc.js} +3 -3
  31. package/dist/web/assets/code-editor-BCwiLVyc.js.br +0 -0
  32. package/dist/web/assets/code-editor-BCwiLVyc.js.gz +0 -0
  33. package/dist/web/assets/codex-sign-in-again-dialog-DcIOYhAe.js +1 -0
  34. package/dist/web/assets/codex-sign-in-again-dialog-DcIOYhAe.js.br +0 -0
  35. package/dist/web/assets/codex-sign-in-again-dialog-DcIOYhAe.js.gz +0 -0
  36. package/dist/web/assets/{conflict-editor-GGqIz6tt.js → conflict-editor-0YEDQ--c.js} +1 -1
  37. package/dist/web/assets/conflict-editor-0YEDQ--c.js.br +0 -0
  38. package/dist/web/assets/conflict-editor-0YEDQ--c.js.gz +0 -0
  39. package/dist/web/assets/{context-menu-CVO3HtIt.js → context-menu-CjYTq8DI.js} +1 -1
  40. package/dist/web/assets/context-menu-CjYTq8DI.js.br +0 -0
  41. package/dist/web/assets/context-menu-CjYTq8DI.js.gz +0 -0
  42. package/dist/web/assets/{csv-preview-ycnxJ_6J.js → csv-preview-CYxznB1I.js} +1 -1
  43. package/dist/web/assets/csv-preview-CYxznB1I.js.br +0 -0
  44. package/dist/web/assets/csv-preview-CYxznB1I.js.gz +0 -0
  45. package/dist/web/assets/{database-viewer-y6URJv8N.js → database-viewer-eP3gCxGb.js} +1 -1
  46. package/dist/web/assets/database-viewer-eP3gCxGb.js.br +0 -0
  47. package/dist/web/assets/database-viewer-eP3gCxGb.js.gz +0 -0
  48. package/dist/web/assets/{design-responsive-dialog-D0QYfX7v.js → design-responsive-dialog-CcJETHO2.js} +1 -1
  49. package/dist/web/assets/design-responsive-dialog-CcJETHO2.js.br +0 -0
  50. package/dist/web/assets/design-responsive-dialog-CcJETHO2.js.gz +0 -0
  51. package/dist/web/assets/{design-tab-DgCTcwot.js → design-tab-B7aVMMfj.js} +1 -1
  52. package/dist/web/assets/design-tab-B7aVMMfj.js.br +0 -0
  53. package/dist/web/assets/design-tab-B7aVMMfj.js.gz +0 -0
  54. package/dist/web/assets/{designs-sidebar-panel-Dtuph5jh.js → designs-sidebar-panel-8KI79o1u.js} +1 -1
  55. package/dist/web/assets/designs-sidebar-panel-8KI79o1u.js.br +0 -0
  56. package/dist/web/assets/designs-sidebar-panel-8KI79o1u.js.gz +0 -0
  57. package/dist/web/assets/{dialog-CaShS4f5.js → dialog-tzBRkGeW.js} +1 -1
  58. package/dist/web/assets/dialog-tzBRkGeW.js.br +0 -0
  59. package/dist/web/assets/dialog-tzBRkGeW.js.gz +0 -0
  60. package/dist/web/assets/{diff-viewer-ciBkExM7.js → diff-viewer-B_K7VQup.js} +1 -1
  61. package/dist/web/assets/diff-viewer-B_K7VQup.js.br +0 -0
  62. package/dist/web/assets/diff-viewer-B_K7VQup.js.gz +0 -0
  63. package/dist/web/assets/{docx-preview-C8K6QzOW.js → docx-preview-C-UKGMXR.js} +1 -1
  64. package/dist/web/assets/docx-preview-C-UKGMXR.js.br +0 -0
  65. package/dist/web/assets/docx-preview-C-UKGMXR.js.gz +0 -0
  66. package/dist/web/assets/{editor-language-service-CkoaAHjF.js → editor-language-service-DYBxZX66.js} +1 -1
  67. package/dist/web/assets/editor-language-service-DYBxZX66.js.br +0 -0
  68. package/dist/web/assets/editor-language-service-DYBxZX66.js.gz +0 -0
  69. package/dist/web/assets/{explorer-body-C5gXPGOl.js → explorer-body-C0syNltJ.js} +1 -1
  70. package/dist/web/assets/explorer-body-C0syNltJ.js.br +0 -0
  71. package/dist/web/assets/explorer-body-C0syNltJ.js.gz +0 -0
  72. package/dist/web/assets/{explorer-window-content-8EBl9Vkx.js → explorer-window-content-CfIomwTq.js} +1 -1
  73. package/dist/web/assets/explorer-window-content-CfIomwTq.js.br +0 -0
  74. package/dist/web/assets/explorer-window-content-CfIomwTq.js.gz +0 -0
  75. package/dist/web/assets/{extension-manager-section-DOwZYx8O.js → extension-manager-section-CL7pl3re.js} +1 -1
  76. package/dist/web/assets/extension-manager-section-CL7pl3re.js.br +0 -0
  77. package/dist/web/assets/extension-manager-section-CL7pl3re.js.gz +0 -0
  78. package/dist/web/assets/{extension-webview-CdEva8pD.js → extension-webview-FHTB0jh1.js} +1 -1
  79. package/dist/web/assets/extension-webview-FHTB0jh1.js.br +0 -0
  80. package/dist/web/assets/extension-webview-FHTB0jh1.js.gz +0 -0
  81. package/dist/web/assets/{files-settings-section-DVemQIZ2.js → files-settings-section-C574RfCl.js} +1 -1
  82. package/dist/web/assets/files-settings-section-C574RfCl.js.br +0 -0
  83. package/dist/web/assets/files-settings-section-C574RfCl.js.gz +0 -0
  84. package/dist/web/assets/{general-settings-section-DiY_5C93.js → general-settings-section--DSUTrEP.js} +1 -1
  85. package/dist/web/assets/general-settings-section--DSUTrEP.js.br +0 -0
  86. package/dist/web/assets/general-settings-section--DSUTrEP.js.gz +0 -0
  87. package/dist/web/assets/{git-log-panel-Cq0WohOO.js → git-log-panel-BzwEbRwN.js} +1 -1
  88. package/dist/web/assets/git-log-panel-BzwEbRwN.js.br +0 -0
  89. package/dist/web/assets/git-log-panel-BzwEbRwN.js.gz +0 -0
  90. package/dist/web/assets/{glide-data-grid-DG9AnCmP.js → glide-data-grid-CUNWBFfN.js} +1 -1
  91. package/dist/web/assets/glide-data-grid-CUNWBFfN.js.br +0 -0
  92. package/dist/web/assets/glide-data-grid-CUNWBFfN.js.gz +0 -0
  93. package/dist/web/assets/{group-chat-tab-DxbDrFJl.js → group-chat-tab-Dp1p4Jdu.js} +1 -1
  94. package/dist/web/assets/group-chat-tab-Dp1p4Jdu.js.br +0 -0
  95. package/dist/web/assets/group-chat-tab-Dp1p4Jdu.js.gz +0 -0
  96. package/dist/web/assets/icons-CO_II6D-.js +1 -0
  97. package/dist/web/assets/icons-CO_II6D-.js.br +0 -0
  98. package/dist/web/assets/icons-CO_II6D-.js.gz +0 -0
  99. package/dist/web/assets/{image-preview-eAv91-an.js → image-preview-78Fguk1f.js} +1 -1
  100. package/dist/web/assets/{index-BVKT5UCu.js → index-CvUGUp7d.js} +6 -6
  101. package/dist/web/assets/index-CvUGUp7d.js.br +0 -0
  102. package/dist/web/assets/index-CvUGUp7d.js.gz +0 -0
  103. package/dist/web/assets/index-DMA-So69.css +1 -0
  104. package/dist/web/assets/index-DMA-So69.css.br +0 -0
  105. package/dist/web/assets/index-DMA-So69.css.gz +0 -0
  106. package/dist/web/assets/{jira-watcher-section-Cr8gSVGY.js → jira-watcher-section-DoXl0GAq.js} +1 -1
  107. package/dist/web/assets/jira-watcher-section-DoXl0GAq.js.br +0 -0
  108. package/dist/web/assets/jira-watcher-section-DoXl0GAq.js.gz +0 -0
  109. package/dist/web/assets/{keybindings-store-Ch1mWz0q.js → keybindings-store-BqGm9AgI.js} +1 -1
  110. package/dist/web/assets/{keyboard-shortcuts-section-BvC6m_C2.js → keyboard-shortcuts-section-BogwnAdr.js} +1 -1
  111. package/dist/web/assets/keyboard-shortcuts-section-BogwnAdr.js.br +0 -0
  112. package/dist/web/assets/keyboard-shortcuts-section-BogwnAdr.js.gz +0 -0
  113. package/dist/web/assets/{markdown-renderer-56wMzGkr.js → markdown-renderer-C33dsNJ_.js} +1 -1
  114. package/dist/web/assets/{markdown-renderer-8JlfrfnD.js → markdown-renderer-CZiECUJp.js} +1 -1
  115. package/dist/web/assets/markdown-renderer-CZiECUJp.js.br +0 -0
  116. package/dist/web/assets/markdown-renderer-CZiECUJp.js.gz +0 -0
  117. package/dist/web/assets/{mobile-explorer-sheet-cJfocgE7.js → mobile-explorer-sheet-BOgo9tbK.js} +1 -1
  118. package/dist/web/assets/mobile-explorer-sheet-BOgo9tbK.js.br +0 -0
  119. package/dist/web/assets/mobile-explorer-sheet-BOgo9tbK.js.gz +0 -0
  120. package/dist/web/assets/{new-design-dialog-BO_D3nex.js → new-design-dialog-DcoejI1s.js} +1 -1
  121. package/dist/web/assets/new-design-dialog-DcoejI1s.js.br +0 -0
  122. package/dist/web/assets/new-design-dialog-DcoejI1s.js.gz +0 -0
  123. package/dist/web/assets/{notification-store-DNWazI7j.js → notification-store-D88Y9kF_.js} +1 -1
  124. package/dist/web/assets/{notifications-settings-section-DaMh3khs.js → notifications-settings-section-Bfxqz65i.js} +1 -1
  125. package/dist/web/assets/notifications-settings-section-Bfxqz65i.js.br +0 -0
  126. package/dist/web/assets/notifications-settings-section-Bfxqz65i.js.gz +0 -0
  127. package/dist/web/assets/{onboarding-entry-CwkNJ69U.js → onboarding-entry-CcvySZ_l.js} +1 -1
  128. package/dist/web/assets/onboarding-entry-CcvySZ_l.js.br +0 -0
  129. package/dist/web/assets/onboarding-entry-CcvySZ_l.js.gz +0 -0
  130. package/dist/web/assets/{onboarding-quick-orientation-u7yM68d3.js → onboarding-quick-orientation-CT4PylG0.js} +1 -1
  131. package/dist/web/assets/onboarding-quick-orientation-CT4PylG0.js.br +0 -0
  132. package/dist/web/assets/onboarding-quick-orientation-CT4PylG0.js.gz +0 -0
  133. package/dist/web/assets/{pdf-preview-CaxTidh0.js → pdf-preview-BWim6mu1.js} +1 -1
  134. package/dist/web/assets/pdf-preview-BWim6mu1.js.br +0 -0
  135. package/dist/web/assets/pdf-preview-BWim6mu1.js.gz +0 -0
  136. package/dist/web/assets/{postgres-viewer-CJOOLdgO.js → postgres-viewer-HwlL1UTJ.js} +1 -1
  137. package/dist/web/assets/postgres-viewer-HwlL1UTJ.js.br +0 -0
  138. package/dist/web/assets/postgres-viewer-HwlL1UTJ.js.gz +0 -0
  139. package/dist/web/assets/{ppmbot-settings-section-rNBdWG7F.js → ppmbot-settings-section-DF0kqdyO.js} +1 -1
  140. package/dist/web/assets/ppmbot-settings-section-DF0kqdyO.js.br +0 -0
  141. package/dist/web/assets/ppmbot-settings-section-DF0kqdyO.js.gz +0 -0
  142. package/dist/web/assets/{problems-panel-BTmOGMcL.js → problems-panel-DRcq5ChN.js} +1 -1
  143. package/dist/web/assets/problems-panel-DRcq5ChN.js.br +0 -0
  144. package/dist/web/assets/problems-panel-DRcq5ChN.js.gz +0 -0
  145. package/dist/web/assets/{process-table-Bc9WEBsS.js → process-table-Ds0S_YK-.js} +1 -1
  146. package/dist/web/assets/process-table-Ds0S_YK-.js.br +0 -0
  147. package/dist/web/assets/process-table-Ds0S_YK-.js.gz +0 -0
  148. package/dist/web/assets/{proxy-settings-section-Bo-FPk6Y.js → proxy-settings-section-Q-ttqVOa.js} +1 -1
  149. package/dist/web/assets/proxy-settings-section-Q-ttqVOa.js.br +0 -0
  150. package/dist/web/assets/proxy-settings-section-Q-ttqVOa.js.gz +0 -0
  151. package/dist/web/assets/{query-audit-section-CQfzKAf9.js → query-audit-section-Cn11xqgz.js} +1 -1
  152. package/dist/web/assets/query-audit-section-Cn11xqgz.js.br +0 -0
  153. package/dist/web/assets/query-audit-section-Cn11xqgz.js.gz +0 -0
  154. package/dist/web/assets/{remote-desktop-clipboard-notice-DgeuoZ4n.js → remote-desktop-clipboard-notice-CvPPtrRq.js} +1 -1
  155. package/dist/web/assets/remote-desktop-clipboard-notice-CvPPtrRq.js.br +0 -0
  156. package/dist/web/assets/remote-desktop-clipboard-notice-CvPPtrRq.js.gz +0 -0
  157. package/dist/web/assets/{remote-desktop-mobile-sheet-BpP7jI0p.js → remote-desktop-mobile-sheet-B-TT9Fdt.js} +2 -2
  158. package/dist/web/assets/remote-desktop-mobile-sheet-B-TT9Fdt.js.br +0 -0
  159. package/dist/web/assets/remote-desktop-mobile-sheet-B-TT9Fdt.js.gz +0 -0
  160. package/dist/web/assets/{remote-desktop-mobile-view-Byn0lFCF.js → remote-desktop-mobile-view-hUnYxXDk.js} +1 -1
  161. package/dist/web/assets/remote-desktop-mobile-view-hUnYxXDk.js.br +0 -0
  162. package/dist/web/assets/remote-desktop-mobile-view-hUnYxXDk.js.gz +0 -0
  163. package/dist/web/assets/{remote-desktop-readiness-gate-B2mXZ9vo.js → remote-desktop-readiness-gate-CUmaeiX9.js} +1 -1
  164. package/dist/web/assets/remote-desktop-readiness-gate-CUmaeiX9.js.br +0 -0
  165. package/dist/web/assets/remote-desktop-readiness-gate-CUmaeiX9.js.gz +0 -0
  166. package/dist/web/assets/{remote-desktop-window-content-CWt3VVjm.js → remote-desktop-window-content-DEPUOOGw.js} +1 -1
  167. package/dist/web/assets/remote-desktop-window-content-DEPUOOGw.js.br +0 -0
  168. package/dist/web/assets/remote-desktop-window-content-DEPUOOGw.js.gz +0 -0
  169. package/dist/web/assets/{schedules-settings-section-Bx9Rm-NB.js → schedules-settings-section-Bv_wrzDp.js} +1 -1
  170. package/dist/web/assets/schedules-settings-section-Bv_wrzDp.js.br +0 -0
  171. package/dist/web/assets/schedules-settings-section-Bv_wrzDp.js.gz +0 -0
  172. package/dist/web/assets/{settings-body-DU3LZkOy.js → settings-body-C5_chEpq.js} +2 -2
  173. package/dist/web/assets/settings-body-C5_chEpq.js.br +0 -0
  174. package/dist/web/assets/settings-body-C5_chEpq.js.gz +0 -0
  175. package/dist/web/assets/{settings-tab-Q5Ai_XB7.js → settings-tab-CogpEbq5.js} +1 -1
  176. package/dist/web/assets/{settings-window-content-DNg-jjm4.js → settings-window-content-BNRirQDZ.js} +1 -1
  177. package/dist/web/assets/{sql-query-editor-BMNsmnfi.js → sql-query-editor-Bg3lOrmt.js} +1 -1
  178. package/dist/web/assets/sql-query-editor-Bg3lOrmt.js.br +0 -0
  179. package/dist/web/assets/sql-query-editor-Bg3lOrmt.js.gz +0 -0
  180. package/dist/web/assets/{sqlite-viewer-DBdxQgCD.js → sqlite-viewer-DMKtDkI6.js} +1 -1
  181. package/dist/web/assets/sqlite-viewer-DMKtDkI6.js.br +0 -0
  182. package/dist/web/assets/sqlite-viewer-DMKtDkI6.js.gz +0 -0
  183. package/dist/web/assets/{system-monitor-body-BEuqhoiF.js → system-monitor-body-Dst39LA7.js} +2 -2
  184. package/dist/web/assets/system-monitor-body-Dst39LA7.js.br +0 -0
  185. package/dist/web/assets/system-monitor-body-Dst39LA7.js.gz +0 -0
  186. package/dist/web/assets/system-monitor-tab-CEwME1_C.js +1 -0
  187. package/dist/web/assets/{system-monitor-window-content-Dr6EgqpJ.js → system-monitor-window-content-DQRBjn9z.js} +1 -1
  188. package/dist/web/assets/{tab-host-window-content-BhS39QWy.js → tab-host-window-content-Dlunzrfh.js} +1 -1
  189. package/dist/web/assets/tab-host-window-content-Dlunzrfh.js.br +0 -0
  190. package/dist/web/assets/tab-host-window-content-Dlunzrfh.js.gz +0 -0
  191. package/dist/web/assets/{team-member-sheet-C5-PeHDb.js → team-member-sheet-CPZGU9j5.js} +2 -2
  192. package/dist/web/assets/team-member-sheet-CPZGU9j5.js.br +0 -0
  193. package/dist/web/assets/team-member-sheet-CPZGU9j5.js.gz +0 -0
  194. package/dist/web/assets/{team-member-window-content-CZjHuvdw.js → team-member-window-content-CwI9JD_H.js} +1 -1
  195. package/dist/web/assets/{team-member-window-content-CZjHuvdw.js.br → team-member-window-content-CwI9JD_H.js.br} +0 -0
  196. package/dist/web/assets/team-member-window-content-CwI9JD_H.js.gz +0 -0
  197. package/dist/web/assets/{terminal-tab-B0w7Jsbs.js → terminal-tab-BcQXleSa.js} +1 -1
  198. package/dist/web/assets/terminal-tab-BcQXleSa.js.br +0 -0
  199. package/dist/web/assets/terminal-tab-BcQXleSa.js.gz +0 -0
  200. package/dist/web/assets/{tool-cards-CmdjXi2c.js → tool-cards-DsQdMorI.js} +2 -2
  201. package/dist/web/assets/tool-cards-DsQdMorI.js.br +0 -0
  202. package/dist/web/assets/tool-cards-DsQdMorI.js.gz +0 -0
  203. package/dist/web/assets/{use-inline-blame-BSb807l9.js → use-inline-blame--fS-pzzX.js} +1 -1
  204. package/dist/web/assets/use-inline-blame--fS-pzzX.js.br +0 -0
  205. package/dist/web/assets/use-inline-blame--fS-pzzX.js.gz +0 -0
  206. package/dist/web/assets/{use-lsp-DhBjkGWr.js → use-lsp-DK26Eter.js} +1 -1
  207. package/dist/web/assets/use-lsp-DK26Eter.js.br +0 -0
  208. package/dist/web/assets/use-lsp-DK26Eter.js.gz +0 -0
  209. package/dist/web/assets/{use-monaco-theme-CNEk66US.js → use-monaco-theme-BVatH9yZ.js} +1 -1
  210. package/dist/web/assets/{use-websocket-Bki-B4fj.js → use-websocket-C1mloX0R.js} +1 -1
  211. package/dist/web/assets/{video-preview-T1SMFp03.js → video-preview-C48Go7JZ.js} +1 -1
  212. package/dist/web/assets/video-preview-C48Go7JZ.js.br +0 -0
  213. package/dist/web/assets/video-preview-C48Go7JZ.js.gz +0 -0
  214. package/dist/web/index.html +6 -6
  215. package/dist/web/index.html.br +0 -0
  216. package/dist/web/index.html.gz +0 -0
  217. package/dist/web/sw.js +1 -1
  218. package/dist/web/sw.js.br +0 -0
  219. package/dist/web/sw.js.gz +0 -0
  220. package/package.json +1 -1
  221. package/src/providers/codex-app-server/codex-auth-failure.ts +51 -0
  222. package/src/providers/codex-app-server/codex-event-mapper.ts +8 -0
  223. package/src/providers/codex-app-server/codex-provider.ts +97 -19
  224. package/src/providers/codex-app-server/codex-usage-source.ts +14 -1
  225. package/src/server/routes/codex-accounts.ts +18 -6
  226. package/src/services/codex-account-auth-state.ts +58 -0
  227. package/src/services/codex-account-login.ts +42 -9
  228. package/src/services/codex-account.service.ts +42 -7
  229. package/src/services/proxy-agent-anthropic-bridge.ts +2 -2
  230. package/src/services/proxy-agent-bridge.ts +2 -2
  231. package/src/services/proxy-agent-turn.ts +80 -20
  232. package/src/services/proxy-image-bridge.ts +3 -3
  233. package/src/services/proxy.service.ts +1 -1
  234. package/src/web/components/chat/codex-usage-panel.tsx +13 -1
  235. package/src/web/components/chat/usage-badge.tsx +14 -0
  236. package/src/web/components/settings/accounts/account-add-dialog.tsx +10 -3
  237. package/src/web/components/settings/accounts/account-card.tsx +15 -4
  238. package/src/web/components/settings/accounts/account-hint.tsx +19 -2
  239. package/src/web/components/settings/accounts/claude-accounts-section.tsx +10 -2
  240. package/src/web/components/settings/accounts/codex-accounts-section.tsx +18 -2
  241. package/src/web/components/settings/accounts/codex-add-account-dialog.tsx +50 -33
  242. package/src/web/components/settings/accounts/codex-sign-in-again-dialog.tsx +47 -0
  243. package/src/web/components/settings/accounts/use-codex-accounts.ts +18 -4
  244. package/src/web/lib/fluent-icon.tsx +38 -2
  245. package/dist/web/assets/accounts-settings-section-CVJ7hQom.js +0 -1
  246. package/dist/web/assets/accounts-settings-section-CVJ7hQom.js.br +0 -0
  247. package/dist/web/assets/accounts-settings-section-CVJ7hQom.js.gz +0 -0
  248. package/dist/web/assets/ai-resource-editor-DoCiQDKY.js.br +0 -0
  249. package/dist/web/assets/ai-resource-editor-DoCiQDKY.js.gz +0 -0
  250. package/dist/web/assets/ai-settings-section-0x6GFJ56.js.br +0 -0
  251. package/dist/web/assets/ai-settings-section-0x6GFJ56.js.gz +0 -0
  252. package/dist/web/assets/appearance-settings-section-mRiGj3_g.js.br +0 -0
  253. package/dist/web/assets/appearance-settings-section-mRiGj3_g.js.gz +0 -0
  254. package/dist/web/assets/audio-preview-CO7Ia2N5.js.br +0 -0
  255. package/dist/web/assets/audio-preview-CO7Ia2N5.js.gz +0 -0
  256. package/dist/web/assets/branch-review-tab-F3CALiEa.js.br +0 -0
  257. package/dist/web/assets/branch-review-tab-F3CALiEa.js.gz +0 -0
  258. package/dist/web/assets/chat-tab-D6BFnkCj.js +0 -1
  259. package/dist/web/assets/chat-tab-D6BFnkCj.js.br +0 -0
  260. package/dist/web/assets/chat-tab-D6BFnkCj.js.gz +0 -0
  261. package/dist/web/assets/chat-tab-IXHMUKMW.js +0 -15
  262. package/dist/web/assets/chat-tab-IXHMUKMW.js.br +0 -0
  263. package/dist/web/assets/chat-tab-IXHMUKMW.js.gz +0 -0
  264. package/dist/web/assets/code-editor-FsR6KpZa.js.br +0 -0
  265. package/dist/web/assets/code-editor-FsR6KpZa.js.gz +0 -0
  266. package/dist/web/assets/codex-daily-guard-Bn8jfcei.js +0 -1
  267. package/dist/web/assets/codex-daily-guard-Bn8jfcei.js.br +0 -0
  268. package/dist/web/assets/codex-daily-guard-Bn8jfcei.js.gz +0 -0
  269. package/dist/web/assets/conflict-editor-GGqIz6tt.js.br +0 -0
  270. package/dist/web/assets/conflict-editor-GGqIz6tt.js.gz +0 -0
  271. package/dist/web/assets/context-menu-CVO3HtIt.js.br +0 -0
  272. package/dist/web/assets/context-menu-CVO3HtIt.js.gz +0 -0
  273. package/dist/web/assets/csv-preview-ycnxJ_6J.js.br +0 -0
  274. package/dist/web/assets/csv-preview-ycnxJ_6J.js.gz +0 -0
  275. package/dist/web/assets/database-viewer-y6URJv8N.js.br +0 -0
  276. package/dist/web/assets/database-viewer-y6URJv8N.js.gz +0 -0
  277. package/dist/web/assets/design-responsive-dialog-D0QYfX7v.js.br +0 -0
  278. package/dist/web/assets/design-responsive-dialog-D0QYfX7v.js.gz +0 -0
  279. package/dist/web/assets/design-tab-DgCTcwot.js.br +0 -0
  280. package/dist/web/assets/design-tab-DgCTcwot.js.gz +0 -0
  281. package/dist/web/assets/designs-sidebar-panel-Dtuph5jh.js.br +0 -0
  282. package/dist/web/assets/designs-sidebar-panel-Dtuph5jh.js.gz +0 -0
  283. package/dist/web/assets/dialog-CaShS4f5.js.br +0 -0
  284. package/dist/web/assets/dialog-CaShS4f5.js.gz +0 -0
  285. package/dist/web/assets/diff-viewer-ciBkExM7.js.br +0 -0
  286. package/dist/web/assets/diff-viewer-ciBkExM7.js.gz +0 -0
  287. package/dist/web/assets/docx-preview-C8K6QzOW.js.br +0 -0
  288. package/dist/web/assets/docx-preview-C8K6QzOW.js.gz +0 -0
  289. package/dist/web/assets/editor-language-service-CkoaAHjF.js.br +0 -0
  290. package/dist/web/assets/editor-language-service-CkoaAHjF.js.gz +0 -0
  291. package/dist/web/assets/explorer-body-C5gXPGOl.js.br +0 -0
  292. package/dist/web/assets/explorer-body-C5gXPGOl.js.gz +0 -0
  293. package/dist/web/assets/explorer-window-content-8EBl9Vkx.js.br +0 -0
  294. package/dist/web/assets/explorer-window-content-8EBl9Vkx.js.gz +0 -0
  295. package/dist/web/assets/extension-manager-section-DOwZYx8O.js.br +0 -0
  296. package/dist/web/assets/extension-manager-section-DOwZYx8O.js.gz +0 -0
  297. package/dist/web/assets/extension-webview-CdEva8pD.js.br +0 -0
  298. package/dist/web/assets/extension-webview-CdEva8pD.js.gz +0 -0
  299. package/dist/web/assets/files-settings-section-DVemQIZ2.js.br +0 -0
  300. package/dist/web/assets/files-settings-section-DVemQIZ2.js.gz +0 -0
  301. package/dist/web/assets/general-settings-section-DiY_5C93.js.br +0 -0
  302. package/dist/web/assets/general-settings-section-DiY_5C93.js.gz +0 -0
  303. package/dist/web/assets/git-log-panel-Cq0WohOO.js.br +0 -0
  304. package/dist/web/assets/git-log-panel-Cq0WohOO.js.gz +0 -0
  305. package/dist/web/assets/glide-data-grid-DG9AnCmP.js.br +0 -0
  306. package/dist/web/assets/glide-data-grid-DG9AnCmP.js.gz +0 -0
  307. package/dist/web/assets/group-chat-tab-DxbDrFJl.js.br +0 -0
  308. package/dist/web/assets/group-chat-tab-DxbDrFJl.js.gz +0 -0
  309. package/dist/web/assets/icons-C9ZwXgel.js +0 -1
  310. package/dist/web/assets/icons-C9ZwXgel.js.br +0 -0
  311. package/dist/web/assets/icons-C9ZwXgel.js.gz +0 -0
  312. package/dist/web/assets/index-BVKT5UCu.js.br +0 -0
  313. package/dist/web/assets/index-BVKT5UCu.js.gz +0 -0
  314. package/dist/web/assets/index-CzYrKDUF.css +0 -1
  315. package/dist/web/assets/index-CzYrKDUF.css.br +0 -0
  316. package/dist/web/assets/index-CzYrKDUF.css.gz +0 -0
  317. package/dist/web/assets/jira-watcher-section-Cr8gSVGY.js.br +0 -0
  318. package/dist/web/assets/jira-watcher-section-Cr8gSVGY.js.gz +0 -0
  319. package/dist/web/assets/keyboard-shortcuts-section-BvC6m_C2.js.br +0 -0
  320. package/dist/web/assets/keyboard-shortcuts-section-BvC6m_C2.js.gz +0 -0
  321. package/dist/web/assets/markdown-renderer-8JlfrfnD.js.br +0 -0
  322. package/dist/web/assets/markdown-renderer-8JlfrfnD.js.gz +0 -0
  323. package/dist/web/assets/mobile-explorer-sheet-cJfocgE7.js.br +0 -0
  324. package/dist/web/assets/mobile-explorer-sheet-cJfocgE7.js.gz +0 -0
  325. package/dist/web/assets/new-design-dialog-BO_D3nex.js.br +0 -0
  326. package/dist/web/assets/new-design-dialog-BO_D3nex.js.gz +0 -0
  327. package/dist/web/assets/notifications-settings-section-DaMh3khs.js.br +0 -0
  328. package/dist/web/assets/notifications-settings-section-DaMh3khs.js.gz +0 -0
  329. package/dist/web/assets/onboarding-entry-CwkNJ69U.js.br +0 -0
  330. package/dist/web/assets/onboarding-entry-CwkNJ69U.js.gz +0 -0
  331. package/dist/web/assets/onboarding-quick-orientation-u7yM68d3.js.br +0 -0
  332. package/dist/web/assets/onboarding-quick-orientation-u7yM68d3.js.gz +0 -0
  333. package/dist/web/assets/pdf-preview-CaxTidh0.js.br +0 -0
  334. package/dist/web/assets/pdf-preview-CaxTidh0.js.gz +0 -0
  335. package/dist/web/assets/postgres-viewer-CJOOLdgO.js.br +0 -0
  336. package/dist/web/assets/postgres-viewer-CJOOLdgO.js.gz +0 -0
  337. package/dist/web/assets/ppmbot-settings-section-rNBdWG7F.js.br +0 -0
  338. package/dist/web/assets/ppmbot-settings-section-rNBdWG7F.js.gz +0 -0
  339. package/dist/web/assets/problems-panel-BTmOGMcL.js.br +0 -0
  340. package/dist/web/assets/problems-panel-BTmOGMcL.js.gz +0 -0
  341. package/dist/web/assets/process-table-Bc9WEBsS.js.br +0 -0
  342. package/dist/web/assets/process-table-Bc9WEBsS.js.gz +0 -0
  343. package/dist/web/assets/proxy-settings-section-Bo-FPk6Y.js.br +0 -0
  344. package/dist/web/assets/proxy-settings-section-Bo-FPk6Y.js.gz +0 -0
  345. package/dist/web/assets/query-audit-section-CQfzKAf9.js.br +0 -0
  346. package/dist/web/assets/query-audit-section-CQfzKAf9.js.gz +0 -0
  347. package/dist/web/assets/remote-desktop-clipboard-notice-DgeuoZ4n.js.br +0 -0
  348. package/dist/web/assets/remote-desktop-clipboard-notice-DgeuoZ4n.js.gz +0 -0
  349. package/dist/web/assets/remote-desktop-mobile-sheet-BpP7jI0p.js.br +0 -0
  350. package/dist/web/assets/remote-desktop-mobile-sheet-BpP7jI0p.js.gz +0 -0
  351. package/dist/web/assets/remote-desktop-mobile-view-Byn0lFCF.js.br +0 -0
  352. package/dist/web/assets/remote-desktop-mobile-view-Byn0lFCF.js.gz +0 -0
  353. package/dist/web/assets/remote-desktop-readiness-gate-B2mXZ9vo.js.br +0 -0
  354. package/dist/web/assets/remote-desktop-readiness-gate-B2mXZ9vo.js.gz +0 -0
  355. package/dist/web/assets/remote-desktop-window-content-CWt3VVjm.js.br +0 -0
  356. package/dist/web/assets/remote-desktop-window-content-CWt3VVjm.js.gz +0 -0
  357. package/dist/web/assets/schedules-settings-section-Bx9Rm-NB.js.br +0 -0
  358. package/dist/web/assets/schedules-settings-section-Bx9Rm-NB.js.gz +0 -0
  359. package/dist/web/assets/settings-body-DU3LZkOy.js.br +0 -0
  360. package/dist/web/assets/settings-body-DU3LZkOy.js.gz +0 -0
  361. package/dist/web/assets/sql-query-editor-BMNsmnfi.js.br +0 -0
  362. package/dist/web/assets/sql-query-editor-BMNsmnfi.js.gz +0 -0
  363. package/dist/web/assets/sqlite-viewer-DBdxQgCD.js.br +0 -0
  364. package/dist/web/assets/sqlite-viewer-DBdxQgCD.js.gz +0 -0
  365. package/dist/web/assets/system-monitor-body-BEuqhoiF.js.br +0 -0
  366. package/dist/web/assets/system-monitor-body-BEuqhoiF.js.gz +0 -0
  367. package/dist/web/assets/system-monitor-tab-BAU1kzbY.js +0 -1
  368. package/dist/web/assets/tab-host-window-content-BhS39QWy.js.br +0 -0
  369. package/dist/web/assets/tab-host-window-content-BhS39QWy.js.gz +0 -0
  370. package/dist/web/assets/team-member-sheet-C5-PeHDb.js.br +0 -0
  371. package/dist/web/assets/team-member-sheet-C5-PeHDb.js.gz +0 -0
  372. package/dist/web/assets/team-member-window-content-CZjHuvdw.js.gz +0 -0
  373. package/dist/web/assets/terminal-tab-B0w7Jsbs.js.br +0 -0
  374. package/dist/web/assets/terminal-tab-B0w7Jsbs.js.gz +0 -0
  375. package/dist/web/assets/tool-cards-CmdjXi2c.js.br +0 -0
  376. package/dist/web/assets/tool-cards-CmdjXi2c.js.gz +0 -0
  377. package/dist/web/assets/use-inline-blame-BSb807l9.js.br +0 -0
  378. package/dist/web/assets/use-inline-blame-BSb807l9.js.gz +0 -0
  379. package/dist/web/assets/use-lsp-DhBjkGWr.js.br +0 -0
  380. package/dist/web/assets/use-lsp-DhBjkGWr.js.gz +0 -0
  381. package/dist/web/assets/video-preview-T1SMFp03.js.br +0 -0
  382. package/dist/web/assets/video-preview-T1SMFp03.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{Ar as r,G as i,Jr as a,W as o}from"./icons-C9ZwXgel.js";import{n as s}from"./api-client-c8YOpTlT.js";import{t as c,y as l}from"./settings-store-DXmQug0m.js";import{n as u}from"./utils-btZ8C8-R.js";import{t as d}from"./ws-auth-B_y5rMfZ.js";import{z as f}from"./index-BVKT5UCu.js";import{r as p}from"./run-in-terminal-SU9cwoZ4.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:l(c.getState().remoteDesktopQuality)??`balanced`,held:1})),g=(0,_.useRef)(l(c.getState().remoteDesktopQuality)),[v,b]=(0,_.useState)(null),x=(0,_.useRef)(null),S=c(e=>e.remoteDesktopShowCursor),w=c(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)(c.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=l(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=c.getState();return{type:`quality`,preset:`custom`,percent:t.remoteDesktopCustomQualityPercent,fps:t.remoteDesktopCustomFps}},[]),Y=(0,_.useCallback)(e=>{g.current=e,c.getState().setRemoteDesktopQuality(e),K(J(e))},[J,K]),X=(0,_.useCallback)((e,t)=>{let n=c.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,c.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,c.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=c(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{n as s}from"./api-client-c8YOpTlT.js";import{t as c,y as l}from"./settings-store-DXmQug0m.js";import{n as u}from"./utils-btZ8C8-R.js";import{t as d}from"./ws-auth-B_y5rMfZ.js";import{z as f}from"./index-CvUGUp7d.js";import{r as p}from"./run-in-terminal-SU9cwoZ4.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:l(c.getState().remoteDesktopQuality)??`balanced`,held:1})),g=(0,_.useRef)(l(c.getState().remoteDesktopQuality)),[v,b]=(0,_.useState)(null),x=(0,_.useRef)(null),S=c(e=>e.remoteDesktopShowCursor),w=c(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)(c.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=l(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=c.getState();return{type:`quality`,preset:`custom`,percent:t.remoteDesktopCustomQualityPercent,fps:t.remoteDesktopCustomFps}},[]),Y=(0,_.useCallback)(e=>{g.current=e,c.getState().setRemoteDesktopQuality(e),K(J(e))},[J,K]),X=(0,_.useCallback)((e,t)=>{let n=c.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,c.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,c.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=c(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-Byn0lFCF.js","assets/rolldown-runtime-C5c2KzVm.js","assets/index-BVKT5UCu.js","assets/vendor-mermaid-eg2XWIjK.js","assets/vendor-ui-BHh12_0v.js","assets/vendor-markdown-QKPNiWEd.js","assets/button-CBehaXpV.js","assets/utils-btZ8C8-R.js","assets/createLucideIcon-DBXq3G0e.js","assets/api-client-c8YOpTlT.js","assets/react-CzUPVyyG.js","assets/settings-store-DXmQug0m.js","assets/file-store-CTlJqj2m.js","assets/window-store-B4cbZ5rr.js","assets/window-pip-registry-DH07f_8k.js","assets/panel-store-BUQ-CPsd.js","assets/onboarding-quick-orientation-u7yM68d3.js","assets/dialog-CaShS4f5.js","assets/portal-container-context-NFSuymMu.js","assets/icons-C9ZwXgel.js","assets/use-is-mobile-CkO33jqU.js","assets/format-file-meta-DLaHgkdx.js","assets/fs-api-RVc5RtTA.js","assets/context-menu-CVO3HtIt.js","assets/input-CP31LZnN.js","assets/mobile-bottom-sheet-Cf4kV1hS.js","assets/use-visual-viewport-C307OVeV.js","assets/scroll-area-xAtds1T-.js","assets/file-icons-BlOxPo3P.js","assets/project-framework-store-XxFXcUpb.js","assets/format-date-BMtvCeb9.js","assets/git-repo-store-DFTJ5ngK.js","assets/project-store-C5gJXkvb.js","assets/ws-auth-B_y5rMfZ.js","assets/tab-store-DqeaGhhE.js","assets/apply-theme-aVoqSG0I.js","assets/resolve-theme-B87m6l4i.js","assets/index-CzYrKDUF.css","assets/remote-desktop-clipboard-notice-DgeuoZ4n.js","assets/run-in-terminal-SU9cwoZ4.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{pt as r}from"./vendor-ui-BHh12_0v.js";import"./icons-C9ZwXgel.js";import"./api-client-c8YOpTlT.js";import"./settings-store-DXmQug0m.js";import{q as i}from"./vendor-mermaid-eg2XWIjK.js";import{n as a}from"./portal-container-context-NFSuymMu.js";import"./panel-store-BUQ-CPsd.js";import"./window-store-B4cbZ5rr.js";import{B as o}from"./index-BVKT5UCu.js";import"./run-in-terminal-SU9cwoZ4.js";import{n as s,t as c}from"./remote-desktop-readiness-gate-B2mXZ9vo.js";var l=e(t(),1),u=e(r(),1),d=n(),f=(0,l.lazy)(()=>i(()=>import(`./remote-desktop-mobile-view-Byn0lFCF.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-hUnYxXDk.js","assets/rolldown-runtime-C5c2KzVm.js","assets/index-CvUGUp7d.js","assets/vendor-mermaid-eg2XWIjK.js","assets/vendor-ui-BHh12_0v.js","assets/vendor-markdown-QKPNiWEd.js","assets/button-CBehaXpV.js","assets/utils-btZ8C8-R.js","assets/createLucideIcon-DBXq3G0e.js","assets/api-client-c8YOpTlT.js","assets/react-CzUPVyyG.js","assets/settings-store-DXmQug0m.js","assets/file-store-CTlJqj2m.js","assets/window-store-B4cbZ5rr.js","assets/window-pip-registry-DH07f_8k.js","assets/panel-store-BUQ-CPsd.js","assets/onboarding-quick-orientation-CT4PylG0.js","assets/dialog-tzBRkGeW.js","assets/portal-container-context-NFSuymMu.js","assets/icons-CO_II6D-.js","assets/use-is-mobile-CkO33jqU.js","assets/format-file-meta-DLaHgkdx.js","assets/fs-api-RVc5RtTA.js","assets/context-menu-CjYTq8DI.js","assets/input-CP31LZnN.js","assets/mobile-bottom-sheet-Cf4kV1hS.js","assets/use-visual-viewport-C307OVeV.js","assets/scroll-area-xAtds1T-.js","assets/file-icons-BlOxPo3P.js","assets/project-framework-store-XxFXcUpb.js","assets/format-date-BMtvCeb9.js","assets/git-repo-store-DFTJ5ngK.js","assets/project-store-C5gJXkvb.js","assets/ws-auth-B_y5rMfZ.js","assets/tab-store-DqeaGhhE.js","assets/apply-theme-aVoqSG0I.js","assets/resolve-theme-B87m6l4i.js","assets/index-DMA-So69.css","assets/remote-desktop-clipboard-notice-CvPPtrRq.js","assets/run-in-terminal-SU9cwoZ4.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{pt as r}from"./vendor-ui-BHh12_0v.js";import"./icons-CO_II6D-.js";import"./api-client-c8YOpTlT.js";import"./settings-store-DXmQug0m.js";import{q as i}from"./vendor-mermaid-eg2XWIjK.js";import{n as a}from"./portal-container-context-NFSuymMu.js";import"./panel-store-BUQ-CPsd.js";import"./window-store-B4cbZ5rr.js";import{B as o}from"./index-CvUGUp7d.js";import"./run-in-terminal-SU9cwoZ4.js";import{n as s,t as c}from"./remote-desktop-readiness-gate-CUmaeiX9.js";var l=e(t(),1),u=e(r(),1),d=n(),f=(0,l.lazy)(()=>i(()=>import(`./remote-desktop-mobile-view-hUnYxXDk.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 +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-BHh12_0v.js";import{En as r,Gr as i,Gt as a,Jr as o,Mn as s,Nt as c,On as l,Qt as u,Ur as d,W as f,or as p,pr as m,ti as h,ut as g,xr as _,z as v,zt as y}from"./icons-C9ZwXgel.js";import"./api-client-c8YOpTlT.js";import{b,t as x,v as S}from"./settings-store-DXmQug0m.js";import"./vendor-mermaid-eg2XWIjK.js";import{n as C}from"./utils-btZ8C8-R.js";import"./panel-store-BUQ-CPsd.js";import"./window-store-B4cbZ5rr.js";import{t as w}from"./use-visual-viewport-C307OVeV.js";import"./ws-auth-B_y5rMfZ.js";import{z as ee}from"./index-BVKT5UCu.js";import"./run-in-terminal-SU9cwoZ4.js";import{a as T,c as te,d as E,f as D,i as ne,n as re,o as O,p as k,r as A,s as ie,t as j}from"./remote-desktop-clipboard-notice-DgeuoZ4n.js";var M=e(t(),1);function ae(e,t,n=10,r=300){let i=Math.hypot(t.x-e.x,t.y-e.y),a=t.t-e.t;return i<=n&&a<=r}function oe(e,t,n=15){return Math.abs(t-e)>n?`pinch`:`scroll`}function N(e,t){return Math.hypot(t.x-e.x,t.y-e.y)}function P(e,t){return{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}function F(e,t,n){return Math.min(Math.max(e,t),n)}function I(e,t,n){return[{type:`pointer`,xFrac:e,yFrac:t,button:n,down:!0},{type:`pointer`,xFrac:e,yFrac:t,button:n,down:!1}]}function se(e,t,n){return{start:{x:e,y:t,t:performance.now()},last:{x:e,y:t},moved:!1,rect:n}}function ce(e,t,n,r,i,a){let o=Math.hypot(t-e.start.x,n-e.start.y);if(r===`touch`){if(!e.moved&&o>10){e.moved=!0;let r=E(e.start.x,e.start.y,e.rect,i);return e.last={x:t,y:n},{message:{type:`pointer`,xFrac:r.xFrac,yFrac:r.yFrac,button:`left`,down:!0}}}if(e.last={x:t,y:n},!e.moved)return{};let r=E(t,n,e.rect,i);return{message:{type:`pointer`,xFrac:r.xFrac,yFrac:r.yFrac,button:null,down:null}}}let s=(t-e.last.x)/i.scale,c=(n-e.last.y)/i.scale;return o>10&&(e.moved=!0),e.last={x:t,y:n},{cursor:{xFrac:F(a.xFrac+s/e.rect.width,0,1),yFrac:F(a.yFrac+c/e.rect.height,0,1)},sendCursorMove:!0}}function L(e,t,n,r,i,a){let o={x:t,y:n,t:performance.now()},s=ae(e.start,o,10,300);if(r===`touch`){let r=E(t,n,e.rect,i);return!e.moved&&s?I(r.xFrac,r.yFrac,`left`):e.moved?[{type:`pointer`,xFrac:r.xFrac,yFrac:r.yFrac,button:`left`,down:!1}]:[]}return!e.moved&&s?I(a.xFrac,a.yFrac,`left`):[]}function R(e,t,n){let r=P(e,t);return{startDistance:N(e,t),startMid:r,lastMid:r,startScale:n,startTime:performance.now(),gesture:null}}function le(e,t,n,r){let i=N(t,n),a=P(t,n);if(e.gesture===null){let t=Math.abs(i-e.startDistance),n=N(e.startMid,a);if(t>15)e.gesture=oe(e.startDistance,i,15);else if(n>15)e.gesture=`scroll`;else return e.lastMid=a,{}}let o;if(e.gesture===`pinch`)o={transform:{scale:F(e.startScale*(i/e.startDistance),1,4),panX:r.panX,panY:r.panY}};else if(r.scale>1.01){let t=a.x-e.lastMid.x,n=a.y-e.lastMid.y;o={transform:{scale:r.scale,panX:r.panX+t,panY:r.panY+n}}}else o={wheelDeltaPx:a.y-e.lastMid.y};return e.lastMid=a,o}function z(e,t,n){if(e.gesture===null&&performance.now()-e.startTime<=300){let r=E(e.lastMid.x,e.lastMid.y,t,n);return I(r.xFrac,r.yFrac,`right`)}return[]}var B={scale:1,panX:0,panY:0},ue=40,de=120;function fe({containerRef:e,canvasRef:t,mode:n,sendMessage:r,enabled:i}){let[a,o]=(0,M.useState)(B),[s,c]=(0,M.useState)({xFrac:.5,yFrac:.5}),l=(0,M.useRef)(a),u=(0,M.useRef)(s),d=(0,M.useRef)(n);d.current=n;let f=(0,M.useRef)({transform:null,cursor:null,sendCursorMove:!1,wheelPx:0}),p=(0,M.useRef)(0),m=(0,M.useCallback)(()=>{p.current=0;let e=f.current;e.transform&&=(l.current=e.transform,o(e.transform),null),e.cursor&&(u.current=e.cursor,c(e.cursor),e.sendCursorMove&&r({type:`pointer`,xFrac:e.cursor.xFrac,yFrac:e.cursor.yFrac,button:null,down:null}),e.cursor=null,e.sendCursorMove=!1),e.wheelPx!==0&&(r({type:`wheel`,dy:-(e.wheelPx/ue)*de}),e.wheelPx=0)},[r]),h=(0,M.useCallback)(()=>{p.current||=requestAnimationFrame(m)},[m]),g=(0,M.useCallback)(()=>{l.current=B,o(B)},[]);return(0,M.useEffect)(()=>{let n=e.current;if(!n||!i)return;let a=null,o=null,s=e=>e.forEach(r),c=()=>{let e=n.getBoundingClientRect(),r=t.current;return!r||!r.width||!r.height?e:D(e,r.width,r.height)},m=e=>{e.preventDefault(),e.stopPropagation();let t=c();if(e.touches.length===1){o=null;let n=e.touches[0];a=se(n.clientX,n.clientY,t)}else if(e.touches.length===2){a=null;let[t,n]=[e.touches[0],e.touches[1]];o=R({x:t.clientX,y:t.clientY},{x:n.clientX,y:n.clientY},l.current.scale)}else a=null,o=null},g=e=>{if(e.preventDefault(),e.stopPropagation(),a&&e.touches.length===1){let t=e.touches[0],n=ce(a,t.clientX,t.clientY,d.current,l.current,u.current);n.message&&r(n.message),n.cursor&&(u.current=n.cursor,f.current.cursor=n.cursor,f.current.sendCursorMove=!!n.sendCursorMove,h());return}if(o&&e.touches.length===2){let[t,n]=[e.touches[0],e.touches[1]],r=le(o,{x:t.clientX,y:t.clientY},{x:n.clientX,y:n.clientY},l.current);r.transform&&(l.current=r.transform,f.current.transform=r.transform,h()),r.wheelDeltaPx&&(f.current.wheelPx+=r.wheelDeltaPx,h())}},_=e=>{e.preventDefault(),e.stopPropagation();let t=e.changedTouches[0];if(a){let e=t?t.clientX:a.last.x,n=t?t.clientY:a.last.y;s(L(a,e,n,d.current,l.current,u.current)),a=null}o&&=(s(z(o,c(),l.current)),null)},v=e=>{e.stopPropagation(),a?.moved&&d.current===`touch`&&s(L(a,a.last.x,a.last.y,`touch`,l.current,u.current)),a=null,o=null};return n.addEventListener(`touchstart`,m,{passive:!1}),n.addEventListener(`touchmove`,g,{passive:!1}),n.addEventListener(`touchend`,_,{passive:!1}),n.addEventListener(`touchcancel`,v,{passive:!1}),()=>{p.current&&cancelAnimationFrame(p.current),n.removeEventListener(`touchstart`,m),n.removeEventListener(`touchmove`,g),n.removeEventListener(`touchend`,_),n.removeEventListener(`touchcancel`,v)}},[e,t,i,r,h]),{transform:a,virtualCursor:n===`mouse`?s:null,resetZoom:g}}function V(e,t,n){let r=e=>{n({type:`key`,code:e,down:!0}),n({type:`key`,code:e,down:!1})};switch(e){case`insertText`:return t&&n({type:`text`,text:t}),!0;case`insertLineBreak`:case`insertParagraph`:return r(`Enter`),!0;case`deleteContentBackward`:return r(`Backspace`),!0;case`deleteContentForward`:return r(`Delete`),!0;default:return!1}}function pe(e,t,n){let r=(0,M.useRef)(null);return(0,M.useEffect)(()=>{let i=r.current;if(!i||!t)return;let a=()=>e({type:`releaseAll`}),o=e=>e.code!==``&&e.key!==`Unidentified`,s=t=>{o(t)&&(t.preventDefault(),e({type:`key`,code:t.code,down:!0}))},c=t=>{o(t)&&(t.preventDefault(),e({type:`key`,code:t.code,down:!1}))},l=t=>{V(t.inputType,t.data,e)&&t.preventDefault()},u=t=>{t.data&&e({type:`text`,text:t.data}),i.value=``},d=e=>{let t=e.clipboardData?.getData(`text/plain`);!t||!n||(e.preventDefault(),n(t))},f=()=>a(),p=()=>{document.hidden&&a()};return i.addEventListener(`keydown`,s),i.addEventListener(`keyup`,c),i.addEventListener(`beforeinput`,l),i.addEventListener(`compositionend`,u),i.addEventListener(`paste`,d),i.addEventListener(`blur`,f),document.addEventListener(`visibilitychange`,p),()=>{i.removeEventListener(`keydown`,s),i.removeEventListener(`keyup`,c),i.removeEventListener(`beforeinput`,l),i.removeEventListener(`compositionend`,u),i.removeEventListener(`paste`,d),i.removeEventListener(`blur`,f),document.removeEventListener(`visibilitychange`,p),a()}},[t,e,n]),{inputRef:r,show:(0,M.useCallback)(()=>r.current?.focus(),[])}}var H=n();function U({onClick:e,label:t,active:n,children:r}){return(0,H.jsxs)(`button`,{type:`button`,onClick:e,"aria-label":t,className:C(`flex min-h-11 min-w-11 flex-1 flex-col items-center justify-center gap-0.5 rounded-lg py-1.5 text-[10px]`,`text-white/80 active:bg-white/10 transition-colors`,n&&`bg-white/15 text-white`),children:[r,(0,H.jsx)(`span`,{children:t})]})}function me({displayLabel:e,onNextDisplay:t,qualityLabel:n,onNextQuality:a,mode:c,onToggleMode:l,onOpenKeyboard:d,onResetZoom:f,settingsOpen:p,onToggleSettings:g,onClose:_}){return(0,H.jsxs)(`div`,{className:`flex shrink-0 items-stretch gap-1 border-t border-white/10 bg-black/90 px-2 pb-[max(0.375rem,env(safe-area-inset-bottom))] pt-1.5`,"data-testid":`remote-desktop-mobile-toolbar`,children:[(0,H.jsx)(U,{onClick:l,label:c===`mouse`?`Mouse`:`Touch`,active:!0,children:c===`mouse`?(0,H.jsx)(s,{className:`size-5`}):(0,H.jsx)(y,{className:`size-5`})}),(0,H.jsx)(U,{onClick:d,label:`Keyboard`,children:(0,H.jsx)(u,{className:`size-5`})}),(0,H.jsx)(U,{onClick:f,label:`Reset zoom`,children:(0,H.jsx)(h,{className:`size-5`})}),e!==null&&(0,H.jsx)(U,{onClick:t,label:e.length>10?`${e.slice(0,9)}…`:e,children:(0,H.jsx)(r,{className:`size-5`})}),(0,H.jsx)(U,{onClick:a,label:n,children:(0,H.jsx)(i,{className:`size-5`})}),(0,H.jsx)(U,{onClick:g,label:`More`,active:p,children:(0,H.jsx)(m,{className:`size-5`})}),(0,H.jsx)(U,{onClick:_,label:`Close`,children:(0,H.jsx)(o,{className:`size-5`})})]})}function W(e){return(e.includes(`ControlLeft`)||e.includes(`MetaLeft`))&&(e.includes(`KeyC`)||e.includes(`KeyX`))}var G=[{label:`Ctrl`,code:`ControlLeft`},{label:`Alt`,code:`AltLeft`},{label:`Shift`,code:`ShiftLeft`},{label:`Win`,code:`MetaLeft`}],K=[{label:`Esc`,code:`Escape`},{label:`Tab`,code:`Tab`},{label:`←`,code:`ArrowLeft`},{label:`↑`,code:`ArrowUp`},{label:`↓`,code:`ArrowDown`},{label:`→`,code:`ArrowRight`}],q=[{label:`Ctrl+C`,codes:[`ControlLeft`,`KeyC`]},{label:`Ctrl+V`,codes:[`ControlLeft`,`KeyV`]},{label:`Ctrl+Z`,codes:[`ControlLeft`,`KeyZ`]},{label:`Ctrl+A`,codes:[`ControlLeft`,`KeyA`]},{label:`Alt+Tab`,codes:[`AltLeft`,`Tab`]},{label:`Ctrl+Alt+Del`,codes:[`ControlLeft`,`AltLeft`,`Delete`]}];function J({onClick:e,active:t,className:n,children:r}){return(0,H.jsx)(`button`,{type:`button`,onClick:e,className:C(`min-h-11 min-w-11 shrink-0 whitespace-nowrap rounded-md px-2.5 text-xs font-medium text-white/80`,`active:bg-white/15 transition-colors`,t&&`bg-primary text-primary-foreground`,n),children:r})}function he({sendMessage:e,onCopyCombo:t}){let[n,r]=(0,M.useState)(new Set),i=(0,M.useRef)(n);i.current=n,(0,M.useEffect)(()=>()=>{i.current.forEach(t=>e({type:`key`,code:t,down:!1}))},[e]);let a=(0,M.useCallback)(t=>{r(n=>{let r=n.has(t);e({type:`key`,code:t,down:!r});let i=new Set(n);return r?i.delete(t):i.add(t),i})},[e]),o=(0,M.useCallback)(t=>{e({type:`key`,code:t,down:!0}),e({type:`key`,code:t,down:!1})},[e]),s=(0,M.useCallback)(n=>{n.forEach(t=>e({type:`key`,code:t,down:!0})),[...n].reverse().forEach(t=>e({type:`key`,code:t,down:!1})),W(n)&&t?.()},[e,t]);return(0,H.jsxs)(`div`,{className:`flex shrink-0 gap-1 overflow-x-auto border-t border-white/10 bg-black/90 px-2 py-1.5`,"data-testid":`remote-desktop-mobile-key-bar`,children:[G.map(e=>(0,H.jsx)(J,{onClick:()=>a(e.code),active:n.has(e.code),children:e.label},e.code)),(0,H.jsx)(`div`,{className:`mx-0.5 w-px shrink-0 bg-white/10`}),K.map(e=>(0,H.jsx)(J,{onClick:()=>o(e.code),children:e.label},e.code)),(0,H.jsx)(`div`,{className:`mx-0.5 w-px shrink-0 bg-white/10`}),q.map(e=>(0,H.jsx)(J,{onClick:()=>s(e.codes),children:e.label},e.label))]})}function Y({icon:e,label:t,hint:n,checked:r,onToggle:i,testId:a,disabled:o}){return(0,H.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":r,disabled:o,onClick:i,"data-testid":a,className:`flex min-h-11 w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-white/80 active:bg-white/10 disabled:opacity-50`,children:[(0,H.jsx)(`span`,{className:`shrink-0 opacity-80`,children:e}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`block truncate text-xs`,children:t}),n&&(0,H.jsx)(`span`,{className:`block truncate text-[10px] text-white/45`,children:n})]}),(0,H.jsx)(`span`,{className:C(`relative h-5 w-9 shrink-0 rounded-full transition-colors`,r?`bg-primary`:`bg-white/20`),children:(0,H.jsx)(`span`,{className:C(`absolute top-0.5 size-4 rounded-full bg-white transition-all`,r?`left-[1.125rem]`:`left-0.5`)})})]})}function ge({statsVisible:e,onToggleStats:t,showCursor:n,onSetShowCursor:r,clipboardEnabled:i,onSetClipboardEnabled:o,audioOn:l,audioReason:u,onSetAudioOn:p,privacyOn:m,privacyReason:h,onSetPrivacyOn:y,hostModes:b,hostModeId:x,hostOriginalModeId:S,onSetHostMode:w,canResizeHost:ee,resolutionError:T,recording:E,recordingSupported:D,onToggleRecording:ne,onScreenshot:re}){let k=(0,M.useMemo)(()=>te(b),[b]),A=(0,M.useMemo)(()=>ie(),[]),j=(0,M.useMemo)(()=>O(b,A,x),[b,A,x]);return(0,H.jsxs)(`div`,{className:`mx-2 mb-1 space-y-0.5 rounded-xl border border-white/10 bg-black/90 p-1`,"data-testid":`remote-desktop-mobile-settings`,children:[(0,H.jsx)(Y,{icon:(0,H.jsx)(c,{className:`size-4`}),label:`Quality monitor`,checked:e,onToggle:t,testId:`remote-desktop-mobile-stats-toggle`}),(0,H.jsx)(Y,{icon:(0,H.jsx)(s,{className:`size-4`}),label:`Show remote cursor`,hint:`Restarts the stream`,checked:n,onToggle:()=>r(!n),testId:`remote-desktop-mobile-cursor-toggle`}),(0,H.jsx)(Y,{icon:(0,H.jsx)(f,{className:`size-4`}),label:`Sync clipboard`,hint:`Off: Ctrl+V pastes the host's own clipboard`,checked:i,onToggle:()=>o(!i),testId:`remote-desktop-mobile-clipboard-toggle`}),(0,H.jsx)(Y,{icon:(0,H.jsx)(d,{className:`size-4`}),label:`Play host audio`,hint:u??void 0,checked:l,disabled:u!==null,onToggle:()=>p(!l),testId:`remote-desktop-mobile-audio-toggle`}),(0,H.jsx)(Y,{icon:(0,H.jsx)(g,{className:`size-4`}),label:`Privacy mode`,hint:h??`Blocks the host's own keyboard and mouse`,checked:m,disabled:h!==null&&!m,onToggle:()=>y(!m),testId:`remote-desktop-mobile-privacy-toggle`}),ee&&k.length>1&&(0,H.jsxs)(`div`,{className:`px-3 pt-1`,children:[(0,H.jsx)(`div`,{className:`pb-1.5 text-[10px] uppercase tracking-wide text-white/40`,children:`Resolution`}),(0,H.jsxs)(`div`,{className:`flex max-h-28 flex-wrap gap-1.5 overflow-y-auto`,children:[S&&S!==x&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>w(S),"data-testid":`remote-desktop-mobile-resolution-original`,className:`min-h-9 rounded-md bg-white/10 px-2.5 py-1 text-[11px] text-white/70 active:bg-white/20`,children:`Original`}),j&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>w(j.id),"data-testid":`remote-desktop-mobile-resolution-fit-local`,className:`min-h-9 rounded-md bg-white/10 px-2.5 py-1 text-[11px] text-white/70 active:bg-white/20`,children:`Fit local`}),k.map(e=>{let t=(x??k.find(e=>e.current)?.id)===e.id;return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>w(e.id),"data-testid":`remote-desktop-mobile-resolution-${e.width}x${e.height}`,className:C(`min-h-9 rounded-md px-2.5 py-1 text-[11px] tabular-nums`,t?`bg-white/25 text-white`:`bg-white/10 text-white/70 active:bg-white/20`),children:[e.width,`×`,e.height]},e.id)})]}),T&&(0,H.jsx)(`div`,{className:`pt-1.5 text-[10px] leading-tight text-red-400`,children:T})]}),(0,H.jsxs)(`button`,{type:`button`,onClick:re,"data-testid":`remote-desktop-mobile-screenshot`,className:`flex min-h-11 w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-xs text-white/80 active:bg-white/10`,children:[(0,H.jsx)(a,{className:`size-4 opacity-80`}),` Save screenshot`]}),D&&(0,H.jsx)(`button`,{type:`button`,onClick:ne,"data-testid":`remote-desktop-mobile-record`,className:`flex min-h-11 w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-xs text-white/80 active:bg-white/10`,children:E?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(_,{className:`size-4 text-red-500`}),` Stop recording`]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(v,{className:`size-4 opacity-80`}),` Start recording`]})})]})}function X({onClose:e}){let t=(0,M.useRef)(null),n=(0,M.useRef)(null),[r,i]=(0,M.useState)(`mouse`),[a,o]=(0,M.useState)(!1),[s,c]=(0,M.useState)(!1),u=re(),{connState:d,errorMessage:f,decoderStatus:m,decoderErrorMessage:h,sendMessage:g,reconnect:_,getTotalBytes:v,getFrameCount:y,quality:C,setQuality:te,showCursor:E,setShowCursor:O,audioOn:ie,setAudioOn:ae,getAudioTracks:oe,privacyOn:N,privacyError:P,setPrivacyOn:F,hostModeId:I,hostOriginalModeId:se,resolutionError:ce,setHostMode:L,pendingHostClipboard:R,clearHostClipboard:le,sendClipboard:z,requestHostClipboard:B}=k(n,{displayId:u.displayId}),ue=x(e=>e.remoteDesktopStatsVisible),de=x(e=>e.toggleRemoteDesktopStatsVisible),V=x(e=>e.remoteDesktopClipboardSync),U=x(e=>e.setRemoteDesktopClipboardSync),W=x(e=>e.remoteDesktopQuality),G=d===`streaming`,{transform:K,virtualCursor:q,resetZoom:J}=fe({containerRef:t,canvasRef:n,mode:r,sendMessage:g,enabled:G}),[Y,X]=(0,M.useState)(!1),_e=(0,M.useCallback)(e=>{X(!0),z(e,!0)},[z]),{caps:Z}=ee(!1),Q=ne(n,oe),{inputRef:ve,show:ye}=pe(g,G,V?_e:void 0),$=w(!0)?.keyboardInset??0,be=(0,M.useCallback)(()=>i(e=>e===`mouse`?`touch`:`mouse`),[]),xe=(0,M.useCallback)(()=>{ye(),o(!0)},[ye]),Se=m===`unsupported`?h:d===`error`?f:d===`closed`?`Disconnected`:d===`connecting`?`Connecting…`:null,Ce={transform:`translate(${K.panX}px, ${K.panY}px) scale(${K.scale})`},we=`${(q?.xFrac??.5)*100}%`,Te=`${(q?.yFrac??.5)*100}%`;if(q&&t.current&&n.current?.width&&n.current.height){let e=t.current.getBoundingClientRect(),r=D({left:0,top:0,width:e.width,height:e.height},n.current.width,n.current.height);we=`${r.left+q.xFrac*r.width}px`,Te=`${r.top+q.yFrac*r.height}px`}return(0,H.jsxs)(`div`,{className:`relative h-full w-full bg-black`,"data-testid":`remote-desktop-mobile-view`,"data-conn-state":d,children:[(0,H.jsxs)(`div`,{ref:t,className:`absolute inset-x-0 top-0 flex items-center justify-center overflow-hidden`,style:{touchAction:`none`,bottom:$},"data-testid":`remote-desktop-mobile-stage-container`,children:[(0,H.jsxs)(`div`,{className:`relative flex h-full w-full items-center justify-center`,style:Ce,children:[(0,H.jsx)(`canvas`,{ref:n,"data-testid":`remote-desktop-canvas`,className:`block h-full w-full min-h-0 min-w-0 object-contain outline-none`}),r===`mouse`&&q&&G&&(0,H.jsx)(`div`,{className:`pointer-events-none absolute rounded-full border-2 border-white bg-primary shadow-[0_0_0_1px_rgba(0,0,0,0.6)]`,style:{left:we,top:Te,width:14,height:14,transform:`translate(-50%, -50%) scale(${1/K.scale})`},"data-testid":`remote-desktop-virtual-cursor`})]}),Se&&(0,H.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-3 bg-black/70 text-sm text-white`,children:[(0,H.jsx)(l,{className:`size-6 opacity-70`}),(0,H.jsx)(`span`,{className:`max-w-sm px-4 text-center`,children:Se}),(d===`error`||d===`closed`)&&m!==`unsupported`&&(0,H.jsxs)(`button`,{onClick:_,className:`flex items-center gap-1.5 rounded-md bg-white/10 px-3 py-1.5 hover:bg-white/20`,children:[(0,H.jsx)(p,{className:`size-3.5`}),` Reconnect`]})]}),(0,H.jsx)(`input`,{ref:ve,type:`text`,autoComplete:`off`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,className:`absolute size-px opacity-0`,"aria-hidden":`true`,tabIndex:-1,onBlur:()=>o(!1),"data-testid":`remote-desktop-virtual-keyboard-input`})]}),(0,H.jsxs)(`div`,{className:`absolute inset-x-0 bottom-0`,style:$>0?{transform:`translateY(-${$}px)`}:void 0,"data-testid":`remote-desktop-mobile-bottom-bar`,children:[(0,H.jsx)(j,{pendingText:R,onDismiss:le,missingToolAction:Y&&Z&&!Z.clipboard.available?Z.clipboard.action:null,onDismissMissingTool:()=>X(!1),positionClassName:`mx-2 mb-1 max-w-[calc(100%-1rem)]`}),s&&(0,H.jsx)(ge,{statsVisible:ue,onToggleStats:de,showCursor:E,onSetShowCursor:O,clipboardEnabled:V,onSetClipboardEnabled:U,audioOn:ie,audioReason:Z&&!Z.audio.available?Z.audio.reason:null,onSetAudioOn:ae,privacyOn:N,privacyReason:P??(Z&&!Z.privacy.available?Z.privacy.reason:null),hostModes:Z?.resolutions?.modes??[],hostModeId:I,hostOriginalModeId:se,onSetHostMode:L,canResizeHost:Z?.inputReady??!1,resolutionError:ce,onSetPrivacyOn:F,recording:Q.recording,recordingSupported:Q.supported,onToggleRecording:Q.toggle,onScreenshot:()=>void T(n.current)}),a&&(0,H.jsx)(he,{sendMessage:g,onCopyCombo:V?B:void 0}),(0,H.jsx)(me,{displayLabel:u.displays.length>1?u.current?.label??null:null,onNextDisplay:u.next,qualityLabel:b(W),onNextQuality:()=>te(S(W)),mode:r,onToggleMode:be,onOpenKeyboard:xe,onResetZoom:J,settingsOpen:s,onToggleSettings:()=>c(e=>!e),onClose:e})]}),(0,H.jsx)(A,{canvasRef:n,getFrameCount:y,getTotalBytes:v,positionClassName:`left-1 top-[calc(env(safe-area-inset-top,0px)+2.75rem)]`})]})}export{X as default};
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-BHh12_0v.js";import{En as r,Gr as i,Gt as a,Jr as o,Mn as s,Nt as c,On as l,Qt as u,Ur as d,W as f,or as p,pr as m,ti as h,ut as g,xr as _,z as v,zt as y}from"./icons-CO_II6D-.js";import"./api-client-c8YOpTlT.js";import{b,t as x,v as S}from"./settings-store-DXmQug0m.js";import"./vendor-mermaid-eg2XWIjK.js";import{n as C}from"./utils-btZ8C8-R.js";import"./panel-store-BUQ-CPsd.js";import"./window-store-B4cbZ5rr.js";import{t as w}from"./use-visual-viewport-C307OVeV.js";import"./ws-auth-B_y5rMfZ.js";import{z as ee}from"./index-CvUGUp7d.js";import"./run-in-terminal-SU9cwoZ4.js";import{a as T,c as te,d as E,f as D,i as ne,n as re,o as O,p as k,r as A,s as ie,t as j}from"./remote-desktop-clipboard-notice-CvPPtrRq.js";var M=e(t(),1);function ae(e,t,n=10,r=300){let i=Math.hypot(t.x-e.x,t.y-e.y),a=t.t-e.t;return i<=n&&a<=r}function oe(e,t,n=15){return Math.abs(t-e)>n?`pinch`:`scroll`}function N(e,t){return Math.hypot(t.x-e.x,t.y-e.y)}function P(e,t){return{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}function F(e,t,n){return Math.min(Math.max(e,t),n)}function I(e,t,n){return[{type:`pointer`,xFrac:e,yFrac:t,button:n,down:!0},{type:`pointer`,xFrac:e,yFrac:t,button:n,down:!1}]}function se(e,t,n){return{start:{x:e,y:t,t:performance.now()},last:{x:e,y:t},moved:!1,rect:n}}function ce(e,t,n,r,i,a){let o=Math.hypot(t-e.start.x,n-e.start.y);if(r===`touch`){if(!e.moved&&o>10){e.moved=!0;let r=E(e.start.x,e.start.y,e.rect,i);return e.last={x:t,y:n},{message:{type:`pointer`,xFrac:r.xFrac,yFrac:r.yFrac,button:`left`,down:!0}}}if(e.last={x:t,y:n},!e.moved)return{};let r=E(t,n,e.rect,i);return{message:{type:`pointer`,xFrac:r.xFrac,yFrac:r.yFrac,button:null,down:null}}}let s=(t-e.last.x)/i.scale,c=(n-e.last.y)/i.scale;return o>10&&(e.moved=!0),e.last={x:t,y:n},{cursor:{xFrac:F(a.xFrac+s/e.rect.width,0,1),yFrac:F(a.yFrac+c/e.rect.height,0,1)},sendCursorMove:!0}}function L(e,t,n,r,i,a){let o={x:t,y:n,t:performance.now()},s=ae(e.start,o,10,300);if(r===`touch`){let r=E(t,n,e.rect,i);return!e.moved&&s?I(r.xFrac,r.yFrac,`left`):e.moved?[{type:`pointer`,xFrac:r.xFrac,yFrac:r.yFrac,button:`left`,down:!1}]:[]}return!e.moved&&s?I(a.xFrac,a.yFrac,`left`):[]}function R(e,t,n){let r=P(e,t);return{startDistance:N(e,t),startMid:r,lastMid:r,startScale:n,startTime:performance.now(),gesture:null}}function le(e,t,n,r){let i=N(t,n),a=P(t,n);if(e.gesture===null){let t=Math.abs(i-e.startDistance),n=N(e.startMid,a);if(t>15)e.gesture=oe(e.startDistance,i,15);else if(n>15)e.gesture=`scroll`;else return e.lastMid=a,{}}let o;if(e.gesture===`pinch`)o={transform:{scale:F(e.startScale*(i/e.startDistance),1,4),panX:r.panX,panY:r.panY}};else if(r.scale>1.01){let t=a.x-e.lastMid.x,n=a.y-e.lastMid.y;o={transform:{scale:r.scale,panX:r.panX+t,panY:r.panY+n}}}else o={wheelDeltaPx:a.y-e.lastMid.y};return e.lastMid=a,o}function z(e,t,n){if(e.gesture===null&&performance.now()-e.startTime<=300){let r=E(e.lastMid.x,e.lastMid.y,t,n);return I(r.xFrac,r.yFrac,`right`)}return[]}var B={scale:1,panX:0,panY:0},ue=40,de=120;function fe({containerRef:e,canvasRef:t,mode:n,sendMessage:r,enabled:i}){let[a,o]=(0,M.useState)(B),[s,c]=(0,M.useState)({xFrac:.5,yFrac:.5}),l=(0,M.useRef)(a),u=(0,M.useRef)(s),d=(0,M.useRef)(n);d.current=n;let f=(0,M.useRef)({transform:null,cursor:null,sendCursorMove:!1,wheelPx:0}),p=(0,M.useRef)(0),m=(0,M.useCallback)(()=>{p.current=0;let e=f.current;e.transform&&=(l.current=e.transform,o(e.transform),null),e.cursor&&(u.current=e.cursor,c(e.cursor),e.sendCursorMove&&r({type:`pointer`,xFrac:e.cursor.xFrac,yFrac:e.cursor.yFrac,button:null,down:null}),e.cursor=null,e.sendCursorMove=!1),e.wheelPx!==0&&(r({type:`wheel`,dy:-(e.wheelPx/ue)*de}),e.wheelPx=0)},[r]),h=(0,M.useCallback)(()=>{p.current||=requestAnimationFrame(m)},[m]),g=(0,M.useCallback)(()=>{l.current=B,o(B)},[]);return(0,M.useEffect)(()=>{let n=e.current;if(!n||!i)return;let a=null,o=null,s=e=>e.forEach(r),c=()=>{let e=n.getBoundingClientRect(),r=t.current;return!r||!r.width||!r.height?e:D(e,r.width,r.height)},m=e=>{e.preventDefault(),e.stopPropagation();let t=c();if(e.touches.length===1){o=null;let n=e.touches[0];a=se(n.clientX,n.clientY,t)}else if(e.touches.length===2){a=null;let[t,n]=[e.touches[0],e.touches[1]];o=R({x:t.clientX,y:t.clientY},{x:n.clientX,y:n.clientY},l.current.scale)}else a=null,o=null},g=e=>{if(e.preventDefault(),e.stopPropagation(),a&&e.touches.length===1){let t=e.touches[0],n=ce(a,t.clientX,t.clientY,d.current,l.current,u.current);n.message&&r(n.message),n.cursor&&(u.current=n.cursor,f.current.cursor=n.cursor,f.current.sendCursorMove=!!n.sendCursorMove,h());return}if(o&&e.touches.length===2){let[t,n]=[e.touches[0],e.touches[1]],r=le(o,{x:t.clientX,y:t.clientY},{x:n.clientX,y:n.clientY},l.current);r.transform&&(l.current=r.transform,f.current.transform=r.transform,h()),r.wheelDeltaPx&&(f.current.wheelPx+=r.wheelDeltaPx,h())}},_=e=>{e.preventDefault(),e.stopPropagation();let t=e.changedTouches[0];if(a){let e=t?t.clientX:a.last.x,n=t?t.clientY:a.last.y;s(L(a,e,n,d.current,l.current,u.current)),a=null}o&&=(s(z(o,c(),l.current)),null)},v=e=>{e.stopPropagation(),a?.moved&&d.current===`touch`&&s(L(a,a.last.x,a.last.y,`touch`,l.current,u.current)),a=null,o=null};return n.addEventListener(`touchstart`,m,{passive:!1}),n.addEventListener(`touchmove`,g,{passive:!1}),n.addEventListener(`touchend`,_,{passive:!1}),n.addEventListener(`touchcancel`,v,{passive:!1}),()=>{p.current&&cancelAnimationFrame(p.current),n.removeEventListener(`touchstart`,m),n.removeEventListener(`touchmove`,g),n.removeEventListener(`touchend`,_),n.removeEventListener(`touchcancel`,v)}},[e,t,i,r,h]),{transform:a,virtualCursor:n===`mouse`?s:null,resetZoom:g}}function V(e,t,n){let r=e=>{n({type:`key`,code:e,down:!0}),n({type:`key`,code:e,down:!1})};switch(e){case`insertText`:return t&&n({type:`text`,text:t}),!0;case`insertLineBreak`:case`insertParagraph`:return r(`Enter`),!0;case`deleteContentBackward`:return r(`Backspace`),!0;case`deleteContentForward`:return r(`Delete`),!0;default:return!1}}function pe(e,t,n){let r=(0,M.useRef)(null);return(0,M.useEffect)(()=>{let i=r.current;if(!i||!t)return;let a=()=>e({type:`releaseAll`}),o=e=>e.code!==``&&e.key!==`Unidentified`,s=t=>{o(t)&&(t.preventDefault(),e({type:`key`,code:t.code,down:!0}))},c=t=>{o(t)&&(t.preventDefault(),e({type:`key`,code:t.code,down:!1}))},l=t=>{V(t.inputType,t.data,e)&&t.preventDefault()},u=t=>{t.data&&e({type:`text`,text:t.data}),i.value=``},d=e=>{let t=e.clipboardData?.getData(`text/plain`);!t||!n||(e.preventDefault(),n(t))},f=()=>a(),p=()=>{document.hidden&&a()};return i.addEventListener(`keydown`,s),i.addEventListener(`keyup`,c),i.addEventListener(`beforeinput`,l),i.addEventListener(`compositionend`,u),i.addEventListener(`paste`,d),i.addEventListener(`blur`,f),document.addEventListener(`visibilitychange`,p),()=>{i.removeEventListener(`keydown`,s),i.removeEventListener(`keyup`,c),i.removeEventListener(`beforeinput`,l),i.removeEventListener(`compositionend`,u),i.removeEventListener(`paste`,d),i.removeEventListener(`blur`,f),document.removeEventListener(`visibilitychange`,p),a()}},[t,e,n]),{inputRef:r,show:(0,M.useCallback)(()=>r.current?.focus(),[])}}var H=n();function U({onClick:e,label:t,active:n,children:r}){return(0,H.jsxs)(`button`,{type:`button`,onClick:e,"aria-label":t,className:C(`flex min-h-11 min-w-11 flex-1 flex-col items-center justify-center gap-0.5 rounded-lg py-1.5 text-[10px]`,`text-white/80 active:bg-white/10 transition-colors`,n&&`bg-white/15 text-white`),children:[r,(0,H.jsx)(`span`,{children:t})]})}function me({displayLabel:e,onNextDisplay:t,qualityLabel:n,onNextQuality:a,mode:c,onToggleMode:l,onOpenKeyboard:d,onResetZoom:f,settingsOpen:p,onToggleSettings:g,onClose:_}){return(0,H.jsxs)(`div`,{className:`flex shrink-0 items-stretch gap-1 border-t border-white/10 bg-black/90 px-2 pb-[max(0.375rem,env(safe-area-inset-bottom))] pt-1.5`,"data-testid":`remote-desktop-mobile-toolbar`,children:[(0,H.jsx)(U,{onClick:l,label:c===`mouse`?`Mouse`:`Touch`,active:!0,children:c===`mouse`?(0,H.jsx)(s,{className:`size-5`}):(0,H.jsx)(y,{className:`size-5`})}),(0,H.jsx)(U,{onClick:d,label:`Keyboard`,children:(0,H.jsx)(u,{className:`size-5`})}),(0,H.jsx)(U,{onClick:f,label:`Reset zoom`,children:(0,H.jsx)(h,{className:`size-5`})}),e!==null&&(0,H.jsx)(U,{onClick:t,label:e.length>10?`${e.slice(0,9)}…`:e,children:(0,H.jsx)(r,{className:`size-5`})}),(0,H.jsx)(U,{onClick:a,label:n,children:(0,H.jsx)(i,{className:`size-5`})}),(0,H.jsx)(U,{onClick:g,label:`More`,active:p,children:(0,H.jsx)(m,{className:`size-5`})}),(0,H.jsx)(U,{onClick:_,label:`Close`,children:(0,H.jsx)(o,{className:`size-5`})})]})}function W(e){return(e.includes(`ControlLeft`)||e.includes(`MetaLeft`))&&(e.includes(`KeyC`)||e.includes(`KeyX`))}var G=[{label:`Ctrl`,code:`ControlLeft`},{label:`Alt`,code:`AltLeft`},{label:`Shift`,code:`ShiftLeft`},{label:`Win`,code:`MetaLeft`}],K=[{label:`Esc`,code:`Escape`},{label:`Tab`,code:`Tab`},{label:`←`,code:`ArrowLeft`},{label:`↑`,code:`ArrowUp`},{label:`↓`,code:`ArrowDown`},{label:`→`,code:`ArrowRight`}],q=[{label:`Ctrl+C`,codes:[`ControlLeft`,`KeyC`]},{label:`Ctrl+V`,codes:[`ControlLeft`,`KeyV`]},{label:`Ctrl+Z`,codes:[`ControlLeft`,`KeyZ`]},{label:`Ctrl+A`,codes:[`ControlLeft`,`KeyA`]},{label:`Alt+Tab`,codes:[`AltLeft`,`Tab`]},{label:`Ctrl+Alt+Del`,codes:[`ControlLeft`,`AltLeft`,`Delete`]}];function J({onClick:e,active:t,className:n,children:r}){return(0,H.jsx)(`button`,{type:`button`,onClick:e,className:C(`min-h-11 min-w-11 shrink-0 whitespace-nowrap rounded-md px-2.5 text-xs font-medium text-white/80`,`active:bg-white/15 transition-colors`,t&&`bg-primary text-primary-foreground`,n),children:r})}function he({sendMessage:e,onCopyCombo:t}){let[n,r]=(0,M.useState)(new Set),i=(0,M.useRef)(n);i.current=n,(0,M.useEffect)(()=>()=>{i.current.forEach(t=>e({type:`key`,code:t,down:!1}))},[e]);let a=(0,M.useCallback)(t=>{r(n=>{let r=n.has(t);e({type:`key`,code:t,down:!r});let i=new Set(n);return r?i.delete(t):i.add(t),i})},[e]),o=(0,M.useCallback)(t=>{e({type:`key`,code:t,down:!0}),e({type:`key`,code:t,down:!1})},[e]),s=(0,M.useCallback)(n=>{n.forEach(t=>e({type:`key`,code:t,down:!0})),[...n].reverse().forEach(t=>e({type:`key`,code:t,down:!1})),W(n)&&t?.()},[e,t]);return(0,H.jsxs)(`div`,{className:`flex shrink-0 gap-1 overflow-x-auto border-t border-white/10 bg-black/90 px-2 py-1.5`,"data-testid":`remote-desktop-mobile-key-bar`,children:[G.map(e=>(0,H.jsx)(J,{onClick:()=>a(e.code),active:n.has(e.code),children:e.label},e.code)),(0,H.jsx)(`div`,{className:`mx-0.5 w-px shrink-0 bg-white/10`}),K.map(e=>(0,H.jsx)(J,{onClick:()=>o(e.code),children:e.label},e.code)),(0,H.jsx)(`div`,{className:`mx-0.5 w-px shrink-0 bg-white/10`}),q.map(e=>(0,H.jsx)(J,{onClick:()=>s(e.codes),children:e.label},e.label))]})}function Y({icon:e,label:t,hint:n,checked:r,onToggle:i,testId:a,disabled:o}){return(0,H.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":r,disabled:o,onClick:i,"data-testid":a,className:`flex min-h-11 w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-white/80 active:bg-white/10 disabled:opacity-50`,children:[(0,H.jsx)(`span`,{className:`shrink-0 opacity-80`,children:e}),(0,H.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`block truncate text-xs`,children:t}),n&&(0,H.jsx)(`span`,{className:`block truncate text-[10px] text-white/45`,children:n})]}),(0,H.jsx)(`span`,{className:C(`relative h-5 w-9 shrink-0 rounded-full transition-colors`,r?`bg-primary`:`bg-white/20`),children:(0,H.jsx)(`span`,{className:C(`absolute top-0.5 size-4 rounded-full bg-white transition-all`,r?`left-[1.125rem]`:`left-0.5`)})})]})}function ge({statsVisible:e,onToggleStats:t,showCursor:n,onSetShowCursor:r,clipboardEnabled:i,onSetClipboardEnabled:o,audioOn:l,audioReason:u,onSetAudioOn:p,privacyOn:m,privacyReason:h,onSetPrivacyOn:y,hostModes:b,hostModeId:x,hostOriginalModeId:S,onSetHostMode:w,canResizeHost:ee,resolutionError:T,recording:E,recordingSupported:D,onToggleRecording:ne,onScreenshot:re}){let k=(0,M.useMemo)(()=>te(b),[b]),A=(0,M.useMemo)(()=>ie(),[]),j=(0,M.useMemo)(()=>O(b,A,x),[b,A,x]);return(0,H.jsxs)(`div`,{className:`mx-2 mb-1 space-y-0.5 rounded-xl border border-white/10 bg-black/90 p-1`,"data-testid":`remote-desktop-mobile-settings`,children:[(0,H.jsx)(Y,{icon:(0,H.jsx)(c,{className:`size-4`}),label:`Quality monitor`,checked:e,onToggle:t,testId:`remote-desktop-mobile-stats-toggle`}),(0,H.jsx)(Y,{icon:(0,H.jsx)(s,{className:`size-4`}),label:`Show remote cursor`,hint:`Restarts the stream`,checked:n,onToggle:()=>r(!n),testId:`remote-desktop-mobile-cursor-toggle`}),(0,H.jsx)(Y,{icon:(0,H.jsx)(f,{className:`size-4`}),label:`Sync clipboard`,hint:`Off: Ctrl+V pastes the host's own clipboard`,checked:i,onToggle:()=>o(!i),testId:`remote-desktop-mobile-clipboard-toggle`}),(0,H.jsx)(Y,{icon:(0,H.jsx)(d,{className:`size-4`}),label:`Play host audio`,hint:u??void 0,checked:l,disabled:u!==null,onToggle:()=>p(!l),testId:`remote-desktop-mobile-audio-toggle`}),(0,H.jsx)(Y,{icon:(0,H.jsx)(g,{className:`size-4`}),label:`Privacy mode`,hint:h??`Blocks the host's own keyboard and mouse`,checked:m,disabled:h!==null&&!m,onToggle:()=>y(!m),testId:`remote-desktop-mobile-privacy-toggle`}),ee&&k.length>1&&(0,H.jsxs)(`div`,{className:`px-3 pt-1`,children:[(0,H.jsx)(`div`,{className:`pb-1.5 text-[10px] uppercase tracking-wide text-white/40`,children:`Resolution`}),(0,H.jsxs)(`div`,{className:`flex max-h-28 flex-wrap gap-1.5 overflow-y-auto`,children:[S&&S!==x&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>w(S),"data-testid":`remote-desktop-mobile-resolution-original`,className:`min-h-9 rounded-md bg-white/10 px-2.5 py-1 text-[11px] text-white/70 active:bg-white/20`,children:`Original`}),j&&(0,H.jsx)(`button`,{type:`button`,onClick:()=>w(j.id),"data-testid":`remote-desktop-mobile-resolution-fit-local`,className:`min-h-9 rounded-md bg-white/10 px-2.5 py-1 text-[11px] text-white/70 active:bg-white/20`,children:`Fit local`}),k.map(e=>{let t=(x??k.find(e=>e.current)?.id)===e.id;return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>w(e.id),"data-testid":`remote-desktop-mobile-resolution-${e.width}x${e.height}`,className:C(`min-h-9 rounded-md px-2.5 py-1 text-[11px] tabular-nums`,t?`bg-white/25 text-white`:`bg-white/10 text-white/70 active:bg-white/20`),children:[e.width,`×`,e.height]},e.id)})]}),T&&(0,H.jsx)(`div`,{className:`pt-1.5 text-[10px] leading-tight text-red-400`,children:T})]}),(0,H.jsxs)(`button`,{type:`button`,onClick:re,"data-testid":`remote-desktop-mobile-screenshot`,className:`flex min-h-11 w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-xs text-white/80 active:bg-white/10`,children:[(0,H.jsx)(a,{className:`size-4 opacity-80`}),` Save screenshot`]}),D&&(0,H.jsx)(`button`,{type:`button`,onClick:ne,"data-testid":`remote-desktop-mobile-record`,className:`flex min-h-11 w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-xs text-white/80 active:bg-white/10`,children:E?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(_,{className:`size-4 text-red-500`}),` Stop recording`]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(v,{className:`size-4 opacity-80`}),` Start recording`]})})]})}function X({onClose:e}){let t=(0,M.useRef)(null),n=(0,M.useRef)(null),[r,i]=(0,M.useState)(`mouse`),[a,o]=(0,M.useState)(!1),[s,c]=(0,M.useState)(!1),u=re(),{connState:d,errorMessage:f,decoderStatus:m,decoderErrorMessage:h,sendMessage:g,reconnect:_,getTotalBytes:v,getFrameCount:y,quality:C,setQuality:te,showCursor:E,setShowCursor:O,audioOn:ie,setAudioOn:ae,getAudioTracks:oe,privacyOn:N,privacyError:P,setPrivacyOn:F,hostModeId:I,hostOriginalModeId:se,resolutionError:ce,setHostMode:L,pendingHostClipboard:R,clearHostClipboard:le,sendClipboard:z,requestHostClipboard:B}=k(n,{displayId:u.displayId}),ue=x(e=>e.remoteDesktopStatsVisible),de=x(e=>e.toggleRemoteDesktopStatsVisible),V=x(e=>e.remoteDesktopClipboardSync),U=x(e=>e.setRemoteDesktopClipboardSync),W=x(e=>e.remoteDesktopQuality),G=d===`streaming`,{transform:K,virtualCursor:q,resetZoom:J}=fe({containerRef:t,canvasRef:n,mode:r,sendMessage:g,enabled:G}),[Y,X]=(0,M.useState)(!1),_e=(0,M.useCallback)(e=>{X(!0),z(e,!0)},[z]),{caps:Z}=ee(!1),Q=ne(n,oe),{inputRef:ve,show:ye}=pe(g,G,V?_e:void 0),$=w(!0)?.keyboardInset??0,be=(0,M.useCallback)(()=>i(e=>e===`mouse`?`touch`:`mouse`),[]),xe=(0,M.useCallback)(()=>{ye(),o(!0)},[ye]),Se=m===`unsupported`?h:d===`error`?f:d===`closed`?`Disconnected`:d===`connecting`?`Connecting…`:null,Ce={transform:`translate(${K.panX}px, ${K.panY}px) scale(${K.scale})`},we=`${(q?.xFrac??.5)*100}%`,Te=`${(q?.yFrac??.5)*100}%`;if(q&&t.current&&n.current?.width&&n.current.height){let e=t.current.getBoundingClientRect(),r=D({left:0,top:0,width:e.width,height:e.height},n.current.width,n.current.height);we=`${r.left+q.xFrac*r.width}px`,Te=`${r.top+q.yFrac*r.height}px`}return(0,H.jsxs)(`div`,{className:`relative h-full w-full bg-black`,"data-testid":`remote-desktop-mobile-view`,"data-conn-state":d,children:[(0,H.jsxs)(`div`,{ref:t,className:`absolute inset-x-0 top-0 flex items-center justify-center overflow-hidden`,style:{touchAction:`none`,bottom:$},"data-testid":`remote-desktop-mobile-stage-container`,children:[(0,H.jsxs)(`div`,{className:`relative flex h-full w-full items-center justify-center`,style:Ce,children:[(0,H.jsx)(`canvas`,{ref:n,"data-testid":`remote-desktop-canvas`,className:`block h-full w-full min-h-0 min-w-0 object-contain outline-none`}),r===`mouse`&&q&&G&&(0,H.jsx)(`div`,{className:`pointer-events-none absolute rounded-full border-2 border-white bg-primary shadow-[0_0_0_1px_rgba(0,0,0,0.6)]`,style:{left:we,top:Te,width:14,height:14,transform:`translate(-50%, -50%) scale(${1/K.scale})`},"data-testid":`remote-desktop-virtual-cursor`})]}),Se&&(0,H.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-3 bg-black/70 text-sm text-white`,children:[(0,H.jsx)(l,{className:`size-6 opacity-70`}),(0,H.jsx)(`span`,{className:`max-w-sm px-4 text-center`,children:Se}),(d===`error`||d===`closed`)&&m!==`unsupported`&&(0,H.jsxs)(`button`,{onClick:_,className:`flex items-center gap-1.5 rounded-md bg-white/10 px-3 py-1.5 hover:bg-white/20`,children:[(0,H.jsx)(p,{className:`size-3.5`}),` Reconnect`]})]}),(0,H.jsx)(`input`,{ref:ve,type:`text`,autoComplete:`off`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,className:`absolute size-px opacity-0`,"aria-hidden":`true`,tabIndex:-1,onBlur:()=>o(!1),"data-testid":`remote-desktop-virtual-keyboard-input`})]}),(0,H.jsxs)(`div`,{className:`absolute inset-x-0 bottom-0`,style:$>0?{transform:`translateY(-${$}px)`}:void 0,"data-testid":`remote-desktop-mobile-bottom-bar`,children:[(0,H.jsx)(j,{pendingText:R,onDismiss:le,missingToolAction:Y&&Z&&!Z.clipboard.available?Z.clipboard.action:null,onDismissMissingTool:()=>X(!1),positionClassName:`mx-2 mb-1 max-w-[calc(100%-1rem)]`}),s&&(0,H.jsx)(ge,{statsVisible:ue,onToggleStats:de,showCursor:E,onSetShowCursor:O,clipboardEnabled:V,onSetClipboardEnabled:U,audioOn:ie,audioReason:Z&&!Z.audio.available?Z.audio.reason:null,onSetAudioOn:ae,privacyOn:N,privacyReason:P??(Z&&!Z.privacy.available?Z.privacy.reason:null),hostModes:Z?.resolutions?.modes??[],hostModeId:I,hostOriginalModeId:se,onSetHostMode:L,canResizeHost:Z?.inputReady??!1,resolutionError:ce,onSetPrivacyOn:F,recording:Q.recording,recordingSupported:Q.supported,onToggleRecording:Q.toggle,onScreenshot:()=>void T(n.current)}),a&&(0,H.jsx)(he,{sendMessage:g,onCopyCombo:V?B:void 0}),(0,H.jsx)(me,{displayLabel:u.displays.length>1?u.current?.label??null:null,onNextDisplay:u.next,qualityLabel:b(W),onNextQuality:()=>te(S(W)),mode:r,onToggleMode:be,onOpenKeyboard:xe,onResetZoom:J,settingsOpen:s,onToggleSettings:()=>c(e=>!e),onClose:e})]}),(0,H.jsx)(A,{canvasRef:n,getFrameCount:y,getTotalBytes:v,positionClassName:`left-1 top-[calc(env(safe-area-inset-top,0px)+2.75rem)]`})]})}export{X as default};
@@ -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,Dn as i,E as a,ct as o,hr as s,un as c,z as l}from"./icons-C9ZwXgel.js";import{t as u}from"./settings-store-DXmQug0m.js";import{z as d}from"./index-BVKT5UCu.js";import{r as f}from"./run-in-terminal-SU9cwoZ4.js";var p=e(t(),1),m=n();function h({onCancel:e,children:t}){let n=u(e=>e.remoteDesktopWarningDismissed),r=u(e=>e.setRemoteDesktopWarningDismissed),[a,o]=(0,p.useState)(!1),[c,l]=(0,p.useState)(!1);if(n||a)return(0,m.jsx)(m.Fragment,{children:t});let d=()=>{c&&r(!0),o(!0)};return(0,m.jsx)(`div`,{className:`flex h-full w-full items-center justify-center overflow-y-auto bg-black p-4 text-white`,"data-testid":`remote-desktop-warning-gate`,children:(0,m.jsxs)(`div`,{className:`flex w-full max-w-sm flex-col gap-4 rounded-xl border border-white/10 bg-white/5 p-5`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,m.jsx)(i,{className:`size-5 shrink-0 text-primary`}),(0,m.jsx)(`h2`,{className:`text-base font-semibold`,children:`Remote Desktop`}),(0,m.jsx)(`span`,{className:`ml-auto rounded-full bg-amber-500/20 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-amber-300`,children:`Beta`})]}),(0,m.jsxs)(`ul`,{className:`flex flex-col gap-2 text-sm text-white/80`,children:[(0,m.jsxs)(`li`,{className:`flex gap-2`,children:[(0,m.jsx)(s,{className:`mt-0.5 size-4 shrink-0 text-amber-300`}),(0,m.jsxs)(`span`,{children:[`This streams the host's `,(0,m.jsx)(`strong`,{children:`whole screen`}),` and lets you `,(0,m.jsx)(`strong`,{children:`move its mouse and type`}),` as if you were sitting at it. Anything you do here happens on the real desktop.`]})]}),(0,m.jsxs)(`li`,{className:`flex gap-2`,children:[(0,m.jsx)(s,{className:`mt-0.5 size-4 shrink-0 text-amber-300`}),(0,m.jsx)(`span`,{children:`Anyone signed in to this PPM can do the same. Avoid opening it over a public share link you don't fully trust; a private network (Tailscale, LAN) is safer.`})]}),(0,m.jsxs)(`li`,{className:`flex gap-2`,children:[(0,m.jsx)(s,{className:`mt-0.5 size-4 shrink-0 text-amber-300`}),(0,m.jsx)(`span`,{children:`Still beta: the host must be unlocked with an active session, UAC prompts stay hidden, and a person at the host will fight you for the cursor.`})]})]}),(0,m.jsxs)(`label`,{className:`flex min-h-11 cursor-pointer items-center gap-2 text-sm text-white/70`,children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked),className:`size-4 accent-primary`,"data-testid":`remote-desktop-warning-dont-show`}),`Don't show this again`]}),(0,m.jsxs)(`div`,{className:`flex gap-2`,children:[(0,m.jsx)(`button`,{type:`button`,onClick:e,className:`min-h-11 flex-1 rounded-md bg-white/10 px-3 text-sm hover:bg-white/20`,"data-testid":`remote-desktop-warning-cancel`,children:`Cancel`}),(0,m.jsx)(`button`,{type:`button`,onClick:d,className:`min-h-11 flex-1 rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground hover:bg-primary/90`,"data-testid":`remote-desktop-warning-continue`,children:`Continue`})]})]})})}function g({onCancel:e,children:t}){let[n,r]=(0,p.useState)(!1),{caps:a,failed:o,runHostAction:s}=d(!n);if(n||a?.videoReady&&a.inputReady)return(0,m.jsx)(m.Fragment,{children:t});let l=a?.requirements.filter(e=>!e.ok)??[],u=!!a?.videoReady&&!a.inputReady,h=t=>{f(t),e()};return(0,m.jsx)(`div`,{className:`flex h-full w-full items-center justify-center overflow-y-auto bg-black p-4 text-white`,"data-testid":`remote-desktop-readiness-gate`,children:(0,m.jsxs)(`div`,{className:`flex w-full max-w-sm flex-col gap-4 rounded-xl border border-white/10 bg-white/5 p-5`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,m.jsx)(i,{className:`size-5 shrink-0 text-primary`}),(0,m.jsx)(`h2`,{className:`text-base font-semibold`,children:`This host needs a few things`})]}),!a&&!o&&(0,m.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-white/70`,children:[(0,m.jsx)(c,{className:`size-4 animate-spin`}),` Checking the host…`]}),o&&(0,m.jsx)(`p`,{className:`text-sm text-red-300`,children:`Could not reach the host's remote-desktop service.`}),(0,m.jsx)(`ul`,{className:`flex flex-col gap-3`,children:a?.requirements.map(e=>(0,m.jsx)(_,{req:e,onHostAction:s,onTerminal:h},e.id))}),l.length>0&&(0,m.jsx)(`p`,{className:`text-xs text-white/50`,children:`Re-checking every few seconds — this updates by itself once fixed.`}),(0,m.jsxs)(`div`,{className:`flex gap-2`,children:[(0,m.jsx)(`button`,{type:`button`,onClick:e,className:`min-h-11 flex-1 rounded-md bg-white/10 px-3 text-sm hover:bg-white/20`,children:`Cancel`}),(0,m.jsx)(`button`,{type:`button`,disabled:!a?.videoReady,onClick:()=>r(!0),className:`min-h-11 flex-1 rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-40`,"data-testid":`remote-desktop-readiness-continue`,children:u?`Continue (view only)`:`Continue`})]})]})})}function _({req:e,...t}){return(0,m.jsxs)(`li`,{className:`flex gap-2`,"data-testid":`remote-desktop-requirement-${e.id}`,"data-ok":e.ok,children:[e.ok?(0,m.jsx)(a,{className:`mt-0.5 size-4 shrink-0 text-emerald-400`}):(0,m.jsx)(l,{className:`mt-0.5 size-4 shrink-0 text-amber-300`}),(0,m.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,m.jsxs)(`div`,{className:`text-sm font-medium`,children:[e.title,!e.ok&&(0,m.jsx)(`span`,{className:`ml-2 text-xs font-normal text-white/50`,children:e.gates===`video`?`required`:`for mouse & keyboard`})]}),!e.ok&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`p`,{className:`text-sm text-white/70`,children:e.detail}),(0,m.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.actions.map(n=>(0,m.jsx)(v,{action:n,reqId:e.id,...t},n.label))})]})]})]})}function v({action:e,reqId:t,onHostAction:n,onTerminal:i}){let a=`inline-flex min-h-11 items-center gap-1.5 rounded-md bg-white/10 px-3 text-sm hover:bg-white/20`;return e.kind===`terminal`?(0,m.jsxs)(`button`,{type:`button`,className:a,onClick:()=>i(e.command),title:e.command,children:[(0,m.jsx)(r,{className:`size-4`}),` `,e.label]}):e.kind===`link`?(0,m.jsxs)(`a`,{className:a,href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,m.jsx)(o,{className:`size-4`}),` `,e.label]}):(0,m.jsx)(`button`,{type:`button`,className:a,onClick:()=>void n(t,e.action),children:e.label})}export{h as n,g as t};
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,Dn as i,E as a,ct as o,hr as s,un as c,z as l}from"./icons-CO_II6D-.js";import{t as u}from"./settings-store-DXmQug0m.js";import{z as d}from"./index-CvUGUp7d.js";import{r as f}from"./run-in-terminal-SU9cwoZ4.js";var p=e(t(),1),m=n();function h({onCancel:e,children:t}){let n=u(e=>e.remoteDesktopWarningDismissed),r=u(e=>e.setRemoteDesktopWarningDismissed),[a,o]=(0,p.useState)(!1),[c,l]=(0,p.useState)(!1);if(n||a)return(0,m.jsx)(m.Fragment,{children:t});let d=()=>{c&&r(!0),o(!0)};return(0,m.jsx)(`div`,{className:`flex h-full w-full items-center justify-center overflow-y-auto bg-black p-4 text-white`,"data-testid":`remote-desktop-warning-gate`,children:(0,m.jsxs)(`div`,{className:`flex w-full max-w-sm flex-col gap-4 rounded-xl border border-white/10 bg-white/5 p-5`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,m.jsx)(i,{className:`size-5 shrink-0 text-primary`}),(0,m.jsx)(`h2`,{className:`text-base font-semibold`,children:`Remote Desktop`}),(0,m.jsx)(`span`,{className:`ml-auto rounded-full bg-amber-500/20 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-amber-300`,children:`Beta`})]}),(0,m.jsxs)(`ul`,{className:`flex flex-col gap-2 text-sm text-white/80`,children:[(0,m.jsxs)(`li`,{className:`flex gap-2`,children:[(0,m.jsx)(s,{className:`mt-0.5 size-4 shrink-0 text-amber-300`}),(0,m.jsxs)(`span`,{children:[`This streams the host's `,(0,m.jsx)(`strong`,{children:`whole screen`}),` and lets you `,(0,m.jsx)(`strong`,{children:`move its mouse and type`}),` as if you were sitting at it. Anything you do here happens on the real desktop.`]})]}),(0,m.jsxs)(`li`,{className:`flex gap-2`,children:[(0,m.jsx)(s,{className:`mt-0.5 size-4 shrink-0 text-amber-300`}),(0,m.jsx)(`span`,{children:`Anyone signed in to this PPM can do the same. Avoid opening it over a public share link you don't fully trust; a private network (Tailscale, LAN) is safer.`})]}),(0,m.jsxs)(`li`,{className:`flex gap-2`,children:[(0,m.jsx)(s,{className:`mt-0.5 size-4 shrink-0 text-amber-300`}),(0,m.jsx)(`span`,{children:`Still beta: the host must be unlocked with an active session, UAC prompts stay hidden, and a person at the host will fight you for the cursor.`})]})]}),(0,m.jsxs)(`label`,{className:`flex min-h-11 cursor-pointer items-center gap-2 text-sm text-white/70`,children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked),className:`size-4 accent-primary`,"data-testid":`remote-desktop-warning-dont-show`}),`Don't show this again`]}),(0,m.jsxs)(`div`,{className:`flex gap-2`,children:[(0,m.jsx)(`button`,{type:`button`,onClick:e,className:`min-h-11 flex-1 rounded-md bg-white/10 px-3 text-sm hover:bg-white/20`,"data-testid":`remote-desktop-warning-cancel`,children:`Cancel`}),(0,m.jsx)(`button`,{type:`button`,onClick:d,className:`min-h-11 flex-1 rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground hover:bg-primary/90`,"data-testid":`remote-desktop-warning-continue`,children:`Continue`})]})]})})}function g({onCancel:e,children:t}){let[n,r]=(0,p.useState)(!1),{caps:a,failed:o,runHostAction:s}=d(!n);if(n||a?.videoReady&&a.inputReady)return(0,m.jsx)(m.Fragment,{children:t});let l=a?.requirements.filter(e=>!e.ok)??[],u=!!a?.videoReady&&!a.inputReady,h=t=>{f(t),e()};return(0,m.jsx)(`div`,{className:`flex h-full w-full items-center justify-center overflow-y-auto bg-black p-4 text-white`,"data-testid":`remote-desktop-readiness-gate`,children:(0,m.jsxs)(`div`,{className:`flex w-full max-w-sm flex-col gap-4 rounded-xl border border-white/10 bg-white/5 p-5`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,m.jsx)(i,{className:`size-5 shrink-0 text-primary`}),(0,m.jsx)(`h2`,{className:`text-base font-semibold`,children:`This host needs a few things`})]}),!a&&!o&&(0,m.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-white/70`,children:[(0,m.jsx)(c,{className:`size-4 animate-spin`}),` Checking the host…`]}),o&&(0,m.jsx)(`p`,{className:`text-sm text-red-300`,children:`Could not reach the host's remote-desktop service.`}),(0,m.jsx)(`ul`,{className:`flex flex-col gap-3`,children:a?.requirements.map(e=>(0,m.jsx)(_,{req:e,onHostAction:s,onTerminal:h},e.id))}),l.length>0&&(0,m.jsx)(`p`,{className:`text-xs text-white/50`,children:`Re-checking every few seconds — this updates by itself once fixed.`}),(0,m.jsxs)(`div`,{className:`flex gap-2`,children:[(0,m.jsx)(`button`,{type:`button`,onClick:e,className:`min-h-11 flex-1 rounded-md bg-white/10 px-3 text-sm hover:bg-white/20`,children:`Cancel`}),(0,m.jsx)(`button`,{type:`button`,disabled:!a?.videoReady,onClick:()=>r(!0),className:`min-h-11 flex-1 rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-40`,"data-testid":`remote-desktop-readiness-continue`,children:u?`Continue (view only)`:`Continue`})]})]})})}function _({req:e,...t}){return(0,m.jsxs)(`li`,{className:`flex gap-2`,"data-testid":`remote-desktop-requirement-${e.id}`,"data-ok":e.ok,children:[e.ok?(0,m.jsx)(a,{className:`mt-0.5 size-4 shrink-0 text-emerald-400`}):(0,m.jsx)(l,{className:`mt-0.5 size-4 shrink-0 text-amber-300`}),(0,m.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,m.jsxs)(`div`,{className:`text-sm font-medium`,children:[e.title,!e.ok&&(0,m.jsx)(`span`,{className:`ml-2 text-xs font-normal text-white/50`,children:e.gates===`video`?`required`:`for mouse & keyboard`})]}),!e.ok&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`p`,{className:`text-sm text-white/70`,children:e.detail}),(0,m.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.actions.map(n=>(0,m.jsx)(v,{action:n,reqId:e.id,...t},n.label))})]})]})]})}function v({action:e,reqId:t,onHostAction:n,onTerminal:i}){let a=`inline-flex min-h-11 items-center gap-1.5 rounded-md bg-white/10 px-3 text-sm hover:bg-white/20`;return e.kind===`terminal`?(0,m.jsxs)(`button`,{type:`button`,className:a,onClick:()=>i(e.command),title:e.command,children:[(0,m.jsx)(r,{className:`size-4`}),` `,e.label]}):e.kind===`link`?(0,m.jsxs)(`a`,{className:a,href:e.url,target:`_blank`,rel:`noreferrer`,children:[(0,m.jsx)(o,{className:`size-4`}),` `,e.label]}):(0,m.jsx)(`button`,{type:`button`,className:a,onClick:()=>void n(t,e.action),children:e.label})}export{h as n,g as t};
@@ -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-BHh12_0v.js";import{En as r,Gt as i,Nt as a,On as o,Tn as s,Zn as c,or as l,pr as u,ut as d,xr as f,z as p}from"./icons-C9ZwXgel.js";import"./api-client-c8YOpTlT.js";import{_ as m,a as h,c as g,d as _,f as v,g as y,i as b,l as x,m as S,n as C,o as w,p as T,r as ee,s as E,t as D,u as O}from"./settings-store-DXmQug0m.js";import"./vendor-mermaid-eg2XWIjK.js";import{n as te}from"./utils-btZ8C8-R.js";import"./portal-container-context-NFSuymMu.js";import"./panel-store-BUQ-CPsd.js";import{t as ne}from"./window-store-B4cbZ5rr.js";import{t as re}from"./button-CBehaXpV.js";import{a as ie,i as k,n as A,o as j,r as M,t as N}from"./dialog-CaShS4f5.js";import"./ws-auth-B_y5rMfZ.js";import{an as P,cn as F,dn as I,fn as L,in as R,ln as z,mn as B,on as V,pn as H,rn as ae,sn as oe,un as U,z as se}from"./index-BVKT5UCu.js";import"./run-in-terminal-SU9cwoZ4.js";import{n as W,t as G}from"./remote-desktop-readiness-gate-B2mXZ9vo.js";import{a as K,c as ce,h as q,i as le,l as ue,m as J,n as de,o as Y,p as fe,r as pe,s as me,t as he,u as X}from"./remote-desktop-clipboard-notice-DgeuoZ4n.js";var Z=e(t(),1);function ge(e,t,n,r){let i=(0,Z.useCallback)((n,r,i,a)=>{let o=e.current;if(!o)return;let{xFrac:s,yFrac:c}=X(n,r,o.getBoundingClientRect());t({type:`pointer`,xFrac:s,yFrac:c,button:i,down:a})},[e,t]);(0,Z.useEffect)(()=>{let a=e.current;if(!a||!n)return;let o=e=>e===0?`left`:e===2?`right`:null,s=()=>t({type:`releaseAll`}),c=null,l=0,u=()=>{l=0,c&&=(i(c.x,c.y,null,null),null)},d=()=>{l&&=(cancelAnimationFrame(l),0),c&&=(i(c.x,c.y,null,null),null)},f=e=>{e.preventDefault(),a.setPointerCapture(e.pointerId),a.focus(),d(),i(e.clientX,e.clientY,o(e.button),!0)},p=e=>{c={x:e.clientX,y:e.clientY},l||=requestAnimationFrame(u)},m=e=>{d(),i(e.clientX,e.clientY,o(e.button),!1)},h=e=>e.preventDefault(),g=!1,_=e=>{if(r&&q(e)){g=e.shiftKey;return}e.preventDefault(),t({type:`key`,code:e.code,down:!0}),r&&J(e)&&r.onCopyCombo()},v=e=>{r&&q(e)||(e.preventDefault(),t({type:`key`,code:e.code,down:!1}))},y=e=>{e.preventDefault();let t=e.clipboardData?.getData(`text/plain`);t&&r?.onPasteText(t,g),g=!1},b=()=>{document.hidden&&s()};return a.tabIndex=0,a.addEventListener(`pointerdown`,f),a.addEventListener(`pointermove`,p),a.addEventListener(`pointerup`,m),a.addEventListener(`contextmenu`,h),a.addEventListener(`keydown`,_),a.addEventListener(`keyup`,v),a.addEventListener(`paste`,y),a.addEventListener(`blur`,s),document.addEventListener(`visibilitychange`,b),()=>{l&&cancelAnimationFrame(l),a.removeEventListener(`pointerdown`,f),a.removeEventListener(`pointermove`,p),a.removeEventListener(`pointerup`,m),a.removeEventListener(`contextmenu`,h),a.removeEventListener(`keydown`,_),a.removeEventListener(`keyup`,v),a.removeEventListener(`blur`,s),document.removeEventListener(`visibilitychange`,b)}},[e,n,i,t,r])}var Q={h264_nvenc:`NVIDIA NVENC`,h264_qsv:`Intel QuickSync`,h264_vaapi:`VAAPI (GPU)`,h264_amf:`AMD AMF`,h264_videotoolbox:`Apple VideoToolbox`,libx264:`Software (x264)`};function _e(e){return Object.hasOwn(Q,e)?Q[e]:e}var $=n(),ve=`flex size-7 shrink-0 items-center justify-center rounded bg-black/40 text-white/70 outline-none hover:bg-black/60 hover:text-white data-[state=open]:bg-black/70 data-[state=open]:text-white`;function ye({displays:e,currentDisplayId:t,onSelectDisplay:n,quality:o,qualityChoice:s,onSetQuality:c,onOpenCustomQuality:l,codecs:h,codec:g,onSetCodec:_,hostModes:v,hostModeId:x,hostOriginalModeId:S,onSetHostMode:C,canResizeHost:w,resolutionError:T,viewStyle:E,customScale:D,onSetViewStyle:O,onSetCustomScale:ne,showCursor:re,onSetShowCursor:ie,audioOn:k,audioReason:A,onSetAudioOn:j,privacyOn:M,privacyReason:N,privacyCanBlank:se,onSetPrivacyOn:W,recording:G,recordingElapsedSec:K,recordingSupported:q,onToggleRecording:le,onScreenshot:J,clipboardEnabled:de,onSetClipboardEnabled:fe,statsVisible:pe,onToggleStats:he}){let X=(0,Z.useMemo)(()=>ce(v),[v]),ge=(0,Z.useMemo)(()=>me(),[]),Q=(0,Z.useMemo)(()=>Y(v,ge,x),[v,ge,x]),ye=!!(S&&S!==x),Se=t??e.find(e=>e.primary)?.id??e[0]?.id??``;return(0,$.jsxs)(`div`,{className:`absolute right-1 top-1 z-40 flex items-center gap-1`,"data-testid":`remote-desktop-toolbar`,children:[e.length>1&&(0,$.jsxs)(ae,{children:[(0,$.jsx)(B,{className:ve,"aria-label":`Display`,title:`Display`,children:(0,$.jsx)(r,{className:`size-3.5`})}),(0,$.jsxs)(P,{align:`end`,className:`w-64`,children:[(0,$.jsx)(oe,{children:`Display`}),(0,$.jsx)(F,{value:Se,onValueChange:n,children:e.map(e=>(0,$.jsxs)(z,{value:e.id,"data-testid":`remote-desktop-display-${e.id}`,children:[e.label,e.primary?` (main)`:``,` · `,e.width,`×`,e.height]},e.id))})]})]}),(0,$.jsxs)(ae,{children:[(0,$.jsx)(B,{className:ve,"aria-label":`Display settings`,title:`Display settings`,"data-testid":`remote-desktop-settings-trigger`,children:(0,$.jsx)(u,{className:`size-3.5`})}),(0,$.jsxs)(P,{align:`end`,className:`w-64`,children:[(0,$.jsx)(oe,{children:`Scale`}),(0,$.jsx)(F,{value:E,onValueChange:e=>O(e),children:b.map(e=>(0,$.jsx)(z,{value:e,"data-testid":`remote-desktop-view-style-${e}`,children:ee[e]},e))}),E===`custom`&&(0,$.jsx)(xe,{scale:D,onSet:ne}),(0,$.jsx)(U,{}),(0,$.jsxs)(I,{children:[(0,$.jsxs)(H,{"data-testid":`remote-desktop-quality-submenu`,children:[`Image quality`,o.held<1&&(0,$.jsxs)(`span`,{className:`ml-1.5 text-[10px] opacity-60`,"data-testid":`remote-desktop-quality-held`,children:[Math.round(o.held*100),`% — link limited`]})]}),(0,$.jsx)(L,{className:`w-56`,children:(0,$.jsxs)(F,{value:s,onValueChange:e=>e===`custom`?l():c(e),children:[m.map(e=>(0,$.jsx)(z,{value:e,"data-testid":`remote-desktop-quality-${e}`,children:y[e].label},e)),(0,$.jsx)(z,{value:`custom`,"data-testid":`remote-desktop-quality-custom`,children:`Custom…`})]})})]}),h.length>1&&(0,$.jsxs)(I,{children:[(0,$.jsx)(H,{"data-testid":`remote-desktop-codec-submenu`,children:`Codec`}),(0,$.jsx)(L,{className:`w-56`,children:(0,$.jsxs)(F,{value:g??`auto`,onValueChange:e=>_(e===`auto`?null:e),children:[(0,$.jsxs)(z,{value:`auto`,children:[`Auto · `,_e(h[0])]}),h.map(e=>(0,$.jsx)(z,{value:e,"data-testid":`remote-desktop-codec-${e}`,children:_e(e)},e))]})})]}),w&&X.length>1&&(0,$.jsxs)(I,{children:[(0,$.jsx)(H,{"data-testid":`remote-desktop-resolution-submenu`,children:`Resolution`}),(0,$.jsxs)(L,{className:`max-h-80 w-56 overflow-y-auto`,children:[ye&&S&&(0,$.jsx)(V,{onSelect:()=>C(S),"data-testid":`remote-desktop-resolution-original`,children:`Original`}),Q&&(0,$.jsxs)(V,{onSelect:()=>C(Q.id),"data-testid":`remote-desktop-resolution-fit-local`,children:[`Fit local `,Q.width,`×`,Q.height]}),(ye||Q)&&(0,$.jsx)(U,{}),(0,$.jsx)(F,{value:x??X.find(e=>e.current)?.id??``,onValueChange:C,children:X.map(e=>(0,$.jsxs)(z,{value:e.id,"data-testid":`remote-desktop-resolution-${e.width}x${e.height}`,children:[ue(e),e.preferred&&(0,$.jsx)(`span`,{className:`ml-1.5 text-[10px] opacity-60`,children:`native`})]},e.id))}),T&&(0,$.jsx)(`div`,{className:`px-2 py-1.5 text-[10px] leading-tight text-destructive`,children:T})]})]}),(0,$.jsx)(U,{}),(0,$.jsx)(R,{checked:re,onCheckedChange:ie,"data-testid":`remote-desktop-show-cursor`,children:`Show remote cursor`}),(0,$.jsx)(R,{checked:de,onCheckedChange:fe,"data-testid":`remote-desktop-clipboard-toggle`,children:`Sync clipboard`}),(0,$.jsx)(R,{checked:k,disabled:A!==null,onCheckedChange:j,"data-testid":`remote-desktop-audio-toggle`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{children:`Play host audio`}),A&&(0,$.jsx)(`span`,{className:`text-[10px] leading-tight text-muted-foreground`,children:A})]})}),(0,$.jsx)(U,{}),(0,$.jsx)(R,{checked:M,disabled:N!==null&&!M,onCheckedChange:W,"data-testid":`remote-desktop-privacy-toggle`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{children:`Privacy mode`}),(0,$.jsx)(`span`,{className:`text-[10px] leading-tight text-muted-foreground`,children:N??(se?`Blocks the host's keyboard and mouse, and blanks its screen`:`Blocks the host's keyboard and mouse (its screen stays on)`)})]})}),(0,$.jsx)(U,{}),(0,$.jsxs)(V,{onSelect:J,"data-testid":`remote-desktop-screenshot`,children:[(0,$.jsx)(i,{className:`size-3.5`}),` Save screenshot`]}),q&&(0,$.jsx)(V,{onSelect:le,"data-testid":`remote-desktop-record`,children:G?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(f,{className:`size-3.5 text-red-500`}),` Stop recording · `,be(K)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(p,{className:`size-3.5`}),` Start recording`]})})]})]}),M&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>W(!1),title:`Privacy mode is on — click to release the host`,"aria-label":`Turn privacy mode off`,className:`flex h-7 shrink-0 items-center gap-1 rounded bg-amber-500/85 px-1.5 text-[10px] font-medium text-black hover:bg-amber-400`,"data-testid":`remote-desktop-privacy-indicator`,children:[(0,$.jsx)(d,{className:`size-3`}),` Host locked`]}),G&&(0,$.jsxs)(`button`,{type:`button`,onClick:le,title:`Stop recording`,"aria-label":`Stop recording`,className:`flex h-7 shrink-0 items-center gap-1 rounded bg-red-600/80 px-1.5 text-[10px] font-medium tabular-nums text-white hover:bg-red-600`,"data-testid":`remote-desktop-recording-indicator`,children:[(0,$.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-white`}),be(K)]}),(0,$.jsx)(`button`,{type:`button`,onClick:he,"aria-label":`Toggle stats overlay`,"aria-pressed":pe,title:`Quality monitor`,className:te(ve,pe&&`bg-primary/70 text-primary-foreground hover:bg-primary/80`),children:(0,$.jsx)(a,{className:`size-3.5`})})]})}function be(e){let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=String(e%60).padStart(2,`0`);return t>0?`${t}:${String(n).padStart(2,`0`)}:${r}`:`${n}:${r}`}function xe({scale:e,onSet:t}){let[n,r]=(0,Z.useState)(null),i=(0,Z.useRef)(null),a=E(Math.round(w(e)*100)),o=n??a,l=g(o);(0,Z.useEffect)(()=>()=>{i.current&&clearTimeout(i.current)},[]);let u=e=>{r(e),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{r(null),t(e/100)},300)},d=e=>t=>{t.preventDefault(),u(E(o+e*1))},f=`flex size-6 shrink-0 items-center justify-center rounded hover:bg-accent disabled:opacity-40`;return(0,$.jsx)(`div`,{className:`px-2 py-1.5`,"data-testid":`remote-desktop-zoom-row`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,className:f,onClick:d(-1),disabled:o<=5,"aria-label":`Decrease`,children:(0,$.jsx)(s,{className:`size-3.5`})}),(0,$.jsxs)(`span`,{className:`relative flex-1 py-2.5`,children:[(0,$.jsx)(`input`,{type:`range`,min:0,max:1,step:1/(C-5),value:l,"aria-label":`Scale`,"aria-valuetext":`${o}%`,"data-testid":`remote-desktop-zoom-slider`,onKeyDown:e=>e.stopPropagation(),onChange:e=>u(x(O(Number(e.target.value)))),className:`h-1 w-full cursor-pointer appearance-none rounded bg-accent accent-primary`}),(0,$.jsxs)(`span`,{className:`pointer-events-none absolute top-0 -translate-x-1/2 rounded bg-primary px-1.5 text-[10px] leading-4 tabular-nums text-primary-foreground`,style:{left:`${l*100}%`},"data-testid":`remote-desktop-zoom-value`,children:[o,`%`]})]}),(0,$.jsx)(`button`,{type:`button`,className:f,onClick:d(1),disabled:o>=C,"aria-label":`Increase`,children:(0,$.jsx)(c,{className:`size-3.5`})})]})})}var Se=400;function Ce({open:e,onOpenChange:t,percent:n,fps:r,more:i,onSetMore:a,onCommit:o,frameSize:s}){let[c,l]=(0,Z.useState)(n),[u,d]=(0,Z.useState)(r),f=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{e&&(l(n),d(r))},[e,n,r]),(0,Z.useEffect)(()=>()=>{f.current&&clearTimeout(f.current)},[]);let p=i?_:100,m=(e,t)=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>o(e,t),Se)},h=e=>{let t=T(e,i);l(t),m(t,u)},g=e=>{let t=v(e);d(t),m(c,t)},y=e=>{a(e);let t=T(c,e);t!==c&&(l(t),m(t,u))},b=S(c,s.width,s.height);return(0,$.jsx)(N,{open:e,onOpenChange:t,children:(0,$.jsxs)(A,{className:`sm:max-w-md`,"data-testid":`remote-desktop-custom-quality-dialog`,children:[(0,$.jsxs)(ie,{children:[(0,$.jsx)(j,{children:`Custom image quality`}),(0,$.jsx)(M,{children:s.width>0?`${c}% of the base rate for ${s.width}×${s.height} — about ${(b/1e3).toFixed(1)} Mbit/s`:`Waiting for the first frame`})]}),(0,$.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`input`,{type:`range`,min:10,max:p,step:1,value:Math.min(c,p),onChange:e=>h(Number(e.target.value)),"aria-label":`Bitrate`,"data-testid":`remote-desktop-custom-bitrate`,className:`h-1 min-w-0 flex-1 cursor-pointer appearance-none rounded bg-accent accent-primary`}),(0,$.jsxs)(`span`,{className:`w-14 text-right text-xs tabular-nums`,children:[c,`%`]}),(0,$.jsx)(`span`,{className:`w-14 text-xs text-muted-foreground`,children:`Bitrate`}),(0,$.jsxs)(`label`,{className:`flex shrink-0 items-center gap-1.5 text-xs`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>y(e.target.checked),"data-testid":`remote-desktop-custom-more`,className:`size-3.5 accent-primary`}),`More`]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`input`,{type:`range`,min:5,max:120,step:1,value:u,onChange:e=>g(Number(e.target.value)),"aria-label":`FPS`,"data-testid":`remote-desktop-custom-fps`,className:`h-1 min-w-0 flex-1 cursor-pointer appearance-none rounded bg-accent accent-primary`}),(0,$.jsx)(`span`,{className:`w-14 text-right text-xs tabular-nums`,children:u}),(0,$.jsx)(`span`,{className:`w-14 text-xs text-muted-foreground`,children:`FPS`}),(0,$.jsx)(`span`,{className:`w-[4.25rem] shrink-0`,"aria-hidden":!0})]})]}),(0,$.jsx)(k,{children:(0,$.jsx)(re,{onClick:()=>t(!1),children:`Close`})})]})})}function we({id:e}){let t=ne(e=>e.close),n=(0,Z.useCallback)(()=>t(e),[t,e]);return(0,$.jsx)(W,{onCancel:n,children:(0,$.jsx)(G,{onCancel:n,children:(0,$.jsx)(Te,{})})})}function Te(){let e=(0,Z.useRef)(null),t=de(),{connState:n,errorMessage:r,decoderStatus:i,decoderErrorMessage:a,sendMessage:s,reconnect:c,getFrameCount:u,getTotalBytes:d,frameSize:f,quality:p,setQuality:m,setCustomQuality:g,showCursor:_,setShowCursor:v,codec:y,setCodec:b,audioOn:x,setAudioOn:S,getAudioTracks:C,privacyOn:w,privacyError:T,setPrivacyOn:ee,hostModeId:E,hostOriginalModeId:O,resolutionError:ne,setHostMode:re,pendingHostClipboard:ie,clearHostClipboard:k,sendClipboard:A,requestHostClipboard:j}=fe(e,{displayId:t.displayId}),M=D(e=>e.remoteDesktopStatsVisible),N=D(e=>e.toggleRemoteDesktopStatsVisible),P=D(e=>e.remoteDesktopViewStyle),F=D(e=>e.remoteDesktopCustomScale),I=D(e=>e.setRemoteDesktopViewStyle),L=D(e=>e.setRemoteDesktopCustomScale),R=D(e=>e.remoteDesktopClipboardSync),z=D(e=>e.remoteDesktopQuality),B=D(e=>e.remoteDesktopCustomQualityPercent),V=D(e=>e.remoteDesktopCustomFps),H=D(e=>e.remoteDesktopCustomQualityMore),ae=D(e=>e.setRemoteDesktopCustomQualityMore),[oe,U]=(0,Z.useState)(!1),W=D(e=>e.setRemoteDesktopClipboardSync),{caps:G}=se(!1),[ce,q]=(0,Z.useState)(!1),ue=(0,Z.useMemo)(()=>R?{onPasteText:(e,t)=>{q(!0),A(e,!0,t)},onCopyCombo:j}:void 0,[R,A,j]);ge(e,s,n===`streaming`,ue);let J=le(e,C),Y=h(P,F,f),me=i===`unsupported`?a:n===`error`?r:n===`closed`?`Disconnected`:n===`connecting`?`Connecting…`:null;return(0,$.jsxs)(`div`,{className:`relative flex h-full w-full items-center justify-center bg-black`,"data-testid":`remote-desktop-window`,"data-conn-state":n,children:[(0,$.jsx)(`div`,{className:te(`flex h-full w-full`,Y?`overflow-auto`:`overflow-hidden`),children:(0,$.jsx)(`canvas`,{ref:e,"data-testid":`remote-desktop-canvas`,"data-view-style":P,className:te(`m-auto outline-none`,!Y&&`max-h-full max-w-full`),style:Y?{width:Y.width,height:Y.height}:void 0})}),(0,$.jsx)(pe,{canvasRef:e,getFrameCount:u,getTotalBytes:d}),(0,$.jsx)(ye,{displays:t.displays,currentDisplayId:t.current?.id,onSelectDisplay:t.select,quality:p,qualityChoice:z,onSetQuality:m,onOpenCustomQuality:()=>U(!0),codecs:G?.encoders??[],codec:y,onSetCodec:b,hostModes:G?.resolutions?.modes??[],hostModeId:E,hostOriginalModeId:O,onSetHostMode:re,canResizeHost:G?.inputReady??!1,resolutionError:ne,viewStyle:P,customScale:F,onSetViewStyle:I,onSetCustomScale:L,showCursor:_,onSetShowCursor:v,audioOn:x,audioReason:G&&!G.audio.available?G.audio.reason:null,onSetAudioOn:S,privacyOn:w,privacyReason:T??(G&&!G.privacy.available?G.privacy.reason:null),privacyCanBlank:G?.privacy?.canBlank??!1,onSetPrivacyOn:ee,recording:J.recording,recordingElapsedSec:J.elapsedSec,recordingSupported:J.supported,onToggleRecording:J.toggle,onScreenshot:()=>void K(e.current),clipboardEnabled:R,onSetClipboardEnabled:W,statsVisible:M,onToggleStats:N}),(0,$.jsx)(he,{pendingText:ie,onDismiss:k,missingToolAction:ce&&G&&!G.clipboard.available?G.clipboard.action:null,onDismissMissingTool:()=>q(!1)}),(0,$.jsx)(Ce,{open:oe,onOpenChange:U,percent:B,fps:V,more:H,onSetMore:ae,onCommit:g,frameSize:f}),me&&(0,$.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-3 bg-black/70 text-sm text-white`,children:[(0,$.jsx)(o,{className:`size-6 opacity-70`}),(0,$.jsx)(`span`,{className:`max-w-sm text-center px-4`,children:me}),(n===`error`||n===`closed`)&&i!==`unsupported`&&(0,$.jsxs)(`button`,{onClick:c,className:`flex items-center gap-1.5 rounded-md bg-white/10 px-3 py-1.5 hover:bg-white/20`,children:[(0,$.jsx)(l,{className:`size-3.5`}),` Reconnect`]})]})]})}export{we as default};
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-BHh12_0v.js";import{En as r,Gt as i,Nt as a,On as o,Tn as s,Zn as c,or as l,pr as u,ut as d,xr as f,z as p}from"./icons-CO_II6D-.js";import"./api-client-c8YOpTlT.js";import{_ as m,a as h,c as g,d as _,f as v,g as y,i as b,l as x,m as S,n as C,o as w,p as T,r as ee,s as E,t as D,u as O}from"./settings-store-DXmQug0m.js";import"./vendor-mermaid-eg2XWIjK.js";import{n as te}from"./utils-btZ8C8-R.js";import"./portal-container-context-NFSuymMu.js";import"./panel-store-BUQ-CPsd.js";import{t as ne}from"./window-store-B4cbZ5rr.js";import{t as re}from"./button-CBehaXpV.js";import{a as ie,i as k,n as A,o as j,r as M,t as N}from"./dialog-tzBRkGeW.js";import"./ws-auth-B_y5rMfZ.js";import{an as P,cn as F,dn as I,fn as L,in as R,ln as z,mn as B,on as V,pn as H,rn as ae,sn as oe,un as U,z as se}from"./index-CvUGUp7d.js";import"./run-in-terminal-SU9cwoZ4.js";import{n as W,t as G}from"./remote-desktop-readiness-gate-CUmaeiX9.js";import{a as K,c as ce,h as q,i as le,l as ue,m as J,n as de,o as Y,p as fe,r as pe,s as me,t as he,u as X}from"./remote-desktop-clipboard-notice-CvPPtrRq.js";var Z=e(t(),1);function ge(e,t,n,r){let i=(0,Z.useCallback)((n,r,i,a)=>{let o=e.current;if(!o)return;let{xFrac:s,yFrac:c}=X(n,r,o.getBoundingClientRect());t({type:`pointer`,xFrac:s,yFrac:c,button:i,down:a})},[e,t]);(0,Z.useEffect)(()=>{let a=e.current;if(!a||!n)return;let o=e=>e===0?`left`:e===2?`right`:null,s=()=>t({type:`releaseAll`}),c=null,l=0,u=()=>{l=0,c&&=(i(c.x,c.y,null,null),null)},d=()=>{l&&=(cancelAnimationFrame(l),0),c&&=(i(c.x,c.y,null,null),null)},f=e=>{e.preventDefault(),a.setPointerCapture(e.pointerId),a.focus(),d(),i(e.clientX,e.clientY,o(e.button),!0)},p=e=>{c={x:e.clientX,y:e.clientY},l||=requestAnimationFrame(u)},m=e=>{d(),i(e.clientX,e.clientY,o(e.button),!1)},h=e=>e.preventDefault(),g=!1,_=e=>{if(r&&q(e)){g=e.shiftKey;return}e.preventDefault(),t({type:`key`,code:e.code,down:!0}),r&&J(e)&&r.onCopyCombo()},v=e=>{r&&q(e)||(e.preventDefault(),t({type:`key`,code:e.code,down:!1}))},y=e=>{e.preventDefault();let t=e.clipboardData?.getData(`text/plain`);t&&r?.onPasteText(t,g),g=!1},b=()=>{document.hidden&&s()};return a.tabIndex=0,a.addEventListener(`pointerdown`,f),a.addEventListener(`pointermove`,p),a.addEventListener(`pointerup`,m),a.addEventListener(`contextmenu`,h),a.addEventListener(`keydown`,_),a.addEventListener(`keyup`,v),a.addEventListener(`paste`,y),a.addEventListener(`blur`,s),document.addEventListener(`visibilitychange`,b),()=>{l&&cancelAnimationFrame(l),a.removeEventListener(`pointerdown`,f),a.removeEventListener(`pointermove`,p),a.removeEventListener(`pointerup`,m),a.removeEventListener(`contextmenu`,h),a.removeEventListener(`keydown`,_),a.removeEventListener(`keyup`,v),a.removeEventListener(`blur`,s),document.removeEventListener(`visibilitychange`,b)}},[e,n,i,t,r])}var Q={h264_nvenc:`NVIDIA NVENC`,h264_qsv:`Intel QuickSync`,h264_vaapi:`VAAPI (GPU)`,h264_amf:`AMD AMF`,h264_videotoolbox:`Apple VideoToolbox`,libx264:`Software (x264)`};function _e(e){return Object.hasOwn(Q,e)?Q[e]:e}var $=n(),ve=`flex size-7 shrink-0 items-center justify-center rounded bg-black/40 text-white/70 outline-none hover:bg-black/60 hover:text-white data-[state=open]:bg-black/70 data-[state=open]:text-white`;function ye({displays:e,currentDisplayId:t,onSelectDisplay:n,quality:o,qualityChoice:s,onSetQuality:c,onOpenCustomQuality:l,codecs:h,codec:g,onSetCodec:_,hostModes:v,hostModeId:x,hostOriginalModeId:S,onSetHostMode:C,canResizeHost:w,resolutionError:T,viewStyle:E,customScale:D,onSetViewStyle:O,onSetCustomScale:ne,showCursor:re,onSetShowCursor:ie,audioOn:k,audioReason:A,onSetAudioOn:j,privacyOn:M,privacyReason:N,privacyCanBlank:se,onSetPrivacyOn:W,recording:G,recordingElapsedSec:K,recordingSupported:q,onToggleRecording:le,onScreenshot:J,clipboardEnabled:de,onSetClipboardEnabled:fe,statsVisible:pe,onToggleStats:he}){let X=(0,Z.useMemo)(()=>ce(v),[v]),ge=(0,Z.useMemo)(()=>me(),[]),Q=(0,Z.useMemo)(()=>Y(v,ge,x),[v,ge,x]),ye=!!(S&&S!==x),Se=t??e.find(e=>e.primary)?.id??e[0]?.id??``;return(0,$.jsxs)(`div`,{className:`absolute right-1 top-1 z-40 flex items-center gap-1`,"data-testid":`remote-desktop-toolbar`,children:[e.length>1&&(0,$.jsxs)(ae,{children:[(0,$.jsx)(B,{className:ve,"aria-label":`Display`,title:`Display`,children:(0,$.jsx)(r,{className:`size-3.5`})}),(0,$.jsxs)(P,{align:`end`,className:`w-64`,children:[(0,$.jsx)(oe,{children:`Display`}),(0,$.jsx)(F,{value:Se,onValueChange:n,children:e.map(e=>(0,$.jsxs)(z,{value:e.id,"data-testid":`remote-desktop-display-${e.id}`,children:[e.label,e.primary?` (main)`:``,` · `,e.width,`×`,e.height]},e.id))})]})]}),(0,$.jsxs)(ae,{children:[(0,$.jsx)(B,{className:ve,"aria-label":`Display settings`,title:`Display settings`,"data-testid":`remote-desktop-settings-trigger`,children:(0,$.jsx)(u,{className:`size-3.5`})}),(0,$.jsxs)(P,{align:`end`,className:`w-64`,children:[(0,$.jsx)(oe,{children:`Scale`}),(0,$.jsx)(F,{value:E,onValueChange:e=>O(e),children:b.map(e=>(0,$.jsx)(z,{value:e,"data-testid":`remote-desktop-view-style-${e}`,children:ee[e]},e))}),E===`custom`&&(0,$.jsx)(xe,{scale:D,onSet:ne}),(0,$.jsx)(U,{}),(0,$.jsxs)(I,{children:[(0,$.jsxs)(H,{"data-testid":`remote-desktop-quality-submenu`,children:[`Image quality`,o.held<1&&(0,$.jsxs)(`span`,{className:`ml-1.5 text-[10px] opacity-60`,"data-testid":`remote-desktop-quality-held`,children:[Math.round(o.held*100),`% — link limited`]})]}),(0,$.jsx)(L,{className:`w-56`,children:(0,$.jsxs)(F,{value:s,onValueChange:e=>e===`custom`?l():c(e),children:[m.map(e=>(0,$.jsx)(z,{value:e,"data-testid":`remote-desktop-quality-${e}`,children:y[e].label},e)),(0,$.jsx)(z,{value:`custom`,"data-testid":`remote-desktop-quality-custom`,children:`Custom…`})]})})]}),h.length>1&&(0,$.jsxs)(I,{children:[(0,$.jsx)(H,{"data-testid":`remote-desktop-codec-submenu`,children:`Codec`}),(0,$.jsx)(L,{className:`w-56`,children:(0,$.jsxs)(F,{value:g??`auto`,onValueChange:e=>_(e===`auto`?null:e),children:[(0,$.jsxs)(z,{value:`auto`,children:[`Auto · `,_e(h[0])]}),h.map(e=>(0,$.jsx)(z,{value:e,"data-testid":`remote-desktop-codec-${e}`,children:_e(e)},e))]})})]}),w&&X.length>1&&(0,$.jsxs)(I,{children:[(0,$.jsx)(H,{"data-testid":`remote-desktop-resolution-submenu`,children:`Resolution`}),(0,$.jsxs)(L,{className:`max-h-80 w-56 overflow-y-auto`,children:[ye&&S&&(0,$.jsx)(V,{onSelect:()=>C(S),"data-testid":`remote-desktop-resolution-original`,children:`Original`}),Q&&(0,$.jsxs)(V,{onSelect:()=>C(Q.id),"data-testid":`remote-desktop-resolution-fit-local`,children:[`Fit local `,Q.width,`×`,Q.height]}),(ye||Q)&&(0,$.jsx)(U,{}),(0,$.jsx)(F,{value:x??X.find(e=>e.current)?.id??``,onValueChange:C,children:X.map(e=>(0,$.jsxs)(z,{value:e.id,"data-testid":`remote-desktop-resolution-${e.width}x${e.height}`,children:[ue(e),e.preferred&&(0,$.jsx)(`span`,{className:`ml-1.5 text-[10px] opacity-60`,children:`native`})]},e.id))}),T&&(0,$.jsx)(`div`,{className:`px-2 py-1.5 text-[10px] leading-tight text-destructive`,children:T})]})]}),(0,$.jsx)(U,{}),(0,$.jsx)(R,{checked:re,onCheckedChange:ie,"data-testid":`remote-desktop-show-cursor`,children:`Show remote cursor`}),(0,$.jsx)(R,{checked:de,onCheckedChange:fe,"data-testid":`remote-desktop-clipboard-toggle`,children:`Sync clipboard`}),(0,$.jsx)(R,{checked:k,disabled:A!==null,onCheckedChange:j,"data-testid":`remote-desktop-audio-toggle`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{children:`Play host audio`}),A&&(0,$.jsx)(`span`,{className:`text-[10px] leading-tight text-muted-foreground`,children:A})]})}),(0,$.jsx)(U,{}),(0,$.jsx)(R,{checked:M,disabled:N!==null&&!M,onCheckedChange:W,"data-testid":`remote-desktop-privacy-toggle`,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{children:`Privacy mode`}),(0,$.jsx)(`span`,{className:`text-[10px] leading-tight text-muted-foreground`,children:N??(se?`Blocks the host's keyboard and mouse, and blanks its screen`:`Blocks the host's keyboard and mouse (its screen stays on)`)})]})}),(0,$.jsx)(U,{}),(0,$.jsxs)(V,{onSelect:J,"data-testid":`remote-desktop-screenshot`,children:[(0,$.jsx)(i,{className:`size-3.5`}),` Save screenshot`]}),q&&(0,$.jsx)(V,{onSelect:le,"data-testid":`remote-desktop-record`,children:G?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(f,{className:`size-3.5 text-red-500`}),` Stop recording · `,be(K)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(p,{className:`size-3.5`}),` Start recording`]})})]})]}),M&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>W(!1),title:`Privacy mode is on — click to release the host`,"aria-label":`Turn privacy mode off`,className:`flex h-7 shrink-0 items-center gap-1 rounded bg-amber-500/85 px-1.5 text-[10px] font-medium text-black hover:bg-amber-400`,"data-testid":`remote-desktop-privacy-indicator`,children:[(0,$.jsx)(d,{className:`size-3`}),` Host locked`]}),G&&(0,$.jsxs)(`button`,{type:`button`,onClick:le,title:`Stop recording`,"aria-label":`Stop recording`,className:`flex h-7 shrink-0 items-center gap-1 rounded bg-red-600/80 px-1.5 text-[10px] font-medium tabular-nums text-white hover:bg-red-600`,"data-testid":`remote-desktop-recording-indicator`,children:[(0,$.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-white`}),be(K)]}),(0,$.jsx)(`button`,{type:`button`,onClick:he,"aria-label":`Toggle stats overlay`,"aria-pressed":pe,title:`Quality monitor`,className:te(ve,pe&&`bg-primary/70 text-primary-foreground hover:bg-primary/80`),children:(0,$.jsx)(a,{className:`size-3.5`})})]})}function be(e){let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=String(e%60).padStart(2,`0`);return t>0?`${t}:${String(n).padStart(2,`0`)}:${r}`:`${n}:${r}`}function xe({scale:e,onSet:t}){let[n,r]=(0,Z.useState)(null),i=(0,Z.useRef)(null),a=E(Math.round(w(e)*100)),o=n??a,l=g(o);(0,Z.useEffect)(()=>()=>{i.current&&clearTimeout(i.current)},[]);let u=e=>{r(e),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{r(null),t(e/100)},300)},d=e=>t=>{t.preventDefault(),u(E(o+e*1))},f=`flex size-6 shrink-0 items-center justify-center rounded hover:bg-accent disabled:opacity-40`;return(0,$.jsx)(`div`,{className:`px-2 py-1.5`,"data-testid":`remote-desktop-zoom-row`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,className:f,onClick:d(-1),disabled:o<=5,"aria-label":`Decrease`,children:(0,$.jsx)(s,{className:`size-3.5`})}),(0,$.jsxs)(`span`,{className:`relative flex-1 py-2.5`,children:[(0,$.jsx)(`input`,{type:`range`,min:0,max:1,step:1/(C-5),value:l,"aria-label":`Scale`,"aria-valuetext":`${o}%`,"data-testid":`remote-desktop-zoom-slider`,onKeyDown:e=>e.stopPropagation(),onChange:e=>u(x(O(Number(e.target.value)))),className:`h-1 w-full cursor-pointer appearance-none rounded bg-accent accent-primary`}),(0,$.jsxs)(`span`,{className:`pointer-events-none absolute top-0 -translate-x-1/2 rounded bg-primary px-1.5 text-[10px] leading-4 tabular-nums text-primary-foreground`,style:{left:`${l*100}%`},"data-testid":`remote-desktop-zoom-value`,children:[o,`%`]})]}),(0,$.jsx)(`button`,{type:`button`,className:f,onClick:d(1),disabled:o>=C,"aria-label":`Increase`,children:(0,$.jsx)(c,{className:`size-3.5`})})]})})}var Se=400;function Ce({open:e,onOpenChange:t,percent:n,fps:r,more:i,onSetMore:a,onCommit:o,frameSize:s}){let[c,l]=(0,Z.useState)(n),[u,d]=(0,Z.useState)(r),f=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{e&&(l(n),d(r))},[e,n,r]),(0,Z.useEffect)(()=>()=>{f.current&&clearTimeout(f.current)},[]);let p=i?_:100,m=(e,t)=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>o(e,t),Se)},h=e=>{let t=T(e,i);l(t),m(t,u)},g=e=>{let t=v(e);d(t),m(c,t)},y=e=>{a(e);let t=T(c,e);t!==c&&(l(t),m(t,u))},b=S(c,s.width,s.height);return(0,$.jsx)(N,{open:e,onOpenChange:t,children:(0,$.jsxs)(A,{className:`sm:max-w-md`,"data-testid":`remote-desktop-custom-quality-dialog`,children:[(0,$.jsxs)(ie,{children:[(0,$.jsx)(j,{children:`Custom image quality`}),(0,$.jsx)(M,{children:s.width>0?`${c}% of the base rate for ${s.width}×${s.height} — about ${(b/1e3).toFixed(1)} Mbit/s`:`Waiting for the first frame`})]}),(0,$.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`input`,{type:`range`,min:10,max:p,step:1,value:Math.min(c,p),onChange:e=>h(Number(e.target.value)),"aria-label":`Bitrate`,"data-testid":`remote-desktop-custom-bitrate`,className:`h-1 min-w-0 flex-1 cursor-pointer appearance-none rounded bg-accent accent-primary`}),(0,$.jsxs)(`span`,{className:`w-14 text-right text-xs tabular-nums`,children:[c,`%`]}),(0,$.jsx)(`span`,{className:`w-14 text-xs text-muted-foreground`,children:`Bitrate`}),(0,$.jsxs)(`label`,{className:`flex shrink-0 items-center gap-1.5 text-xs`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>y(e.target.checked),"data-testid":`remote-desktop-custom-more`,className:`size-3.5 accent-primary`}),`More`]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`input`,{type:`range`,min:5,max:120,step:1,value:u,onChange:e=>g(Number(e.target.value)),"aria-label":`FPS`,"data-testid":`remote-desktop-custom-fps`,className:`h-1 min-w-0 flex-1 cursor-pointer appearance-none rounded bg-accent accent-primary`}),(0,$.jsx)(`span`,{className:`w-14 text-right text-xs tabular-nums`,children:u}),(0,$.jsx)(`span`,{className:`w-14 text-xs text-muted-foreground`,children:`FPS`}),(0,$.jsx)(`span`,{className:`w-[4.25rem] shrink-0`,"aria-hidden":!0})]})]}),(0,$.jsx)(k,{children:(0,$.jsx)(re,{onClick:()=>t(!1),children:`Close`})})]})})}function we({id:e}){let t=ne(e=>e.close),n=(0,Z.useCallback)(()=>t(e),[t,e]);return(0,$.jsx)(W,{onCancel:n,children:(0,$.jsx)(G,{onCancel:n,children:(0,$.jsx)(Te,{})})})}function Te(){let e=(0,Z.useRef)(null),t=de(),{connState:n,errorMessage:r,decoderStatus:i,decoderErrorMessage:a,sendMessage:s,reconnect:c,getFrameCount:u,getTotalBytes:d,frameSize:f,quality:p,setQuality:m,setCustomQuality:g,showCursor:_,setShowCursor:v,codec:y,setCodec:b,audioOn:x,setAudioOn:S,getAudioTracks:C,privacyOn:w,privacyError:T,setPrivacyOn:ee,hostModeId:E,hostOriginalModeId:O,resolutionError:ne,setHostMode:re,pendingHostClipboard:ie,clearHostClipboard:k,sendClipboard:A,requestHostClipboard:j}=fe(e,{displayId:t.displayId}),M=D(e=>e.remoteDesktopStatsVisible),N=D(e=>e.toggleRemoteDesktopStatsVisible),P=D(e=>e.remoteDesktopViewStyle),F=D(e=>e.remoteDesktopCustomScale),I=D(e=>e.setRemoteDesktopViewStyle),L=D(e=>e.setRemoteDesktopCustomScale),R=D(e=>e.remoteDesktopClipboardSync),z=D(e=>e.remoteDesktopQuality),B=D(e=>e.remoteDesktopCustomQualityPercent),V=D(e=>e.remoteDesktopCustomFps),H=D(e=>e.remoteDesktopCustomQualityMore),ae=D(e=>e.setRemoteDesktopCustomQualityMore),[oe,U]=(0,Z.useState)(!1),W=D(e=>e.setRemoteDesktopClipboardSync),{caps:G}=se(!1),[ce,q]=(0,Z.useState)(!1),ue=(0,Z.useMemo)(()=>R?{onPasteText:(e,t)=>{q(!0),A(e,!0,t)},onCopyCombo:j}:void 0,[R,A,j]);ge(e,s,n===`streaming`,ue);let J=le(e,C),Y=h(P,F,f),me=i===`unsupported`?a:n===`error`?r:n===`closed`?`Disconnected`:n===`connecting`?`Connecting…`:null;return(0,$.jsxs)(`div`,{className:`relative flex h-full w-full items-center justify-center bg-black`,"data-testid":`remote-desktop-window`,"data-conn-state":n,children:[(0,$.jsx)(`div`,{className:te(`flex h-full w-full`,Y?`overflow-auto`:`overflow-hidden`),children:(0,$.jsx)(`canvas`,{ref:e,"data-testid":`remote-desktop-canvas`,"data-view-style":P,className:te(`m-auto outline-none`,!Y&&`max-h-full max-w-full`),style:Y?{width:Y.width,height:Y.height}:void 0})}),(0,$.jsx)(pe,{canvasRef:e,getFrameCount:u,getTotalBytes:d}),(0,$.jsx)(ye,{displays:t.displays,currentDisplayId:t.current?.id,onSelectDisplay:t.select,quality:p,qualityChoice:z,onSetQuality:m,onOpenCustomQuality:()=>U(!0),codecs:G?.encoders??[],codec:y,onSetCodec:b,hostModes:G?.resolutions?.modes??[],hostModeId:E,hostOriginalModeId:O,onSetHostMode:re,canResizeHost:G?.inputReady??!1,resolutionError:ne,viewStyle:P,customScale:F,onSetViewStyle:I,onSetCustomScale:L,showCursor:_,onSetShowCursor:v,audioOn:x,audioReason:G&&!G.audio.available?G.audio.reason:null,onSetAudioOn:S,privacyOn:w,privacyReason:T??(G&&!G.privacy.available?G.privacy.reason:null),privacyCanBlank:G?.privacy?.canBlank??!1,onSetPrivacyOn:ee,recording:J.recording,recordingElapsedSec:J.elapsedSec,recordingSupported:J.supported,onToggleRecording:J.toggle,onScreenshot:()=>void K(e.current),clipboardEnabled:R,onSetClipboardEnabled:W,statsVisible:M,onToggleStats:N}),(0,$.jsx)(he,{pendingText:ie,onDismiss:k,missingToolAction:ce&&G&&!G.clipboard.available?G.clipboard.action:null,onDismissMissingTool:()=>q(!1)}),(0,$.jsx)(Ce,{open:oe,onOpenChange:U,percent:B,fps:V,more:H,onSetMore:ae,onCommit:g,frameSize:f}),me&&(0,$.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-3 bg-black/70 text-sm text-white`,children:[(0,$.jsx)(o,{className:`size-6 opacity-70`}),(0,$.jsx)(`span`,{className:`max-w-sm text-center px-4`,children:me}),(n===`error`||n===`closed`)&&i!==`unsupported`&&(0,$.jsxs)(`button`,{onClick:c,className:`flex items-center gap-1.5 rounded-md bg-white/10 px-3 py-1.5 hover:bg-white/20`,children:[(0,$.jsx)(l,{className:`size-3.5`}),` Reconnect`]})]})]})}export{we as default};
@@ -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-BHh12_0v.js";import{Mr as r,O as i,Qn as a,S as o,Wn as s,Yn as c,Zn as l,j as u}from"./icons-C9ZwXgel.js";import{n as d,s as f}from"./api-client-c8YOpTlT.js";import{n as p}from"./utils-btZ8C8-R.js";import"./portal-container-context-NFSuymMu.js";import"./context-menu-CVO3HtIt.js";import{n as m}from"./use-is-mobile-CkO33jqU.js";import{t as h}from"./button-CBehaXpV.js";import{a as g,n as ee,o as _,t as v}from"./dialog-CaShS4f5.js";import{t as y}from"./mobile-bottom-sheet-Cf4kV1hS.js";import"./use-visual-viewport-C307OVeV.js";import{t as b}from"./input-CP31LZnN.js";import{t as te}from"./scroll-area-xAtds1T-.js";import{Gt as x,Kt as S,Xt as C,ct as w,dt as T,en as E,lt as D,ot as O,qt as k,st as A,ut as j}from"./index-BVKT5UCu.js";var M=e(t(),1),N=1e4;function P(){let[e,t]=(0,M.useState)([]),[n,r]=(0,M.useState)(!0),i=(0,M.useCallback)(async()=>{try{t(await d.get(`/api/schedules`))}catch{}finally{r(!1)}},[]);return(0,M.useEffect)(()=>{i();let e=setInterval(()=>{document.visibilityState===`visible`&&i()},N);return()=>clearInterval(e)},[i]),{schedules:e,loading:n,refetch:i}}function F(e){let[t,n]=(0,M.useState)([]),[r,i]=(0,M.useState)(!1),a=(0,M.useCallback)(async()=>{if(e!=null){i(!0);try{n(await d.get(`/api/schedules/${e}/runs?limit=20`))}catch{n([])}finally{i(!1)}}},[e]);return(0,M.useEffect)(()=>{a()},[a]),{runs:t,loading:r,refetch:a}}var I=n(),ne={done:`bg-success/10 text-success`,error:`bg-error/10 text-error`,running:`bg-warning/10 text-warning`,skipped:`bg-muted text-muted-foreground`};function re({scheduleId:e}){let{runs:t,loading:n}=F(e);return n&&t.length===0?(0,I.jsx)(`p`,{className:`text-[11px] text-muted-foreground py-1`,children:`Loading runs…`}):t.length===0?(0,I.jsx)(`p`,{className:`text-[11px] text-muted-foreground py-1`,children:`No runs yet.`}):(0,I.jsx)(`div`,{className:`space-y-1`,children:t.map(e=>(0,I.jsx)(ie,{run:e},e.id))})}function L(e){return new Date(e.includes(`T`)?e:e.replace(` `,`T`)+`Z`)}function ie({run:e}){let[t,n]=(0,M.useState)(!1),r=!!(e.output_truncated||e.error),i=e.ended_at?`${Math.round((L(e.ended_at).getTime()-L(e.started_at).getTime())/1e3)}s`:`…`;return(0,I.jsxs)(`div`,{className:`rounded border border-border text-[11px]`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:()=>r&&n(!t),className:p(`w-full flex items-center gap-2 px-2 py-2 min-h-11 text-left`,r&&`cursor-pointer hover:bg-accent/30`),children:[(0,I.jsx)(`span`,{className:p(`rounded px-1.5 py-0.5 font-medium shrink-0`,ne[e.status]),children:e.status}),(0,I.jsxs)(`span`,{className:`text-muted-foreground truncate flex-1`,children:[L(e.started_at).toLocaleString(),` · `,i,e.cost_usd!=null&&` · $${e.cost_usd.toFixed(4)}`,e.context_window_pct!=null&&` · ctx ${e.context_window_pct}%`]})]}),t&&(0,I.jsxs)(`div`,{className:`px-2 pb-2 space-y-1`,children:[e.error&&(0,I.jsx)(`p`,{className:`text-error break-all`,children:e.error}),e.output_truncated&&(0,I.jsx)(`pre`,{className:`overflow-auto max-h-96 whitespace-pre-wrap break-all text-muted-foreground font-mono text-[10px]`,children:e.output_truncated})]})]})}function ae({schedule:e,onEdit:t,onChanged:n}){let[o,l]=(0,M.useState)(!1),[m,h]=(0,M.useState)(0);return(0,I.jsxs)(`div`,{className:`rounded-lg border border-border`,children:[(0,I.jsxs)(x,{children:[(0,I.jsx)(E,{asChild:!0,children:(0,I.jsxs)(`button`,{type:`button`,onClick:()=>l(!o),className:`w-full flex items-center gap-2 px-2.5 py-2.5 min-h-11 text-left cursor-pointer hover:bg-accent/30`,children:[o?(0,I.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}):(0,I.jsx)(u,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,I.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,I.jsx)(`p`,{className:`text-xs font-medium truncate`,children:e.name}),(0,I.jsxs)(`p`,{className:`text-[11px] text-muted-foreground truncate`,children:[(0,I.jsx)(`span`,{className:`font-mono`,children:e.cron_expr}),` · `,e.next_fire_at&&e.enabled?`next ${new Date(e.next_fire_at).toLocaleString()}`:`—`]})]}),(0,I.jsx)(`span`,{className:p(`rounded px-1.5 py-0.5 text-[10px] font-medium shrink-0`,e.enabled?`bg-success/10 text-success`:`bg-muted text-muted-foreground`),children:e.enabled?`Enabled`:`Disabled`})]})}),(0,I.jsxs)(S,{children:[(0,I.jsxs)(k,{onClick:async()=>{try{let t=await d.post(`/api/schedules/${e.id}/run-now`);f.success(`Run #${t.runId} started${t.wasRunning?` (previous run still active)`:``}`),l(!0),h(e=>e+1)}catch(e){f.error(e instanceof Error?e.message:`Run failed`)}},children:[(0,I.jsx)(c,{className:`size-3.5`}),` Run now`]}),(0,I.jsxs)(k,{onClick:async()=>{try{await d.patch(`/api/schedules/${e.id}`,{enabled:!e.enabled}),n()}catch(e){f.error(e instanceof Error?e.message:`Update failed`)}},children:[(0,I.jsx)(a,{className:`size-3.5`}),` `,e.enabled?`Disable`:`Enable`]}),(0,I.jsxs)(k,{onClick:t,children:[(0,I.jsx)(s,{className:`size-3.5`}),` Edit`]}),(0,I.jsx)(C,{}),(0,I.jsxs)(k,{variant:`destructive`,onClick:async()=>{try{await d.del(`/api/schedules/${e.id}`),f.success(`Schedule deleted`),n()}catch(e){f.error(e instanceof Error?e.message:`Delete failed`)}},children:[(0,I.jsx)(r,{className:`size-3.5`}),` Delete`]})]})]}),o&&(0,I.jsxs)(`div`,{className:`px-2.5 pb-2.5 space-y-1.5`,children:[(0,I.jsx)(`p`,{className:`text-[11px] text-muted-foreground break-all line-clamp-3`,children:e.prompt}),(0,I.jsx)(re,{scheduleId:e.id},m)]})]})}function R(e,t,n,r,i,a,o,s){return R.fromTZ(R.tp(e,t,n,r,i,a,o),s)}R.fromTZISO=(e,t,n)=>R.fromTZ(B(e,t),n),R.fromTZ=function(e,t){let n=new Date(Date.UTC(e.y,e.m-1,e.d,e.h,e.i,e.s)),r=z(e.tz,n),i=new Date(n.getTime()-r),a=z(e.tz,i);if(a-r===0)return i;{let r=new Date(n.getTime()-a),o=z(e.tz,r);if(o-a===0||!t&&o-a>0)return r;if(t)throw Error(`Invalid date passed to fromTZ()`);return i}},R.toTZ=function(e,t){let n=e.toLocaleString(`en-US`,{timeZone:t}).replace(/[\u202f]/,` `),r=new Date(n);return{y:r.getFullYear(),m:r.getMonth()+1,d:r.getDate(),h:r.getHours(),i:r.getMinutes(),s:r.getSeconds(),tz:t}},R.tp=(e,t,n,r,i,a,o)=>({y:e,m:t,d:n,h:r,i,s:a,tz:o});function z(e,t=new Date){let n=t.toLocaleString(`en-US`,{timeZone:e,timeZoneName:`shortOffset`}).split(` `).slice(-1)[0],r=t.toLocaleString(`en-US`).replace(/[\u202f]/,` `);return Date.parse(`${r} GMT`)-Date.parse(`${r} ${n}`)}function B(e,t){let n=new Date(Date.parse(e));if(isNaN(n))throw Error(`minitz: Invalid ISO8601 passed to parser.`);let r=e.substring(9);return e.includes(`Z`)||r.includes(`-`)||r.includes(`+`)?R.tp(n.getUTCFullYear(),n.getUTCMonth()+1,n.getUTCDate(),n.getUTCHours(),n.getUTCMinutes(),n.getUTCSeconds(),`Etc/UTC`):R.tp(n.getFullYear(),n.getMonth()+1,n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),t)}R.minitz=R;var V=32,H=31|V,U=[1,2,4,8,16],W=class{pattern;timezone;second;minute;hour;day;month;dayOfWeek;lastDayOfMonth;starDOM;starDOW;constructor(e,t){this.pattern=e,this.timezone=t,this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.lastDayOfMonth=!1,this.starDOM=!1,this.starDOW=!1,this.parse()}parse(){if(!(typeof this.pattern==`string`||this.pattern instanceof String))throw TypeError(`CronPattern: Pattern has to be of type string.`);this.pattern.indexOf(`@`)>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let e=this.pattern.replace(/\s+/g,` `).split(` `);if(e.length<5||e.length>6)throw TypeError(`CronPattern: invalid configuration format ('`+this.pattern+`'), exactly five or six space separated parts are required.`);if(e.length===5&&e.unshift(`0`),e[3].indexOf(`L`)>=0&&(e[3]=e[3].replace(`L`,``),this.lastDayOfMonth=!0),e[3]==`*`&&(this.starDOM=!0),e[4].length>=3&&(e[4]=this.replaceAlphaMonths(e[4])),e[5].length>=3&&(e[5]=this.replaceAlphaDays(e[5])),e[5]==`*`&&(this.starDOW=!0),this.pattern.indexOf(`?`)>=0){let t=new q(new Date,this.timezone).getDate(!0);e[0]=e[0].replace(`?`,t.getSeconds().toString()),e[1]=e[1].replace(`?`,t.getMinutes().toString()),e[2]=e[2].replace(`?`,t.getHours().toString()),this.starDOM||(e[3]=e[3].replace(`?`,t.getDate().toString())),e[4]=e[4].replace(`?`,(t.getMonth()+1).toString()),this.starDOW||(e[5]=e[5].replace(`?`,t.getDay().toString()))}this.throwAtIllegalCharacters(e),this.partToArray(`second`,e[0],0,1),this.partToArray(`minute`,e[1],0,1),this.partToArray(`hour`,e[2],0,1),this.partToArray(`day`,e[3],-1,1),this.partToArray(`month`,e[4],-1,1),this.partToArray(`dayOfWeek`,e[5],0,H),this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray(e,t,n,r){let i=this[e],a=e===`day`&&this.lastDayOfMonth;if(t===``&&!a)throw TypeError(`CronPattern: configuration entry `+e+` (`+t+`) is empty, check for trailing spaces.`);if(t===`*`)return i.fill(r);let o=t.split(`,`);if(o.length>1)for(let t=0;t<o.length;t++)this.partToArray(e,o[t],n,r);else t.indexOf(`-`)!==-1&&t.indexOf(`/`)!==-1?this.handleRangeWithStepping(t,e,n,r):t.indexOf(`-`)===-1?t.indexOf(`/`)===-1?t!==``&&this.handleNumber(t,e,n,r):this.handleStepping(t,e,n,r):this.handleRange(t,e,n,r)}throwAtIllegalCharacters(e){for(let t=0;t<e.length;t++)if((t===5?/[^/*0-9,\-#L]+/:/[^/*0-9,-]+/).test(e[t]))throw TypeError(`CronPattern: configuration entry `+t+` (`+e[t]+`) contains illegal characters.`)}handleNumber(e,t,n,r){let i=this.extractNth(e,t),a=parseInt(i[0],10)+n;if(isNaN(a))throw TypeError(`CronPattern: `+t+` is not a number: '`+e+`'`);this.setPart(t,a,i[1]||r)}setPart(e,t,n){if(!Object.prototype.hasOwnProperty.call(this,e))throw TypeError(`CronPattern: Invalid part specified: `+e);if(e===`dayOfWeek`){if(t===7&&(t=0),t<0||t>6)throw RangeError(`CronPattern: Invalid value for dayOfWeek: `+t);this.setNthWeekdayOfMonth(t,n);return}if(e===`second`||e===`minute`){if(t<0||t>=60)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`hour`){if(t<0||t>=24)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`day`){if(t<0||t>=31)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`month`&&(t<0||t>=12))throw RangeError(`CronPattern: Invalid value for `+e+`: `+t);this[e][t]=n}handleRangeWithStepping(e,t,n,r){let i=this.extractNth(e,t),a=i[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(a===null)throw TypeError(`CronPattern: Syntax error, illegal range with stepping: '`+e+`'`);let[,o,s,c]=a,l=parseInt(o,10)+n,u=parseInt(s,10)+n,d=parseInt(c,10);if(isNaN(l))throw TypeError(`CronPattern: Syntax error, illegal lower range (NaN)`);if(isNaN(u))throw TypeError(`CronPattern: Syntax error, illegal upper range (NaN)`);if(isNaN(d))throw TypeError(`CronPattern: Syntax error, illegal stepping: (NaN)`);if(d===0)throw TypeError(`CronPattern: Syntax error, illegal stepping: 0`);if(d>this[t].length)throw TypeError(`CronPattern: Syntax error, steps cannot be greater than maximum value of part (`+this[t].length+`)`);if(l>u)throw TypeError(`CronPattern: From value is larger than to value: '`+e+`'`);for(let e=l;e<=u;e+=d)this.setPart(t,e,i[1]||r)}extractNth(e,t){let n=e,r;if(n.includes(`#`)){if(t!==`dayOfWeek`)throw Error(`CronPattern: nth (#) only allowed in day-of-week field`);r=n.split(`#`)[1],n=n.split(`#`)[0]}return[n,r]}handleRange(e,t,n,r){let i=this.extractNth(e,t),a=i[0].split(`-`);if(a.length!==2)throw TypeError(`CronPattern: Syntax error, illegal range: '`+e+`'`);let o=parseInt(a[0],10)+n,s=parseInt(a[1],10)+n;if(isNaN(o))throw TypeError(`CronPattern: Syntax error, illegal lower range (NaN)`);if(isNaN(s))throw TypeError(`CronPattern: Syntax error, illegal upper range (NaN)`);if(o>s)throw TypeError(`CronPattern: From value is larger than to value: '`+e+`'`);for(let e=o;e<=s;e++)this.setPart(t,e,i[1]||r)}handleStepping(e,t,n,r){let i=this.extractNth(e,t),a=i[0].split(`/`);if(a.length!==2)throw TypeError(`CronPattern: Syntax error, illegal stepping: '`+e+`'`);a[0]===``&&(a[0]=`*`);let o=0;a[0]!==`*`&&(o=parseInt(a[0],10)+n);let s=parseInt(a[1],10);if(isNaN(s))throw TypeError(`CronPattern: Syntax error, illegal stepping: (NaN)`);if(s===0)throw TypeError(`CronPattern: Syntax error, illegal stepping: 0`);if(s>this[t].length)throw TypeError(`CronPattern: Syntax error, max steps for part is (`+this[t].length+`)`);for(let e=o;e<this[t].length;e+=s)this.setPart(t,e,i[1]||r)}replaceAlphaDays(e){return e.replace(/-sun/gi,`-7`).replace(/sun/gi,`0`).replace(/mon/gi,`1`).replace(/tue/gi,`2`).replace(/wed/gi,`3`).replace(/thu/gi,`4`).replace(/fri/gi,`5`).replace(/sat/gi,`6`)}replaceAlphaMonths(e){return e.replace(/jan/gi,`1`).replace(/feb/gi,`2`).replace(/mar/gi,`3`).replace(/apr/gi,`4`).replace(/may/gi,`5`).replace(/jun/gi,`6`).replace(/jul/gi,`7`).replace(/aug/gi,`8`).replace(/sep/gi,`9`).replace(/oct/gi,`10`).replace(/nov/gi,`11`).replace(/dec/gi,`12`)}handleNicknames(e){let t=e.trim().toLowerCase();return t===`@yearly`||t===`@annually`?`0 0 1 1 *`:t===`@monthly`?`0 0 1 * *`:t===`@weekly`?`0 0 * * 0`:t===`@daily`?`0 0 * * *`:t===`@hourly`?`0 * * * *`:e}setNthWeekdayOfMonth(e,t){if(typeof t!=`number`&&t===`L`)this.dayOfWeek[e]=this.dayOfWeek[e]|V;else if(t===H)this.dayOfWeek[e]=H;else if(t<6&&t>0)this.dayOfWeek[e]=this.dayOfWeek[e]|U[t-1];else throw TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${t}, Type: ${typeof t}`)}},G=[31,28,31,30,31,30,31,31,30,31,30,31],K=[[`month`,`year`,0],[`day`,`month`,-1],[`hour`,`day`,0],[`minute`,`hour`,0],[`second`,`minute`,0]],q=class e{tz;ms;second;minute;hour;day;month;year;constructor(t,n){if(this.tz=n,t&&t instanceof Date)if(!isNaN(t))this.fromDate(t);else throw TypeError(`CronDate: Invalid date passed to CronDate constructor`);else if(t===void 0)this.fromDate(new Date);else if(t&&typeof t==`string`)this.fromString(t);else if(t instanceof e)this.fromCronDate(t);else throw TypeError(`CronDate: Invalid type (`+typeof t+`) passed to CronDate constructor`)}isNthWeekdayOfMonth(e,t,n,r){let i=new Date(Date.UTC(e,t,n)).getUTCDay(),a=0;for(let r=1;r<=n;r++)new Date(Date.UTC(e,t,r)).getUTCDay()===i&&a++;if(r&H&&U[a-1]&r)return!0;if(r&V){let r=new Date(Date.UTC(e,t+1,0)).getUTCDate();for(let a=n+1;a<=r;a++)if(new Date(Date.UTC(e,t,a)).getUTCDay()===i)return!1;return!0}return!1}fromDate(e){if(this.tz!==void 0)if(typeof this.tz==`number`)this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes()+this.tz,this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),this.apply();else{let t=R.toTZ(e,this.tz);this.ms=e.getMilliseconds(),this.second=t.s,this.minute=t.i,this.hour=t.h,this.day=t.d,this.month=t.m-1,this.year=t.y}else this.ms=e.getMilliseconds(),this.second=e.getSeconds(),this.minute=e.getMinutes(),this.hour=e.getHours(),this.day=e.getDate(),this.month=e.getMonth(),this.year=e.getFullYear()}fromCronDate(e){this.tz=e.tz,this.year=e.year,this.month=e.month,this.day=e.day,this.hour=e.hour,this.minute=e.minute,this.second=e.second,this.ms=e.ms}apply(){if(this.month>11||this.day>G[this.month]||this.hour>59||this.minute>59||this.second>59||this.hour<0||this.minute<0||this.second<0){let e=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes(),this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),!0}else return!1}fromString(e){if(typeof this.tz==`number`){let t=R.fromTZISO(e);this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes(),this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),this.apply()}else return this.fromDate(R.fromTZISO(e,this.tz))}findNext(e,t,n,r){let i=this[t],a;n.lastDayOfMonth&&(a=this.month===1?new Date(Date.UTC(this.year,this.month+1,0,0,0,0,0)).getUTCDate():G[this.month]);let o=!n.starDOW&&t==`day`?new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay():void 0;for(let s=this[t]+r;s<n[t].length;s++){let c=n[t][s];if(t===`day`&&n.lastDayOfMonth&&s-r==a&&(c=1),t===`day`&&!n.starDOW){let t=n.dayOfWeek[(o+(s-r-1))%7];if(t&&t&H)t=this.isNthWeekdayOfMonth(this.year,this.month,s-r,t)?1:0;else if(t)throw Error(`CronDate: Invalid value for dayOfWeek encountered. ${t}`);e.legacyMode&&!n.starDOM?c||=t:c&&=t}if(c)return this[t]=s-r,i===this[t]?1:2}return 3}recurse(e,t,n){let r=this.findNext(t,K[n][0],e,K[n][2]);if(r>1){let i=n+1;for(;i<K.length;)this[K[i][0]]=-K[i][2],i++;if(r===3)return this[K[n][1]]++,this[K[n][0]]=-K[n][2],this.apply(),this.recurse(e,t,0);if(this.apply())return this.recurse(e,t,n-1)}return n+=1,n>=K.length?this:this.year>=3e3?null:this.recurse(e,t,n)}increment(e,t,n){return this.second+=t.interval!==void 0&&t.interval>1&&n?t.interval:1,this.ms=0,this.apply(),this.recurse(e,t,0)}getDate(e){return e||this.tz===void 0?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):typeof this.tz==`number`?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):R.fromTZ(R.tp(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}};function oe(e){if(e===void 0&&(e={}),delete e.name,e.legacyMode=e.legacyMode===void 0?!0:e.legacyMode,e.paused=e.paused===void 0?!1:e.paused,e.maxRuns=e.maxRuns===void 0?1/0:e.maxRuns,e.catch=e.catch===void 0?!1:e.catch,e.interval=e.interval===void 0?0:parseInt(e.interval.toString(),10),e.utcOffset=e.utcOffset===void 0?void 0:parseInt(e.utcOffset.toString(),10),e.unref=e.unref===void 0?!1:e.unref,e.startAt&&=new q(e.startAt,e.timezone),e.stopAt&&=new q(e.stopAt,e.timezone),e.interval!==null){if(isNaN(e.interval))throw Error(`CronOptions: Supplied value for interval is not a number`);if(e.interval<0)throw Error(`CronOptions: Supplied value for interval can not be negative`)}if(e.utcOffset!==void 0){if(isNaN(e.utcOffset))throw Error(`CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.`);if(e.utcOffset<-870||e.utcOffset>870)throw Error(`CronOptions: utcOffset out of bounds.`);if(e.utcOffset!==void 0&&e.timezone)throw Error(`CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.`)}if(e.unref!==!0&&e.unref!==!1)throw Error(`CronOptions: Unref should be either true, false or undefined(false).`);return e}function J(e){return Object.prototype.toString.call(e)===`[object Function]`||typeof e==`function`||e instanceof Function}function se(e){return J(e)}function ce(e){typeof Deno<`u`&&typeof Deno.unrefTimer<`u`?Deno.unrefTimer(e):e&&typeof e.unref<`u`&&e.unref()}var Y=30*1e3,X=[],Z=class{name;options;_states;fn;constructor(e,t,n){let r,i;if(J(t))i=t;else if(typeof t==`object`)r=t;else if(t!==void 0)throw Error(`Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).`);if(J(n))i=n;else if(typeof n==`object`)r=n;else if(n!==void 0)throw Error(`Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).`);if(this.name=r?.name,this.options=oe(r),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:r?r.maxRuns:void 0,paused:r?r.paused:!1,pattern:new W(`* * * * *`)},e&&(e instanceof Date||typeof e==`string`&&e.indexOf(`:`)>0)?this._states.once=new q(e,this.options.timezone||this.options.utcOffset):this._states.pattern=new W(e,this.options.timezone),this.name){if(X.find(e=>e.name===this.name))throw Error(`Cron: Tried to initialize new named job '`+this.name+`', but name already taken.`);X.push(this)}return i!==void 0&&se(i)&&(this.fn=i,this.schedule()),this}nextRun(e){let t=this._next(e);return t?t.getDate(!1):null}nextRuns(e,t){this._states.maxRuns!==void 0&&e>this._states.maxRuns&&(e=this._states.maxRuns);let n=[],r=t||this._states.currentRun||void 0;for(;e--&&(r=this.nextRun(r));)n.push(r);return n}getPattern(){return this._states.pattern?this._states.pattern.pattern:void 0}isRunning(){let e=this.nextRun(this._states.currentRun),t=!this._states.paused,n=this.fn!==void 0,r=!this._states.kill;return t&&n&&r&&e!==null}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext(e){let t=this._next(e);return t?e instanceof q||e instanceof Date?t.getTime()-e.getTime():t.getTime()-new q(e).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let e=X.indexOf(this);e>=0&&X.splice(e,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule(e){if(e&&this.fn)throw Error(`Cron: It is not allowed to schedule two functions using the same Croner instance.`);e&&(this.fn=e);let t=this.msToNext(),n=this.nextRun(this._states.currentRun);return t==null||isNaN(t)||n===null?this:(t>Y&&(t=Y),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(n),t),this._states.currentTimeout&&this.options.unref&&ce(this._states.currentTimeout),this)}async _trigger(e){if(this._states.blocking=!0,this._states.currentRun=new q(void 0,this.options.timezone||this.options.utcOffset),this.options.catch)try{this.fn!==void 0&&await this.fn(this,this.options.context)}catch(e){J(this.options.catch)&&this.options.catch(e,this)}else this.fn!==void 0&&await this.fn(this,this.options.context);this._states.previousRun=new q(e,this.options.timezone||this.options.utcOffset),this._states.blocking=!1}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger(e){let t=new Date,n=!this._states.paused&&t.getTime()>=e.getTime(),r=this._states.blocking&&this.options.protect;n&&!r?(this._states.maxRuns!==void 0&&this._states.maxRuns--,this._trigger()):n&&r&&J(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next(e){let t=!!(e||this._states.currentRun),n=!1;!e&&this.options.startAt&&this.options.interval&&([e,t]=this._calculatePreviousRun(e,t),n=!e),e=new q(e,this.options.timezone||this.options.utcOffset),this.options.startAt&&e&&e.getTime()<this.options.startAt.getTime()&&(e=this.options.startAt);let r=this._states.once||new q(e,this.options.timezone||this.options.utcOffset);return!n&&r!==this._states.once&&(r=r.increment(this._states.pattern,this.options,t)),this._states.once&&this._states.once.getTime()<=e.getTime()||r===null||this._states.maxRuns!==void 0&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&r.getTime()>=this.options.stopAt.getTime()?null:r}_calculatePreviousRun(e,t){let n=new q(void 0,this.options.timezone||this.options.utcOffset),r=e;if(this.options.startAt.getTime()<=n.getTime()){r=this.options.startAt;let e=r.getTime()+this.options.interval*1e3;for(;e<=n.getTime();)r=new q(r,this.options.timezone||this.options.utcOffset).increment(this._states.pattern,this.options,!0),e=r.getTime()+this.options.interval*1e3;t=!0}return r===null&&(r=void 0),[r,t]}},le=[`bypassPermissions`,`acceptEdits`,`default`,`plan`];function ue({open:e,schedule:t,onClose:n,onSaved:r}){let i=m(),[a,o]=(0,M.useState)(()=>$(t)),[s,c]=(0,M.useState)([]),[l,u]=(0,M.useState)(!1),[f,p]=(0,M.useState)(null);(0,M.useEffect)(()=>{e&&(o($(t)),p(null),d.get(`/api/projects`).then(c).catch(()=>c([])))},[e,t]);let x=(0,M.useMemo)(()=>{try{return new Z(a.cron_expr).nextRuns(3).map(e=>e.toLocaleString())}catch{return null}},[a.cron_expr]),S=(e,t)=>o(n=>({...n,[e]:t})),C=(0,I.jsxs)(`div`,{className:`space-y-3 px-1`,children:[(0,I.jsx)(Q,{label:`Name`,children:(0,I.jsx)(b,{value:a.name,onChange:e=>S(`name`,e.target.value),placeholder:`Morning PR review`,className:`h-11 md:h-9 text-xs`})}),(0,I.jsxs)(Q,{label:`Cron expression (local timezone)`,children:[(0,I.jsx)(b,{value:a.cron_expr,onChange:e=>S(`cron_expr`,e.target.value),placeholder:`0 7 * * *`,className:`h-11 md:h-9 text-xs font-mono`}),(0,I.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:x?`Next: ${x.join(` · `)}`:`—`})]}),(0,I.jsx)(Q,{label:`Project`,children:(0,I.jsxs)(O,{value:a.project_path,onValueChange:e=>S(`project_path`,e),children:[(0,I.jsx)(D,{className:`w-full min-h-11 md:min-h-9 text-xs`,children:(0,I.jsx)(j,{placeholder:`Select project`})}),(0,I.jsx)(A,{children:s.map(e=>(0,I.jsx)(w,{value:e.path,children:e.name},e.path))})]})}),(0,I.jsx)(Q,{label:`Prompt (do not embed secrets)`,children:(0,I.jsx)(`textarea`,{value:a.prompt,onChange:e=>S(`prompt`,e.target.value),placeholder:`Check open PRs and summarize. If nothing to do, finish immediately.`,rows:4,className:`w-full rounded-md border border-input bg-transparent px-3 py-2 text-xs outline-none focus-visible:ring-2 focus-visible:ring-ring/50 resize-y`})}),(0,I.jsxs)(Q,{label:`Permission mode`,children:[(0,I.jsxs)(O,{value:a.permission_mode,onValueChange:e=>S(`permission_mode`,e),children:[(0,I.jsx)(D,{className:`w-full min-h-11 md:min-h-9 text-xs`,children:(0,I.jsx)(j,{})}),(0,I.jsx)(A,{children:le.map(e=>(0,I.jsx)(w,{value:e,children:e},e))})]}),a.permission_mode===`bypassPermissions`&&(0,I.jsx)(`p`,{className:`text-[11px] text-warning`,children:`⚠ Unattended writes — agent can modify code and run commands`})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,I.jsx)(Q,{label:`Max turns (optional)`,children:(0,I.jsx)(b,{type:`number`,min:1,value:a.max_turns,onChange:e=>S(`max_turns`,e.target.value),placeholder:`∞`,className:`h-11 md:h-9 text-xs`})}),(0,I.jsx)(Q,{label:`Timeout (ms)`,children:(0,I.jsx)(b,{type:`number`,min:1e4,value:a.timeout_ms,onChange:e=>S(`timeout_ms`,e.target.value),className:`h-11 md:h-9 text-xs`})})]}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between min-h-11`,children:[(0,I.jsx)(`span`,{className:`text-xs font-medium`,children:`Enabled`}),(0,I.jsx)(T,{checked:a.enabled,onCheckedChange:e=>S(`enabled`,e)})]}),f&&(0,I.jsx)(`p`,{className:`text-[11px] text-error`,children:f}),(0,I.jsx)(h,{onClick:async()=>{if(!a.name.trim()||!a.project_path||!a.prompt.trim()){p(`Name, project, and prompt are required`);return}if(!x){p(`Invalid cron expression`);return}u(!0),p(null);try{let e={name:a.name.trim(),cron_expr:a.cron_expr,project_path:a.project_path,prompt:a.prompt,permission_mode:a.permission_mode,max_turns:a.max_turns===``?null:Number(a.max_turns),timeout_ms:Number(a.timeout_ms)||18e5,enabled:a.enabled};t?await d.patch(`/api/schedules/${t.id}`,e):await d.post(`/api/schedules`,e),r(),n()}catch(e){p(e instanceof Error?e.message:String(e))}finally{u(!1)}},disabled:l,className:`w-full min-h-11 cursor-pointer`,children:l?`Saving…`:t?`Save changes`:`Create schedule`})]}),E=t?`Edit: ${t.name}`:`New schedule`;return i?(0,I.jsxs)(y,{open:e,onClose:n,className:`max-h-[85vh] flex flex-col`,children:[(0,I.jsx)(`p`,{className:`text-sm font-semibold text-center pb-2`,children:E}),(0,I.jsx)(te,{className:`flex-1 min-h-0 px-3 pb-3`,children:C})]}):(0,I.jsx)(v,{open:e,onOpenChange:e=>!e&&n(),children:(0,I.jsxs)(ee,{className:`max-w-md max-h-[85vh] overflow-y-auto`,children:[(0,I.jsx)(g,{children:(0,I.jsx)(_,{className:`text-sm`,children:E})}),C]})})}function Q({label:e,children:t}){return(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:e}),t]})}function $(e){return{name:e?.name??``,cron_expr:e?.cron_expr??`0 7 * * *`,project_path:e?.project_path??``,prompt:e?.prompt??``,permission_mode:e?.permission_mode??`bypassPermissions`,max_turns:e?.max_turns==null?``:String(e.max_turns),timeout_ms:String(e?.timeout_ms??18e5),enabled:e?!!e.enabled:!0}}function de(){let{schedules:e,loading:t,refetch:n}=P(),[r,i]=(0,M.useState)(!1),[a,s]=(0,M.useState)(null),c=()=>{s(null),i(!0)},u=e=>{s(e),i(!0)};return(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Periodically wake Claude to work on a project unattended.`}),(0,I.jsxs)(h,{size:`sm`,onClick:c,className:`min-h-11 md:min-h-8 text-xs gap-1 cursor-pointer shrink-0`,children:[(0,I.jsx)(l,{className:`size-3.5`}),` Add`]})]}),t&&e.length===0?(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:`Loading…`}):e.length===0?(0,I.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,I.jsx)(o,{className:`size-8 text-muted-foreground/50`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No schedules yet. Add one to run Claude periodically.`}),(0,I.jsxs)(h,{size:`sm`,onClick:c,className:`min-h-11 text-xs gap-1 cursor-pointer`,children:[(0,I.jsx)(l,{className:`size-3.5`}),` Add schedule`]})]}):(0,I.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,I.jsx)(ae,{schedule:e,onEdit:()=>u(e),onChanged:n},e.id))}),(0,I.jsx)(ue,{open:r,schedule:a,onClose:()=>i(!1),onSaved:n})]})}export{de as SchedulesSettingsSection};
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-BHh12_0v.js";import{Mr as r,O as i,Qn as a,S as o,Wn as s,Yn as c,Zn as l,j as u}from"./icons-CO_II6D-.js";import{n as d,s as f}from"./api-client-c8YOpTlT.js";import{n as p}from"./utils-btZ8C8-R.js";import"./portal-container-context-NFSuymMu.js";import"./context-menu-CjYTq8DI.js";import{n as m}from"./use-is-mobile-CkO33jqU.js";import{t as h}from"./button-CBehaXpV.js";import{a as g,n as ee,o as _,t as v}from"./dialog-tzBRkGeW.js";import{t as y}from"./mobile-bottom-sheet-Cf4kV1hS.js";import"./use-visual-viewport-C307OVeV.js";import{t as b}from"./input-CP31LZnN.js";import{t as te}from"./scroll-area-xAtds1T-.js";import{Gt as x,Kt as S,Xt as C,ct as w,dt as T,en as E,lt as D,ot as O,qt as k,st as A,ut as j}from"./index-CvUGUp7d.js";var M=e(t(),1),N=1e4;function P(){let[e,t]=(0,M.useState)([]),[n,r]=(0,M.useState)(!0),i=(0,M.useCallback)(async()=>{try{t(await d.get(`/api/schedules`))}catch{}finally{r(!1)}},[]);return(0,M.useEffect)(()=>{i();let e=setInterval(()=>{document.visibilityState===`visible`&&i()},N);return()=>clearInterval(e)},[i]),{schedules:e,loading:n,refetch:i}}function F(e){let[t,n]=(0,M.useState)([]),[r,i]=(0,M.useState)(!1),a=(0,M.useCallback)(async()=>{if(e!=null){i(!0);try{n(await d.get(`/api/schedules/${e}/runs?limit=20`))}catch{n([])}finally{i(!1)}}},[e]);return(0,M.useEffect)(()=>{a()},[a]),{runs:t,loading:r,refetch:a}}var I=n(),ne={done:`bg-success/10 text-success`,error:`bg-error/10 text-error`,running:`bg-warning/10 text-warning`,skipped:`bg-muted text-muted-foreground`};function re({scheduleId:e}){let{runs:t,loading:n}=F(e);return n&&t.length===0?(0,I.jsx)(`p`,{className:`text-[11px] text-muted-foreground py-1`,children:`Loading runs…`}):t.length===0?(0,I.jsx)(`p`,{className:`text-[11px] text-muted-foreground py-1`,children:`No runs yet.`}):(0,I.jsx)(`div`,{className:`space-y-1`,children:t.map(e=>(0,I.jsx)(ie,{run:e},e.id))})}function L(e){return new Date(e.includes(`T`)?e:e.replace(` `,`T`)+`Z`)}function ie({run:e}){let[t,n]=(0,M.useState)(!1),r=!!(e.output_truncated||e.error),i=e.ended_at?`${Math.round((L(e.ended_at).getTime()-L(e.started_at).getTime())/1e3)}s`:`…`;return(0,I.jsxs)(`div`,{className:`rounded border border-border text-[11px]`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:()=>r&&n(!t),className:p(`w-full flex items-center gap-2 px-2 py-2 min-h-11 text-left`,r&&`cursor-pointer hover:bg-accent/30`),children:[(0,I.jsx)(`span`,{className:p(`rounded px-1.5 py-0.5 font-medium shrink-0`,ne[e.status]),children:e.status}),(0,I.jsxs)(`span`,{className:`text-muted-foreground truncate flex-1`,children:[L(e.started_at).toLocaleString(),` · `,i,e.cost_usd!=null&&` · $${e.cost_usd.toFixed(4)}`,e.context_window_pct!=null&&` · ctx ${e.context_window_pct}%`]})]}),t&&(0,I.jsxs)(`div`,{className:`px-2 pb-2 space-y-1`,children:[e.error&&(0,I.jsx)(`p`,{className:`text-error break-all`,children:e.error}),e.output_truncated&&(0,I.jsx)(`pre`,{className:`overflow-auto max-h-96 whitespace-pre-wrap break-all text-muted-foreground font-mono text-[10px]`,children:e.output_truncated})]})]})}function ae({schedule:e,onEdit:t,onChanged:n}){let[o,l]=(0,M.useState)(!1),[m,h]=(0,M.useState)(0);return(0,I.jsxs)(`div`,{className:`rounded-lg border border-border`,children:[(0,I.jsxs)(x,{children:[(0,I.jsx)(E,{asChild:!0,children:(0,I.jsxs)(`button`,{type:`button`,onClick:()=>l(!o),className:`w-full flex items-center gap-2 px-2.5 py-2.5 min-h-11 text-left cursor-pointer hover:bg-accent/30`,children:[o?(0,I.jsx)(i,{className:`size-3.5 shrink-0 text-muted-foreground`}):(0,I.jsx)(u,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,I.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,I.jsx)(`p`,{className:`text-xs font-medium truncate`,children:e.name}),(0,I.jsxs)(`p`,{className:`text-[11px] text-muted-foreground truncate`,children:[(0,I.jsx)(`span`,{className:`font-mono`,children:e.cron_expr}),` · `,e.next_fire_at&&e.enabled?`next ${new Date(e.next_fire_at).toLocaleString()}`:`—`]})]}),(0,I.jsx)(`span`,{className:p(`rounded px-1.5 py-0.5 text-[10px] font-medium shrink-0`,e.enabled?`bg-success/10 text-success`:`bg-muted text-muted-foreground`),children:e.enabled?`Enabled`:`Disabled`})]})}),(0,I.jsxs)(S,{children:[(0,I.jsxs)(k,{onClick:async()=>{try{let t=await d.post(`/api/schedules/${e.id}/run-now`);f.success(`Run #${t.runId} started${t.wasRunning?` (previous run still active)`:``}`),l(!0),h(e=>e+1)}catch(e){f.error(e instanceof Error?e.message:`Run failed`)}},children:[(0,I.jsx)(c,{className:`size-3.5`}),` Run now`]}),(0,I.jsxs)(k,{onClick:async()=>{try{await d.patch(`/api/schedules/${e.id}`,{enabled:!e.enabled}),n()}catch(e){f.error(e instanceof Error?e.message:`Update failed`)}},children:[(0,I.jsx)(a,{className:`size-3.5`}),` `,e.enabled?`Disable`:`Enable`]}),(0,I.jsxs)(k,{onClick:t,children:[(0,I.jsx)(s,{className:`size-3.5`}),` Edit`]}),(0,I.jsx)(C,{}),(0,I.jsxs)(k,{variant:`destructive`,onClick:async()=>{try{await d.del(`/api/schedules/${e.id}`),f.success(`Schedule deleted`),n()}catch(e){f.error(e instanceof Error?e.message:`Delete failed`)}},children:[(0,I.jsx)(r,{className:`size-3.5`}),` Delete`]})]})]}),o&&(0,I.jsxs)(`div`,{className:`px-2.5 pb-2.5 space-y-1.5`,children:[(0,I.jsx)(`p`,{className:`text-[11px] text-muted-foreground break-all line-clamp-3`,children:e.prompt}),(0,I.jsx)(re,{scheduleId:e.id},m)]})]})}function R(e,t,n,r,i,a,o,s){return R.fromTZ(R.tp(e,t,n,r,i,a,o),s)}R.fromTZISO=(e,t,n)=>R.fromTZ(B(e,t),n),R.fromTZ=function(e,t){let n=new Date(Date.UTC(e.y,e.m-1,e.d,e.h,e.i,e.s)),r=z(e.tz,n),i=new Date(n.getTime()-r),a=z(e.tz,i);if(a-r===0)return i;{let r=new Date(n.getTime()-a),o=z(e.tz,r);if(o-a===0||!t&&o-a>0)return r;if(t)throw Error(`Invalid date passed to fromTZ()`);return i}},R.toTZ=function(e,t){let n=e.toLocaleString(`en-US`,{timeZone:t}).replace(/[\u202f]/,` `),r=new Date(n);return{y:r.getFullYear(),m:r.getMonth()+1,d:r.getDate(),h:r.getHours(),i:r.getMinutes(),s:r.getSeconds(),tz:t}},R.tp=(e,t,n,r,i,a,o)=>({y:e,m:t,d:n,h:r,i,s:a,tz:o});function z(e,t=new Date){let n=t.toLocaleString(`en-US`,{timeZone:e,timeZoneName:`shortOffset`}).split(` `).slice(-1)[0],r=t.toLocaleString(`en-US`).replace(/[\u202f]/,` `);return Date.parse(`${r} GMT`)-Date.parse(`${r} ${n}`)}function B(e,t){let n=new Date(Date.parse(e));if(isNaN(n))throw Error(`minitz: Invalid ISO8601 passed to parser.`);let r=e.substring(9);return e.includes(`Z`)||r.includes(`-`)||r.includes(`+`)?R.tp(n.getUTCFullYear(),n.getUTCMonth()+1,n.getUTCDate(),n.getUTCHours(),n.getUTCMinutes(),n.getUTCSeconds(),`Etc/UTC`):R.tp(n.getFullYear(),n.getMonth()+1,n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),t)}R.minitz=R;var V=32,H=31|V,U=[1,2,4,8,16],W=class{pattern;timezone;second;minute;hour;day;month;dayOfWeek;lastDayOfMonth;starDOM;starDOW;constructor(e,t){this.pattern=e,this.timezone=t,this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.lastDayOfMonth=!1,this.starDOM=!1,this.starDOW=!1,this.parse()}parse(){if(!(typeof this.pattern==`string`||this.pattern instanceof String))throw TypeError(`CronPattern: Pattern has to be of type string.`);this.pattern.indexOf(`@`)>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let e=this.pattern.replace(/\s+/g,` `).split(` `);if(e.length<5||e.length>6)throw TypeError(`CronPattern: invalid configuration format ('`+this.pattern+`'), exactly five or six space separated parts are required.`);if(e.length===5&&e.unshift(`0`),e[3].indexOf(`L`)>=0&&(e[3]=e[3].replace(`L`,``),this.lastDayOfMonth=!0),e[3]==`*`&&(this.starDOM=!0),e[4].length>=3&&(e[4]=this.replaceAlphaMonths(e[4])),e[5].length>=3&&(e[5]=this.replaceAlphaDays(e[5])),e[5]==`*`&&(this.starDOW=!0),this.pattern.indexOf(`?`)>=0){let t=new q(new Date,this.timezone).getDate(!0);e[0]=e[0].replace(`?`,t.getSeconds().toString()),e[1]=e[1].replace(`?`,t.getMinutes().toString()),e[2]=e[2].replace(`?`,t.getHours().toString()),this.starDOM||(e[3]=e[3].replace(`?`,t.getDate().toString())),e[4]=e[4].replace(`?`,(t.getMonth()+1).toString()),this.starDOW||(e[5]=e[5].replace(`?`,t.getDay().toString()))}this.throwAtIllegalCharacters(e),this.partToArray(`second`,e[0],0,1),this.partToArray(`minute`,e[1],0,1),this.partToArray(`hour`,e[2],0,1),this.partToArray(`day`,e[3],-1,1),this.partToArray(`month`,e[4],-1,1),this.partToArray(`dayOfWeek`,e[5],0,H),this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray(e,t,n,r){let i=this[e],a=e===`day`&&this.lastDayOfMonth;if(t===``&&!a)throw TypeError(`CronPattern: configuration entry `+e+` (`+t+`) is empty, check for trailing spaces.`);if(t===`*`)return i.fill(r);let o=t.split(`,`);if(o.length>1)for(let t=0;t<o.length;t++)this.partToArray(e,o[t],n,r);else t.indexOf(`-`)!==-1&&t.indexOf(`/`)!==-1?this.handleRangeWithStepping(t,e,n,r):t.indexOf(`-`)===-1?t.indexOf(`/`)===-1?t!==``&&this.handleNumber(t,e,n,r):this.handleStepping(t,e,n,r):this.handleRange(t,e,n,r)}throwAtIllegalCharacters(e){for(let t=0;t<e.length;t++)if((t===5?/[^/*0-9,\-#L]+/:/[^/*0-9,-]+/).test(e[t]))throw TypeError(`CronPattern: configuration entry `+t+` (`+e[t]+`) contains illegal characters.`)}handleNumber(e,t,n,r){let i=this.extractNth(e,t),a=parseInt(i[0],10)+n;if(isNaN(a))throw TypeError(`CronPattern: `+t+` is not a number: '`+e+`'`);this.setPart(t,a,i[1]||r)}setPart(e,t,n){if(!Object.prototype.hasOwnProperty.call(this,e))throw TypeError(`CronPattern: Invalid part specified: `+e);if(e===`dayOfWeek`){if(t===7&&(t=0),t<0||t>6)throw RangeError(`CronPattern: Invalid value for dayOfWeek: `+t);this.setNthWeekdayOfMonth(t,n);return}if(e===`second`||e===`minute`){if(t<0||t>=60)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`hour`){if(t<0||t>=24)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`day`){if(t<0||t>=31)throw RangeError(`CronPattern: Invalid value for `+e+`: `+t)}else if(e===`month`&&(t<0||t>=12))throw RangeError(`CronPattern: Invalid value for `+e+`: `+t);this[e][t]=n}handleRangeWithStepping(e,t,n,r){let i=this.extractNth(e,t),a=i[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(a===null)throw TypeError(`CronPattern: Syntax error, illegal range with stepping: '`+e+`'`);let[,o,s,c]=a,l=parseInt(o,10)+n,u=parseInt(s,10)+n,d=parseInt(c,10);if(isNaN(l))throw TypeError(`CronPattern: Syntax error, illegal lower range (NaN)`);if(isNaN(u))throw TypeError(`CronPattern: Syntax error, illegal upper range (NaN)`);if(isNaN(d))throw TypeError(`CronPattern: Syntax error, illegal stepping: (NaN)`);if(d===0)throw TypeError(`CronPattern: Syntax error, illegal stepping: 0`);if(d>this[t].length)throw TypeError(`CronPattern: Syntax error, steps cannot be greater than maximum value of part (`+this[t].length+`)`);if(l>u)throw TypeError(`CronPattern: From value is larger than to value: '`+e+`'`);for(let e=l;e<=u;e+=d)this.setPart(t,e,i[1]||r)}extractNth(e,t){let n=e,r;if(n.includes(`#`)){if(t!==`dayOfWeek`)throw Error(`CronPattern: nth (#) only allowed in day-of-week field`);r=n.split(`#`)[1],n=n.split(`#`)[0]}return[n,r]}handleRange(e,t,n,r){let i=this.extractNth(e,t),a=i[0].split(`-`);if(a.length!==2)throw TypeError(`CronPattern: Syntax error, illegal range: '`+e+`'`);let o=parseInt(a[0],10)+n,s=parseInt(a[1],10)+n;if(isNaN(o))throw TypeError(`CronPattern: Syntax error, illegal lower range (NaN)`);if(isNaN(s))throw TypeError(`CronPattern: Syntax error, illegal upper range (NaN)`);if(o>s)throw TypeError(`CronPattern: From value is larger than to value: '`+e+`'`);for(let e=o;e<=s;e++)this.setPart(t,e,i[1]||r)}handleStepping(e,t,n,r){let i=this.extractNth(e,t),a=i[0].split(`/`);if(a.length!==2)throw TypeError(`CronPattern: Syntax error, illegal stepping: '`+e+`'`);a[0]===``&&(a[0]=`*`);let o=0;a[0]!==`*`&&(o=parseInt(a[0],10)+n);let s=parseInt(a[1],10);if(isNaN(s))throw TypeError(`CronPattern: Syntax error, illegal stepping: (NaN)`);if(s===0)throw TypeError(`CronPattern: Syntax error, illegal stepping: 0`);if(s>this[t].length)throw TypeError(`CronPattern: Syntax error, max steps for part is (`+this[t].length+`)`);for(let e=o;e<this[t].length;e+=s)this.setPart(t,e,i[1]||r)}replaceAlphaDays(e){return e.replace(/-sun/gi,`-7`).replace(/sun/gi,`0`).replace(/mon/gi,`1`).replace(/tue/gi,`2`).replace(/wed/gi,`3`).replace(/thu/gi,`4`).replace(/fri/gi,`5`).replace(/sat/gi,`6`)}replaceAlphaMonths(e){return e.replace(/jan/gi,`1`).replace(/feb/gi,`2`).replace(/mar/gi,`3`).replace(/apr/gi,`4`).replace(/may/gi,`5`).replace(/jun/gi,`6`).replace(/jul/gi,`7`).replace(/aug/gi,`8`).replace(/sep/gi,`9`).replace(/oct/gi,`10`).replace(/nov/gi,`11`).replace(/dec/gi,`12`)}handleNicknames(e){let t=e.trim().toLowerCase();return t===`@yearly`||t===`@annually`?`0 0 1 1 *`:t===`@monthly`?`0 0 1 * *`:t===`@weekly`?`0 0 * * 0`:t===`@daily`?`0 0 * * *`:t===`@hourly`?`0 * * * *`:e}setNthWeekdayOfMonth(e,t){if(typeof t!=`number`&&t===`L`)this.dayOfWeek[e]=this.dayOfWeek[e]|V;else if(t===H)this.dayOfWeek[e]=H;else if(t<6&&t>0)this.dayOfWeek[e]=this.dayOfWeek[e]|U[t-1];else throw TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${t}, Type: ${typeof t}`)}},G=[31,28,31,30,31,30,31,31,30,31,30,31],K=[[`month`,`year`,0],[`day`,`month`,-1],[`hour`,`day`,0],[`minute`,`hour`,0],[`second`,`minute`,0]],q=class e{tz;ms;second;minute;hour;day;month;year;constructor(t,n){if(this.tz=n,t&&t instanceof Date)if(!isNaN(t))this.fromDate(t);else throw TypeError(`CronDate: Invalid date passed to CronDate constructor`);else if(t===void 0)this.fromDate(new Date);else if(t&&typeof t==`string`)this.fromString(t);else if(t instanceof e)this.fromCronDate(t);else throw TypeError(`CronDate: Invalid type (`+typeof t+`) passed to CronDate constructor`)}isNthWeekdayOfMonth(e,t,n,r){let i=new Date(Date.UTC(e,t,n)).getUTCDay(),a=0;for(let r=1;r<=n;r++)new Date(Date.UTC(e,t,r)).getUTCDay()===i&&a++;if(r&H&&U[a-1]&r)return!0;if(r&V){let r=new Date(Date.UTC(e,t+1,0)).getUTCDate();for(let a=n+1;a<=r;a++)if(new Date(Date.UTC(e,t,a)).getUTCDay()===i)return!1;return!0}return!1}fromDate(e){if(this.tz!==void 0)if(typeof this.tz==`number`)this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes()+this.tz,this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),this.apply();else{let t=R.toTZ(e,this.tz);this.ms=e.getMilliseconds(),this.second=t.s,this.minute=t.i,this.hour=t.h,this.day=t.d,this.month=t.m-1,this.year=t.y}else this.ms=e.getMilliseconds(),this.second=e.getSeconds(),this.minute=e.getMinutes(),this.hour=e.getHours(),this.day=e.getDate(),this.month=e.getMonth(),this.year=e.getFullYear()}fromCronDate(e){this.tz=e.tz,this.year=e.year,this.month=e.month,this.day=e.day,this.hour=e.hour,this.minute=e.minute,this.second=e.second,this.ms=e.ms}apply(){if(this.month>11||this.day>G[this.month]||this.hour>59||this.minute>59||this.second>59||this.hour<0||this.minute<0||this.second<0){let e=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes(),this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),!0}else return!1}fromString(e){if(typeof this.tz==`number`){let t=R.fromTZISO(e);this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes(),this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),this.apply()}else return this.fromDate(R.fromTZISO(e,this.tz))}findNext(e,t,n,r){let i=this[t],a;n.lastDayOfMonth&&(a=this.month===1?new Date(Date.UTC(this.year,this.month+1,0,0,0,0,0)).getUTCDate():G[this.month]);let o=!n.starDOW&&t==`day`?new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay():void 0;for(let s=this[t]+r;s<n[t].length;s++){let c=n[t][s];if(t===`day`&&n.lastDayOfMonth&&s-r==a&&(c=1),t===`day`&&!n.starDOW){let t=n.dayOfWeek[(o+(s-r-1))%7];if(t&&t&H)t=this.isNthWeekdayOfMonth(this.year,this.month,s-r,t)?1:0;else if(t)throw Error(`CronDate: Invalid value for dayOfWeek encountered. ${t}`);e.legacyMode&&!n.starDOM?c||=t:c&&=t}if(c)return this[t]=s-r,i===this[t]?1:2}return 3}recurse(e,t,n){let r=this.findNext(t,K[n][0],e,K[n][2]);if(r>1){let i=n+1;for(;i<K.length;)this[K[i][0]]=-K[i][2],i++;if(r===3)return this[K[n][1]]++,this[K[n][0]]=-K[n][2],this.apply(),this.recurse(e,t,0);if(this.apply())return this.recurse(e,t,n-1)}return n+=1,n>=K.length?this:this.year>=3e3?null:this.recurse(e,t,n)}increment(e,t,n){return this.second+=t.interval!==void 0&&t.interval>1&&n?t.interval:1,this.ms=0,this.apply(),this.recurse(e,t,0)}getDate(e){return e||this.tz===void 0?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):typeof this.tz==`number`?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):R.fromTZ(R.tp(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}};function oe(e){if(e===void 0&&(e={}),delete e.name,e.legacyMode=e.legacyMode===void 0?!0:e.legacyMode,e.paused=e.paused===void 0?!1:e.paused,e.maxRuns=e.maxRuns===void 0?1/0:e.maxRuns,e.catch=e.catch===void 0?!1:e.catch,e.interval=e.interval===void 0?0:parseInt(e.interval.toString(),10),e.utcOffset=e.utcOffset===void 0?void 0:parseInt(e.utcOffset.toString(),10),e.unref=e.unref===void 0?!1:e.unref,e.startAt&&=new q(e.startAt,e.timezone),e.stopAt&&=new q(e.stopAt,e.timezone),e.interval!==null){if(isNaN(e.interval))throw Error(`CronOptions: Supplied value for interval is not a number`);if(e.interval<0)throw Error(`CronOptions: Supplied value for interval can not be negative`)}if(e.utcOffset!==void 0){if(isNaN(e.utcOffset))throw Error(`CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.`);if(e.utcOffset<-870||e.utcOffset>870)throw Error(`CronOptions: utcOffset out of bounds.`);if(e.utcOffset!==void 0&&e.timezone)throw Error(`CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.`)}if(e.unref!==!0&&e.unref!==!1)throw Error(`CronOptions: Unref should be either true, false or undefined(false).`);return e}function J(e){return Object.prototype.toString.call(e)===`[object Function]`||typeof e==`function`||e instanceof Function}function se(e){return J(e)}function ce(e){typeof Deno<`u`&&typeof Deno.unrefTimer<`u`?Deno.unrefTimer(e):e&&typeof e.unref<`u`&&e.unref()}var Y=30*1e3,X=[],Z=class{name;options;_states;fn;constructor(e,t,n){let r,i;if(J(t))i=t;else if(typeof t==`object`)r=t;else if(t!==void 0)throw Error(`Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).`);if(J(n))i=n;else if(typeof n==`object`)r=n;else if(n!==void 0)throw Error(`Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).`);if(this.name=r?.name,this.options=oe(r),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:r?r.maxRuns:void 0,paused:r?r.paused:!1,pattern:new W(`* * * * *`)},e&&(e instanceof Date||typeof e==`string`&&e.indexOf(`:`)>0)?this._states.once=new q(e,this.options.timezone||this.options.utcOffset):this._states.pattern=new W(e,this.options.timezone),this.name){if(X.find(e=>e.name===this.name))throw Error(`Cron: Tried to initialize new named job '`+this.name+`', but name already taken.`);X.push(this)}return i!==void 0&&se(i)&&(this.fn=i,this.schedule()),this}nextRun(e){let t=this._next(e);return t?t.getDate(!1):null}nextRuns(e,t){this._states.maxRuns!==void 0&&e>this._states.maxRuns&&(e=this._states.maxRuns);let n=[],r=t||this._states.currentRun||void 0;for(;e--&&(r=this.nextRun(r));)n.push(r);return n}getPattern(){return this._states.pattern?this._states.pattern.pattern:void 0}isRunning(){let e=this.nextRun(this._states.currentRun),t=!this._states.paused,n=this.fn!==void 0,r=!this._states.kill;return t&&n&&r&&e!==null}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext(e){let t=this._next(e);return t?e instanceof q||e instanceof Date?t.getTime()-e.getTime():t.getTime()-new q(e).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let e=X.indexOf(this);e>=0&&X.splice(e,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule(e){if(e&&this.fn)throw Error(`Cron: It is not allowed to schedule two functions using the same Croner instance.`);e&&(this.fn=e);let t=this.msToNext(),n=this.nextRun(this._states.currentRun);return t==null||isNaN(t)||n===null?this:(t>Y&&(t=Y),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(n),t),this._states.currentTimeout&&this.options.unref&&ce(this._states.currentTimeout),this)}async _trigger(e){if(this._states.blocking=!0,this._states.currentRun=new q(void 0,this.options.timezone||this.options.utcOffset),this.options.catch)try{this.fn!==void 0&&await this.fn(this,this.options.context)}catch(e){J(this.options.catch)&&this.options.catch(e,this)}else this.fn!==void 0&&await this.fn(this,this.options.context);this._states.previousRun=new q(e,this.options.timezone||this.options.utcOffset),this._states.blocking=!1}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger(e){let t=new Date,n=!this._states.paused&&t.getTime()>=e.getTime(),r=this._states.blocking&&this.options.protect;n&&!r?(this._states.maxRuns!==void 0&&this._states.maxRuns--,this._trigger()):n&&r&&J(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next(e){let t=!!(e||this._states.currentRun),n=!1;!e&&this.options.startAt&&this.options.interval&&([e,t]=this._calculatePreviousRun(e,t),n=!e),e=new q(e,this.options.timezone||this.options.utcOffset),this.options.startAt&&e&&e.getTime()<this.options.startAt.getTime()&&(e=this.options.startAt);let r=this._states.once||new q(e,this.options.timezone||this.options.utcOffset);return!n&&r!==this._states.once&&(r=r.increment(this._states.pattern,this.options,t)),this._states.once&&this._states.once.getTime()<=e.getTime()||r===null||this._states.maxRuns!==void 0&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&r.getTime()>=this.options.stopAt.getTime()?null:r}_calculatePreviousRun(e,t){let n=new q(void 0,this.options.timezone||this.options.utcOffset),r=e;if(this.options.startAt.getTime()<=n.getTime()){r=this.options.startAt;let e=r.getTime()+this.options.interval*1e3;for(;e<=n.getTime();)r=new q(r,this.options.timezone||this.options.utcOffset).increment(this._states.pattern,this.options,!0),e=r.getTime()+this.options.interval*1e3;t=!0}return r===null&&(r=void 0),[r,t]}},le=[`bypassPermissions`,`acceptEdits`,`default`,`plan`];function ue({open:e,schedule:t,onClose:n,onSaved:r}){let i=m(),[a,o]=(0,M.useState)(()=>$(t)),[s,c]=(0,M.useState)([]),[l,u]=(0,M.useState)(!1),[f,p]=(0,M.useState)(null);(0,M.useEffect)(()=>{e&&(o($(t)),p(null),d.get(`/api/projects`).then(c).catch(()=>c([])))},[e,t]);let x=(0,M.useMemo)(()=>{try{return new Z(a.cron_expr).nextRuns(3).map(e=>e.toLocaleString())}catch{return null}},[a.cron_expr]),S=(e,t)=>o(n=>({...n,[e]:t})),C=(0,I.jsxs)(`div`,{className:`space-y-3 px-1`,children:[(0,I.jsx)(Q,{label:`Name`,children:(0,I.jsx)(b,{value:a.name,onChange:e=>S(`name`,e.target.value),placeholder:`Morning PR review`,className:`h-11 md:h-9 text-xs`})}),(0,I.jsxs)(Q,{label:`Cron expression (local timezone)`,children:[(0,I.jsx)(b,{value:a.cron_expr,onChange:e=>S(`cron_expr`,e.target.value),placeholder:`0 7 * * *`,className:`h-11 md:h-9 text-xs font-mono`}),(0,I.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:x?`Next: ${x.join(` · `)}`:`—`})]}),(0,I.jsx)(Q,{label:`Project`,children:(0,I.jsxs)(O,{value:a.project_path,onValueChange:e=>S(`project_path`,e),children:[(0,I.jsx)(D,{className:`w-full min-h-11 md:min-h-9 text-xs`,children:(0,I.jsx)(j,{placeholder:`Select project`})}),(0,I.jsx)(A,{children:s.map(e=>(0,I.jsx)(w,{value:e.path,children:e.name},e.path))})]})}),(0,I.jsx)(Q,{label:`Prompt (do not embed secrets)`,children:(0,I.jsx)(`textarea`,{value:a.prompt,onChange:e=>S(`prompt`,e.target.value),placeholder:`Check open PRs and summarize. If nothing to do, finish immediately.`,rows:4,className:`w-full rounded-md border border-input bg-transparent px-3 py-2 text-xs outline-none focus-visible:ring-2 focus-visible:ring-ring/50 resize-y`})}),(0,I.jsxs)(Q,{label:`Permission mode`,children:[(0,I.jsxs)(O,{value:a.permission_mode,onValueChange:e=>S(`permission_mode`,e),children:[(0,I.jsx)(D,{className:`w-full min-h-11 md:min-h-9 text-xs`,children:(0,I.jsx)(j,{})}),(0,I.jsx)(A,{children:le.map(e=>(0,I.jsx)(w,{value:e,children:e},e))})]}),a.permission_mode===`bypassPermissions`&&(0,I.jsx)(`p`,{className:`text-[11px] text-warning`,children:`⚠ Unattended writes — agent can modify code and run commands`})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,I.jsx)(Q,{label:`Max turns (optional)`,children:(0,I.jsx)(b,{type:`number`,min:1,value:a.max_turns,onChange:e=>S(`max_turns`,e.target.value),placeholder:`∞`,className:`h-11 md:h-9 text-xs`})}),(0,I.jsx)(Q,{label:`Timeout (ms)`,children:(0,I.jsx)(b,{type:`number`,min:1e4,value:a.timeout_ms,onChange:e=>S(`timeout_ms`,e.target.value),className:`h-11 md:h-9 text-xs`})})]}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between min-h-11`,children:[(0,I.jsx)(`span`,{className:`text-xs font-medium`,children:`Enabled`}),(0,I.jsx)(T,{checked:a.enabled,onCheckedChange:e=>S(`enabled`,e)})]}),f&&(0,I.jsx)(`p`,{className:`text-[11px] text-error`,children:f}),(0,I.jsx)(h,{onClick:async()=>{if(!a.name.trim()||!a.project_path||!a.prompt.trim()){p(`Name, project, and prompt are required`);return}if(!x){p(`Invalid cron expression`);return}u(!0),p(null);try{let e={name:a.name.trim(),cron_expr:a.cron_expr,project_path:a.project_path,prompt:a.prompt,permission_mode:a.permission_mode,max_turns:a.max_turns===``?null:Number(a.max_turns),timeout_ms:Number(a.timeout_ms)||18e5,enabled:a.enabled};t?await d.patch(`/api/schedules/${t.id}`,e):await d.post(`/api/schedules`,e),r(),n()}catch(e){p(e instanceof Error?e.message:String(e))}finally{u(!1)}},disabled:l,className:`w-full min-h-11 cursor-pointer`,children:l?`Saving…`:t?`Save changes`:`Create schedule`})]}),E=t?`Edit: ${t.name}`:`New schedule`;return i?(0,I.jsxs)(y,{open:e,onClose:n,className:`max-h-[85vh] flex flex-col`,children:[(0,I.jsx)(`p`,{className:`text-sm font-semibold text-center pb-2`,children:E}),(0,I.jsx)(te,{className:`flex-1 min-h-0 px-3 pb-3`,children:C})]}):(0,I.jsx)(v,{open:e,onOpenChange:e=>!e&&n(),children:(0,I.jsxs)(ee,{className:`max-w-md max-h-[85vh] overflow-y-auto`,children:[(0,I.jsx)(g,{children:(0,I.jsx)(_,{className:`text-sm`,children:E})}),C]})})}function Q({label:e,children:t}){return(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:e}),t]})}function $(e){return{name:e?.name??``,cron_expr:e?.cron_expr??`0 7 * * *`,project_path:e?.project_path??``,prompt:e?.prompt??``,permission_mode:e?.permission_mode??`bypassPermissions`,max_turns:e?.max_turns==null?``:String(e.max_turns),timeout_ms:String(e?.timeout_ms??18e5),enabled:e?!!e.enabled:!0}}function de(){let{schedules:e,loading:t,refetch:n}=P(),[r,i]=(0,M.useState)(!1),[a,s]=(0,M.useState)(null),c=()=>{s(null),i(!0)},u=e=>{s(e),i(!0)};return(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Periodically wake Claude to work on a project unattended.`}),(0,I.jsxs)(h,{size:`sm`,onClick:c,className:`min-h-11 md:min-h-8 text-xs gap-1 cursor-pointer shrink-0`,children:[(0,I.jsx)(l,{className:`size-3.5`}),` Add`]})]}),t&&e.length===0?(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:`Loading…`}):e.length===0?(0,I.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,I.jsx)(o,{className:`size-8 text-muted-foreground/50`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No schedules yet. Add one to run Claude periodically.`}),(0,I.jsxs)(h,{size:`sm`,onClick:c,className:`min-h-11 text-xs gap-1 cursor-pointer`,children:[(0,I.jsx)(l,{className:`size-3.5`}),` Add schedule`]})]}):(0,I.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,I.jsx)(ae,{schedule:e,onEdit:()=>u(e),onChanged:n},e.id))}),(0,I.jsx)(ue,{open:r,schedule:a,onClose:()=>i(!1),onSaved:n})]})}export{de as SchedulesSettingsSection};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/general-settings-section-DiY_5C93.js","assets/rolldown-runtime-C5c2KzVm.js","assets/index-BVKT5UCu.js","assets/vendor-mermaid-eg2XWIjK.js","assets/vendor-ui-BHh12_0v.js","assets/vendor-markdown-QKPNiWEd.js","assets/button-CBehaXpV.js","assets/utils-btZ8C8-R.js","assets/createLucideIcon-DBXq3G0e.js","assets/api-client-c8YOpTlT.js","assets/react-CzUPVyyG.js","assets/settings-store-DXmQug0m.js","assets/file-store-CTlJqj2m.js","assets/window-store-B4cbZ5rr.js","assets/window-pip-registry-DH07f_8k.js","assets/panel-store-BUQ-CPsd.js","assets/onboarding-quick-orientation-u7yM68d3.js","assets/dialog-CaShS4f5.js","assets/portal-container-context-NFSuymMu.js","assets/icons-C9ZwXgel.js","assets/use-is-mobile-CkO33jqU.js","assets/format-file-meta-DLaHgkdx.js","assets/fs-api-RVc5RtTA.js","assets/context-menu-CVO3HtIt.js","assets/input-CP31LZnN.js","assets/mobile-bottom-sheet-Cf4kV1hS.js","assets/use-visual-viewport-C307OVeV.js","assets/scroll-area-xAtds1T-.js","assets/file-icons-BlOxPo3P.js","assets/project-framework-store-XxFXcUpb.js","assets/format-date-BMtvCeb9.js","assets/git-repo-store-DFTJ5ngK.js","assets/project-store-C5gJXkvb.js","assets/ws-auth-B_y5rMfZ.js","assets/tab-store-DqeaGhhE.js","assets/apply-theme-aVoqSG0I.js","assets/resolve-theme-B87m6l4i.js","assets/index-CzYrKDUF.css","assets/onboarding-entry-CwkNJ69U.js","assets/separator-D8SNZI6E.js","assets/appearance-settings-section-mRiGj3_g.js","assets/ai-settings-section-Cp6jcnTn.js","assets/ai-settings-section-0x6GFJ56.js","assets/api-settings-0s1Rfgcu.js","assets/accounts-settings-section-CVJ7hQom.js","assets/codex-daily-guard-Bn8jfcei.js","assets/ppmbot-settings-section-rNBdWG7F.js","assets/notifications-settings-section-DaMh3khs.js","assets/jira-watcher-section-Cr8gSVGY.js","assets/extension-manager-section-DOwZYx8O.js","assets/proxy-settings-section-Bo-FPk6Y.js","assets/schedules-settings-section-Bx9Rm-NB.js","assets/keyboard-shortcuts-section-BvC6m_C2.js","assets/files-settings-section-DVemQIZ2.js","assets/query-audit-section-CQfzKAf9.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{At as r,Ft as i,Ln as a,Qt as o,S as s,Zt as c,_ as l,j as u,l as d,ot as f,pr as p,tr as m,un as h,v as g,x as _,y as v}from"./icons-C9ZwXgel.js";import{q as y}from"./vendor-mermaid-eg2XWIjK.js";import{n as b}from"./utils-btZ8C8-R.js";import{t as x}from"./button-CBehaXpV.js";import{t as S}from"./scroll-area-xAtds1T-.js";import{t as C}from"./separator-D8SNZI6E.js";var w=[{id:`core`,label:null},{id:`ai`,label:`AI & Accounts`},{id:`integrations`,label:`Integrations`},{id:`advanced`,label:`Advanced`}],T=[{id:`general`,group:`core`,label:`General`,subtitle:`Device name, password, version`,icon:p},{id:`appearance`,group:`core`,label:`Appearance`,subtitle:`Theme, tabs, explorer skin`,icon:a},{id:`ai-provider`,group:`ai`,label:`AI Provider`,subtitle:`Model, execution mode, limits`,icon:g},{id:`accounts`,group:`ai`,label:`Accounts`,subtitle:`Claude and Codex sign-ins, rotation`,icon:c},{id:`ppmbot`,group:`integrations`,label:`PPMBot`,subtitle:`Telegram AI bot`,icon:v},{id:`notifications`,group:`integrations`,label:`Notifications`,subtitle:`Push & Telegram alerts`,icon:l},{id:`jira`,group:`integrations`,label:`Jira Watcher`,subtitle:`Auto-debug Jira tickets`,icon:_},{id:`extensions`,group:`integrations`,label:`Extensions`,subtitle:`Install and manage extensions`,icon:m},{id:`proxy`,group:`integrations`,label:`API Proxy`,subtitle:`Expose accounts as Anthropic API`,icon:i},{id:`schedules`,group:`advanced`,label:`Scheduled Agents`,subtitle:`Run Claude on a cron schedule`,icon:s},{id:`shortcuts`,group:`advanced`,label:`Keyboard Shortcuts`,subtitle:`Customize key bindings`,icon:o},{id:`files`,group:`advanced`,label:`File Filters`,subtitle:`Exclude patterns, ignore files`,icon:r},{id:`query-audit`,group:`advanced`,label:`Query Audit Log`,subtitle:`SQL history retention and size`,icon:f}];function E(e){return typeof e==`string`&&T.some(t=>t.id===e)}function D(e){return T.find(t=>t.id===e)}function O(e){return T.filter(t=>t.group===e)}var k=n();function A({active:e,onSelect:t}){return(0,k.jsx)(S,{className:`h-full`,children:(0,k.jsx)(`nav`,{className:`p-2 space-y-4`,"aria-label":`Settings categories`,children:w.map(n=>{let r=O(n.id);return r.length===0?null:(0,k.jsxs)(`div`,{className:`space-y-1`,children:[n.label&&(0,k.jsx)(`h3`,{className:`px-2 pt-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:n.label}),r.map(n=>{let r=n.icon,i=n.id===e;return(0,k.jsxs)(`button`,{onClick:()=>t(n.id),"data-testid":`settings-rail-${n.id}`,"aria-current":i?`page`:void 0,className:b(`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-md text-left cursor-pointer transition-colors`,i?`bg-accent text-accent-foreground`:`hover:bg-accent/50 active:bg-accent`),children:[(0,k.jsx)(r,{className:b(`size-4 shrink-0`,i?`text-foreground`:`text-muted-foreground`)}),(0,k.jsx)(`span`,{className:`text-sm truncate`,children:n.label})]},n.id)})]},n.id)})})})}function j({onSelect:e}){return(0,k.jsx)(S,{className:`h-full`,children:(0,k.jsx)(`nav`,{className:`p-3 space-y-5`,"aria-label":`Settings categories`,children:w.map(t=>{let n=O(t.id);return n.length===0?null:(0,k.jsxs)(`div`,{className:`space-y-1`,children:[t.label&&(0,k.jsx)(`h3`,{className:`px-1 pb-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:t.label}),n.map(t=>{let n=t.icon;return(0,k.jsxs)(`button`,{onClick:()=>e(t.id),"data-testid":`settings-index-${t.id}`,className:`w-full flex items-center gap-3 px-2.5 py-3 rounded-lg text-left cursor-pointer group hover:bg-accent/50 active:bg-accent transition-colors`,children:[(0,k.jsx)(`div`,{className:`size-10 rounded-md bg-muted flex items-center justify-center shrink-0 group-hover:bg-accent`,children:(0,k.jsx)(n,{className:`size-4 text-muted-foreground`})}),(0,k.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,k.jsx)(`p`,{className:`text-sm font-medium truncate`,children:t.label}),(0,k.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:t.subtitle})]}),(0,k.jsx)(u,{className:`size-4 text-muted-foreground shrink-0`})]},t.id)})]},t.id)})})})}var M=e(t(),1),N={general:(0,M.lazy)(()=>y(()=>import(`./general-settings-section-DiY_5C93.js`).then(e=>({default:e.GeneralSettingsSection})),__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]))),appearance:(0,M.lazy)(()=>y(()=>import(`./appearance-settings-section-mRiGj3_g.js`).then(e=>({default:e.AppearanceSettingsSection})),__vite__mapDeps([40,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,39]))),"ai-provider":(0,M.lazy)(()=>y(()=>import(`./ai-settings-section-Cp6jcnTn.js`).then(e=>({default:e.AISettingsSection})),__vite__mapDeps([41,3,1,4,5,6,7,9,11,10,13,42,2,8,12,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,43]))),accounts:(0,M.lazy)(()=>y(()=>import(`./accounts-settings-section-CVJ7hQom.js`).then(e=>({default:e.AccountsSettingsSection})),__vite__mapDeps([44,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,45,43]))),ppmbot:(0,M.lazy)(()=>y(()=>import(`./ppmbot-settings-section-rNBdWG7F.js`).then(e=>({default:e.PPMBotSettingsSection})),__vite__mapDeps([46,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,39]))),notifications:(0,M.lazy)(()=>y(()=>import(`./notifications-settings-section-DaMh3khs.js`).then(e=>({default:e.NotificationsSettingsSection})),__vite__mapDeps([47,4,1,5,39,7,19]))),jira:(0,M.lazy)(()=>y(()=>import(`./jira-watcher-section-Cr8gSVGY.js`).then(e=>({default:e.JiraWatcherSection})),__vite__mapDeps([48,2,1,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]))),extensions:(0,M.lazy)(()=>y(()=>import(`./extension-manager-section-DOwZYx8O.js`).then(e=>({default:e.ExtensionManagerSection})),__vite__mapDeps([49,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]))),proxy:(0,M.lazy)(()=>y(()=>import(`./proxy-settings-section-Bo-FPk6Y.js`).then(e=>({default:e.ProxySettingsSection})),__vite__mapDeps([50,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,43]))),schedules:(0,M.lazy)(()=>y(()=>import(`./schedules-settings-section-Bx9Rm-NB.js`).then(e=>({default:e.SchedulesSettingsSection})),__vite__mapDeps([51,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]))),shortcuts:(0,M.lazy)(()=>y(()=>import(`./keyboard-shortcuts-section-BvC6m_C2.js`).then(e=>({default:e.KeyboardShortcutsSection})),__vite__mapDeps([52,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]))),files:(0,M.lazy)(()=>y(()=>import(`./files-settings-section-DVemQIZ2.js`).then(e=>({default:e.FilesSettingsSection})),__vite__mapDeps([53,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,39]))),"query-audit":(0,M.lazy)(()=>y(()=>import(`./query-audit-section-CQfzKAf9.js`).then(e=>({default:e.QueryAuditSection})),__vite__mapDeps([54,1,4,5,6,7,9,24,43,19])))};function P({category:e}){let t=N[e];return(0,k.jsx)(M.Suspense,{fallback:(0,k.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,k.jsx)(h,{className:`size-5 animate-spin text-muted-foreground`})}),children:(0,k.jsx)(t,{})})}function F({initialCategory:e,onCategoryChange:t}){let[n,r]=(0,M.useState)(e??`general`),[i,a]=(0,M.useState)(e===void 0),o=D(n),s=o.icon;function c(e){r(e),a(!1),t?.(e)}return(0,k.jsx)(`div`,{className:`@container h-full w-full`,"data-testid":`settings-window`,"data-category":n,children:(0,k.jsxs)(`div`,{className:`h-full w-full flex`,children:[(0,k.jsx)(`aside`,{className:`hidden @[640px]:flex @[640px]:flex-col w-[210px] shrink-0 border-r border-border min-h-0`,"data-testid":`settings-rail`,children:(0,k.jsx)(A,{active:n,onSelect:c})}),(0,k.jsxs)(`div`,{className:`relative flex-1 min-w-0`,children:[(0,k.jsxs)(`div`,{className:`h-full flex flex-col min-h-0`,children:[(0,k.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 px-2 py-2.5 @[640px]:px-4`,children:[(0,k.jsx)(x,{variant:`ghost`,size:`icon`,"aria-label":`Back to settings list`,className:`size-9 shrink-0 cursor-pointer @[640px]:hidden`,onClick:()=>a(!0),children:(0,k.jsx)(d,{className:`size-4`})}),(0,k.jsx)(s,{className:`size-4 text-muted-foreground shrink-0`}),(0,k.jsx)(`h2`,{className:`text-sm font-semibold truncate`,"data-testid":`settings-pane-title`,children:o.label})]}),(0,k.jsx)(C,{}),(0,k.jsx)(S,{className:`flex-1 min-h-0`,children:(0,k.jsx)(`div`,{className:`p-4 pb-8`,children:(0,k.jsx)(P,{category:n})})})]}),i&&(0,k.jsxs)(`div`,{className:`absolute inset-0 z-10 bg-background flex flex-col min-h-0 @[640px]:hidden`,"data-testid":`settings-index`,children:[(0,k.jsx)(`div`,{className:`shrink-0 px-4 py-3`,children:(0,k.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Settings`})}),(0,k.jsx)(C,{}),(0,k.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,k.jsx)(j,{onSelect:c})})]})]})]})})}export{E as n,F as t};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/general-settings-section--DSUTrEP.js","assets/rolldown-runtime-C5c2KzVm.js","assets/index-CvUGUp7d.js","assets/vendor-mermaid-eg2XWIjK.js","assets/vendor-ui-BHh12_0v.js","assets/vendor-markdown-QKPNiWEd.js","assets/button-CBehaXpV.js","assets/utils-btZ8C8-R.js","assets/createLucideIcon-DBXq3G0e.js","assets/api-client-c8YOpTlT.js","assets/react-CzUPVyyG.js","assets/settings-store-DXmQug0m.js","assets/file-store-CTlJqj2m.js","assets/window-store-B4cbZ5rr.js","assets/window-pip-registry-DH07f_8k.js","assets/panel-store-BUQ-CPsd.js","assets/onboarding-quick-orientation-CT4PylG0.js","assets/dialog-tzBRkGeW.js","assets/portal-container-context-NFSuymMu.js","assets/icons-CO_II6D-.js","assets/use-is-mobile-CkO33jqU.js","assets/format-file-meta-DLaHgkdx.js","assets/fs-api-RVc5RtTA.js","assets/context-menu-CjYTq8DI.js","assets/input-CP31LZnN.js","assets/mobile-bottom-sheet-Cf4kV1hS.js","assets/use-visual-viewport-C307OVeV.js","assets/scroll-area-xAtds1T-.js","assets/file-icons-BlOxPo3P.js","assets/project-framework-store-XxFXcUpb.js","assets/format-date-BMtvCeb9.js","assets/git-repo-store-DFTJ5ngK.js","assets/project-store-C5gJXkvb.js","assets/ws-auth-B_y5rMfZ.js","assets/tab-store-DqeaGhhE.js","assets/apply-theme-aVoqSG0I.js","assets/resolve-theme-B87m6l4i.js","assets/index-DMA-So69.css","assets/onboarding-entry-CcvySZ_l.js","assets/separator-D8SNZI6E.js","assets/appearance-settings-section-DACtiDor.js","assets/ai-settings-section-BlKlcihJ.js","assets/ai-settings-section-B7Un4KiW.js","assets/api-settings-0s1Rfgcu.js","assets/accounts-settings-section-Cs7BC5O1.js","assets/codex-sign-in-again-dialog-DcIOYhAe.js","assets/ppmbot-settings-section-DF0kqdyO.js","assets/notifications-settings-section-Bfxqz65i.js","assets/jira-watcher-section-DoXl0GAq.js","assets/extension-manager-section-CL7pl3re.js","assets/proxy-settings-section-Q-ttqVOa.js","assets/schedules-settings-section-Bv_wrzDp.js","assets/keyboard-shortcuts-section-BogwnAdr.js","assets/files-settings-section-C574RfCl.js","assets/query-audit-section-Cn11xqgz.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{At as r,Ft as i,Ln as a,Qt as o,S as s,Zt as c,_ as l,j as u,l as d,ot as f,pr as p,tr as m,un as h,v as g,x as _,y as v}from"./icons-CO_II6D-.js";import{q as y}from"./vendor-mermaid-eg2XWIjK.js";import{n as b}from"./utils-btZ8C8-R.js";import{t as x}from"./button-CBehaXpV.js";import{t as S}from"./scroll-area-xAtds1T-.js";import{t as C}from"./separator-D8SNZI6E.js";var w=[{id:`core`,label:null},{id:`ai`,label:`AI & Accounts`},{id:`integrations`,label:`Integrations`},{id:`advanced`,label:`Advanced`}],T=[{id:`general`,group:`core`,label:`General`,subtitle:`Device name, password, version`,icon:p},{id:`appearance`,group:`core`,label:`Appearance`,subtitle:`Theme, tabs, explorer skin`,icon:a},{id:`ai-provider`,group:`ai`,label:`AI Provider`,subtitle:`Model, execution mode, limits`,icon:g},{id:`accounts`,group:`ai`,label:`Accounts`,subtitle:`Claude and Codex sign-ins, rotation`,icon:c},{id:`ppmbot`,group:`integrations`,label:`PPMBot`,subtitle:`Telegram AI bot`,icon:v},{id:`notifications`,group:`integrations`,label:`Notifications`,subtitle:`Push & Telegram alerts`,icon:l},{id:`jira`,group:`integrations`,label:`Jira Watcher`,subtitle:`Auto-debug Jira tickets`,icon:_},{id:`extensions`,group:`integrations`,label:`Extensions`,subtitle:`Install and manage extensions`,icon:m},{id:`proxy`,group:`integrations`,label:`API Proxy`,subtitle:`Expose accounts as Anthropic API`,icon:i},{id:`schedules`,group:`advanced`,label:`Scheduled Agents`,subtitle:`Run Claude on a cron schedule`,icon:s},{id:`shortcuts`,group:`advanced`,label:`Keyboard Shortcuts`,subtitle:`Customize key bindings`,icon:o},{id:`files`,group:`advanced`,label:`File Filters`,subtitle:`Exclude patterns, ignore files`,icon:r},{id:`query-audit`,group:`advanced`,label:`Query Audit Log`,subtitle:`SQL history retention and size`,icon:f}];function E(e){return typeof e==`string`&&T.some(t=>t.id===e)}function D(e){return T.find(t=>t.id===e)}function O(e){return T.filter(t=>t.group===e)}var k=n();function A({active:e,onSelect:t}){return(0,k.jsx)(S,{className:`h-full`,children:(0,k.jsx)(`nav`,{className:`p-2 space-y-4`,"aria-label":`Settings categories`,children:w.map(n=>{let r=O(n.id);return r.length===0?null:(0,k.jsxs)(`div`,{className:`space-y-1`,children:[n.label&&(0,k.jsx)(`h3`,{className:`px-2 pt-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:n.label}),r.map(n=>{let r=n.icon,i=n.id===e;return(0,k.jsxs)(`button`,{onClick:()=>t(n.id),"data-testid":`settings-rail-${n.id}`,"aria-current":i?`page`:void 0,className:b(`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-md text-left cursor-pointer transition-colors`,i?`bg-accent text-accent-foreground`:`hover:bg-accent/50 active:bg-accent`),children:[(0,k.jsx)(r,{className:b(`size-4 shrink-0`,i?`text-foreground`:`text-muted-foreground`)}),(0,k.jsx)(`span`,{className:`text-sm truncate`,children:n.label})]},n.id)})]},n.id)})})})}function j({onSelect:e}){return(0,k.jsx)(S,{className:`h-full`,children:(0,k.jsx)(`nav`,{className:`p-3 space-y-5`,"aria-label":`Settings categories`,children:w.map(t=>{let n=O(t.id);return n.length===0?null:(0,k.jsxs)(`div`,{className:`space-y-1`,children:[t.label&&(0,k.jsx)(`h3`,{className:`px-1 pb-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:t.label}),n.map(t=>{let n=t.icon;return(0,k.jsxs)(`button`,{onClick:()=>e(t.id),"data-testid":`settings-index-${t.id}`,className:`w-full flex items-center gap-3 px-2.5 py-3 rounded-lg text-left cursor-pointer group hover:bg-accent/50 active:bg-accent transition-colors`,children:[(0,k.jsx)(`div`,{className:`size-10 rounded-md bg-muted flex items-center justify-center shrink-0 group-hover:bg-accent`,children:(0,k.jsx)(n,{className:`size-4 text-muted-foreground`})}),(0,k.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,k.jsx)(`p`,{className:`text-sm font-medium truncate`,children:t.label}),(0,k.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:t.subtitle})]}),(0,k.jsx)(u,{className:`size-4 text-muted-foreground shrink-0`})]},t.id)})]},t.id)})})})}var M=e(t(),1),N={general:(0,M.lazy)(()=>y(()=>import(`./general-settings-section--DSUTrEP.js`).then(e=>({default:e.GeneralSettingsSection})),__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]))),appearance:(0,M.lazy)(()=>y(()=>import(`./appearance-settings-section-DACtiDor.js`).then(e=>({default:e.AppearanceSettingsSection})),__vite__mapDeps([40,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,39]))),"ai-provider":(0,M.lazy)(()=>y(()=>import(`./ai-settings-section-BlKlcihJ.js`).then(e=>({default:e.AISettingsSection})),__vite__mapDeps([41,3,1,4,5,6,7,9,11,10,13,42,2,8,12,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,43]))),accounts:(0,M.lazy)(()=>y(()=>import(`./accounts-settings-section-Cs7BC5O1.js`).then(e=>({default:e.AccountsSettingsSection})),__vite__mapDeps([44,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,45,43]))),ppmbot:(0,M.lazy)(()=>y(()=>import(`./ppmbot-settings-section-DF0kqdyO.js`).then(e=>({default:e.PPMBotSettingsSection})),__vite__mapDeps([46,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,39]))),notifications:(0,M.lazy)(()=>y(()=>import(`./notifications-settings-section-Bfxqz65i.js`).then(e=>({default:e.NotificationsSettingsSection})),__vite__mapDeps([47,4,1,5,39,7,19]))),jira:(0,M.lazy)(()=>y(()=>import(`./jira-watcher-section-DoXl0GAq.js`).then(e=>({default:e.JiraWatcherSection})),__vite__mapDeps([48,2,1,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]))),extensions:(0,M.lazy)(()=>y(()=>import(`./extension-manager-section-CL7pl3re.js`).then(e=>({default:e.ExtensionManagerSection})),__vite__mapDeps([49,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]))),proxy:(0,M.lazy)(()=>y(()=>import(`./proxy-settings-section-Q-ttqVOa.js`).then(e=>({default:e.ProxySettingsSection})),__vite__mapDeps([50,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,43]))),schedules:(0,M.lazy)(()=>y(()=>import(`./schedules-settings-section-Bv_wrzDp.js`).then(e=>({default:e.SchedulesSettingsSection})),__vite__mapDeps([51,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]))),shortcuts:(0,M.lazy)(()=>y(()=>import(`./keyboard-shortcuts-section-BogwnAdr.js`).then(e=>({default:e.KeyboardShortcutsSection})),__vite__mapDeps([52,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]))),files:(0,M.lazy)(()=>y(()=>import(`./files-settings-section-C574RfCl.js`).then(e=>({default:e.FilesSettingsSection})),__vite__mapDeps([53,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,39]))),"query-audit":(0,M.lazy)(()=>y(()=>import(`./query-audit-section-Cn11xqgz.js`).then(e=>({default:e.QueryAuditSection})),__vite__mapDeps([54,1,4,5,6,7,9,24,43,19])))};function P({category:e}){let t=N[e];return(0,k.jsx)(M.Suspense,{fallback:(0,k.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,k.jsx)(h,{className:`size-5 animate-spin text-muted-foreground`})}),children:(0,k.jsx)(t,{})})}function F({initialCategory:e,onCategoryChange:t}){let[n,r]=(0,M.useState)(e??`general`),[i,a]=(0,M.useState)(e===void 0),o=D(n),s=o.icon;function c(e){r(e),a(!1),t?.(e)}return(0,k.jsx)(`div`,{className:`@container h-full w-full`,"data-testid":`settings-window`,"data-category":n,children:(0,k.jsxs)(`div`,{className:`h-full w-full flex`,children:[(0,k.jsx)(`aside`,{className:`hidden @[640px]:flex @[640px]:flex-col w-[210px] shrink-0 border-r border-border min-h-0`,"data-testid":`settings-rail`,children:(0,k.jsx)(A,{active:n,onSelect:c})}),(0,k.jsxs)(`div`,{className:`relative flex-1 min-w-0`,children:[(0,k.jsxs)(`div`,{className:`h-full flex flex-col min-h-0`,children:[(0,k.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 px-2 py-2.5 @[640px]:px-4`,children:[(0,k.jsx)(x,{variant:`ghost`,size:`icon`,"aria-label":`Back to settings list`,className:`size-9 shrink-0 cursor-pointer @[640px]:hidden`,onClick:()=>a(!0),children:(0,k.jsx)(d,{className:`size-4`})}),(0,k.jsx)(s,{className:`size-4 text-muted-foreground shrink-0`}),(0,k.jsx)(`h2`,{className:`text-sm font-semibold truncate`,"data-testid":`settings-pane-title`,children:o.label})]}),(0,k.jsx)(C,{}),(0,k.jsx)(S,{className:`flex-1 min-h-0`,children:(0,k.jsx)(`div`,{className:`p-4 pb-8`,children:(0,k.jsx)(P,{category:n})})})]}),i&&(0,k.jsxs)(`div`,{className:`absolute inset-0 z-10 bg-background flex flex-col min-h-0 @[640px]:hidden`,"data-testid":`settings-index`,children:[(0,k.jsx)(`div`,{className:`shrink-0 px-4 py-3`,children:(0,k.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Settings`})}),(0,k.jsx)(C,{}),(0,k.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,k.jsx)(j,{onSelect:c})})]})]})]})})}export{E as n,F as t};
@@ -1 +1 @@
1
- import{S as e}from"./vendor-markdown-QKPNiWEd.js";import"./vendor-ui-BHh12_0v.js";import"./icons-C9ZwXgel.js";import"./vendor-mermaid-eg2XWIjK.js";import"./button-CBehaXpV.js";import"./scroll-area-xAtds1T-.js";import"./separator-D8SNZI6E.js";import{n as t,t as n}from"./settings-body-DU3LZkOy.js";var r=e(),i=({metadata:e})=>(0,r.jsx)(n,{initialCategory:t(e?.category)?e.category:void 0});export{i as SettingsTab};
1
+ import{S as e}from"./vendor-markdown-QKPNiWEd.js";import"./vendor-ui-BHh12_0v.js";import"./icons-CO_II6D-.js";import"./vendor-mermaid-eg2XWIjK.js";import"./button-CBehaXpV.js";import"./scroll-area-xAtds1T-.js";import"./separator-D8SNZI6E.js";import{n as t,t as n}from"./settings-body-C5_chEpq.js";var r=e(),i=({metadata:e})=>(0,r.jsx)(n,{initialCategory:t(e?.category)?e.category:void 0});export{i as SettingsTab};