@xopcai/xopc 0.0.122 → 0.0.124

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 (273) hide show
  1. package/README.md +28 -11
  2. package/README.zh-CN.md +28 -11
  3. package/dist/browser-ext/manifest.json +1 -1
  4. package/dist/extensions/telegram/xopc.extension.json +1 -1
  5. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CK3s5cJo.js → agent-avatar-dicebear-B5uSVAyJ.js} +1 -1
  6. package/dist/gateway/static/root/assets/agents-BjIxt67Z.js +2 -0
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-CWsNHtTs.js → app-management-settings-panel-CYCONLIL.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-C4b8y6iZ.js → appearance-settings-Clw3ryKg.js} +1 -1
  9. package/dist/gateway/static/root/assets/apps-page-QICTeGjX.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-DAtNW3Ia.js → archive-plugin-CXUGRp2i.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-Dm-RY54y.js → attachment-load-Cmiub3Wg.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automation-suggestion-card-BKHewSVT.js → automation-suggestion-card-CU0-4nQ-.js} +1 -1
  13. package/dist/gateway/static/root/assets/automations-page-Car-jtiz.js +1 -0
  14. package/dist/gateway/static/root/assets/{binary-plugins-BG6Xnk71.js → binary-plugins-0Izz-N3p.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-DfndiO3h.js → block-editor-C1Kv0IkJ.js} +28 -28
  16. package/dist/gateway/static/root/assets/browser-settings-page-CMeBJzlS.js +8 -0
  17. package/dist/gateway/static/root/assets/{capability-presets-api-Cx93GLdw.js → capability-presets-api-BmQTM9Il.js} +1 -1
  18. package/dist/gateway/static/root/assets/capability-presets-settings-panel-DZEJEoCF.js +1 -0
  19. package/dist/gateway/static/root/assets/{channel-recipient-api-DdPTtEs8.js → channel-recipient-api-BeA2aVor.js} +1 -1
  20. package/dist/gateway/static/root/assets/channels-settings-kkW-xFau.js +1 -0
  21. package/dist/gateway/static/root/assets/connectors-page-BvaQvO5F.js +2 -0
  22. package/dist/gateway/static/root/assets/{directory-picker-path-field-D835EHJd.js → directory-picker-path-field-2rjzUu57.js} +1 -1
  23. package/dist/gateway/static/root/assets/{dreaming-settings-CCa1F7Fg.js → dreaming-settings-DnHO686d.js} +1 -1
  24. package/dist/gateway/static/root/assets/{extension-debug-page-W2ITCPSA.js → extension-debug-page-BGLRuWVN.js} +1 -1
  25. package/dist/gateway/static/root/assets/{extension-page-DrvUytvn.js → extension-page-D978ePp9.js} +1 -1
  26. package/dist/gateway/static/root/assets/{extension-settings-page-qM8aLT5u.js → extension-settings-page-B6Ih4Swx.js} +1 -1
  27. package/dist/gateway/static/root/assets/{fetch-ovkvM8KQ.js → fetch-BU5S0Sn7.js} +1 -1
  28. package/dist/gateway/static/root/assets/{gateway-config-api-BB3biuD0.js → gateway-config-api-BIPGwrl1.js} +1 -1
  29. package/dist/gateway/static/root/assets/gateway-settings-CMEA3r5u.js +1 -0
  30. package/dist/gateway/static/root/assets/{gateway-startup-retry-CanQ8UcR.js → gateway-startup-retry-Cd0Zz30N.js} +1 -1
  31. package/dist/gateway/static/root/assets/{goal-create-dialog-CNqNdEkQ.js → goal-create-dialog-B-KHKeXN.js} +1 -1
  32. package/dist/gateway/static/root/assets/goal-detail-page-BxrSoWdj.js +1 -0
  33. package/dist/gateway/static/root/assets/{goals-config-api-BBOX6mUl.js → goals-config-api-B95KdGMj.js} +1 -1
  34. package/dist/gateway/static/root/assets/{goals-page-BP1kfvWv.js → goals-page-BTJzIl28.js} +2 -2
  35. package/dist/gateway/static/root/assets/{goals-settings-Bh3A7OZV.js → goals-settings-BJyEuLLm.js} +1 -1
  36. package/dist/gateway/static/root/assets/heartbeat-settings-wkOjYNQT.js +1 -0
  37. package/dist/gateway/static/root/assets/index-BLaXr6Ev.css +1 -0
  38. package/dist/gateway/static/root/assets/index-c_9TVr_C.js +191 -0
  39. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-B4TKJHla.js → keyboard-shortcuts-settings-BT8T4DyC.js} +1 -1
  40. package/dist/gateway/static/root/assets/logs-page-CrxBJUgI.js +2 -0
  41. package/dist/gateway/static/root/assets/{markdown-split-DcFtdLci.js → markdown-split-Dv66bO2b.js} +1 -1
  42. package/dist/gateway/static/root/assets/{media-plugins-B6SmeLVB.js → media-plugins-BhIQU5yS.js} +1 -1
  43. package/dist/gateway/static/root/assets/messages-O6TAtdFC.js +3 -0
  44. package/dist/gateway/static/root/assets/models-hub-panel-DOOpz6y1.js +2 -0
  45. package/dist/gateway/static/root/assets/notes-page-Br16pK9v.js +1 -0
  46. package/dist/gateway/static/root/assets/notes-workbench-PSJAi0ZC.js +2 -0
  47. package/dist/gateway/static/root/assets/{preview-open-alternatives-C29O19s7.js → preview-open-alternatives-DGzet1d7.js} +1 -1
  48. package/dist/gateway/static/root/assets/project-detail-page-CIGGgKuw.js +1 -0
  49. package/dist/gateway/static/root/assets/projects-page-B2grhsBt.js +1 -0
  50. package/dist/gateway/static/root/assets/remote-access-hub-CXMORxBD.js +1 -0
  51. package/dist/gateway/static/root/assets/{save-bar-controls-B4ad9GfB.js → save-bar-controls-Cqgb-jqa.js} +1 -1
  52. package/dist/gateway/static/root/assets/{schedule-field-DdYncfLR.js → schedule-field-DVZcI8Yt.js} +1 -1
  53. package/dist/gateway/static/root/assets/{schema-form-BMTrDE-7.js → schema-form-Bj7sOxC8.js} +1 -1
  54. package/dist/gateway/static/root/assets/sessions-page-Bi2wkBzU.js +1 -0
  55. package/dist/gateway/static/root/assets/settings-advanced-gate-B1L3G4IA.js +1 -0
  56. package/dist/gateway/static/root/assets/{settings-collapsible-section-MwTW2eK4.js → settings-collapsible-section-BmXn-8N6.js} +1 -1
  57. package/dist/gateway/static/root/assets/{settings-form-section-Dg6LBbcr.js → settings-form-section-BnqYMWHR.js} +1 -1
  58. package/dist/gateway/static/root/assets/settings-page-BfRSHJmO.js +1 -0
  59. package/dist/gateway/static/root/assets/{settings-page-layout-BX4T-OLF.js → settings-page-layout-CdWZU1hd.js} +1 -1
  60. package/dist/gateway/static/root/assets/{setup-status-panel-Ce1pcFtR.js → setup-status-panel-CWtPM7RK.js} +1 -1
  61. package/dist/gateway/static/root/assets/{share-preview-page-DWE-dUFh.js → share-preview-page-IB1v8i86.js} +1 -1
  62. package/dist/gateway/static/root/assets/shares-settings-ngbsBgij.js +1 -0
  63. package/dist/gateway/static/root/assets/skill-reload-api-BIe442Gv.js +1 -0
  64. package/dist/gateway/static/root/assets/skills-page-BfchZRVa.js +2 -0
  65. package/dist/gateway/static/root/assets/{system-settings-panel-Dd6Y35Cm.js → system-settings-panel-BxQ384RC.js} +1 -1
  66. package/dist/gateway/static/root/assets/{typed-models-lib-Cx6XV5A2.js → typed-models-lib-BkcpvFYO.js} +1 -1
  67. package/dist/gateway/static/root/assets/{use-channel-catalog-D4sMbmy7.js → use-channel-catalog-Cd0FaEQ4.js} +1 -1
  68. package/dist/gateway/static/root/assets/{user-profile-settings-panel-Bx-hjMQc.js → user-profile-settings-panel-DQ7NnRSY.js} +1 -1
  69. package/dist/gateway/static/root/assets/{utils-D7b_vZnv.js → utils-YKhVf7Ka.js} +1 -1
  70. package/dist/gateway/static/root/assets/voice-api-key-field-C5Ov8Uk_.js +1 -0
  71. package/dist/gateway/static/root/assets/{workflow-run-setup-panel--TdohF5N.js → workflow-run-setup-panel-BYD9BtOq.js} +2 -2
  72. package/dist/gateway/static/root/assets/{workflow-start-dialog-B0lavx_o.js → workflow-start-dialog-BNJVCWoS.js} +1 -1
  73. package/dist/gateway/static/root/assets/workflows-page-BYF29ANm.js +18 -0
  74. package/dist/gateway/static/root/index.html +5 -5
  75. package/dist/package.js +1 -1
  76. package/dist/src/agent/agent-manager.d.ts +6 -1
  77. package/dist/src/agent/agent-manager.js +28 -12
  78. package/dist/src/agent/agent-manager.js.map +1 -1
  79. package/dist/src/agent/context/workspace-templates/AGENTS.md +1 -1
  80. package/dist/src/agent/embedded/xopc-tools-bridge.js +11 -7
  81. package/dist/src/agent/embedded/xopc-tools-bridge.js.map +1 -1
  82. package/dist/src/agent/lifecycle/progress.js +3 -1
  83. package/dist/src/agent/lifecycle/progress.js.map +1 -1
  84. package/dist/src/agent/lifecycle/timeout-wrapper.d.ts +2 -2
  85. package/dist/src/agent/lifecycle/timeout-wrapper.js +4 -4
  86. package/dist/src/agent/lifecycle/timeout-wrapper.js.map +1 -1
  87. package/dist/src/agent/memory/summary-generator.d.ts +1 -1
  88. package/dist/src/agent/memory/summary-generator.js +1 -2
  89. package/dist/src/agent/memory/summary-generator.js.map +1 -1
  90. package/dist/src/agent/middleware/index.d.ts +1 -1
  91. package/dist/src/agent/middleware/self-verify.d.ts +44 -14
  92. package/dist/src/agent/middleware/self-verify.js +214 -44
  93. package/dist/src/agent/middleware/self-verify.js.map +1 -1
  94. package/dist/src/agent/orchestration/agent-event-handler.js +57 -15
  95. package/dist/src/agent/orchestration/agent-event-handler.js.map +1 -1
  96. package/dist/src/agent/prompt/sections/tooling.js +18 -13
  97. package/dist/src/agent/prompt/sections/tooling.js.map +1 -1
  98. package/dist/src/agent/prompt/system-reminder.js +2 -2
  99. package/dist/src/agent/prompt/system-reminder.js.map +1 -1
  100. package/dist/src/agent/sandbox/sanitize-env-vars.d.ts +2 -2
  101. package/dist/src/agent/sandbox/sanitize-env-vars.js +2 -2
  102. package/dist/src/agent/sandbox/sanitize-env-vars.js.map +1 -1
  103. package/dist/src/agent/sandbox/types.d.ts +2 -2
  104. package/dist/src/agent/sandbox/types.js.map +1 -1
  105. package/dist/src/agent/service/btw-query.js +1 -1
  106. package/dist/src/agent/service/btw-query.js.map +1 -1
  107. package/dist/src/agent/service/process-direct-one-shot.js +6 -2
  108. package/dist/src/agent/service/process-direct-one-shot.js.map +1 -1
  109. package/dist/src/agent/service/process-direct-streaming.js +12 -7
  110. package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
  111. package/dist/src/agent/service.js +2 -1
  112. package/dist/src/agent/service.js.map +1 -1
  113. package/dist/src/agent/skills/skill-tool-gating.js +1 -1
  114. package/dist/src/agent/skills/skill-tool-gating.js.map +1 -1
  115. package/dist/src/agent/starter-agents.js +9 -9
  116. package/dist/src/agent/starter-agents.js.map +1 -1
  117. package/dist/src/agent/tools/apply-patch.d.ts +25 -0
  118. package/dist/src/agent/tools/apply-patch.js +256 -0
  119. package/dist/src/agent/tools/apply-patch.js.map +1 -0
  120. package/dist/src/agent/tools/delegate-tool.d.ts +1 -1
  121. package/dist/src/agent/tools/delegate-tool.js +3 -3
  122. package/dist/src/agent/tools/delegate-tool.js.map +1 -1
  123. package/dist/src/agent/tools/exec-command.d.ts +30 -0
  124. package/dist/src/agent/tools/exec-command.js +224 -0
  125. package/dist/src/agent/tools/exec-command.js.map +1 -0
  126. package/dist/src/agent/tools/execute-code-tool.js +7 -4
  127. package/dist/src/agent/tools/execute-code-tool.js.map +1 -1
  128. package/dist/src/agent/tools/factory.d.ts +3 -3
  129. package/dist/src/agent/tools/factory.js +8 -9
  130. package/dist/src/agent/tools/factory.js.map +1 -1
  131. package/dist/src/agent/tools/goal-tool.d.ts +5 -1
  132. package/dist/src/agent/tools/goal-tool.js +8 -2
  133. package/dist/src/agent/tools/goal-tool.js.map +1 -1
  134. package/dist/src/agent/tools/index.d.ts +4 -3
  135. package/dist/src/agent/tools/index.js +5 -4
  136. package/dist/src/agent/tools/skills-tools.d.ts +1 -1
  137. package/dist/src/agent/tools/skills-tools.js.map +1 -1
  138. package/dist/src/agent/tools/update-plan-tool.d.ts +11 -0
  139. package/dist/src/agent/tools/update-plan-tool.js +72 -0
  140. package/dist/src/agent/tools/update-plan-tool.js.map +1 -0
  141. package/dist/src/agent/workflow/builtins/debug-incident.d.ts +1 -1
  142. package/dist/src/agent/workflow/builtins/debug-incident.js +1 -1
  143. package/dist/src/agent/workflow/builtins/debug-incident.js.map +1 -1
  144. package/dist/src/agent/workflow/builtins/pr-review.d.ts +1 -1
  145. package/dist/src/agent/workflow/builtins/pr-review.js +1 -1
  146. package/dist/src/agent/workflow/builtins/pr-review.js.map +1 -1
  147. package/dist/src/agent/workflow/builtins/release-check.d.ts +1 -1
  148. package/dist/src/agent/workflow/builtins/release-check.js +1 -1
  149. package/dist/src/agent/workflow/builtins/release-check.js.map +1 -1
  150. package/dist/src/agent/workflow/step-labels.js +7 -3
  151. package/dist/src/agent/workflow/step-labels.js.map +1 -1
  152. package/dist/src/chat-commands/agent-edit.js +1 -1
  153. package/dist/src/chat-commands/agent-edit.js.map +1 -1
  154. package/dist/src/chat-commands/builtins/goal.js +4 -1
  155. package/dist/src/chat-commands/builtins/goal.js.map +1 -1
  156. package/dist/src/chat-commands/builtins/review.d.ts +1 -0
  157. package/dist/src/chat-commands/builtins/review.js +167 -0
  158. package/dist/src/chat-commands/builtins/review.js.map +1 -0
  159. package/dist/src/chat-commands/index.d.ts +1 -0
  160. package/dist/src/chat-commands/index.js +3 -1
  161. package/dist/src/chat-commands/index.js.map +1 -1
  162. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  163. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  164. package/dist/src/config/agent-profile.js +1 -1
  165. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  166. package/dist/src/gateway/agent-builtin-tools.js +3 -2
  167. package/dist/src/gateway/agent-builtin-tools.js.map +1 -1
  168. package/dist/src/gateway/agents-admin.js +1 -1
  169. package/dist/src/gateway/chat-stream/mapper.d.ts +6 -0
  170. package/dist/src/gateway/chat-stream/mapper.js +149 -6
  171. package/dist/src/gateway/chat-stream/mapper.js.map +1 -1
  172. package/dist/src/gateway/chat-stream/protocol.d.ts +51 -1
  173. package/dist/src/gateway/hono/routes/commands-skills.js +21 -0
  174. package/dist/src/gateway/hono/routes/commands-skills.js.map +1 -1
  175. package/dist/src/gateway/hono/routes/index.js +2 -0
  176. package/dist/src/gateway/hono/routes/index.js.map +1 -1
  177. package/dist/src/gateway/hono/routes/lazy-bundles.js +1 -0
  178. package/dist/src/gateway/hono/routes/lazy-bundles.js.map +1 -1
  179. package/dist/src/gateway/hono/routes/projects.js +136 -14
  180. package/dist/src/gateway/hono/routes/projects.js.map +1 -1
  181. package/dist/src/gateway/hono/routes/search.d.ts +3 -0
  182. package/dist/src/gateway/hono/routes/search.js +47 -0
  183. package/dist/src/gateway/hono/routes/search.js.map +1 -0
  184. package/dist/src/gateway/security/dangerous-tools.js +1 -1
  185. package/dist/src/gateway/security/dangerous-tools.js.map +1 -1
  186. package/dist/src/infra/update-restart.js +1 -1
  187. package/dist/src/projects/index.d.ts +3 -0
  188. package/dist/src/projects/index.js +4 -1
  189. package/dist/src/projects/project-agent-suggestion.d.ts +14 -0
  190. package/dist/src/projects/project-agent-suggestion.js +19 -0
  191. package/dist/src/projects/project-agent-suggestion.js.map +1 -0
  192. package/dist/src/projects/project-kind.d.ts +13 -0
  193. package/dist/src/projects/project-kind.js +147 -0
  194. package/dist/src/projects/project-kind.js.map +1 -0
  195. package/dist/src/projects/project-service.d.ts +15 -0
  196. package/dist/src/projects/project-service.js +96 -3
  197. package/dist/src/projects/project-service.js.map +1 -1
  198. package/dist/src/projects/project-store.js +32 -8
  199. package/dist/src/projects/project-store.js.map +1 -1
  200. package/dist/src/projects/types.d.ts +4 -1
  201. package/dist/src/projects/workspace-project.d.ts +22 -0
  202. package/dist/src/projects/workspace-project.js +143 -0
  203. package/dist/src/projects/workspace-project.js.map +1 -0
  204. package/dist/src/review/review-git.d.ts +48 -0
  205. package/dist/src/review/review-git.js +333 -0
  206. package/dist/src/review/review-git.js.map +1 -0
  207. package/dist/src/review/review-types.d.ts +22 -0
  208. package/dist/src/review/review-types.js +29 -0
  209. package/dist/src/review/review-types.js.map +1 -0
  210. package/dist/src/session/session-context-for-llm.js +151 -0
  211. package/dist/src/session/session-context-for-llm.js.map +1 -1
  212. package/dist/src/storage/sqlite/migrations/021_projects_fts.sql +21 -0
  213. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  214. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  215. package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
  216. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  217. package/dist/src/storage/sqlite/schema.js +1 -1
  218. package/dist/src/tui/backends/embedded-backend.d.ts +8 -1
  219. package/dist/src/tui/backends/embedded-backend.js +60 -1
  220. package/dist/src/tui/backends/embedded-backend.js.map +1 -1
  221. package/dist/src/tui/backends/gateway-sse-backend.d.ts +9 -1
  222. package/dist/src/tui/backends/gateway-sse-backend.js +29 -0
  223. package/dist/src/tui/backends/gateway-sse-backend.js.map +1 -1
  224. package/dist/src/tui/components/assistant-message.js +35 -0
  225. package/dist/src/tui/components/assistant-message.js.map +1 -1
  226. package/dist/src/tui/tui-agent-events.js +25 -0
  227. package/dist/src/tui/tui-agent-events.js.map +1 -1
  228. package/dist/src/tui/tui-backend.d.ts +20 -0
  229. package/dist/src/tui/tui-commands.d.ts +1 -0
  230. package/dist/src/tui/tui-commands.js +110 -4
  231. package/dist/src/tui/tui-commands.js.map +1 -1
  232. package/dist/src/tui/tui-picker-overlay.d.ts +2 -0
  233. package/dist/src/tui/tui-picker-overlay.js +153 -1
  234. package/dist/src/tui/tui-picker-overlay.js.map +1 -1
  235. package/dist/src/tui/tui.js +36 -2
  236. package/dist/src/tui/tui.js.map +1 -1
  237. package/dist/src/workflows/service/workflow-run-service.js +1 -1
  238. package/dist/src/workflows/service/workflow-run-service.js.map +1 -1
  239. package/package.json +1 -1
  240. package/dist/gateway/static/root/assets/agents-SsQrj9B-.js +0 -2
  241. package/dist/gateway/static/root/assets/apps-page-CYb6fame.js +0 -1
  242. package/dist/gateway/static/root/assets/automations-page-DpOOq1nk.js +0 -1
  243. package/dist/gateway/static/root/assets/browser-settings-page-9nXxgh4u.js +0 -8
  244. package/dist/gateway/static/root/assets/capability-presets-settings-panel-D528_YFy.js +0 -1
  245. package/dist/gateway/static/root/assets/channels-settings-Ck-3h5lI.js +0 -1
  246. package/dist/gateway/static/root/assets/connectors-page-DL-fAqE_.js +0 -2
  247. package/dist/gateway/static/root/assets/gateway-settings-mmmnIH27.js +0 -1
  248. package/dist/gateway/static/root/assets/goal-detail-page-Ceu5zrN6.js +0 -1
  249. package/dist/gateway/static/root/assets/heartbeat-settings-YoYgKlfX.js +0 -1
  250. package/dist/gateway/static/root/assets/index-DdqSO9R2.js +0 -191
  251. package/dist/gateway/static/root/assets/index-jGB-2nI-.css +0 -1
  252. package/dist/gateway/static/root/assets/logs-page-BgVk5DvZ.js +0 -2
  253. package/dist/gateway/static/root/assets/messages-B5O4OIEo.js +0 -3
  254. package/dist/gateway/static/root/assets/models-hub-panel-BU0x8PGP.js +0 -2
  255. package/dist/gateway/static/root/assets/notes-page-D6JYVP4I.js +0 -1
  256. package/dist/gateway/static/root/assets/notes-workbench-mqRJYnJS.js +0 -2
  257. package/dist/gateway/static/root/assets/project-detail-page-DOTgzoeh.js +0 -1
  258. package/dist/gateway/static/root/assets/projects-page-DGUIb4y5.js +0 -1
  259. package/dist/gateway/static/root/assets/remote-access-hub-DVKKUj3u.js +0 -1
  260. package/dist/gateway/static/root/assets/sessions-page-BVbzUWxW.js +0 -1
  261. package/dist/gateway/static/root/assets/settings-advanced-gate-DrNNoSqE.js +0 -1
  262. package/dist/gateway/static/root/assets/settings-page-CMDqgeMR.js +0 -1
  263. package/dist/gateway/static/root/assets/shares-settings-aKSraR8l.js +0 -1
  264. package/dist/gateway/static/root/assets/skill-reload-api-CS-FU_B-.js +0 -1
  265. package/dist/gateway/static/root/assets/skills-page-BaF3u0LA.js +0 -2
  266. package/dist/gateway/static/root/assets/voice-api-key-field-CkhbRt1q.js +0 -1
  267. package/dist/gateway/static/root/assets/workflows-page-CZR05Bu_.js +0 -18
  268. package/dist/src/agent/tools/edit.d.ts +0 -14
  269. package/dist/src/agent/tools/edit.js +0 -132
  270. package/dist/src/agent/tools/edit.js.map +0 -1
  271. package/dist/src/agent/tools/shell.d.ts +0 -15
  272. package/dist/src/agent/tools/shell.js +0 -158
  273. package/dist/src/agent/tools/shell.js.map +0 -1
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-B5O4OIEo.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l,t as u}from"./fetch-ovkvM8KQ.js";import{a as d,i as f}from"./vendor-swr-BIWyz7Rc.js";import{$a as p,An as m,Ba as h,Fi as g,H as _,Ha as v,Ic as y,Ii as b,Li as x,Lr as S,Pi as C,Po as w,Ri as T,So as E,Tc as D,Wo as O,aa as k,ia as A,jc as j,lc as M,mc as N,na as P,ns as F,oa as I,ra as L,sa as R,ta as z,ut as B,vo as V,zs as H}from"./index-DdqSO9R2.js";var U=e(t(),1),W=n();function G(e){return e===`builtin`||e===`user`?e:`marketplace`}async function K(e){try{let t=await e.json();if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&typeof t.error.message==`string`)return t.error.message;if(typeof t.message==`string`)return t.message}catch{}return e.statusText||`HTTP ${e.status}`}async function ee(e){let t=await u(c(`/api/marketplace/packages/${encodeURIComponent(e.trim())}`),{cache:`no-store`});if(!t.ok)throw Error(await K(t));let n=await t.json();if(!n.ok||!n.payload?.id)throw Error(n.error??`Invalid response`);return n.payload}async function q(e){let t=await u(c(`/api/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await K(t));let n=await t.json();if(!n.ok||!n.payload?.extensionId)throw Error(n.error??`Invalid response`);return n.payload}async function J(e){let t=await u(c(`/api/extensions/bundled/activation`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e.extensionId.trim(),enabled:e.enabled})});if(!t.ok)throw Error(await K(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error?.message??`Invalid response`);return n.payload}async function Y(e){let t=await u(c(`/api/marketplace/uninstall`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e})});if(!t.ok)throw Error(await K(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error??`Invalid response`);return n.payload}var X=r();function Z(e,t){let n=e.find(e=>e.id===t);return n?n.source===`bundled`?`bundled`:`user`:`absent`}var te={q:``,debounced:``,detailPkg:null,rowBusy:null,actionError:null,restartHint:null};function ne({className:e}){let t=a(o(e=>e.language)).appsPage,n=s(e=>!!e.token),r=g(),{mutate:u}=d(),[h,_]=(0,U.useReducer)(B,te),{q:v,debounced:y,detailPkg:b,rowBusy:x,actionError:S,restartHint:C}=h,w=n?`marketplace-${y}`:null;(0,U.useEffect)(()=>{let e=window.setTimeout(()=>_({type:`patch`,patch:{debounced:v.trim()}}),300);return()=>window.clearTimeout(e)},[v]);let{data:T,isLoading:D,error:k}=f(w,async()=>l(y.length>0?c(`/api/marketplace?q=${encodeURIComponent(y)}`):c(`/api/marketplace`)),{revalidateOnFocus:!1}),A=(0,U.useCallback)(()=>{u(`gateway-extensions-list`),m()},[u]),j=(0,U.useCallback)(async(e,n)=>{_({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let r=await q({name:e,overwrite:n});A(),r.requiresGatewayRestart&&_({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw _({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceInstallFailed}}),e}finally{_({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceInstallFailed,t.marketplaceRestartHint,A]),N=(0,U.useCallback)(async e=>{_({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let n=await Y(e);A(),n.requiresGatewayRestart&&_({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw _({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceUninstallFailed}}),e}finally{_({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceRestartHint,t.marketplaceUninstallFailed,A]),P=T?.extensions??[];return(0,X.jsxs)(`div`,{className:i(`flex flex-col gap-4`,e),children:[(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(E,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`input`,{type:`search`,value:v,onChange:e=>_({type:`patch`,patch:{q:e.target.value}}),placeholder:t.marketplaceSearchPlaceholder,className:`ui-input h-10 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted`})]}),k?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:k instanceof Error?k.message:t.marketplaceLoadFailed}):null,S?(0,X.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:S}):null,C?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:C}):null,D&&!T?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):(0,X.jsx)(`ul`,{className:`flex flex-col gap-3`,children:P.length===0?(0,X.jsx)(`li`,{className:`text-sm text-fg-muted`,children:t.marketplaceEmpty}):P.map(e=>{let n=Z(r,e.id),a=x===e.id;return(0,X.jsx)(`li`,{className:`list-none`,children:(0,X.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-label":`${e.name}, ${t.marketplaceDetailTitle}`,onClick:()=>_({type:`patch`,patch:{detailPkg:e.id}}),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),_({type:`patch`,patch:{detailPkg:e.id}}))},className:i(`flex w-full cursor-pointer flex-wrap items-start gap-3 rounded-xl border border-edge bg-surface-base p-4 text-left shadow-surface`,`transition-[transform,background-color,border-color,box-shadow] duration-150 ease-out`,`hover:border-edge-subtle hover:bg-surface-hover/40`,`active:scale-[0.992] active:bg-surface-hover/55`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:hover:bg-surface-hover/25 dark:active:bg-surface-hover/35`),children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`h3`,{className:`font-semibold text-fg`,children:e.name}),e.verified?(0,X.jsx)(M,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null,e.version?(0,X.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e.version}):null]}),e.description?(0,X.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.description}):null,(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(e.categories??[]).map(e=>(0,X.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e))}),(0,X.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,X.jsx)(O,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:e.npmPackage})]})]}),(0,X.jsx)(`div`,{role:`group`,className:`flex shrink-0 flex-col items-end gap-2 sm:min-w-[9rem]`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:n===`bundled`?(0,X.jsx)(`span`,{className:`rounded-md bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.marketplaceBuiltin}):n===`user`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`text-[11px] font-medium text-fg-muted`,children:t.marketplaceInstalled}),(0,X.jsxs)(`button`,{type:`button`,disabled:a,onClick:()=>{window.confirm(t.marketplaceUninstallConfirm)&&N(e.id).catch(()=>{})},className:i(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-colors active:scale-[0.98] active:bg-surface-hover/80`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[a?(0,X.jsx)(F,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,X.jsx)(p,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t.marketplaceUninstall]})]}):(0,X.jsxs)(`button`,{type:`button`,disabled:a,onClick:()=>{j(e.id,!1).catch(()=>{})},className:i(`inline-flex w-full items-center justify-center rounded-lg bg-accent px-3 py-2 text-xs font-medium text-white`,`shadow-surface transition-[transform,background-color] active:scale-[0.98]`,`hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`disabled:pointer-events-none disabled:opacity-50`),children:[a?(0,X.jsx)(F,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,t.marketplaceInstall]})})]})},e.id)})}),b?(0,X.jsx)(re,{packageName:b,copy:t,extensions:r,onClose:()=>_({type:`patch`,patch:{detailPkg:null}}),onInstall:j,onUninstall:N}):null]})}function re(e){let t=(0,W.c)(61),{packageName:n,copy:r,extensions:a,onClose:o,onInstall:c,onUninstall:l}=e,[u,d]=(0,U.useState)(!1),m=s(se)?`ext-mp-detail-${n}`:null,h;t[0]===n?h=t[1]:(h=async()=>ee(n),t[0]=n,t[1]=h);let g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g={revalidateOnFocus:!1},t[2]=g):g=t[2];let{data:_,error:y,isLoading:b}=f(m,h,g),x;t[3]!==a||t[4]!==n?(x=Z(a,n),t[3]=a,t[4]=n,t[5]=x):x=t[5];let C=x,w=C===`user`,T;t[6]!==r.marketplaceNoReadme||t[7]!==_?(T=_?.readme?.trim()||(_?.description?.trim()?`### ${_.name}\n\n${_.description}`:`*${r.marketplaceNoReadme}*`),t[6]=r.marketplaceNoReadme,t[7]=_,t[8]=T):T=t[8];let E=T,O;t[9]===o?O=t[10]:(O=e=>!e&&o(),t[9]=o,t[10]=O);let M;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,X.jsx)(L,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[11]=M):M=t[11];let N;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,X.jsx)(D,{className:`size-5`}),t[12]=N):N=t[12];let P;t[13]!==r.detailBack||t[14]!==o?(P=(0,X.jsx)(`button`,{type:`button`,onClick:o,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailBack,children:N}),t[13]=r.detailBack,t[14]=o,t[15]=P):P=t[15];let R;t[16]===r.marketplaceDetailTitle?R=t[17]:(R=(0,X.jsx)(I,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:r.marketplaceDetailTitle}),t[16]=r.marketplaceDetailTitle,t[17]=R);let B;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,X.jsx)(v,{className:`size-5`}),t[18]=B):B=t[18];let V;t[19]!==r.detailClose||t[20]!==o?(V=(0,X.jsx)(`button`,{type:`button`,onClick:o,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailClose,children:B}),t[19]=r.detailClose,t[20]=o,t[21]=V):V=t[21];let H;t[22]!==V||t[23]!==P||t[24]!==R?(H=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[P,R,V]}),t[22]=V,t[23]=P,t[24]=R,t[25]=H):H=t[25];let G;t[26]!==r.marketplaceAuthor||t[27]!==r.marketplaceDetailLoadFailed||t[28]!==r.marketplaceDetailReadmeHeading||t[29]!==r.marketplaceDownloads||t[30]!==r.marketplaceVersion||t[31]!==_||t[32]!==y||t[33]!==b||t[34]!==E?(G=b&&!_?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):y?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.marketplaceDetailLoadFailed}):_?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:_.name}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,X.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:_.id})}),(0,X.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceAuthor}),(0,X.jsx)(`dd`,{children:_.author.username})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceVersion}),(0,X.jsx)(`dd`,{children:_.latestVersion.version})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDownloads}),(0,X.jsx)(`dd`,{children:_.downloads})]})]}),_.readme?.trim()?(0,X.jsx)(`h4`,{className:`mb-2 mt-6 text-sm font-semibold text-fg`,children:r.marketplaceDetailReadmeHeading}):null,(0,X.jsx)(`div`,{className:`markdown-content min-w-0 break-words text-sm`,children:(0,X.jsx)(S,{content:E})})]}):null,t[26]=r.marketplaceAuthor,t[27]=r.marketplaceDetailLoadFailed,t[28]=r.marketplaceDetailReadmeHeading,t[29]=r.marketplaceDownloads,t[30]=r.marketplaceVersion,t[31]=_,t[32]=y,t[33]=b,t[34]=E,t[35]=G):G=t[35];let K;t[36]===G?K=t[37]:(K=(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:G}),t[36]=G,t[37]=K);let q;t[38]!==u||t[39]!==r.marketplaceBuiltinGoBuiltin||t[40]!==r.marketplaceBuiltinManageHint||t[41]!==r.marketplaceInstall||t[42]!==r.marketplaceReinstall||t[43]!==r.marketplaceReinstallConfirm||t[44]!==r.marketplaceUninstall||t[45]!==r.marketplaceUninstallConfirm||t[46]!==_||t[47]!==C||t[48]!==o||t[49]!==c||t[50]!==l||t[51]!==n||t[52]!==w?(q=_?(0,X.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:C===`bundled`?(0,X.jsxs)(`div`,{className:`flex w-full flex-col items-stretch gap-2`,children:[(0,X.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:r.marketplaceBuiltinManageHint}),(0,X.jsx)(j,{to:`/apps?tab=builtin`,onClick:o,className:`inline-flex w-fit items-center justify-center rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.marketplaceBuiltinGoBuiltin})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{w&&!window.confirm(r.marketplaceReinstallConfirm)||(d(!0),c(n,w).catch(ae).finally(()=>d(!1)))},className:i(`inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium`,`bg-accent text-white shadow-surface hover:bg-accent-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`disabled:pointer-events-none disabled:opacity-50`),children:[u?(0,X.jsx)(F,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,w?r.marketplaceReinstall:r.marketplaceInstall]}),w?(0,X.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{window.confirm(r.marketplaceUninstallConfirm)&&(d(!0),l(n).then(()=>o()).catch(ie).finally(()=>d(!1)))},className:i(`inline-flex items-center justify-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,X.jsx)(p,{className:`size-4 shrink-0`,"aria-hidden":!0}),r.marketplaceUninstall]}):null]})}):null,t[38]=u,t[39]=r.marketplaceBuiltinGoBuiltin,t[40]=r.marketplaceBuiltinManageHint,t[41]=r.marketplaceInstall,t[42]=r.marketplaceReinstall,t[43]=r.marketplaceReinstallConfirm,t[44]=r.marketplaceUninstall,t[45]=r.marketplaceUninstallConfirm,t[46]=_,t[47]=C,t[48]=o,t[49]=c,t[50]=l,t[51]=n,t[52]=w,t[53]=q):q=t[53];let J;t[54]!==H||t[55]!==K||t[56]!==q?(J=(0,X.jsxs)(A,{children:[M,(0,X.jsxs)(z,{className:`fixed left-1/2 top-1/2 z-[131] flex max-h-[min(90vh,44rem)] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,onOpenAutoFocus:oe,children:[H,K,q]})]}),t[54]=H,t[55]=K,t[56]=q,t[57]=J):J=t[57];let Y;return t[58]!==J||t[59]!==O?(Y=(0,X.jsx)(k,{defaultOpen:!0,onOpenChange:O,children:J}),t[58]=J,t[59]=O,t[60]=Y):Y=t[60],Y}function ie(){}function ae(){}function oe(e){return e.preventDefault()}function se(e){return!!e.token}function ce(){let e=o(e=>e.language),t=a(e),n=R(e=>e.setPageHeader),r=R(e=>e.clearPageHeader),i=g(),s=b(),[c,l]=y(),u=G(c.get(`tab`)),d=c.get(`q`)??``,[f,p]=(0,U.useState)(u),[m,h]=(0,U.useState)(d),[v,x]=(0,U.useState)(null),S=c.toString(),C=(0,U.useRef)(S);if(C.current!==S){C.current=S;let e=G(c.get(`tab`)),t=c.get(`q`)??``;p(t=>t===e?t:e),h(e=>e===t?e:t)}(0,U.useEffect)(()=>{l(e=>{let t=new URLSearchParams(e),n=m.trim();return n?t.set(`q`,n):t.delete(`q`),f===`marketplace`?t.delete(`tab`):t.set(`tab`,f),t.toString()===e.toString()?e:t},{replace:!0})},[f,m,l]);let w=(0,U.useMemo)(()=>i.filter(e=>e.source===`bundled`),[i]),T=(0,U.useMemo)(()=>i.filter(e=>e.source!==`bundled`),[i]),D=f===`builtin`?w:T,O=(0,U.useMemo)(()=>{let t=m.trim().toLowerCase(),n=D;return t&&(n=n.filter(e=>(e.name??``).toLowerCase().includes(t)||e.id.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t))),n.toSorted((t,n)=>t.hasUi===n.hasUi?(t.name||t.id).localeCompare(n.name||n.id,e):t.hasUi?-1:1)},[D,m,e]);if((0,U.useEffect)(()=>{x(e=>{if(!e)return e;let t=i.find(t=>t.id===e.id);return t?Q(e)===Q(t)&&e.active===t.active?e:t:null})},[i]),(0,U.useLayoutEffect)(()=>(n({startExtra:null,main:(0,X.jsx)(`div`,{className:`min-w-0`,children:(0,X.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.appsPage.title})}),end:null}),()=>r()),[r,t.appsPage.title,n]),s&&f!==`marketplace`)return(0,X.jsx)(me,{});let k=f!==`marketplace`&&D.length>0;return(0,X.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,X.jsxs)(`div`,{className:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:[(0,X.jsxs)(`div`,{className:`mb-5 flex flex-col gap-3 border-b border-edge-subtle pb-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge-subtle`,children:[(0,X.jsx)(_,{items:[{id:`marketplace`,label:t.appsPage.tabMarketplace},{id:`builtin`,label:t.appsPage.tabBuiltin,count:w.length},{id:`user`,label:t.appsPage.tabUser,count:T.length}],activeTab:f,onChange:p,ariaLabel:t.appsPage.appsNavAria,tabIdPrefix:`apps-tab`,panelIdPrefix:`apps-panel`,className:`flex-wrap`}),k?(0,X.jsxs)(`div`,{className:`relative w-full min-w-0 sm:max-w-xs`,children:[(0,X.jsx)(E,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,X.jsx)(`input`,{type:`search`,value:m,onChange:e=>h(e.target.value),placeholder:t.appsPage.searchPlaceholder,className:`w-full rounded-lg border border-edge bg-surface-base py-2 pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,autoComplete:`off`})]}):null]}),f===`marketplace`?(0,X.jsx)(ne,{}):f===`builtin`&&w.length===0?(0,X.jsx)(ge,{message:t.appsPage.emptyBuiltin}):f===`user`&&T.length===0?(0,X.jsx)(ge,{message:t.appsPage.emptyUser}):O.length===0?(0,X.jsx)(`p`,{className:`rounded-xl border border-dashed border-edge-subtle bg-surface-hover/30 px-3 py-8 sm:px-5 xl:px-6 text-center text-sm text-fg-muted dark:bg-surface-hover/15`,children:t.appsPage.noSearchResults}):(0,X.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:O.map(e=>(0,X.jsx)(fe,{extension:e,copy:t.appsPage,showSourceBadge:f===`user`,onOpen:()=>x(e)},e.id))})]}),v?(0,X.jsx)(pe,{extension:v,copy:t.appsPage,onClose:()=>x(null)},v.id):null]})}function Q(e){return e.activationEligible??e.active}function le(e,t){return e.source===`bundled`?t.providerBundled:e.source===`global`?t.providerGlobal:e.source===`workspace`?t.providerWorkspace:t.providerOther}function ue(e,t){return e.source===`global`?t.badgeSourceGlobal:e.source===`workspace`?t.badgeSourceWorkspace:t.badgeSourceOther}function de(e,t){let n=Q(e);return n&&e.active?t.runStateLive:n&&!e.active?t.runStatePendingOn:!n&&e.active?t.runStatePendingOff:t.runStateOff}function fe(e){let t=(0,W.c)(45),{extension:n,copy:r,showSourceBadge:a,onOpen:o}=e,s;t[0]===n?s=t[1]:(s=Q(n),t[0]=n,t[1]=s);let c=s,l=n.hasUi?r.cardTooltipHasUi:r.cardTooltipNoUi,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(`group flex w-full flex-col rounded-xl border border-edge bg-surface-base p-4 text-left shadow-sm transition-colors`,`hover:border-edge-subtle hover:bg-surface-hover/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`dark:hover:bg-surface-hover/25`),t[2]=u):u=t[2];let d=n.name||n.id,f;t[3]===d?f=t[4]:(f=d.charAt(0).toUpperCase(),t[3]=d,t[4]=f);let p;t[5]===f?p=t[6]:(p=(0,X.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-base font-semibold text-accent-fg`,"aria-hidden":!0,children:f}),t[5]=f,t[6]=p);let m;t[7]===n.name?m=t[8]:(m=(0,X.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[7]=n.name,t[8]=m);let h;t[9]===n.version?h=t[10]:(h=n.version?(0,X.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`v`,n.version]}):null,t[9]=n.version,t[10]=h);let g;t[11]!==m||t[12]!==h?(g=(0,X.jsxs)(`div`,{className:`min-w-0`,children:[m,h]}),t[11]=m,t[12]=h,t[13]=g):g=t[13];let _;t[14]!==r.statusEnabled||t[15]!==c?(_=c?(0,X.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:[(0,X.jsx)(N,{className:`size-3`,strokeWidth:2.5,"aria-hidden":!0}),r.statusEnabled]}):(0,X.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-full border-2 border-accent text-accent`,"aria-hidden":!0,children:(0,X.jsx)(w,{className:`size-4`,strokeWidth:2.5})}),t[14]=r.statusEnabled,t[15]=c,t[16]=_):_=t[16];let v;t[17]!==g||t[18]!==_?(v=(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[g,_]}),t[17]=g,t[18]=_,t[19]=v):v=t[19];let y;t[20]!==r.cardNoDescription||t[21]!==n.description?(y=n.description?.trim()||r.cardNoDescription,t[20]=r.cardNoDescription,t[21]=n.description,t[22]=y):y=t[22];let b;t[23]===y?b=t[24]:(b=(0,X.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:y}),t[23]=y,t[24]=b);let x=n.hasUi?r.badgeKindUi:r.badgeKindBackend,S;t[25]!==x||t[26]!==l?(S=(0,X.jsx)(`span`,{title:l,className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:x}),t[25]=x,t[26]=l,t[27]=S):S=t[27];let C;t[28]!==r||t[29]!==n||t[30]!==a?(C=n.source===`bundled`?(0,X.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:r.badgeBundled}):a?(0,X.jsx)(`span`,{title:le(n,r),className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:ue(n,r)}):null,t[28]=r,t[29]=n,t[30]=a,t[31]=C):C=t[31];let T;t[32]!==S||t[33]!==C?(T=(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[S,C]}),t[32]=S,t[33]=C,t[34]=T):T=t[34];let E;t[35]!==v||t[36]!==b||t[37]!==T?(E=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[v,b,T]}),t[35]=v,t[36]=b,t[37]=T,t[38]=E):E=t[38];let D;t[39]!==E||t[40]!==p?(D=(0,X.jsxs)(`div`,{className:`flex gap-3`,children:[p,E]}),t[39]=E,t[40]=p,t[41]=D):D=t[41];let O;return t[42]!==o||t[43]!==D?(O=(0,X.jsx)(`button`,{type:`button`,onClick:o,className:u,children:D}),t[42]=o,t[43]=D,t[44]=O):O=t[44],O}function pe({extension:e,copy:t,onClose:n}){let{mutate:r}=d(),[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(null),[l,u]=(0,U.useState)(!1),f=e.activationEligible===!0,p=(0,U.useCallback)(async()=>{if(e.source===`bundled`){c(null),u(!1),o(!0);try{let{requiresGatewayRestart:t}=await J({extensionId:e.id,enabled:!f});await r(`gateway-extensions-list`),m(),u(t)}catch(e){c(e instanceof Error?e.message:t.builtinToggleFailed)}finally{o(!1)}}},[f,t.builtinToggleFailed,e.id,e.source,r]),g=e.ui?.contributions?.pages??[],_=e.ui?.contributions?.settingsPanels??[],y=e.ui?.contributions?.chatWidgets??[],b=e.ui?.contributions?.sidebarPanels??[],S=g.find(e=>e.showInNav)??g[0],w=_[0],E=S?C(e.id,S):null,O=w?`/settings/ext/${e.id}/${w.id}`:e.hasConfigSchema||x(e)?`/settings/ext/${e.id}`:null;return(0,X.jsx)(k,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,X.jsxs)(A,{children:[(0,X.jsx)(L,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,X.jsxs)(z,{className:`fixed left-1/2 top-1/2 z-[131] flex max-h-[min(90vh,44rem)] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailBack,children:(0,X.jsx)(D,{className:`size-5`})}),(0,X.jsx)(I,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,X.jsxs)(P,{className:`sr-only`,children:[e.name,` (`,e.id,`)`]}),(0,X.jsx)(`button`,{type:`button`,onClick:n,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":t.detailClose,children:(0,X.jsx)(v,{className:`size-5`})})]}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,X.jsx)(`div`,{className:`flex size-16 shrink-0 items-center justify-center rounded-2xl bg-accent-soft text-xl font-semibold text-accent-fg`,"aria-hidden":!0,children:(e.name||e.id).charAt(0).toUpperCase()}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:e.name}),(0,X.jsxs)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:[t.detailProviderPrefix,` `,le(e,t)]}),e.version?(0,X.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[`v`,e.version]}):null]})]}),(0,X.jsx)(`p`,{className:`mt-5 text-sm leading-relaxed text-fg`,children:e.description?.trim()||t.detailNoDescription}),e.hasUi?null:(0,X.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.backendOnlyHint}),(0,X.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:de(e,t)}),e.source===`bundled`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`mt-4 rounded-lg border border-edge-subtle bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted dark:bg-surface-hover/20`,children:t.builtinConfigHint}),(0,X.jsxs)(`div`,{className:`mt-3 rounded-lg border border-edge-subtle bg-surface-hover/40 p-3 dark:bg-surface-hover/20`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:t.builtinRuntimeToggle}),(0,X.jsx)(h,{type:`button`,variant:`secondary`,disabled:a,onClick:()=>void p(),className:`shrink-0 py-1.5 text-xs`,children:a?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(F,{className:`mr-1.5 size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),t.builtinToggleBusy]}):f?t.builtinToggleDisable:t.builtinToggleEnable})]}),s?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-rose-600 dark:text-rose-400`,children:s}):null,l?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.builtinToggleRestartHint}):null]})]}):(0,X.jsx)(`p`,{className:`mt-4 rounded-lg border border-edge-subtle bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted dark:bg-surface-hover/20`,children:t.cliManageHint}),e.hasUi&&(g.length>0||_.length>0||y.length>0)?(0,X.jsxs)(`section`,{className:`mt-8`,children:[(0,X.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-fg`,children:t.detailSectionFeatures}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,X.jsx)($,{template:t.badgePages,count:g.length,hidden:g.length===0}),(0,X.jsx)($,{template:t.badgeSettings,count:_.length,hidden:_.length===0}),(0,X.jsx)($,{template:t.badgeWidgets,count:y.length,hidden:y.length===0}),(0,X.jsx)($,{template:t.badgeSidebar,count:b.length,hidden:b.length===0})]})]}):null,T(e)&&(E||O)?(0,X.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[E?(0,X.jsxs)(j,{to:E,onClick:n,className:i(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,X.jsx)(H,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,O?(0,X.jsxs)(j,{to:O,onClick:n,className:i(`inline-flex items-center gap-1.5 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,X.jsx)(V,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.openSettings]}):null]}):null,(0,X.jsx)(`p`,{className:`mt-6 text-[11px] leading-relaxed text-fg-muted`,children:t.restartNote})]})]})]})})}function $(e){let t=(0,W.c)(6),{template:n,count:r,hidden:i}=e;if(i||r===0)return null;let a;if(t[0]!==r||t[1]!==n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\{\{count\}\}/g,t[3]=e):e=t[3],a=n.replace(e,String(r)),t[0]=r,t[1]=n,t[2]=a}else a=t[2];let o;return t[4]===a?o=t[5]:(o=(0,X.jsx)(`span`,{className:`inline-flex items-center rounded-md bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:a}),t[4]=a,t[5]=o),o}function me(){let e=(0,W.c)(5),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,X.jsx)(`div`,{className:`mb-6 h-8 w-40 max-w-full animate-pulse rounded-md bg-surface-hover`}),n=(0,X.jsx)(`div`,{className:`mb-2 h-4 w-full max-w-md animate-pulse rounded bg-surface-hover`}),r=(0,X.jsx)(`div`,{className:`mb-5 h-9 w-full max-w-lg animate-pulse rounded-full bg-surface-hover`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=[`ap0`,`ap1`,`ap2`,`ap3`,`ap4`,`ap5`],e[3]=i):i=e[3];let a;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,X.jsxs)(`div`,{className:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:[t,n,r,(0,X.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:i.map(he)})]})}),e[4]=a):a=e[4],a}function he(e){return(0,X.jsx)(`div`,{className:`h-36 animate-pulse rounded-xl border border-edge bg-surface-base`},e)}function ge(e){let t=(0,W.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,X.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-col items-center justify-center rounded-xl border border-dashed border-edge-subtle bg-surface-hover/40 px-4 py-12 text-center dark:bg-surface-hover/20`,children:(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{ce as AppsPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-B5O4OIEo.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{r as s}from"./toast-z0toXu32.js";import{i as c}from"./vendor-swr-BIWyz7Rc.js";import{$ as l,$a as u,Ac as d,Ba as f,Ha as p,Ic as m,Io as h,Oo as g,Os as _,Po as v,Va as y,Vo as b,Wr as x,aa as S,c as C,cc as w,ea as T,fo as E,ga as D,ia as O,jc as k,ki as A,oa as ee,ra as j,sa as M,ta as te,va as N,zs as ne}from"./index-DdqSO9R2.js";import{t as P}from"./format-cron-label-arqgGlVV.js";import{i as F,n as I,o as L,r as re,t as ie}from"./dist-wO9a2_ID.js";import{i as ae,n as R,r as oe,t as se}from"./workflow-run-setup-panel--TdohF5N.js";var z=n(),B=e(t(),1),V=r(),H={name:``,description:``,triggerMode:`daily`,time:`09:00`,weekday:`1`,intervalMinutes:`60`,cronExpr:`0 9 * * *`,webhookSecretId:``,actionMode:`agent`,agentId:``,instruction:``,workflowId:``,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0,safetyMode:`suggest_only`,timeoutSeconds:`300`,afterRunMode:`none`,webhookUrl:``,disableAfterFailures:`3`};function U(e){return e===`zh`?`zh-CN`:`en-US`}function ce(e,t,n){return e?new Intl.DateTimeFormat(U(n),{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}).format(new Date(e)):t.never}function le(e,t,n,r){if(e.kind===`manual`)return t.trigger.manual;if(e.kind===`webhook`)return t.trigger.webhook;if(e.kind===`event`)return t.trigger.eventWithType.replace(`{type}`,e.eventType);let i=e.schedule;return i.kind===`once`?t.trigger.onceAt.replace(`{time}`,ce(Date.parse(i.at),t,r)):i.kind===`interval`?t.trigger.everyMinutes.replace(`{minutes}`,String(Math.round(i.everyMs/6e4))):P(i.expr,U(r),n.scheduleBadge,{timezone:i.tz})}function W(e,t){return e.kind===`workflow`?t.action.workflowWithId.replace(`{id}`,e.workflowId):e.agentId?t.action.agentWithId.replace(`{id}`,e.agentId):t.action.agent}function G(e){return e.safety?.mode??`auto_apply`}function ue(e){return e===`succeeded`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`running`||e===`queued`?`bg-blue-500/10 text-blue-700 dark:text-blue-300`:`bg-surface-hover text-fg-muted`}function de(e,t){if(e==null)return t.never;if(e<1e3)return`${e}ms`;let n=Math.round(e/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`}function K(e){return e.status===`running`||e.status===`queued`}function fe(e){return e.status===`failed`||e.status===`timeout`||e.status===`cancelled`}function q(e){return K(e)?0:fe(e)?1:e.status===`succeeded`?2:3}function pe(e){return[...e].sort((e,t)=>{let n=q(e)-q(t);return n===0?t.createdAtMs-e.createdAtMs:n})}function me(e){let t=(0,z.c)(5),n;t[0]===e?n=t[1]:(n=()=>typeof window>`u`?!1:window.matchMedia(e).matches,t[0]=e,t[1]=n);let[r,i]=(0,B.useState)(n),a,o;return t[2]===e?(a=t[3],o=t[4]):(a=()=>{if(typeof window>`u`)return;let t=window.matchMedia(e),n=()=>i(t.matches);return n(),t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},o=[e],t[2]=e,t[3]=a,t[4]=o),(0,B.useEffect)(a,o),r}function he(e,t){let[n,r]=e.time.split(`:`),i=Number.parseInt(n||`9`,10),a=Number.parseInt(r||`0`,10),o;o=e.triggerMode===`manual`?{kind:`manual`}:e.triggerMode===`webhook`?{kind:`webhook`,...e.webhookSecretId.trim()?{secretId:e.webhookSecretId.trim()}:{}}:e.triggerMode===`goalBlocked`?{kind:`event`,eventType:`goal.status_changed`,source:`goals`,payloadMatch:{status:`blocked`}}:e.triggerMode===`noteCreated`?{kind:`event`,eventType:`note.created`,source:`notes`}:e.triggerMode===`workflowFailed`?{kind:`event`,eventType:`workflow.run.completed`,source:`workflows`,payloadMatch:{status:`failed`}}:e.triggerMode===`sessionUpdated`?{kind:`event`,eventType:`session.transcript.updated`,source:`sessions`}:e.triggerMode===`interval`?{kind:`schedule`,schedule:{kind:`interval`,everyMs:Math.max(1,Number.parseInt(e.intervalMinutes,10)||60)*6e4}}:e.triggerMode===`weekly`?{kind:`schedule`,schedule:{kind:`cron`,expr:`${a} ${i} * * ${e.weekday}`}}:e.triggerMode===`cron`?{kind:`schedule`,schedule:{kind:`cron`,expr:e.cronExpr.trim()}}:{kind:`schedule`,schedule:{kind:`cron`,expr:`${a} ${i} * * *`}};let s=R(t,e.workflowInput),c=e.workflowInput.goal.trim()||e.workflowGoal.trim(),l=e.safetyMode===`auto_apply`?e.afterRunMode:`none`,u=e.actionMode===`workflow`?{kind:`workflow`,workflowId:e.workflowId.trim(),...e.agentId.trim()?{agentId:e.agentId.trim()}:{},...s===void 0?{}:{input:s},...c?{goal:c}:{},...e.workflowInput.concurrency.trim()?{concurrency:Math.max(1,Number.parseInt(e.workflowInput.concurrency,10)||1)}:{},...e.workflowInput.maxSubagents.trim()?{maxSubagents:Math.max(1,Number.parseInt(e.workflowInput.maxSubagents,10)||1)}:{},timeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||300)}:{kind:`agent`,instruction:e.instruction.trim(),...e.agentId.trim()?{agentId:e.agentId.trim()}:{},timeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||300)};return{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},trigger:o,action:u,safety:{mode:e.safetyMode},afterRun:l===`webhook`?{kind:`webhook`,url:e.webhookUrl.trim()}:{kind:l},reliability:{timeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||300),disableAfterConsecutiveFailures:Math.max(1,Number.parseInt(e.disableAfterFailures,10)||3)}}}function J(){let e=o(e=>e.language),t=a(e),n=t.automations,r=t.cron,u=M(e=>e.setPageHeader),d=M(e=>e.clearPageHeader),[h,g]=m(),_=h.get(`run`)?.trim()??``,y=h.get(`draft`)?.trim()??``,b=h.get(`action`)?.trim()??``,w=h.get(`projectId`)?.trim()??``,E=h.get(`autogenerate`)===`1`,D=(0,B.useRef)(``),k=me(`(min-width: 1280px)`),[N,ne]=(0,B.useState)(`activity`),[P,ae]=(0,B.useState)(!1),[R,se]=(0,B.useState)(`blank`),[z,U]=(0,B.useState)(H),[le,W]=(0,B.useState)(null),[G,ue]=(0,B.useState)(null),[de,K]=(0,B.useState)(!1),[q,J]=(0,B.useState)(null),[_e,X]=(0,B.useState)(``),[Z,Se]=(0,B.useState)(null),[Ce,we]=(0,B.useState)(!1),[Ee,De]=(0,B.useState)(!1),[Q,$]=(0,B.useState)(null),[Oe,ke]=(0,B.useState)(!1),[Ae,je]=(0,B.useState)(!1),[Me,Ne]=(0,B.useState)(!1),[Pe,Fe]=(0,B.useState)(null),Ie=c([`automations`,w],()=>C.list(w?{projectId:w}:void 0),{refreshInterval:15e3}),Le=c([`automation-runs`,w],()=>C.runs(50,void 0,w?{projectId:w}:void 0),{refreshInterval:1e4}),Re=c(`automation-metrics`,()=>C.metrics(),{refreshInterval:15e3}),ze=c(G?`automation-run-events:${G}`:null,()=>C.runEvents(G),{refreshInterval:5e3}),Be=c(`automation-workflow-definitions`,l),Ve=c(`automation-chat-agents`,A),He=Ie.data?.automations??[],Ue=(0,B.useMemo)(()=>pe(Le.data?.runs??[]),[Le.data?.runs]),We=(0,B.useMemo)(()=>Ue.find(e=>e.id===G)??null,[Ue,G]),Ge=(0,B.useMemo)(()=>He.find(e=>e.id===q)??null,[He,q]),Ke=(0,B.useMemo)(()=>Ue.filter(e=>e.automationId===q),[Ue,q]),qe=ze.data?.events??[],Je=Re.data,Ye=(0,B.useMemo)(()=>Ue.filter(fe),[Ue]),Xe=Ue[0]??null,Ze=(0,B.useMemo)(()=>Be.data??[],[Be.data]),Qe=Ve.data?.items??[],$e=(0,B.useMemo)(()=>Ze.find(e=>e.id===z.workflowId.trim())??null,[z.workflowId,Ze]),et=z.actionMode===`workflow`&&(!z.workflowId.trim()||Ze.length>0&&!Ze.some(e=>e.id===z.workflowId)),tt=z.actionMode===`workflow`&&$e?!oe($e,z.workflowInput,z.workflowInputValid).valid:!1,nt=!!z.name.trim()&&(z.actionMode===`workflow`?!et&&!tt:!!z.instruction.trim())&&(z.afterRunMode!==`webhook`||!!z.webhookUrl.trim()),rt=(0,B.useMemo)(()=>[{name:n.templates.dailyAgent.name,description:n.templates.dailyAgent.description,form:{...H,name:n.templates.dailyAgent.name,instruction:n.templates.dailyAgent.instruction,triggerMode:`daily`}},{name:n.templates.morningWorkflow.name,description:n.templates.morningWorkflow.description,form:{...H,name:n.templates.morningWorkflow.formName,actionMode:`workflow`,workflowId:Ze[0]?.id??``}},{name:n.templates.webhookAgent.name,description:n.templates.webhookAgent.description,form:{...H,name:n.templates.webhookAgent.formName,triggerMode:`webhook`}},{name:n.templates.blockedGoal.name,description:n.templates.blockedGoal.description,form:{...H,name:n.templates.blockedGoal.formName,triggerMode:`goalBlocked`,instruction:n.templates.blockedGoal.instruction}},{name:n.templates.noteCreated.name,description:n.templates.noteCreated.description,form:{...H,name:n.templates.noteCreated.formName,triggerMode:`noteCreated`,instruction:n.templates.noteCreated.instruction}}],[n,Ze]),it=(0,B.useCallback)(async()=>{await Promise.all([Ie.mutate(),Le.mutate(),Re.mutate(),ze.mutate()])},[Ie.mutate,Re.mutate,ze.mutate,Le.mutate]),at=(0,B.useCallback)(e=>{se(e),ae(!0),e===`blank`&&U(H)},[]),ot=(0,B.useCallback)(async()=>{Ne(!0),W(null);try{await it()}catch(e){let t=e instanceof Error?e.message:String(e);W(t),s({type:`error`,title:n.feedback.actionFailed,message:t})}finally{Ne(!1)}},[n.feedback.actionFailed,it]);(0,B.useEffect)(()=>{_&&(ne(`activity`),ue(_),k||K(!0))},[_,k]),(0,B.useEffect)(()=>{k&&K(!1)},[k]),(0,B.useEffect)(()=>{b===`create`&&(at(`blank`),g(e=>{let t=new URLSearchParams(e);return t.delete(`action`),t},{replace:!0}))},[b,at,g]),(0,B.useEffect)(()=>{if(!y)return;let t=`${e}:${E?`auto`:`seed`}:${y}`;D.current!==t&&(D.current=t,X(y),Se(null),De(!1),se(`draft`),ae(!0),g(e=>{let t=new URLSearchParams(e);return t.delete(`draft`),t.delete(`autogenerate`),t},{replace:!0}),E&&(W(null),we(!0),C.draft({prompt:y,language:e}).then(e=>{Se(e.draft),De(!1)}).catch(e=>{W(e instanceof Error?e.message:String(e))}).finally(()=>{we(!1)})))},[E,y,e,g]);let st=(0,B.useCallback)(e=>{ue(e),k||K(!0),g(t=>{let n=new URLSearchParams(t);return n.set(`run`,e),n},{replace:!0})},[g,k]);(0,B.useEffect)(()=>{$(null),je(!1)},[G]);async function ct(){if(W(null),nt)try{await C.create({...he(z,$e),...w?{projectId:w}:{}}),U(H),ae(!1),await it(),s({type:`success`,title:n.dashboard.created})}catch(e){let t=e instanceof Error?e.message:String(e);W(t),s({type:`error`,title:n.feedback.actionFailed,message:t})}}async function lt(e,t,r){W(null),Fe(e);try{return await t(),await it(),r&&s({type:`success`,title:r}),!0}catch(e){let t=e instanceof Error?e.message:String(e);return W(t),s({type:`error`,title:n.feedback.actionFailed,message:t}),!1}finally{Fe(null)}}async function ut(){let t=_e.trim();if(t){W(null),we(!0);try{Se((await C.draft({prompt:t,language:e})).draft),De(!1)}catch(e){W(e instanceof Error?e.message:String(e))}finally{we(!1)}}}async function dt(){Z&&await lt(`draft:publish`,async()=>{await C.create({...Z.automation,...w?{projectId:w}:{}}),Se(null),X(``),De(!1),ae(!1)},n.dashboard.created)}async function ft(t){W(null),ke(!0),$(null),je(!1);try{$((await C.repairDraft(t.id,{language:e})).repair)}catch(e){W(e instanceof Error?e.message:String(e))}finally{ke(!1)}}async function pt(e){Q&&await lt(`run:${e.id}:repair`,async()=>{await C.update(e.automationId,Q.patch),$(null),je(!1)},n.feedback.repairApplied)}let mt=(0,B.useMemo)(()=>(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(x,{className:`size-9 shrink-0 p-0`,loading:Me,label:n.refresh,onClick:ot}),(0,V.jsxs)(F,{children:[(0,V.jsx)(L,{asChild:!0,children:(0,V.jsxs)(f,{variant:`primary`,children:[(0,V.jsx)(v,{className:`size-4`}),n.new]})}),(0,V.jsx)(re,{children:(0,V.jsxs)(ie,{align:`end`,className:`z-70 min-w-52 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:[(0,V.jsx)(I,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>at(`draft`),children:n.createMenu.draft}),(0,V.jsx)(I,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>at(`template`),children:n.createMenu.template}),(0,V.jsx)(I,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>at(`blank`),children:n.createMenu.blank})]})})]})]}),[n.createMenu.blank,n.createMenu.draft,n.createMenu.template,n.new,n.refresh,at,Me,ot]);return(0,B.useLayoutEffect)(()=>(u({startExtra:null,main:(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),(0,V.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:n.subtitle})]}),end:mt}),()=>d()),[d,mt,n.subtitle,n.title,u]),(0,V.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,V.jsxs)(`div`,{className:`flex w-full flex-col gap-5 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,V.jsxs)(`section`,{className:`grid gap-3 sm:grid-cols-4`,children:[(0,V.jsx)(Y,{label:n.dashboard.needsAttention,value:Je?.failedLastHour??Ye.length,tone:Ye.length>0?`danger`:`neutral`}),(0,V.jsx)(Y,{label:n.metrics.running,value:Je?.runningRuns??Ue.filter(e=>e.status===`running`).length}),(0,V.jsx)(Y,{label:n.dashboard.latestResult,value:Xe?n.status[Xe.status]:n.none,tone:Xe&&fe(Xe)?`danger`:`neutral`}),(0,V.jsx)(Y,{label:n.metrics.next,value:Je?.nextRun?ce(Je.nextRun.runAtMs,n,e):n.none})]}),(0,V.jsx)(`nav`,{className:`inline-flex w-fit rounded-lg border border-edge bg-surface-panel p-1`,children:[{id:`activity`,label:n.dashboard.activity,count:Ue.length},{id:`automations`,label:n.dashboard.manage,count:He.length}].map(e=>(0,V.jsxs)(`button`,{className:i(`inline-flex items-center gap-2 rounded-md px-3 py-1.5 text-sm font-medium text-fg-muted`,N===e.id&&`bg-surface-hover text-fg`),onClick:()=>{ne(e.id),e.id!==`activity`&&K(!1)},children:[(0,V.jsx)(`span`,{children:e.label}),(0,V.jsx)(`span`,{className:`rounded-full border border-edge/70 px-1.5 py-0.5 text-[0.6875rem] leading-none text-fg-muted`,children:e.count})]},e.id))}),le?(0,V.jsx)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:le}):null,N===`activity`?(0,V.jsxs)(`section`,{className:`grid h-[min(42rem,calc(100vh-17rem))] min-h-[28rem] items-stretch gap-4 xl:grid-cols-[minmax(0,1fr)_26rem]`,children:[(0,V.jsx)(`div`,{className:`min-h-0 min-w-0`,children:(0,V.jsx)(ye,{runs:Ue.slice(0,12),labels:n,cronLabels:r,language:e,selectedRunId:G,busyAction:Pe,className:`h-full overflow-y-auto`,onSelectRun:st,onAction:lt})}),(0,V.jsx)(be,{className:`hidden h-full xl:block`,run:We,events:qe,labels:n,cronLabels:r,language:e,loading:ze.isLoading,repairDraft:Q,repairLoading:Oe,repairApproved:Ae,busyAction:Pe,onRepairApprovedChange:je,onSuggestRepair:ft,onApplyRepair:pt})]}):(0,V.jsx)(`section`,{children:(0,V.jsx)(ve,{automations:He,runs:Ue,labels:n,cronLabels:r,language:e,busyAction:Pe,onOpenDetails:J,onAction:lt})})]}),(0,V.jsx)(S,{open:P,onOpenChange:ae,children:(0,V.jsxs)(O,{children:[(0,V.jsx)(j,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,V.jsxs)(te,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(760px,calc(100vh-2rem))] w-[min(100%-2rem,48rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-5 py-4`,children:[(0,V.jsx)(ee,{className:`text-base font-semibold text-fg`,children:R===`draft`?n.draft.title:R===`template`?n.createMenu.templatesTitle:n.createTitle}),(0,V.jsx)(T,{asChild:!0,children:(0,V.jsx)(f,{variant:`ghost`,"aria-label":n.close,children:(0,V.jsx)(p,{className:`size-4`})})})]}),R===`draft`?(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,V.jsx)(ge,{labels:n,prompt:_e,draft:Z,loading:Ce,approved:Ee,publishBusy:Pe===`draft:publish`,onPromptChange:X,onGenerate:ut,onPublish:dt,onApprovedChange:De,onDiscard:()=>{Se(null),De(!1)}})}):R===`template`?(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,V.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:rt.map(e=>(0,V.jsxs)(`button`,{className:`rounded-lg border border-edge bg-surface-base p-4 text-left hover:bg-surface-hover`,onClick:()=>{U(e.form),se(`blank`)},children:[(0,V.jsx)(`div`,{className:`font-medium text-fg`,children:e.name}),(0,V.jsx)(`div`,{className:`mt-2 text-sm text-fg-muted`,children:e.description})]},e.name))})}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Te,{form:z,labels:n,setForm:U,workflowDefinitions:Ze,selectedWorkflow:$e,workflowsLoading:Be.isLoading,agentOptions:Qe,agentsLoading:Ve.isLoading,language:e}),(0,V.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,V.jsx)(T,{asChild:!0,children:(0,V.jsx)(f,{variant:`ghost`,children:n.cancel})}),(0,V.jsx)(f,{variant:`primary`,onClick:ct,disabled:!nt,children:n.create})]})]})]})]})}),(0,V.jsx)(xe,{automation:Ge,runs:Ke,labels:n,cronLabels:r,language:e,busyAction:Pe,onClose:()=>J(null),onSelectRun:e=>{st(e),J(null)},onAction:lt}),(0,V.jsx)(S,{open:!k&&de&&!!We,onOpenChange:K,children:(0,V.jsxs)(O,{children:[(0,V.jsx)(j,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,V.jsxs)(te,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(85vh,40rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,V.jsx)(ee,{className:`truncate text-base font-semibold text-fg`,children:We?.automationName??n.dashboard.result}),(0,V.jsx)(T,{asChild:!0,children:(0,V.jsx)(f,{variant:`ghost`,"aria-label":n.close,children:(0,V.jsx)(p,{className:`size-4`})})})]}),(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,V.jsx)(be,{className:`h-full rounded-none border-0`,run:We,events:qe,labels:n,cronLabels:r,language:e,loading:ze.isLoading,repairDraft:Q,repairLoading:Oe,repairApproved:Ae,busyAction:Pe,onRepairApprovedChange:je,onSuggestRepair:ft,onApplyRepair:pt})})]})]})})]})}function Y(e){let t=(0,z.c)(13),{label:n,value:r,tone:a}=e,o=a===void 0?`neutral`:a,s=o===`danger`?`border-red-500/30`:`border-edge`,c;t[0]===s?c=t[1]:(c=i(`rounded-lg border bg-surface-panel px-4 py-3`,s),t[0]=s,t[1]=c);let l;t[2]===n?l=t[3]:(l=(0,V.jsx)(`div`,{className:`text-xs font-medium uppercase text-fg-muted`,children:n}),t[2]=n,t[3]=l);let u=o===`danger`?`text-red-700 dark:text-red-300`:`text-fg`,d;t[4]===u?d=t[5]:(d=i(`mt-1 truncate text-lg font-semibold`,u),t[4]=u,t[5]=d);let f;t[6]!==d||t[7]!==r?(f=(0,V.jsx)(`div`,{className:d,children:r}),t[6]=d,t[7]=r,t[8]=f):f=t[8];let p;return t[9]!==c||t[10]!==l||t[11]!==f?(p=(0,V.jsxs)(`div`,{className:c,children:[l,f]}),t[9]=c,t[10]=l,t[11]=f,t[12]=p):p=t[12],p}function ge(e){let t=(0,z.c)(47),{labels:n,prompt:r,draft:i,loading:a,approved:o,publishBusy:s,onPromptChange:c,onGenerate:l,onPublish:u,onApprovedChange:d,onDiscard:p}=e,m=s===void 0?!1:s,h=!!(i&&i.simulation.requiredConfirmations.length>0),g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,V.jsx)(E,{className:`size-4 text-accent`}),t[0]=g):g=t[0];let _;t[1]===n.draft.title?_=t[2]:(_=(0,V.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[g,n.draft.title]}),t[1]=n.draft.title,t[2]=_);let v;t[3]===n.draft.subtitle?v=t[4]:(v=(0,V.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:n.draft.subtitle}),t[3]=n.draft.subtitle,t[4]=v);let y;t[5]!==_||t[6]!==v?(y=(0,V.jsxs)(`div`,{className:`min-w-0`,children:[_,v]}),t[5]=_,t[6]=v,t[7]=y):y=t[7];let b;t[8]!==a||t[9]!==r?(b=a||!r.trim(),t[8]=a,t[9]=r,t[10]=b):b=t[10];let x;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,V.jsx)(E,{className:`size-4`}),t[11]=x):x=t[11];let S=a?n.draft.generating:n.draft.generate,C;t[12]!==l||t[13]!==b||t[14]!==S?(C=(0,V.jsxs)(f,{variant:`primary`,onClick:l,disabled:b,children:[x,S]}),t[12]=l,t[13]=b,t[14]=S,t[15]=C):C=t[15];let w;t[16]!==y||t[17]!==C?(w=(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[y,C]}),t[16]=y,t[17]=C,t[18]=w):w=t[18];let T;t[19]===c?T=t[20]:(T=e=>c(e.target.value),t[19]=c,t[20]=T);let D;t[21]!==n.draft.placeholder||t[22]!==r||t[23]!==T?(D=(0,V.jsx)(`textarea`,{className:`mt-4 min-h-20 w-full resize-y rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`,value:r,onChange:T,placeholder:n.draft.placeholder}),t[21]=n.draft.placeholder,t[22]=r,t[23]=T,t[24]=D):D=t[24];let O;t[25]!==o||t[26]!==i||t[27]!==n.draft.approval||t[28]!==n.draft.assumptions||t[29]!==n.draft.discard||t[30]!==n.draft.publish||t[31]!==n.draft.review||t[32]!==n.draft.risks||t[33]!==n.draft.safety||t[34]!==n.feedback||t[35]!==n.info||t[36]!==n.none||t[37]!==d||t[38]!==p||t[39]!==u||t[40]!==m||t[41]!==h?(O=i?(0,V.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg border border-edge bg-surface-base p-4 lg:grid-cols-[1fr_1fr]`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:i.automation.name}),i.automation.description?(0,V.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:i.automation.description}):null,(0,V.jsxs)(`div`,{className:`mt-3 grid gap-2 text-sm`,children:[(0,V.jsx)(Ce,{label:n.info.when,value:i.simulation.triggerSummary}),(0,V.jsx)(Ce,{label:n.info.run,value:i.simulation.actionSummary})]})]}),(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:n.draft.review}),(0,V.jsx)(_e,{title:n.draft.safety,items:[...i.simulation.safetyNotes,...i.simulation.requiredConfirmations],empty:n.none}),(0,V.jsx)(_e,{title:n.draft.assumptions,items:i.assumptions,empty:n.none}),(0,V.jsx)(_e,{title:n.draft.risks,items:i.risks,empty:n.none}),h?(0,V.jsxs)(`label`,{className:`mt-4 flex items-start gap-2 text-sm text-fg`,children:[(0,V.jsx)(`input`,{className:`mt-1`,type:`checkbox`,checked:o,onChange:e=>d(e.target.checked)}),(0,V.jsx)(`span`,{children:n.draft.approval})]}):null,(0,V.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,V.jsx)(f,{variant:`ghost`,onClick:p,children:n.draft.discard}),(0,V.jsx)(f,{variant:`primary`,onClick:u,disabled:m||h&&!o,children:m?n.feedback.working:n.draft.publish})]})]})]}):null,t[25]=o,t[26]=i,t[27]=n.draft.approval,t[28]=n.draft.assumptions,t[29]=n.draft.discard,t[30]=n.draft.publish,t[31]=n.draft.review,t[32]=n.draft.risks,t[33]=n.draft.safety,t[34]=n.feedback,t[35]=n.info,t[36]=n.none,t[37]=d,t[38]=p,t[39]=u,t[40]=m,t[41]=h,t[42]=O):O=t[42];let k;return t[43]!==w||t[44]!==D||t[45]!==O?(k=(0,V.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-panel p-4`,children:[w,D,O]}),t[43]=w,t[44]=D,t[45]=O,t[46]=k):k=t[46],k}function _e(e){let t=(0,z.c)(10),{title:n,items:r,empty:i}=e,a;t[0]===n?a=t[1]:(a=(0,V.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=a);let o;t[2]!==i||t[3]!==r?(o=r.length>0?r.map(X):(0,V.jsx)(`li`,{className:`text-fg-muted`,children:i}),t[2]=i,t[3]=r,t[4]=o):o=t[4];let s;t[5]===o?s=t[6]:(s=(0,V.jsx)(`ul`,{className:`mt-1 space-y-1 text-sm text-fg`,children:o}),t[5]=o,t[6]=s);let c;return t[7]!==a||t[8]!==s?(c=(0,V.jsxs)(`div`,{className:`mt-3`,children:[a,s]}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function X(e){return(0,V.jsxs)(`li`,{children:[`- `,e]},e)}function ve(e){let t=(0,z.c)(22),{automations:n,runs:r,labels:a,cronLabels:o,language:s,busyAction:c,onOpenDetails:l,onAction:d}=e;if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,V.jsx)(y,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===a.empty.automations?n=t[2]:(n=(0,V.jsx)(we,{icon:e,title:a.empty.automations}),t[1]=a.empty.automations,t[2]=n),n}let p;if(t[3]!==n||t[4]!==c||t[5]!==o||t[6]!==a||t[7]!==s||t[8]!==d||t[9]!==l||t[10]!==r){let e;t[12]!==c||t[13]!==o||t[14]!==a||t[15]!==s||t[16]!==d||t[17]!==l||t[18]!==r?(e=e=>{let t=r.filter(t=>t.automationId===e.id),n=t.find(K),p=t[0],m=c===`automation:${e.id}:run`,_=c===`automation:${e.id}:toggle`,v=c===`automation:${e.id}:delete`;return(0,V.jsxs)(`article`,{className:`flex min-h-44 cursor-pointer flex-col rounded-lg border border-edge bg-surface-panel p-3.5 outline-none hover:bg-surface-hover`,role:`button`,tabIndex:0,onClick:()=>l(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&l(e.id)},children:[(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.name}),n?(0,V.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-blue-500`}):null]}),e.description?(0,V.jsx)(`div`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.description}):null]}),(0,V.jsx)(`span`,{className:i(`shrink-0 rounded-full px-2 py-0.5 text-xs`,e.enabled?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-surface-hover text-fg-muted`),children:e.enabled?a.enabled:a.paused})]}),(0,V.jsxs)(`div`,{className:`mt-3 space-y-2 text-sm`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-fg`,children:[(0,V.jsx)(`span`,{className:`shrink-0 text-xs font-medium uppercase text-fg-muted`,children:a.info.when}),(0,V.jsx)(`span`,{className:`truncate`,children:le(e.trigger,a,o,s)})]}),(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-fg-muted`,children:[(0,V.jsx)(`span`,{className:`shrink-0 text-xs font-medium uppercase`,children:a.info.run}),(0,V.jsx)(`span`,{className:`truncate`,children:W(e.action,a)})]})]}),(0,V.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,V.jsxs)(`span`,{children:[a.last,`: `,ce(e.state.lastRunAtMs,a,s)]}),(0,V.jsxs)(`span`,{children:[a.next,`: `,ce(e.state.nextRunAtMs,a,s)]}),(0,V.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5`,ue(e.state.lastRunStatus)),children:e.state.lastRunStatus?a.status[e.state.lastRunStatus]:a.status.notRun}),p?.error?(0,V.jsx)(`p`,{className:`basis-full line-clamp-1 text-red-700 dark:text-red-300`,children:p.error}):null]}),(0,V.jsx)(`div`,{className:`mt-auto flex justify-end pt-3`,children:(0,V.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,V.jsx)(f,{variant:`ghost`,className:`size-8 rounded-md p-0`,"aria-label":a.dashboard.runNow,disabled:c!==null,onClick:t=>{t.stopPropagation(),d(`automation:${e.id}:run`,()=>C.runNow(e.id),a.feedback.rerunQueued)},children:(0,V.jsx)(h,{className:i(`size-4`,m&&`animate-pulse`)})}),(0,V.jsx)(f,{variant:`ghost`,className:`size-8 rounded-md p-0`,"aria-label":e.enabled?a.dashboard.pause:a.dashboard.resume,disabled:c!==null,onClick:t=>{t.stopPropagation(),d(`automation:${e.id}:toggle`,()=>e.enabled?C.pause(e.id):C.resume(e.id),e.enabled?a.feedback.paused:a.dashboard.resumed)},children:_?(0,V.jsx)(g,{className:`size-4 animate-spin`}):e.enabled?(0,V.jsx)(b,{className:`size-4`}):(0,V.jsx)(h,{className:`size-4`})}),(0,V.jsx)(f,{variant:`ghost`,className:`size-8 rounded-md p-0`,"aria-label":a.dashboard.delete,disabled:c!==null,onClick:t=>{t.stopPropagation(),d(`automation:${e.id}:delete`,()=>C.remove(e.id),a.dashboard.deleted)},children:v?(0,V.jsx)(g,{className:`size-4 animate-spin`}):(0,V.jsx)(u,{className:`size-4`})})]})})]},e.id)},t[12]=c,t[13]=o,t[14]=a,t[15]=s,t[16]=d,t[17]=l,t[18]=r,t[19]=e):e=t[19],p=n.map(e),t[3]=n,t[4]=c,t[5]=o,t[6]=a,t[7]=s,t[8]=d,t[9]=l,t[10]=r,t[11]=p}else p=t[11];let m;return t[20]===p?m=t[21]:(m=(0,V.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:p}),t[20]=p,t[21]=m),m}function ye(e){let t=(0,z.c)(25),{runs:n,labels:r,cronLabels:a,language:o,selectedRunId:s,busyAction:c,className:l,onSelectRun:u,onAction:p}=e;if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,V.jsx)(d,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===r.empty.runs?n=t[2]:(n=(0,V.jsx)(we,{icon:e,title:r.empty.runs}),t[1]=r.empty.runs,t[2]=n),n}let m;t[3]===l?m=t[4]:(m=i(`rounded-lg border border-edge bg-surface-panel`,l),t[3]=l,t[4]=m);let h;if(t[5]!==c||t[6]!==a||t[7]!==r||t[8]!==o||t[9]!==p||t[10]!==u||t[11]!==n||t[12]!==s){let e;t[14]!==c||t[15]!==a||t[16]!==r||t[17]!==o||t[18]!==p||t[19]!==u||t[20]!==s?(e=e=>(0,V.jsxs)(`div`,{className:i(`grid cursor-pointer gap-3 border-b border-edge p-4 outline-none last:border-b-0 hover:bg-surface-hover md:grid-cols-[1fr_auto]`,s===e.id&&`bg-surface-hover`),role:`button`,tabIndex:0,onClick:()=>u(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&u(e.id)},children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`font-medium text-fg`,children:e.automationName}),(0,V.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs`,ue(e.status)),children:r.status[e.status]}),e.workflowRunId?(0,V.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[r.workflowPrefix,` `,e.workflowRunId.slice(0,8)]}):null]}),(0,V.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:e.error||e.summary||W(e.actionSnapshot,r)}),(0,V.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[ce(e.createdAtMs,r,o),` · `,e.manual?r.trigger.manual:le(e.triggerSnapshot,r,a,o)]})]}),e.status===`running`||e.status===`queued`?(0,V.jsx)(f,{variant:`ghost`,disabled:c!==null,onClick:t=>{t.stopPropagation(),p(`run:${e.id}:cancel`,()=>C.cancelRun(e.id),r.dashboard.cancelled)},children:c===`run:${e.id}:cancel`?r.feedback.working:r.cancel}):null]},e.id),t[14]=c,t[15]=a,t[16]=r,t[17]=o,t[18]=p,t[19]=u,t[20]=s,t[21]=e):e=t[21],h=n.map(e),t[5]=c,t[6]=a,t[7]=r,t[8]=o,t[9]=p,t[10]=u,t[11]=n,t[12]=s,t[13]=h}else h=t[13];let g;return t[22]!==m||t[23]!==h?(g=(0,V.jsx)(`div`,{className:m,children:h}),t[22]=m,t[23]=h,t[24]=g):g=t[24],g}function be(e){let t=(0,z.c)(127),{className:n,run:r,events:a,labels:o,cronLabels:s,language:c,loading:l,repairDraft:u,repairLoading:p,repairApproved:m,busyAction:h,onRepairApprovedChange:g,onSuggestRepair:v,onApplyRepair:y}=e;if(!r){let e;t[0]===n?e=t[1]:(e=i(`flex min-h-64 flex-col justify-center rounded-lg border border-edge bg-surface-panel px-4 text-center text-sm text-fg-muted`,n),t[0]=n,t[1]=e);let r;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,V.jsx)(d,{className:`mx-auto size-5`}),t[2]=r):r=t[2];let a;t[3]===o.selectRun?a=t[4]:(a=(0,V.jsx)(`div`,{className:`mt-2`,children:o.selectRun}),t[3]=o.selectRun,t[4]=a);let s;return t[5]!==e||t[6]!==a?(s=(0,V.jsxs)(`aside`,{className:e,children:[r,a]}),t[5]=e,t[6]=a,t[7]=s):s=t[7],s}let b;t[8]===n?b=t[9]:(b=i(`min-h-0 overflow-y-auto rounded-lg border border-edge bg-surface-panel`,n),t[8]=n,t[9]=b);let x;t[10]===r.automationName?x=t[11]:(x=(0,V.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:r.automationName}),t[10]=r.automationName,t[11]=x);let S;t[12]===r.id?S=t[13]:(S=r.id.slice(0,8),t[12]=r.id,t[13]=S);let C;t[14]===S?C=t[15]:(C=(0,V.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:S}),t[14]=S,t[15]=C);let w;t[16]!==x||t[17]!==C?(w=(0,V.jsxs)(`div`,{className:`min-w-0`,children:[x,C]}),t[16]=x,t[17]=C,t[18]=w):w=t[18];let T;t[19]===r.status?T=t[20]:(T=i(`shrink-0 rounded-full px-2 py-0.5 text-xs`,ue(r.status)),t[19]=r.status,t[20]=T);let D=o.status[r.status],O;t[21]!==T||t[22]!==D?(O=(0,V.jsx)(`span`,{className:T,children:D}),t[21]=T,t[22]=D,t[23]=O):O=t[23];let A;t[24]!==w||t[25]!==O?(A=(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[w,O]}),t[24]=w,t[25]=O,t[26]=A):A=t[26];let ee=o.details.created,j;t[27]!==o||t[28]!==c||t[29]!==r.createdAtMs?(j=ce(r.createdAtMs,o,c),t[27]=o,t[28]=c,t[29]=r.createdAtMs,t[30]=j):j=t[30];let M;t[31]!==o.details.created||t[32]!==j?(M=(0,V.jsx)(Z,{label:ee,value:j}),t[31]=o.details.created,t[32]=j,t[33]=M):M=t[33];let te=o.details.started,N;t[34]!==o||t[35]!==c||t[36]!==r.startedAtMs?(N=ce(r.startedAtMs,o,c),t[34]=o,t[35]=c,t[36]=r.startedAtMs,t[37]=N):N=t[37];let P;t[38]!==o.details.started||t[39]!==N?(P=(0,V.jsx)(Z,{label:te,value:N}),t[38]=o.details.started,t[39]=N,t[40]=P):P=t[40];let F=o.details.duration,I;t[41]!==o||t[42]!==r.durationMs?(I=de(r.durationMs,o),t[41]=o,t[42]=r.durationMs,t[43]=I):I=t[43];let L;t[44]!==o.details.duration||t[45]!==I?(L=(0,V.jsx)(Z,{label:F,value:I}),t[44]=o.details.duration,t[45]=I,t[46]=L):L=t[46];let re;t[47]!==o.details.model||t[48]!==r.model?(re=r.model?(0,V.jsx)(Z,{label:o.details.model,value:r.model}):null,t[47]=o.details.model,t[48]=r.model,t[49]=re):re=t[49];let ie;t[50]!==M||t[51]!==P||t[52]!==L||t[53]!==re?(ie=(0,V.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs text-fg-muted`,children:[M,P,L,re]}),t[50]=M,t[51]=P,t[52]=L,t[53]=re,t[54]=ie):ie=t[54];let ae;t[55]===o.dashboard.result?ae=t[56]:(ae=(0,V.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:o.dashboard.result}),t[55]=o.dashboard.result,t[56]=ae);let R;t[57]===r?R=t[58]:(R=fe(r)?`text-red-700 dark:text-red-300`:`text-fg`,t[57]=r,t[58]=R);let oe;t[59]===R?oe=t[60]:(oe=i(`mt-1 break-words text-sm`,R),t[59]=R,t[60]=oe);let se;t[61]!==o||t[62]!==r.actionSnapshot||t[63]!==r.error||t[64]!==r.summary?(se=r.error||r.summary||W(r.actionSnapshot,o),t[61]=o,t[62]=r.actionSnapshot,t[63]=r.error,t[64]=r.summary,t[65]=se):se=t[65];let B;t[66]!==oe||t[67]!==se?(B=(0,V.jsx)(`p`,{className:oe,children:se}),t[66]=oe,t[67]=se,t[68]=B):B=t[68];let H;t[69]!==s||t[70]!==o||t[71]!==c||t[72]!==r.manual||t[73]!==r.triggerSnapshot?(H=r.manual?o.trigger.manual:le(r.triggerSnapshot,o,s,c),t[69]=s,t[70]=o,t[71]=c,t[72]=r.manual,t[73]=r.triggerSnapshot,t[74]=H):H=t[74];let U;t[75]!==o.explain.whyRan||t[76]!==H?(U=(0,V.jsx)(Z,{label:o.explain.whyRan,value:H}),t[75]=o.explain.whyRan,t[76]=H,t[77]=U):U=t[77];let G;t[78]!==o.dashboard.openSession||t[79]!==r.sessionKey?(G=r.sessionKey?(0,V.jsx)(f,{asChild:!0,variant:`secondary`,className:`h-8 justify-start rounded-md px-2 text-xs`,children:(0,V.jsxs)(k,{to:`/chat/${encodeURIComponent(r.sessionKey)}`,children:[(0,V.jsx)(ne,{className:`size-3.5`}),o.dashboard.openSession]})}):null,t[78]=o.dashboard.openSession,t[79]=r.sessionKey,t[80]=G):G=t[80];let K;t[81]!==o.feedback||t[82]!==r.workflowRunId?(K=r.workflowRunId?(0,V.jsx)(f,{asChild:!0,variant:`secondary`,className:`h-8 justify-start rounded-md px-2 text-xs`,children:(0,V.jsxs)(k,{to:`/workflows?run=${encodeURIComponent(r.workflowRunId)}`,children:[(0,V.jsx)(_,{className:`size-3.5`}),o.feedback.workflow]})}):null,t[81]=o.feedback,t[82]=r.workflowRunId,t[83]=K):K=t[83];let q;t[84]!==U||t[85]!==G||t[86]!==K?(q=(0,V.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs text-fg-muted`,children:[U,G,K]}),t[84]=U,t[85]=G,t[86]=K,t[87]=q):q=t[87];let pe;t[88]!==ae||t[89]!==B||t[90]!==q?(pe=(0,V.jsxs)(`div`,{className:`mt-3 rounded-md border border-edge/70 bg-surface-base/50 p-3`,children:[ae,B,q]}),t[88]=ae,t[89]=B,t[90]=q,t[91]=pe):pe=t[91];let me;t[92]!==o.repair||t[93]!==v||t[94]!==p||t[95]!==r?(me=r.status===`failed`||r.status===`timeout`||r.status===`cancelled`?(0,V.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,V.jsxs)(f,{variant:`secondary`,onClick:()=>v(r),disabled:p,children:[(0,V.jsx)(E,{className:`size-4`}),p?o.repair.generating:o.repair.suggest]})}):null,t[92]=o.repair,t[93]=v,t[94]=p,t[95]=r,t[96]=me):me=t[96];let he;t[97]!==ie||t[98]!==pe||t[99]!==me||t[100]!==A?(he=(0,V.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[A,ie,pe,me]}),t[97]=ie,t[98]=pe,t[99]=me,t[100]=A,t[101]=he):he=t[101];let J;t[102]!==h||t[103]!==o.feedback||t[104]!==o.none||t[105]!==o.repair||t[106]!==y||t[107]!==g||t[108]!==m||t[109]!==u||t[110]!==r?(J=u?(0,V.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[(0,V.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:o.repair.title}),(0,V.jsx)(`div`,{className:`mt-2 text-sm text-fg`,children:u.explanation}),u.expectedEffect?(0,V.jsx)(`div`,{className:`mt-2 text-sm text-fg-muted`,children:u.expectedEffect}):null,(0,V.jsx)(_e,{title:o.repair.risks,items:u.risks,empty:o.none}),(0,V.jsx)(`pre`,{className:`mt-3 max-h-36 overflow-auto rounded-md bg-surface-base p-2 text-xs text-fg-muted`,children:JSON.stringify(u.patch,null,2)}),u.requiresApproval?(0,V.jsxs)(`label`,{className:`mt-3 flex items-start gap-2 text-sm text-fg`,children:[(0,V.jsx)(`input`,{className:`mt-1`,type:`checkbox`,checked:m,onChange:e=>g(e.target.checked)}),(0,V.jsx)(`span`,{children:o.repair.approval})]}):null,(0,V.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,V.jsx)(f,{variant:`primary`,onClick:()=>y(r),disabled:h===`run:${r.id}:repair`||u.requiresApproval&&!m,children:h===`run:${r.id}:repair`?o.feedback.working:o.repair.apply})})]}):null,t[102]=h,t[103]=o.feedback,t[104]=o.none,t[105]=o.repair,t[106]=y,t[107]=g,t[108]=m,t[109]=u,t[110]=r,t[111]=J):J=t[111];let Y;t[112]===o.timeline?Y=t[113]:(Y=(0,V.jsx)(`div`,{className:`mb-3 text-xs font-semibold uppercase text-fg-muted`,children:o.timeline}),t[112]=o.timeline,t[113]=Y);let ge;t[114]!==a||t[115]!==o||t[116]!==c||t[117]!==l?(ge=l?(0,V.jsx)(`div`,{className:`text-sm text-fg-muted`,children:o.loading}):a.length===0?(0,V.jsx)(`div`,{className:`text-sm text-fg-muted`,children:o.empty.events}):(0,V.jsx)(`ol`,{className:`space-y-3`,children:a.map(e=>(0,V.jsxs)(`li`,{className:`grid grid-cols-[0.75rem_1fr] gap-3`,children:[(0,V.jsx)(`span`,{className:i(`mt-1 size-2 rounded-full`,Se(e.type))}),(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-sm text-fg`,children:e.message}),(0,V.jsxs)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:[ce(e.createdAtMs,o,c),` · `,e.type]}),e.data&&typeof e.data==`object`?(0,V.jsx)(`pre`,{className:`mt-2 max-h-28 overflow-auto rounded-md bg-surface-base p-2 text-xs text-fg-muted`,children:JSON.stringify(e.data,null,2)}):null]})]},e.id))}),t[114]=a,t[115]=o,t[116]=c,t[117]=l,t[118]=ge):ge=t[118];let X;t[119]!==Y||t[120]!==ge?(X=(0,V.jsxs)(`div`,{className:`px-4 py-3`,children:[Y,ge]}),t[119]=Y,t[120]=ge,t[121]=X):X=t[121];let ve;return t[122]!==b||t[123]!==he||t[124]!==J||t[125]!==X?(ve=(0,V.jsxs)(`aside`,{className:b,children:[he,J,X]}),t[122]=b,t[123]=he,t[124]=J,t[125]=X,t[126]=ve):ve=t[126],ve}function xe(e){let t=(0,z.c)(25),{automation:n,runs:r,labels:a,cronLabels:o,language:s,busyAction:c,onClose:l,onSelectRun:m,onAction:v}=e,y;t[0]===n?y=t[1]:(y=n?G(n):`suggest_only`,t[0]=n,t[1]=y);let x=y,E=n?c===`automation:${n.id}:run`:!1,D=n?c===`automation:${n.id}:toggle`:!1,A=n?c===`automation:${n.id}:delete`:!1,M=!!n,N;t[2]===l?N=t[3]:(N=e=>!e&&l(),t[2]=l,t[3]=N);let P;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,V.jsx)(j,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),t[4]=P):P=t[4];let F;t[5]!==n||t[6]!==c||t[7]!==o||t[8]!==A||t[9]!==a||t[10]!==s||t[11]!==x||t[12]!==v||t[13]!==l||t[14]!==m||t[15]!==E||t[16]!==r||t[17]!==D?(F=n?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(ee,{className:`truncate text-base font-semibold text-fg`,children:n.name}),n.description?(0,V.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:n.description}):null]}),(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,V.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs`,n.enabled?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-surface-hover text-fg-muted`),children:n.enabled?a.enabled:a.paused}),(0,V.jsx)(T,{asChild:!0,children:(0,V.jsx)(f,{variant:`ghost`,"aria-label":a.close,children:(0,V.jsx)(p,{className:`size-4`})})})]})]}),(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,V.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[18rem_1fr]`,children:[(0,V.jsxs)(`aside`,{className:`grid h-fit gap-3 rounded-lg border border-edge bg-surface-base p-4`,children:[(0,V.jsx)(Ce,{label:a.info.when,value:le(n.trigger,a,o,s)}),(0,V.jsx)(Ce,{label:a.info.run,value:W(n.action,a)}),(0,V.jsx)(Ce,{label:a.info.safety,value:a.safety[x]}),(0,V.jsx)(Z,{label:a.last,value:ce(n.state.lastRunAtMs,a,s)}),(0,V.jsx)(Z,{label:a.next,value:ce(n.state.nextRunAtMs,a,s)}),n.state.consecutiveFailures?(0,V.jsx)(Z,{label:a.dashboard.failures,value:String(n.state.consecutiveFailures)}):null,n.state.lastError?(0,V.jsx)(`p`,{className:`break-words text-sm text-red-700 dark:text-red-300`,children:n.state.lastError}):null]}),(0,V.jsxs)(`section`,{className:`min-w-0`,children:[(0,V.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.dashboard.runHistory}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.dashboard.runHistoryDescription})]}),(0,V.jsx)(`span`,{className:`rounded-full border border-edge bg-surface-base px-2.5 py-1 text-xs text-fg-muted`,children:r.length})]}),r.length===0?(0,V.jsx)(we,{icon:(0,V.jsx)(d,{className:`size-5`}),title:a.empty.runs}):(0,V.jsx)(`div`,{className:`grid gap-2`,children:r.map(e=>(0,V.jsx)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:(0,V.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,V.jsxs)(`button`,{className:`min-w-0 text-left outline-none`,onClick:()=>m(e.id),children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[e.status===`succeeded`?(0,V.jsx)(w,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-300`}):(0,V.jsx)(d,{className:`size-4 shrink-0 text-fg-muted`}),(0,V.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:ce(e.createdAtMs,a,s)}),(0,V.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs`,ue(e.status)),children:a.status[e.status]})]}),(0,V.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.error||e.summary||W(e.actionSnapshot,a)})]}),(0,V.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-1`,children:[e.sessionKey?(0,V.jsx)(f,{asChild:!0,variant:`ghost`,className:`h-8 rounded-md px-2 text-xs`,children:(0,V.jsxs)(k,{to:`/chat/${encodeURIComponent(e.sessionKey)}`,children:[(0,V.jsx)(ne,{className:`size-3.5`}),a.dashboard.openSession]})}):null,e.workflowRunId?(0,V.jsx)(f,{asChild:!0,variant:`ghost`,className:`h-8 rounded-md px-2 text-xs`,children:(0,V.jsxs)(k,{to:`/workflows?run=${encodeURIComponent(e.workflowRunId)}`,children:[(0,V.jsx)(_,{className:`size-3.5`}),a.feedback.workflow]})}):null]})]})},e.id))})]})]})}),(0,V.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-2 border-t border-edge px-5 py-4`,children:[(0,V.jsxs)(f,{variant:`ghost`,disabled:c!==null,onClick:()=>void v(`automation:${n.id}:delete`,()=>C.remove(n.id),a.dashboard.deleted).then(e=>{e&&l()}),children:[A?(0,V.jsx)(g,{className:`size-4 animate-spin`}):(0,V.jsx)(u,{className:`size-4`}),a.dashboard.delete]}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsxs)(f,{variant:`secondary`,disabled:c!==null,onClick:()=>void v(`automation:${n.id}:toggle`,()=>n.enabled?C.pause(n.id):C.resume(n.id),n.enabled?a.feedback.paused:a.dashboard.resumed),children:[D?(0,V.jsx)(g,{className:`size-4 animate-spin`}):n.enabled?(0,V.jsx)(b,{className:`size-4`}):(0,V.jsx)(h,{className:`size-4`}),n.enabled?a.dashboard.pause:a.dashboard.resume]}),(0,V.jsxs)(f,{variant:`primary`,disabled:c!==null,onClick:()=>void v(`automation:${n.id}:run`,()=>C.runNow(n.id),a.feedback.rerunQueued),children:[E?(0,V.jsx)(g,{className:`size-4 animate-spin`}):(0,V.jsx)(h,{className:`size-4`}),a.dashboard.runNow]})]})]})]}):null,t[5]=n,t[6]=c,t[7]=o,t[8]=A,t[9]=a,t[10]=s,t[11]=x,t[12]=v,t[13]=l,t[14]=m,t[15]=E,t[16]=r,t[17]=D,t[18]=F):F=t[18];let I;t[19]===F?I=t[20]:(I=(0,V.jsxs)(O,{children:[P,(0,V.jsx)(te,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(760px,calc(100vh-2rem))] w-[min(100%-2rem,56rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:F})]}),t[19]=F,t[20]=I);let L;return t[21]!==M||t[22]!==N||t[23]!==I?(L=(0,V.jsx)(S,{open:M,onOpenChange:N,children:I}),t[21]=M,t[22]=N,t[23]=I,t[24]=L):L=t[24],L}function Z(e){let t=(0,z.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,V.jsx)(`span`,{children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,V.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,V.jsxs)(`div`,{className:`grid grid-cols-[5rem_1fr] gap-2`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function Se(e){return e.endsWith(`.failed`)?`bg-red-500`:e.endsWith(`.completed`)?`bg-emerald-500`:e.endsWith(`.started`)?`bg-blue-500`:`bg-fg-muted`}function Ce(e){let t=(0,z.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,V.jsx)(`div`,{className:`text-xs font-medium uppercase text-fg-muted`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,V.jsx)(`div`,{className:`mt-1 truncate text-sm text-fg`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,V.jsxs)(`div`,{className:`min-w-0`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function we(e){let t=(0,z.c)(5),{icon:n,title:r}=e,i;t[0]===r?i=t[1]:(i=(0,V.jsx)(`div`,{className:`mt-2 text-sm`,children:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,V.jsxs)(`div`,{className:`flex min-h-48 flex-col items-center justify-center rounded-lg border border-edge bg-surface-panel text-fg-muted`,children:[n,i]}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function Te(e){let t=(0,z.c)(218),{form:n,labels:r,setForm:a,workflowDefinitions:o,selectedWorkflow:s,workflowsLoading:c,agentOptions:l,agentsLoading:u,language:d}=e,f;t[0]===a?f=t[1]:(f=e=>a(t=>({...t,...e})),t[0]=a,t[1]=f);let p=f,m,h;t[2]!==n.actionMode||t[3]!==n.workflowId||t[4]!==a||t[5]!==o?(m=()=>{if(n.actionMode!==`workflow`||n.workflowId.trim())return;let e=o[0]?.id;e&&a(t=>({...t,workflowId:e,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}))},h=[n.actionMode,n.workflowId,a,o],t[2]=n.actionMode,t[3]=n.workflowId,t[4]=a,t[5]=o,t[6]=m,t[7]=h):(m=t[6],h=t[7]),(0,B.useEffect)(m,h);let g;t[8]===p?g=t[9]:(g=e=>p({name:e.target.value}),t[8]=p,t[9]=g);let _;t[10]!==n.name||t[11]!==g?(_=(0,V.jsx)(`input`,{className:Q,value:n.name,onChange:g}),t[10]=n.name,t[11]=g,t[12]=_):_=t[12];let v;t[13]!==r.form.name||t[14]!==_?(v=(0,V.jsx)($,{label:r.form.name,children:_}),t[13]=r.form.name,t[14]=_,t[15]=v):v=t[15];let y;t[16]===p?y=t[17]:(y=e=>p({description:e.target.value}),t[16]=p,t[17]=y);let b;t[18]!==n.description||t[19]!==y?(b=(0,V.jsx)(`input`,{className:Q,value:n.description,onChange:y}),t[18]=n.description,t[19]=y,t[20]=b):b=t[20];let x;t[21]!==r.form.description||t[22]!==b?(x=(0,V.jsx)($,{label:r.form.description,children:b}),t[21]=r.form.description,t[22]=b,t[23]=x):x=t[23];let S;t[24]===r.form.trigger?S=t[25]:(S=(0,V.jsx)(Oe,{title:r.form.trigger}),t[24]=r.form.trigger,t[25]=S);let C;t[26]===p?C=t[27]:(C=e=>p({triggerMode:e.target.value}),t[26]=p,t[27]=C);let w;t[28]===r.trigger.manual?w=t[29]:(w=(0,V.jsx)(N,{value:`manual`,children:r.trigger.manual}),t[28]=r.trigger.manual,t[29]=w);let T;t[30]===r.trigger.daily?T=t[31]:(T=(0,V.jsx)(N,{value:`daily`,children:r.trigger.daily}),t[30]=r.trigger.daily,t[31]=T);let E;t[32]===r.trigger.weekly?E=t[33]:(E=(0,V.jsx)(N,{value:`weekly`,children:r.trigger.weekly}),t[32]=r.trigger.weekly,t[33]=E);let O;t[34]===r.trigger.interval?O=t[35]:(O=(0,V.jsx)(N,{value:`interval`,children:r.trigger.interval}),t[34]=r.trigger.interval,t[35]=O);let k;t[36]===r.trigger.customCron?k=t[37]:(k=(0,V.jsx)(N,{value:`cron`,children:r.trigger.customCron}),t[36]=r.trigger.customCron,t[37]=k);let A;t[38]===r.trigger.webhook?A=t[39]:(A=(0,V.jsx)(N,{value:`webhook`,children:r.trigger.webhook}),t[38]=r.trigger.webhook,t[39]=A);let ee;t[40]===r.trigger.goalBlocked?ee=t[41]:(ee=(0,V.jsx)(N,{value:`goalBlocked`,children:r.trigger.goalBlocked}),t[40]=r.trigger.goalBlocked,t[41]=ee);let j;t[42]===r.trigger.noteCreated?j=t[43]:(j=(0,V.jsx)(N,{value:`noteCreated`,children:r.trigger.noteCreated}),t[42]=r.trigger.noteCreated,t[43]=j);let M;t[44]===r.trigger.workflowFailed?M=t[45]:(M=(0,V.jsx)(N,{value:`workflowFailed`,children:r.trigger.workflowFailed}),t[44]=r.trigger.workflowFailed,t[45]=M);let te;t[46]===r.trigger.sessionUpdated?te=t[47]:(te=(0,V.jsx)(N,{value:`sessionUpdated`,children:r.trigger.sessionUpdated}),t[46]=r.trigger.sessionUpdated,t[47]=te);let ne;t[48]!==n.triggerMode||t[49]!==C||t[50]!==w||t[51]!==T||t[52]!==E||t[53]!==O||t[54]!==k||t[55]!==A||t[56]!==ee||t[57]!==j||t[58]!==M||t[59]!==te?(ne=(0,V.jsxs)(D,{className:Q,value:n.triggerMode,onChange:C,children:[w,T,E,O,k,A,ee,j,M,te]}),t[48]=n.triggerMode,t[49]=C,t[50]=w,t[51]=T,t[52]=E,t[53]=O,t[54]=k,t[55]=A,t[56]=ee,t[57]=j,t[58]=M,t[59]=te,t[60]=ne):ne=t[60];let P;t[61]!==n.time||t[62]!==n.triggerMode||t[63]!==n.weekday||t[64]!==r.form.day||t[65]!==r.form.time||t[66]!==r.weekdays||t[67]!==p?(P=n.triggerMode===`daily`||n.triggerMode===`weekly`?(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,V.jsx)($,{label:r.form.time,children:(0,V.jsx)(`input`,{className:Q,type:`time`,value:n.time,onChange:e=>p({time:e.target.value})})}),n.triggerMode===`weekly`?(0,V.jsx)($,{label:r.form.day,children:(0,V.jsxs)(D,{className:Q,value:n.weekday,onChange:e=>p({weekday:e.target.value}),children:[(0,V.jsx)(N,{value:`1`,children:r.weekdays.monday}),(0,V.jsx)(N,{value:`2`,children:r.weekdays.tuesday}),(0,V.jsx)(N,{value:`3`,children:r.weekdays.wednesday}),(0,V.jsx)(N,{value:`4`,children:r.weekdays.thursday}),(0,V.jsx)(N,{value:`5`,children:r.weekdays.friday}),(0,V.jsx)(N,{value:`6`,children:r.weekdays.saturday}),(0,V.jsx)(N,{value:`0`,children:r.weekdays.sunday})]})}):null]}):null,t[61]=n.time,t[62]=n.triggerMode,t[63]=n.weekday,t[64]=r.form.day,t[65]=r.form.time,t[66]=r.weekdays,t[67]=p,t[68]=P):P=t[68];let F;t[69]!==n.intervalMinutes||t[70]!==n.triggerMode||t[71]!==r.form.everyMinutes||t[72]!==p?(F=n.triggerMode===`interval`?(0,V.jsx)($,{label:r.form.everyMinutes,children:(0,V.jsx)(`input`,{className:Q,inputMode:`numeric`,value:n.intervalMinutes,onChange:e=>p({intervalMinutes:e.target.value})})}):null,t[69]=n.intervalMinutes,t[70]=n.triggerMode,t[71]=r.form.everyMinutes,t[72]=p,t[73]=F):F=t[73];let I;t[74]!==n.cronExpr||t[75]!==n.triggerMode||t[76]!==r.form.expression||t[77]!==p?(I=n.triggerMode===`cron`?(0,V.jsx)($,{label:r.form.expression,children:(0,V.jsx)(`input`,{className:Q,value:n.cronExpr,onChange:e=>p({cronExpr:e.target.value})})}):null,t[74]=n.cronExpr,t[75]=n.triggerMode,t[76]=r.form.expression,t[77]=p,t[78]=I):I=t[78];let L;t[79]!==n.triggerMode||t[80]!==n.webhookSecretId||t[81]!==r.form.secretId||t[82]!==p?(L=n.triggerMode===`webhook`?(0,V.jsx)($,{label:r.form.secretId,children:(0,V.jsx)(`input`,{className:Q,value:n.webhookSecretId,onChange:e=>p({webhookSecretId:e.target.value})})}):null,t[79]=n.triggerMode,t[80]=n.webhookSecretId,t[81]=r.form.secretId,t[82]=p,t[83]=L):L=t[83];let re;t[84]===r.form.action?re=t[85]:(re=(0,V.jsx)(Oe,{title:r.form.action}),t[84]=r.form.action,t[85]=re);let ie;t[86]!==n.workflowId||t[87]!==p||t[88]!==o?(ie=e=>{let t=e.target.value;p({actionMode:t,...t===`workflow`&&!n.workflowId.trim()&&o[0]?{workflowId:o[0].id,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}:{}})},t[86]=n.workflowId,t[87]=p,t[88]=o,t[89]=ie):ie=t[89];let R;t[90]===r.action.runAgent?R=t[91]:(R=(0,V.jsx)(N,{value:`agent`,children:r.action.runAgent}),t[90]=r.action.runAgent,t[91]=R);let oe;t[92]===r.action.runWorkflow?oe=t[93]:(oe=(0,V.jsx)(N,{value:`workflow`,children:r.action.runWorkflow}),t[92]=r.action.runWorkflow,t[93]=oe);let H;t[94]!==n.actionMode||t[95]!==ie||t[96]!==R||t[97]!==oe?(H=(0,V.jsxs)(D,{className:Q,value:n.actionMode,onChange:ie,children:[R,oe]}),t[94]=n.actionMode,t[95]=ie,t[96]=R,t[97]=oe,t[98]=H):H=t[98];let U=r.form.agent,ce=n.agentId,le;t[99]===p?le=t[100]:(le=e=>p({agentId:e.target.value}),t[99]=p,t[100]=le);let W=u?r.form.loadingAgents:r.form.defaultAgent,G;t[101]===W?G=t[102]:(G=(0,V.jsx)(N,{value:``,children:W}),t[101]=W,t[102]=G);let ue;t[103]===l?ue=t[104]:(ue=l.map(De),t[103]=l,t[104]=ue);let de;t[105]!==n.agentId||t[106]!==le||t[107]!==G||t[108]!==ue?(de=(0,V.jsxs)(D,{className:Q,value:ce,onChange:le,children:[G,ue]}),t[105]=n.agentId,t[106]=le,t[107]=G,t[108]=ue,t[109]=de):de=t[109];let K;t[110]!==r.form.agent||t[111]!==de?(K=(0,V.jsx)($,{label:U,children:de}),t[110]=r.form.agent,t[111]=de,t[112]=K):K=t[112];let fe;t[113]!==n.actionMode||t[114]!==n.agentId||t[115]!==n.description||t[116]!==n.instruction||t[117]!==n.name||t[118]!==n.triggerMode||t[119]!==n.workflowId||t[120]!==n.workflowInput||t[121]!==r.form.instruction||t[122]!==r.form.loadingWorkflows||t[123]!==r.form.noWorkflows||t[124]!==r.form.triggeredRun||t[125]!==r.form.workflow||t[126]!==d||t[127]!==s||t[128]!==p||t[129]!==o||t[130]!==c?(fe=n.actionMode===`agent`?(0,V.jsxs)($,{label:r.form.instruction,children:[(0,V.jsx)(`div`,{className:`flex justify-end`,children:(0,V.jsx)(ae,{value:n.instruction,onApply:e=>p({instruction:e}),fieldId:`automation.instruction`,fieldLabel:r.form.instruction,scenario:`automation.instruction`,locale:d,context:{automationName:n.name,automationDescription:n.description,triggerMode:n.triggerMode,agentId:n.agentId},showLabel:!1})}),(0,V.jsx)(`textarea`,{className:i(Q,`min-h-32 resize-y`),value:n.instruction,onChange:e=>p({instruction:e.target.value})})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)($,{label:r.form.workflow,children:(0,V.jsxs)(D,{className:Q,value:n.workflowId,onChange:e=>p({workflowId:e.target.value,workflowGoal:``,workflowInput:{goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``},workflowInputValid:!0}),disabled:c||o.length===0,children:[c?(0,V.jsx)(N,{value:``,children:r.form.loadingWorkflows}):null,!c&&o.length===0?(0,V.jsx)(N,{value:``,children:r.form.noWorkflows}):null,o.map(Ee)]})}),s?(0,V.jsx)(se,{definition:s,language:d,value:n.workflowInput,onChange:e=>p({workflowInput:e,workflowGoal:e.goal,workflowInputValid:!0}),mode:`automation`,badgeLabel:r.form.triggeredRun,onValidityChange:e=>p({workflowInputValid:e.valid}),aiAssist:{inputScenario:`automation.workflowInput`,goalScenario:`automation.workflowGoal`,context:{automationName:n.name,automationDescription:n.description,triggerMode:n.triggerMode,workflowId:s.id,workflowTitle:s.title,workflowDescription:s.description}},inputClassName:`rounded-lg`}):null]}),t[113]=n.actionMode,t[114]=n.agentId,t[115]=n.description,t[116]=n.instruction,t[117]=n.name,t[118]=n.triggerMode,t[119]=n.workflowId,t[120]=n.workflowInput,t[121]=r.form.instruction,t[122]=r.form.loadingWorkflows,t[123]=r.form.noWorkflows,t[124]=r.form.triggeredRun,t[125]=r.form.workflow,t[126]=d,t[127]=s,t[128]=p,t[129]=o,t[130]=c,t[131]=fe):fe=t[131];let q;t[132]===r.form.safety?q=t[133]:(q=(0,V.jsx)(Oe,{title:r.form.safety}),t[132]=r.form.safety,t[133]=q);let pe;t[134]!==n.afterRunMode||t[135]!==p?(pe=e=>{let t=e.target.value;p({safetyMode:t,...t!==`auto_apply`&&n.afterRunMode===`webhook`?{afterRunMode:`none`,webhookUrl:``}:{}})},t[134]=n.afterRunMode,t[135]=p,t[136]=pe):pe=t[136];let me;t[137]===r.safety.suggest_only?me=t[138]:(me=(0,V.jsx)(N,{value:`suggest_only`,children:r.safety.suggest_only}),t[137]=r.safety.suggest_only,t[138]=me);let he;t[139]===r.safety.ask_before_apply?he=t[140]:(he=(0,V.jsx)(N,{value:`ask_before_apply`,children:r.safety.ask_before_apply}),t[139]=r.safety.ask_before_apply,t[140]=he);let J;t[141]===r.safety.auto_apply?J=t[142]:(J=(0,V.jsx)(N,{value:`auto_apply`,children:r.safety.auto_apply}),t[141]=r.safety.auto_apply,t[142]=J);let Y;t[143]!==n.safetyMode||t[144]!==pe||t[145]!==me||t[146]!==he||t[147]!==J?(Y=(0,V.jsxs)(D,{className:Q,value:n.safetyMode,onChange:pe,children:[me,he,J]}),t[143]=n.safetyMode,t[144]=pe,t[145]=me,t[146]=he,t[147]=J,t[148]=Y):Y=t[148];let ge=n.safetyMode===`suggest_only`?r.safety.suggestOnlyDescription:n.safetyMode===`ask_before_apply`?r.safety.askBeforeApplyDescription:r.safety.autoApplyDescription,_e;t[149]===ge?_e=t[150]:(_e=(0,V.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:ge}),t[149]=ge,t[150]=_e);let X;t[151]!==r.form.safety||t[152]!==Y||t[153]!==_e?(X=(0,V.jsxs)($,{label:r.form.safety,children:[Y,_e]}),t[151]=r.form.safety,t[152]=Y,t[153]=_e,t[154]=X):X=t[154];let ve;t[155]===r.form.afterRun?ve=t[156]:(ve=(0,V.jsx)(Oe,{title:r.form.afterRun}),t[155]=r.form.afterRun,t[156]=ve);let ye;t[157]===p?ye=t[158]:(ye=e=>p({afterRunMode:e.target.value}),t[157]=p,t[158]=ye);let be;t[159]===r.afterRun.none?be=t[160]:(be=(0,V.jsx)(N,{value:`none`,children:r.afterRun.none}),t[159]=r.afterRun.none,t[160]=be);let xe;t[161]===r.afterRun.saveToSession?xe=t[162]:(xe=(0,V.jsx)(N,{value:`saveToSession`,children:r.afterRun.saveToSession}),t[161]=r.afterRun.saveToSession,t[162]=xe);let Z=n.safetyMode!==`auto_apply`,Se;t[163]!==r.afterRun.webhook||t[164]!==Z?(Se=(0,V.jsx)(N,{value:`webhook`,disabled:Z,children:r.afterRun.webhook}),t[163]=r.afterRun.webhook,t[164]=Z,t[165]=Se):Se=t[165];let Ce;t[166]!==n.afterRunMode||t[167]!==ye||t[168]!==be||t[169]!==xe||t[170]!==Se?(Ce=(0,V.jsxs)(D,{className:Q,value:n.afterRunMode,onChange:ye,children:[be,xe,Se]}),t[166]=n.afterRunMode,t[167]=ye,t[168]=be,t[169]=xe,t[170]=Se,t[171]=Ce):Ce=t[171];let we;t[172]!==n.afterRunMode||t[173]!==n.webhookUrl||t[174]!==r.form.webhookUrl||t[175]!==p?(we=n.afterRunMode===`webhook`?(0,V.jsx)($,{label:r.form.webhookUrl,children:(0,V.jsx)(`input`,{className:Q,value:n.webhookUrl,onChange:e=>p({webhookUrl:e.target.value})})}):null,t[172]=n.afterRunMode,t[173]=n.webhookUrl,t[174]=r.form.webhookUrl,t[175]=p,t[176]=we):we=t[176];let Te;t[177]===r.form.reliability?Te=t[178]:(Te=(0,V.jsx)(Oe,{title:r.form.reliability}),t[177]=r.form.reliability,t[178]=Te);let ke;t[179]===p?ke=t[180]:(ke=e=>p({timeoutSeconds:e.target.value}),t[179]=p,t[180]=ke);let Ae;t[181]!==n.timeoutSeconds||t[182]!==ke?(Ae=(0,V.jsx)(`input`,{className:Q,inputMode:`numeric`,value:n.timeoutSeconds,onChange:ke}),t[181]=n.timeoutSeconds,t[182]=ke,t[183]=Ae):Ae=t[183];let je;t[184]!==r.form.timeoutSeconds||t[185]!==Ae?(je=(0,V.jsx)($,{label:r.form.timeoutSeconds,children:Ae}),t[184]=r.form.timeoutSeconds,t[185]=Ae,t[186]=je):je=t[186];let Me;t[187]===p?Me=t[188]:(Me=e=>p({disableAfterFailures:e.target.value}),t[187]=p,t[188]=Me);let Ne;t[189]!==n.disableAfterFailures||t[190]!==Me?(Ne=(0,V.jsx)(`input`,{className:Q,inputMode:`numeric`,value:n.disableAfterFailures,onChange:Me}),t[189]=n.disableAfterFailures,t[190]=Me,t[191]=Ne):Ne=t[191];let Pe;t[192]!==r.form.disableAfterFailures||t[193]!==Ne?(Pe=(0,V.jsx)($,{label:r.form.disableAfterFailures,children:Ne}),t[192]=r.form.disableAfterFailures,t[193]=Ne,t[194]=Pe):Pe=t[194];let Fe;t[195]!==je||t[196]!==Pe?(Fe=(0,V.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[je,Pe]}),t[195]=je,t[196]=Pe,t[197]=Fe):Fe=t[197];let Ie;return t[198]!==S||t[199]!==ne||t[200]!==P||t[201]!==F||t[202]!==I||t[203]!==L||t[204]!==re||t[205]!==H||t[206]!==K||t[207]!==fe||t[208]!==q||t[209]!==X||t[210]!==ve||t[211]!==Ce||t[212]!==we||t[213]!==Te||t[214]!==v||t[215]!==Fe||t[216]!==x?(Ie=(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,V.jsxs)(`div`,{className:`grid gap-4`,children:[v,x,S,ne,P,F,I,L,re,H,K,fe,q,X,ve,Ce,we,Te,Fe]})}),t[198]=S,t[199]=ne,t[200]=P,t[201]=F,t[202]=I,t[203]=L,t[204]=re,t[205]=H,t[206]=K,t[207]=fe,t[208]=q,t[209]=X,t[210]=ve,t[211]=Ce,t[212]=we,t[213]=Te,t[214]=v,t[215]=Fe,t[216]=x,t[217]=Ie):Ie=t[217],Ie}function Ee(e){return(0,V.jsx)(N,{value:e.id,children:e.title||e.name},e.id)}function De(e){return(0,V.jsx)(N,{value:e.id,children:e.name||e.id},e.id)}var Q=`w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none focus:border-accent`;function $(e){let t=(0,z.c)(5),{label:n,children:r}=e,i;t[0]===n?i=t[1]:(i=(0,V.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,V.jsxs)(`div`,{className:`grid gap-1.5`,children:[i,r]}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function Oe(e){let t=(0,z.c)(3),{title:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,V.jsx)(_,{className:`size-4 text-fg-muted`}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,V.jsxs)(`div`,{className:`flex items-center gap-2 pt-2 text-sm font-semibold text-fg`,children:[r,n]}),t[1]=n,t[2]=i),i}export{J as AutomationsPage};
@@ -1,8 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-B5O4OIEo.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l,t as u}from"./fetch-ovkvM8KQ.js";import{r as d}from"./toast-z0toXu32.js";import{Aa as f,Ba as p,Da as m,Ds as h,Fo as g,H as _,Hs as v,Ic as y,Io as b,Jo as x,Lo as S,Mi as C,Mo as w,Oo as T,Qa as E,Wa as D,Ws as O,Xa as k,Xs as A,Zn as j,_o as M,ac as N,cc as P,ct as F,dc as I,f as L,ga as R,go as ee,ji as z,ka as B,lo as V,lt as H,mo as te,nc as U,ns as W,tc as ne,ua as G,ut as re,va as K,zs as ie}from"./index-DdqSO9R2.js";import{t as ae}from"./settings-advanced-gate-DrNNoSqE.js";import{n as oe,t as q}from"./settings-form-section-Dg6LBbcr.js";import{n as se,r as ce,t as le}from"./settings-page-layout-BX4T-OLF.js";import{c as ue,r as de,s as J}from"./typed-models-lib-Cx6XV5A2.js";import{i as fe,l as pe,s as me,u as he}from"./gateway-config-api-BB3biuD0.js";var Y=e(t(),1),X=n(),Z=r();function Q(e){let t=(0,X.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function ge(e){switch(e){case`ready`:return`bg-emerald-500`;case`not_installed`:case`checking`:return`bg-amber-500`;case`error`:return`bg-red-500`;default:return`bg-fg-subtle/60`}}function _e(e){let t=(0,X.c)(28),{value:n,onChange:r,onOpenConfig:a,options:o,m:s}=e,c;if(t[0]!==s.browserGoToConfigure||t[1]!==s.browserPickerSubtitle||t[2]!==s.browserPickerTitle||t[3]!==r||t[4]!==a||t[5]!==o||t[6]!==n){let e=o.find(e=>e.value===n)??o[0],l;t[8]===s.browserPickerTitle?l=t[9]:(l=(0,Z.jsx)(`label`,{htmlFor:`browser-backend-select`,className:`text-sm font-medium text-fg`,children:s.browserPickerTitle}),t[8]=s.browserPickerTitle,t[9]=l);let u;t[10]===s.browserPickerSubtitle?u=t[11]:(u=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:s.browserPickerSubtitle}),t[10]=s.browserPickerSubtitle,t[11]=u);let d;t[12]!==l||t[13]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[l,u]}),t[12]=l,t[13]=u,t[14]=d):d=t[14];let f;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(f=i(ue(),`min-w-0 flex-1 sm:max-w-md`),t[15]=f):f=t[15];let p;t[16]===r?p=t[17]:(p=e=>r(e.target.value),t[16]=r,t[17]=p);let m=s.browserPickerTitle,h;t[18]===o?h=t[19]:(h=o.map(ve),t[18]=o,t[19]=h);let g;t[20]!==s.browserPickerTitle||t[21]!==p||t[22]!==h||t[23]!==n?(g=(0,Z.jsx)(R,{id:`browser-backend-select`,className:f,value:n,onChange:p,"aria-label":m,children:h}),t[20]=s.browserPickerTitle,t[21]=p,t[22]=h,t[23]=n,t[24]=g):g=t[24];let _=a?(0,Z.jsxs)(`button`,{type:`button`,className:i(`inline-flex shrink-0 items-center justify-center gap-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-accent`,`transition-colors hover:border-edge-strong hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),onClick:()=>a(n),"aria-label":`${e?.name??n} — ${s.browserGoToConfigure}`,children:[(0,Z.jsx)(`span`,{children:s.browserGoToConfigure}),(0,Z.jsx)(I,{className:`size-4 shrink-0`,"aria-hidden":!0})]}):null,v;t[25]!==_||t[26]!==g?(v=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-2`,children:[g,_]}),t[25]=_,t[26]=g,t[27]=v):v=t[27],c=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d,v,e?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2.5`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e.statusLabel?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-medium text-fg-muted`,"aria-label":e.statusLabel,children:[(0,Z.jsx)(`span`,{className:i(`inline-block size-1.5 rounded-full`,ge(e.status)),"aria-hidden":!0}),e.statusLabel]}):null}),(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:e.tagline})]}):null]}),t[0]=s.browserGoToConfigure,t[1]=s.browserPickerSubtitle,t[2]=s.browserPickerTitle,t[3]=r,t[4]=a,t[5]=o,t[6]=n,t[7]=c}else c=t[7];return c}function ve(e){return(0,Z.jsx)(K,{value:e.value,children:e.name},e.value)}function ye(e){return`browser-focus-${e}`}function be(e){switch(e){case`connection`:case`extension`:case`local`:case`cloak`:case`cdp`:case`cloud`:case`runtime`:case`security`:return e;default:return null}}function xe(e){let t=(0,X.c)(89),{a:n,form:r,update:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=ye(`runtime`),t[0]=a):a=t[0];let o;t[1]===n.browserBehaviorShow?o=t[2]:(o=(0,Z.jsx)(oe,{icon:te,title:n.browserBehaviorShow}),t[1]=n.browserBehaviorShow,t[2]=o);let s;t[3]===i?s=t[4]:(s=e=>i({browserHeadless:e.target.checked}),t[3]=i,t[4]=s);let c;t[5]!==r.browserHeadless||t[6]!==s?(c=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserHeadless,onChange:s}),t[5]=r.browserHeadless,t[6]=s,t[7]=c):c=t[7];let l;t[8]===n.browserHeadlessOn?l=t[9]:(l=(0,Z.jsx)(`span`,{children:n.browserHeadlessOn}),t[8]=n.browserHeadlessOn,t[9]=l);let u;t[10]!==c||t[11]!==l?(u=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[c,l]}),t[10]=c,t[11]=l,t[12]=u):u=t[12];let d;t[13]!==n.desc.browserHeadless||t[14]!==n.label.browserHeadless||t[15]!==u?(d=(0,Z.jsx)(Q,{label:n.label.browserHeadless,description:n.desc.browserHeadless,children:u}),t[13]=n.desc.browserHeadless,t[14]=n.label.browserHeadless,t[15]=u,t[16]=d):d=t[16];let f=n.label.browserDialogPolicy,p=n.desc.browserDialogPolicy,m;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(m=ue(),t[17]=m):m=t[17];let h;t[18]===i?h=t[19]:(h=e=>i({browserDialogPolicy:e.target.value}),t[18]=i,t[19]=h);let g;t[20]===n.browserDialogPolicyMustRespond?g=t[21]:(g=(0,Z.jsx)(K,{value:`must_respond`,children:n.browserDialogPolicyMustRespond}),t[20]=n.browserDialogPolicyMustRespond,t[21]=g);let _;t[22]===n.browserDialogPolicyAutoDismiss?_=t[23]:(_=(0,Z.jsx)(K,{value:`auto_dismiss`,children:n.browserDialogPolicyAutoDismiss}),t[22]=n.browserDialogPolicyAutoDismiss,t[23]=_);let v;t[24]===n.browserDialogPolicyAutoAccept?v=t[25]:(v=(0,Z.jsx)(K,{value:`auto_accept`,children:n.browserDialogPolicyAutoAccept}),t[24]=n.browserDialogPolicyAutoAccept,t[25]=v);let y;t[26]!==r.browserDialogPolicy||t[27]!==h||t[28]!==g||t[29]!==_||t[30]!==v?(y=(0,Z.jsxs)(R,{className:m,value:r.browserDialogPolicy,onChange:h,children:[g,_,v]}),t[26]=r.browserDialogPolicy,t[27]=h,t[28]=g,t[29]=_,t[30]=v,t[31]=y):y=t[31];let b;t[32]!==n.desc.browserDialogPolicy||t[33]!==n.label.browserDialogPolicy||t[34]!==y?(b=(0,Z.jsx)(Q,{label:f,description:p,children:y}),t[32]=n.desc.browserDialogPolicy,t[33]=n.label.browserDialogPolicy,t[34]=y,t[35]=b):b=t[35];let x=n.label.browserDialogTimeout,S=n.desc.browserDialogTimeout,C;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(C=J(),t[36]=C):C=t[36];let w=r.browserDialogTimeout??``,T;t[37]===i?T=t[38]:(T=e=>{let t=e.target.value;i({browserDialogTimeout:t===``?void 0:Number.parseInt(t,10)})},t[37]=i,t[38]=T);let E;t[39]!==w||t[40]!==T?(E=(0,Z.jsx)(`input`,{type:`number`,className:C,min:1,value:w,placeholder:`300`,onChange:T}),t[39]=w,t[40]=T,t[41]=E):E=t[41];let D;t[42]!==n.desc.browserDialogTimeout||t[43]!==n.label.browserDialogTimeout||t[44]!==E?(D=(0,Z.jsx)(Q,{label:x,description:S,children:E}),t[42]=n.desc.browserDialogTimeout,t[43]=n.label.browserDialogTimeout,t[44]=E,t[45]=D):D=t[45];let O;t[46]!==b||t[47]!==D||t[48]!==d?(O=(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[d,b,D]}),t[46]=b,t[47]=D,t[48]=d,t[49]=O):O=t[49];let k;t[50]!==o||t[51]!==O?(k=(0,Z.jsx)(`div`,{id:a,className:`scroll-mt-24`,children:(0,Z.jsxs)(q,{children:[o,O]})}),t[50]=o,t[51]=O,t[52]=k):k=t[52];let A;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(A=ye(`security`),t[53]=A):A=t[53];let j;t[54]===n.browserSecurityShow?j=t[55]:(j=(0,Z.jsx)(oe,{icon:M,title:n.browserSecurityShow}),t[54]=n.browserSecurityShow,t[55]=j);let N;t[56]===i?N=t[57]:(N=e=>i({browserAllowPrivateUrls:e.target.checked}),t[56]=i,t[57]=N);let P;t[58]!==r.browserAllowPrivateUrls||t[59]!==N?(P=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserAllowPrivateUrls,onChange:N}),t[58]=r.browserAllowPrivateUrls,t[59]=N,t[60]=P):P=t[60];let F;t[61]===n.browserAllowPrivateOn?F=t[62]:(F=(0,Z.jsx)(`span`,{children:n.browserAllowPrivateOn}),t[61]=n.browserAllowPrivateOn,t[62]=F);let I;t[63]!==P||t[64]!==F?(I=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[P,F]}),t[63]=P,t[64]=F,t[65]=I):I=t[65];let L;t[66]!==n.desc.browserAllowPrivateUrls||t[67]!==n.label.browserAllowPrivateUrls||t[68]!==I?(L=(0,Z.jsx)(Q,{label:n.label.browserAllowPrivateUrls,description:n.desc.browserAllowPrivateUrls,children:I}),t[66]=n.desc.browserAllowPrivateUrls,t[67]=n.label.browserAllowPrivateUrls,t[68]=I,t[69]=L):L=t[69];let ee=n.label.browserCommandTimeout,z=n.desc.browserCommandTimeout,B;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(B=J(),t[70]=B):B=t[70];let V=r.browserCommandTimeout??``,H;t[71]===i?H=t[72]:(H=e=>{let t=e.target.value;i({browserCommandTimeout:t===``?void 0:Number.parseInt(t,10)})},t[71]=i,t[72]=H);let U;t[73]!==V||t[74]!==H?(U=(0,Z.jsx)(`input`,{type:`number`,className:B,min:5,value:V,placeholder:`30`,onChange:H}),t[73]=V,t[74]=H,t[75]=U):U=t[75];let W;t[76]!==n.desc.browserCommandTimeout||t[77]!==n.label.browserCommandTimeout||t[78]!==U?(W=(0,Z.jsx)(Q,{label:ee,description:z,children:U}),t[76]=n.desc.browserCommandTimeout,t[77]=n.label.browserCommandTimeout,t[78]=U,t[79]=W):W=t[79];let ne;t[80]!==L||t[81]!==W?(ne=(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[L,W]}),t[80]=L,t[81]=W,t[82]=ne):ne=t[82];let G;t[83]!==j||t[84]!==ne?(G=(0,Z.jsx)(`div`,{id:A,className:`scroll-mt-24`,children:(0,Z.jsxs)(q,{className:`border border-amber-500/20`,children:[j,ne]})}),t[83]=j,t[84]=ne,t[85]=G):G=t[85];let re;return t[86]!==k||t[87]!==G?(re=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[k,G]}),t[86]=k,t[87]=G,t[88]=re):re=t[88],re}function Se(e){let t=(0,X.c)(9),{language:n,label:r,className:a}=e,o;t[0]===n?o=t[1]:(o=G(n),t[0]=n,t[1]=o);let s;t[2]===a?s=t[3]:(s=i(`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,a),t[2]=a,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(ie,{className:`size-3 shrink-0`,"aria-hidden":!0}),t[4]=c):c=t[4];let l;return t[5]!==r||t[6]!==o||t[7]!==s?(l=(0,Z.jsxs)(`a`,{href:o,target:`_blank`,rel:`noreferrer`,className:s,children:[r,c]}),t[5]=r,t[6]=o,t[7]=s,t[8]=l):l=t[8],l}function Ce(e){let t=(0,X.c)(27),{title:n,description:r,recommended:a,recommendedLabel:o,icon:s,onSelect:c,selectLabel:l}=e,u=`${n} — ${l}`,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=i(`group flex w-full flex-col rounded-xl border border-edge bg-surface-panel px-3 py-3 text-left transition-colors`,`hover:border-edge-strong hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=d):d=t[0];let f;t[1]===s?f=t[2]:(f=(0,Z.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,Z.jsx)(s,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=s,t[2]=f);let p;t[3]===n?p=t[4]:(p=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=p);let m;t[5]!==a||t[6]!==o?(m=a&&o?(0,Z.jsx)(`span`,{className:`rounded-full bg-accent/15 px-2 py-0.5 text-[10px] font-medium text-accent`,children:o}):null,t[5]=a,t[6]=o,t[7]=m):m=t[7];let h;t[8]!==p||t[9]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[p,m]}),t[8]=p,t[9]=m,t[10]=h):h=t[10];let g;t[11]===r?g=t[12]:(g=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=g);let _;t[13]!==h||t[14]!==g?(_=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[h,g]}),t[13]=h,t[14]=g,t[15]=_):_=t[15];let v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(I,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=v):v=t[16];let y;t[17]!==f||t[18]!==_?(y=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[f,_,v]}),t[17]=f,t[18]=_,t[19]=y):y=t[19];let b;t[20]===l?b=t[21]:(b=(0,Z.jsx)(`span`,{className:`mt-2 text-[11px] font-medium text-accent`,children:l}),t[20]=l,t[21]=b);let x;return t[22]!==c||t[23]!==u||t[24]!==y||t[25]!==b?(x=(0,Z.jsxs)(`button`,{type:`button`,onClick:c,"aria-label":u,className:d,children:[y,b]}),t[22]=c,t[23]=u,t[24]=y,t[25]=b,t[26]=x):x=t[26],x}function we(e){let t=(0,X.c)(25),{m:n,onStart:r}=e,i=j(Te),a;t[0]!==n.browserBackendCloakBrowser||t[1]!==n.browserModeCloakTagline||t[2]!==n.browserSetupCloudDesc||t[3]!==n.browserSetupCloudTitle||t[4]!==n.browserSetupExtDesc||t[5]!==n.browserSetupExtTitle||t[6]!==n.browserSetupLocalDesc||t[7]!==n.browserSetupLocalTitle||t[8]!==i?(a=[{id:`extension`,icon:w,title:n.browserSetupExtTitle,description:n.browserSetupExtDesc,recommended:!0},{id:`cloakbrowser`,icon:ee,title:n.browserBackendCloakBrowser,description:n.browserModeCloakTagline},{id:`local`,icon:x,title:n.browserSetupLocalTitle,description:n.browserSetupLocalDesc},{id:`cloud`,icon:A,title:n.browserSetupCloudTitle,description:n.browserSetupCloudDesc}].filter(e=>pe(e.id,i)),t[0]=n.browserBackendCloakBrowser,t[1]=n.browserModeCloakTagline,t[2]=n.browserSetupCloudDesc,t[3]=n.browserSetupCloudTitle,t[4]=n.browserSetupExtDesc,t[5]=n.browserSetupExtTitle,t[6]=n.browserSetupLocalDesc,t[7]=n.browserSetupLocalTitle,t[8]=i,t[9]=a):a=t[9];let o=a,s;t[10]===n.browserSetupTitle?s=t[11]:(s=(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.browserSetupTitle}),t[10]=n.browserSetupTitle,t[11]=s);let c;t[12]===n.browserSetupSubtitle?c=t[13]:(c=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:n.browserSetupSubtitle}),t[12]=n.browserSetupSubtitle,t[13]=c);let l;t[14]!==s||t[15]!==c?(l=(0,Z.jsxs)(`div`,{children:[s,c]}),t[14]=s,t[15]=c,t[16]=l):l=t[16];let u;t[17]!==n.browserSetupRecommended||t[18]!==n.browserSetupSelect||t[19]!==o||t[20]!==r?(u=(0,Z.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.map(e=>(0,Z.jsx)(Ce,{icon:e.icon,title:e.title,description:e.description,recommended:e.recommended,recommendedLabel:n.browserSetupRecommended,selectLabel:n.browserSetupSelect,onSelect:()=>r(e.id)},e.id))}),t[17]=n.browserSetupRecommended,t[18]=n.browserSetupSelect,t[19]=o,t[20]=r,t[21]=u):u=t[21];let d;return t[22]!==l||t[23]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-base px-4 py-4`,children:[l,u]}),t[22]=l,t[23]=u,t[24]=d):d=t[24],d}function Te(e){return e.mode}function Ee(e){if(e.kind===`loading`)return`checking`;if(e.kind===`error`)return`error`;if(e.kind===`ok`)return e.data.installed?`ready`:`not_installed`}function De(e,t){if(e)return{ready:t.browserStatusReady,not_installed:t.browserStatusNotInstalled,checking:t.browserStatusChecking,unknown:t.browserStatusUnknown,error:t.browserStatusError}[e]}function Oe(e){if(e.kind!==`idle`)return e.kind===`loading`?`checking`:e.kind===`error`?`error`:e.data.connected?`ready`:(e.data.running,`not_installed`)}function ke(e,t){if(e.kind!==`idle`)return e.kind===`loading`?t.browserStatusChecking:e.kind===`error`?t.browserStatusError:e.data.connected?t.browserExtensionConnected:e.data.running?t.browserExtensionWaiting:t.browserExtensionServerOff}var Ae=[`overview`,`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],je=[`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],Me={connection:`overview`,extension:`extension`,local:`local`,cloak:`cloakbrowser`,cdp:`cdp`,cloud:`cloud`,runtime:`overview`,security:`overview`};function Ne(e){let t=(e??``).trim();return t===`behavior`?`overview`:Ae.includes(t)?t:`overview`}function Pe(e){return je.includes(e)}function Fe(e){let t=(0,X.c)(46),{icon:n,title:r,description:i,status:a,statusDetail:o,primaryAction:s,children:c,advanced:l,m:u,embedded:d,sectionTitle:f,advancedTitle:p}=e,m=d===void 0?!1:d,h;t[0]!==l||t[1]!==p?(h=l?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[p?(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:p}):null,l]}):null,t[0]=l,t[1]=p,t[2]=h):h=t[2];let g=h;if(m){let e;t[3]!==i||t[4]!==f?(e=f?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:f}),i?(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i}):null]}):null,t[3]=i,t[4]=f,t[5]=e):e=t[5];let n;t[6]!==u||t[7]!==s||t[8]!==a||t[9]!==o?(n=a||s?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[a?(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(Ie,{kind:a,detail:o,m:u})}):(0,Z.jsx)(`span`,{}),s?(0,Z.jsx)(`div`,{className:`shrink-0`,children:s}):null]}):null,t[6]=u,t[7]=s,t[8]=a,t[9]=o,t[10]=n):n=t[10];let r;t[11]===c?r=t[12]:(r=c?(0,Z.jsx)(`div`,{className:`flex flex-col gap-4`,children:c}):null,t[11]=c,t[12]=r);let l;return t[13]!==g||t[14]!==e||t[15]!==n||t[16]!==r?(l=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e,n,r,g]}),t[13]=g,t[14]=e,t[15]=n,t[16]=r,t[17]=l):l=t[17],l}let _;t[18]===n?_=t[19]:(_=(0,Z.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,Z.jsx)(n,{className:`size-4`,strokeWidth:1.75})}),t[18]=n,t[19]=_);let v;t[20]===r?v=t[21]:(v=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r}),t[20]=r,t[21]=v);let y;t[22]!==u||t[23]!==a||t[24]!==o?(y=a?(0,Z.jsx)(Ie,{kind:a,detail:o,m:u}):null,t[22]=u,t[23]=a,t[24]=o,t[25]=y):y=t[25];let b;t[26]!==v||t[27]!==y?(b=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28];let x;t[29]===i?x=t[30]:(x=(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i}),t[29]=i,t[30]=x);let S;t[31]!==b||t[32]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[b,x]}),t[31]=b,t[32]=x,t[33]=S):S=t[33];let C;t[34]===s?C=t[35]:(C=s?(0,Z.jsx)(`div`,{className:`shrink-0`,children:s}):null,t[34]=s,t[35]=C);let w;t[36]!==_||t[37]!==S||t[38]!==C?(w=(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[_,S,C]}),t[36]=_,t[37]=S,t[38]=C,t[39]=w):w=t[39];let T;t[40]===c?T=t[41]:(T=c?(0,Z.jsx)(`div`,{className:`flex flex-col gap-4`,children:c}):null,t[40]=c,t[41]=T);let E;return t[42]!==g||t[43]!==w||t[44]!==T?(E=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl border border-edge bg-surface-panel p-4`,children:[w,T,g]}),t[42]=g,t[43]=w,t[44]=T,t[45]=E):E=t[45],E}function Ie(e){let t=(0,X.c)(27),{kind:n,detail:r,m:a}=e,o,s,c,l;if(t[0]!==n||t[1]!==a.browserStatusChecking||t[2]!==a.browserStatusError||t[3]!==a.browserStatusNotInstalled||t[4]!==a.browserStatusReady||t[5]!==a.browserStatusUnknown){let{icon:e,color:r,label:u}={ready:{icon:P,color:`text-green-600 dark:text-green-400`,label:a.browserStatusReady},not_installed:{icon:E,color:`text-amber-600 dark:text-amber-400`,label:a.browserStatusNotInstalled},checking:{icon:W,color:`text-fg-muted`,label:a.browserStatusChecking},unknown:{icon:N,color:`text-fg-muted`,label:a.browserStatusUnknown},error:{icon:U,color:`text-red-600 dark:text-red-400`,label:a.browserStatusError}}[n];o=e,s=u,l=`inline-flex min-w-0 flex-col items-start gap-1`,c=i(`inline-flex shrink-0 items-center gap-1 whitespace-nowrap text-xs font-medium`,r),t[0]=n,t[1]=a.browserStatusChecking,t[2]=a.browserStatusError,t[3]=a.browserStatusNotInstalled,t[4]=a.browserStatusReady,t[5]=a.browserStatusUnknown,t[6]=o,t[7]=s,t[8]=c,t[9]=l}else o=t[6],s=t[7],c=t[8],l=t[9];let u=n===`checking`&&`animate-spin`,d;t[10]===u?d=t[11]:(d=i(`size-3.5 shrink-0`,u),t[10]=u,t[11]=d);let f;t[12]!==o||t[13]!==d?(f=(0,Z.jsx)(o,{className:d}),t[12]=o,t[13]=d,t[14]=f):f=t[14];let p;t[15]===s?p=t[16]:(p=(0,Z.jsx)(`span`,{children:s}),t[15]=s,t[16]=p);let m;t[17]!==c||t[18]!==f||t[19]!==p?(m=(0,Z.jsxs)(`span`,{className:c,children:[f,p]}),t[17]=c,t[18]=f,t[19]=p,t[20]=m):m=t[20];let h;t[21]===r?h=t[22]:(h=r?(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] leading-snug text-fg-subtle`,children:r}):null,t[21]=r,t[22]=h);let g;return t[23]!==l||t[24]!==m||t[25]!==h?(g=(0,Z.jsxs)(`span`,{className:l,children:[m,h]}),t[23]=l,t[24]=m,t[25]=h,t[26]=g):g=t[26],g}function Le(e){let t=(0,X.c)(5),{kind:n,message:r}=e,a=n===`success`?`border-green-500/30 bg-green-500/10 text-green-700 dark:text-green-300`:`border-red-500/30 bg-red-500/10 text-red-600 dark:text-red-300`,o;t[0]===a?o=t[1]:(o=i(`rounded-lg border px-3 py-2 text-xs leading-relaxed`,a),t[0]=a,t[1]=o);let s;return t[2]!==r||t[3]!==o?(s=(0,Z.jsx)(`div`,{className:o,children:r}),t[2]=r,t[3]=o,t[4]=s):s=t[4],s}var Re={instances:[],launchStatus:`idle`,launchMessage:null,testStatus:`idle`,testMessage:null,executablePath:``};function ze({m:e,cdpUrl:t,onCdpUrlChange:n,launch:r,stop:i,listInstances:a,ping:o,embedded:s=!1}){let[c,l]=(0,Y.useReducer)(re,Re),{instances:u,launchStatus:d,launchMessage:f,testStatus:p,testMessage:m,executablePath:h}=c,_=(0,Y.useCallback)(async()=>{try{l({type:`patch`,patch:{instances:await a()}})}catch{}},[a]);(0,Y.useEffect)(()=>{_();let e=setInterval(()=>void _(),8e3);return()=>clearInterval(e)},[_]);let v=(0,Y.useCallback)(async()=>{if(d!==`pending`){l({type:`patch`,patch:{launchStatus:`pending`,launchMessage:null}});try{let t=await r(h.trim()||void 0);l({type:`patch`,patch:{launchStatus:`ok`,launchMessage:e.browserCdpLaunchedAtPort.replace(`{{port}}`,String(t.port))}}),n(t.wsEndpoint),await _()}catch(e){l({type:`patch`,patch:{launchStatus:`error`,launchMessage:e instanceof Error?e.message:String(e)}})}}},[h,r,d,e.browserCdpLaunchedAtPort,n,_]),y=(0,Y.useCallback)(async e=>{await i(e),await _()},[_,i]),x=(0,Y.useCallback)(async()=>{if(t.trim()){l({type:`patch`,patch:{testStatus:`pending`,testMessage:null}});try{let n=await o(t.trim());n.reachable?l({type:`patch`,patch:{testStatus:`ok`,testMessage:e.browserCdpReachable.replace(`{{browser}}`,n.browser??`—`)}}):l({type:`patch`,patch:{testStatus:`error`,testMessage:e.browserCdpUnreachable.replace(`{{error}}`,n.error??`—`)}})}catch(t){l({type:`patch`,patch:{testStatus:`error`,testMessage:e.browserCdpUnreachable.replace(`{{error}}`,t instanceof Error?t.message:String(t))}})}}},[t,e.browserCdpReachable,e.browserCdpUnreachable,o]);return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Z.jsxs)(Fe,{icon:b,title:e.browserCdpLaunchLocal,description:e.browserCdpLaunchLocalDesc,m:e,embedded:s,sectionTitle:s?e.browserCdpLaunchLocal:void 0,primaryAction:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:d===`pending`,onClick:()=>void v(),children:[d===`pending`?(0,Z.jsx)(W,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(b,{className:`size-3.5`}),d===`pending`?e.browserCdpLaunching:e.browserCdpLaunchLocal]}),children:[f?(0,Z.jsx)(Le,{kind:d===`error`?`error`:`success`,message:f}):null,(0,Z.jsx)(Q,{label:e.browserCdpChromePath,description:e.browserCdpChromePathDesc,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:h,placeholder:`/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`,onChange:e=>l({type:`patch`,patch:{executablePath:e.target.value}}),autoComplete:`off`})}),u.length>0?(0,Z.jsx)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge bg-surface-base p-3 text-xs`,children:u.map(t=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsxs)(`span`,{className:`font-mono text-fg`,children:[`port `,t.port,` · pid `,t.pid]}),(0,Z.jsx)(`span`,{className:`truncate text-fg-subtle`,children:t.wsEndpoint})]}),(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs font-medium text-fg hover:bg-surface-raised`,onClick:()=>void y(t.port),children:[(0,Z.jsx)(V,{className:`size-3`}),e.browserCdpStopLocal]})]},t.port))}):null]}),(0,Z.jsxs)(Fe,{icon:D,title:e.label.browserCdpUrl,description:e.desc.browserCdpUrl,m:e,embedded:s,sectionTitle:s?e.label.browserCdpUrl:void 0,primaryAction:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:!t.trim()||p===`pending`,onClick:()=>void x(),children:[p===`pending`?(0,Z.jsx)(W,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(g,{className:`size-3.5`}),p===`pending`?e.browserCdpTesting:e.browserCdpTestConnection]}),children:[(0,Z.jsx)(`input`,{type:`text`,className:J(),value:t,placeholder:`ws://127.0.0.1:9222`,onChange:e=>n(e.target.value),autoComplete:`off`}),(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:e.browserCdpLoopbackOnly}),m?(0,Z.jsx)(Le,{kind:p===`error`?`error`:`success`,message:m}):null]})]})}function Be(e,t){let n=t.phase;if(!n)return e.browserInstallPhaseStarting;if(n===`downloading`)return t.percent==null?e.browserInstallPhaseDownloading:e.browserInstallPhaseDownloadingPercent.replace(`{{percent}}`,String(t.percent));switch(n){case`starting`:return e.browserInstallPhaseStarting;case`verifying`:return e.browserInstallPhaseVerifying;case`extracting`:return e.browserInstallPhaseExtracting;case`running`:return t.message??e.browserInstallPhaseRunning;case`ready`:return e.browserInstallPhaseReady;default:return t.message??e.browserInstallPhaseRunning}}function Ve(e){let t=(0,X.c)(32),{m:n,progress:r,showLogs:i,onCancel:a,cancelling:o}=e,s=i===void 0?!1:i,c=o===void 0?!1:o;if(!r.phase)return null;let l;t[0]!==n||t[1]!==r?(l=Be(n,r),t[0]=n,t[1]=r,t[2]=l):l=t[2];let u=l,d=r.percent==null?(r.phase===`extracting`||r.phase===`verifying`||r.phase===`running`||r.phase,null):Math.min(100,Math.max(0,r.percent)),f;t[3]===u?f=t[4]:(f=(0,Z.jsx)(`span`,{className:`text-fg`,children:u}),t[3]=u,t[4]=f);let p;t[5]===d?p=t[6]:(p=d==null?null:(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[d,`%`]}),t[5]=d,t[6]=p);let m;t[7]!==c||t[8]!==n||t[9]!==a?(m=a?(0,Z.jsx)(`button`,{type:`button`,className:`rounded-md border border-edge px-2 py-0.5 text-[11px] font-medium text-fg-muted hover:bg-surface-raised hover:text-fg disabled:cursor-not-allowed disabled:opacity-60`,disabled:c,onClick:()=>void a(),children:c?n.browserInstallCancelling:n.browserInstallCancel}):null,t[7]=c,t[8]=n,t[9]=a,t[10]=m):m=t[10];let h;t[11]!==p||t[12]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[p,m]}),t[11]=p,t[12]=m,t[13]=h):h=t[13];let g;t[14]!==f||t[15]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs text-fg-muted`,children:[f,h]}),t[14]=f,t[15]=h,t[16]=g):g=t[16];let _;t[17]===d?_=t[18]:(_=(0,Z.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-raised`,children:d==null?(0,Z.jsx)(`div`,{className:`h-full w-1/3 animate-pulse rounded-full bg-accent/70`}):(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-300 ease-out`,style:{width:`${d}%`}})}),t[17]=d,t[18]=_);let v;t[19]!==r.lines||t[20]!==s?(v=s&&r.lines.length>0?(0,Z.jsx)(`div`,{className:`max-h-28 overflow-y-auto rounded-md border border-edge bg-surface-panel px-2 py-1.5 font-mono text-[10px] leading-relaxed text-fg-muted`,children:r.lines.map(He)}):null,t[19]=r.lines,t[20]=s,t[21]=v):v=t[21];let y;t[22]!==r.message||t[23]!==r.percent||t[24]!==r.phase||t[25]!==s?(y=!s&&r.phase===`downloading`&&r.message&&r.percent==null?(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:r.message}):null,t[22]=r.message,t[23]=r.percent,t[24]=r.phase,t[25]=s,t[26]=y):y=t[26];let b;return t[27]!==v||t[28]!==y||t[29]!==g||t[30]!==_?(b=(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[g,_,v,y]}),t[27]=v,t[28]=y,t[29]=g,t[30]=_,t[31]=b):b=t[31],b}function He(e){return(0,Z.jsx)(`div`,{className:`truncate`,children:e},e)}var Ue={confirmOpen:!1,installStatus:`idle`,installMessage:null,openStatus:`idle`,openMessage:null,runtime:null};function We({m:e,doctor:t,refetch:n,applyDoctor:r,installStream:i,fetchRuntimeStatus:a,launchCloak:o,form:s,onChange:c,embedded:l=!1}){let[u,d]=(0,Y.useReducer)(re,Ue),{confirmOpen:f,installStatus:p,installMessage:m,openStatus:h,openMessage:g,runtime:_}=u,{progress:y,running:x,cancelling:S,run:C,reset:w,cancel:E}=i,D=t.kind===`ok`?t.data:null,O=D?.installed===!0,k=p===`installing`||x,A=(0,Y.useCallback)(async()=>{if(O)try{d({type:`patch`,patch:{runtime:await a()}})}catch{}},[a,O]);(0,Y.useEffect)(()=>{if(!O){d({type:`patch`,patch:{runtime:null}});return}A();let e=setInterval(()=>void A(),8e3);return()=>clearInterval(e)},[O,A]);let j=(0,Y.useCallback)(async()=>{d({type:`patch`,patch:{confirmOpen:!1,installStatus:`installing`,installMessage:null}}),w();let t=await C({body:{cacheDir:s.cacheDir.trim()||void 0,binaryPath:s.binaryPath.trim()||void 0},fallbackError:e.browserCloakInstallFailed});if(!t.ok){if(t.error===`busy`){d({type:`patch`,patch:{installStatus:`installing`}});return}if(t.error===`cancelled`){d({type:`patch`,patch:{installStatus:`idle`,installMessage:null}}),w();return}d({type:`patch`,patch:{installStatus:`failed`,installMessage:t.errorMessage??e.browserCloakInstallFailed}});return}t.payload&&r?.(t.payload),d({type:`patch`,patch:{installStatus:`installed`,installMessage:t.payload?.binaryPath?`${e.browserCloakInstalled}: ${t.payload.binaryPath}`:e.browserCloakInstalled}}),await n({cacheDir:s.cacheDir,binaryPath:s.binaryPath}),await A()},[r,s.binaryPath,s.cacheDir,e.browserCloakInstallFailed,e.browserCloakInstalled,n,A,w,C]),M=(0,Y.useCallback)(async()=>{if(h!==`pending`){d({type:`patch`,patch:{openStatus:`pending`,openMessage:null}});try{let t=await o();d({type:`patch`,patch:{openStatus:`ok`,openMessage:t.reused?e.browserCloakOpenReused.replace(`{{port}}`,String(t.port)):e.browserCloakOpenLaunched.replace(`{{port}}`,String(t.port)),runtime:t}})}catch(e){d({type:`patch`,patch:{openStatus:`error`,openMessage:e instanceof Error?e.message:String(e)}})}}},[o,e.browserCloakOpenLaunched,e.browserCloakOpenReused,h]),N=t.kind===`loading`?`checking`:t.kind===`error`?`error`:O?`ready`:`not_installed`,F=O&&D?.version?`v${D.version} (${D.platform})`:void 0;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Fe,{icon:ee,title:e.browserCloakGuideTitle,description:e.browserCloakGuideDesc,status:N,statusDetail:F,m:e,embedded:l,primaryAction:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[O?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:h===`pending`,onClick:()=>void M(),children:[h===`pending`?(0,Z.jsx)(W,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(b,{className:`size-3.5`}),h===`pending`?e.browserCloakOpening:e.browserCloakOpen]}):null,(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:k,onClick:()=>d({type:`patch`,patch:{confirmOpen:!0}}),children:[k?(0,Z.jsx)(W,{className:`size-3.5 animate-spin`}):O?(0,Z.jsx)(T,{className:`size-3.5`}):p===`installed`?(0,Z.jsx)(P,{className:`size-3.5 text-green-500`}):(0,Z.jsx)(v,{className:`size-3.5`}),k?e.browserCloakInstalling:O?e.browserReinstall:e.browserCloakDownload]})]}),children:[x?(0,Z.jsx)(Ve,{m:e,progress:y,cancelling:S,onCancel:()=>void E()}):null,m?(0,Z.jsx)(Le,{kind:p===`failed`?`error`:`success`,message:m}):null,g?(0,Z.jsx)(Le,{kind:h===`error`?`error`:`success`,message:g}):null,O&&_?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge bg-surface-base p-3 text-xs`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:_.running?e.browserCloakRuntimeRunning.replace(`{{port}}`,String(_.port)):e.browserCloakRuntimeOff})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Z.jsx)(`span`,{className:`text-fg-subtle`,children:e.browserCloakProfileLabel}),(0,Z.jsx)(`span`,{className:`break-all font-mono text-[11px] text-fg-muted`,children:_.userDataDir})]}),(0,Z.jsx)(`p`,{className:`text-[11px] leading-relaxed text-fg-subtle`,children:e.browserCloakProfileAgentHint}),_.temporaryProfile?(0,Z.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:e.browserCloakTemporaryProfileHint}):null]}):null,(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(Q,{label:e.label.browserCloakKeepOpen,description:e.desc.browserCloakKeepOpen,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:s.keepOpen,onChange:e=>c({keepOpen:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserCloakKeepOpenOn})]})}),(0,Z.jsx)(Q,{label:e.label.browserCloakTemporaryProfile,description:e.desc.browserCloakTemporaryProfile,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:s.temporaryProfile,onChange:e=>c({temporaryProfile:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserCloakTemporaryProfileOn})]})}),(0,Z.jsx)(Q,{label:e.label.browserHumanize,description:e.desc.browserHumanize,children:(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:s.humanize,onChange:e=>c({humanize:e.target.checked})}),(0,Z.jsx)(`span`,{children:e.browserHumanizeOn})]})}),(0,Z.jsx)(Q,{label:e.label.browserHumanPreset,description:e.desc.browserHumanPreset,children:(0,Z.jsxs)(R,{className:ue(),value:s.humanPreset,onChange:e=>c({humanPreset:e.target.value}),children:[(0,Z.jsx)(K,{value:`careful`,children:e.browserHumanPresetCareful}),(0,Z.jsx)(K,{value:`default`,children:e.browserHumanPresetDefault})]})})]})]}),(0,Z.jsxs)(q,{className:`mt-4 border border-edge-subtle`,children:[(0,Z.jsx)(oe,{icon:ee,title:e.browserCloakAdvancedShow}),(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsxs)(Q,{label:e.label.browserCloakCacheDir,description:e.desc.browserCloakCacheDir,children:[(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.cacheDir,placeholder:`~/.xopc/bin/cloakbrowser`,onChange:e=>c({cacheDir:e.target.value}),autoComplete:`off`}),(0,Z.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:e.browserCacheDirHomeOnly})]}),(0,Z.jsxs)(Q,{label:e.label.browserCloakBinaryPath,description:e.desc.browserCloakBinaryPath,children:[(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.binaryPath,placeholder:`~/.xopc/bin/cloakbrowser/chromium-v.../Chromium.app/Contents/MacOS/Chromium`,onChange:e=>c({binaryPath:e.target.value}),autoComplete:`off`}),s.binaryPath.trim()?(0,Z.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:e.browserBinaryPathWarning}):null]}),(0,Z.jsx)(Q,{label:e.label.browserCloakTimezone,description:e.desc.browserCloakTimezone,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.timezone,placeholder:`America/New_York`,onChange:e=>c({timezone:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserCloakLocale,description:e.desc.browserCloakLocale,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.locale,placeholder:`en-US`,onChange:e=>c({locale:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserCloakWebrtcIp,description:e.desc.browserCloakWebrtcIp,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.webrtcIp,placeholder:`203.0.113.10`,onChange:e=>c({webrtcIp:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserCloakFingerprintPlatform,description:e.desc.browserCloakFingerprintPlatform,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:s.fingerprintPlatform,placeholder:`macos`,onChange:e=>c({fingerprintPlatform:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(`div`,{className:`sm:col-span-2`,children:(0,Z.jsx)(Q,{label:e.label.browserCloakExtraArgs,description:e.desc.browserCloakExtraArgs,children:(0,Z.jsx)(`textarea`,{className:Ge(),value:s.extraArgs,placeholder:`--disable-dev-shm-usage`,rows:3,onChange:e=>c({extraArgs:e.target.value})})})})]})]}),(0,Z.jsx)(L,{open:f,title:e.browserConfirmDownloadTitle,description:Ke(e,D),confirmLabel:e.browserConfirmDownloadConfirm,cancelLabel:e.browserConfirmDownloadCancel,onConfirm:()=>void j(),onCancel:()=>d({type:`patch`,patch:{confirmOpen:!1}})})]})}function Ge(){return`${J()} min-h-[4.5rem] resize-y font-mono text-xs`}function Ke(e,t){if(!t)return e.browserConfirmDownloadBody;let n=[e.browserConfirmDownloadBody.replace(`{{version}}`,t.version??`—`).replace(`{{platform}}`,t.platform).replace(`{{url}}`,t.downloadUrl||`—`)];return t.expectedSha256?n.push(`SHA-256: ${t.expectedSha256.slice(0,16)}…`):n.push(e.browserCloakSha256Skipped),n.join(`
2
- `)}function qe({m:e,form:t,onChange:n,testCloud:r,embedded:i=!1}){let[s,c]=(0,Y.useState)(`idle`),[l,u]=(0,Y.useState)(null),d=t.provider===`local`?`browserbase`:t.provider,f=a(o(e=>e.language)).providersSettings,p=m({show:f.show,hide:f.hide,copy:f.copy,copied:f.copied}),h=(0,Y.useCallback)(()=>fe().then(e=>e.apiKey??null),[]),_=(0,Y.useCallback)(async()=>{c(`pending`),u(null);try{let n=await r(d,t.apiKey);n.reachable?(c(`ok`),u(e.browserCloudTestOk)):(c(`error`),u(e.browserCloudTestFailed.replace(`{{error}}`,n.error??`—`)))}catch(t){c(`error`),u(e.browserCloudTestFailed.replace(`{{error}}`,t instanceof Error?t.message:String(t)))}},[t.apiKey,e.browserCloudTestFailed,e.browserCloudTestOk,d,r]);return(0,Z.jsxs)(Fe,{icon:A,title:e.label.browserCloudProvider,description:e.desc.browserCloudProvider,m:e,embedded:i,primaryAction:(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:s===`pending`,onClick:()=>void _(),children:[s===`pending`?(0,Z.jsx)(W,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(g,{className:`size-3.5`}),e.browserCloudTestConnection]}),children:[(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(Q,{label:e.label.browserCloudProvider,description:e.desc.browserCloudProvider,children:(0,Z.jsxs)(R,{className:ue(),value:d,onChange:e=>n({provider:e.target.value}),children:[(0,Z.jsx)(K,{value:`browserbase`,children:e.browserCloudProviderBrowserbase}),(0,Z.jsx)(K,{value:`browser-use`,children:e.browserCloudProviderBrowserUse})]})}),(0,Z.jsx)(Q,{label:e.label.browserCloudApiKey,description:e.desc.browserCloudApiKey,children:(0,Z.jsx)(B,{value:t.apiKey,onChange:e=>n({apiKey:e}),placeholder:d===`browserbase`?`BROWSERBASE_API_KEY`:`BROWSER_USE_API_KEY`,labels:p,reveal:h,loadFailedLabel:`Failed to load key`})}),d===`browserbase`?(0,Z.jsx)(Q,{label:e.label.browserCloudProjectId,description:e.desc.browserCloudProjectId,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:t.projectId,placeholder:`BROWSERBASE_PROJECT_ID`,onChange:e=>n({projectId:e.target.value}),autoComplete:`off`})}):null,(0,Z.jsx)(Q,{label:e.label.browserCloudRegion,description:e.desc.browserCloudRegion,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:t.region,placeholder:`us-west-2`,onChange:e=>n({region:e.target.value}),autoComplete:`off`})})]}),l?(0,Z.jsx)(Le,{kind:s===`error`?`error`:`success`,message:l}):null]})}function Je(e){let t=(0,X.c)(48),{m:n,installed:r,extensionDir:a,connected:o,busy:s,onOpenChrome:c,onCopyPath:l,onRevealFolder:u,pathBusy:d,folderBusy:f}=e,p;t[0]!==r||t[1]!==n.browserExtensionInstallStep1?(p={id:`install`,label:n.browserExtensionInstallStep1,done:r},t[0]=r,t[1]=n.browserExtensionInstallStep1,t[2]=p):p=t[2];let m=!!a&&o,h;t[3]!==s||t[4]!==a||t[5]!==f||t[6]!==n.browserExtensionCopyPath||t[7]!==n.browserExtensionInstallStep2FolderLabel||t[8]!==n.browserExtensionInstalling||t[9]!==n.browserExtensionOpenChrome||t[10]!==n.browserExtensionRevealFolder||t[11]!==l||t[12]!==c||t[13]!==u||t[14]!==d?(h=a?(0,Z.jsxs)(`div`,{className:`mt-2 rounded-md border border-edge bg-surface-raised px-2.5 py-2`,children:[(0,Z.jsx)(`p`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.browserExtensionInstallStep2FolderLabel}),(0,Z.jsx)(`p`,{className:`mt-1 break-all font-mono text-[11px] text-fg`,children:a}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-3`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:s,onClick:c,children:n.browserExtensionOpenChrome}),(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:s,onClick:l,title:a,children:d?n.browserExtensionInstalling:n.browserExtensionCopyPath}),(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:s,onClick:u,title:a,children:f?n.browserExtensionInstalling:n.browserExtensionRevealFolder})]})]}):null,t[3]=s,t[4]=a,t[5]=f,t[6]=n.browserExtensionCopyPath,t[7]=n.browserExtensionInstallStep2FolderLabel,t[8]=n.browserExtensionInstalling,t[9]=n.browserExtensionOpenChrome,t[10]=n.browserExtensionRevealFolder,t[11]=l,t[12]=c,t[13]=u,t[14]=d,t[15]=h):h=t[15];let g;t[16]!==n.browserExtensionInstallStep2||t[17]!==m||t[18]!==h?(g={id:`load`,label:n.browserExtensionInstallStep2,done:m,detail:h},t[16]=n.browserExtensionInstallStep2,t[17]=m,t[18]=h,t[19]=g):g=t[19];let _;t[20]!==o||t[21]!==n.browserExtensionInstallStep3?(_={id:`connect`,label:n.browserExtensionInstallStep3,done:o},t[20]=o,t[21]=n.browserExtensionInstallStep3,t[22]=_):_=t[22];let v;t[23]!==p||t[24]!==g||t[25]!==_?(v=[p,g,_],t[23]=p,t[24]=g,t[25]=_,t[26]=v):v=t[26];let y=v,b;t[27]===y?b=t[28]:(b=y.filter(Ye),t[27]=y,t[28]=b);let x=b.length,S=n.browserExtensionInstallGuideTitle,C;t[29]===n.browserExtensionInstallGuideTitle?C=t[30]:(C=(0,Z.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:n.browserExtensionInstallGuideTitle}),t[29]=n.browserExtensionInstallGuideTitle,t[30]=C);let w;t[31]!==x||t[32]!==n.browserExtensionChecklistProgress||t[33]!==y.length?(w=n.browserExtensionChecklistProgress.replace(`{{done}}`,String(x)).replace(`{{total}}`,String(y.length)),t[31]=x,t[32]=n.browserExtensionChecklistProgress,t[33]=y.length,t[34]=w):w=t[34];let T;t[35]===w?T=t[36]:(T=(0,Z.jsx)(`span`,{className:`ml-auto text-xs font-normal text-fg-muted`,children:w}),t[35]=w,t[36]=T);let E;t[37]!==T||t[38]!==C?(E=(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[C,T]}),t[37]=T,t[38]=C,t[39]=E):E=t[39];let D;t[40]!==n.browserExtensionChecklistDone||t[41]!==n.browserExtensionChecklistPending||t[42]!==y?(D=(0,Z.jsx)(`ol`,{className:`flex flex-col gap-3`,children:y.map((e,t)=>(0,Z.jsxs)(`li`,{className:`flex gap-2.5`,children:[(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,"aria-hidden":!0,children:e.done?(0,Z.jsx)(P,{className:`size-4 text-emerald-500`,strokeWidth:2}):(0,Z.jsx)(ne,{className:`size-4 text-fg-subtle`,strokeWidth:1.75})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`p`,{className:i(`text-[11px] leading-relaxed`,e.done?`text-fg-muted line-through decoration-fg-subtle/60`:`text-fg`),children:[(0,Z.jsxs)(`span`,{className:`sr-only`,children:[e.done?n.browserExtensionChecklistDone:n.browserExtensionChecklistPending,` `]}),t+1,`. `,e.label]}),e.detail]})]},e.id))}),t[40]=n.browserExtensionChecklistDone,t[41]=n.browserExtensionChecklistPending,t[42]=y,t[43]=D):D=t[43];let O;return t[44]!==n.browserExtensionInstallGuideTitle||t[45]!==E||t[46]!==D?(O=(0,Z.jsxs)(`div`,{"aria-label":S,className:`rounded-xl border border-edge bg-surface-base px-3 py-3`,children:[E,D]}),t[44]=n.browserExtensionInstallGuideTitle,t[45]=E,t[46]=D,t[47]=O):O=t[47],O}function Ye(e){return e.done}var Xe=19820,Ze=3e4;function Qe({m:e,probe:t,artifacts:n,onChange:r,startBridge:i,stopBridge:a,disconnectExtension:o,installArtifacts:s,refetchArtifacts:c,openExtensionChrome:l,revealExtensionFolder:u,form:p,embedded:m=!1}){let[h,_]=(0,Y.useState)(null),[y,x]=(0,Y.useState)(null),[C,T]=(0,Y.useState)(null),E=p.port??Xe,D=p.host||`127.0.0.1`,O=`ws://${D}:${E}/browser-ext`,A=t.kind===`ok`&&t.data.running,j=t.kind===`ok`&&t.data.connected,M=t.kind===`ok`&&t.data.bridgeHeld===!0,N=t.kind===`ok`&&t.data.portConflict===!0,P=A||M,F=n.kind===`ok`?n.data:t.kind===`ok`?t.data.artifacts:void 0,I=F?.installed===!0,L=F?.extensionDir,R=F?.needsChromeReload===!0,ee=t.kind===`ok`?j?{icon:S,color:`text-green-500`,label:e.browserExtensionConnected}:A?{icon:g,color:`text-amber-500`,label:e.browserExtensionWaiting}:{icon:k,color:`text-fg-muted`,label:e.browserExtensionServerOff}:{icon:k,color:`text-fg-muted`,label:`…`},z=ee.icon,B=(0,Y.useCallback)(async()=>{if(!h){_(`start`),x(null);try{await i({host:D,port:E})}catch(e){x(e instanceof Error?e.message:String(e))}finally{_(null)}}},[h,D,E,i]),H=(0,Y.useCallback)(async()=>{if(!h){_(`stop`),x(null);try{await a()}catch(e){x(e instanceof Error?e.message:String(e))}finally{_(null)}}},[h,a]),te=(0,Y.useCallback)(async()=>{if(!h){_(`disconnect`),x(null);try{await o()}catch(e){x(e instanceof Error?e.message:String(e))}finally{_(null)}}},[h,o]),U=(0,Y.useCallback)(async()=>{if(!h){_(`install`),x(null),T(null);try{let t=await s({force:I});t?.extensionDir?T(`${e.browserExtensionInstalled}: ${t.extensionDir}`):T(e.browserExtensionInstalled),await c()}catch(e){x(e instanceof Error?e.message:String(e))}finally{_(null)}}},[h,s,I,e.browserExtensionInstalled,c]),ne=(0,Y.useCallback)(async()=>{if(!h){_(`open`),x(null);try{await l()}catch(e){x(e instanceof Error?e.message:String(e))}finally{_(null)}}},[h,l]),G=(0,Y.useCallback)(async()=>{if(!(!L||h)){_(`path`),x(null),T(null);try{await f(L)?d({type:`success`,title:e.browserExtensionPathCopied}):T(e.browserExtensionPathCopyFailed)}catch(e){x(e instanceof Error?e.message:String(e))}finally{_(null)}}},[h,L,e.browserExtensionPathCopied,e.browserExtensionPathCopyFailed]),re=(0,Y.useCallback)(async()=>{if(!(!L||h)){_(`folder`),x(null),T(null);try{await u(),d({type:`success`,title:e.browserExtensionFolderOpened})}catch(e){x(e instanceof Error?e.message:String(e))}finally{_(null)}}},[h,L,e.browserExtensionFolderOpened,u]),K=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:h!==null,onClick:()=>void U(),children:[h===`install`?(0,Z.jsx)(W,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(v,{className:`size-3.5`}),h===`install`?e.browserExtensionInstalling:e.browserExtensionInstall]}),P?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:h!==null,onClick:()=>void H(),children:[h===`stop`?(0,Z.jsx)(W,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(V,{className:`size-3.5`}),e.browserExtensionStopBridge]}):(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:h!==null,onClick:()=>void B(),children:[h===`start`?(0,Z.jsx)(W,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(b,{className:`size-3.5`}),h===`start`?e.browserExtensionStarting:e.browserExtensionStartBridge]}),j?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:h!==null,onClick:()=>void te(),children:[h===`disconnect`?(0,Z.jsx)(W,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(k,{className:`size-3.5`}),e.browserExtensionDisconnect]}):null]});return(0,Z.jsx)(Fe,{icon:w,title:e.browserBackendExtension,description:e.browserExtensionDownloadHint,m:e,embedded:m,primaryAction:K,advancedTitle:e.browserAdvancedShow,advanced:(0,Z.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,Z.jsx)(Q,{label:e.label.browserExtensionPort,description:e.desc.browserExtensionPort,children:(0,Z.jsx)(`input`,{type:`number`,className:J(),min:1024,max:65535,value:p.port??``,placeholder:String(Xe),onChange:e=>{let t=e.target.value;r({port:t===``?void 0:Number.parseInt(t,10)})}})}),(0,Z.jsx)(Q,{label:e.label.browserExtensionHost,description:e.desc.browserExtensionHost,children:(0,Z.jsx)(`input`,{type:`text`,className:J(),value:p.host,placeholder:`127.0.0.1`,onChange:e=>r({host:e.target.value}),autoComplete:`off`})}),(0,Z.jsx)(Q,{label:e.label.browserExtensionConnectionTimeout,description:e.desc.browserExtensionConnectionTimeout,children:(0,Z.jsx)(`input`,{type:`number`,className:J(),min:1,step:1,value:p.connectionTimeoutMs==null?``:Math.round(p.connectionTimeoutMs/1e3),placeholder:String(Ze/1e3),onChange:e=>{let t=e.target.value;r({connectionTimeoutMs:t===``?void 0:Math.max(1,Number.parseInt(t,10))*1e3})}})})]}),children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:O}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs ${ee.color}`,children:[(0,Z.jsx)(z,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:ee.label})]})]}),(0,Z.jsx)(Je,{m:e,installed:I,extensionDir:L,connected:j,busy:h!==null,pathBusy:h===`path`,folderBusy:h===`folder`,onOpenChrome:()=>void ne(),onCopyPath:()=>void G(),onRevealFolder:()=>void re()}),R?(0,Z.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-relaxed text-amber-800 dark:text-amber-200`,children:e.browserExtensionNeedsChromeReload}):null,N?(0,Z.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-relaxed text-amber-800 dark:text-amber-200`,children:e.browserExtensionPortConflict.replace(`{{port}}`,String(E))}):null,C?(0,Z.jsx)(Le,{kind:`success`,message:C}):null,y?(0,Z.jsx)(Le,{kind:`error`,message:y}):null]})})}function $e(e){let t=(0,X.c)(41),{m:n,doctor:r,refetch:i,applyDoctor:a,installStream:o,embedded:s}=e,c=s===void 0?!1:s,[l,u]=(0,Y.useState)(`idle`),[d,f]=(0,Y.useState)(null),{progress:p,running:m,cancelling:h,run:g,reset:_,cancel:y}=o,b;t[0]!==a||t[1]!==n.browserPlaywrightInstallFailed||t[2]!==n.browserPlaywrightInstalled||t[3]!==i||t[4]!==_||t[5]!==g?(b=async()=>{u(`installing`),f(null),_();let e=await g({fallbackError:n.browserPlaywrightInstallFailed});if(!e.ok){if(e.error===`busy`){u(`installing`);return}if(e.error===`cancelled`){u(`idle`),f(null),_();return}u(`failed`),f(e.errorMessage??n.browserPlaywrightInstallFailed);return}e.payload&&a?.(e.payload),u(`installed`),f(e.payload?.executablePath?`${n.browserPlaywrightInstalled}: ${e.payload.executablePath}`:n.browserPlaywrightInstalled),await i()},t[0]=a,t[1]=n.browserPlaywrightInstallFailed,t[2]=n.browserPlaywrightInstalled,t[3]=i,t[4]=_,t[5]=g,t[6]=b):b=t[6];let S=b,C=r.kind===`loading`?`checking`:r.kind===`error`?`error`:r.kind===`ok`?r.data.installed?`ready`:`not_installed`:`unknown`,w=r.kind===`ok`&&r.data.installed&&r.data.executablePath?r.data.executablePath:void 0,E=r.kind===`ok`&&r.data.installed,D=l===`installing`||m,O;t[7]===S?O=t[8]:(O=()=>void S(),t[7]=S,t[8]=O);let k;t[9]!==E||t[10]!==D||t[11]!==l?(k=D?(0,Z.jsx)(W,{className:`size-3.5 animate-spin`}):E?(0,Z.jsx)(T,{className:`size-3.5`}):l===`installed`?(0,Z.jsx)(P,{className:`size-3.5 text-green-500`}):(0,Z.jsx)(v,{className:`size-3.5`}),t[9]=E,t[10]=D,t[11]=l,t[12]=k):k=t[12];let A=D?n.browserPlaywrightInstalling:E?n.browserReinstall:n.browserPlaywrightInstall,j;t[13]!==D||t[14]!==O||t[15]!==k||t[16]!==A?(j=(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:D,onClick:O,children:[k,A]}),t[13]=D,t[14]=O,t[15]=k,t[16]=A,t[17]=j):j=t[17];let M;t[18]===n.browserPlaywrightManualInstall?M=t[19]:(M=(0,Z.jsx)(`p`,{className:`text-fg-muted`,children:n.browserPlaywrightManualInstall}),t[18]=n.browserPlaywrightManualInstall,t[19]=M);let N;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(`code`,{className:`mt-2 block w-fit rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg`,children:`node node_modules/playwright-core/cli.js install chromium`}),t[20]=N):N=t[20];let F;t[21]===M?F=t[22]:(F=(0,Z.jsxs)(`div`,{className:`text-xs`,children:[M,N]}),t[21]=M,t[22]=F);let I;t[23]!==y||t[24]!==h||t[25]!==n||t[26]!==p||t[27]!==m?(I=m?(0,Z.jsx)(Ve,{m:n,progress:p,showLogs:!0,cancelling:h,onCancel:()=>void y()}):null,t[23]=y,t[24]=h,t[25]=n,t[26]=p,t[27]=m,t[28]=I):I=t[28];let L;t[29]!==d||t[30]!==l?(L=d?(0,Z.jsx)(Le,{kind:l===`failed`?`error`:`success`,message:d}):null,t[29]=d,t[30]=l,t[31]=L):L=t[31];let R;return t[32]!==c||t[33]!==n||t[34]!==w||t[35]!==C||t[36]!==I||t[37]!==L||t[38]!==j||t[39]!==F?(R=(0,Z.jsxs)(Fe,{icon:x,title:n.browserPlaywrightGuideTitle,description:n.browserPlaywrightGuideDesc,status:C,statusDetail:w,m:n,embedded:c,primaryAction:j,children:[F,I,L]}),t[32]=c,t[33]=n,t[34]=w,t[35]=C,t[36]=I,t[37]=L,t[38]=j,t[39]=F,t[40]=R):R=t[40],R}async function et(e){let t=await u(e),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1){let e=typeof n.error==`string`?n.error:n.error?.message;throw Error(e||`Request failed: ${t.status}`)}if(n.payload===void 0)throw Error(`Empty payload`);return n.payload}async function $(e,t){let n=await u(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})}),r=await n.json().catch(()=>({}));if(!n.ok||r.ok===!1){let e=typeof r.error==`string`?r.error:r.error?.message;throw Error(e||`Request failed: ${n.status}`)}if(r.payload===void 0)throw Error(`Empty payload`);return r.payload}var tt={playwright:{kind:`idle`},cloak:{kind:`idle`},extension:{kind:`idle`},extensionArtifacts:{kind:`idle`}};function nt(e,t){switch(t.type){case`playwright`:return{...e,playwright:t.state};case`cloak`:return{...e,cloak:t.state};case`extension`:return{...e,extension:t.state};case`extension-artifacts`:return{...e,extensionArtifacts:t.state};case`playwright-idle`:return{...e,playwright:{kind:`idle`}};case`cloak-idle`:return{...e,cloak:{kind:`idle`}};case`extension-idle`:return{...e,extension:{kind:`idle`},extensionArtifacts:{kind:`idle`}};case`extension-start-probe`:return{...e,extension:e.extension.kind===`ok`?e.extension:{kind:`loading`}};case`extension-artifacts-start-probe`:return{...e,extensionArtifacts:e.extensionArtifacts.kind===`ok`?e.extensionArtifacts:{kind:`loading`}}}}function rt(e){let[t,n]=(0,Y.useReducer)(nt,tt),{playwright:r,cloak:i,extension:a,extensionArtifacts:o}=t,s=(0,Y.useCallback)(async()=>{n({type:`playwright`,state:{kind:`loading`}});try{n({type:`playwright`,state:{kind:`ok`,data:await et(c(`/api/browser/playwright/doctor`))}})}catch(e){n({type:`playwright`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}})}},[]),l=(0,Y.useCallback)(async t=>{n({type:`cloak`,state:{kind:`loading`}});let r=(t?.cacheDir??e.cacheDir??``).trim(),i=(t?.binaryPath??e.binaryPath??``).trim(),a=new URLSearchParams;r&&a.set(`cacheDir`,r),i&&a.set(`binaryPath`,i);try{let e=await et(c(`/api/browser/cloakbrowser/doctor${a.size?`?${a}`:``}`));return n({type:`cloak`,state:{kind:`ok`,data:e}}),e}catch(e){return n({type:`cloak`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}}),null}},[e.binaryPath,e.cacheDir]),d=(0,Y.useCallback)(e=>{n({type:`playwright`,state:{kind:`ok`,data:e}})},[]),f=(0,Y.useCallback)(e=>{n({type:`cloak`,state:{kind:`ok`,data:e}})},[]),p=(0,Y.useCallback)(async()=>et(c(`/api/browser/cloakbrowser/status`)),[]),m=(0,Y.useCallback)(async()=>$(c(`/api/browser/cloakbrowser/launch`),{}),[]),h=e.browserEnabled===!0&&e.probeExtension===!0,g=e.browserEnabled===!0&&e.probeLocal===!0,_=e.browserEnabled===!0&&e.probeCloak===!0,{extensionHost:v,extensionPort:y}=e,b=(0,Y.useCallback)(async()=>{let e=new URLSearchParams({probe:`1`});v&&e.set(`host`,v),y!==void 0&&e.set(`port`,String(y)),n({type:`extension-start-probe`});try{let t=await u(c(`/api/browser/extension-status?${e}`),{signal:AbortSignal.timeout(3e3)}),r=await t.json().catch(()=>({}));if(!t.ok){n({type:`extension`,state:{kind:`error`,message:`HTTP ${t.status}`}});return}n({type:`extension`,state:{kind:`ok`,data:{running:r.running===!0,connected:r.connected===!0,backend:r.backend,artifacts:r.artifacts,bridgeHeld:r.bridgeHeld===!0,refCount:typeof r.refCount==`number`?r.refCount:void 0,manualBridge:r.manualBridge===!0,portConflict:r.portConflict===!0}}})}catch(e){n({type:`extension`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}})}},[v,y]),x=(0,Y.useCallback)(async()=>{n({type:`extension-artifacts-start-probe`});try{let e=await et(c(`/api/browser/extension/doctor`));return n({type:`extension-artifacts`,state:{kind:`ok`,data:e}}),e}catch(e){return n({type:`extension-artifacts`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}}),null}},[]),S=(0,Y.useCallback)(async e=>{let t=(await $(c(`/api/browser/extension/install`),{force:e?.force??!1})).doctor;return n({type:`extension-artifacts`,state:{kind:`ok`,data:t}}),await b(),t},[b]),C=(0,Y.useCallback)(async()=>{await $(c(`/api/browser/extension/open`),{action:`chrome`})},[]),w=(0,Y.useCallback)(async()=>{await $(c(`/api/browser/extension/open`),{action:`folder`})},[]);(0,Y.useEffect)(()=>{if(!g){n({type:`playwright-idle`});return}s()},[g,s]),(0,Y.useEffect)(()=>{if(!_){n({type:`cloak-idle`});return}l()},[_,l]);let T=(0,Y.useRef)(h);T.current!==h&&(T.current=h,h||n({type:`extension-idle`})),(0,Y.useEffect)(()=>{if(!h)return;b(),x();let e=setInterval(()=>void b(),5e3);return()=>clearInterval(e)},[h,b,x]);let E=(0,Y.useCallback)(async e=>{await $(c(`/api/browser/extension/start`),{host:e?.host??v,port:e?.port??y}),await b()},[v,y,b]),D=(0,Y.useCallback)(async()=>{await $(c(`/api/browser/extension/stop`),{}),await b()},[b]),O=(0,Y.useCallback)(async()=>{await $(c(`/api/browser/extension/disconnect`),{}),await b()},[b]),k=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{if(!h||e.activeBackend!==`extension`){k.current=null;return}if(a.kind!==`ok`||a.data.running||a.data.bridgeHeld)return;let t=`${v}:${y??19820}`;k.current!==t&&(k.current=t,E({host:v,port:y}).catch(()=>{k.current=null}))},[h,a,v,y,e.activeBackend,E]),{playwright:r,cloak:i,extension:a,extensionArtifacts:o,refetchPlaywright:s,applyPlaywrightDoctor:d,refetchCloak:l,applyCloakDoctor:f,fetchCloakRuntimeStatus:p,launchCloak:m,refetchExtension:b,refetchExtensionArtifacts:x,installExtensionArtifacts:S,openExtensionChrome:C,revealExtensionFolder:w,pingCdp:(0,Y.useCallback)(async e=>$(c(`/api/browser/cdp/ping`),{cdpUrl:e}),[]),testCloud:(0,Y.useCallback)(async(e,t)=>$(c(`/api/browser/cloud/test-connection`),{provider:e,apiKey:t}),[]),launchCdp:(0,Y.useCallback)(async e=>$(c(`/api/browser/cdp/launch`),{executablePath:e}),[]),stopCdp:(0,Y.useCallback)(async e=>{await $(c(`/api/browser/cdp/stop`),{port:e})},[]),listCdpInstances:(0,Y.useCallback)(async()=>(await et(c(`/api/browser/cdp/instances`))).instances,[]),startExtensionBridge:E,stopExtensionBridge:D,disconnectExtension:O}}var it=`
3
-
4
- `,at=/\r\n/g,ot={playwright:`/api/browser/playwright/install/stream`,cloakbrowser:`/api/browser/cloakbrowser/install/stream`},st={playwright:`/api/browser/playwright/install/cancel`,cloakbrowser:`/api/browser/cloakbrowser/install/cancel`},ct=8;function lt(){return{phase:null,message:null,percent:null,lines:[]}}function ut(e,t){let n={phase:t.phase,message:t.message??t.line??e.message,percent:t.percent??e.percent,lines:e.lines};if(t.line){let r=[...e.lines,t.line];n.lines=r.length>ct?r.slice(-8):r}return n}async function dt(e,t,n){let r=e.getReader(),i=new TextDecoder,a=``,o=null,s=e=>{let n=``,r=``;for(let t of e.split(`
5
- `)){let e=t.replace(/\r$/,``);e.startsWith(`event:`)?n=e.slice(6).trim():e.startsWith(`data:`)&&(r+=e.slice(5).trimStart())}if(r){if(n===`progress`){try{let e=JSON.parse(r);e&&typeof e==`object`&&typeof e.phase==`string`&&t(e)}catch{}return}if(n===`result`)try{let e=JSON.parse(r);o=e.ok?{ok:!0,payload:e.payload}:{ok:!1,error:String(e.error??`unknown`),message:typeof e.message==`string`?e.message:void 0,status:e.error===`busy`?409:e.error===`cancelled`?499:500}}catch{o={ok:!1,error:`parse`,status:0}}}};try{let e=async()=>{if(o!==null)return o;if(n?.aborted)return await r.cancel().catch(()=>{}),{ok:!1,error:`cancelled`,status:499};let{done:t,value:c}=await r.read();if(t)return o??{ok:!1,error:`no-result`,status:0};a+=i.decode(c,{stream:!0}),a=a.replace(at,`
6
- `);let l=a.split(it);a=l.pop()??``;for(let e of l)e.length&&s(e);return e()},t=await e();if(t)return t}catch(e){if(n?.aborted||e instanceof DOMException&&e.name===`AbortError`)return{ok:!1,error:`cancelled`,status:499};throw e}finally{r.releaseLock()}return o||(n?.aborted?{ok:!1,error:`cancelled`,status:499}:{ok:!1,error:`no-result`,status:0})}function ft(e){let[t,n]=(0,Y.useState)(lt),[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(!1),s=(0,Y.useRef)(!1),l=(0,Y.useRef)(null),d=(0,Y.useCallback)(()=>{s.current||n(lt())},[]),f=(0,Y.useCallback)(async()=>{if(s.current){o(!0);try{await u(c(st[e]),{method:`POST`}).catch(()=>{}),l.current?.abort()}finally{o(!1)}}},[e]);return{progress:t,running:r,cancelling:a,run:(0,Y.useCallback)(async t=>{if(s.current)return{ok:!1,error:`busy`,status:409,errorMessage:`An install for this browser type is already in progress.`};let r=new AbortController;l.current=r,s.current=!0,i(!0),n(lt());try{let i=await u(c(ot[e]),{method:`POST`,headers:{Accept:`text/event-stream`,...t.body===void 0?{}:{"Content-Type":`application/json`}},body:t.body===void 0?void 0:JSON.stringify(t.body),signal:r.signal});if(!i.ok||!i.body){let e=await i.text().catch(()=>``),t=`HTTP ${i.status}`;try{let n=JSON.parse(e);typeof n.message==`string`?t=n.message:typeof n.error==`string`&&(t=n.error)}catch{e&&(t=e.slice(0,500))}return{ok:!1,error:i.status===409?`busy`:`http`,status:i.status,errorMessage:t}}let a=await dt(i.body,e=>{n(t=>ut(t,e))},r.signal);return a.ok?a:a.error===`cancelled`?{...a,errorMessage:void 0}:{...a,errorMessage:a.message??(a.error===`busy`?`An install for this browser type is already in progress.`:t.fallbackError)}}catch(e){return r.signal.aborted||e instanceof DOMException&&e.name===`AbortError`?{ok:!1,error:`cancelled`,status:499}:{ok:!1,error:`network`,errorMessage:e instanceof Error?e.message:t.fallbackError}}finally{l.current===r&&(l.current=null),s.current=!1,i(!1),o(!1)}},[e]),reset:d,cancel:f}}function pt(e){let t=(0,X.c)(150),{a:n,form:r,update:a,activeTab:s,setActiveTab:c}=e,l=o(ht),u=j(mt),d=ft(`playwright`),f=ft(`cloakbrowser`),p=r.browserEnabled&&(s===`overview`||s===`extension`),m=r.browserEnabled&&(s===`overview`||s===`local`),g=r.browserEnabled&&(s===`overview`||s===`cloakbrowser`),_;t[0]!==r.browserBackend||t[1]!==r.browserCloakBinaryPath||t[2]!==r.browserCloakCacheDir||t[3]!==r.browserEnabled||t[4]!==r.browserExtensionHost||t[5]!==r.browserExtensionPort||t[6]!==g||t[7]!==p||t[8]!==m?(_={cacheDir:r.browserCloakCacheDir,binaryPath:r.browserCloakBinaryPath,browserEnabled:r.browserEnabled,activeBackend:r.browserBackend,probeExtension:p,probeLocal:m,probeCloak:g,extensionHost:r.browserExtensionHost,extensionPort:r.browserExtensionPort},t[0]=r.browserBackend,t[1]=r.browserCloakBinaryPath,t[2]=r.browserCloakCacheDir,t[3]=r.browserEnabled,t[4]=r.browserExtensionHost,t[5]=r.browserExtensionPort,t[6]=g,t[7]=p,t[8]=m,t[9]=_):_=t[9];let v=rt(_),y;t[10]===v.playwright?y=t[11]:(y=Ee(v.playwright),t[10]=v.playwright,t[11]=y);let b=y,S;t[12]===v.cloak?S=t[13]:(S=Ee(v.cloak),t[12]=v.cloak,t[13]=S);let C=S,T;t[14]===v.extension?T=t[15]:(T=Oe(v.extension),t[14]=v.extension,t[15]=T);let E=T,O;t[16]!==n||t[17]!==v.extension?(O=ke(v.extension,n),t[16]=n,t[17]=v.extension,t[18]=O):O=t[18];let k=O,M;t[19]!==n||t[20]!==C||t[21]!==E||t[22]!==k||t[23]!==b||t[24]!==u?(M=[{value:`extension`,icon:w,name:n.browserBackendExtension,tagline:n.browserModeExtTagline,status:E,statusLabel:k},{value:`local`,icon:x,name:n.browserBackendLocal,tagline:n.browserModeLocalTagline,status:b,statusLabel:De(b,n)},{value:`cloakbrowser`,icon:ee,name:n.browserBackendCloakBrowser,tagline:n.browserModeCloakTagline,status:C,statusLabel:De(C,n)},{value:`cdp`,icon:D,name:n.browserBackendCdp,tagline:n.browserModeCdpTagline},{value:`cloud`,icon:A,name:n.browserBackendCloud,tagline:n.browserModeCloudTagline}].filter(e=>pe(e.value,u)),t[19]=n,t[20]=C,t[21]=E,t[22]=k,t[23]=b,t[24]=u,t[25]=M):M=t[25];let N=M,P;t[26]!==c||t[27]!==a?(P=e=>{a({browserEnabled:!0,browserBackend:e}),c(e)},t[26]=c,t[27]=a,t[28]=P):P=t[28];let F=P,I=!r.browserEnabled&&`pointer-events-none opacity-40`,L;t[29]===I?L=t[30]:(L=i(`flex flex-col gap-5 transition-opacity`,I),t[29]=I,t[30]=L);let R=!r.browserEnabled,z;t[31]!==n||t[32]!==s||t[33]!==v.disconnectExtension||t[34]!==v.extension||t[35]!==v.extensionArtifacts||t[36]!==v.installExtensionArtifacts||t[37]!==v.openExtensionChrome||t[38]!==v.refetchExtensionArtifacts||t[39]!==v.revealExtensionFolder||t[40]!==v.startExtensionBridge||t[41]!==v.stopExtensionBridge||t[42]!==r.browserExtensionConnectionTimeout||t[43]!==r.browserExtensionHost||t[44]!==r.browserExtensionPort||t[45]!==a?(z=s===`extension`?(0,Z.jsx)(q,{children:(0,Z.jsx)(Qe,{embedded:!0,m:n,probe:v.extension,artifacts:v.extensionArtifacts,form:{port:r.browserExtensionPort,host:r.browserExtensionHost,connectionTimeoutMs:r.browserExtensionConnectionTimeout},onChange:e=>a({...e.port===void 0?{}:{browserExtensionPort:e.port},...e.host===void 0?{}:{browserExtensionHost:e.host},...e.connectionTimeoutMs===void 0?{}:{browserExtensionConnectionTimeout:e.connectionTimeoutMs}}),startBridge:v.startExtensionBridge,stopBridge:v.stopExtensionBridge,disconnectExtension:v.disconnectExtension,installArtifacts:v.installExtensionArtifacts,refetchArtifacts:v.refetchExtensionArtifacts,openExtensionChrome:v.openExtensionChrome,revealExtensionFolder:v.revealExtensionFolder})}):null,t[31]=n,t[32]=s,t[33]=v.disconnectExtension,t[34]=v.extension,t[35]=v.extensionArtifacts,t[36]=v.installExtensionArtifacts,t[37]=v.openExtensionChrome,t[38]=v.refetchExtensionArtifacts,t[39]=v.revealExtensionFolder,t[40]=v.startExtensionBridge,t[41]=v.stopExtensionBridge,t[42]=r.browserExtensionConnectionTimeout,t[43]=r.browserExtensionHost,t[44]=r.browserExtensionPort,t[45]=a,t[46]=z):z=t[46];let B;t[47]!==n||t[48]!==s||t[49]!==v.applyPlaywrightDoctor||t[50]!==v.playwright||t[51]!==v.refetchPlaywright||t[52]!==d?(B=s===`local`?(0,Z.jsx)(q,{children:(0,Z.jsx)($e,{embedded:!0,m:n,doctor:v.playwright,refetch:v.refetchPlaywright,applyDoctor:v.applyPlaywrightDoctor,installStream:d})}):null,t[47]=n,t[48]=s,t[49]=v.applyPlaywrightDoctor,t[50]=v.playwright,t[51]=v.refetchPlaywright,t[52]=d,t[53]=B):B=t[53];let V;t[54]!==n||t[55]!==s||t[56]!==f||t[57]!==v.applyCloakDoctor||t[58]!==v.cloak||t[59]!==v.fetchCloakRuntimeStatus||t[60]!==v.launchCloak||t[61]!==v.refetchCloak||t[62]!==r.browserCloakBinaryPath||t[63]!==r.browserCloakCacheDir||t[64]!==r.browserCloakExtraArgs||t[65]!==r.browserCloakFingerprintPlatform||t[66]!==r.browserCloakKeepOpen||t[67]!==r.browserCloakLocale||t[68]!==r.browserCloakTemporaryProfile||t[69]!==r.browserCloakTimezone||t[70]!==r.browserCloakWebrtcIp||t[71]!==r.browserHumanPreset||t[72]!==r.browserHumanize||t[73]!==a?(V=s===`cloakbrowser`?(0,Z.jsx)(q,{children:(0,Z.jsx)(We,{embedded:!0,m:n,doctor:v.cloak,refetch:v.refetchCloak,applyDoctor:v.applyCloakDoctor,installStream:f,fetchRuntimeStatus:v.fetchCloakRuntimeStatus,launchCloak:v.launchCloak,form:{cacheDir:r.browserCloakCacheDir,binaryPath:r.browserCloakBinaryPath,keepOpen:r.browserCloakKeepOpen,temporaryProfile:r.browserCloakTemporaryProfile,humanize:r.browserHumanize,humanPreset:r.browserHumanPreset,timezone:r.browserCloakTimezone,locale:r.browserCloakLocale,webrtcIp:r.browserCloakWebrtcIp,fingerprintPlatform:r.browserCloakFingerprintPlatform,extraArgs:r.browserCloakExtraArgs},onChange:e=>a({...e.cacheDir===void 0?{}:{browserCloakCacheDir:e.cacheDir},...e.binaryPath===void 0?{}:{browserCloakBinaryPath:e.binaryPath},...e.keepOpen===void 0?{}:{browserCloakKeepOpen:e.keepOpen},...e.temporaryProfile===void 0?{}:{browserCloakTemporaryProfile:e.temporaryProfile},...e.humanize===void 0?{}:{browserHumanize:e.humanize},...e.humanPreset===void 0?{}:{browserHumanPreset:e.humanPreset},...e.timezone===void 0?{}:{browserCloakTimezone:e.timezone},...e.locale===void 0?{}:{browserCloakLocale:e.locale},...e.webrtcIp===void 0?{}:{browserCloakWebrtcIp:e.webrtcIp},...e.fingerprintPlatform===void 0?{}:{browserCloakFingerprintPlatform:e.fingerprintPlatform},...e.extraArgs===void 0?{}:{browserCloakExtraArgs:e.extraArgs}})})}):null,t[54]=n,t[55]=s,t[56]=f,t[57]=v.applyCloakDoctor,t[58]=v.cloak,t[59]=v.fetchCloakRuntimeStatus,t[60]=v.launchCloak,t[61]=v.refetchCloak,t[62]=r.browserCloakBinaryPath,t[63]=r.browserCloakCacheDir,t[64]=r.browserCloakExtraArgs,t[65]=r.browserCloakFingerprintPlatform,t[66]=r.browserCloakKeepOpen,t[67]=r.browserCloakLocale,t[68]=r.browserCloakTemporaryProfile,t[69]=r.browserCloakTimezone,t[70]=r.browserCloakWebrtcIp,t[71]=r.browserHumanPreset,t[72]=r.browserHumanize,t[73]=a,t[74]=V):V=t[74];let H;t[75]!==n||t[76]!==s||t[77]!==v.launchCdp||t[78]!==v.listCdpInstances||t[79]!==v.pingCdp||t[80]!==v.stopCdp||t[81]!==r.browserCdpUrl||t[82]!==a?(H=s===`cdp`?(0,Z.jsx)(q,{children:(0,Z.jsx)(ze,{embedded:!0,m:n,cdpUrl:r.browserCdpUrl,onCdpUrlChange:e=>a({browserCdpUrl:e}),launch:v.launchCdp,stop:v.stopCdp,listInstances:v.listCdpInstances,ping:v.pingCdp})}):null,t[75]=n,t[76]=s,t[77]=v.launchCdp,t[78]=v.listCdpInstances,t[79]=v.pingCdp,t[80]=v.stopCdp,t[81]=r.browserCdpUrl,t[82]=a,t[83]=H):H=t[83];let te;t[84]!==n||t[85]!==s||t[86]!==v.testCloud||t[87]!==r.browserCloudApiKey||t[88]!==r.browserCloudProjectId||t[89]!==r.browserCloudProvider||t[90]!==r.browserCloudRegion||t[91]!==a?(te=s===`cloud`?(0,Z.jsx)(q,{children:(0,Z.jsx)(qe,{embedded:!0,m:n,form:{provider:r.browserCloudProvider,apiKey:r.browserCloudApiKey,projectId:r.browserCloudProjectId,region:r.browserCloudRegion},onChange:e=>a({...e.provider===void 0?{}:{browserCloudProvider:e.provider},...e.apiKey===void 0?{}:{browserCloudApiKey:e.apiKey},...e.projectId===void 0?{}:{browserCloudProjectId:e.projectId},...e.region===void 0?{}:{browserCloudRegion:e.region}}),testCloud:v.testCloud})}):null,t[84]=n,t[85]=s,t[86]=v.testCloud,t[87]=r.browserCloudApiKey,t[88]=r.browserCloudProjectId,t[89]=r.browserCloudProvider,t[90]=r.browserCloudRegion,t[91]=a,t[92]=te):te=t[92];let U;t[93]!==z||t[94]!==B||t[95]!==V||t[96]!==H||t[97]!==te||t[98]!==L||t[99]!==R?(U=(0,Z.jsxs)(`div`,{className:L,"aria-hidden":R,children:[z,B,V,H,te]}),t[93]=z,t[94]=B,t[95]=V,t[96]=H,t[97]=te,t[98]=L,t[99]=R,t[100]=U):U=t[100];let W=U;if(s===`overview`){let e;t[101]!==n||t[102]!==r.browserEnabled||t[103]!==F?(e=r.browserEnabled?null:(0,Z.jsx)(we,{m:n,onStart:F}),t[101]=n,t[102]=r.browserEnabled,t[103]=F,t[104]=e):e=t[104];let o;t[105]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,"aria-hidden":!0,children:(0,Z.jsx)(h,{className:`size-4`,strokeWidth:1.75})}),t[105]=o):o=t[105];let s;t[106]===a?s=t[107]:(s=e=>a({browserEnabled:e.target.checked}),t[106]=a,t[107]=s);let u;t[108]!==r.browserEnabled||t[109]!==s?(u=(0,Z.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserEnabled,onChange:s}),t[108]=r.browserEnabled,t[109]=s,t[110]=u):u=t[110];let d;t[111]===n.browserEnabledOn?d=t[112]:(d=(0,Z.jsx)(`span`,{children:n.browserEnabledOn}),t[111]=n.browserEnabledOn,t[112]=d);let f;t[113]!==u||t[114]!==d?(f=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[u,d]}),t[113]=u,t[114]=d,t[115]=f):f=t[115];let p;t[116]!==n.desc.browserEnabled||t[117]!==n.label.browserEnabled||t[118]!==f?(p=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3`,children:[o,(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Z.jsx)(Q,{label:n.label.browserEnabled,description:n.desc.browserEnabled,children:f})})]}),t[116]=n.desc.browserEnabled,t[117]=n.label.browserEnabled,t[118]=f,t[119]=p):p=t[119];let m;t[120]!==n.browserDocsLink||t[121]!==l?(m=(0,Z.jsx)(Se,{language:l,label:n.browserDocsLink,className:`shrink-0 pt-1`}),t[120]=n.browserDocsLink,t[121]=l,t[122]=m):m=t[122];let g;t[123]!==p||t[124]!==m?(g=(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[p,m]}),t[123]=p,t[124]=m,t[125]=g):g=t[125];let _;t[126]!==n||t[127]!==r.browserBackend||t[128]!==r.browserEnabled||t[129]!==N||t[130]!==c||t[131]!==a?(_=r.browserEnabled?(0,Z.jsx)(`div`,{id:ye(`connection`),className:i(`scroll-mt-24 transition-opacity`,!r.browserEnabled&&`pointer-events-none opacity-40`),children:(0,Z.jsx)(_e,{m:n,value:r.browserBackend,onChange:e=>a({browserBackend:e}),onOpenConfig:c,options:N})}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.browserDisabledHint}),t[126]=n,t[127]=r.browserBackend,t[128]=r.browserEnabled,t[129]=N,t[130]=c,t[131]=a,t[132]=_):_=t[132];let v;t[133]!==g||t[134]!==_?(v=(0,Z.jsx)(q,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[g,_]})}),t[133]=g,t[134]=_,t[135]=v):v=t[135];let y=!r.browserEnabled&&`pointer-events-none opacity-40`,b;t[136]===y?b=t[137]:(b=i(`transition-opacity`,y),t[136]=y,t[137]=b);let x=!r.browserEnabled,S;t[138]!==n||t[139]!==r||t[140]!==a?(S=(0,Z.jsx)(xe,{a:n,form:r,update:a}),t[138]=n,t[139]=r,t[140]=a,t[141]=S):S=t[141];let C;t[142]!==b||t[143]!==x||t[144]!==S?(C=(0,Z.jsx)(ae,{children:(0,Z.jsx)(`div`,{className:b,"aria-hidden":x,children:S})}),t[142]=b,t[143]=x,t[144]=S,t[145]=C):C=t[145];let w;return t[146]!==e||t[147]!==v||t[148]!==C?(w=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[e,v,C]}),t[146]=e,t[147]=v,t[148]=C,t[149]=w):w=t[149],w}return Pe(s)?W:null}function mt(e){return e.mode}function ht(e){return e.language}function gt(e){let t=(0,X.c)(57),{sectionId:n,intro:r,vm:i,children:s,tabbed:c}=e,l=c===void 0?!1:c,u=o(_t),d;t[0]===u?d=t[1]:(d=a(u),t[0]=u,t[1]=d);let f=d,m=f.agentSettings,h=f.settingsSections[n]??n;if(!i.hasToken){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(O,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75}),t[2]=e):e=t[2];let n;t[3]===h?n=t[4]:(n=(0,Z.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:h}),t[3]=h,t[4]=n);let r;t[5]===m.needToken?r=t[6]:(r=(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:m.needToken}),t[5]=m.needToken,t[6]=r);let i;return t[7]!==n||t[8]!==r?(i=(0,Z.jsx)(le,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[e,(0,Z.jsxs)(`div`,{children:[n,r]})]})}),t[7]=n,t[8]=r,t[9]=i):i=t[9],i}if(i.loading){let e,n;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`div`,{className:`h-8 w-48 animate-pulse rounded bg-surface-hover`}),n=(0,Z.jsx)(`div`,{className:`mt-6 h-32 animate-pulse rounded-xl bg-surface-hover`}),t[10]=e,t[11]=n):(e=t[10],n=t[11]);let r;return t[12]===f.logs.loading?r=t[13]:(r=(0,Z.jsxs)(le,{gap:`gap-0`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[e,n,(0,Z.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:f.logs.loading})]}),t[12]=f.logs.loading,t[13]=r),r}if(!i.form){let e=i.error??i.fetchError??m.loadError,n;t[14]===e?n=t[15]:(n=(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[14]=e,t[15]=n);let r;t[16]===i?r=t[17]:(r=()=>void i.mutate(),t[16]=i,t[17]=r);let a;t[18]!==f.logs.refresh||t[19]!==r?(a=(0,Z.jsx)(p,{type:`button`,variant:`secondary`,onClick:r,children:f.logs.refresh}),t[18]=f.logs.refresh,t[19]=r,t[20]=a):a=t[20];let o;return t[21]!==n||t[22]!==a?(o=(0,Z.jsxs)(le,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:[n,a]}),t[21]=n,t[22]=a,t[23]=o):o=t[23],o}let g=l?void 0:r,_;t[24]===m.sectionDesc?_=t[25]:(_=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:m.sectionDesc}),t[24]=m.sectionDesc,t[25]=_);let v;t[26]!==m.saved||t[27]!==i.dirty||t[28]!==i.saveOk?(v=i.saveOk&&!i.dirty?(0,Z.jsx)(`span`,{className:`text-sm text-fg-muted`,role:`status`,children:m.saved}):null,t[26]=m.saved,t[27]=i.dirty,t[28]=i.saveOk,t[29]=v):v=t[29];let y=!i.dirty||i.saving,b;t[30]!==m.discard||t[31]!==y||t[32]!==i.discard?(b=(0,Z.jsx)(p,{type:`button`,variant:`secondary`,disabled:y,onClick:i.discard,children:m.discard}),t[30]=m.discard,t[31]=y,t[32]=i.discard,t[33]=b):b=t[33];let x=!i.dirty||i.saving,S;t[34]===i?S=t[35]:(S=()=>void i.save(),t[34]=i,t[35]=S);let C=i.saving?m.saving:m.save,w;t[36]!==x||t[37]!==S||t[38]!==C?(w=(0,Z.jsx)(p,{type:`button`,variant:`primary`,disabled:x,onClick:S,children:C}),t[36]=x,t[37]=S,t[38]=C,t[39]=w):w=t[39];let T;t[40]!==w||t[41]!==v||t[42]!==b?(T=(0,Z.jsxs)(Z.Fragment,{children:[v,b,w]}),t[40]=w,t[41]=v,t[42]=b,t[43]=T):T=t[43];let E;t[44]!==h||t[45]!==T||t[46]!==g||t[47]!==_?(E=(0,Z.jsx)(se,{title:h,subtitle:g,meta:_,actions:T}),t[44]=h,t[45]=T,t[46]=g,t[47]=_,t[48]=E):E=t[48];let D;t[49]===i.error?D=t[50]:(D=i.error?(0,Z.jsx)(`div`,{className:`rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/50 dark:bg-red-950/50 dark:text-red-400`,role:`alert`,children:i.error}):null,t[49]=i.error,t[50]=D);let k;t[51]===s?k=t[52]:(k=(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-col gap-5 pb-8`,children:s}),t[51]=s,t[52]=k);let A;return t[53]!==E||t[54]!==D||t[55]!==k?(A=(0,Z.jsxs)(le,{gap:`gap-6`,children:[E,D,k]}),t[53]=E,t[54]=D,t[55]=k,t[56]=A):A=t[56],A}function _t(e){return e.language}var vt={enabled:!0,mode:`default`,reserveTokens:8e3,triggerThreshold:.8,minMessagesBeforeCompact:10,keepRecentMessages:5,evictionWindow:.2,retentionWindow:6},yt={enabled:!0,maxToolResultChars:1e4,headKeepRatio:.3,tailKeepRatio:.3},bt={enabled:!0,useEnhancedSystem:!0,userProfileEnabled:!0,provider:``,injectionFrequency:``,memoryCharLimit:void 0,userCharLimit:void 0,contextCadence:void 0,dialecticCadence:void 0},xt={summaryModel:``},St={enabled:!1,memoryNudgeInterval:10,skillNudgeInterval:10,maxToolRounds:8,maxHistoryMessages:80,maxDurationMs:12e4},Ct={model:``,maxLength:void 0};function wt(e){if(!e)return``;if(typeof e==`string`)return e;if(typeof e==`object`&&!Array.isArray(e)){let t=e.primary;return typeof t==`string`?t:``}return``}function Tt(e){if(typeof e!=`object`||!e||!(`fallbacks`in e))return[];let t=e.fallbacks;return Array.isArray(t)?t.filter(e=>typeof e==`string`&&e.trim().length>0):[]}function Et(e){return e===!0||e===`true`||e===1}function Dt(e){let t=e;if(!t||typeof t!=`object`||Array.isArray(t))return{browserEnabled:!0,browserHeadless:!1,browserAllowPrivateUrls:!1,browserCommandTimeout:void 0,browserBackend:`extension`,browserCloudProvider:`local`,browserCloudApiKey:``,browserCloudProjectId:``,browserCloudRegion:``,browserCdpUrl:``,browserExtensionPort:void 0,browserExtensionHost:`127.0.0.1`,browserExtensionConnectionTimeout:void 0,browserCloakKeepOpen:!0,browserCloakTemporaryProfile:!1,browserCloakCacheDir:``,browserCloakBinaryPath:``,browserCloakTimezone:``,browserCloakLocale:``,browserCloakWebrtcIp:``,browserCloakFingerprintPlatform:``,browserCloakExtraArgs:``,browserHumanize:!0,browserHumanPreset:`careful`,browserDialogPolicy:`auto_dismiss`,browserDialogTimeout:void 0};let n=t,r=Et(n.enabled),i=n.headless,a=i===!0||i===`true`||i===1,o=Et(n.allowPrivateUrls),s=typeof n.commandTimeout==`number`&&Number.isFinite(n.commandTimeout)&&n.commandTimeout>=5?Math.floor(n.commandTimeout):void 0,c=n.backend,l=c===`local`||c===`cdp`||c===`cloud`||c===`extension`||c===`cloakbrowser`?c:`extension`,u=n.cloudProvider,d=u===`browserbase`||u===`browser-use`?u:`local`,f=typeof n.cloud==`object`&&n.cloud&&!Array.isArray(n.cloud)?n.cloud:{},p=typeof f.apiKey==`string`?f.apiKey:``,m=typeof f.projectId==`string`?f.projectId:``,h=typeof f.region==`string`?f.region:``,g=typeof n.cdpUrl==`string`?n.cdpUrl:``,_=typeof n.extension==`object`&&n.extension&&!Array.isArray(n.extension)?n.extension:{},v=typeof _.port==`number`&&Number.isFinite(_.port)&&_.port>=1024&&_.port<=65535?Math.floor(_.port):void 0,y=typeof _.host==`string`&&_.host?_.host:`127.0.0.1`,b=typeof _.connectionTimeout==`number`&&Number.isFinite(_.connectionTimeout)&&_.connectionTimeout>=1e3?Math.floor(_.connectionTimeout):void 0,x=typeof n.cloakbrowser==`object`&&n.cloakbrowser&&!Array.isArray(n.cloakbrowser)?n.cloakbrowser:{},S=n.humanPreset==="default"?`default`:`careful`,C=n.dialogPolicy,w=C===`must_respond`||C===`auto_accept`?C:`auto_dismiss`,T=typeof n.dialogTimeoutSeconds==`number`&&Number.isFinite(n.dialogTimeoutSeconds)&&n.dialogTimeoutSeconds>=1?Math.floor(n.dialogTimeoutSeconds):void 0;return{browserEnabled:r,browserHeadless:a,browserAllowPrivateUrls:o,browserCommandTimeout:s,browserBackend:l,browserCloudProvider:d,browserCloudApiKey:p,browserCloudProjectId:m,browserCloudRegion:h,browserCdpUrl:g,browserExtensionPort:v,browserExtensionHost:y,browserExtensionConnectionTimeout:b,browserCloakKeepOpen:x.keepOpen!==!1,browserCloakTemporaryProfile:x.temporaryProfile===!0,browserCloakCacheDir:typeof x.cacheDir==`string`?x.cacheDir:``,browserCloakBinaryPath:typeof x.binaryPath==`string`?x.binaryPath:``,browserCloakTimezone:typeof x.timezone==`string`?x.timezone:``,browserCloakLocale:typeof x.locale==`string`?x.locale:``,browserCloakWebrtcIp:typeof x.webrtcIp==`string`?x.webrtcIp:``,browserCloakFingerprintPlatform:typeof x.fingerprintPlatform==`string`?x.fingerprintPlatform:``,browserCloakExtraArgs:Array.isArray(x.extraArgs)?x.extraArgs.filter(e=>typeof e==`string`&&e.trim().length>0).join(`
7
- `):``,browserHumanize:n.humanize!==!1,browserHumanPreset:S,browserDialogPolicy:w,browserDialogTimeout:T}}function Ot(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...vt};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:vt.enabled,mode:t.mode===`safeguard`?`safeguard`:`default`,reserveTokens:typeof t.reserveTokens==`number`&&Number.isFinite(t.reserveTokens)?Math.floor(t.reserveTokens):vt.reserveTokens,triggerThreshold:typeof t.triggerThreshold==`number`&&Number.isFinite(t.triggerThreshold)?t.triggerThreshold:vt.triggerThreshold,minMessagesBeforeCompact:typeof t.minMessagesBeforeCompact==`number`&&Number.isFinite(t.minMessagesBeforeCompact)?Math.floor(t.minMessagesBeforeCompact):vt.minMessagesBeforeCompact,keepRecentMessages:typeof t.keepRecentMessages==`number`&&Number.isFinite(t.keepRecentMessages)?Math.floor(t.keepRecentMessages):vt.keepRecentMessages,evictionWindow:typeof t.evictionWindow==`number`&&Number.isFinite(t.evictionWindow)?t.evictionWindow:vt.evictionWindow,retentionWindow:typeof t.retentionWindow==`number`&&Number.isFinite(t.retentionWindow)?Math.floor(t.retentionWindow):vt.retentionWindow}}function kt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...yt};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:yt.enabled,maxToolResultChars:typeof t.maxToolResultChars==`number`&&Number.isFinite(t.maxToolResultChars)?Math.floor(t.maxToolResultChars):yt.maxToolResultChars,headKeepRatio:typeof t.headKeepRatio==`number`&&Number.isFinite(t.headKeepRatio)?t.headKeepRatio:yt.headKeepRatio,tailKeepRatio:typeof t.tailKeepRatio==`number`&&Number.isFinite(t.tailKeepRatio)?t.tailKeepRatio:yt.tailKeepRatio}}function At(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...bt};let t=e,n=t.provider,r=n===`none`||n===`stub`?n:``,i=t.injectionFrequency,a=i===`every-turn`||i===`first-turn`?i:``;return{enabled:typeof t.enabled==`boolean`?t.enabled:bt.enabled,useEnhancedSystem:typeof t.useEnhancedSystem==`boolean`?t.useEnhancedSystem:bt.useEnhancedSystem,userProfileEnabled:typeof t.userProfileEnabled==`boolean`?t.userProfileEnabled:bt.userProfileEnabled,provider:r,injectionFrequency:a,memoryCharLimit:typeof t.memoryCharLimit==`number`&&t.memoryCharLimit>0?Math.floor(t.memoryCharLimit):void 0,userCharLimit:typeof t.userCharLimit==`number`&&t.userCharLimit>0?Math.floor(t.userCharLimit):void 0,contextCadence:typeof t.contextCadence==`number`&&t.contextCadence>=1?Math.floor(t.contextCadence):void 0,dialecticCadence:typeof t.dialecticCadence==`number`&&t.dialecticCadence>=1?Math.floor(t.dialecticCadence):void 0}}function jt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...xt};let t=e;return{summaryModel:typeof t.summaryModel==`string`?t.summaryModel:``}}function Mt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...St};let t=e;return{enabled:typeof t.enabled==`boolean`?t.enabled:St.enabled,memoryNudgeInterval:typeof t.memoryNudgeInterval==`number`&&t.memoryNudgeInterval>=0?Math.floor(t.memoryNudgeInterval):St.memoryNudgeInterval,skillNudgeInterval:typeof t.skillNudgeInterval==`number`&&t.skillNudgeInterval>=0?Math.floor(t.skillNudgeInterval):St.skillNudgeInterval,maxToolRounds:typeof t.maxToolRounds==`number`&&t.maxToolRounds>=1&&t.maxToolRounds<=32?Math.floor(t.maxToolRounds):St.maxToolRounds,maxHistoryMessages:typeof t.maxHistoryMessages==`number`&&t.maxHistoryMessages>=10&&t.maxHistoryMessages<=200?Math.floor(t.maxHistoryMessages):St.maxHistoryMessages,maxDurationMs:typeof t.maxDurationMs==`number`&&t.maxDurationMs>=3e4&&t.maxDurationMs<=6e5?Math.floor(t.maxDurationMs):St.maxDurationMs}}function Nt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{...Ct};let t=e;return{model:typeof t.model==`string`?t.model:``,maxLength:typeof t.maxLength==`number`&&t.maxLength>0?t.maxLength:void 0}}function Pt(e,t){if(!e||typeof e!=`object`||Array.isArray(e))return{enabled:t};let n=e;return{enabled:typeof n.enabled==`boolean`?n.enabled:t}}function Ft(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function It(e){if(e==null)return``;if(typeof e==`string`){let t=e.trim();if(!t)return``;try{let e=JSON.parse(t);if(typeof e==`object`&&e&&!Array.isArray(e))return JSON.stringify(e,null,2)}catch{return t}return``}if(typeof e==`object`&&!Array.isArray(e))try{return JSON.stringify(e,null,2)}catch{return``}return``}function Lt(e){let t=e.imageGenerationModelTimeoutMs;if(typeof t==`number`&&Number.isFinite(t)&&t>0)return Math.floor(t);let n=e.imageGenerationModel;if(n&&typeof n==`object`&&!Array.isArray(n)){let e=n.timeoutMs;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return Math.floor(e)}return null}function Rt(e){if(e.imageGenerationModelAutoProviderFallback===!0)return!0;let t=e.imageGenerationModel;return t&&typeof t==`object`&&!Array.isArray(t)?t.autoProviderFallback===!0:!1}function zt(e){let t={},n=t.models&&typeof t.models==`object`&&!Array.isArray(t.models)?t.models:{},r=n.chat,i=t.modelFallbacks,a=Array.isArray(i)&&i.every(e=>typeof e==`string`)?i:Tt(r),o=t.imageModelFallbacks,s=Array.isArray(o)&&o.every(e=>typeof e==`string`)?o:Tt(t.imageModel),c=t.imageGenerationModelFallbacks,l=Array.isArray(c)&&c.every(e=>typeof e==`string`)?c:Tt(t.imageGenerationModel),u=Dt((e&&typeof e==`object`&&!Array.isArray(e)?e:{}).browser),d=typeof t.maxTaskDurationMs==`number`&&Number.isFinite(t.maxTaskDurationMs)?t.maxTaskDurationMs:void 0,f=d===void 0?void 0:Math.round(d/6e4);return{model:wt(r),modelFallbacks:a,imageModel:wt(t.imageModel),imageModelFallbacks:s,imageGenerationModel:wt(t.imageGenerationModel),imageGenerationModelFallbacks:l,imageGenerationModelTimeoutMs:Lt(t),imageGenerationModelAutoProviderFallback:Rt(t),mediaMaxMb:typeof t.mediaMaxMb==`number`&&!Number.isNaN(t.mediaMaxMb)?t.mediaMaxMb:void 0,maxTokens:typeof t.maxTokens==`number`?t.maxTokens:8192,temperature:typeof t.temperature==`number`?t.temperature:.7,maxToolIterations:typeof t.maxToolIterations==`number`?t.maxToolIterations:20,maxTaskDurationMinutes:f,maxRequestsPerTurn:typeof t.maxRequestsPerTurn==`number`?t.maxRequestsPerTurn:50,maxToolFailuresPerTurn:typeof t.maxToolFailuresPerTurn==`number`?t.maxToolFailuresPerTurn:3,workspace:typeof t.workspace==`string`?t.workspace:`~/.xopc/workspace`,...u,thinkingDefault:typeof t.thinkingDefault==`string`?t.thinkingDefault:`medium`,reasoningDefault:typeof t.reasoningDefault==`string`?t.reasoningDefault:`stream`,verboseDefault:typeof t.verboseDefault==`string`?t.verboseDefault:`full`,compaction:Ot(t.compaction),pruning:kt(t.pruning),memory:At(t.memory),sessionSearch:jt(t.sessionSearch),backgroundReview:Mt(t.backgroundReview),webExtract:Nt(t.webExtract),delegate:Pt(t.delegate,!1),executeCode:Pt(t.executeCode,!1),systemPromptOverride:typeof t.systemPromptOverride==`string`?t.systemPromptOverride:``,skillsAllowlist:Ft(t.skills),toolsDisable:(()=>{let e=t.tools;if(!e||typeof e!=`object`||Array.isArray(e))return[];let n=e.disable;return Ft(n)})(),typedModels:de(n),paramsJson:It(t.params)}}function Bt(e){return{enabled:e.browserEnabled,headless:e.browserHeadless,allowPrivateUrls:e.browserAllowPrivateUrls,...e.browserCommandTimeout===void 0?{}:{commandTimeout:e.browserCommandTimeout},backend:e.browserBackend,...e.browserCloudProvider===`local`?{}:{cloudProvider:e.browserCloudProvider},...e.browserBackend===`cloud`?{cloud:{...e.browserCloudApiKey.trim()?{apiKey:e.browserCloudApiKey.trim()}:{},...e.browserCloudProjectId.trim()?{projectId:e.browserCloudProjectId.trim()}:{},...e.browserCloudRegion.trim()?{region:e.browserCloudRegion.trim()}:{}}}:{},...e.browserCdpUrl.trim()?{cdpUrl:e.browserCdpUrl.trim()}:{},...e.browserBackend===`extension`?{extension:{...e.browserExtensionPort===void 0?{}:{port:e.browserExtensionPort},...e.browserExtensionHost.trim()?{host:e.browserExtensionHost.trim()}:{},...e.browserExtensionConnectionTimeout===void 0?{}:{connectionTimeout:e.browserExtensionConnectionTimeout}}}:{},...e.browserBackend===`cloakbrowser`?{cloakbrowser:{keepOpen:e.browserCloakKeepOpen,temporaryProfile:e.browserCloakTemporaryProfile,...e.browserCloakCacheDir.trim()?{cacheDir:e.browserCloakCacheDir.trim()}:{},...e.browserCloakBinaryPath.trim()?{binaryPath:e.browserCloakBinaryPath.trim()}:{},...e.browserCloakTimezone.trim()?{timezone:e.browserCloakTimezone.trim()}:{},...e.browserCloakLocale.trim()?{locale:e.browserCloakLocale.trim()}:{},...e.browserCloakWebrtcIp.trim()?{webrtcIp:e.browserCloakWebrtcIp.trim()}:{},...e.browserCloakFingerprintPlatform.trim()?{fingerprintPlatform:e.browserCloakFingerprintPlatform.trim()}:{},...(()=>{let t=e.browserCloakExtraArgs.split(`
8
- `).map(e=>e.trim()).filter(Boolean);return t.length>0?{extraArgs:t}:{}})()},humanize:e.browserHumanize,humanPreset:e.browserHumanPreset}:{},...e.browserDialogPolicy===`auto_dismiss`?{}:{dialogPolicy:e.browserDialogPolicy},...e.browserDialogTimeout===void 0?{}:{dialogTimeoutSeconds:e.browserDialogTimeout}}}async function Vt(e){await l(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({browser:Bt(e)})}),z()}var Ht=F();function Ut(e,t={}){let n=!!s(e=>e.token),[r,i]=(0,Y.useReducer)(Ht,{form:null,baseline:null}),a=r.form,o=r.baseline,[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(!1),m=(0,Y.useRef)(!1),h=(0,Y.useRef)(null),{data:g,error:_,isLoading:v,mutate:y}=C(n);H({enabled:n,parsed:(0,Y.useMemo)(()=>g?.payload?.config===void 0?null:zt(g.payload.config),[g]),dirty:m.current,trackedParsedRef:h,dispatch:i,onResetDirty:()=>{m.current=!1}});let b=!!(n&&v&&g===void 0&&!_),x=_ instanceof Error?_.message:_?String(_):null,S=(0,Y.useMemo)(()=>!a||!o?!1:JSON.stringify(a)!==JSON.stringify(o),[a,o]);return{hasToken:n,loading:b,fetchError:x,form:a,update:(0,Y.useCallback)(e=>{m.current=!0,p(!1),i({type:`patch`,patch:e})},[]),dirty:S,saving:c,saveOk:f,error:u,setError:d,save:(0,Y.useCallback)(async()=>{if(!a||c)return!1;l(!0),d(null),p(!1);try{return await Vt(a),m.current=!1,i({type:`saved`,value:a}),p(!0),y(),!0}catch(t){return d(t instanceof Error?t.message:e.saveError),!1}finally{l(!1)}},[e.saveError,a,y,c]),discard:(0,Y.useCallback)(()=>{m.current=!1,i({type:`discard`}),p(!1),d(null)},[]),mutate:y}}function Wt(e,t){return e.browserTabs[t]}function Gt(){let e=(0,X.c)(43),t=o(qt),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n,i=r.agentSettings,s=r.chat,c=j(Kt),l;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(l={saveScope:`browser`},e[2]=l):l=e[2];let u=Ut(i,l),[d,f]=y(),p;e[3]===c?p=e[4]:(p=he(Ae,c),e[3]=c,e[4]=p);let m=p,h;e[5]===d?h=e[6]:(h=be(d.get(`focus`)),e[5]=d,e[6]=h);let g=h,v;e[7]!==g||e[8]!==d?(v=g?Me[g]??Ne(d.get(`tab`)):Ne(d.get(`tab`)),e[7]=g,e[8]=d,e[9]=v):v=e[9];let b=v,x;bb0:{if(!u.form){x=null;break bb0}let t;e[10]!==i||e[11]!==s||e[12]!==u.form||e[13]!==u.update?(t={form:u.form,update:u.update,a:i,chat:s},e[10]=i,e[11]=s,e[12]=u.form,e[13]=u.update,e[14]=t):t=e[14],x=t}let S=x,C;e[15]===f?C=e[16]:(C=e=>{f(t=>{let n=new URLSearchParams(t);return n.delete(`focus`),e===`overview`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[15]=f,e[16]=C);let w=C;me(b,w);let T,E;e[17]!==g||e[18]!==d||e[19]!==f?(T=()=>{if(!g)return;let e=Me[g]??Ne(d.get(`tab`));f(t=>{let n=new URLSearchParams(t);return n.delete(`focus`),e===`overview`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0});let t=g===`runtime`||g===`security`?ye(g):null;if(!t)return;let n=window.setTimeout(()=>{document.getElementById(t)?.scrollIntoView({behavior:`smooth`,block:`start`})},80);return()=>window.clearTimeout(n)},E=[g,d,f],e[17]=g,e[18]=d,e[19]=f,e[20]=T,e[21]=E):(T=e[20],E=e[21]),(0,Y.useEffect)(T,E);let D;if(e[22]!==i||e[23]!==m){let t;e[25]===i?t=e[26]:(t=e=>({id:e,label:Wt(i,e)}),e[25]=i,e[26]=t),D=m.map(t),e[22]=i,e[23]=m,e[24]=D}else D=e[24];let O=D,k;e[27]!==b||e[28]!==i.browserTabsAria||e[29]!==w||e[30]!==O?(k=(0,Z.jsx)(_,{items:O,activeTab:b,onChange:w,ariaLabel:i.browserTabsAria,tabIdPrefix:`agent-browser-tab`,panelIdPrefix:`agent-browser-panel`}),e[27]=b,e[28]=i.browserTabsAria,e[29]=w,e[30]=O,e[31]=k):k=e[31];let A;e[32]!==b||e[33]!==S||e[34]!==w?(A=S?(0,Z.jsx)(pt,{...S,activeTab:b,setActiveTab:w}):null,e[32]=b,e[33]=S,e[34]=w,e[35]=A):A=e[35];let M;e[36]!==b||e[37]!==A?(M=(0,Z.jsx)(ce,{id:b,activeTab:b,tabIdPrefix:`agent-browser-tab`,panelIdPrefix:`agent-browser-panel`,showHeading:!1,framed:!1,children:A}),e[36]=b,e[37]=A,e[38]=M):M=e[38];let N;return e[39]!==k||e[40]!==M||e[41]!==u?(N=(0,Z.jsxs)(gt,{sectionId:`agent-browser`,intro:``,vm:u,tabbed:!0,children:[k,M]}),e[39]=k,e[40]=M,e[41]=u,e[42]=N):N=e[42],N}function Kt(e){return e.mode}function qt(e){return e.language}export{Gt as AgentBrowserSettingsPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-B5O4OIEo.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s}from"./fetch-ovkvM8KQ.js";import{i as c}from"./vendor-swr-BIWyz7Rc.js";import{$a as l,Ba as u,Bn as d,Gs as f,Ha as p,Ic as m,Mo as h,Na as g,Po as _,Rs as v,To as y,Ua as b,aa as x,ba as S,bc as C,ea as w,ht as T,ia as E,ms as D,na as O,oa as k,ra as A,ta as j,ya as M}from"./index-DdqSO9R2.js";import{n as N,t as P}from"./settings-form-section-Dg6LBbcr.js";import{n as F,t as I}from"./settings-page-layout-BX4T-OLF.js";import{a as L,i as R,o as z,t as B}from"./typed-models-lib-Cx6XV5A2.js";import{a as ee,i as te,n as ne,o as V,r as re,s as ie,t as ae}from"./capability-presets-api-Cx93GLdw.js";var H=n(),U=e(t(),1),W=r();function oe(e){return e.name||e.directoryId}function se(e){let t=(0,H.c)(57),{mode:n,selected:r,catalog:a,loading:o,disabled:s,onModeChange:c,onSelectedChange:l,labels:d}=e,f=n===`allowlist`||n===`denylist`,p;t[0]===a?p=t[1]:(p=a.map(oe).filter(Boolean),t[0]=a,t[1]=p);let m=p,h;bb0:{if(n===`inherit`){h=d.inheritSummary;break bb0}if(n===`all`){h=d.allSummary;break bb0}if(n===`off`){h=d.offSummary;break bb0}let e=n===`allowlist`?d.allowSummary:d.denySummary,i;t[2]!==r.size||t[3]!==e?(i=e.replace(`{{count}}`,String(r.size)),t[2]=r.size,t[3]=e,t[4]=i):i=t[4],h=i}let g=h,_;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,W.jsx)(C,{className:`size-3.5`,"aria-hidden":!0}),t[5]=_):_=t[5];let v;t[6]===d.overrideSummaryTitle?v=t[7]:(v=(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[_,d.overrideSummaryTitle]}),t[6]=d.overrideSummaryTitle,t[7]=v);let y;t[8]===g?y=t[9]:(y=(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:g}),t[8]=g,t[9]=y);let b;t[10]!==v||t[11]!==y?(b=(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/50 px-3 py-2`,children:[v,y]}),t[10]=v,t[11]=y,t[12]=b):b=t[12];let x;t[13]===d.modeLabel?x=t[14]:(x=(0,W.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:d.modeLabel}),t[13]=d.modeLabel,t[14]=x);let S;t[15]===d.modeInherit?S=t[16]:(S=[`inherit`,d.modeInherit],t[15]=d.modeInherit,t[16]=S);let w;t[17]===d.modeAll?w=t[18]:(w=[`all`,d.modeAll],t[17]=d.modeAll,t[18]=w);let T;t[19]===d.modeAllowlist?T=t[20]:(T=[`allowlist`,d.modeAllowlist],t[19]=d.modeAllowlist,t[20]=T);let E;t[21]===d.modeDenylist?E=t[22]:(E=[`denylist`,d.modeDenylist],t[21]=d.modeDenylist,t[22]=E);let D;t[23]===d.modeOff?D=t[24]:(D=[`off`,d.modeOff],t[23]=d.modeOff,t[24]=D);let O;t[25]!==E||t[26]!==D||t[27]!==S||t[28]!==w||t[29]!==T?(O=[S,w,T,E,D],t[25]=E,t[26]=D,t[27]=S,t[28]=w,t[29]=T,t[30]=O):O=t[30];let k=O,A;t[31]!==s||t[32]!==n||t[33]!==c||t[34]!==k?(A=(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:k.map(e=>{let[t,r]=e;return(0,W.jsx)(`button`,{type:`button`,className:i(`rounded-lg border px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,n===t?`border-accent/35 bg-accent-soft text-accent-fg`:`border-edge-subtle bg-surface-panel text-fg hover:border-edge hover:bg-surface-hover/55`),disabled:s,onClick:()=>c(t),children:r},t)})}),t[31]=s,t[32]=n,t[33]=c,t[34]=k,t[35]=A):A=t[35];let j;t[36]!==A||t[37]!==x?(j=(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[x,A]}),t[36]=A,t[37]=x,t[38]=j):j=t[38];let M;t[39]!==a||t[40]!==m||t[41]!==s||t[42]!==d.catalogLoading||t[43]!==d.emptyCatalog||t[44]!==d.noDescription||t[45]!==d.quickActionsLabel||t[46]!==d.quickClear||t[47]!==d.quickSelectAll||t[48]!==o||t[49]!==l||t[50]!==f||t[51]!==r?(M=f?(0,W.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:d.quickActionsLabel}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(u,{type:`button`,variant:`secondary`,className:z,disabled:s||o||m.length===0,onClick:()=>l(new Set(m)),children:d.quickSelectAll}),(0,W.jsx)(u,{type:`button`,variant:`secondary`,className:z,disabled:s||o||r.size===0,onClick:()=>l(new Set),children:d.quickClear})]})]}),o?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d.catalogLoading}):a.length===0?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d.emptyCatalog}):(0,W.jsx)(`ul`,{className:`flex flex-col gap-2.5 text-sm`,children:a.map(e=>{let t=oe(e),n=r.has(t),a=typeof e.description==`string`?e.description.trim():``,o=a||d.noDescription;return(0,W.jsx)(`li`,{className:`h-16 shrink-0 overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel/60 px-3 dark:border-edge-subtle`,children:(0,W.jsxs)(`label`,{className:`flex h-full cursor-pointer items-center gap-3 text-sm`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`shrink-0 rounded border-edge`,checked:n,disabled:s,onChange:()=>{let e=new Set(r);n?e.delete(t):e.add(t),l(e)},"aria-label":t}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,W.jsx)(`div`,{className:`truncate font-mono text-xs font-medium text-fg`,title:t,children:t}),(0,W.jsx)(`p`,{className:i(`mt-0.5 truncate text-xs leading-tight text-fg-muted`,!a&&`italic text-fg-subtle`),title:o,children:o})]})]})},t)})})]}):null,t[39]=a,t[40]=m,t[41]=s,t[42]=d.catalogLoading,t[43]=d.emptyCatalog,t[44]=d.noDescription,t[45]=d.quickActionsLabel,t[46]=d.quickClear,t[47]=d.quickSelectAll,t[48]=o,t[49]=l,t[50]=f,t[51]=r,t[52]=M):M=t[52];let N;return t[53]!==j||t[54]!==M||t[55]!==b?(N=(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[b,j,M]}),t[53]=j,t[54]=M,t[55]=b,t[56]=N):N=t[56],N}var G=[`write_file`,`edit_file`,`shell`,`execute_code`],K=[`shell`,`execute_code`,`automation`,`extensions`,`bundle-mcp`,`skill_manage`],q=[`send_message`,`send_media`,`text_to_speech`,`create_share`],J=[`read_file`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`,`web_extract`],Y=[...G,...q],X=[`read_file`,`write_file`,`edit_file`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`],ce=[`send_message`,`send_media`];function le(e,t){let n={};for(let[r,i]of t)for(let t of r)e.has(t)&&(n[t]=i);return n}function ue(e){let t=(0,H.c)(92),{builtinToolIds:n,toolModes:r,onChange:a,disabled:o,getToolDescription:s,getGroupTitle:c,labels:l}=e,d;t[0]===n?d=t[1]:(d=new Set(n),t[0]=n,t[1]=d);let f=d,p;t[2]!==f||t[3]!==r?(p=Object.entries(r).filter(e=>{let[t]=e;return f.has(t)}).toSorted(Z),t[2]=f,t[3]=r,t[4]=p):p=t[4];let m=p,h;if(t[5]!==f||t[6]!==n){h=[];for(let e of ee){let t=e.toolIds.filter(e=>f.has(e));t.length>0&&h.push({key:e.key,ids:[...t]})}let e;t[8]===n?e=t[9]:(e=V(n),t[8]=n,t[9]=e);let r=e;if(r.length>0){let e;t[10]===r?e=t[11]:(e={key:`misc`,ids:r},t[10]=r,t[11]=e),h.push(e)}t[5]=f,t[6]=n,t[7]=h}else h=t[7];let g=h,_;t[12]!==a||t[13]!==r?(_=(e,t)=>{let n={...r};t===`inherit`?delete n[e]:n[e]=t,a(n)},t[12]=a,t[13]=r,t[14]=_):_=t[14];let v=_,y;t[15]!==f||t[16]!==a?(y=e=>{a(le(f,e))},t[15]=f,t[16]=a,t[17]=y):y=t[17];let b=y;if(n.length===0){let e;return t[18]===l.emptyBuiltin?e=t[19]:(e=(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.emptyBuiltin}),t[18]=l.emptyBuiltin,t[19]=e),e}let x;t[20]===l.quickActionsLabel?x=t[21]:(x=(0,W.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:l.quickActionsLabel}),t[20]=l.quickActionsLabel,t[21]=x);let S;t[22]===a?S=t[23]:(S=()=>a({}),t[22]=a,t[23]=S);let C;t[24]!==o||t[25]!==l.quickClearOverrides||t[26]!==S?(C=(0,W.jsx)(u,{type:`button`,variant:`secondary`,className:z,disabled:o,onClick:S,children:l.quickClearOverrides}),t[24]=o,t[25]=l.quickClearOverrides,t[26]=S,t[27]=C):C=t[27];let w;t[28]===b?w=t[29]:(w=()=>b([[G,`deny`]]),t[28]=b,t[29]=w);let T;t[30]!==o||t[31]!==l.quickReadOnlyWorkspace||t[32]!==w?(T=(0,W.jsx)(u,{type:`button`,variant:`secondary`,className:z,disabled:o,onClick:w,children:l.quickReadOnlyWorkspace}),t[30]=o,t[31]=l.quickReadOnlyWorkspace,t[32]=w,t[33]=T):T=t[33];let E;t[34]===b?E=t[35]:(E=()=>b([[K,`deny`]]),t[34]=b,t[35]=E);let D;t[36]!==o||t[37]!==l.quickHighRiskOff||t[38]!==E?(D=(0,W.jsx)(u,{type:`button`,variant:`secondary`,className:z,disabled:o,onClick:E,children:l.quickHighRiskOff}),t[36]=o,t[37]=l.quickHighRiskOff,t[38]=E,t[39]=D):D=t[39];let O;t[40]===b?O=t[41]:(O=()=>b([[q,`deny`]]),t[40]=b,t[41]=O);let k;t[42]!==o||t[43]!==l.quickNoOutbound||t[44]!==O?(k=(0,W.jsx)(u,{type:`button`,variant:`secondary`,className:z,disabled:o,onClick:O,children:l.quickNoOutbound}),t[42]=o,t[43]=l.quickNoOutbound,t[44]=O,t[45]=k):k=t[45];let A;t[46]===b?A=t[47]:(A=()=>b([[J,`allow`],[Y,`deny`]]),t[46]=b,t[47]=A);let j;t[48]!==o||t[49]!==l.quickResearchMode||t[50]!==A?(j=(0,W.jsx)(u,{type:`button`,variant:`secondary`,className:z,disabled:o,onClick:A,children:l.quickResearchMode}),t[48]=o,t[49]=l.quickResearchMode,t[50]=A,t[51]=j):j=t[51];let M;t[52]===b?M=t[53]:(M=()=>b([[X,`allow`],[ce,`deny`]]),t[52]=b,t[53]=M);let N;t[54]!==o||t[55]!==l.quickCodingMode||t[56]!==M?(N=(0,W.jsx)(u,{type:`button`,variant:`secondary`,className:z,disabled:o,onClick:M,children:l.quickCodingMode}),t[54]=o,t[55]=l.quickCodingMode,t[56]=M,t[57]=N):N=t[57];let P;t[58]!==D||t[59]!==k||t[60]!==j||t[61]!==N||t[62]!==C||t[63]!==T?(P=(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[C,T,D,k,j,N]}),t[58]=D,t[59]=k,t[60]=j,t[61]=N,t[62]=C,t[63]=T,t[64]=P):P=t[64];let F;t[65]!==P||t[66]!==x?(F=(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[x,P]}),t[65]=P,t[66]=x,t[67]=F):F=t[67];let I;t[68]===l.overrideSummaryTitle?I=t[69]:(I=(0,W.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:l.overrideSummaryTitle}),t[68]=l.overrideSummaryTitle,t[69]=I);let L;t[70]!==l.modeAllow||t[71]!==l.modeDeny||t[72]!==l.noOverrides||t[73]!==m?(L=m.length>0?(0,W.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:m.map(e=>{let[t,n]=e;return(0,W.jsxs)(`span`,{className:i(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 font-mono text-[11px]`,n===`deny`&&`border-red-500/25 bg-red-500/10 text-red-700 dark:text-red-300`,n===`allow`&&`border-accent/25 bg-accent/10 text-accent`),children:[t,(0,W.jsx)(`span`,{className:`font-sans opacity-80`,children:n===`allow`?l.modeAllow:l.modeDeny})]},t)})}):(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.noOverrides}),t[70]=l.modeAllow,t[71]=l.modeDeny,t[72]=l.noOverrides,t[73]=m,t[74]=L):L=t[74];let R;t[75]!==I||t[76]!==L?(R=(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/50 px-3 py-2`,children:[I,L]}),t[75]=I,t[76]=L,t[77]=R):R=t[77];let B;t[78]!==o||t[79]!==c||t[80]!==s||t[81]!==g||t[82]!==l.inheritedMode||t[83]!==l.modeAllow||t[84]!==l.modeDeny||t[85]!==v||t[86]!==r?(B=(0,W.jsx)(`div`,{className:`flex flex-col gap-5`,children:g.map(e=>{let{key:t,ids:n}=e;return(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:c(t)}),(0,W.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:n.map(e=>{let t=s(e),n=Object.prototype.hasOwnProperty.call(r,e)?r[e]:`inherit`;return(0,W.jsx)(`li`,{className:i(`rounded-xl border px-3 py-2.5 transition-colors dark:border-edge-subtle`,n===`inherit`?`border-edge-subtle bg-surface-panel/40`:`border-edge bg-surface-panel`),children:(0,W.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`font-mono text-xs font-medium text-fg`,children:e}),t?(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:t}):null]}),(0,W.jsx)(`div`,{className:`inline-flex w-fit rounded-lg border border-edge-subtle bg-surface-base p-0.5`,children:[`inherit`,`allow`,`deny`].map(t=>(0,W.jsx)(`button`,{type:`button`,className:i(`rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,n===t?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`),disabled:o,onClick:()=>v(e,t),children:t===`inherit`?l.inheritedMode:t===`allow`?l.modeAllow:l.modeDeny},t))})]})},e)})})]},t)})}),t[78]=o,t[79]=c,t[80]=s,t[81]=g,t[82]=l.inheritedMode,t[83]=l.modeAllow,t[84]=l.modeDeny,t[85]=v,t[86]=r,t[87]=B):B=t[87];let te;return t[88]!==F||t[89]!==R||t[90]!==B?(te=(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[F,R,B]}),t[88]=F,t[89]=R,t[90]=B,t[91]=te):te=t[91],te}function Z(e,t){let[n]=e,[r]=t;return n.localeCompare(r)}var de=[{id:`overview`,icon:f},{id:`models`,icon:D},{id:`tools`,icon:b},{id:`skills`,icon:h},{id:`impact`,icon:v}];function fe(e){return R(Object.entries(e?.models?.roles??{}).map(([e,t])=>({id:e,model:t.model,fallbacks:t.fallbacks??[],description:t.description})))}function pe(e){return Object.fromEntries(Object.entries(e?.tools?.builtin??{}).map(([e,t])=>[e,t.mode===`allow`?`allow`:`deny`]))}function Q(e){let t=e?.skills;if(!t)return new Set;let n=t.mode===`denylist`?t.deny:t.allow;return new Set(n??[])}function me(e){return{id:e?.id??``,name:e?.name??``,description:e?.description??``,version:String(e?.version??1),modelRows:fe(e),toolModes:pe(e),skillMode:e?.skills?.mode??`inherit`,skillPick:Q(e)}}function he(e,t){let n=B(e.modelRows);return n?.roles?{...t?.models?.defaultRole?{defaultRole:t.models.defaultRole}:{},roles:n.roles}:null}function $(e){let t=Object.fromEntries(Object.entries(e.toolModes).toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,{mode:t}]));return Object.keys(t).length>0?{builtin:t}:null}function ge(e){if(e.skillMode===`inherit`)return null;let t=[...e.skillPick].toSorted((e,t)=>e.localeCompare(t));return e.skillMode===`allowlist`?{mode:`allowlist`,allow:t}:e.skillMode===`denylist`?{mode:`denylist`,deny:t}:{mode:e.skillMode}}function _e(e,t){return{id:e.id.trim(),name:e.name.trim(),description:e.description.trim(),version:Number(e.version),models:he(e,t),tools:$(e),skills:ge(e)}}function ve(e){return e?{id:e.id,name:e.name,description:e.description??``,version:e.version,models:e.models?.roles?{...e.models.defaultRole?{defaultRole:e.models.defaultRole}:{},roles:e.models.roles}:null,tools:e.tools?.builtin&&Object.keys(e.tools.builtin).length>0?{builtin:e.tools.builtin}:null,skills:e.skills??{mode:`all`}}:null}function ye(e){return[e.models?.roles?`${Object.keys(e.models.roles).length} model roles`:``,e.tools?.builtin?`${Object.keys(e.tools.builtin).length} tool access settings`:``,e.skills?`skills: ${e.skills.mode}`:``].filter(Boolean).join(` · `)||`No shared settings yet`}function be(e){return e===`safe-coder`?{id:`safe-coder`,name:`Safe Coder`,description:`Shared settings for coding agents: code-oriented model roles, careful shell usage, and focused engineering skills.`,version:`1`,modelRows:[{id:`deep`,model:``,fallbacks:[],description:`Complex implementation and planning`},{id:`code`,model:``,fallbacks:[],description:`Code edits and tests`},{id:`review`,model:``,fallbacks:[],description:`Review and risk checks`}],toolModes:{shell:`deny`,send_message:`deny`,send_media:`deny`},skillMode:`allowlist`,skillPick:new Set([`diagnose`,`tdd`])}:e===`read-only`?{id:`read-only-research`,name:`Read-only Research`,description:`Shared settings for reading, searching, and summarizing without modifying files or running shell commands.`,version:`1`,modelRows:[{id:`deep`,model:``,fallbacks:[],description:`Synthesis and long-context reading`},{id:`fast`,model:``,fallbacks:[],description:`Quick summaries`}],toolModes:{write_file:`deny`,edit_file:`deny`,shell:`deny`,send_message:`deny`,send_media:`deny`},skillMode:`all`,skillPick:new Set}:e===`low-cost`?{id:`low-cost-assistant`,name:`Low-cost Assistant`,description:`Shared settings for lightweight agents that should prefer faster or cheaper model roles.`,version:`1`,modelRows:[{id:`deep`,model:``,fallbacks:[],description:`Default low-cost model`},{id:`fast`,model:``,fallbacks:[],description:`Low-latency replies`},{id:`cheap`,model:``,fallbacks:[],description:`Batch or summary work`}],toolModes:{},skillMode:`inherit`,skillPick:new Set}:{id:``,name:``,description:``,version:`1`,modelRows:[],toolModes:{},skillMode:`inherit`,skillPick:new Set}}function xe(){let e=a(o(e=>e.language)),t=e.capabilityPresetsSettings,n=!!s(e=>e.token),{data:r,error:C,isLoading:R,mutate:z}=c(n?`settings-capability-presets`:null,re,{revalidateOnFocus:!1}),{data:B=[],isLoading:ee}=c(n?`settings-capability-presets-skills-catalog`:null,d,{revalidateOnFocus:!1}),[V,H]=m(),[oe,G]=(0,U.useState)(``),[K,q]=(0,U.useState)(`overview`),[J,Y]=(0,U.useState)(()=>be(`blank`)),[X,ce]=(0,U.useState)(!1),[le,Z]=(0,U.useState)(null),fe=r?.presets??[],pe=r?.defaultPresetId??`default`,Q=fe.find(e=>e.id===pe)??null,he=fe.filter(e=>e.id!==pe),$=(0,U.useMemo)(()=>fe.find(e=>e.id===oe)??fe[0]??null,[fe,oe]),ge=!$||J.id.trim()!==$.id,xe=!!($&&$.id===pe),Ce=JSON.stringify(_e(J,$))!==JSON.stringify(ve($)),we=le??(C instanceof Error?C.message:null),Te=V.get(`action`)===`new`||!!V.get(`preset`),Ee=ge?t.newPreset:$?.name??t.editorTitle,De=t=>e.agentsSettings.toolsDisableGroups[t],Oe=t=>t in e.agentsSettings.toolDescriptions?e.agentsSettings.toolDescriptions[t]:``;(0,U.useEffect)(()=>{if(!r||X)return;if(V.get(`action`)===`new`){let e=V.get(`starter`);G(``),Y(be(e===`safe-coder`||e===`read-only`||e===`low-cost`?e:`blank`)),q(`overview`);return}let e=V.get(`preset`)?.trim(),t=e?r.presets.find(t=>t.id===e):null;if(t){G(t.id),Y(me(t)),q(V.get(`tab`)??`overview`);return}$&&(G($.id),Y(e=>e.id===$.id?e:me($)))},[X,r,V,$]);function ke(e){G(e.id),Y(me(e)),H({preset:e.id},{replace:!0}),q(`overview`)}function Ae(e){let t=be(e);G(``),Y(t),Z(null),H(e===`blank`?{action:`new`}:{action:`new`,starter:e},{replace:!0}),q(`overview`)}function je(){H({},{replace:!0}),Z(null),Y(me($)),q(`overview`)}async function Me(){let e=L(J.modelRows,{invalidId:t.invalidModelRoleId,duplicateId:t.duplicateModelRoleId,invalidModel:t.invalidModelRef});if(e){Z(e),q(`models`);return}ce(!0),Z(null);try{if(ge){let e=await ae({id:J.id.trim(),name:J.name.trim(),...J.description.trim()?{description:J.description.trim()}:{}}),t=e.presets,n=_e(J,null);(n.models||n.tools||n.skills)&&(t=await te(e.presetId,{version:n.version,models:n.models,tools:n.tools,skills:n.skills})),await z(t,{revalidate:!1}),G(e.presetId),H({preset:e.presetId},{replace:!0})}else if($){let e=_e(J,$);await z(await te($.id,{name:e.name,description:e.description||null,version:e.version,models:e.models,tools:e.tools,skills:e.skills}),{revalidate:!1})}}catch(e){Z(e instanceof Error?e.message:t.saveError)}finally{ce(!1)}}async function Ne(){if($){ce(!0),Z(null);try{let e=await ne($.id);await z(e,{revalidate:!1});let t=e.presets[0]??null;G(t?.id??``),Y(me(t)),H(t?{preset:t.id}:{},{replace:!0})}catch(e){Z(e instanceof Error?e.message:t.saveError)}finally{ce(!1)}}}return n?(0,W.jsxs)(I,{gap:`gap-5`,className:`pb-24`,children:[(0,W.jsx)(F,{title:t.title,subtitle:t.subtitle,actions:(0,W.jsxs)(u,{type:`button`,onClick:()=>Ae(`blank`),disabled:X,children:[(0,W.jsx)(_,{className:`size-4`,"aria-hidden":!0}),t.newPreset]})}),we?(0,W.jsx)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:we}):null,R?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.loading}):(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,W.jsxs)(P,{children:[(0,W.jsx)(N,{icon:_,title:t.newPreset,subtitle:t.editorHint}),(0,W.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:[`blank`,`safe-coder`,`read-only`,`low-cost`].map(e=>(0,W.jsxs)(`button`,{type:`button`,className:`min-h-28 rounded-lg border border-edge-subtle bg-surface-panel px-4 py-3 text-left text-sm text-fg transition-colors hover:border-edge hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>Ae(e),children:[(0,W.jsx)(`span`,{className:`font-medium`,children:t.starters[e].title}),(0,W.jsx)(`span`,{className:`mt-2 block text-xs leading-relaxed text-fg-muted`,children:t.starters[e].description})]},e))})]}),Q?(0,W.jsxs)(P,{children:[(0,W.jsx)(N,{icon:D,title:t.globalDefaultsTitle,subtitle:t.globalDefaultsHint}),(0,W.jsxs)(`button`,{type:`button`,onClick:()=>ke(Q),className:`group rounded-lg border border-accent/25 bg-accent/5 px-4 py-3 text-left text-fg transition-colors hover:border-accent/40 hover:bg-accent/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:Q.name}),(0,W.jsx)(`span`,{className:`rounded-full border border-accent/25 bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-accent`,children:t.globalDefaultsBadge})]}),(0,W.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-subtle`,children:Q.id})]}),(0,W.jsx)(`span`,{className:`shrink-0 rounded-full border border-edge-subtle bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.globalDefaultsInherited})]}),Q.description?(0,W.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:Q.description}):null,(0,W.jsx)(`div`,{className:`mt-3 text-xs text-fg-subtle`,children:ye(Q)})]})]}):null,(0,W.jsxs)(P,{children:[(0,W.jsx)(N,{icon:D,title:t.listTitle,subtitle:t.listHint}),he.length===0?(0,W.jsx)(`div`,{className:`rounded-lg border border-dashed border-edge-subtle px-3 py-4 text-sm text-fg-muted`,children:t.empty}):(0,W.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:he.map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>ke(e),className:`group min-h-36 rounded-lg border border-edge-subtle bg-surface-panel px-4 py-3 text-left text-fg transition-colors hover:border-edge hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:e.name}),(0,W.jsx)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-fg-subtle`,children:e.id})]}),(0,W.jsx)(`span`,{className:`shrink-0 rounded-full border border-edge-subtle px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.usage.length})]}),e.description?(0,W.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:e.description}):null,(0,W.jsx)(`div`,{className:`mt-3 truncate text-xs text-fg-subtle`,children:ye(e)})]},e.id))})]})]}),(0,W.jsx)(x,{open:Te,onOpenChange:e=>{e||je()},children:(0,W.jsxs)(E,{children:[(0,W.jsx)(A,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim`,S)}),(0,W.jsx)(j,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(90vh,760px)] w-[min(100%-2rem,64rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,M),onOpenAutoFocus:e=>e.preventDefault(),children:(0,W.jsxs)(T,{layer:`modal`,children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(k,{className:`truncate text-base font-semibold text-fg`,children:Ee}),(0,W.jsx)(O,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:ge?t.editorHint:J.id})]}),(0,W.jsx)(w,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:i(g,`shrink-0 p-1.5 hover:bg-surface-base`),"aria-label":t.closeDialog,children:(0,W.jsx)(p,{className:`size-4`,"aria-hidden":!0})})})]}),we?(0,W.jsx)(`div`,{className:`mx-4 mt-3 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:we}):null,(0,W.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-2 border-b border-edge-subtle bg-surface-base px-4 py-2 dark:border-edge`,children:de.map(({id:e,icon:n})=>(0,W.jsxs)(`button`,{type:`button`,className:i(`inline-flex items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,K===e?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>q(e),children:[(0,W.jsx)(n,{className:`size-4`,"aria-hidden":!0}),t.tabs[e]]},e))}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-4`,children:(0,W.jsxs)(`div`,{className:`mx-auto max-w-4xl`,children:[K===`overview`?(0,W.jsxs)(P,{children:[(0,W.jsx)(N,{icon:f,title:t.overviewTitle,subtitle:t.overviewHint}),(0,W.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:t.idLabel}),(0,W.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:J.id,disabled:X||!ge,onChange:e=>Y(t=>({...t,id:e.target.value.toLowerCase()})),placeholder:`safe-coder`})]}),(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:t.versionLabel}),(0,W.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:J.version,disabled:X,inputMode:`numeric`,onChange:e=>Y(t=>({...t,version:e.target.value}))})]}),(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:t.nameLabel}),(0,W.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:J.name,disabled:X,onChange:e=>Y(t=>({...t,name:e.target.value})),placeholder:t.namePlaceholder})]}),(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,W.jsx)(`span`,{className:`font-medium text-fg`,children:t.descriptionLabel}),(0,W.jsx)(`textarea`,{className:`min-h-24 w-full resize-y rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:J.description,disabled:X,onChange:e=>Y(t=>({...t,description:e.target.value})),placeholder:t.descriptionPlaceholder})]})]}),(0,W.jsxs)(`div`,{className:`mt-5 grid gap-2 sm:grid-cols-3`,children:[(0,W.jsx)(Se,{icon:D,label:t.modelsTitle,value:String(J.modelRows.length)}),(0,W.jsx)(Se,{icon:b,label:t.toolsTitle,value:String(Object.keys(J.toolModes).length)}),(0,W.jsx)(Se,{icon:h,label:t.skillsTitle,value:t.skillModeLabels[J.skillMode]})]})]}):null,K===`models`?(0,W.jsxs)(P,{children:[(0,W.jsx)(N,{icon:D,title:t.modelsTitle,subtitle:t.modelsHint}),(0,W.jsx)(ie,{rows:J.modelRows,onChange:e=>Y(t=>({...t,modelRows:e})),disabled:X,defaultRole:$?.models?.defaultRole,chat:e.chat,labels:{id:t.modelRoleIdLabel,description:t.modelRoleDescriptionLabel,primaryModel:t.modelPrimaryModelLabel,fallbackModels:t.modelFallbackModelsLabel,addFallback:t.modelAddFallback,removeFallback:t.modelRemoveFallback,fallbackPlaceholder:t.modelFallbackPlaceholder,fallbackEmptyHint:t.modelFallbackEmptyHint,add:t.addModelRole,remove:t.removeModelRole,recommendedTitle:t.modelRecommendedTitle,customTitle:t.modelCustomTitle,defaultBadge:t.modelDefaultBadge,addPurpose:t.addModelPurpose,noCustomRoles:t.noCustomModelRoles,idPlaceholder:`deep`,descriptionPlaceholder:t.modelRoleDescriptionPlaceholder,roleNames:t.modelRoleNames,roleDescriptions:t.modelRoleDescriptions}})]}):null,K===`tools`?(0,W.jsxs)(P,{children:[(0,W.jsx)(N,{icon:b,title:t.toolsTitle,subtitle:t.toolsHint}),(0,W.jsx)(ue,{builtinToolIds:r?.builtinToolIds??[],toolModes:J.toolModes,onChange:e=>Y(t=>({...t,toolModes:e})),disabled:X,getToolDescription:Oe,getGroupTitle:De,labels:{quickActionsLabel:t.toolsQuickActionsLabel,quickClearOverrides:t.toolsQuickClearOverrides,quickReadOnlyWorkspace:t.toolsQuickReadOnlyWorkspace,quickHighRiskOff:t.toolsQuickHighRiskOff,quickNoOutbound:t.toolsQuickNoOutbound,quickResearchMode:t.toolsQuickResearchMode,quickCodingMode:t.toolsQuickCodingMode,emptyBuiltin:t.toolsEmptyBuiltin,overrideSummaryTitle:t.toolsOverrideSummaryTitle,noOverrides:t.toolsNoOverrides,inheritedMode:t.toolModes.inherit,modeAllow:t.toolModes.allow,modeDeny:t.toolModes.deny}})]}):null,K===`skills`?(0,W.jsxs)(P,{children:[(0,W.jsx)(N,{icon:h,title:t.skillsTitle,subtitle:t.skillsHint}),(0,W.jsx)(se,{mode:J.skillMode,selected:J.skillPick,catalog:B,loading:ee,disabled:X,onModeChange:e=>Y(t=>({...t,skillMode:e})),onSelectedChange:e=>Y(t=>({...t,skillPick:e})),labels:{modeLabel:t.skillsModeLabel,modeInherit:t.skillsModeInherit,modeAll:t.skillsModeAll,modeAllowlist:t.skillsModeAllowlist,modeDenylist:t.skillsModeDenylist,modeOff:t.skillsModeOff,quickActionsLabel:t.skillsQuickActionsLabel,quickSelectAll:t.skillsQuickSelectAll,quickClear:t.skillsQuickClear,catalogLoading:t.skillsCatalogLoading,emptyCatalog:t.skillsEmptyCatalog,noDescription:t.skillsNoDescription,overrideSummaryTitle:t.skillsOverrideSummaryTitle,inheritSummary:t.skillsInheritSummary,allSummary:t.skillsAllSummary,offSummary:t.skillsOffSummary,allowSummary:t.skillsAllowSummary,denySummary:t.skillsDenySummary}})]}):null,K===`impact`?(0,W.jsxs)(P,{children:[(0,W.jsx)(N,{icon:v,title:t.usageTitle,subtitle:t.usageHint}),$?.usage.length?(0,W.jsx)(`div`,{className:`grid gap-2`,children:$.usage.map(e=>(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.agentName||e.agentId}),(0,W.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-muted`,children:e.agentId})]},e.agentId))}):(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noUsage})]}):null]})}),(0,W.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 border-t border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 text-sm`,children:[(0,W.jsx)(`div`,{className:`font-medium text-fg`,children:Ce?t.unsavedTitle:t.noUnsavedTitle}),(0,W.jsx)(`div`,{className:`text-xs text-fg-muted`,children:Ce?($?.usage.length??0)>0?t.unsavedImpact.replace(`{{count}}`,String($?.usage.length??0)):t.unsavedNoImpact:t.noUnsavedHint})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Ce?(0,W.jsx)(u,{type:`button`,variant:`secondary`,disabled:X,onClick:()=>Y(me($)),children:t.discard}):null,$&&!xe?(0,W.jsxs)(u,{type:`button`,variant:`secondary`,disabled:X,onClick:()=>void Ne(),children:[(0,W.jsx)(l,{className:`size-4`,"aria-hidden":!0}),t.delete]}):null,(0,W.jsxs)(u,{type:`button`,disabled:X||!J.id.trim()||!J.name.trim()||!Ce,onClick:()=>void Me(),children:[(0,W.jsx)(y,{className:`size-4`,"aria-hidden":!0}),t.savePreset]})]})]})]})})]})})]}):(0,W.jsxs)(I,{gap:`gap-3`,children:[(0,W.jsx)(F,{title:t.title}),(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})]})}function Se(e){let t=(0,H.c)(10),{icon:n,label:r,value:i}=e,a;t[0]===n?a=t[1]:(a=(0,W.jsx)(n,{className:`size-3.5`,"aria-hidden":!0}),t[0]=n,t[1]=a);let o;t[2]!==r||t[3]!==a?(o=(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[a,r]}),t[2]=r,t[3]=a,t[4]=o):o=t[4];let s;t[5]===i?s=t[6]:(s=(0,W.jsx)(`div`,{className:`mt-1 text-sm font-medium text-fg`,children:i}),t[5]=i,t[6]=s);let c;return t[7]!==o||t[8]!==s?(c=(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}export{xe as CapabilityPresetsSettingsPanel};