@hienlh/ppm 0.22.8 → 0.22.10

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 (315) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/CLAUDE.md +3 -0
  3. package/assets/skills/ppm/SKILL.md +1 -1
  4. package/assets/skills/ppm/references/http-api.md +11 -1
  5. package/bun.lock +10 -10
  6. package/dist/web/assets/accounts-settings-section-BYz8j7Fq.js +1 -0
  7. package/dist/web/assets/accounts-settings-section-BYz8j7Fq.js.br +0 -0
  8. package/dist/web/assets/accounts-settings-section-BYz8j7Fq.js.gz +0 -0
  9. package/dist/web/assets/{ai-resource-editor-CtvWAxMW.js → ai-resource-editor-K7Q5d1jo.js} +1 -1
  10. package/dist/web/assets/ai-resource-editor-K7Q5d1jo.js.br +0 -0
  11. package/dist/web/assets/ai-resource-editor-K7Q5d1jo.js.gz +0 -0
  12. package/dist/web/assets/ai-settings-section-ChEBg9Be.js +1 -0
  13. package/dist/web/assets/ai-settings-section-CyWSTidP.js +1 -0
  14. package/dist/web/assets/ai-settings-section-CyWSTidP.js.br +0 -0
  15. package/dist/web/assets/ai-settings-section-CyWSTidP.js.gz +0 -0
  16. package/dist/web/assets/{appearance-settings-section-DRWpbQqj.js → appearance-settings-section-DH0DxaKv.js} +1 -1
  17. package/dist/web/assets/appearance-settings-section-DH0DxaKv.js.br +0 -0
  18. package/dist/web/assets/appearance-settings-section-DH0DxaKv.js.gz +0 -0
  19. package/dist/web/assets/{branch-review-tab-B3BMVCdK.js → branch-review-tab-BjPYFJ7n.js} +1 -1
  20. package/dist/web/assets/branch-review-tab-BjPYFJ7n.js.br +0 -0
  21. package/dist/web/assets/branch-review-tab-BjPYFJ7n.js.gz +0 -0
  22. package/dist/web/assets/chat-tab-BFrvTu8k.js +15 -0
  23. package/dist/web/assets/chat-tab-BFrvTu8k.js.br +0 -0
  24. package/dist/web/assets/chat-tab-BFrvTu8k.js.gz +0 -0
  25. package/dist/web/assets/code-editor-CTTLNDyE.js +7 -0
  26. package/dist/web/assets/code-editor-CTTLNDyE.js.br +0 -0
  27. package/dist/web/assets/code-editor-CTTLNDyE.js.gz +0 -0
  28. package/dist/web/assets/{codex-daily-guard-DjLeZ_hE.js → codex-daily-guard-PsB0g8B0.js} +1 -1
  29. package/dist/web/assets/codex-daily-guard-PsB0g8B0.js.br +0 -0
  30. package/dist/web/assets/codex-daily-guard-PsB0g8B0.js.gz +0 -0
  31. package/dist/web/assets/{conflict-editor-Dx8MnO6j.js → conflict-editor-BoLsr5fL.js} +1 -1
  32. package/dist/web/assets/conflict-editor-BoLsr5fL.js.br +0 -0
  33. package/dist/web/assets/conflict-editor-BoLsr5fL.js.gz +0 -0
  34. package/dist/web/assets/{csv-preview-U-Fy9KPT.js → csv-preview-C-7PUd6W.js} +1 -1
  35. package/dist/web/assets/csv-preview-C-7PUd6W.js.br +0 -0
  36. package/dist/web/assets/csv-preview-C-7PUd6W.js.gz +0 -0
  37. package/dist/web/assets/database-viewer-BJgZ-0s2.js +1 -0
  38. package/dist/web/assets/database-viewer-BJgZ-0s2.js.br +0 -0
  39. package/dist/web/assets/database-viewer-BJgZ-0s2.js.gz +0 -0
  40. package/dist/web/assets/{diff-viewer-Bv2J64t8.js → diff-viewer-i0_wCJL2.js} +1 -1
  41. package/dist/web/assets/diff-viewer-i0_wCJL2.js.br +0 -0
  42. package/dist/web/assets/diff-viewer-i0_wCJL2.js.gz +0 -0
  43. package/dist/web/assets/{editor-language-service-C1J6iorq.js → editor-language-service-DDhZjZqB.js} +1 -1
  44. package/dist/web/assets/editor-language-service-DDhZjZqB.js.br +0 -0
  45. package/dist/web/assets/editor-language-service-DDhZjZqB.js.gz +0 -0
  46. package/dist/web/assets/explorer-body-DeIIj3uF.js +2 -0
  47. package/dist/web/assets/explorer-body-DeIIj3uF.js.br +0 -0
  48. package/dist/web/assets/explorer-body-DeIIj3uF.js.gz +0 -0
  49. package/dist/web/assets/{explorer-window-content-CZIwX6cE.js → explorer-window-content-D0i22zgM.js} +1 -1
  50. package/dist/web/assets/explorer-window-content-D0i22zgM.js.br +0 -0
  51. package/dist/web/assets/explorer-window-content-D0i22zgM.js.gz +0 -0
  52. package/dist/web/assets/{extension-manager-section-DGSKz5iJ.js → extension-manager-section-D8TSwRG8.js} +1 -1
  53. package/dist/web/assets/extension-manager-section-D8TSwRG8.js.br +0 -0
  54. package/dist/web/assets/extension-manager-section-D8TSwRG8.js.gz +0 -0
  55. package/dist/web/assets/{extension-webview-FuuXP0Aw.js → extension-webview-CfzJpLQR.js} +1 -1
  56. package/dist/web/assets/extension-webview-CfzJpLQR.js.br +0 -0
  57. package/dist/web/assets/extension-webview-CfzJpLQR.js.gz +0 -0
  58. package/dist/web/assets/{files-settings-section-CGd2yfzl.js → files-settings-section-Ne10pnQU.js} +1 -1
  59. package/dist/web/assets/files-settings-section-Ne10pnQU.js.br +0 -0
  60. package/dist/web/assets/files-settings-section-Ne10pnQU.js.gz +0 -0
  61. package/dist/web/assets/{general-settings-section-CcG10nJq.js → general-settings-section-fbSqpiKY.js} +1 -1
  62. package/dist/web/assets/general-settings-section-fbSqpiKY.js.br +0 -0
  63. package/dist/web/assets/general-settings-section-fbSqpiKY.js.gz +0 -0
  64. package/dist/web/assets/{git-log-panel-B-aSlSlu.js → git-log-panel-9mRsulRQ.js} +1 -1
  65. package/dist/web/assets/git-log-panel-9mRsulRQ.js.br +0 -0
  66. package/dist/web/assets/git-log-panel-9mRsulRQ.js.gz +0 -0
  67. package/dist/web/assets/{glide-data-grid-usB_4gTg.js → glide-data-grid-OhxZFlYg.js} +3 -3
  68. package/dist/web/assets/glide-data-grid-OhxZFlYg.js.br +0 -0
  69. package/dist/web/assets/glide-data-grid-OhxZFlYg.js.gz +0 -0
  70. package/dist/web/assets/group-chat-tab-4DdMvOkG.js +1 -0
  71. package/dist/web/assets/group-chat-tab-4DdMvOkG.js.br +0 -0
  72. package/dist/web/assets/group-chat-tab-4DdMvOkG.js.gz +0 -0
  73. package/dist/web/assets/index-C3v3QRVR.js +52 -0
  74. package/dist/web/assets/index-C3v3QRVR.js.br +0 -0
  75. package/dist/web/assets/index-C3v3QRVR.js.gz +0 -0
  76. package/dist/web/assets/index-aXJy_SvC.css +1 -0
  77. package/dist/web/assets/index-aXJy_SvC.css.br +0 -0
  78. package/dist/web/assets/index-aXJy_SvC.css.gz +0 -0
  79. package/dist/web/assets/{jira-watcher-section-cDMBzIR7.js → jira-watcher-section-PYPh3xGU.js} +1 -1
  80. package/dist/web/assets/jira-watcher-section-PYPh3xGU.js.br +0 -0
  81. package/dist/web/assets/jira-watcher-section-PYPh3xGU.js.gz +0 -0
  82. package/dist/web/assets/keybindings-store-DhAtn4Pd.js +1 -0
  83. package/dist/web/assets/{keyboard-shortcuts-section-CIcdYToP.js → keyboard-shortcuts-section-CM3pNiBR.js} +1 -1
  84. package/dist/web/assets/keyboard-shortcuts-section-CM3pNiBR.js.br +0 -0
  85. package/dist/web/assets/keyboard-shortcuts-section-CM3pNiBR.js.gz +0 -0
  86. package/dist/web/assets/{markdown-renderer-BzX5WysW.js → markdown-renderer-Df1vynCr.js} +1 -1
  87. package/dist/web/assets/{markdown-renderer-KTNg80_A.js → markdown-renderer-DqNZUt1S.js} +3 -3
  88. package/dist/web/assets/markdown-renderer-DqNZUt1S.js.br +0 -0
  89. package/dist/web/assets/{markdown-renderer-KTNg80_A.js.gz → markdown-renderer-DqNZUt1S.js.gz} +0 -0
  90. package/dist/web/assets/{mobile-explorer-sheet-cnwXe-Uz.js → mobile-explorer-sheet-BSuzC_08.js} +1 -1
  91. package/dist/web/assets/mobile-explorer-sheet-BSuzC_08.js.br +0 -0
  92. package/dist/web/assets/mobile-explorer-sheet-BSuzC_08.js.gz +0 -0
  93. package/dist/web/assets/notification-store-DbKwLWwl.js +1 -0
  94. package/dist/web/assets/{ppmbot-settings-section-CDp69sHV.js → ppmbot-settings-section-CY_yAGFM.js} +1 -1
  95. package/dist/web/assets/ppmbot-settings-section-CY_yAGFM.js.br +0 -0
  96. package/dist/web/assets/ppmbot-settings-section-CY_yAGFM.js.gz +0 -0
  97. package/dist/web/assets/{problems-panel-BiE3c-31.js → problems-panel-CJNasbnt.js} +1 -1
  98. package/dist/web/assets/problems-panel-CJNasbnt.js.br +0 -0
  99. package/dist/web/assets/problems-panel-CJNasbnt.js.gz +0 -0
  100. package/dist/web/assets/{process-table-DcEq9HCl.js → process-table-1CN3rBVp.js} +1 -1
  101. package/dist/web/assets/process-table-1CN3rBVp.js.br +0 -0
  102. package/dist/web/assets/process-table-1CN3rBVp.js.gz +0 -0
  103. package/dist/web/assets/{proxy-settings-section-P_ULFRpZ.js → proxy-settings-section-CqcvneFB.js} +1 -1
  104. package/dist/web/assets/proxy-settings-section-CqcvneFB.js.br +0 -0
  105. package/dist/web/assets/proxy-settings-section-CqcvneFB.js.gz +0 -0
  106. package/dist/web/assets/{remote-desktop-clipboard-notice-COjdmADR.js → remote-desktop-clipboard-notice-BysFGa_4.js} +1 -1
  107. package/dist/web/assets/remote-desktop-clipboard-notice-BysFGa_4.js.br +0 -0
  108. package/dist/web/assets/remote-desktop-clipboard-notice-BysFGa_4.js.gz +0 -0
  109. package/dist/web/assets/{remote-desktop-mobile-sheet-lCU5l2w4.js → remote-desktop-mobile-sheet-DLW_0HDz.js} +2 -2
  110. package/dist/web/assets/remote-desktop-mobile-sheet-DLW_0HDz.js.br +0 -0
  111. package/dist/web/assets/remote-desktop-mobile-sheet-DLW_0HDz.js.gz +0 -0
  112. package/dist/web/assets/{remote-desktop-mobile-view-Bo-wgZPC.js → remote-desktop-mobile-view-Df6SfRtI.js} +1 -1
  113. package/dist/web/assets/remote-desktop-mobile-view-Df6SfRtI.js.br +0 -0
  114. package/dist/web/assets/remote-desktop-mobile-view-Df6SfRtI.js.gz +0 -0
  115. package/dist/web/assets/{remote-desktop-readiness-gate-Cqz8kqWG.js → remote-desktop-readiness-gate-LugXhLJ3.js} +1 -1
  116. package/dist/web/assets/remote-desktop-readiness-gate-LugXhLJ3.js.br +0 -0
  117. package/dist/web/assets/remote-desktop-readiness-gate-LugXhLJ3.js.gz +0 -0
  118. package/dist/web/assets/remote-desktop-window-content-k-pIAIDq.js +1 -0
  119. package/dist/web/assets/remote-desktop-window-content-k-pIAIDq.js.br +0 -0
  120. package/dist/web/assets/remote-desktop-window-content-k-pIAIDq.js.gz +0 -0
  121. package/dist/web/assets/{schedules-settings-section-DHs84DvG.js → schedules-settings-section-ByCm7IOg.js} +1 -1
  122. package/dist/web/assets/schedules-settings-section-ByCm7IOg.js.br +0 -0
  123. package/dist/web/assets/schedules-settings-section-ByCm7IOg.js.gz +0 -0
  124. package/dist/web/assets/{settings-body-CLt6iutX.js → settings-body-Dwt_rUSa.js} +2 -2
  125. package/dist/web/assets/settings-body-Dwt_rUSa.js.br +0 -0
  126. package/dist/web/assets/settings-body-Dwt_rUSa.js.gz +0 -0
  127. package/dist/web/assets/settings-store-m6qOXoy4.js +2 -0
  128. package/dist/web/assets/settings-store-m6qOXoy4.js.br +0 -0
  129. package/dist/web/assets/settings-store-m6qOXoy4.js.gz +0 -0
  130. package/dist/web/assets/{settings-tab-DjOxh-vW.js → settings-tab-Dvj9UfzL.js} +1 -1
  131. package/dist/web/assets/{settings-window-content-BxzSerga.js → settings-window-content-Di-eONmj.js} +1 -1
  132. package/dist/web/assets/{sql-query-editor-4Okd-7ss.js → sql-query-editor-DgwwJxwJ.js} +1 -1
  133. package/dist/web/assets/sql-query-editor-DgwwJxwJ.js.br +0 -0
  134. package/dist/web/assets/sql-query-editor-DgwwJxwJ.js.gz +0 -0
  135. package/dist/web/assets/{sqlite-viewer-BqDUckIJ.js → sqlite-viewer-gxiJZ3kk.js} +1 -1
  136. package/dist/web/assets/sqlite-viewer-gxiJZ3kk.js.br +0 -0
  137. package/dist/web/assets/sqlite-viewer-gxiJZ3kk.js.gz +0 -0
  138. package/dist/web/assets/{system-monitor-body-Ssmt-r5H.js → system-monitor-body-BJrVntEe.js} +2 -2
  139. package/dist/web/assets/system-monitor-body-BJrVntEe.js.br +0 -0
  140. package/dist/web/assets/system-monitor-body-BJrVntEe.js.gz +0 -0
  141. package/dist/web/assets/{system-monitor-tab-DNe62hWL.js → system-monitor-tab-Uz9A5I07.js} +1 -1
  142. package/dist/web/assets/{system-monitor-window-content-C6vnW_pQ.js → system-monitor-window-content-9cKlCVN0.js} +1 -1
  143. package/dist/web/assets/{tab-host-window-content--BVyPR1f.js → tab-host-window-content-D3M-lRyv.js} +1 -1
  144. package/dist/web/assets/tab-host-window-content-D3M-lRyv.js.br +0 -0
  145. package/dist/web/assets/tab-host-window-content-D3M-lRyv.js.gz +0 -0
  146. package/dist/web/assets/{team-member-sheet-CE2eHuFX.js → team-member-sheet-D66xVR6G.js} +2 -2
  147. package/dist/web/assets/team-member-sheet-D66xVR6G.js.br +0 -0
  148. package/dist/web/assets/team-member-sheet-D66xVR6G.js.gz +0 -0
  149. package/dist/web/assets/{team-member-window-content-B1sg0R4H.js → team-member-window-content-D6SxpWVr.js} +1 -1
  150. package/dist/web/assets/team-member-window-content-D6SxpWVr.js.br +0 -0
  151. package/dist/web/assets/team-member-window-content-D6SxpWVr.js.gz +0 -0
  152. package/dist/web/assets/{terminal-tab-BrdS4bAy.js → terminal-tab-DUfOyHxp.js} +3 -3
  153. package/dist/web/assets/terminal-tab-DUfOyHxp.js.br +0 -0
  154. package/dist/web/assets/terminal-tab-DUfOyHxp.js.gz +0 -0
  155. package/dist/web/assets/{tool-cards-DzYJVhjl.js → tool-cards-O9N-oJuB.js} +3 -3
  156. package/dist/web/assets/tool-cards-O9N-oJuB.js.br +0 -0
  157. package/dist/web/assets/tool-cards-O9N-oJuB.js.gz +0 -0
  158. package/dist/web/assets/{use-inline-blame-CKu-Sd-l.js → use-inline-blame-B40AsaN2.js} +1 -1
  159. package/dist/web/assets/use-inline-blame-B40AsaN2.js.br +0 -0
  160. package/dist/web/assets/use-inline-blame-B40AsaN2.js.gz +0 -0
  161. package/dist/web/assets/{use-lsp-BaG0NUXY.js → use-lsp-B30TcKvt.js} +1 -1
  162. package/dist/web/assets/use-lsp-B30TcKvt.js.br +0 -0
  163. package/dist/web/assets/use-lsp-B30TcKvt.js.gz +0 -0
  164. package/dist/web/assets/{use-monaco-theme-DvWcXiCH.js → use-monaco-theme-DGi9_j5M.js} +1 -1
  165. package/dist/web/assets/{use-websocket-Dj0e6N6t.js → use-websocket-DdGdvJc5.js} +1 -1
  166. package/dist/web/assets/video-preview-RS5jKlrC.js +1 -0
  167. package/dist/web/assets/video-preview-RS5jKlrC.js.br +0 -0
  168. package/dist/web/assets/video-preview-RS5jKlrC.js.gz +0 -0
  169. package/dist/web/index.html +3 -3
  170. package/dist/web/index.html.br +0 -0
  171. package/dist/web/index.html.gz +0 -0
  172. package/dist/web/sw.js +1 -1
  173. package/dist/web/sw.js.br +0 -0
  174. package/dist/web/sw.js.gz +0 -0
  175. package/docs/codebase-summary.md +1 -1
  176. package/docs/project-roadmap.md +1 -1
  177. package/package.json +2 -2
  178. package/src/providers/claude-agent-sdk.ts +87 -8
  179. package/src/server/index.ts +9 -0
  180. package/src/server/routes/mcp-auth.ts +117 -0
  181. package/src/server/routes/settings.ts +2 -0
  182. package/src/server/ws/chat-mcp-sign-in-sync.ts +58 -0
  183. package/src/server/ws/chat.ts +35 -1
  184. package/src/services/mcp-oauth/mcp-control-query.ts +58 -0
  185. package/src/services/mcp-oauth/mcp-oauth-flows.ts +271 -0
  186. package/src/services/mcp-oauth/mcp-oauth-redirect.ts +68 -0
  187. package/src/services/mcp-oauth/mcp-status-probe.ts +76 -0
  188. package/src/web/components/ai-resources/ai-resources-panel.tsx +4 -0
  189. package/src/web/components/chat/chat-tab.tsx +5 -0
  190. package/src/web/components/mcp-auth/claude-ai-connector.ts +11 -0
  191. package/src/web/components/mcp-auth/mcp-server-name.ts +10 -0
  192. package/src/web/components/mcp-auth/mcp-sign-in-bar.tsx +74 -0
  193. package/src/web/components/mcp-auth/mcp-sign-in-dialog.tsx +196 -0
  194. package/src/web/components/mcp-auth/mcp-sign-in-list.tsx +110 -0
  195. package/src/web/components/mcp-auth/use-mcp-sign-in-flow.ts +120 -0
  196. package/src/web/components/settings/ai-settings-section.tsx +11 -0
  197. package/src/web/hooks/use-chat.ts +14 -0
  198. package/src/web/lib/api-mcp-auth.ts +54 -0
  199. package/src/web/stores/settings-store.ts +34 -0
  200. package/dist/web/assets/accounts-settings-section-Dk9qWWTy.js +0 -1
  201. package/dist/web/assets/accounts-settings-section-Dk9qWWTy.js.br +0 -0
  202. package/dist/web/assets/accounts-settings-section-Dk9qWWTy.js.gz +0 -0
  203. package/dist/web/assets/ai-resource-editor-CtvWAxMW.js.br +0 -0
  204. package/dist/web/assets/ai-resource-editor-CtvWAxMW.js.gz +0 -0
  205. package/dist/web/assets/ai-settings-section-BxN-zFfm.js +0 -1
  206. package/dist/web/assets/ai-settings-section-CfI9nNSa.js +0 -1
  207. package/dist/web/assets/ai-settings-section-CfI9nNSa.js.br +0 -0
  208. package/dist/web/assets/ai-settings-section-CfI9nNSa.js.gz +0 -0
  209. package/dist/web/assets/appearance-settings-section-DRWpbQqj.js.br +0 -0
  210. package/dist/web/assets/appearance-settings-section-DRWpbQqj.js.gz +0 -0
  211. package/dist/web/assets/branch-review-tab-B3BMVCdK.js.br +0 -0
  212. package/dist/web/assets/branch-review-tab-B3BMVCdK.js.gz +0 -0
  213. package/dist/web/assets/chat-tab-B0g-TzDa.js +0 -15
  214. package/dist/web/assets/chat-tab-B0g-TzDa.js.br +0 -0
  215. package/dist/web/assets/chat-tab-B0g-TzDa.js.gz +0 -0
  216. package/dist/web/assets/code-editor-DXra_Rnt.js +0 -7
  217. package/dist/web/assets/code-editor-DXra_Rnt.js.br +0 -0
  218. package/dist/web/assets/code-editor-DXra_Rnt.js.gz +0 -0
  219. package/dist/web/assets/codex-daily-guard-DjLeZ_hE.js.br +0 -0
  220. package/dist/web/assets/codex-daily-guard-DjLeZ_hE.js.gz +0 -0
  221. package/dist/web/assets/conflict-editor-Dx8MnO6j.js.br +0 -0
  222. package/dist/web/assets/conflict-editor-Dx8MnO6j.js.gz +0 -0
  223. package/dist/web/assets/csv-preview-U-Fy9KPT.js.br +0 -0
  224. package/dist/web/assets/csv-preview-U-Fy9KPT.js.gz +0 -0
  225. package/dist/web/assets/database-viewer-v5S-zzB6.js +0 -1
  226. package/dist/web/assets/database-viewer-v5S-zzB6.js.br +0 -0
  227. package/dist/web/assets/database-viewer-v5S-zzB6.js.gz +0 -0
  228. package/dist/web/assets/diff-viewer-Bv2J64t8.js.br +0 -0
  229. package/dist/web/assets/diff-viewer-Bv2J64t8.js.gz +0 -0
  230. package/dist/web/assets/editor-language-service-C1J6iorq.js.br +0 -0
  231. package/dist/web/assets/editor-language-service-C1J6iorq.js.gz +0 -0
  232. package/dist/web/assets/explorer-body-BpTOY2kH.js +0 -2
  233. package/dist/web/assets/explorer-body-BpTOY2kH.js.br +0 -0
  234. package/dist/web/assets/explorer-body-BpTOY2kH.js.gz +0 -0
  235. package/dist/web/assets/explorer-window-content-CZIwX6cE.js.br +0 -0
  236. package/dist/web/assets/explorer-window-content-CZIwX6cE.js.gz +0 -0
  237. package/dist/web/assets/extension-manager-section-DGSKz5iJ.js.br +0 -0
  238. package/dist/web/assets/extension-manager-section-DGSKz5iJ.js.gz +0 -0
  239. package/dist/web/assets/extension-webview-FuuXP0Aw.js.br +0 -0
  240. package/dist/web/assets/extension-webview-FuuXP0Aw.js.gz +0 -0
  241. package/dist/web/assets/files-settings-section-CGd2yfzl.js.br +0 -0
  242. package/dist/web/assets/files-settings-section-CGd2yfzl.js.gz +0 -0
  243. package/dist/web/assets/general-settings-section-CcG10nJq.js.br +0 -0
  244. package/dist/web/assets/general-settings-section-CcG10nJq.js.gz +0 -0
  245. package/dist/web/assets/git-log-panel-B-aSlSlu.js.br +0 -0
  246. package/dist/web/assets/git-log-panel-B-aSlSlu.js.gz +0 -0
  247. package/dist/web/assets/glide-data-grid-usB_4gTg.js.br +0 -0
  248. package/dist/web/assets/glide-data-grid-usB_4gTg.js.gz +0 -0
  249. package/dist/web/assets/group-chat-tab-BAMi_dhb.js +0 -1
  250. package/dist/web/assets/group-chat-tab-BAMi_dhb.js.br +0 -0
  251. package/dist/web/assets/group-chat-tab-BAMi_dhb.js.gz +0 -0
  252. package/dist/web/assets/index-CoTvom0K.js +0 -52
  253. package/dist/web/assets/index-CoTvom0K.js.br +0 -0
  254. package/dist/web/assets/index-CoTvom0K.js.gz +0 -0
  255. package/dist/web/assets/index-DLn9-Lrb.css +0 -1
  256. package/dist/web/assets/index-DLn9-Lrb.css.br +0 -0
  257. package/dist/web/assets/index-DLn9-Lrb.css.gz +0 -0
  258. package/dist/web/assets/jira-watcher-section-cDMBzIR7.js.br +0 -3
  259. package/dist/web/assets/jira-watcher-section-cDMBzIR7.js.gz +0 -0
  260. package/dist/web/assets/keybindings-store-D7nwnInl.js +0 -1
  261. package/dist/web/assets/keyboard-shortcuts-section-CIcdYToP.js.br +0 -0
  262. package/dist/web/assets/keyboard-shortcuts-section-CIcdYToP.js.gz +0 -0
  263. package/dist/web/assets/markdown-renderer-KTNg80_A.js.br +0 -0
  264. package/dist/web/assets/mobile-explorer-sheet-cnwXe-Uz.js.br +0 -0
  265. package/dist/web/assets/mobile-explorer-sheet-cnwXe-Uz.js.gz +0 -0
  266. package/dist/web/assets/notification-store-Bayjh6Js.js +0 -1
  267. package/dist/web/assets/ppmbot-settings-section-CDp69sHV.js.br +0 -0
  268. package/dist/web/assets/ppmbot-settings-section-CDp69sHV.js.gz +0 -0
  269. package/dist/web/assets/problems-panel-BiE3c-31.js.br +0 -0
  270. package/dist/web/assets/problems-panel-BiE3c-31.js.gz +0 -0
  271. package/dist/web/assets/process-table-DcEq9HCl.js.br +0 -0
  272. package/dist/web/assets/process-table-DcEq9HCl.js.gz +0 -0
  273. package/dist/web/assets/proxy-settings-section-P_ULFRpZ.js.br +0 -0
  274. package/dist/web/assets/proxy-settings-section-P_ULFRpZ.js.gz +0 -0
  275. package/dist/web/assets/remote-desktop-clipboard-notice-COjdmADR.js.br +0 -0
  276. package/dist/web/assets/remote-desktop-clipboard-notice-COjdmADR.js.gz +0 -0
  277. package/dist/web/assets/remote-desktop-mobile-sheet-lCU5l2w4.js.br +0 -0
  278. package/dist/web/assets/remote-desktop-mobile-sheet-lCU5l2w4.js.gz +0 -0
  279. package/dist/web/assets/remote-desktop-mobile-view-Bo-wgZPC.js.br +0 -0
  280. package/dist/web/assets/remote-desktop-mobile-view-Bo-wgZPC.js.gz +0 -0
  281. package/dist/web/assets/remote-desktop-readiness-gate-Cqz8kqWG.js.br +0 -0
  282. package/dist/web/assets/remote-desktop-readiness-gate-Cqz8kqWG.js.gz +0 -0
  283. package/dist/web/assets/remote-desktop-window-content-R-aRW07B.js +0 -1
  284. package/dist/web/assets/remote-desktop-window-content-R-aRW07B.js.br +0 -0
  285. package/dist/web/assets/remote-desktop-window-content-R-aRW07B.js.gz +0 -0
  286. package/dist/web/assets/schedules-settings-section-DHs84DvG.js.br +0 -0
  287. package/dist/web/assets/schedules-settings-section-DHs84DvG.js.gz +0 -0
  288. package/dist/web/assets/settings-body-CLt6iutX.js.br +0 -0
  289. package/dist/web/assets/settings-body-CLt6iutX.js.gz +0 -0
  290. package/dist/web/assets/settings-store-tWrnlyEW.js +0 -2
  291. package/dist/web/assets/settings-store-tWrnlyEW.js.br +0 -0
  292. package/dist/web/assets/settings-store-tWrnlyEW.js.gz +0 -0
  293. package/dist/web/assets/sql-query-editor-4Okd-7ss.js.br +0 -0
  294. package/dist/web/assets/sql-query-editor-4Okd-7ss.js.gz +0 -0
  295. package/dist/web/assets/sqlite-viewer-BqDUckIJ.js.br +0 -0
  296. package/dist/web/assets/sqlite-viewer-BqDUckIJ.js.gz +0 -0
  297. package/dist/web/assets/system-monitor-body-Ssmt-r5H.js.br +0 -0
  298. package/dist/web/assets/system-monitor-body-Ssmt-r5H.js.gz +0 -0
  299. package/dist/web/assets/tab-host-window-content--BVyPR1f.js.br +0 -0
  300. package/dist/web/assets/tab-host-window-content--BVyPR1f.js.gz +0 -0
  301. package/dist/web/assets/team-member-sheet-CE2eHuFX.js.br +0 -0
  302. package/dist/web/assets/team-member-sheet-CE2eHuFX.js.gz +0 -0
  303. package/dist/web/assets/team-member-window-content-B1sg0R4H.js.br +0 -0
  304. package/dist/web/assets/team-member-window-content-B1sg0R4H.js.gz +0 -0
  305. package/dist/web/assets/terminal-tab-BrdS4bAy.js.br +0 -0
  306. package/dist/web/assets/terminal-tab-BrdS4bAy.js.gz +0 -0
  307. package/dist/web/assets/tool-cards-DzYJVhjl.js.br +0 -0
  308. package/dist/web/assets/tool-cards-DzYJVhjl.js.gz +0 -0
  309. package/dist/web/assets/use-inline-blame-CKu-Sd-l.js.br +0 -0
  310. package/dist/web/assets/use-inline-blame-CKu-Sd-l.js.gz +0 -0
  311. package/dist/web/assets/use-lsp-BaG0NUXY.js.br +0 -0
  312. package/dist/web/assets/use-lsp-BaG0NUXY.js.gz +0 -0
  313. package/dist/web/assets/video-preview-ZyRR49Lr.js +0 -1
  314. package/dist/web/assets/video-preview-ZyRR49Lr.js.br +0 -0
  315. package/dist/web/assets/video-preview-ZyRR49Lr.js.gz +0 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.22.10] - 2026-09-24
6
+
7
+ ### Added
8
+ - Sign in to MCP servers that need OAuth (Vanta, plugin connectors) from the chat's new sign-in bar, Settings → AI Provider, or the AI Resources panel; hiding the bar is remembered per server.
9
+
10
+ ## [0.22.9] - 2026-09-23
11
+
12
+ ### Fixed
13
+ - Chats on Claude Opus 5.5 no longer fail with "Claude Code 2.1.251 does not support this model"; the bundled Claude Agent SDK is now 0.3.280.
14
+
5
15
  ## [0.22.8] - 2026-09-23
6
16
 
7
17
  ### Fixed
package/CLAUDE.md CHANGED
@@ -155,6 +155,8 @@ Related: `configService.save()`/`set()` throw when `load()` has not run, because
155
155
  - **`opacity` is not a dimming level, it is a fade toward whatever is behind it — so one value cannot serve both modes**: the file explorer marked gitignored rows with `opacity-40`, which reads as a single decision and is not one. Measured against PPM's six built-in themes, that put a gitignored *filename* at **1.72–1.89:1** against the panel on the three light themes and 2.07–2.23:1 on the dark ones — unreadable on light, merely dim on dark, from the same class, so it reproduces only for whoever is on a light theme. A de-emphasised state has to be a **colour**: `--color-text-dim` is `color-mix(in srgb, var(--text-2) 50%, var(--text-3))`, which measures 3.59–5.21:1 across all six while staying visibly below `--text-2`. The file icon is then left alone entirely — those glyphs are `background-image` artwork with no `currentColor`, so an opacity on them is that same fade and nothing else, which is why the *folder* icon was the washed-out thing in the report. `tests/unit/web/explorer-ignored-contrast.test.ts` measures the hazard and the mitigation together and reads the mix out of `globals.css` rather than restating it, so the two cannot drift.
156
156
  - **Half of VS Code's compact folders is worse than none of it**: joining a single-child chain into one `a/b/c` row only makes sense if it happens on the way *in*, before the intermediate row is ever drawn. PPM's `flatten-visible-tree.ts` required both paths to be in `expandedPaths`, so it fired one gesture too late: clicking a folder made the row you clicked vanish upward into its parent and shifted everything below it a level left. `depth` is the load-bearing part — it becomes `paddingLeft`, so a compacted chain indented its children by how many rows were above them rather than by where they actually sit. It also leaked into four other files as an `effectiveNode`/`effectivePath` shadowing the real one (focus, range selection, the drop target, the inline-create target). One row per directory, always; `tests/unit/web/explorer-row-per-directory.test.ts` pins it.
157
157
 
158
+ - **MCP sign-in works in SDK mode, through methods `sdk.d.ts` does not declare**: a server the CLI reports as `needs-auth` (an HTTP server with OAuth such as Vanta, every plugin connector) used to be unusable from PPM because the CLI's `/mcp` screen does not exist without a terminal — and the model, reading the CLI's own "this session is non-interactive" hint, told users to go and open one. The `Query` object in fact carries `mcpAuthenticate(name, redirectUri?)` and `mcpSubmitOAuthCallbackUrl(name, url)` (in `sdk.mjs`, stripped from the typings), and a **prompt-less** streaming `query()` answers them — and `mcpServerStatus()` — in about a second with no model call. `src/services/mcp-oauth/` runs each sign-in in a subprocess of its own, and that process has to outlive the dialog's request: with the default `redirectScheme: "localhost"` the CLI's callback listener lives *inside* it, so closing it early strands the browser on a dead page. An https origin gets `redirectUri` pointed at PPM's public `GET /api/mcp-auth/callback` instead, which is what makes a phone over a tunnel work (Vanta accepts it); plain http falls back to the localhost listener plus a paste box. Four traps. The tokens land in the CLI's shared credential store, so a *running* chat still reports the server `needs-auth` until `reconnectMcpServer` is called in it — `chat-mcp-sign-in-sync.ts` does that, and drops an idle subprocess that still cannot see them. claude.ai connectors (`claude.ai <name>`, scope `claudeai`) answer "Server not found" to `mcp_authenticate` in SDK mode, so the UI sends them to claude.ai's connector settings rather than starting a flow that cannot succeed. The expiry timer only starts once there is a link, so `mcpAuthenticate` and the status probe's reads are wrapped in `withTimeout` — a CLI that never answers would otherwise hold its subprocess for as long as PPM runs, and every caller shares the probe. And in an e2e, Bun's `fetch` reuses a pooled socket the server has already closed after a long idle stretch, so a request silently never arrives: that read as a hung sign-in until the server log showed no `starting sign-in` line for it — `tests/e2e/mcp-sign-in-e2e.mjs` sends `Connection: close`. `tests/unit/services/mcp-oauth-flows.test.ts` greps `sdk.mjs` for the undeclared methods so an SDK upgrade that renames them fails a test rather than the button.
159
+
158
160
  ## UI Rules
159
161
 
160
162
  When creating or modifying any UI component, you MUST read and follow `docs/design-guidelines.md`, especially the **Mobile-First UI Rules** section. Key rules:
@@ -203,4 +205,5 @@ Before planning or implementing a new feature, read `docs/project-roadmap.md` to
203
205
  - `dist/web` asset pipeline — `scripts/copy-monaco.ts` stages `monaco-editor/min/vs` under `dist/web/assets/monaco/` (inside `assets/` so it inherits the immutable cache header, the SW runtime cache and the compressed siblings), `scripts/precompress-web.ts` writes `.br`/`.gz` siblings, and `src/server/routes/static-encoding.ts` chooses one per request (honouring `q=0` and `*`, keeping the original MIME, adding `Vary: Accept-Encoding` and the encoding in the ETag). Both scripts run after `build:web` in the `build` chain
204
206
  - `src/web/components/extensions/` — the webview host. `extension-webview.tsx` matches a panel to a tab and mounts its HTML as a sandboxed `srcDoc`; `webview-theme.ts` injects PPM's applied theme into it (mode attribute + token block) and forwards later theme changes by `postMessage`
205
207
  - `scripts/gen-nerd-font.ts` + `src/web/styles/nerd-font.generated.css` + `src/web/styles/fonts/` — the terminal's icon glyphs (Nerd Fonts symbols-only, MIT, ryanoasis/nerd-fonts), subset per icon set so each `@font-face` is fetched only when something draws a character in its range. Regenerate with `bun scripts/gen-nerd-font.ts` after editing its `BLOCKS`; `TERMINAL_FONT_FAMILY` in `src/web/lib/editor-font.ts` is what names the family, and `use-terminal.ts` is what invalidates xterm's glyph atlas when a face lands
208
+ - `src/services/mcp-oauth/` — MCP sign-in for `needs-auth` servers: `mcp-oauth-flows.ts` (one prompt-less Claude subprocess per flow, opened by the provider's `openMcpControlQuery`), `mcp-status-probe.ts` (cached per-directory status), `mcp-oauth-redirect.ts` (pure redirect/host rules). Routes `src/server/routes/mcp-auth.ts` (public `GET /api/mcp-auth/callback` mounted before auth), chat sync `src/server/ws/chat-mcp-sign-in-sync.ts`, UI `src/web/components/mcp-auth/` (dialog/bottom sheet, chat bar, the list shown in Settings → AI Provider and the AI Resources panel), e2e `tests/e2e/mcp-sign-in-e2e.mjs`
206
209
  - `src/services/named-tunnel/` — Named tunnel (stable `https://<prefix>.<zone>` URL via Cloudflare login), orchestrated from `src/server/routes/named-tunnel.ts`, spawned/probed by the supervisor; UI in `src/web/components/tunnels/named-tunnel/`
@@ -71,4 +71,4 @@ This skill covers the `ppm` CLI, its HTTP API, and its config DB. It does **not*
71
71
  - Third-party extensions (inspect via `ppm ext list`).
72
72
  - The Claude Agent SDK internals (separate skill).
73
73
 
74
- <!-- Generated for PPM v0.22.8 at build time. Re-run `ppm export skill --install` to refresh. -->
74
+ <!-- Generated for PPM v0.22.10 at build time. Re-run `ppm export skill --install` to refresh. -->
@@ -161,6 +161,16 @@ _Base URL: `http://localhost:8080` (default; override via `ppm config set port <
161
161
 
162
162
  - `POST /api/loopback/callback`
163
163
 
164
+ ## /api/mcp-auth
165
+
166
+ - `GET /api/mcp-auth/status`
167
+ - `POST /api/mcp-auth/start`
168
+ - `GET /api/mcp-auth/flows/:id`
169
+ - `POST /api/mcp-auth/flows/:id/callback`
170
+ - `POST /api/mcp-auth/flows/:id/confirm`
171
+ - `DELETE /api/mcp-auth/flows/:id`
172
+ - `GET /api/mcp-auth/state`
173
+
164
174
  ## /api/postgres
165
175
 
166
176
  - `POST /api/postgres/test`
@@ -349,4 +359,4 @@ _Base URL: `http://localhost:8080` (default; override via `ppm config set port <
349
359
  - `ws://<host>/ws/terminal` — PTY terminal multiplexer
350
360
  - `ws://<host>/ws/extensions` — extension host channel
351
361
 
352
- <!-- Generated from src/server/routes/ for PPM v0.22.8 -->
362
+ <!-- Generated from src/server/routes/ for PPM v0.22.10 -->
package/bun.lock CHANGED
@@ -5,7 +5,7 @@
5
5
  "": {
6
6
  "name": "ppm",
7
7
  "dependencies": {
8
- "@anthropic-ai/claude-agent-sdk": "0.3.251",
8
+ "@anthropic-ai/claude-agent-sdk": "0.3.280",
9
9
  "@codemirror/lang-sql": "^6.10.0",
10
10
  "@glideapps/glide-data-grid": "^6.0.3",
11
11
  "@inquirer/prompts": "^8.3.0",
@@ -105,23 +105,23 @@
105
105
  "packages": {
106
106
  "@antfu/install-pkg": ["@antfu/install-pkg@1.1.0", "", { "dependencies": { "package-manager-detector": "^1.3.0", "tinyexec": "^1.0.1" } }, "sha512-MGQsmw10ZyI+EJo45CdSER4zEb+p31LpDAFp2Z3gkSd1yqVZGi0Ebx++YTEMonJy4oChEMLsxZ64j8FH6sSqtQ=="],
107
107
 
108
- "@anthropic-ai/claude-agent-sdk": ["@anthropic-ai/claude-agent-sdk@0.3.251", "", { "optionalDependencies": { "@anthropic-ai/claude-agent-sdk-darwin-arm64": "0.3.251", "@anthropic-ai/claude-agent-sdk-darwin-x64": "0.3.251", "@anthropic-ai/claude-agent-sdk-linux-arm64": "0.3.251", "@anthropic-ai/claude-agent-sdk-linux-arm64-musl": "0.3.251", "@anthropic-ai/claude-agent-sdk-linux-x64": "0.3.251", "@anthropic-ai/claude-agent-sdk-linux-x64-musl": "0.3.251", "@anthropic-ai/claude-agent-sdk-win32-arm64": "0.3.251", "@anthropic-ai/claude-agent-sdk-win32-x64": "0.3.251" }, "peerDependencies": { "@anthropic-ai/sdk": ">=0.93.0", "@modelcontextprotocol/sdk": "^1.29.0", "zod": "^4.0.0" } }, "sha512-DqSi8mH2tQYRlVV0G+lJnQ/WbjJZ/a+8cJ3vPuYoqh8esIIvXHm1ZOXV1UPGsFYRnbBytEoiSGitguEXd+sQ+Q=="],
108
+ "@anthropic-ai/claude-agent-sdk": ["@anthropic-ai/claude-agent-sdk@0.3.280", "", { "optionalDependencies": { "@anthropic-ai/claude-agent-sdk-darwin-arm64": "0.3.280", "@anthropic-ai/claude-agent-sdk-darwin-x64": "0.3.280", "@anthropic-ai/claude-agent-sdk-linux-arm64": "0.3.280", "@anthropic-ai/claude-agent-sdk-linux-arm64-musl": "0.3.280", "@anthropic-ai/claude-agent-sdk-linux-x64": "0.3.280", "@anthropic-ai/claude-agent-sdk-linux-x64-musl": "0.3.280", "@anthropic-ai/claude-agent-sdk-win32-arm64": "0.3.280", "@anthropic-ai/claude-agent-sdk-win32-x64": "0.3.280" }, "peerDependencies": { "@anthropic-ai/sdk": ">=0.93.0", "@modelcontextprotocol/sdk": "^1.29.0", "zod": "^4.0.0" } }, "sha512-aIQSTKcCJcOgi125GAGQaNZUYgxbEBQwV2Ac+Utp0+gGUjIEWjTqz4B8kXr9XjkcCTYiRUMTDsXPAUfIcBDjnw=="],
109
109
 
110
- "@anthropic-ai/claude-agent-sdk-darwin-arm64": ["@anthropic-ai/claude-agent-sdk-darwin-arm64@0.3.251", "", { "os": "darwin", "cpu": "arm64" }, "sha512-C23h+Dbddcc4gai95+lhm4/94am2IOq+bf3IdEDDS7EPqDQqajo2s5q1/ZSwq9rOc0RJLT7Ws72ZCzYJh67KSg=="],
110
+ "@anthropic-ai/claude-agent-sdk-darwin-arm64": ["@anthropic-ai/claude-agent-sdk-darwin-arm64@0.3.280", "", { "os": "darwin", "cpu": "arm64" }, "sha512-Yws14X5g5hgDtF565Tld/+dILAhH9QZpundjKMyO3dFasq9miXZlhU0NwXqwTO2xP0jDjJ54zduIiJwkcfcvGw=="],
111
111
 
112
- "@anthropic-ai/claude-agent-sdk-darwin-x64": ["@anthropic-ai/claude-agent-sdk-darwin-x64@0.3.251", "", { "os": "darwin", "cpu": "x64" }, "sha512-HrLnb3ggk+vMbymUvbosgPmxWp4W6Ot+0mNVjoBYDn5OZrTV3C3LRtbWf7jwcGyKMcg0xJf0AqiudQ2BRrlr8A=="],
112
+ "@anthropic-ai/claude-agent-sdk-darwin-x64": ["@anthropic-ai/claude-agent-sdk-darwin-x64@0.3.280", "", { "os": "darwin", "cpu": "x64" }, "sha512-B1eLx/oZ5RL1c3a13nQ4cRUksWyhGcVNS5vbCHnOVu4Pz+dH0moZ+iY8VaE6FvikVAQwFEW6VDU00b6m3tYdsQ=="],
113
113
 
114
- "@anthropic-ai/claude-agent-sdk-linux-arm64": ["@anthropic-ai/claude-agent-sdk-linux-arm64@0.3.251", "", { "os": "linux", "cpu": "arm64" }, "sha512-3E27F5j82EWOyEniRW7crmo0jWYYQmPDdP52jWq6Y6aytiyYIdUFMEGZZ6chVHNlZiU7GsjTa3teKk2xlQ68lQ=="],
114
+ "@anthropic-ai/claude-agent-sdk-linux-arm64": ["@anthropic-ai/claude-agent-sdk-linux-arm64@0.3.280", "", { "os": "linux", "cpu": "arm64" }, "sha512-6s96OIvBHT2817hCFLIZ421JBpQnvrmZucpjlWsyCODKmwGsSxiEhlWqK2h5Q7lwS6F7bzeAhqjGvC7FzDl9Rw=="],
115
115
 
116
- "@anthropic-ai/claude-agent-sdk-linux-arm64-musl": ["@anthropic-ai/claude-agent-sdk-linux-arm64-musl@0.3.251", "", { "os": "linux", "cpu": "arm64" }, "sha512-RTUf7TPBUkQ6oV3pDkEdcD47I0uH0ZpvmZlXHnrLGznFqyLr+7XHupOxUMJD0Jwm9v5qeqpNiPAYB0dL4RYiHg=="],
116
+ "@anthropic-ai/claude-agent-sdk-linux-arm64-musl": ["@anthropic-ai/claude-agent-sdk-linux-arm64-musl@0.3.280", "", { "os": "linux", "cpu": "arm64" }, "sha512-uDh+Ggjb36l+jcVgaYxSziGHmBSSR3clqvGlQ0Bgc1v5dLF4igwqZ6ZPW/hS9dArG27fislIOetH1waEgIr+GA=="],
117
117
 
118
- "@anthropic-ai/claude-agent-sdk-linux-x64": ["@anthropic-ai/claude-agent-sdk-linux-x64@0.3.251", "", { "os": "linux", "cpu": "x64" }, "sha512-qCD87XPjcNM1u4ukqmcgpHDl3Y6l+cW8j7kPzH91Y5yLBYJ5xYZA2KtJ7AYNEPOteVyOGJw/efmva0S8CRr0fg=="],
118
+ "@anthropic-ai/claude-agent-sdk-linux-x64": ["@anthropic-ai/claude-agent-sdk-linux-x64@0.3.280", "", { "os": "linux", "cpu": "x64" }, "sha512-vpPyxYLy+zNc7LwQDWsZf0GZtTYa0PJLxzuv2vK9iV2dG+hrbRNTl35NSKKRR9rMj6RpKz0i2NLyVQ+D4mREgw=="],
119
119
 
120
- "@anthropic-ai/claude-agent-sdk-linux-x64-musl": ["@anthropic-ai/claude-agent-sdk-linux-x64-musl@0.3.251", "", { "os": "linux", "cpu": "x64" }, "sha512-SzXrdy7jjrjJIuTG+VMRAY0YZ3G/8w21WuhAozwnvnEUAPo6NDv6lgFinu7NO8J6CPE+MK2sGze6JeCF+ljgUg=="],
120
+ "@anthropic-ai/claude-agent-sdk-linux-x64-musl": ["@anthropic-ai/claude-agent-sdk-linux-x64-musl@0.3.280", "", { "os": "linux", "cpu": "x64" }, "sha512-IVbIgvi5C0sdLg/p9hpiVvAQ/ikvTKwOOEy5C1aT7w8XLqBgfpJbzzVuk06df1Q0HlILUmf63EKPmq48lbxtqA=="],
121
121
 
122
- "@anthropic-ai/claude-agent-sdk-win32-arm64": ["@anthropic-ai/claude-agent-sdk-win32-arm64@0.3.251", "", { "os": "win32", "cpu": "arm64" }, "sha512-FH1ZLcyc97ie3h7CSlIxA1ppXILgf0V8sFQrWnHyKBrthJXQkMHXhsTq9OZV/2KhXslNf2hTe0gHpZ1nCL1Gmg=="],
122
+ "@anthropic-ai/claude-agent-sdk-win32-arm64": ["@anthropic-ai/claude-agent-sdk-win32-arm64@0.3.280", "", { "os": "win32", "cpu": "arm64" }, "sha512-heTflHwciJF+Hrf7v0J53QBzD+9mxN9gt2VVmEJAN0+ejbPcOcqnGGZHvyc9aZUuGh5INN0ECaiL4Fn1X2vXQQ=="],
123
123
 
124
- "@anthropic-ai/claude-agent-sdk-win32-x64": ["@anthropic-ai/claude-agent-sdk-win32-x64@0.3.251", "", { "os": "win32", "cpu": "x64" }, "sha512-/jmtFIvfF0UFMxSZ8WV2Aus8aGA3+8Ft6AHvWuBJkY5jM2ubfqi6GnBjKCAL831TTllp2rKZlViANtWWRBvpvg=="],
124
+ "@anthropic-ai/claude-agent-sdk-win32-x64": ["@anthropic-ai/claude-agent-sdk-win32-x64@0.3.280", "", { "os": "win32", "cpu": "x64" }, "sha512-N+Y1zJb19nx0oPTvzkl/E3ng9AtWGW+K4hySmSHCgYSsgIwfs1YzDj/F5eHDMrxgklTuzFp76TvL3S75z5ge+g=="],
125
125
 
126
126
  "@anthropic-ai/sdk": ["@anthropic-ai/sdk@0.97.1", "", { "dependencies": { "json-schema-to-ts": "^3.1.1", "standardwebhooks": "^1.0.0" }, "peerDependencies": { "zod": "^3.25.0 || ^4.0.0" }, "optionalPeers": ["zod"], "bin": { "anthropic-ai-sdk": "bin/cli" } }, "sha512-wOf7AUeJPitcVpvKO4UMu63mWH5SaVipkGd7OOQJt/G6VYGlV8D2Gp9dLxOrttDJh/9gqPqdaBwDGcBevumeAg=="],
127
127
 
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import"./vendor-ui-DmZ-Mb-H.js";import{Br as r,Tn as i,V as a,Xt as o,ct as s,dn as c,kr as l,ln as u,nt as d,or as f,qn as p,st as m,wr as h,xt as g}from"./icons-DQjqk0lJ.js";import{n as _,r as v}from"./api-client-Jn3njtNw.js";import{n as y}from"./utils-Bmf_8h7Y.js";import"./portal-container-context-BarKmT4S.js";import{n as b}from"./use-is-mobile-TkcwP1Gx.js";import{n as x,t as S}from"./button-B9CTrsEf.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./dialog-B84_DJQ8.js";import{t as k}from"./mobile-bottom-sheet-C3TniEP-.js";import"./use-visual-viewport-Lp878uzs.js";import{t as A}from"./input-QNG_gTHh.js";import{$ as j,An as M,J as N,Mn as P,Q as ee,X as F,Y as te,Z as I,an as ne,jn as L,st as R,yn as z}from"./index-C3v3QRVR.js";import{addAccount as B,deleteAccount as V,exchangeOAuthCode as H,getAISettings as U,getAccountSettings as W,getOAuthUrl as G,getUsageHistory as re,importAccounts as K,patchAccount as q,testAccountToken as ie,testExport as J,testRawToken as ae,updateAccountSettings as Y}from"./api-settings-BZFSteM_.js";import{a as oe,c as se,d as ce,f as le,i as ue,n as de,o as fe,r as pe,s as me,t as he,u as ge}from"./codex-daily-guard-PsB0g8B0.js";var X=e(t(),1),Z=n(),_e=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],Q=Array.from({length:24},(e,t)=>t);function ve(e,t){let n=Array.from({length:7},()=>Array.from({length:24},()=>({sum:0,count:0,avg:0})));for(let r of e){let e=t===`5h`?r.five_hour_util:r.weekly_util;if(e==null)continue;let i=new Date(r.recorded_at+(r.recorded_at.endsWith(`Z`)?``:`Z`)),a=(i.getDay()+6)%7,o=i.getHours();n[a][o].sum+=e,n[a][o].count+=1}for(let e of n)for(let t of e)t.avg=t.count>0?t.sum/t.count:0;return n}function ye(e){return e.map(e=>{let t=e.reduce((e,t)=>e+t.sum,0),n=e.reduce((e,t)=>e+t.count,0);return n>0?t/n:0})}function be(e){return Q.map(t=>{let n=0,r=0;for(let i of e)n+=i[t].sum,r+=i[t].count;return r>0?n/r:0})}function xe(e){return e===0?`bg-surface-elevated`:e<.3?`bg-success/30`:e<.5?`bg-success/60`:e<.7?`bg-warning/50`:e<.9?`bg-warning/80`:`bg-error/80`}function Se(e){return e<.3?`bg-success`:e<.7?`bg-warning`:`bg-error`}function Ce({accountId:e}){let[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(!0),[a,o]=(0,X.useState)(`5h`);(0,X.useEffect)(()=>{i(!0),re(e).then(n).catch(()=>n([])).finally(()=>i(!1))},[e]);let s=(0,X.useMemo)(()=>t?ve(t,a):null,[t,a]),c=(0,X.useMemo)(()=>s?ye(s):[],[s]),l=(0,X.useMemo)(()=>s?be(s):[],[s]),d=Math.max(...c,.01);if(Math.max(...l,.01),r)return(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,Z.jsx)(u,{className:`size-3 animate-spin text-text-subtle`})});if(!t||t.length===0)return(0,Z.jsx)(`div`,{className:`text-[10px] text-text-subtle py-2 text-center`,children:`No usage history yet`});let f=t.length,p=new Set(t.map(e=>new Date(e.recorded_at+(e.recorded_at.endsWith(`Z`)?``:`Z`)).toDateString())).size;return(0,Z.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-medium text-text-subtle`,children:`Usage Pattern (7d)`}),(0,Z.jsxs)(`div`,{className:`flex gap-0.5 text-[9px]`,children:[(0,Z.jsx)(`button`,{onClick:()=>o(`5h`),className:`px-1.5 py-0.5 rounded cursor-pointer transition-colors ${a===`5h`?`bg-primary/15 text-primary`:`text-text-subtle hover:text-text-secondary`}`,title:`5-hour rolling window limit — resets every 5 hours`,children:`5h`}),(0,Z.jsx)(`button`,{onClick:()=>o(`weekly`),className:`px-1.5 py-0.5 rounded cursor-pointer transition-colors ${a===`weekly`?`bg-primary/15 text-primary`:`text-text-subtle hover:text-text-secondary`}`,title:`Weekly limit — resets every 7 days`,children:`Wk`})]})]}),(0,Z.jsxs)(`p`,{className:`text-[9px] text-text-subtle leading-tight`,children:[`Avg `,a===`5h`?`5-hour`:`weekly`,` limit usage over `,p,`d (`,f,` samples). Higher % = closer to rate limit. Hover cells for details.`]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Avg usage by day of week`}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-[2px] mt-0.5`,children:_e.map((e,t)=>{let n=c[t]??0;return(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(`span`,{className:`text-[8px] text-text-subtle w-5 shrink-0 text-right tabular-nums`,children:e}),(0,Z.jsx)(`div`,{className:`flex-1 h-2.5 bg-surface-elevated rounded-sm overflow-hidden`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-sm transition-all ${Se(n)}`,style:{width:`${Math.round(n/d*100)}%`}})}),(0,Z.jsxs)(`span`,{className:`text-[8px] text-text-subtle w-6 shrink-0 text-right tabular-nums`,children:[Math.round(n*100),`%`]})]},e)})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Avg usage by hour (0h-23h)`}),(0,Z.jsx)(`div`,{className:`flex gap-[1px] mt-0.5`,children:Q.map(e=>{let t=l[e]??0;return(0,Z.jsxs)(`div`,{className:`flex-1 flex flex-col items-center gap-[1px]`,children:[(0,Z.jsx)(`div`,{className:`w-full aspect-square rounded-[2px] ${xe(t)}`,title:`${e}:00 — avg ${Math.round(t*100)}% usage`}),e%6==0&&(0,Z.jsx)(`span`,{className:`text-[7px] text-text-subtle tabular-nums`,children:e})]},e)})})]}),s&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Day x Hour heatmap`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-[1px] mt-0.5`,children:[_e.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-[1px]`,children:[(0,Z.jsx)(`span`,{className:`text-[7px] text-text-subtle w-4 shrink-0 text-right`,children:e.charAt(0)}),Q.map(n=>{let r=s[t][n];return(0,Z.jsx)(`div`,{className:`flex-1 aspect-square rounded-[1px] ${xe(r.avg)}`,title:`${e} ${n}:00 — ${r.count>0?`avg ${Math.round(r.avg*100)}% (${r.count} samples)`:`no data`}`},n)})]},e)),(0,Z.jsxs)(`div`,{className:`flex items-center gap-[1px]`,children:[(0,Z.jsx)(`span`,{className:`w-4 shrink-0`}),Q.map(e=>(0,Z.jsx)(`div`,{className:`flex-1 text-center`,children:e%6==0&&(0,Z.jsx)(`span`,{className:`text-[7px] text-text-subtle tabular-nums`,children:e})},e))]})]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[8px] text-text-subtle`,children:[(0,Z.jsx)(`span`,{children:`Low`}),(0,Z.jsxs)(`div`,{className:`flex gap-[2px]`,children:[(0,Z.jsx)(`div`,{className:`size-2 rounded-[1px] bg-success/30`}),(0,Z.jsx)(`div`,{className:`size-2 rounded-[1px] bg-success/60`}),(0,Z.jsx)(`div`,{className:`size-2 rounded-[1px] bg-warning/50`}),(0,Z.jsx)(`div`,{className:`size-2 rounded-[1px] bg-warning/80`}),(0,Z.jsx)(`div`,{className:`size-2 rounded-[1px] bg-error/80`})]}),(0,Z.jsx)(`span`,{children:`High`}),(0,Z.jsx)(`span`,{className:`ml-1`,children:`|`}),(0,Z.jsx)(`div`,{className:`size-2 rounded-[1px] bg-surface-elevated border border-border/30`}),(0,Z.jsx)(`span`,{children:`No data`})]})]})}function we({profile:e,accountId:t,onClose:n}){let i=[[`Name`,e.account?.display_name],[`Email`,e.account?.email],[`Org`,e.organization?.name],[`Type`,e.organization?.organization_type],[`Tier`,e.organization?.rate_limit_tier],[`Status`,e.organization?.subscription_status]];return(0,Z.jsxs)(`section`,{className:`space-y-2 border-t border-border pt-3`,"data-testid":`account-profile-panel`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-medium`,children:`Profile`}),(0,Z.jsx)(`button`,{className:`p-2 text-muted-foreground hover:text-foreground cursor-pointer`,onClick:n,"aria-label":`Close profile`,children:(0,Z.jsx)(r,{className:`size-4`})})]}),(0,Z.jsx)(`div`,{className:`grid grid-cols-[80px_1fr] gap-x-3 gap-y-1 text-xs`,children:i.map(([e,t])=>t?(0,Z.jsxs)(`span`,{className:`contents`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,Z.jsx)(`span`,{className:`break-all`,children:t})]},e):null)}),(0,Z.jsx)(Ce,{accountId:t})]})}function Te({display:e,onConfirm:t,onCancel:n}){let r=b(),i=(0,Z.jsxs)(`div`,{className:`space-y-4`,"data-testid":`account-delete-confirm`,children:[(0,Z.jsxs)(`p`,{className:`text-sm`,children:[`Remove `,(0,Z.jsx)(`span`,{className:`font-medium`,children:e}),`?`]}),(0,Z.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`The stored token is deleted from this machine. Any export you already made keeps working.`}),(0,Z.jsxs)(`div`,{className:`flex flex-col-reverse md:flex-row gap-2 md:justify-end pt-2`,children:[(0,Z.jsx)(S,{variant:`outline`,onClick:n,className:`min-h-11`,children:`Cancel`}),(0,Z.jsx)(S,{variant:`destructive`,autoFocus:!1,onClick:t,className:`min-h-11`,children:`Remove account`})]})]});return r?(0,Z.jsx)(k,{open:!0,onClose:n,children:(0,Z.jsxs)(`div`,{className:`px-4 pb-4`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold mb-3`,children:`Remove account`}),i]})}):(0,Z.jsx)(O,{open:!0,onOpenChange:e=>{e||n()},children:(0,Z.jsxs)(T,{className:`sm:max-w-sm`,children:[(0,Z.jsx)(C,{children:(0,Z.jsx)(E,{className:`text-sm`,children:`Remove account`})}),i]})})}function Ee({open:e,onOpenChange:t,onSuccess:n}){let[r,i]=(0,X.useState)(``),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(!1),[l,d]=(0,X.useState)(null),[f,p]=(0,X.useState)(null),[m,h]=(0,X.useState)(``),[g,_]=(0,X.useState)(!1),[v,y]=(0,X.useState)(`idle`);function b(){p(null),h(``),y(`idle`),d(null)}function x(){t(!1),b(),i(``),o(``),d(null)}async function k(){_(!0),d(null);try{let{url:e,state:t}=await G();p(t),y(`waiting`),window.open(e,`_blank`)}catch(e){d(e.message)}_(!1)}async function j(){if(!(!m.trim()||!f)){_(!0),d(null);try{let e=m.trim();e.includes(`#`)&&(e=e.split(`#`)[0]??e);let t=await H(e,f);x(),n(t?.status===`disabled`?`Signed in. This account is still disabled — enable it to use it.`:`Account connected via OAuth!`)}catch(e){d(e.message)}_(!1)}}async function M(){if(r.trim()){c(!0),d(null);try{let e=await B({apiKey:r.trim(),label:a.trim()||void 0});x(),n(e?.status===`disabled`?`Token updated. This account is still disabled — enable it to use it.`:`Account added!`)}catch(e){d(e.message)}c(!1)}}let N=r.trim()?r.trim().startsWith(`sk-ant-oat`)?`OAuth token (Claude Max/Pro)`:r.trim().startsWith(`sk-ant-api`)?`API key`:`Unknown format`:``;return(0,Z.jsx)(O,{open:e,onOpenChange:e=>{e||x()},children:(0,Z.jsxs)(T,{className:`sm:max-w-md`,children:[(0,Z.jsxs)(C,{children:[(0,Z.jsx)(E,{className:`text-sm`,children:`Add Claude Account`}),(0,Z.jsx)(D,{className:`text-xs leading-relaxed`,children:`Connect via OAuth (recommended) or paste a token manually.`})]}),(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,Z.jsx)(`p`,{className:`text-[11px] font-medium`,children:`Recommended: Login with Claude`}),v===`idle`?(0,Z.jsx)(S,{size:`sm`,className:`w-full h-8 text-xs`,onClick:k,disabled:g,children:g?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(u,{className:`size-3 animate-spin mr-1`}),` Opening...`]}):`Login with Claude`}):(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Authorize in the opened tab, then paste the code:`}),(0,Z.jsx)(A,{placeholder:`Paste code here...`,value:m,onChange:e=>h(e.target.value),className:`text-xs h-8 font-mono`,autoFocus:!0}),(0,Z.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,Z.jsx)(S,{size:`sm`,className:`flex-1 h-7 text-xs`,onClick:j,disabled:!m.trim()||g,children:g?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(u,{className:`size-3 animate-spin mr-1`}),` Connecting...`]}):`Connect`}),(0,Z.jsx)(S,{size:`sm`,variant:`ghost`,className:`h-7 text-xs`,onClick:b,children:`Cancel`})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`flex-1 border-t`}),(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`or paste token`}),(0,Z.jsx)(`div`,{className:`flex-1 border-t`})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(R,{htmlFor:`add-token`,className:`text-xs`,children:`Token`}),(0,Z.jsx)(A,{id:`add-token`,type:`password`,placeholder:`sk-ant-...`,value:r,onChange:e=>i(e.target.value),className:`text-xs h-8 font-mono`}),N&&(0,Z.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[`Detected: `,N]})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(R,{htmlFor:`add-label`,className:`text-xs`,children:`Label (optional)`}),(0,Z.jsx)(A,{id:`add-label`,placeholder:`e.g. Personal, Work`,value:a,onChange:e=>o(e.target.value),className:`text-xs h-8`})]})]}),l&&(0,Z.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:l}),(0,Z.jsxs)(w,{children:[(0,Z.jsx)(S,{size:`sm`,variant:`outline`,className:`text-xs h-7`,onClick:x,children:`Cancel`}),(0,Z.jsx)(S,{size:`sm`,className:`text-xs h-7`,onClick:M,disabled:!r.trim()||s,children:s?`Adding...`:`Add Token`})]})]})})}function De(e){let t=new Blob([e],{type:`application/json`}),n=document.createElement(`a`);n.href=URL.createObjectURL(t),n.download=`ppm-accounts-backup.json`,n.click(),URL.revokeObjectURL(n.href)}function Oe({open:e,onOpenChange:t,accounts:n,preselectId:r,onMessage:i}){let a=n.filter(e=>e.hasRefreshToken),[o,s]=(0,X.useState)(new Set),[l,f]=(0,X.useState)(``),[p,h]=(0,X.useState)(!1),[g,_]=(0,X.useState)(!1),[y,b]=(0,X.useState)(!1),[x,k]=(0,X.useState)(!1);e&&!x&&(s(r?new Set([r]):new Set(a.map(e=>e.id))),k(!0)),!e&&x&&k(!1);function j(){t(!1),f(``),h(!1),_(!1)}async function M(e){if(o.size===0)return;b(!0);let t=l.trim()||`ppm-hienlh`;try{let n={"Content-Type":`application/json`},r=v();r&&(n.Authorization=`Bearer ${r}`);let a=await fetch(`/api/accounts/export`,{method:`POST`,headers:n,body:JSON.stringify({password:t,accountIds:[...o],includeRefreshToken:p,refreshBeforeExport:g})});if(!a.ok){let e=await a.json();throw Error(e.error??`Export failed: ${a.status}`)}let s=await a.text();e&&await ne(s)?i?.(`Backup copied to clipboard!`):(De(s),i?.(`Backup downloaded.`)),j()}catch{}b(!1)}let N=o.size>0&&!y;return(0,Z.jsx)(O,{open:e,onOpenChange:e=>{e||j()},children:(0,Z.jsxs)(T,{className:`sm:max-w-md`,children:[(0,Z.jsxs)(C,{children:[(0,Z.jsxs)(E,{className:`text-sm flex items-center gap-1.5`,children:[(0,Z.jsx)(c,{className:`size-3.5`}),` Export Accounts`]}),(0,Z.jsx)(D,{className:`text-xs`,children:`Select accounts and set a password to protect the backup.`})]}),(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,Z.jsx)(`p`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Accounts to export`}),(0,Z.jsx)(`button`,{className:`text-[10px] text-primary hover:underline cursor-pointer`,onClick:()=>s(o.size===a.length?new Set:new Set(a.map(e=>e.id))),children:o.size===a.length?`Deselect all`:`Select all`})]}),a.length===0?(0,Z.jsx)(`p`,{className:`text-[10px] text-muted-foreground p-2 border rounded`,children:`No exportable accounts.`}):(0,Z.jsx)(`div`,{className:`max-h-36 overflow-y-auto space-y-1 border rounded p-2`,children:a.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,id:`exp-${e.id}`,checked:o.has(e.id),onChange:t=>{let n=new Set(o);t.target.checked?n.add(e.id):n.delete(e.id),s(n)},className:`size-3.5 accent-primary cursor-pointer`}),(0,Z.jsx)(`label`,{htmlFor:`exp-${e.id}`,className:`text-xs cursor-pointer truncate`,children:e.label??e.email??e.id.slice(0,8)})]},e.id))})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(R,{className:`text-xs`,children:[`Password `,(0,Z.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,Z.jsx)(A,{type:`password`,placeholder:`Leave empty for default`,value:l,onChange:e=>f(e.target.value),className:`text-xs h-8`,autoComplete:`new-password`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,id:`exp-full`,checked:p,onChange:e=>h(e.target.checked),className:`size-3.5 accent-primary cursor-pointer`}),(0,Z.jsx)(`label`,{htmlFor:`exp-full`,className:`text-[11px] cursor-pointer`,children:`Include refresh tokens (full transfer)`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,id:`exp-refresh`,checked:g,onChange:e=>_(e.target.checked),className:`size-3.5 accent-primary cursor-pointer`}),(0,Z.jsx)(`label`,{htmlFor:`exp-refresh`,className:`text-[11px] cursor-pointer`,children:`Refresh tokens before export`})]}),p?(0,Z.jsxs)(`div`,{className:`rounded-md border border-error/30 bg-error/5 p-2.5`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] font-medium text-error`,children:`Full transfer — source accounts will expire`}),(0,Z.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Refresh tokens included. Source machine expires in ~1h after target refreshes.`})]}):g?(0,Z.jsx)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 p-2.5`,children:(0,Z.jsx)(`p`,{className:`text-[10px] font-medium text-warning`,children:`Refresh before export — invalidates previous shares`})}):(0,Z.jsx)(`div`,{className:`rounded-md border border-success/30 bg-success/5 p-2.5`,children:(0,Z.jsx)(`p`,{className:`text-[10px] font-medium text-success`,children:`Share current token (safe)`})}),(0,Z.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Encrypted with AES-256-GCM + scrypt.`})]}),(0,Z.jsxs)(w,{className:`gap-1.5 flex-col sm:flex-row`,children:[(0,Z.jsx)(S,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,onClick:j,children:`Cancel`}),(0,Z.jsxs)(S,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,disabled:!N,onClick:()=>M(!0),children:[(0,Z.jsx)(d,{className:`size-3 mr-1`}),` Copy`]}),(0,Z.jsx)(S,{size:`sm`,className:`text-xs h-7 cursor-pointer`,disabled:!N,onClick:()=>M(!1),children:y?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(u,{className:`size-3 animate-spin mr-1`}),` Exporting...`]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(m,{className:`size-3 mr-1`}),` Download`]})})]})]})})}function ke({open:e,onOpenChange:t,onSuccess:n}){let[r,i]=(0,X.useState)(``),[a,o]=(0,X.useState)(``),[s,l]=(0,X.useState)(!1),[d,f]=(0,X.useState)(null);function p(){t(!1),i(``),o(``),f(null)}async function m(){if(r.trim()){l(!0),f(null);try{let e=await K({data:r.trim(),password:a.trim()||`ppm-hienlh`});p(),n(`Imported ${e.imported} account(s)`)}catch(e){f(e.message||`Import failed`)}l(!1)}}return(0,Z.jsx)(O,{open:e,onOpenChange:e=>{e||p()},children:(0,Z.jsxs)(T,{className:`sm:max-w-md`,children:[(0,Z.jsxs)(C,{children:[(0,Z.jsxs)(E,{className:`text-sm flex items-center gap-1.5`,children:[(0,Z.jsx)(c,{className:`size-3.5`}),` Import Accounts`]}),(0,Z.jsx)(D,{className:`text-xs`,children:`Paste backup data and enter the export password. Imported accounts are temporary (~1h).`})]}),(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(R,{className:`text-xs`,children:`Backup data`}),(0,Z.jsx)(`textarea`,{value:r,onChange:e=>i(e.target.value),placeholder:`Paste backup JSON here...`,rows:4,className:`w-full text-xs p-2 rounded border border-border bg-background font-mono resize-none focus:outline-none focus:ring-1 focus:ring-primary`})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(R,{className:`text-xs`,children:[`Password `,(0,Z.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,Z.jsx)(A,{type:`password`,placeholder:`Leave empty for default`,value:a,onChange:e=>o(e.target.value),className:`text-xs h-8`,autoComplete:`current-password`})]})]}),d&&(0,Z.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:d}),(0,Z.jsxs)(w,{children:[(0,Z.jsx)(S,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,onClick:p,children:`Cancel`}),(0,Z.jsx)(S,{size:`sm`,className:`text-xs h-7 cursor-pointer`,disabled:!r.trim()||s,onClick:m,children:s?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(u,{className:`size-3 animate-spin mr-1`}),` Importing...`]}):`Import`})]})]})})}var $=typeof window<`u`?window.matchMedia(`(min-width: 768px)`):null;function Ae(e){return $?.addEventListener(`change`,e),()=>$?.removeEventListener(`change`,e)}function je(){return $?.matches??!0}function Me(){let[e,t]=(0,X.useState)(null),[n,r]=(0,X.useState)(!0);return(0,X.useEffect)(()=>{r(!0),W().then(t).finally(()=>r(!1))},[]),n?(0,Z.jsx)(`p`,{className:`text-xs text-text-subtle py-4 text-center`,children:`Loading...`}):e?(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Rotation Strategy`}),(0,Z.jsxs)(N,{value:e.strategy,onValueChange:async e=>{t(await Y({strategy:e}))},children:[(0,Z.jsx)(I,{className:`w-full h-9 text-xs`,children:(0,Z.jsx)(ee,{})}),(0,Z.jsxs)(te,{children:[(0,Z.jsx)(F,{value:`round-robin`,children:`Round-robin`}),(0,Z.jsx)(F,{value:`fill-first`,children:`Fill-first`}),(0,Z.jsx)(F,{value:`lowest-usage`,children:`Lowest usage`})]})]}),(0,Z.jsxs)(`p`,{className:`text-[10px] text-text-subtle`,children:[e.strategy===`round-robin`&&`Cycles through accounts evenly`,e.strategy===`fill-first`&&`Uses one account until its limit, then moves on`,e.strategy===`lowest-usage`&&`Picks the account with the lowest current usage`]})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Max Retry`}),(0,Z.jsx)(`input`,{type:`number`,min:0,value:e.maxRetry,className:`w-full h-9 text-xs border rounded-md px-3 bg-background`,onChange:async e=>{let n=parseInt(e.target.value,10);!isNaN(n)&&n>=0&&t(await Y({maxRetry:n}))}}),(0,Z.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`How many accounts to try on failure. 0 = try all available accounts.`})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5 border-t border-border pt-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Cooldown parking`}),(0,Z.jsx)(j,{checked:e.cooldownEnabled,onCheckedChange:async e=>{t(await Y({cooldownEnabled:e}))}})]}),(0,Z.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`Park a failing account (rate limit / usage limit / auth error) until it recovers. Off: accounts stay selectable — rotation still skips accounts already ≥95% on the 5-hour limit.`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-xs border-t border-border pt-3`,children:[(0,Z.jsx)(`span`,{className:`text-text-subtle`,children:`Active accounts`}),(0,Z.jsx)(`span`,{className:`font-medium text-text-primary`,children:e.activeCount})]})]}):(0,Z.jsx)(`p`,{className:`text-xs text-text-subtle py-4 text-center`,children:`Failed to load settings`})}function Ne({open:e,onOpenChange:t}){let n=(0,X.useSyncExternalStore)(Ae,je);return e?n?(0,Z.jsx)(O,{open:e,onOpenChange:t,children:(0,Z.jsxs)(T,{className:`sm:max-w-sm`,children:[(0,Z.jsx)(C,{children:(0,Z.jsxs)(E,{className:`text-sm flex items-center gap-2`,children:[(0,Z.jsx)(f,{className:`size-4`}),` Rotation & Retry`]})}),(0,Z.jsx)(Me,{})]})}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`fixed inset-0 z-50 transition-opacity duration-200 opacity-100`,onClick:()=>t(!1),style:{backgroundColor:`rgba(0,0,0,0.5)`}}),(0,Z.jsxs)(`div`,{className:y(`fixed bottom-0 left-0 right-0 z-50 bg-background rounded-t-2xl border-t border-border shadow-2xl`,`transition-transform duration-300 ease-out max-h-[85vh] overflow-y-auto`,`translate-y-0`),children:[(0,Z.jsx)(`div`,{className:`flex justify-center pt-3 pb-1`,children:(0,Z.jsx)(`div`,{className:`w-10 h-1 rounded-full bg-border`})}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-border`,children:[(0,Z.jsxs)(`span`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,Z.jsx)(f,{className:`size-4`}),` Rotation & Retry`]}),(0,Z.jsx)(`button`,{onClick:()=>t(!1),className:`flex items-center justify-center size-7 rounded-md hover:bg-surface-elevated transition-colors`,children:(0,Z.jsx)(r,{className:`size-4`})})]}),(0,Z.jsx)(`div`,{className:`px-4 py-4 pb-8`,children:(0,Z.jsx)(Me,{})})]})]}):null}var Pe=x(`inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2`,{variants:{variant:{default:`border-transparent bg-primary text-primary-foreground shadow`,secondary:`border-transparent bg-secondary text-secondary-foreground`,destructive:`border-transparent bg-destructive text-destructive-foreground shadow`,outline:`text-foreground`}},defaultVariants:{variant:`default`}});function Fe({className:e,variant:t,...n}){return(0,Z.jsx)(`div`,{className:y(Pe({variant:t}),e),...n})}function Ie(e){let t=Math.floor(Date.now()/1e3);return e>t?`${Math.floor((e-t)/60)}m`:`exp`}function Le({accounts:e}){let[t,n]=(0,X.useState)([]),[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(new Map),l=e.filter(e=>e.hasRefreshToken);async function d(){if(l.length!==0){i(!0);try{let e=await J(l.map(e=>e.id),a);n(t=>[...t,{round:t.length+1,time:new Date().toLocaleTimeString(),includeRefresh:a,items:e}])}catch{}i(!1)}}async function f(e,t){c(t=>new Map(t).set(e,{loading:!0}));try{let n=await ae(t);c(t=>new Map(t).set(e,{loading:!1,...n}))}catch(t){c(n=>new Map(n).set(e,{loading:!1,status:`error`,error:t.message}))}}function p(e,t){return[{key:`r${e.round}-pre-${t.id}`,label:`Pre-export`,token:t.preExportTokenFull,preview:t.preExportToken,expires:t.preExportExpires},{key:`r${e.round}-exp-${t.id}`,label:`Exported`,token:t.exportedTokenFull,preview:t.exportedToken,expires:t.exportedExpires},{key:`r${e.round}-post-${t.id}`,label:`Post-export`,token:t.postExportTokenFull,preview:t.postExportToken,expires:t.postExportExpires}]}function m(){for(let e of t)for(let t of e.items)for(let n of p(e,t))n.token&&f(n.key,n.token)}return(0,Z.jsxs)(`section`,{className:`border-t pt-4 space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium`,children:`Simulate export`}),t.length>0&&(0,Z.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[t.length,` round(s)`]})]}),(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Every run appends a round. Earlier rounds are kept so tokens can be compared across runs.`}),l.length===0?(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No OAuth account with a refresh token to export.`}):(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(j,{id:`sim-include-refresh`,checked:a,onCheckedChange:o,className:`cursor-pointer`}),(0,Z.jsx)(R,{htmlFor:`sim-include-refresh`,className:`text-[11px] cursor-pointer`,children:`Include refresh tokens`})]}),(0,Z.jsx)(S,{size:`sm`,className:`h-7 text-xs cursor-pointer`,disabled:r,onClick:()=>void d(),children:r?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(u,{className:`size-3 animate-spin mr-1`}),` Exporting...`]}):`Run export #${t.length+1}`})]}),t.length>0&&(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(S,{size:`sm`,variant:`outline`,className:`w-full h-7 text-[11px] cursor-pointer`,onClick:m,children:[`Test all tokens (`,t.reduce((e,t)=>e+t.items.length*3,0),`)`]}),t.map(e=>(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(`p`,{className:`text-xs font-medium text-primary`,children:[`Round #`,e.round]}),(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e.time}),(0,Z.jsx)(Fe,{variant:e.includeRefresh?`destructive`:`secondary`,className:`text-[9px] px-1 py-0`,children:e.includeRefresh?`with refresh`:`access only`})]}),e.items.map(t=>(0,Z.jsxs)(`div`,{className:`p-2 rounded-lg border bg-card space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] font-medium`,children:t.label??t.email??t.id.slice(0,8)}),t.tokenChanged&&(0,Z.jsx)(Fe,{variant:`secondary`,className:`text-[9px] px-1 py-0`,children:`DB token changed`})]}),p(e,t).map(e=>{let t=s.get(e.key);return(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px]`,children:[(0,Z.jsx)(`span`,{className:`w-20 shrink-0 text-muted-foreground text-[10px]`,children:e.label}),(0,Z.jsx)(`code`,{className:`flex-1 truncate font-mono text-[10px] bg-muted px-1 rounded`,children:e.preview??`N/A`}),e.expires&&(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground shrink-0`,children:Ie(e.expires)}),e.token?(0,Z.jsx)(S,{size:`sm`,variant:`outline`,className:`h-6 text-[10px] px-1.5 cursor-pointer shrink-0`,disabled:t?.loading,onClick:()=>void f(e.key,e.token),children:t?.loading?(0,Z.jsx)(u,{className:`size-3 animate-spin`}):`Test`}):(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`-`}),t&&!t.loading&&(0,Z.jsx)(`span`,{className:`text-[10px] font-medium shrink-0 ${t.status?.startsWith(`valid`)?`text-success`:`text-error`}`,children:t.status})]},e.key)})]},`r${e.round}-${t.id}`))]},e.round))]})]})}function Re(e){let t=Math.floor(Date.now()/1e3),n=Math.floor(Math.abs(e-t)/60);return e>t?`${n}m left`:`expired ${n}m ago`}function ze({open:e,onOpenChange:t,accounts:n}){let[r,i]=(0,X.useState)(new Map),[a,o]=(0,X.useState)(!1);async function s(e){i(t=>new Map(t).set(e,{loading:!0}));try{let t=await ie(e,a);i(n=>new Map(n).set(e,{loading:!1,result:t}))}catch(t){i(n=>new Map(n).set(e,{loading:!1,error:t.message}))}}function c(){for(let e of n.filter(e=>e.expiresAt!==null))s(e.id)}return(0,Z.jsx)(O,{open:e,onOpenChange:t,children:(0,Z.jsxs)(T,{className:`sm:max-w-xl max-h-[85vh] flex flex-col`,children:[(0,Z.jsxs)(C,{children:[(0,Z.jsxs)(E,{className:`text-sm flex items-center gap-1.5`,children:[(0,Z.jsx)(g,{className:`size-4`}),` Token Test`]}),(0,Z.jsx)(D,{className:`text-xs`,children:`Probe stored tokens for validity. Nothing is modified.`})]}),(0,Z.jsxs)(`div`,{className:`space-y-4 overflow-y-auto flex-1 pr-1`,children:[(0,Z.jsxs)(`section`,{className:`space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium`,children:`Current tokens`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(j,{id:`token-test-refresh`,checked:a,onCheckedChange:o,className:`cursor-pointer`}),(0,Z.jsx)(R,{htmlFor:`token-test-refresh`,className:`text-[11px] cursor-pointer`,children:`Also test refresh`})]}),(0,Z.jsx)(S,{size:`sm`,variant:`outline`,className:`h-7 text-xs cursor-pointer`,onClick:c,children:`Test all`})]})]}),n.length===0&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No accounts to test.`}),(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:n.map(e=>{let t=r.get(e.id),n=t?.result?.accessToken.status;return(0,Z.jsxs)(`div`,{className:`p-2 rounded border bg-card space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium truncate block`,children:e.label??e.email??e.id.slice(0,8)}),e.expiresAt&&(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Re(e.expiresAt)})]}),(0,Z.jsx)(S,{size:`sm`,variant:`outline`,className:`h-7 text-xs cursor-pointer shrink-0`,disabled:t?.loading,onClick:()=>void s(e.id),children:t?.loading?(0,Z.jsx)(u,{className:`size-3 animate-spin`}):`Test`})]}),t&&!t.loading&&(0,Z.jsxs)(`div`,{className:`text-[11px] pl-2 border-l-2 border-muted`,children:[t.error&&(0,Z.jsx)(`p`,{className:`text-error`,children:t.error}),n&&(0,Z.jsxs)(`span`,{className:n.startsWith(`valid`)?`text-success`:`text-error`,children:[n,t.result?.accessToken.code?` (${t.result.accessToken.code})`:``]})]})]},e.id)})})]}),(0,Z.jsx)(Le,{accounts:n})]}),(0,Z.jsx)(w,{children:(0,Z.jsx)(S,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Close`})})]})})}function Be(){let{usages:e,accounts:t,activeAccountId:n,initialLoading:r,refreshing:i,flashIds:a,reload:s}=pe(),[c,d]=(0,X.useState)(null),[h,_]=(0,X.useState)(null),[v,y]=(0,X.useState)(null),[b,x]=(0,X.useState)(null),[C,w]=(0,X.useState)(null),[T,E]=(0,X.useState)(null);function D(e){s(),e&&d(e)}async function O(e,t){_(e);try{await q(e,{status:t===`disabled`?`active`:`disabled`})}catch(e){d(e.message)}_(null),s()}async function k(){if(v){try{await V(v.id),d(`Account "${v.display}" removed.`),s()}catch(e){d(`Failed to remove: ${e.message}`)}y(null)}}let A=new Map(t.map(e=>[e.id,e])),j=e[0]?.usage.lastFetchedAt;return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(me,{description:`Connect multiple Claude accounts. PPM rotates between them automatically to avoid rate limits.`,onRefresh:()=>void s(),refreshing:i,disabled:r,actions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(S,{size:`sm`,className:`cursor-pointer gap-1.5`,onClick:()=>E(`add`),children:[(0,Z.jsx)(p,{className:`size-4`}),` Add account`]}),(0,Z.jsxs)(S,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>{w(null),E(`export`)},children:[(0,Z.jsx)(m,{className:`size-4`}),` Export`]}),(0,Z.jsxs)(S,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>E(`import`),children:[(0,Z.jsx)(l,{className:`size-4`}),` Import`]}),(0,Z.jsxs)(S,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>E(`rotation`),children:[(0,Z.jsx)(f,{className:`size-4`}),` Rotation`]}),(0,Z.jsxs)(S,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>E(`token-test`),children:[(0,Z.jsx)(g,{className:`size-4`}),` Token test`]})]})}),(0,Z.jsx)(se,{message:c,onDismiss:()=>d(null)}),(0,Z.jsxs)(`section`,{className:`space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-medium`,children:`Accounts`}),j&&(0,Z.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`usage `,ce(new Date(j).getTime())]})]}),r?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,Z.jsx)(u,{className:`size-4 animate-spin`}),` Loading accounts...`]}):e.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,Z.jsx)(o,{className:`size-5 text-muted-foreground`}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No accounts connected yet.`}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Add one to start using PPM.`})]}):(0,Z.jsx)(oe,{children:e.map(e=>(0,Z.jsx)(ue,{layout:`strip`,entry:e,isActive:e.accountId===n,accountInfo:A.get(e.accountId),onToggle:O,toggling:h===e.accountId,onDelete:(e,t)=>y({id:e,display:t}),onExport:e=>{w(e),E(`export`)},onViewProfile:(e,t)=>x({profile:e,accountId:t}),flash:a.has(e.accountId)},e.accountId))})]}),b&&(0,Z.jsx)(we,{profile:b.profile,accountId:b.accountId,onClose:()=>x(null)}),v&&(0,Z.jsx)(Te,{display:v.display,onConfirm:()=>void k(),onCancel:()=>y(null)}),(0,Z.jsx)(Ee,{open:T===`add`,onOpenChange:e=>E(e?`add`:null),onSuccess:D}),(0,Z.jsx)(Oe,{open:T===`export`,onOpenChange:e=>{E(e?`export`:null),e||w(null)},accounts:t,preselectId:C,onMessage:d}),(0,Z.jsx)(ke,{open:T===`import`,onOpenChange:e=>E(e?`import`:null),onSuccess:D}),(0,Z.jsx)(Ne,{open:T===`rotation`,onOpenChange:e=>E(e?`rotation`:null)}),(0,Z.jsx)(ze,{open:T===`token-test`,onOpenChange:e=>E(e?`token-test`:null),accounts:t})]})}function Ve({open:e,onOpenChange:t,label:n,onLabelChange:r,apiKey:a,onApiKeyChange:c,adding:l,onAddApiKey:d,deviceWaiting:f,onStartDevice:p,device:m,error:h,browser:g,onStartBrowser:_,loginStarting:v,callbackUrl:y,onCallbackUrlChange:b,submittingCallback:x,onSubmitCallback:k}){let j=v||f||!!g||l;return(0,Z.jsx)(O,{open:e,onOpenChange:t,children:(0,Z.jsxs)(T,{className:`sm:max-w-md max-h-[90dvh] overflow-y-auto`,children:[(0,Z.jsxs)(C,{children:[(0,Z.jsx)(E,{className:`text-sm`,children:`Add Codex Account`}),(0,Z.jsx)(D,{className:`text-xs leading-relaxed`,children:`Choose browser login, a device code, or an OpenAI API key.`})]}),(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(R,{htmlFor:`codex-label`,className:`text-xs`,children:`Label (optional)`}),(0,Z.jsx)(A,{id:`codex-label`,placeholder:`e.g. Personal, Work`,value:n,onChange:e=>r(e.target.value),disabled:j,className:`text-xs`})]}),(0,Z.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,Z.jsx)(`p`,{className:`text-[11px] font-medium`,children:`Browser login`}),(0,Z.jsxs)(S,{size:`sm`,className:`w-full cursor-pointer gap-1.5`,onClick:_,disabled:j,children:[(0,Z.jsx)(s,{className:`size-4`}),` Sign in with browser`]}),g&&(0,Z.jsxs)(`div`,{className:`space-y-2 text-xs`,children:[(0,Z.jsxs)(`a`,{href:g.authUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-primary hover:underline`,children:[(0,Z.jsx)(s,{className:`size-3`}),` Open ChatGPT sign-in`]}),(0,Z.jsx)(`p`,{children:`Sign in, then copy the full localhost callback URL from the address bar and paste it below. On a phone, copy it even if the page fails to load.`}),(0,Z.jsx)(R,{htmlFor:`codex-callback-url`,children:`Callback URL`}),(0,Z.jsx)(A,{id:`codex-callback-url`,type:`password`,autoComplete:`off`,spellCheck:!1,placeholder:`http://localhost:.../auth/callback?...`,value:y,onChange:e=>b(e.target.value),disabled:x}),(0,Z.jsxs)(S,{size:`sm`,onClick:k,disabled:!y.trim()||x,children:[x&&(0,Z.jsx)(u,{className:`size-3 animate-spin`}),` Submit callback URL`]}),(0,Z.jsxs)(`p`,{role:`status`,className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Z.jsx)(u,{className:`size-3 animate-spin`}),` Waiting for authorization. This may complete automatically on this computer.`]})]})]}),(0,Z.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,Z.jsx)(`p`,{className:`text-[11px] font-medium`,children:`Device code`}),(0,Z.jsx)(S,{size:`sm`,className:`w-full cursor-pointer gap-1.5`,onClick:p,disabled:j,children:f?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(u,{className:`size-4 animate-spin`}),` Waiting for authorization...`]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(i,{className:`size-4`}),` Sign in with device code`]})}),m&&(0,Z.jsxs)(`div`,{className:`rounded-md border border-primary/40 bg-primary/10 p-2.5 space-y-1.5`,children:[(0,Z.jsx)(`p`,{className:`text-[11px]`,children:`Enter this code to authorize:`}),(0,Z.jsx)(`div`,{className:`font-mono text-lg tracking-widest`,children:m.userCode}),(0,Z.jsxs)(`a`,{href:m.verificationUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-primary hover:underline text-[11px]`,children:[(0,Z.jsx)(s,{className:`size-3`}),` `,m.verificationUrl]})]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`flex-1 border-t`}),(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`or paste an API key`}),(0,Z.jsx)(`div`,{className:`flex-1 border-t`})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(R,{htmlFor:`codex-api-key`,className:`text-xs`,children:`OpenAI API key`}),(0,Z.jsx)(A,{id:`codex-api-key`,type:`password`,placeholder:`sk-...`,value:a,onChange:e=>c(e.target.value),className:`text-xs font-mono`})]})]}),v&&(0,Z.jsx)(`p`,{role:`status`,className:`text-xs`,children:`Starting login...`}),h&&(0,Z.jsx)(`div`,{role:`alert`,className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:h}),(0,Z.jsxs)(w,{children:[(0,Z.jsx)(S,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Cancel`}),(0,Z.jsxs)(S,{size:`sm`,className:`text-xs cursor-pointer gap-1.5`,onClick:d,disabled:!a.trim()||j,children:[l?(0,Z.jsx)(u,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(o,{className:`size-3.5`}),`Add key`]})]})]})})}function He({mode:e,onOpenChange:t,password:n,onPasswordChange:r,busy:i,onExport:a,onImport:o,error:s}){let d=(0,X.useRef)(null),f=e===`export`;return(0,Z.jsx)(O,{open:e!==null,onOpenChange:t,children:(0,Z.jsxs)(T,{className:`sm:max-w-md`,children:[(0,Z.jsxs)(C,{children:[(0,Z.jsxs)(E,{className:`text-sm flex items-center gap-1.5`,children:[(0,Z.jsx)(c,{className:`size-4`}),` `,f?`Export Codex Accounts`:`Import Codex Accounts`]}),(0,Z.jsx)(D,{className:`text-xs leading-relaxed`,children:f?`Writes a password-encrypted file containing each account's login.`:`Reads a backup file. The password must be the one it was exported with.`})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(R,{htmlFor:`codex-backup-password`,className:`text-xs`,children:`Password`}),(0,Z.jsx)(A,{id:`codex-backup-password`,type:`password`,placeholder:f?`Choose a password`:`Password used for the export`,value:n,onChange:e=>r(e.target.value),className:`text-xs`,autoComplete:f?`new-password`:`current-password`}),(0,Z.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`A backup holds full logins — keep the file and its password together.`})]}),s&&(0,Z.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:s}),(0,Z.jsx)(`input`,{ref:d,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&o(t)}}),(0,Z.jsxs)(w,{children:[(0,Z.jsx)(S,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Cancel`}),(0,Z.jsxs)(S,{size:`sm`,className:`text-xs cursor-pointer gap-1.5`,disabled:!n.trim()||i,onClick:()=>f?a():d.current?.click(),children:[i?(0,Z.jsx)(u,{className:`size-3.5 animate-spin`}):f?(0,Z.jsx)(m,{className:`size-3.5`}):(0,Z.jsx)(l,{className:`size-3.5`}),f?`Download backup`:`Choose file`]})]})]})})}var Ue=[{value:`round-robin`,label:`Round-robin`,hint:`Take the next account each time.`},{value:`fill-first`,label:`Fill-first`,hint:`Stay on one account until it runs out.`},{value:`lowest-usage`,label:`Lowest usage`,hint:`Pick whichever has the most left.`}];function We({open:e,onOpenChange:t,strategy:n,onChange:r}){return(0,Z.jsx)(O,{open:e,onOpenChange:t,children:(0,Z.jsxs)(T,{className:`sm:max-w-md`,children:[(0,Z.jsxs)(C,{children:[(0,Z.jsx)(E,{className:`text-sm`,children:`Codex Rotation`}),(0,Z.jsx)(D,{className:`text-xs leading-relaxed`,children:`How a new chat chooses among your Codex accounts.`})]}),(0,Z.jsx)(`div`,{className:`space-y-2`,children:Ue.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>r(e.value),"aria-current":n===e.value?`true`:void 0,className:y(`w-full text-left rounded-md border px-3 py-2.5 min-h-11 cursor-pointer transition-colors`,n===e.value?`border-primary bg-primary/10`:`border-border hover:bg-accent/50 active:bg-accent`),children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium`,children:e.label}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.hint})]},e.value))}),(0,Z.jsx)(w,{children:(0,Z.jsx)(S,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Done`})})]})})}function Ge(e){return e==null?null:Math.round(e*100)}function Ke({usage:e}){let t=e.session==null&&e.weekly==null;return(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(t||e.session!=null)&&(0,Z.jsx)(ge,{label:`5-Hour Session`,pct:Ge(e.fiveHour),reset:le(e.session),resetsAt:e.session?.resetsAt}),(t||e.weekly!=null)&&(0,Z.jsx)(ge,{label:`Weekly`,pct:Ge(e.sevenDay),reset:le(e.weekly),resetsAt:e.weekly?.resetsAt})]})}var qe=2e3,Je=21e4;function Ye(e){let[t,n]=(0,X.useState)([]),[r,i]=(0,X.useState)(`round-robin`),[a,o]=(0,X.useState)({}),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(new Set),[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(!1),[y,b]=(0,X.useState)(null),[x,S]=(0,X.useState)(null),[C,w]=(0,X.useState)(!1),[T,E]=(0,X.useState)(null),[D,O]=(0,X.useState)(!1),[k,A]=(0,X.useState)(``),[j,M]=(0,X.useState)(!1),[N,P]=(0,X.useState)(``),[ee,F]=(0,X.useState)(!1),[te,I]=(0,X.useState)(!1),[ne,L]=(0,X.useState)(null),R=(0,X.useRef)(null),z=(0,X.useRef)(null),B=(0,X.useRef)(0),V=(0,X.useRef)(!1),H=(0,X.useRef)(!1),U=(0,X.useRef)(!1),W=(0,X.useRef)(e);W.current=e;let G=(0,X.useCallback)(async()=>{c(!0);try{let e=await _.get(`/api/codex-accounts`);n(e.accounts),i(e.strategy),_.get(`/api/codex-accounts/usage`).then(o).catch(()=>{})}finally{c(!1)}},[]);(0,X.useEffect)(()=>{G()},[G]);let re=async()=>{if(!(!d.trim()||H.current||V.current||z.current)){H.current=!0,g(!0),b(null);try{await _.post(`/api/codex-accounts/api-key`,{apiKey:d.trim(),label:p.trim()||void 0}),f(``),m(``),e(),await G()}catch(e){b(e.message)}finally{H.current=!1,g(!1)}}},K=(0,X.useCallback)(()=>{B.current+=1,V.current=!1,U.current=!1,R.current?.(),R.current=null;let e=z.current;z.current=null,e&&_.del(`/api/codex-accounts/${e.method}-login/${e.id}`).catch(()=>{})},[]),q=(0,X.useCallback)(()=>{K(),S(null),w(!1),E(null),O(!1),A(``),M(!1)},[K]),ie=(0,X.useCallback)((e,t)=>{let n=Date.now()+(t===`browser`?61e4:Je),r=!1,i;R.current=()=>{r=!0,clearTimeout(i)};let a=async()=>{if(r)return;let o=null;try{o=await _.get(`/api/codex-accounts/${t}-login/${e}/status`)}catch{}if(!r){if(o?.state===`done`){q(),m(``),W.current(),await G();return}if(o?.state===`error`||Date.now()>n){q(),b(o?.state===`error`?o.error:`${t===`browser`?`Browser`:`Device`} login timed out.`);return}i=setTimeout(a,qe)}};a()},[q,G]);(0,X.useEffect)(()=>K,[K]);let J=async e=>{if(V.current||z.current||H.current)return;V.current=!0;let t=++B.current;O(!0),b(null);try{let n=await _.post(`/api/codex-accounts/${e}-login`,{label:p.trim()||void 0});if(t!==B.current){_.del(`/api/codex-accounts/${e}-login/${n.id}`).catch(()=>{});return}z.current={id:n.id,method:e},e===`device`?(S(n),w(!0)):E(n),ie(n.id,e)}catch(e){t===B.current&&b(e.message)}finally{t===B.current&&(V.current=!1,O(!1))}};return{accounts:t,strategy:r,usages:a,loading:s,apiKey:d,setApiKey:f,label:p,setLabel:m,adding:h,err:y,setErr:b,device:x,deviceWaiting:C,backupPassword:N,setBackupPassword:P,exporting:ee,importing:te,msg:ne,setMsg:L,toggling:l,load:G,addApiKey:re,startDevice:()=>J(`device`),startBrowser:()=>J(`browser`),browser:T,loginStarting:D,callbackUrl:k,setCallbackUrl:A,submittingCallback:j,submitCallback:async()=>{let e=z.current;if(e?.method!==`browser`||!k.trim()||U.current)return;let t=B.current;U.current=!0,M(!0),b(null);let n=k.trim();A(``);try{await _.post(`/api/codex-accounts/browser-login/${e.id}/callback`,{callbackUrl:n})}catch(e){t===B.current&&b(e.message)}finally{t===B.current&&(U.current=!1,M(!1))}},cancelLogin:q,remove:async e=>{await _.del(`/api/codex-accounts/${e}`),await G()},toggle:async(e,t)=>{let n=t===`disabled`?`active`:`disabled`;u(t=>new Set(t).add(e)),b(null);try{await _.patch(`/api/codex-accounts/${e}`,{status:n}),await G()}catch(e){b(e.message||`Could not change the account`)}finally{u(t=>{let n=new Set(t);return n.delete(e),n})}},toggleDailyGuard:async(e,t)=>{u(t=>new Set(t).add(e)),b(null);try{await _.patch(`/api/codex-accounts/${e}`,{dailyGuardEnabled:!t}),await G()}catch(e){b(e.message||`Could not change Daily guard`)}finally{u(t=>{let n=new Set(t);return n.delete(e),n})}},changeStrategy:async e=>{i(e);try{await _.put(`/api/codex-accounts/strategy`,{strategy:e})}catch{}},doExport:async()=>{if(!N.trim()){b(`Set a backup password first.`);return}F(!0),b(null),L(null);try{let t={"Content-Type":`application/json`},n=v();n&&(t.Authorization=`Bearer ${n}`);let r=await fetch(`/api/codex-accounts/export`,{method:`POST`,headers:t,body:JSON.stringify({password:N})});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error??`Export failed: ${r.status}`)}let i=await r.text(),a=new Blob([i],{type:`application/json`}),o=document.createElement(`a`);o.href=URL.createObjectURL(a),o.download=`ppm-codex-accounts-backup.json`,o.click(),URL.revokeObjectURL(o.href),L(`Backup downloaded.`),e()}catch(e){b(e.message)}finally{F(!1)}},doImport:async t=>{if(!N.trim()){b(`Enter the backup password first.`);return}I(!0),b(null),L(null);try{let n=await t.text(),r=await _.post(`/api/codex-accounts/import`,{data:n,password:N});L(`Imported ${r.imported}${r.skipped?`, skipped ${r.skipped}`:``}.`),e(),await G()}catch(e){b(e.message)}finally{I(!1)}}}}function Xe(){let[e,t]=(0,X.useState)(null),n=Ye(()=>t(null));return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(me,{description:(0,Z.jsxs)(Z.Fragment,{children:[`Each Codex account keeps its own login (`,(0,Z.jsx)(`code`,{children:`CODEX_HOME`}),`). One is picked per chat by the rotation setting.`]}),onRefresh:()=>void n.load(),refreshing:n.loading,actions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(S,{size:`sm`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`add`),children:[(0,Z.jsx)(p,{className:`size-4`}),` Add account`]}),(0,Z.jsxs)(S,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`export`),children:[(0,Z.jsx)(m,{className:`size-4`}),` Export`]}),(0,Z.jsxs)(S,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`import`),children:[(0,Z.jsx)(l,{className:`size-4`}),` Import`]}),(0,Z.jsxs)(S,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`rotation`),children:[(0,Z.jsx)(f,{className:`size-4`}),` Rotation`]})]})}),(0,Z.jsx)(se,{message:n.msg??n.err,onDismiss:()=>{n.setMsg(null),n.setErr(null)}}),(0,Z.jsxs)(`section`,{className:`space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-medium`,children:`Codex Accounts`}),(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground capitalize`,children:n.strategy.replace(`-`,` `)})]}),n.loading&&n.accounts.length===0?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,Z.jsx)(u,{className:`size-4 animate-spin`}),` Loading accounts...`]}):n.accounts.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,Z.jsx)(o,{className:`size-5 text-muted-foreground`}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No Codex accounts yet.`}),(0,Z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Chats use your default `,(0,Z.jsx)(`code`,{children:`~/.codex`}),` login until you add one.`]})]}):(0,Z.jsx)(oe,{children:n.accounts.map(e=>{let t=n.usages[e.id]??{};return(0,Z.jsxs)(fe,{dense:!0,className:`min-w-[300px] shrink-0 snap-start`,"data-testid":`account-card`,"data-account-id":e.id,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium truncate flex-1 min-w-0`,children:e.label}),(0,Z.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-text-subtle border border-border rounded px-1 shrink-0`,children:e.type}),de(e.planType)&&(0,Z.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0`,children:de(e.planType)}),(0,Z.jsx)(j,{checked:e.status!==`disabled`,onCheckedChange:()=>void n.toggle(e.id,e.status??`active`),disabled:n.toggling.has(e.id),"aria-label":e.status===`disabled`?`Enable account`:`Disable account`,className:`cursor-pointer shrink-0`}),(0,Z.jsxs)(M,{children:[(0,Z.jsx)(P,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,onClick:()=>void n.remove(e.id),"aria-label":`Remove account`,className:`p-2 rounded cursor-pointer text-text-subtle hover:text-error hover:bg-surface-elevated transition-colors shrink-0`,children:(0,Z.jsx)(h,{className:`size-4`})})}),(0,Z.jsx)(L,{side:`top`,children:`Remove account`})]})]}),(0,Z.jsx)(Ke,{usage:t}),t.session==null&&(()=>{let r=he(t.weekly);return r?(0,Z.jsxs)(`div`,{className:`flex min-h-12 items-center justify-between gap-3 rounded-md border px-2.5 py-1.5 ${e.dailyGuardEnabled&&r.blocked?`border-error/40 bg-error/5`:`border-border/50 bg-surface/40`}`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium ${e.dailyGuardEnabled&&r.blocked?`text-error`:`text-text-secondary`}`,children:[(0,Z.jsx)(`span`,{children:`Daily guard`}),(0,Z.jsxs)(M,{children:[(0,Z.jsx)(P,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,"aria-label":`About Daily guard`,className:`text-text-subtle hover:text-text-primary cursor-help`,children:(0,Z.jsx)(a,{className:`size-3.5`})})}),(0,Z.jsx)(L,{side:`top`,className:`max-w-64 text-xs leading-relaxed`,children:`Spreads the weekly quota across five weekdays, adding 20% per weekday. Weekend slots keep the previous cap; unused allowance carries forward. Daily slots start at the reset time and use UTC weekdays. Turn it off any time to use the remaining quota freely.`})]})]}),(0,Z.jsx)(`p`,{className:`text-[10px] tabular-nums ${e.dailyGuardEnabled&&r.blocked?`text-error`:`text-text-subtle`}`,children:e.dailyGuardEnabled&&r.blocked?`${Math.round(r.used*100)}% used / ${Math.round(r.cap*100)}% daily cap. New turns paused.`:`Weekday ${r.day}/5, ${Math.round(r.cap*100)}% daily cap`})]}),(0,Z.jsxs)(`span`,{className:`hidden`,title:`Weekday ${r.day}/5: hold weekly usage at or below ${Math.round(r.cap*100)}% to last until reset.`,children:[`Daily guard `,e.dailyGuardEnabled?`· Weekday ${r.day}/5 cap ${Math.round(r.cap*100)}%`:``]}),(0,Z.jsx)(j,{checked:!!e.dailyGuardEnabled,onCheckedChange:()=>void n.toggleDailyGuard(e.id,!!e.dailyGuardEnabled),disabled:n.toggling.has(e.id),"aria-label":e.dailyGuardEnabled?`Disable Daily guard`:`Enable Daily guard`,className:`cursor-pointer shrink-0`})]}):null})()]},e.id)})})]}),(0,Z.jsx)(Ve,{open:e===`add`,onOpenChange:e=>{e||n.cancelLogin(),t(e?`add`:null)},label:n.label,onLabelChange:n.setLabel,apiKey:n.apiKey,onApiKeyChange:n.setApiKey,adding:n.adding,onAddApiKey:()=>void n.addApiKey(),deviceWaiting:n.deviceWaiting,onStartDevice:()=>void n.startDevice(),device:n.device,browser:n.browser,onStartBrowser:()=>void n.startBrowser(),loginStarting:n.loginStarting,callbackUrl:n.callbackUrl,onCallbackUrlChange:n.setCallbackUrl,submittingCallback:n.submittingCallback,onSubmitCallback:()=>void n.submitCallback(),error:n.err}),(0,Z.jsx)(He,{mode:e===`export`?`export`:e===`import`?`import`:null,onOpenChange:e=>{e||t(null)},password:n.backupPassword,onPasswordChange:n.setBackupPassword,busy:n.exporting||n.importing,onExport:()=>void n.doExport(),onImport:e=>void n.doImport(e),error:n.err}),(0,Z.jsx)(We,{open:e===`rotation`,onOpenChange:e=>t(e?`rotation`:null),strategy:n.strategy,onChange:e=>void n.changeStrategy(e)})]})}var Ze=[{id:`claude`,label:`Claude`},{id:`codex`,label:`Codex`}];function Qe(){let[e,t]=(0,X.useState)(null),[n,r]=(0,X.useState)(`claude`);(0,X.useEffect)(()=>{let e=!1;return U().then(n=>{e||t(new Set(Object.keys(n.providers??{})))}).catch(()=>{e||t(new Set([`claude`]))}),()=>{e=!0}},[]);let i=Ze.filter(t=>t.id===`claude`||e?.has(t.id)),a=i.length>1;return(0,Z.jsxs)(`div`,{className:`space-y-4`,"data-testid":`accounts-pane`,"data-provider":n,children:[a&&(0,Z.jsx)(`div`,{className:`flex gap-1 border-b border-border/50`,children:i.map(e=>(0,Z.jsxs)(`button`,{onClick:()=>r(e.id),"data-testid":`accounts-tab-${e.id}`,"aria-current":n===e.id?`page`:void 0,className:`flex items-center gap-1.5 px-3 py-2 text-xs rounded-t transition-colors cursor-pointer ${n===e.id?`text-primary border-b-2 border-primary font-medium`:`text-text-subtle hover:text-text-secondary`}`,children:[(0,Z.jsx)(z,{providerId:e.id}),e.label]},e.id))}),e===null&&!a&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Z.jsx)(u,{className:`size-3 animate-spin`}),` Checking configured providers...`]}),n===`claude`?(0,Z.jsx)(Be,{}):(0,Z.jsx)(Xe,{})]})}export{Qe as AccountsSettingsSection};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import"./vendor-ui-DmZ-Mb-H.js";import{Dr as r,dn as i,ln as a,r as o,tr as s}from"./icons-DQjqk0lJ.js";import{s as c}from"./api-client-Jn3njtNw.js";import"./settings-store-tWrnlyEW.js";import"./vendor-mermaid-D6lgjvVE.js";import{n as l}from"./utils-Bmf_8h7Y.js";import{G as u,H as d,U as f,V as p,W as m,u as h}from"./index-CoTvom0K.js";import{t as g}from"./use-monaco-theme-DvWcXiCH.js";var _=e(t(),1),v=n();function y({metadata:e}){let t=e?.filePath,n=e?.name,l=e?.resourceType??`skill`,y=e?.scope??`user`,x=e?.readOnly===!0,S=e?.shadowed===!0,C=e?.shadowedBy,w=e?.project??``,[T,E]=(0,_.useState)(``),[D,O]=(0,_.useState)(``),[k,A]=(0,_.useState)(!0),[j,M]=(0,_.useState)(null),[N,P]=(0,_.useState)(!1),F=g(),I=(0,_.useRef)(``),L=T!==D;(0,_.useEffect)(()=>{let e=!1;return A(!0),M(null),m(t,w).then(t=>{e||(E(t.content),O(t.content),I.current=t.content)}).catch(t=>{e||M(t.message)}).finally(()=>{e||A(!1)}),()=>{e=!0}},[t,w]);let R=(0,_.useCallback)(async()=>{if(x||N)return;let e=I.current;if(e!==D){P(!0);try{await u(t,e,w),O(e),E(e),c.success(`Saved`),f.getState().reload()}catch(e){c.error(e.message)}finally{P(!1)}}},[t,w,D,x,N]);(0,_.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&(e.preventDefault(),R())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[R]);let z=d[l];return(0,v.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[(0,v.jsx)(z,{className:`size-4 text-text-subtle`}),(0,v.jsx)(`span`,{className:`text-sm font-semibold`,children:n}),(0,v.jsx)(p,{scope:y}),L&&!x&&(0,v.jsx)(`span`,{className:`size-1.5 rounded-full bg-primary`,title:`Unsaved changes`}),(0,v.jsx)(`div`,{className:`flex-1`}),(0,v.jsxs)(`span`,{className:`hidden sm:block text-[11px] text-text-subtle`,children:[l,` · markdown`]}),!x&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`button`,{onClick:()=>E(D),disabled:!L||N,className:`flex items-center gap-1 rounded px-2 py-1 text-xs text-text-secondary hover:bg-surface-elevated disabled:opacity-40`,children:[(0,v.jsx)(r,{className:`size-3.5`}),` Revert`]}),(0,v.jsxs)(`button`,{onClick:()=>void R(),disabled:!L||N,className:`flex items-center gap-1 rounded bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-40`,children:[N?(0,v.jsx)(a,{className:`size-3.5 animate-spin`}):(0,v.jsx)(s,{className:`size-3.5`}),` Save`]})]})]}),x&&(0,v.jsx)(b,{icon:i,tone:`muted`,children:`Bundled resource — read-only. Duplicate it (from the AI Resources panel) to make an editable copy.`}),S&&C&&(0,v.jsxs)(b,{icon:o,tone:`warn`,children:[`This `,l,` is overridden by another “`,C.name,`” from a higher-priority source (`,C.source,`). It is currently inactive.`]}),(0,v.jsx)(`div`,{className:`min-h-0 flex-1`,children:k?(0,v.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,v.jsx)(a,{className:`size-5 animate-spin text-primary`})}):j?(0,v.jsx)(`div`,{className:`p-6 text-center text-sm text-destructive`,children:j}):(0,v.jsx)(h,{height:`100%`,language:`markdown`,theme:F,value:T,onChange:e=>{let t=e??``;I.current=t,E(t)},options:{readOnly:x,minimap:{enabled:!1},fontSize:13,wordWrap:`on`,scrollBeyondLastLine:!1,lineNumbers:`on`}})})]})}function b({icon:e,tone:t,children:n}){return(0,v.jsxs)(`div`,{className:l(`flex items-start gap-2 px-3 py-2 text-[12px] shrink-0 border-b border-border`,t===`warn`?`bg-amber-500/10 text-amber-300`:`bg-surface-elevated text-text-secondary`),children:[(0,v.jsx)(e,{className:`mt-0.5 size-3.5 shrink-0`}),(0,v.jsx)(`span`,{children:n})]})}export{y as AiResourceEditor};
1
+ import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import"./vendor-ui-DmZ-Mb-H.js";import{Dr as r,dn as i,ln as a,r as o,tr as s}from"./icons-DQjqk0lJ.js";import{s as c}from"./api-client-Jn3njtNw.js";import"./settings-store-m6qOXoy4.js";import"./vendor-mermaid-D6lgjvVE.js";import{n as l}from"./utils-Bmf_8h7Y.js";import{G as u,K as d,U as f,W as p,q as m,u as h}from"./index-C3v3QRVR.js";import{t as g}from"./use-monaco-theme-DGi9_j5M.js";var _=e(t(),1),v=n();function y({metadata:e}){let t=e?.filePath,n=e?.name,l=e?.resourceType??`skill`,y=e?.scope??`user`,x=e?.readOnly===!0,S=e?.shadowed===!0,C=e?.shadowedBy,w=e?.project??``,[T,E]=(0,_.useState)(``),[D,O]=(0,_.useState)(``),[k,A]=(0,_.useState)(!0),[j,M]=(0,_.useState)(null),[N,P]=(0,_.useState)(!1),F=g(),I=(0,_.useRef)(``),L=T!==D;(0,_.useEffect)(()=>{let e=!1;return A(!0),M(null),d(t,w).then(t=>{e||(E(t.content),O(t.content),I.current=t.content)}).catch(t=>{e||M(t.message)}).finally(()=>{e||A(!1)}),()=>{e=!0}},[t,w]);let R=(0,_.useCallback)(async()=>{if(x||N)return;let e=I.current;if(e!==D){P(!0);try{await m(t,e,w),O(e),E(e),c.success(`Saved`),u.getState().reload()}catch(e){c.error(e.message)}finally{P(!1)}}},[t,w,D,x,N]);(0,_.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&(e.preventDefault(),R())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[R]);let z=p[l];return(0,v.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[(0,v.jsx)(z,{className:`size-4 text-text-subtle`}),(0,v.jsx)(`span`,{className:`text-sm font-semibold`,children:n}),(0,v.jsx)(f,{scope:y}),L&&!x&&(0,v.jsx)(`span`,{className:`size-1.5 rounded-full bg-primary`,title:`Unsaved changes`}),(0,v.jsx)(`div`,{className:`flex-1`}),(0,v.jsxs)(`span`,{className:`hidden sm:block text-[11px] text-text-subtle`,children:[l,` · markdown`]}),!x&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`button`,{onClick:()=>E(D),disabled:!L||N,className:`flex items-center gap-1 rounded px-2 py-1 text-xs text-text-secondary hover:bg-surface-elevated disabled:opacity-40`,children:[(0,v.jsx)(r,{className:`size-3.5`}),` Revert`]}),(0,v.jsxs)(`button`,{onClick:()=>void R(),disabled:!L||N,className:`flex items-center gap-1 rounded bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-40`,children:[N?(0,v.jsx)(a,{className:`size-3.5 animate-spin`}):(0,v.jsx)(s,{className:`size-3.5`}),` Save`]})]})]}),x&&(0,v.jsx)(b,{icon:i,tone:`muted`,children:`Bundled resource — read-only. Duplicate it (from the AI Resources panel) to make an editable copy.`}),S&&C&&(0,v.jsxs)(b,{icon:o,tone:`warn`,children:[`This `,l,` is overridden by another “`,C.name,`” from a higher-priority source (`,C.source,`). It is currently inactive.`]}),(0,v.jsx)(`div`,{className:`min-h-0 flex-1`,children:k?(0,v.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,v.jsx)(a,{className:`size-5 animate-spin text-primary`})}):j?(0,v.jsx)(`div`,{className:`p-6 text-center text-sm text-destructive`,children:j}):(0,v.jsx)(h,{height:`100%`,language:`markdown`,theme:F,value:T,onChange:e=>{let t=e??``;I.current=t,E(t)},options:{readOnly:x,minimap:{enabled:!1},fontSize:13,wordWrap:`on`,scrollBeyondLastLine:!1,lineNumbers:`on`}})})]})}function b({icon:e,tone:t,children:n}){return(0,v.jsxs)(`div`,{className:l(`flex items-start gap-2 px-3 py-2 text-[12px] shrink-0 border-b border-border`,t===`warn`?`bg-amber-500/10 text-amber-300`:`bg-surface-elevated text-text-secondary`),children:[(0,v.jsx)(e,{className:`mt-0.5 size-3.5 shrink-0`}),(0,v.jsx)(`span`,{children:n})]})}export{y as AiResourceEditor};
@@ -0,0 +1 @@
1
+ import"./vendor-markdown-CuWCHIVb.js";import"./vendor-ui-DmZ-Mb-H.js";import"./icons-DQjqk0lJ.js";import"./api-client-Jn3njtNw.js";import"./settings-store-m6qOXoy4.js";import"./vendor-mermaid-D6lgjvVE.js";import"./portal-container-context-BarKmT4S.js";import"./panel-store-D20Zuf3i.js";import"./window-store-UC1jJeLM.js";import"./tab-store-krAuHQ6_.js";import"./use-is-mobile-TkcwP1Gx.js";import"./button-B9CTrsEf.js";import"./dialog-B84_DJQ8.js";import"./mobile-bottom-sheet-C3TniEP-.js";import"./use-visual-viewport-Lp878uzs.js";import"./input-QNG_gTHh.js";import{t as e}from"./ai-settings-section-CyWSTidP.js";export{e as AISettingsSection};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import{Qn as r,ct as i,wr as a}from"./icons-DQjqk0lJ.js";import{n as o}from"./api-client-Jn3njtNw.js";import{t as s}from"./input-QNG_gTHh.js";import{$ as c,J as l,Q as u,V as d,X as f,Y as p,Z as m,ln as h,st as g,yn as _}from"./index-C3v3QRVR.js";import{getAISettings as v,updateAISettings as y}from"./api-settings-BZFSteM_.js";var b=e(t(),1),x=n(),S=[128e3,272e3,4e5,512e3,872e3,1e6],C=[1e5,2e5,23e4,35e4,45e4,75e4,9e5];function w({id:e,label:t,value:n,presets:r,disabled:i,compact:a,onChange:o}){let[c,l]=(0,b.useState)(!!n&&!r.includes(Number(n))),u=a?`text-[11px]`:`text-sm`;return(0,x.jsxs)(`div`,{className:`space-y-1`,children:[(0,x.jsx)(g,{htmlFor:e,className:u,children:t}),(0,x.jsxs)(`select`,{id:e,value:c?`custom`:n||`default`,disabled:i,"aria-describedby":`codex-context-help`,className:`w-full min-h-11 sm:min-h-0 rounded-md border border-input bg-background px-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 ${a?`h-7`:`h-9`} ${u}`,onChange:e=>{let t=e.target.value;l(t===`custom`),t!==`custom`&&o(t===`default`?``:t)},children:[(0,x.jsx)(`option`,{value:`default`,children:`Codex default`}),r.map(e=>(0,x.jsxs)(`option`,{value:String(e),children:[e===1e6?`1M`:`${e/1e3}K`,` tokens`]},e)),(0,x.jsx)(`option`,{value:`custom`,children:`Custom...`})]}),c&&(0,x.jsx)(s,{id:`${e}-custom`,"aria-label":`Custom ${t.toLowerCase()}`,type:`number`,min:1,step:1,required:!0,value:n,disabled:i,placeholder:`Enter tokens`,"aria-describedby":`codex-context-help`,className:`min-h-11 sm:min-h-0 ${a?`h-7 text-[11px]`:``}`,onChange:e=>o(e.target.value)})]})}function T({config:e,compact:t,saving:n,onSave:r}){let[i,a]=(0,b.useState)(String(e?.model_context_window??``)),[o,s]=(0,b.useState)(String(e?.model_auto_compact_token_limit??``)),[c,l]=(0,b.useState)(null),u=t?`text-[11px]`:`text-sm`,d=t?`text-[9px]`:`text-[11px]`;async function f(e){e.preventDefault();let t=i.trim()?Number(i):null,n=o.trim()?Number(o):null;if([t,n].some(e=>e!==null&&(!Number.isSafeInteger(e)||e<=0))){l(`Enter positive whole numbers of tokens, or leave blank for Codex defaults.`);return}if(t!==null&&n!==null&&n>t){l(`Auto-compact threshold must not exceed the context window.`);return}l(null),await r({model_context_window:t,model_auto_compact_token_limit:n})}return(0,x.jsxs)(`form`,{onSubmit:f,className:`space-y-2 rounded-md border border-border p-3`,children:[(0,x.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,x.jsx)(w,{id:`codex-context-window`,label:`Context window (tokens)`,value:i,presets:S,disabled:n,compact:t,onChange:e=>{a(e),l(null)}}),(0,x.jsx)(w,{id:`codex-compact-threshold`,label:`Auto-compact threshold (tokens)`,value:o,presets:C,disabled:n,compact:t,onChange:e=>{s(e),l(null)}})]}),(0,x.jsx)(`p`,{id:`codex-context-help`,className:`${d} text-muted-foreground`,children:`Choose Codex default to use Codex configuration and model defaults, or Custom to enter a value. Presets are shortcuts, not a list of limits supported by your model; increasing these values does not unlock a larger context window. Applies to new sessions and sessions resumed after a PPM restart.`}),c&&(0,x.jsx)(`p`,{role:`alert`,className:`${u} text-error`,children:c}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,x.jsx)(`a`,{href:`https://learn.chatgpt.com/docs/config-file/config-reference`,target:`_blank`,rel:`noreferrer`,className:`${d} text-primary underline`,children:`Codex context documentation`}),(0,x.jsx)(`button`,{type:`submit`,disabled:n,className:`min-h-11 sm:min-h-0 rounded-md border border-border px-3 py-1.5 hover:bg-surface-elevated disabled:opacity-50 ${u}`,children:n?`Saving...`:`Save context settings`})]})]})}var E=[{value:`low`,label:`Low`},{value:`medium`,label:`Medium`},{value:`high`,label:`High`},{value:`xhigh`,label:`Extra`},{value:`max`,label:`Max`}],D=[{value:`bypassPermissions`,label:`Bypass permissions (default)`},{value:`default`,label:`Ask before edits`},{value:`acceptEdits`,label:`Edit automatically`},{value:`plan`,label:`Plan mode`}],O={claude:`Claude`,cursor:`Cursor`,codex:`Codex`,gemini:`Gemini`};function k({compact:e}={}){let[t,n]=(0,b.useState)(null),[r,a]=(0,b.useState)(``),[S,C]=(0,b.useState)([]),[w,k]=(0,b.useState)(!1),[j,M]=(0,b.useState)(!1),[N,P]=(0,b.useState)(null),[F,I]=(0,b.useState)(0);(0,b.useEffect)(()=>{v().then(e=>{n(e),a(e.default_provider??`claude`)}).catch(e=>P(e.message))},[]),(0,b.useEffect)(()=>{r&&(k(!0),o.get(`/api/settings/ai/providers/${r}/models`).then(C).catch(()=>C([])).finally(()=>k(!1)))},[r]);let L=t?Object.keys(t.providers).filter(e=>e!==`mock`).map(e=>({id:e,name:O[e]??e})):[],R=t?.providers[r],z=R?.type===`agent-sdk`||!R?.type&&r===`claude`,B=async e=>{if(!t)return!1;M(!0),P(null);try{return n(await y(e)),I(e=>e+1),!0}catch(e){return P(e.message),!1}finally{M(!1)}},V=(e,t)=>B({providers:{[r]:{[e]:t}}}),H=e?`text-[11px]`:`text-sm`,U=e?`text-xs`:`text-sm`,W=e?`space-y-2`:`space-y-4`,G=e?`space-y-1.5`:`space-y-3`,K=e?`space-y-1`:`space-y-1.5`;if(!t)return(0,x.jsxs)(`div`,{className:G,children:[(0,x.jsx)(`h3`,{className:`${U} font-medium text-text-secondary`,children:`AI Settings`}),(0,x.jsx)(`p`,{className:`${H} text-text-subtle`,children:N?`Error: ${N}`:`Loading...`})]});let q=z?S:[{value:`__default__`,label:`Auto (default)`},...S];return(0,x.jsxs)(`div`,{className:W,children:[(0,x.jsx)(`h3`,{className:`${U} font-medium text-text-secondary`,children:`AI Settings`}),(0,x.jsxs)(`div`,{className:K,children:[(0,x.jsx)(g,{htmlFor:`ai-new-chat-provider`,className:e?H:void 0,children:`New chat provider`}),(0,x.jsxs)(l,{value:t.new_chat_provider_mode??`default`,disabled:j,onValueChange:e=>B({new_chat_provider_mode:e}),children:[(0,x.jsx)(m,{id:`ai-new-chat-provider`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,x.jsx)(u,{})}),(0,x.jsxs)(p,{children:[(0,x.jsx)(f,{value:`follow-focus`,children:`Follow last focused chat`}),(0,x.jsx)(f,{value:`default`,children:`Always use default provider`})]})]}),(0,x.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:t.new_chat_provider_mode===`follow-focus`?`New tabs follow the last chat you focused in this project, across panels. Existing tabs keep their provider.`:`New tabs always use the default provider. Existing tabs keep their provider.`})]}),(0,x.jsxs)(`div`,{className:K,children:[(0,x.jsx)(g,{htmlFor:`ai-default-provider`,className:e?H:void 0,children:`Default provider`}),(0,x.jsxs)(l,{value:t.default_provider,disabled:j,onValueChange:e=>B({default_provider:e}),children:[(0,x.jsx)(m,{id:`ai-default-provider`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,x.jsx)(u,{})}),(0,x.jsx)(p,{children:L.map(e=>(0,x.jsx)(f,{value:e.id,children:e.name},e.id))})]}),t.new_chat_provider_mode===`follow-focus`&&(0,x.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Used when no chat has been focused in this project yet.`})]}),(0,x.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border border-border p-3`,children:[(0,x.jsxs)(`div`,{className:K,children:[(0,x.jsx)(g,{htmlFor:`ai-share-provider-context`,className:e?H:void 0,children:`Share rules and memory between providers`}),(0,x.jsx)(`p`,{id:`ai-share-provider-context-description`,className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Share project rules and memory, plus global instruction files, across providers. Applies from the next project-chat message. Turning off keeps context already sent.`})]}),(0,x.jsx)(c,{id:`ai-share-provider-context`,"aria-describedby":`ai-share-provider-context-description`,checked:t.share_provider_context??!0,disabled:j,onCheckedChange:e=>B({share_provider_context:e})})]}),L.length>1&&(0,x.jsx)(`div`,{className:`flex gap-0.5 border-b border-border/50 -mx-1 px-1`,children:L.map(e=>(0,x.jsxs)(`button`,{onClick:()=>a(e.id),className:`flex items-center gap-1 px-2 py-1 text-[11px] rounded-t transition-colors ${r===e.id?`text-primary border-b-2 border-primary font-medium`:`text-text-subtle hover:text-text-secondary`}`,children:[(0,x.jsx)(_,{providerId:e.id}),(0,x.jsx)(`span`,{className:`capitalize`,children:e.name})]},e.id))}),(0,x.jsxs)(`div`,{className:G,children:[r===`codex`&&(0,x.jsxs)(`button`,{type:`button`,onClick:()=>h(`accounts`),className:`w-full flex items-center justify-between gap-2 rounded-md border border-border px-2.5 py-2 text-left cursor-pointer hover:bg-surface-elevated transition-colors`,children:[(0,x.jsx)(`span`,{className:`${H} text-text-secondary`,children:`Codex accounts & login`}),(0,x.jsx)(i,{className:`size-3.5 text-text-subtle shrink-0`})]}),S.length>0&&(0,x.jsxs)(`div`,{className:K,children:[(0,x.jsx)(g,{htmlFor:`ai-model`,className:e?H:void 0,children:`Model`}),(0,x.jsxs)(l,{value:z?R?.model??S[0]?.value:R?.model||`__default__`,onValueChange:e=>V(`model`,e===`__default__`?void 0:e),disabled:w,children:[(0,x.jsx)(m,{id:`ai-model`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,x.jsx)(u,{placeholder:w?`Loading models...`:`Select model`})}),(0,x.jsx)(p,{className:`max-h-[300px]`,children:q.map(e=>(0,x.jsx)(f,{value:e.value,children:e.label},e.value))})]})]}),r===`codex`&&(0,x.jsx)(T,{config:R,compact:e,saving:j,onSave:e=>B({providers:{codex:e}})},JSON.stringify([R?.model_context_window,R?.model_auto_compact_token_limit])),z&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:K,children:[(0,x.jsx)(g,{htmlFor:`ai-base-url`,className:e?H:void 0,children:`Base URL`}),(0,x.jsx)(s,{id:`ai-base-url`,type:`url`,defaultValue:R?.base_url??``,placeholder:`https://api.anthropic.com (default)`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{V(`base_url`,e.target.value.trim()||void 0)}},`baseurl-${r}-${F}`)]}),(0,x.jsxs)(`div`,{className:K,children:[(0,x.jsx)(g,{htmlFor:`ai-api-key`,className:e?H:void 0,children:`API Key / Token`}),(0,x.jsx)(s,{id:`ai-api-key`,type:`password`,defaultValue:R?.api_key??``,placeholder:`sk-ant-... (optional, overrides accounts)`,className:e?`h-7 text-[11px] font-mono`:`font-mono`,onBlur:e=>{let t=e.target.value.trim();t.startsWith(`••••`)||V(`api_key`,t||void 0)}},`apikey-${r}-${F}`),(0,x.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Direct API key or OAuth token. Leave empty to use connected accounts.`})]}),(0,x.jsxs)(`div`,{className:K,children:[(0,x.jsx)(g,{htmlFor:`ai-effort`,className:e?H:void 0,children:`Effort`}),(0,x.jsxs)(l,{value:R?.effort??`high`,onValueChange:e=>V(`effort`,e),children:[(0,x.jsx)(m,{id:`ai-effort`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,x.jsx)(u,{})}),(0,x.jsx)(p,{children:E.map(e=>(0,x.jsx)(f,{value:e.value,children:e.label},e.value))})]})]}),(0,x.jsxs)(`div`,{className:K,children:[(0,x.jsx)(g,{htmlFor:`ai-max-turns`,className:e?H:void 0,children:`Max Turns (1-500)`}),(0,x.jsx)(s,{id:`ai-max-turns`,type:`number`,min:1,max:500,defaultValue:R?.max_turns??100,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseInt(e.target.value);isNaN(t)||V(`max_turns`,t)}},`turns-${r}-${F}`)]}),(0,x.jsxs)(`div`,{className:K,children:[(0,x.jsx)(g,{htmlFor:`ai-budget`,className:e?H:void 0,children:`Max Budget (USD)`}),(0,x.jsx)(s,{id:`ai-budget`,type:`number`,step:.1,min:.01,max:50,defaultValue:R?.max_budget_usd??``,placeholder:`No limit`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseFloat(e.target.value);V(`max_budget_usd`,isNaN(t)?void 0:t)}},`budget-${r}-${F}`)]}),(0,x.jsxs)(`div`,{className:K,children:[(0,x.jsx)(g,{htmlFor:`ai-thinking`,className:e?H:void 0,children:`Thinking Budget (tokens)`}),(0,x.jsx)(s,{id:`ai-thinking`,type:`number`,min:0,defaultValue:R?.thinking_budget_tokens??``,placeholder:`Adaptive (model decides)`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseInt(e.target.value);V(`thinking_budget_tokens`,isNaN(t)?void 0:t)}},`thinking-${r}-${F}`)]}),(0,x.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(g,{htmlFor:`ai-agent-teams`,className:e?H:void 0,children:`Agent Teams`}),(0,x.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Experimental. Enables multi-agent collaboration with shared tasks and messaging. Uses ~7x more tokens.`})]}),(0,x.jsx)(c,{id:`ai-agent-teams`,checked:R?.agent_teams??!1,onCheckedChange:e=>V(`agent_teams`,e)})]}),R?.agent_teams&&(0,x.jsx)(A,{compact:e}),(0,x.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(g,{htmlFor:`ai-context-1m`,className:e?H:void 0,children:`1M Context Window`}),(0,x.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Requires an entitled account (Max/Team/Enterprise) and an Opus 4 / Sonnet 4 model. Other accounts will error.`})]}),(0,x.jsx)(c,{id:`ai-context-1m`,checked:R?.context_1m??!1,onCheckedChange:e=>V(`context_1m`,e)})]}),(0,x.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(g,{htmlFor:`ai-inherit-mcp`,className:e?H:void 0,children:`Inherit Claude Code MCP`}),(0,x.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Auto-load MCP servers from Claude Code's ~/.claude.json (global + per-project). Your own MCP servers override inherited ones.`})]}),(0,x.jsx)(c,{id:`ai-inherit-mcp`,checked:R?.inherit_claude_mcp??!0,onCheckedChange:e=>V(`inherit_claude_mcp`,e)})]}),(0,x.jsxs)(`div`,{className:K,children:[(0,x.jsx)(g,{className:e?H:void 0,children:`MCP sign-in`}),(0,x.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Servers that use OAuth stay unavailable to Claude until someone signs in. Project-scoped servers are listed in the project's AI Resources panel.`}),(0,x.jsx)(`div`,{className:`-mx-2`,children:(0,x.jsx)(d,{showWhenEmpty:!0})})]})]}),(0,x.jsxs)(`div`,{className:K,children:[(0,x.jsx)(g,{htmlFor:`ai-permission-mode`,className:e?H:void 0,children:`Default Permission Mode`}),(0,x.jsxs)(l,{value:R?.permission_mode??`bypassPermissions`,onValueChange:e=>V(`permission_mode`,e),children:[(0,x.jsx)(m,{id:`ai-permission-mode`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,x.jsx)(u,{})}),(0,x.jsx)(p,{children:D.map(e=>(0,x.jsx)(f,{value:e.value,children:e.label},e.value))})]})]}),(0,x.jsxs)(`div`,{className:K,children:[(0,x.jsx)(g,{htmlFor:`ai-system-prompt`,className:e?H:void 0,children:`Additional Instructions`}),(0,x.jsx)(`textarea`,{id:`ai-system-prompt`,rows:e?3:4,defaultValue:R?.system_prompt??``,placeholder:`Enter additional instructions for ${r}...`,className:`w-full rounded-md border border-input bg-background px-3 py-2 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${e?`text-[11px]`:`text-sm`}`,onBlur:e=>{V(`system_prompt`,e.target.value.trim()||void 0)}},`sysprompt-${r}-${F}`)]})]}),j&&(0,x.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`Saving...`}),N&&(0,x.jsx)(`p`,{className:`text-xs text-error`,children:N})]})}function A({compact:e}){let[t,n]=(0,b.useState)([]),[i,s]=(0,b.useState)(!1),[c,l]=(0,b.useState)(null),u=(0,b.useCallback)(async()=>{s(!0);try{n(await o.get(`/api/teams`)??[])}catch{}s(!1)},[]);(0,b.useEffect)(()=>{u()},[u]);let d=async e=>{try{await o.del(`/api/teams/${encodeURIComponent(e)}`),n(t=>t.filter(t=>t.name!==e)),l(null)}catch{}};return t.length===0&&!i?null:(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,x.jsxs)(g,{className:e?`text-[11px]`:void 0,children:[`Teams (`,t.length,`)`]}),(0,x.jsx)(`button`,{onClick:u,className:`text-text-subtle hover:text-foreground p-1`,"aria-label":`Refresh teams`,children:(0,x.jsx)(r,{className:`size-3 ${i?`animate-spin`:``}`})})]}),t.map(e=>(0,x.jsxs)(`div`,{className:`flex items-center justify-between p-2 rounded bg-surface-elevated text-xs`,children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsx)(`div`,{className:`font-medium truncate`,children:e.name}),e.description&&(0,x.jsx)(`div`,{className:`text-text-subtle truncate`,children:e.description}),(0,x.jsxs)(`div`,{className:`text-text-subtle`,children:[e.members?.length??e.memberCount??0,` members`,e.createdAt?` · ${new Date(e.createdAt).toLocaleDateString()}`:``]})]}),c===e.name?(0,x.jsxs)(`div`,{className:`flex gap-1 shrink-0 ml-2`,children:[(0,x.jsx)(`button`,{onClick:()=>d(e.name),className:`px-2 py-1 bg-error text-white rounded text-[10px]`,children:`Delete`}),(0,x.jsx)(`button`,{onClick:()=>l(null),className:`px-2 py-1 bg-panel-2 text-text rounded text-[10px]`,children:`Cancel`})]}):(0,x.jsx)(`button`,{onClick:()=>l(e.name),className:`shrink-0 text-text-subtle hover:text-error p-1 ml-2`,"aria-label":`Delete team ${e.name}`,children:(0,x.jsx)(a,{className:`size-3.5`})})]},e.name))]})}export{k as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import{c as r,l as i,s as a,u as o}from"./vendor-ui-DmZ-Mb-H.js";import{Wr as s,qn as c,w as l,wr as u,zr as d}from"./icons-DQjqk0lJ.js";import{s as f}from"./api-client-Jn3njtNw.js";import{t as p}from"./settings-store-tWrnlyEW.js";import"./vendor-mermaid-D6lgjvVE.js";import{n as m}from"./utils-Bmf_8h7Y.js";import"./portal-container-context-BarKmT4S.js";import{n as h}from"./use-is-mobile-TkcwP1Gx.js";import{n as g,t as _}from"./button-B9CTrsEf.js";import{a as v,i as y,n as b,o as x,r as S,t as C}from"./dialog-B84_DJQ8.js";import{t as w}from"./input-QNG_gTHh.js";import{n as T,r as E,t as D}from"./resolve-theme-BNubecVz.js";import{Ht as O,Z as k,_ as A,o as j,y as M}from"./index-CoTvom0K.js";import{t as N}from"./separator-DwDoQpxS.js";var P=n();function F(){let e=p(e=>e.themeStyle),t=p(e=>e.themeMode),n=p(e=>e.customThemeId),r=p(e=>e.customThemes),i=p(e=>e.setThemeStyle),a=p(e=>e.setThemeMode),o=D(e,t,r,n);return(0,P.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:T.map(e=>{let t=E[e];if(!t)return null;let n=o.id===e;return(0,P.jsxs)(`button`,{onClick:()=>{i(t.style),a(t.mode)},className:m(`relative flex items-center gap-2 rounded-lg border p-2 text-left transition-colors min-h-11`,n?`border-primary ring-[3px] ring-accent-wash`:`border-border hover:bg-accent/40`),children:[(0,P.jsx)(M,{swatch:t.swatch}),(0,P.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`span`,{className:`block truncate text-xs font-medium text-text`,children:t.name.replace(/ (Dark|Light)$/,``)}),(0,P.jsx)(`span`,{className:`block text-[10px] text-text-3 capitalize`,children:t.mode})]}),n&&(0,P.jsx)(l,{className:`absolute top-1 right-1 size-3.5 text-primary`})]},e)})})}var I=e(t(),1);function L({className:e,orientation:t=`horizontal`,...n}){return(0,P.jsx)(i,{"data-slot":`tabs`,"data-orientation":t,orientation:t,className:m(`group/tabs flex gap-2 data-[orientation=horizontal]:flex-col`,e),...n})}var R=g(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function z({className:e,variant:t=`default`,...n}){return(0,P.jsx)(r,{"data-slot":`tabs-list`,"data-variant":t,className:m(R({variant:t}),e),...n})}function B({className:e,...t}){return(0,P.jsx)(o,{"data-slot":`tabs-trigger`,className:m(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent`,`data-[state=active]:bg-background data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100`,e),...t})}function V({className:e,...t}){return(0,P.jsx)(a,{"data-slot":`tabs-content`,className:m(`flex-1 outline-none`,e),...t})}function H({open:e,onOpenChange:t}){let n=p(e=>e.importThemeFrom),r=p(e=>e.setCustomTheme),[i,a]=(0,I.useState)(`url`),[o,s]=(0,I.useState)(``),[c,l]=(0,I.useState)(``),[u,d]=(0,I.useState)(``),[m,h]=(0,I.useState)(!1),g=()=>{s(``),l(``),d(``),a(`url`)},T=async()=>{let e=i===`url`?o.trim():c.trim();if(!e){f.error(`Nothing to import`);return}h(!0);try{let a=await n({source:i===`url`?`url`:i===`upload`?`upload`:`json`,value:e,name:u.trim()||void 0});f.success(a.length>1?`Imported ${a.length} themes`:`Imported "${a[0]?.name}"`),a[0]&&r(a[0].id),g(),t(!1)}catch(e){f.error(e.message||`Import failed`)}finally{h(!1)}},E=async e=>{if(e)try{l(await e.text()),d(e.name.replace(/\.json$/i,``))}catch{f.error(`Could not read file`)}};return(0,P.jsx)(C,{open:e,onOpenChange:t,children:(0,P.jsxs)(b,{className:`max-w-md`,children:[(0,P.jsxs)(v,{children:[(0,P.jsx)(x,{children:`Import theme`}),(0,P.jsx)(S,{className:`text-text-3`,children:`Import a VSCode color theme. Single-mode themes apply to both dark and light.`})]}),(0,P.jsxs)(L,{value:i,onValueChange:e=>a(e),children:[(0,P.jsxs)(z,{className:`w-full`,children:[(0,P.jsx)(B,{value:`url`,className:`flex-1`,children:`URL`}),(0,P.jsx)(B,{value:`json`,className:`flex-1`,children:`Paste JSON`}),(0,P.jsx)(B,{value:`upload`,className:`flex-1`,children:`Upload`})]}),(0,P.jsxs)(V,{value:`url`,className:`space-y-2 pt-2`,children:[(0,P.jsx)(w,{placeholder:`https://…/theme.json or Marketplace .vsix URL`,value:o,onChange:e=>s(e.target.value)}),(0,P.jsx)(`p`,{className:`text-[11px] text-text-3`,children:`Only https URLs; private/internal addresses are blocked.`})]}),(0,P.jsx)(V,{value:`json`,className:`pt-2`,children:(0,P.jsx)(`textarea`,{className:`w-full h-40 rounded-md border border-border bg-surface p-2 text-xs font-mono text-text focus:outline-none focus:border-ring`,placeholder:`{ "name": "My Theme", "type": "dark", "colors": { … }, "tokenColors": [ … ] }`,value:c,onChange:e=>l(e.target.value)})}),(0,P.jsxs)(V,{value:`upload`,className:`space-y-2 pt-2`,children:[(0,P.jsx)(`input`,{type:`file`,accept:`.json,application/json`,onChange:e=>E(e.target.files?.[0]),className:`block w-full text-xs text-text-2 file:mr-3 file:rounded file:border file:border-border file:bg-panel-2 file:px-2 file:py-1 file:text-text`}),c&&(0,P.jsxs)(`p`,{className:`text-[11px] text-success`,children:[`File loaded (`,c.length,` chars)`]})]})]}),(0,P.jsx)(w,{placeholder:`Optional name`,value:u,onChange:e=>d(e.target.value)}),(0,P.jsxs)(y,{children:[(0,P.jsx)(_,{variant:`outline`,onClick:()=>t(!1),disabled:m,children:`Cancel`}),(0,P.jsx)(_,{onClick:T,disabled:m,children:m?`Importing…`:`Import`})]})]})})}function U(){let e=p(e=>e.customThemes),t=p(e=>e.themeStyle),n=p(e=>e.customThemeId),r=p(e=>e.setCustomTheme),i=p(e=>e.deleteCustomTheme),[a,o]=(0,I.useState)(!1);return(0,P.jsxs)(`section`,{className:`space-y-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:`Imported themes`}),(0,P.jsxs)(_,{size:`sm`,variant:`outline`,className:`h-7 gap-1 text-xs`,onClick:()=>o(!0),children:[(0,P.jsx)(c,{className:`size-3.5`}),` Import`]})]}),e.length===0?(0,P.jsx)(`p`,{className:`text-[11px] text-text-3`,children:`No imported themes yet. Import a VSCode theme from a URL, .vsix, or JSON.`}):(0,P.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>{let a=t===`custom`&&n===e.id;return(0,P.jsxs)(`li`,{className:m(`flex items-center gap-2 rounded-md border px-2 py-1.5`,a?`border-primary bg-primary/10`:`border-border`),children:[(0,P.jsx)(M,{swatch:e.swatch}),(0,P.jsxs)(`button`,{className:`flex-1 min-w-0 text-left`,onClick:()=>r(e.id),children:[(0,P.jsx)(`span`,{className:`block truncate text-xs text-text`,children:e.name}),(0,P.jsx)(`span`,{className:`block text-[10px] text-text-3`,children:e.mode})]}),a&&(0,P.jsx)(l,{className:`size-4 text-primary shrink-0`}),(0,P.jsx)(`button`,{className:`text-text-3 hover:text-error transition-colors shrink-0`,title:`Delete`,onClick:()=>void i(e.id),children:(0,P.jsx)(u,{className:`size-3.5`})})]},e.id)})}),(0,P.jsx)(H,{open:a,onOpenChange:o})]})}var W=[{value:`default`,label:`Default`},{value:`boxed`,label:`Boxed`},{value:`pill`,label:`Pill`}],G=[{value:`auto`,label:`Auto`},{value:`windows`,label:`Windows`},{value:`macos`,label:`macOS`}];function K({options:e,value:t,onChange:n}){return(0,P.jsx)(`div`,{className:`flex gap-2`,children:e.map(e=>(0,P.jsx)(_,{variant:t===e.value?`default`:`outline`,onClick:()=>n(e.value),className:m(`flex-1 cursor-pointer`,t===e.value&&`ring-2 ring-primary`),children:e.label},e.value))})}function q(){let{theme:e,setTheme:t,tabWrap:n,toggleTabWrap:r,editorTabStyle:i,setEditorTabStyle:a,explorerSkin:o,setExplorerSkin:c}=p(O(e=>({theme:e.themeMode,setTheme:e.setThemeMode,tabWrap:e.tabWrap,toggleTabWrap:e.toggleTabWrap,editorTabStyle:e.editorTabStyle,setEditorTabStyle:e.setEditorTabStyle,explorerSkin:e.explorerSkin,setExplorerSkin:e.setExplorerSkin}))),{wordWrap:l,toggleWordWrap:u,mobileWordWrap:f,toggleMobileWordWrap:g,lspEnabled:v,setLspEnabled:y}=p(O(e=>({wordWrap:e.wordWrap,toggleWordWrap:e.toggleWordWrap,mobileWordWrap:e.mobileWordWrap,toggleMobileWordWrap:e.toggleMobileWordWrap,lspEnabled:e.lspEnabled,setLspEnabled:e.setLspEnabled}))),b=h(),x=j();return(0,P.jsxs)(`div`,{className:`space-y-6`,children:[(0,P.jsxs)(`section`,{className:`space-y-3`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-medium`,children:`Theme`}),(0,P.jsx)(F,{}),(0,P.jsx)(`div`,{className:`flex gap-2`,children:A.map(n=>{let r=n.icon;return(0,P.jsxs)(_,{variant:e===n.value?`default`:`outline`,onClick:()=>t(n.value),className:m(`flex-1 gap-2 cursor-pointer`,e===n.value&&`ring-2 ring-primary`),children:[(0,P.jsx)(r,{className:`size-4`}),n.label]},n.value)})})]}),(0,P.jsx)(N,{}),(0,P.jsx)(U,{}),(0,P.jsx)(N,{}),(0,P.jsxs)(`section`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,P.jsx)(d,{className:`size-4 text-muted-foreground shrink-0`}),(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:`Wrap Tabs`}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Stack tabs in rows instead of scrolling`})]})]}),(0,P.jsx)(k,{checked:n,onCheckedChange:r})]}),(0,P.jsxs)(`section`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,P.jsx)(d,{className:`size-4 text-muted-foreground shrink-0`}),(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:`Word Wrap`}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:b?`Wrap long lines instead of scrolling sideways (this device)`:`Wrap long lines in the editor (Alt+Z)`})]})]}),(0,P.jsx)(k,{checked:b?f:l,onCheckedChange:()=>b?g():u()})]}),(0,P.jsxs)(`section`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,P.jsx)(s,{className:`size-4 text-muted-foreground shrink-0`}),(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:`Language Server`}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:x?`Off on a touch device — it runs a server process per project`:`Completions, hover, F12, rename and quick fix (this device)`})]})]}),(0,P.jsx)(k,{checked:v&&!x,disabled:x,onCheckedChange:y})]}),(0,P.jsxs)(`section`,{className:`space-y-2`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-medium`,children:`Tab Style`}),(0,P.jsx)(K,{options:W,value:i,onChange:a})]}),(0,P.jsxs)(`section`,{className:`space-y-2`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-medium`,children:`Explorer Skin`}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Chrome the OS File Explorer window wears. Auto follows the host platform.`}),(0,P.jsx)(K,{options:G,value:o,onChange:c})]})]})}export{q as AppearanceSettingsSection};
1
+ import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import{c as r,l as i,s as a,u as o}from"./vendor-ui-DmZ-Mb-H.js";import{Wr as s,qn as c,w as l,wr as u,zr as d}from"./icons-DQjqk0lJ.js";import{s as f}from"./api-client-Jn3njtNw.js";import{t as p}from"./settings-store-m6qOXoy4.js";import"./vendor-mermaid-D6lgjvVE.js";import{n as m}from"./utils-Bmf_8h7Y.js";import"./portal-container-context-BarKmT4S.js";import{n as h}from"./use-is-mobile-TkcwP1Gx.js";import{n as g,t as _}from"./button-B9CTrsEf.js";import{a as v,i as y,n as b,o as x,r as S,t as C}from"./dialog-B84_DJQ8.js";import{t as w}from"./input-QNG_gTHh.js";import{n as T,r as E,t as D}from"./resolve-theme-BNubecVz.js";import{$ as O,Wt as k,_ as A,o as j,y as M}from"./index-C3v3QRVR.js";import{t as N}from"./separator-DwDoQpxS.js";var P=n();function F(){let e=p(e=>e.themeStyle),t=p(e=>e.themeMode),n=p(e=>e.customThemeId),r=p(e=>e.customThemes),i=p(e=>e.setThemeStyle),a=p(e=>e.setThemeMode),o=D(e,t,r,n);return(0,P.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:T.map(e=>{let t=E[e];if(!t)return null;let n=o.id===e;return(0,P.jsxs)(`button`,{onClick:()=>{i(t.style),a(t.mode)},className:m(`relative flex items-center gap-2 rounded-lg border p-2 text-left transition-colors min-h-11`,n?`border-primary ring-[3px] ring-accent-wash`:`border-border hover:bg-accent/40`),children:[(0,P.jsx)(M,{swatch:t.swatch}),(0,P.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`span`,{className:`block truncate text-xs font-medium text-text`,children:t.name.replace(/ (Dark|Light)$/,``)}),(0,P.jsx)(`span`,{className:`block text-[10px] text-text-3 capitalize`,children:t.mode})]}),n&&(0,P.jsx)(l,{className:`absolute top-1 right-1 size-3.5 text-primary`})]},e)})})}var I=e(t(),1);function L({className:e,orientation:t=`horizontal`,...n}){return(0,P.jsx)(i,{"data-slot":`tabs`,"data-orientation":t,orientation:t,className:m(`group/tabs flex gap-2 data-[orientation=horizontal]:flex-col`,e),...n})}var R=g(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function z({className:e,variant:t=`default`,...n}){return(0,P.jsx)(r,{"data-slot":`tabs-list`,"data-variant":t,className:m(R({variant:t}),e),...n})}function B({className:e,...t}){return(0,P.jsx)(o,{"data-slot":`tabs-trigger`,className:m(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent`,`data-[state=active]:bg-background data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100`,e),...t})}function V({className:e,...t}){return(0,P.jsx)(a,{"data-slot":`tabs-content`,className:m(`flex-1 outline-none`,e),...t})}function H({open:e,onOpenChange:t}){let n=p(e=>e.importThemeFrom),r=p(e=>e.setCustomTheme),[i,a]=(0,I.useState)(`url`),[o,s]=(0,I.useState)(``),[c,l]=(0,I.useState)(``),[u,d]=(0,I.useState)(``),[m,h]=(0,I.useState)(!1),g=()=>{s(``),l(``),d(``),a(`url`)},T=async()=>{let e=i===`url`?o.trim():c.trim();if(!e){f.error(`Nothing to import`);return}h(!0);try{let a=await n({source:i===`url`?`url`:i===`upload`?`upload`:`json`,value:e,name:u.trim()||void 0});f.success(a.length>1?`Imported ${a.length} themes`:`Imported "${a[0]?.name}"`),a[0]&&r(a[0].id),g(),t(!1)}catch(e){f.error(e.message||`Import failed`)}finally{h(!1)}},E=async e=>{if(e)try{l(await e.text()),d(e.name.replace(/\.json$/i,``))}catch{f.error(`Could not read file`)}};return(0,P.jsx)(C,{open:e,onOpenChange:t,children:(0,P.jsxs)(b,{className:`max-w-md`,children:[(0,P.jsxs)(v,{children:[(0,P.jsx)(x,{children:`Import theme`}),(0,P.jsx)(S,{className:`text-text-3`,children:`Import a VSCode color theme. Single-mode themes apply to both dark and light.`})]}),(0,P.jsxs)(L,{value:i,onValueChange:e=>a(e),children:[(0,P.jsxs)(z,{className:`w-full`,children:[(0,P.jsx)(B,{value:`url`,className:`flex-1`,children:`URL`}),(0,P.jsx)(B,{value:`json`,className:`flex-1`,children:`Paste JSON`}),(0,P.jsx)(B,{value:`upload`,className:`flex-1`,children:`Upload`})]}),(0,P.jsxs)(V,{value:`url`,className:`space-y-2 pt-2`,children:[(0,P.jsx)(w,{placeholder:`https://…/theme.json or Marketplace .vsix URL`,value:o,onChange:e=>s(e.target.value)}),(0,P.jsx)(`p`,{className:`text-[11px] text-text-3`,children:`Only https URLs; private/internal addresses are blocked.`})]}),(0,P.jsx)(V,{value:`json`,className:`pt-2`,children:(0,P.jsx)(`textarea`,{className:`w-full h-40 rounded-md border border-border bg-surface p-2 text-xs font-mono text-text focus:outline-none focus:border-ring`,placeholder:`{ "name": "My Theme", "type": "dark", "colors": { … }, "tokenColors": [ … ] }`,value:c,onChange:e=>l(e.target.value)})}),(0,P.jsxs)(V,{value:`upload`,className:`space-y-2 pt-2`,children:[(0,P.jsx)(`input`,{type:`file`,accept:`.json,application/json`,onChange:e=>E(e.target.files?.[0]),className:`block w-full text-xs text-text-2 file:mr-3 file:rounded file:border file:border-border file:bg-panel-2 file:px-2 file:py-1 file:text-text`}),c&&(0,P.jsxs)(`p`,{className:`text-[11px] text-success`,children:[`File loaded (`,c.length,` chars)`]})]})]}),(0,P.jsx)(w,{placeholder:`Optional name`,value:u,onChange:e=>d(e.target.value)}),(0,P.jsxs)(y,{children:[(0,P.jsx)(_,{variant:`outline`,onClick:()=>t(!1),disabled:m,children:`Cancel`}),(0,P.jsx)(_,{onClick:T,disabled:m,children:m?`Importing…`:`Import`})]})]})})}function U(){let e=p(e=>e.customThemes),t=p(e=>e.themeStyle),n=p(e=>e.customThemeId),r=p(e=>e.setCustomTheme),i=p(e=>e.deleteCustomTheme),[a,o]=(0,I.useState)(!1);return(0,P.jsxs)(`section`,{className:`space-y-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:`Imported themes`}),(0,P.jsxs)(_,{size:`sm`,variant:`outline`,className:`h-7 gap-1 text-xs`,onClick:()=>o(!0),children:[(0,P.jsx)(c,{className:`size-3.5`}),` Import`]})]}),e.length===0?(0,P.jsx)(`p`,{className:`text-[11px] text-text-3`,children:`No imported themes yet. Import a VSCode theme from a URL, .vsix, or JSON.`}):(0,P.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>{let a=t===`custom`&&n===e.id;return(0,P.jsxs)(`li`,{className:m(`flex items-center gap-2 rounded-md border px-2 py-1.5`,a?`border-primary bg-primary/10`:`border-border`),children:[(0,P.jsx)(M,{swatch:e.swatch}),(0,P.jsxs)(`button`,{className:`flex-1 min-w-0 text-left`,onClick:()=>r(e.id),children:[(0,P.jsx)(`span`,{className:`block truncate text-xs text-text`,children:e.name}),(0,P.jsx)(`span`,{className:`block text-[10px] text-text-3`,children:e.mode})]}),a&&(0,P.jsx)(l,{className:`size-4 text-primary shrink-0`}),(0,P.jsx)(`button`,{className:`text-text-3 hover:text-error transition-colors shrink-0`,title:`Delete`,onClick:()=>void i(e.id),children:(0,P.jsx)(u,{className:`size-3.5`})})]},e.id)})}),(0,P.jsx)(H,{open:a,onOpenChange:o})]})}var W=[{value:`default`,label:`Default`},{value:`boxed`,label:`Boxed`},{value:`pill`,label:`Pill`}],G=[{value:`auto`,label:`Auto`},{value:`windows`,label:`Windows`},{value:`macos`,label:`macOS`}];function K({options:e,value:t,onChange:n}){return(0,P.jsx)(`div`,{className:`flex gap-2`,children:e.map(e=>(0,P.jsx)(_,{variant:t===e.value?`default`:`outline`,onClick:()=>n(e.value),className:m(`flex-1 cursor-pointer`,t===e.value&&`ring-2 ring-primary`),children:e.label},e.value))})}function q(){let{theme:e,setTheme:t,tabWrap:n,toggleTabWrap:r,editorTabStyle:i,setEditorTabStyle:a,explorerSkin:o,setExplorerSkin:c}=p(k(e=>({theme:e.themeMode,setTheme:e.setThemeMode,tabWrap:e.tabWrap,toggleTabWrap:e.toggleTabWrap,editorTabStyle:e.editorTabStyle,setEditorTabStyle:e.setEditorTabStyle,explorerSkin:e.explorerSkin,setExplorerSkin:e.setExplorerSkin}))),{wordWrap:l,toggleWordWrap:u,mobileWordWrap:f,toggleMobileWordWrap:g,lspEnabled:v,setLspEnabled:y}=p(k(e=>({wordWrap:e.wordWrap,toggleWordWrap:e.toggleWordWrap,mobileWordWrap:e.mobileWordWrap,toggleMobileWordWrap:e.toggleMobileWordWrap,lspEnabled:e.lspEnabled,setLspEnabled:e.setLspEnabled}))),b=h(),x=j();return(0,P.jsxs)(`div`,{className:`space-y-6`,children:[(0,P.jsxs)(`section`,{className:`space-y-3`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-medium`,children:`Theme`}),(0,P.jsx)(F,{}),(0,P.jsx)(`div`,{className:`flex gap-2`,children:A.map(n=>{let r=n.icon;return(0,P.jsxs)(_,{variant:e===n.value?`default`:`outline`,onClick:()=>t(n.value),className:m(`flex-1 gap-2 cursor-pointer`,e===n.value&&`ring-2 ring-primary`),children:[(0,P.jsx)(r,{className:`size-4`}),n.label]},n.value)})})]}),(0,P.jsx)(N,{}),(0,P.jsx)(U,{}),(0,P.jsx)(N,{}),(0,P.jsxs)(`section`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,P.jsx)(d,{className:`size-4 text-muted-foreground shrink-0`}),(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:`Wrap Tabs`}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Stack tabs in rows instead of scrolling`})]})]}),(0,P.jsx)(O,{checked:n,onCheckedChange:r})]}),(0,P.jsxs)(`section`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,P.jsx)(d,{className:`size-4 text-muted-foreground shrink-0`}),(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:`Word Wrap`}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:b?`Wrap long lines instead of scrolling sideways (this device)`:`Wrap long lines in the editor (Alt+Z)`})]})]}),(0,P.jsx)(O,{checked:b?f:l,onCheckedChange:()=>b?g():u()})]}),(0,P.jsxs)(`section`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,P.jsx)(s,{className:`size-4 text-muted-foreground shrink-0`}),(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:`Language Server`}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:x?`Off on a touch device — it runs a server process per project`:`Completions, hover, F12, rename and quick fix (this device)`})]})]}),(0,P.jsx)(O,{checked:v&&!x,disabled:x,onCheckedChange:y})]}),(0,P.jsxs)(`section`,{className:`space-y-2`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-medium`,children:`Tab Style`}),(0,P.jsx)(K,{options:W,value:i,onChange:a})]}),(0,P.jsxs)(`section`,{className:`space-y-2`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-medium`,children:`Explorer Skin`}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Chrome the OS File Explorer window wears. Auto follows the host platform.`}),(0,P.jsx)(K,{options:G,value:o,onChange:c})]})]})}export{q as AppearanceSettingsSection};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import"./vendor-ui-DmZ-Mb-H.js";import{O as r,Qn as i,_t as a,an as o,j as s,ln as c,u as l,w as u}from"./icons-DQjqk0lJ.js";import{n as d}from"./api-client-Jn3njtNw.js";import"./settings-store-tWrnlyEW.js";import"./vendor-mermaid-D6lgjvVE.js";import"./portal-container-context-BarKmT4S.js";import"./project-store-hNvwfqX3.js";import"./project-framework-store-ViZgce6y.js";import{n as f}from"./use-is-mobile-TkcwP1Gx.js";import"./git-repo-store-BCEPfUGT.js";import{t as p}from"./button-B9CTrsEf.js";import{t as m}from"./file-icons-wS-OmEVu.js";import{t as h}from"./mobile-bottom-sheet-C3TniEP-.js";import"./use-visual-viewport-Lp878uzs.js";import{t as g}from"./scroll-area-C0fQWNnx.js";import{At as ee,et as te,it as ne,nt as _,rt as re,tt as ie}from"./index-CoTvom0K.js";import"./use-monaco-theme-DvWcXiCH.js";import"./use-inline-blame-CKu-Sd-l.js";import{DiffViewer as ae}from"./diff-viewer-Bv2J64t8.js";var v=e(t(),1),y=`ppm:branch-review`,b=`${y}:recent`,x=20;function oe(e,t,n){return`${y}:${e}:${t}:${n}`}function S(e,t){return e[t.path]===t.blob}function se(e,t){let n={...e};return S(e,t)?delete n[t.path]:n[t.path]=t.blob,n}function C(e,t,n){if(!n)return{};let r={...e};for(let e of t)r[e.path]=e.blob;return r}function w(e,t){return t.reduce((t,n)=>t+(S(e,n)?1:0),0)}function T(e,t){let n=new Set(t.map(e=>e.path)),r={};for(let[t,i]of Object.entries(e))n.has(t)&&(r[t]=i);return r}function E(e){return e.find(e=>!e.binary)??e[0]??null}function ce(e,t,n){if(t.length===0)return null;let r=n?t.findIndex(e=>e.path===n)+1:0;for(let n=0;n<t.length;n++){let i=t[(r+n)%t.length];if(i&&!S(e,i))return i}return null}function le(e){try{let t=localStorage.getItem(e);if(!t)return{};let n=JSON.parse(t);if(!n||typeof n!=`object`||Array.isArray(n))return{};let r={};for(let[e,t]of Object.entries(n))typeof t==`string`&&(r[e]=t);return r}catch{return{}}}function D(e,t,n=x){let r=[t,...e.filter(e=>e!==t)];return{recent:r.slice(0,n),evicted:r.slice(n)}}function O(){try{let e=JSON.parse(localStorage.getItem(b)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function k(e,t){try{if(Object.keys(t).length===0){localStorage.removeItem(e);let t=O().filter(t=>t!==e);localStorage.setItem(b,JSON.stringify(t));return}localStorage.setItem(e,JSON.stringify(t));let{recent:n,evicted:r}=D(O(),e);for(let e of r)localStorage.removeItem(e);localStorage.setItem(b,JSON.stringify(n))}catch{}}var A=n(),j={M:`text-warning`,A:`text-success`,D:`text-error`,R:`text-primary`,C:`text-accent-2`,T:`text-text-3`};function M({children:e}){return(0,A.jsx)(`span`,{dir:`rtl`,className:`truncate text-left min-w-0 flex-1`,children:(0,A.jsx)(`bdi`,{children:e})})}function N(e){let{node:t,depth:n,byPath:i,reviewed:a,selectedPath:o,collapsed:c,onToggleCollapse:l,onSelect:d,onToggleReviewed:f}=e,p=t.file?i.get(t.fullPath):void 0;if(!p){let i=c.has(t.fullPath);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`button`,{type:`button`,"data-testid":`branch-review-folder`,className:`w-full flex items-center gap-1 px-2 py-1 text-xs min-h-11 md:min-h-0 hover:bg-surface-hover text-left`,style:{paddingLeft:n*14+8},onClick:()=>l(t.fullPath),children:[i?(0,A.jsx)(s,{className:`size-3 shrink-0`}):(0,A.jsx)(r,{className:`size-3 shrink-0`}),(0,A.jsx)(`span`,{className:`truncate text-text-2`,children:t.name})]}),!i&&t.children.map(t=>(0,A.jsx)(N,{...e,node:t,depth:n+1},t.fullPath))]})}let h=S(a,p),g=o===p.path;return(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 pr-2 py-1 text-xs cursor-pointer border-l-2 min-h-11 md:min-h-0 hover:bg-surface-hover ${g?`bg-primary/10 border-primary`:`border-transparent`}`,style:{paddingLeft:n*14+6},onClick:()=>d(p.path),"aria-current":g?`true`:void 0,"data-testid":`branch-review-file`,"data-path":p.path,"data-selected":g?`true`:`false`,"data-reviewed":h?`true`:`false`,children:[(0,A.jsx)(`button`,{type:`button`,"aria-label":h?`Mark ${p.path} unreviewed`:`Mark ${p.path} reviewed`,"data-testid":`branch-review-check`,className:`size-11 md:size-4 shrink-0 flex items-center justify-center`,onClick:e=>{e.stopPropagation(),f(p)},children:(0,A.jsx)(`span`,{"data-testid":`branch-review-check-box`,className:`size-4 rounded border flex items-center justify-center ${h?`bg-primary border-primary text-primary-foreground`:`border-border`}`,children:h&&(0,A.jsx)(u,{className:`size-3`})})}),(0,A.jsx)(m,{name:t.name,className:`size-3.5 shrink-0`}),(0,A.jsx)(M,{children:t.name}),(0,A.jsx)(`span`,{className:`shrink-0 font-mono ${j[p.status]}`,children:p.status}),p.binary?(0,A.jsx)(`span`,{className:`shrink-0 text-text-3 italic`,children:`bin`}):(0,A.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[10px]`,children:[(0,A.jsxs)(`span`,{className:`text-success`,children:[`+`,p.additions]}),` `,(0,A.jsxs)(`span`,{className:`text-error`,children:[`-`,p.deletions]})]})]})}function ue(e,t){let n=e.filter(e=>!e.remote&&e.name!==t);return n.find(e=>e.name===`main`)?.name??n.find(e=>e.name===`master`)?.name??n[0]?.name??``}function P({metadata:e}){let t=e?.projectName,n=ee(t),r=f(),[s,u]=(0,v.useState)([]),[m,y]=(0,v.useState)(``),[b,x]=(0,v.useState)(``),[S,D]=(0,v.useState)(null),[O,j]=(0,v.useState)(null),[P,F]=(0,v.useState)({}),[de,I]=(0,v.useState)(new Set),[L,R]=(0,v.useState)(!1),[z,B]=(0,v.useState)(null),[V,H]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(!t||!n.repo)return;let e=!1;return d.get(n.gitUrl(`/branches`)).then(t=>{if(e)return;u(t);let n=t.find(e=>e.current)?.name;x(e=>e||n||``),y(e=>e||ue(t,n))}).catch(t=>!e&&B(t instanceof Error?t.message:`Could not list branches`)),()=>{e=!0}},[t,n]);let U=(0,v.useRef)(null),W=(0,v.useCallback)(async()=>{if(!t||!n.repo||!m||!b)return;U.current?.abort();let e=new AbortController;U.current=e,R(!0),B(null);try{let t=new URLSearchParams({base:m,head:b}),r=await d.get(n.gitUrl(`/branch-diff?${t}`),{signal:e.signal});if(e.signal.aborted)return;D(r),j(e=>e&&r.files.some(t=>t.path===e)?e:E(r.files)?.path??null)}catch(t){if(e.signal.aborted)return;D(null),B(t instanceof Error?t.message:`Could not compare these branches`)}finally{e.signal.aborted||R(!1)}},[t,n,m,b]);(0,v.useEffect)(()=>(W(),()=>U.current?.abort()),[W]);let G=t&&m&&b?oe(t,m,b):null;(0,v.useEffect)(()=>{I(new Set)},[G]),(0,v.useEffect)(()=>{F(G?le(G):{})},[G]);let K=S&&S.base===m&&S.head===b?S:null;(0,v.useEffect)(()=>{!G||!K||F(e=>{let t=T(e,K.files);return Object.keys(t).length!==Object.keys(e).length&&k(G,t),t})},[G,K]);let q=(0,v.useCallback)(e=>{F(e),G&&k(G,e)},[G]),J=K?.files??[],Y=(0,v.useMemo)(()=>new Map(J.map(e=>[e.path,e])),[J]),X=(0,v.useMemo)(()=>w(P,J),[P,J]),fe=(0,v.useMemo)(()=>ie(te(J.map(e=>({path:e.path,status:e.status===`T`?`M`:e.status})))),[J]),Z=O?Y.get(O)??null:null,Q=(0,v.useCallback)(()=>{let e=ce(P,J,O);e&&(j(e.path),H(!1))},[P,J,O]);if(n.noRepo)return(0,A.jsx)(_,{onReload:n.reload});if(n.needsPick)return(0,A.jsx)(ne,{repos:n.repos,onChoose:n.choose});let $=(0,A.jsx)(g,{className:`h-full`,children:(0,A.jsxs)(`div`,{className:`py-1`,children:[J.length===0&&!L&&(0,A.jsx)(`div`,{className:`px-3 py-6 text-center text-xs text-text-3`,children:z?`—`:`These branches have identical trees.`}),fe.map(e=>(0,A.jsx)(N,{node:e,depth:0,byPath:Y,reviewed:P,selectedPath:O,collapsed:de,onToggleCollapse:e=>I(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelect:e=>{j(e),H(!1)},onToggleReviewed:e=>q(se(P,e))},e.fullPath)),!!K?.omitted&&(0,A.jsxs)(`div`,{className:`px-3 py-3 text-center text-xs text-text-3`,children:[K.omitted.toLocaleString(),` more `,K.omitted===1?`file`:`files`,` not listed.`]})]})});return(0,A.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-bg`,children:[n.isNested&&n.repo&&(0,A.jsx)(re,{repo:n.repo,repos:n.repos,onChoose:n.choose}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 border-b border-border shrink-0 flex-wrap`,children:[(0,A.jsx)(`select`,{value:m,onChange:e=>y(e.target.value),"aria-label":`Base branch`,"data-testid":`branch-review-base`,className:`h-7 max-w-[38%] rounded-md border border-border bg-panel px-2 text-xs min-w-0`,children:s.map(e=>(0,A.jsx)(`option`,{value:e.name,children:e.name},e.name))}),(0,A.jsx)(l,{className:`size-3.5 text-text-3 shrink-0`}),(0,A.jsx)(`select`,{value:b,onChange:e=>x(e.target.value),"aria-label":`Branch to review`,"data-testid":`branch-review-head`,className:`h-7 max-w-[38%] rounded-md border border-border bg-panel px-2 text-xs min-w-0`,children:s.map(e=>(0,A.jsx)(`option`,{value:e.name,children:e.name},e.name))}),(0,A.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,A.jsxs)(`span`,{className:`text-xs text-text-2 tabular-nums`,"data-testid":`branch-review-progress`,children:[X,`/`,J.length,` reviewed`]}),(0,A.jsx)(p,{variant:`ghost`,size:`icon-xs`,title:X===J.length&&J.length>0?`Clear all`:`Mark all reviewed`,disabled:J.length===0,onClick:()=>q(C(P,J,X!==J.length)),children:(0,A.jsx)(o,{className:`size-3.5`})}),(0,A.jsx)(p,{variant:`ghost`,size:`icon-xs`,title:`Reload`,onClick:()=>void W(),children:(0,A.jsx)(i,{className:L?`animate-spin`:``})})]})]}),z&&(0,A.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-destructive bg-destructive/10 shrink-0`,children:z}),(0,A.jsxs)(`div`,{className:`flex-1 flex min-h-0`,children:[!r&&(0,A.jsx)(`div`,{className:`w-72 shrink-0 border-r border-border flex flex-col min-h-0`,children:$}),(0,A.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col`,children:Z?(0,A.jsx)(ae,{metadata:{filePath:n.projectFile(Z.path),projectName:t,ref1:K?.mergeBase,ref2:K?.headCommit}},`${Z.path}:${K?.mergeBase}:${K?.headCommit}`):(0,A.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-xs text-text-3`,children:L?(0,A.jsx)(c,{className:`size-4 animate-spin`}):`Nothing to review.`})})]}),r&&(0,A.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border p-2 shrink-0`,children:[(0,A.jsxs)(p,{variant:`secondary`,size:`sm`,className:`flex-1 min-h-11`,onClick:()=>H(!0),children:[(0,A.jsx)(a,{className:`size-4`}),J.length,` files`]}),(0,A.jsx)(p,{variant:`secondary`,size:`sm`,className:`flex-1 min-h-11`,onClick:Q,children:`Next unreviewed`})]}),r&&(0,A.jsx)(h,{open:V,onClose:()=>H(!1),children:(0,A.jsx)(`div`,{className:`max-h-[70vh] overflow-hidden flex flex-col`,children:$})}),!r&&Z&&(0,A.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border px-2 py-1 shrink-0`,children:[(0,A.jsx)(M,{children:Z.path}),(0,A.jsx)(p,{variant:`ghost`,size:`xs`,onClick:Q,children:`Next unreviewed`})]})]})}export{P as BranchReviewTab};
1
+ import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import"./vendor-ui-DmZ-Mb-H.js";import{O as r,Qn as i,_t as a,an as o,j as s,ln as c,u as l,w as u}from"./icons-DQjqk0lJ.js";import{n as d}from"./api-client-Jn3njtNw.js";import"./settings-store-m6qOXoy4.js";import"./vendor-mermaid-D6lgjvVE.js";import"./portal-container-context-BarKmT4S.js";import"./project-store-hNvwfqX3.js";import"./project-framework-store-ViZgce6y.js";import{n as f}from"./use-is-mobile-TkcwP1Gx.js";import"./git-repo-store-BCEPfUGT.js";import{t as p}from"./button-B9CTrsEf.js";import{t as m}from"./file-icons-wS-OmEVu.js";import{t as h}from"./mobile-bottom-sheet-C3TniEP-.js";import"./use-visual-viewport-Lp878uzs.js";import{t as g}from"./scroll-area-C0fQWNnx.js";import{Mt as ee,at as te,it as ne,nt as _,ot as re,rt as ie}from"./index-C3v3QRVR.js";import"./use-monaco-theme-DGi9_j5M.js";import"./use-inline-blame-B40AsaN2.js";import{DiffViewer as ae}from"./diff-viewer-i0_wCJL2.js";var v=e(t(),1),y=`ppm:branch-review`,b=`${y}:recent`,x=20;function oe(e,t,n){return`${y}:${e}:${t}:${n}`}function S(e,t){return e[t.path]===t.blob}function se(e,t){let n={...e};return S(e,t)?delete n[t.path]:n[t.path]=t.blob,n}function C(e,t,n){if(!n)return{};let r={...e};for(let e of t)r[e.path]=e.blob;return r}function w(e,t){return t.reduce((t,n)=>t+(S(e,n)?1:0),0)}function T(e,t){let n=new Set(t.map(e=>e.path)),r={};for(let[t,i]of Object.entries(e))n.has(t)&&(r[t]=i);return r}function E(e){return e.find(e=>!e.binary)??e[0]??null}function ce(e,t,n){if(t.length===0)return null;let r=n?t.findIndex(e=>e.path===n)+1:0;for(let n=0;n<t.length;n++){let i=t[(r+n)%t.length];if(i&&!S(e,i))return i}return null}function le(e){try{let t=localStorage.getItem(e);if(!t)return{};let n=JSON.parse(t);if(!n||typeof n!=`object`||Array.isArray(n))return{};let r={};for(let[e,t]of Object.entries(n))typeof t==`string`&&(r[e]=t);return r}catch{return{}}}function D(e,t,n=x){let r=[t,...e.filter(e=>e!==t)];return{recent:r.slice(0,n),evicted:r.slice(n)}}function O(){try{let e=JSON.parse(localStorage.getItem(b)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function k(e,t){try{if(Object.keys(t).length===0){localStorage.removeItem(e);let t=O().filter(t=>t!==e);localStorage.setItem(b,JSON.stringify(t));return}localStorage.setItem(e,JSON.stringify(t));let{recent:n,evicted:r}=D(O(),e);for(let e of r)localStorage.removeItem(e);localStorage.setItem(b,JSON.stringify(n))}catch{}}var A=n(),j={M:`text-warning`,A:`text-success`,D:`text-error`,R:`text-primary`,C:`text-accent-2`,T:`text-text-3`};function M({children:e}){return(0,A.jsx)(`span`,{dir:`rtl`,className:`truncate text-left min-w-0 flex-1`,children:(0,A.jsx)(`bdi`,{children:e})})}function N(e){let{node:t,depth:n,byPath:i,reviewed:a,selectedPath:o,collapsed:c,onToggleCollapse:l,onSelect:d,onToggleReviewed:f}=e,p=t.file?i.get(t.fullPath):void 0;if(!p){let i=c.has(t.fullPath);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`button`,{type:`button`,"data-testid":`branch-review-folder`,className:`w-full flex items-center gap-1 px-2 py-1 text-xs min-h-11 md:min-h-0 hover:bg-surface-hover text-left`,style:{paddingLeft:n*14+8},onClick:()=>l(t.fullPath),children:[i?(0,A.jsx)(s,{className:`size-3 shrink-0`}):(0,A.jsx)(r,{className:`size-3 shrink-0`}),(0,A.jsx)(`span`,{className:`truncate text-text-2`,children:t.name})]}),!i&&t.children.map(t=>(0,A.jsx)(N,{...e,node:t,depth:n+1},t.fullPath))]})}let h=S(a,p),g=o===p.path;return(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 pr-2 py-1 text-xs cursor-pointer border-l-2 min-h-11 md:min-h-0 hover:bg-surface-hover ${g?`bg-primary/10 border-primary`:`border-transparent`}`,style:{paddingLeft:n*14+6},onClick:()=>d(p.path),"aria-current":g?`true`:void 0,"data-testid":`branch-review-file`,"data-path":p.path,"data-selected":g?`true`:`false`,"data-reviewed":h?`true`:`false`,children:[(0,A.jsx)(`button`,{type:`button`,"aria-label":h?`Mark ${p.path} unreviewed`:`Mark ${p.path} reviewed`,"data-testid":`branch-review-check`,className:`size-11 md:size-4 shrink-0 flex items-center justify-center`,onClick:e=>{e.stopPropagation(),f(p)},children:(0,A.jsx)(`span`,{"data-testid":`branch-review-check-box`,className:`size-4 rounded border flex items-center justify-center ${h?`bg-primary border-primary text-primary-foreground`:`border-border`}`,children:h&&(0,A.jsx)(u,{className:`size-3`})})}),(0,A.jsx)(m,{name:t.name,className:`size-3.5 shrink-0`}),(0,A.jsx)(M,{children:t.name}),(0,A.jsx)(`span`,{className:`shrink-0 font-mono ${j[p.status]}`,children:p.status}),p.binary?(0,A.jsx)(`span`,{className:`shrink-0 text-text-3 italic`,children:`bin`}):(0,A.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[10px]`,children:[(0,A.jsxs)(`span`,{className:`text-success`,children:[`+`,p.additions]}),` `,(0,A.jsxs)(`span`,{className:`text-error`,children:[`-`,p.deletions]})]})]})}function ue(e,t){let n=e.filter(e=>!e.remote&&e.name!==t);return n.find(e=>e.name===`main`)?.name??n.find(e=>e.name===`master`)?.name??n[0]?.name??``}function P({metadata:e}){let t=e?.projectName,n=ee(t),r=f(),[s,u]=(0,v.useState)([]),[m,y]=(0,v.useState)(``),[b,x]=(0,v.useState)(``),[S,D]=(0,v.useState)(null),[O,j]=(0,v.useState)(null),[P,F]=(0,v.useState)({}),[de,I]=(0,v.useState)(new Set),[L,R]=(0,v.useState)(!1),[z,B]=(0,v.useState)(null),[V,H]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(!t||!n.repo)return;let e=!1;return d.get(n.gitUrl(`/branches`)).then(t=>{if(e)return;u(t);let n=t.find(e=>e.current)?.name;x(e=>e||n||``),y(e=>e||ue(t,n))}).catch(t=>!e&&B(t instanceof Error?t.message:`Could not list branches`)),()=>{e=!0}},[t,n]);let U=(0,v.useRef)(null),W=(0,v.useCallback)(async()=>{if(!t||!n.repo||!m||!b)return;U.current?.abort();let e=new AbortController;U.current=e,R(!0),B(null);try{let t=new URLSearchParams({base:m,head:b}),r=await d.get(n.gitUrl(`/branch-diff?${t}`),{signal:e.signal});if(e.signal.aborted)return;D(r),j(e=>e&&r.files.some(t=>t.path===e)?e:E(r.files)?.path??null)}catch(t){if(e.signal.aborted)return;D(null),B(t instanceof Error?t.message:`Could not compare these branches`)}finally{e.signal.aborted||R(!1)}},[t,n,m,b]);(0,v.useEffect)(()=>(W(),()=>U.current?.abort()),[W]);let G=t&&m&&b?oe(t,m,b):null;(0,v.useEffect)(()=>{I(new Set)},[G]),(0,v.useEffect)(()=>{F(G?le(G):{})},[G]);let K=S&&S.base===m&&S.head===b?S:null;(0,v.useEffect)(()=>{!G||!K||F(e=>{let t=T(e,K.files);return Object.keys(t).length!==Object.keys(e).length&&k(G,t),t})},[G,K]);let q=(0,v.useCallback)(e=>{F(e),G&&k(G,e)},[G]),J=K?.files??[],Y=(0,v.useMemo)(()=>new Map(J.map(e=>[e.path,e])),[J]),X=(0,v.useMemo)(()=>w(P,J),[P,J]),fe=(0,v.useMemo)(()=>ie(_(J.map(e=>({path:e.path,status:e.status===`T`?`M`:e.status})))),[J]),Z=O?Y.get(O)??null:null,Q=(0,v.useCallback)(()=>{let e=ce(P,J,O);e&&(j(e.path),H(!1))},[P,J,O]);if(n.noRepo)return(0,A.jsx)(ne,{onReload:n.reload});if(n.needsPick)return(0,A.jsx)(re,{repos:n.repos,onChoose:n.choose});let $=(0,A.jsx)(g,{className:`h-full`,children:(0,A.jsxs)(`div`,{className:`py-1`,children:[J.length===0&&!L&&(0,A.jsx)(`div`,{className:`px-3 py-6 text-center text-xs text-text-3`,children:z?`—`:`These branches have identical trees.`}),fe.map(e=>(0,A.jsx)(N,{node:e,depth:0,byPath:Y,reviewed:P,selectedPath:O,collapsed:de,onToggleCollapse:e=>I(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelect:e=>{j(e),H(!1)},onToggleReviewed:e=>q(se(P,e))},e.fullPath)),!!K?.omitted&&(0,A.jsxs)(`div`,{className:`px-3 py-3 text-center text-xs text-text-3`,children:[K.omitted.toLocaleString(),` more `,K.omitted===1?`file`:`files`,` not listed.`]})]})});return(0,A.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-bg`,children:[n.isNested&&n.repo&&(0,A.jsx)(te,{repo:n.repo,repos:n.repos,onChoose:n.choose}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 border-b border-border shrink-0 flex-wrap`,children:[(0,A.jsx)(`select`,{value:m,onChange:e=>y(e.target.value),"aria-label":`Base branch`,"data-testid":`branch-review-base`,className:`h-7 max-w-[38%] rounded-md border border-border bg-panel px-2 text-xs min-w-0`,children:s.map(e=>(0,A.jsx)(`option`,{value:e.name,children:e.name},e.name))}),(0,A.jsx)(l,{className:`size-3.5 text-text-3 shrink-0`}),(0,A.jsx)(`select`,{value:b,onChange:e=>x(e.target.value),"aria-label":`Branch to review`,"data-testid":`branch-review-head`,className:`h-7 max-w-[38%] rounded-md border border-border bg-panel px-2 text-xs min-w-0`,children:s.map(e=>(0,A.jsx)(`option`,{value:e.name,children:e.name},e.name))}),(0,A.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,A.jsxs)(`span`,{className:`text-xs text-text-2 tabular-nums`,"data-testid":`branch-review-progress`,children:[X,`/`,J.length,` reviewed`]}),(0,A.jsx)(p,{variant:`ghost`,size:`icon-xs`,title:X===J.length&&J.length>0?`Clear all`:`Mark all reviewed`,disabled:J.length===0,onClick:()=>q(C(P,J,X!==J.length)),children:(0,A.jsx)(o,{className:`size-3.5`})}),(0,A.jsx)(p,{variant:`ghost`,size:`icon-xs`,title:`Reload`,onClick:()=>void W(),children:(0,A.jsx)(i,{className:L?`animate-spin`:``})})]})]}),z&&(0,A.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-destructive bg-destructive/10 shrink-0`,children:z}),(0,A.jsxs)(`div`,{className:`flex-1 flex min-h-0`,children:[!r&&(0,A.jsx)(`div`,{className:`w-72 shrink-0 border-r border-border flex flex-col min-h-0`,children:$}),(0,A.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col`,children:Z?(0,A.jsx)(ae,{metadata:{filePath:n.projectFile(Z.path),projectName:t,ref1:K?.mergeBase,ref2:K?.headCommit}},`${Z.path}:${K?.mergeBase}:${K?.headCommit}`):(0,A.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-xs text-text-3`,children:L?(0,A.jsx)(c,{className:`size-4 animate-spin`}):`Nothing to review.`})})]}),r&&(0,A.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border p-2 shrink-0`,children:[(0,A.jsxs)(p,{variant:`secondary`,size:`sm`,className:`flex-1 min-h-11`,onClick:()=>H(!0),children:[(0,A.jsx)(a,{className:`size-4`}),J.length,` files`]}),(0,A.jsx)(p,{variant:`secondary`,size:`sm`,className:`flex-1 min-h-11`,onClick:Q,children:`Next unreviewed`})]}),r&&(0,A.jsx)(h,{open:V,onClose:()=>H(!1),children:(0,A.jsx)(`div`,{className:`max-h-[70vh] overflow-hidden flex flex-col`,children:$})}),!r&&Z&&(0,A.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border px-2 py-1 shrink-0`,children:[(0,A.jsx)(M,{children:Z.path}),(0,A.jsx)(p,{variant:`ghost`,size:`xs`,onClick:Q,children:`Next unreviewed`})]})]})}export{P as BranchReviewTab};