@xopcai/xopc 0.0.415 → 0.0.416

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 (251) hide show
  1. package/dist/browser-ext/_locales/en/messages.json +4 -1
  2. package/dist/browser-ext/_locales/zh_CN/messages.json +4 -1
  3. package/dist/browser-ext/dist/assets/{page-context-MuzjMBlJ.js → page-context-CVvmTWZb.js} +33 -9
  4. package/dist/browser-ext/dist/background.js +39 -10
  5. package/dist/browser-ext/dist/sidepanel.html +1 -1
  6. package/dist/browser-ext/dist/sidepanel.js +22 -3
  7. package/dist/browser-ext/manifest.json +1 -1
  8. package/dist/extensions/telegram/xopc.extension.json +1 -1
  9. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CJFwitU2.js → agent-avatar-dicebear-CufU7cqe.js} +1 -1
  10. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-DHDAcss8.js +1 -0
  11. package/dist/gateway/static/root/assets/agents-BV3dAoa0.js +77 -0
  12. package/dist/gateway/static/root/assets/{app-management-settings-panel-DgwqNi5i.js → app-management-settings-panel-D4-n1uBg.js} +1 -1
  13. package/dist/gateway/static/root/assets/{appearance-settings-C0wJfFyz.js → appearance-settings-Cgn4eNsX.js} +1 -1
  14. package/dist/gateway/static/root/assets/apps-page-BOYzD7Zz.js +1 -0
  15. package/dist/gateway/static/root/assets/{archive-plugin-Ch7wolHE.js → archive-plugin-B4btCsiV.js} +1 -1
  16. package/dist/gateway/static/root/assets/{automations-page-DK7AU79v.js → automations-page-yb1EL_3N.js} +1 -1
  17. package/dist/gateway/static/root/assets/automations-workspace-J7LJ4RuV.js +8 -0
  18. package/dist/gateway/static/root/assets/{binary-plugins-B4HcHYsC.js → binary-plugins-DQT9e258.js} +1 -1
  19. package/dist/gateway/static/root/assets/{block-editor-BQAWEZF-.js → block-editor-B50rU9tL.js} +4 -4
  20. package/dist/gateway/static/root/assets/browser-automations-page-BiQz6lJA.js +3 -0
  21. package/dist/gateway/static/root/assets/browser-settings-page-W9kuxBbE.js +3 -0
  22. package/dist/gateway/static/root/assets/capabilities-page-iXe87MdG.js +2 -0
  23. package/dist/gateway/static/root/assets/capabilities-settings-panel-CRLSXe7Z.js +8 -0
  24. package/dist/gateway/static/root/assets/{capability-header-actions-D4Yq35fD.js → capability-header-actions-BMnbzHms.js} +1 -1
  25. package/dist/gateway/static/root/assets/channels-CrRJkOKX.js +1 -0
  26. package/dist/gateway/static/root/assets/{chat-terminal-dock-zdMySdMm.js → chat-terminal-dock-Bd3af4gL.js} +2 -2
  27. package/dist/gateway/static/root/assets/{computer-settings-page-C5Z6Jr0p.js → computer-settings-page-DXfqy7xh.js} +1 -1
  28. package/dist/gateway/static/root/assets/{connector-service-page-Cxus0qrZ.js → connector-service-page-B-cw0CPU.js} +1 -1
  29. package/dist/gateway/static/root/assets/connectors-page-DbFxc0Fd.js +1 -0
  30. package/dist/gateway/static/root/assets/{date-picker-DuyyD6jz.js → date-picker-CqzXevH6.js} +1 -1
  31. package/dist/gateway/static/root/assets/{dependency-picker-BZN72rrk.js → dependency-picker-pgT4Gyaf.js} +1 -1
  32. package/dist/gateway/static/root/assets/{desktop-pet-settings-BcyP7Z6v.js → desktop-pet-settings-Dy_-i2L8.js} +1 -1
  33. package/dist/gateway/static/root/assets/{desktop-pet-BtvTIDCi.js → desktop-pet-zICeqw9c.js} +1 -1
  34. package/dist/gateway/static/root/assets/device-pairing-wizard-ByGbxqkg.js +1 -0
  35. package/dist/gateway/static/root/assets/{directory-picker-path-field-DOusKz-O.js → directory-picker-path-field-C-aQ7qoM.js} +1 -1
  36. package/dist/gateway/static/root/assets/{extension-debug-page-Bt4FwsFu.js → extension-debug-page-2NwpYkS5.js} +1 -1
  37. package/dist/gateway/static/root/assets/{extension-page-0vsxX3FB.js → extension-page-y9J0z7_Q.js} +1 -1
  38. package/dist/gateway/static/root/assets/{extension-settings-page-5Pt5_ELc.js → extension-settings-page-BtowusUh.js} +1 -1
  39. package/dist/gateway/static/root/assets/gateway-realtime-C52ghnBK.js +1 -0
  40. package/dist/gateway/static/root/assets/gateway-settings-BYSKzUMR.js +1 -0
  41. package/dist/gateway/static/root/assets/highlight-code-Cz6eeDH5.js +1 -0
  42. package/dist/gateway/static/root/assets/{highlighted-body-KQOG7T2V-Cbk7eMlg.js → highlighted-body-KQOG7T2V-BiAa8HKC.js} +1 -1
  43. package/dist/gateway/static/root/assets/home-page-Cd1BjYHj.js +2 -0
  44. package/dist/gateway/static/root/assets/{image-generation-api-CAS8QVla.js → image-generation-api-gBFro48x.js} +1 -1
  45. package/dist/gateway/static/root/assets/{imports-page-BCLBYzV1.js → imports-page-BZQpXgjj.js} +1 -1
  46. package/dist/gateway/static/root/assets/index-Cy16gQST.css +1 -0
  47. package/dist/gateway/static/root/assets/index-DRyGCING.js +710 -0
  48. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CM_kt5XN.js → keyboard-shortcuts-settings-CYunR34k.js} +1 -1
  49. package/dist/gateway/static/root/assets/local-app-workbench-page-B_Ac1lly.js +1 -0
  50. package/dist/gateway/static/root/assets/{local-apps-page-BTSOChhk.js → local-apps-page-w-J5bY02.js} +1 -1
  51. package/dist/gateway/static/root/assets/logs-page-Dnjvvx2i.js +2 -0
  52. package/dist/gateway/static/root/assets/management-settings-w1EDwgLW.js +1 -0
  53. package/dist/gateway/static/root/assets/{media-plugins-DYQDjCVQ.js → media-plugins-CIx1koXw.js} +1 -1
  54. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-DISkHmEC.js +1 -0
  55. package/dist/gateway/static/root/assets/note-detail-panel-CNkxMTFU.js +5 -0
  56. package/dist/gateway/static/root/assets/note-image-lightbox-D5GH2wuC.js +1 -0
  57. package/dist/gateway/static/root/assets/notes-page-DZgKqFBG.js +8 -0
  58. package/dist/gateway/static/root/assets/{page-context-capture-button-DVn_dU83.js → page-context-capture-button-DusR2Itk.js} +1 -1
  59. package/dist/gateway/static/root/assets/personal-page-CR5JFkQ9.js +1 -0
  60. package/dist/gateway/static/root/assets/{personal-settings-panel-C16Iqe7X.js → personal-settings-panel-B7undvlr.js} +1 -1
  61. package/dist/gateway/static/root/assets/phone-model-picker-fWDltRUJ.js +1 -0
  62. package/dist/gateway/static/root/assets/phone-settings-page-CsOirAiy.js +1 -0
  63. package/dist/gateway/static/root/assets/plugin-details-dialog-BOBVIB3j.js +1 -0
  64. package/dist/gateway/static/root/assets/{preview-open-alternatives-RlHk76TI.js → preview-open-alternatives-CMxjsKSw.js} +1 -1
  65. package/dist/gateway/static/root/assets/{product-open-page-Dh-HqLrE.js → product-open-page-CrlyJx5M.js} +1 -1
  66. package/dist/gateway/static/root/assets/{product-preview-content-c3K-4DWc.js → product-preview-content-B-Jhzi7W.js} +1 -1
  67. package/dist/gateway/static/root/assets/project-detail-page-DoYUbtcI.js +7 -0
  68. package/dist/gateway/static/root/assets/{projects-page-B8HAt9sD.js → projects-page-xGQd9oAZ.js} +1 -1
  69. package/dist/gateway/static/root/assets/refresh-cw-BRlGaq2w.js +1 -0
  70. package/dist/gateway/static/root/assets/remote-access-hub-Gs0Xkws9.js +1 -0
  71. package/dist/gateway/static/root/assets/runtime-tools-settings-panel-Bwg7U7TR.js +1 -0
  72. package/dist/gateway/static/root/assets/{schema-form-CXO1B1k4.js → schema-form-ByzTNR_C.js} +1 -1
  73. package/dist/gateway/static/root/assets/{session-manager-CA1NkTR_.js → session-manager-B_h0jlLb.js} +1 -1
  74. package/dist/gateway/static/root/assets/sessions-page-XzK1ftbR.js +1 -0
  75. package/dist/gateway/static/root/assets/settings-advanced-gate-D_8Mvnog.js +1 -0
  76. package/dist/gateway/static/root/assets/{settings-form-section-BQxKmbbJ.js → settings-form-section-Brgd8IOV.js} +1 -1
  77. package/dist/gateway/static/root/assets/{settings-page-DvVMpKiA.js → settings-page-B6Mv02eg.js} +1 -1
  78. package/dist/gateway/static/root/assets/settings-page-header-BWyxJKOG.js +1 -0
  79. package/dist/gateway/static/root/assets/{settings-page-layout-B20AfmFG.js → settings-page-layout-DLHcS-0T.js} +1 -1
  80. package/dist/gateway/static/root/assets/setup-status-panel-DSCj5yis.js +1 -0
  81. package/dist/gateway/static/root/assets/{share-preview-page-XgZk8Oa1.js → share-preview-page-DF8Of0aZ.js} +1 -1
  82. package/dist/gateway/static/root/assets/shares-settings-DXNPe4Tl.js +1 -0
  83. package/dist/gateway/static/root/assets/{skill-api-CV-WT2hj.js → skill-api-CKCDCHLq.js} +1 -1
  84. package/dist/gateway/static/root/assets/skill-reload-api-BH0WF6Br.js +1 -0
  85. package/dist/gateway/static/root/assets/skills-page-DFWMVRW4.js +2 -0
  86. package/dist/gateway/static/root/assets/system-settings-panel-DB-ttubV.js +1 -0
  87. package/dist/gateway/static/root/assets/task-detail-page-BJY7c8wb.js +2 -0
  88. package/dist/gateway/static/root/assets/{task-result-evidence-D-gGKNX9.js → task-result-evidence-B-vt1BgK.js} +1 -1
  89. package/dist/gateway/static/root/assets/{tracing-settings-page-CQw3G-FB.js → tracing-settings-page-Dt51Z_ws.js} +1 -1
  90. package/dist/gateway/static/root/assets/{tunnel-api-B2HnCi0U.js → tunnel-api-Dok3t7Qe.js} +1 -1
  91. package/dist/gateway/static/root/assets/usage-page-lJym5G7F.js +1 -0
  92. package/dist/gateway/static/root/assets/{use-autosave-Dc0nwUpX.js → use-autosave-D4EMIB-V.js} +1 -1
  93. package/dist/gateway/static/root/assets/user-model-page-BXdNkITp.js +2 -0
  94. package/dist/gateway/static/root/assets/{voice-api-key-field-BSWXZkGa.js → voice-api-key-field-CO3KuanA.js} +1 -1
  95. package/dist/gateway/static/root/assets/{work-discovery-overlay-H3cdwq3l.js → work-discovery-overlay-BJRtgQM3.js} +1 -1
  96. package/dist/gateway/static/root/assets/wrench-DFb4r8bH.js +1 -0
  97. package/dist/gateway/static/root/assets/xopc-cloud-account-card-CS-_GxHV.js +1 -0
  98. package/dist/gateway/static/root/browser-setup-test.html +5 -0
  99. package/dist/gateway/static/root/browser-setup-test.js +7 -0
  100. package/dist/gateway/static/root/index.html +7 -4
  101. package/dist/package.js +1 -1
  102. package/dist/packages/gateway-contract/src/browser-setup.js +6 -0
  103. package/dist/packages/gateway-contract/src/index.js +4 -0
  104. package/dist/packages/gateway-contract/src/phone-setup.js +6 -0
  105. package/dist/packages/realtime-client/src/index.js +1 -0
  106. package/dist/packages/realtime-protocol/src/index.js +1 -0
  107. package/dist/src/agent/agent-manager.d.ts +4 -0
  108. package/dist/src/agent/agent-manager.js +12 -1
  109. package/dist/src/agent/embedded/tool-search-extension.js +14 -1
  110. package/dist/src/agent/service.d.ts +1 -0
  111. package/dist/src/agent/service.js +5 -0
  112. package/dist/src/agent/service.types.d.ts +2 -0
  113. package/dist/src/agent/tool-manuals/phone.d.ts +1 -1
  114. package/dist/src/agent/tool-manuals/phone.js +1 -1
  115. package/dist/src/agent/tool-manuals/xopc-configuration.d.ts +2 -0
  116. package/dist/src/agent/tool-manuals/xopc-configuration.js +25 -0
  117. package/dist/src/agent/tools/browser/tool/browser-use-tool.d.ts +2 -0
  118. package/dist/src/agent/tools/browser/tool/browser-use-tool.js +6 -2
  119. package/dist/src/agent/tools/factory.d.ts +3 -0
  120. package/dist/src/agent/tools/factory.js +11 -1
  121. package/dist/src/agent/tools/phone-use-tool.d.ts +1 -0
  122. package/dist/src/agent/tools/phone-use-tool.js +9 -1
  123. package/dist/src/agent/tools/tool-manual-tool.d.ts +1 -1
  124. package/dist/src/agent/tools/tool-manual-tool.js +3 -1
  125. package/dist/src/agent/tools/toolExposure.js +3 -0
  126. package/dist/src/agent/tools/xopc-use-tool.d.ts +4 -2
  127. package/dist/src/agent/tools/xopc-use-tool.js +40 -2
  128. package/dist/src/browser/drivers/browser-driver.d.ts +2 -2
  129. package/dist/src/browser/drivers/extension-driver.d.ts +2 -2
  130. package/dist/src/browser/drivers/extension-driver.js +6 -3
  131. package/dist/src/browser/providers/browser-ext-install.js +2 -1
  132. package/dist/src/browser/runtime/browser-runtime.d.ts +4 -1
  133. package/dist/src/browser/runtime/browser-runtime.js +29 -17
  134. package/dist/src/browser/setup/repository.d.ts +5 -0
  135. package/dist/src/browser/setup/repository.js +42 -0
  136. package/dist/src/browser/setup/service.d.ts +152 -0
  137. package/dist/src/browser/setup/service.js +404 -0
  138. package/dist/src/browser/setup/types.d.ts +38 -0
  139. package/dist/src/browser/setup/types.js +1 -0
  140. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  141. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  142. package/dist/src/config/schema.d.ts +2 -0
  143. package/dist/src/connectors/connected-source-understanding.js +1 -1
  144. package/dist/src/connectors/learning-coordinator.js +1 -1
  145. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  146. package/dist/src/gateway/hono/routes/browser-setup.d.ts +3 -0
  147. package/dist/src/gateway/hono/routes/browser-setup.js +114 -0
  148. package/dist/src/gateway/hono/routes/browser.d.ts +2 -1
  149. package/dist/src/gateway/hono/routes/browser.js +1 -1
  150. package/dist/src/gateway/hono/routes/connectors.js +7 -7
  151. package/dist/src/gateway/hono/routes/home.js +1 -1
  152. package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
  153. package/dist/src/gateway/hono/routes/phone-dependencies.js +1 -1
  154. package/dist/src/gateway/hono/routes/phone-setup.d.ts +7 -0
  155. package/dist/src/gateway/hono/routes/phone-setup.js +162 -0
  156. package/dist/src/gateway/hono/routes/phone.js +3 -7
  157. package/dist/src/gateway/hono/routes/public-gateway.js +3 -1
  158. package/dist/src/gateway/provider-model-setup.js +1 -1
  159. package/dist/src/gateway/service/config-coordinator.d.ts +2 -0
  160. package/dist/src/gateway/service.d.ts +5 -0
  161. package/dist/src/gateway/service.js +57 -12
  162. package/dist/src/gateway/xopc-cloud-capability-setup.js +7 -1
  163. package/dist/src/home-intelligence/host.js +2 -2
  164. package/dist/src/infra/update-restart.js +1 -1
  165. package/dist/src/phone/adb-driver.d.ts +2 -0
  166. package/dist/src/phone/adb-driver.js +35 -17
  167. package/dist/src/phone/contracts.d.ts +40 -0
  168. package/dist/src/phone/contracts.js +17 -4
  169. package/dist/src/phone/model-adapter.d.ts +59 -2
  170. package/dist/src/phone/model-adapter.js +107 -13
  171. package/dist/src/phone/numeric-entry.d.ts +31 -0
  172. package/dist/src/phone/numeric-entry.js +126 -0
  173. package/dist/src/phone/planning.d.ts +27 -0
  174. package/dist/src/phone/planning.js +79 -0
  175. package/dist/src/phone/recovery.d.ts +37 -0
  176. package/dist/src/phone/recovery.js +81 -0
  177. package/dist/src/phone/repository.d.ts +1 -0
  178. package/dist/src/phone/repository.js +3 -0
  179. package/dist/src/phone/runtime.js +232 -54
  180. package/dist/src/phone/semantic-controls.d.ts +13 -0
  181. package/dist/src/phone/semantic-controls.js +76 -0
  182. package/dist/src/phone/setup/service.d.ts +148 -0
  183. package/dist/src/phone/setup/service.js +251 -0
  184. package/dist/src/providers/presentation.js +2 -2
  185. package/dist/src/providers/xopc-cloud-model-source.js +6 -2
  186. package/dist/src/realtime/runtime.js +1 -1
  187. package/dist/src/storage/sqlite/schema.d.ts +2 -2
  188. package/dist/src/storage/sqlite/schema.js +7 -7
  189. package/dist/src/storage/sqlite/schema.sql +10 -0
  190. package/dist/src/storage/sqlite/upgrades/260_browser_setup.sql +9 -0
  191. package/dist/src/user-context/sources/index.js +1 -1
  192. package/dist/src/work-discovery/service.js +2 -2
  193. package/package.json +6 -6
  194. package/skills/tools/configure-xopc/SKILL.md +47 -0
  195. package/skills/tools/configure-xopc/references/browser/acceptance.md +31 -0
  196. package/skills/tools/configure-xopc/references/browser/chrome-extension.md +19 -0
  197. package/skills/tools/configure-xopc/references/browser/overview.md +22 -0
  198. package/skills/tools/configure-xopc/references/browser/permissions.md +25 -0
  199. package/skills/tools/configure-xopc/references/browser/troubleshooting.md +24 -0
  200. package/skills/tools/configure-xopc/references/phone/acceptance.md +25 -0
  201. package/skills/tools/configure-xopc/references/phone/aliyun.md +29 -0
  202. package/skills/tools/configure-xopc/references/phone/dependencies.md +18 -0
  203. package/skills/tools/configure-xopc/references/phone/local.md +19 -0
  204. package/skills/tools/configure-xopc/references/phone/models.md +18 -0
  205. package/skills/tools/configure-xopc/references/phone/overview.md +30 -0
  206. package/skills/tools/configure-xopc/references/phone/troubleshooting.md +24 -0
  207. package/skills/tools/configure-xopc/references/scene-index.md +12 -0
  208. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-DclyJr1N.js +0 -1
  209. package/dist/gateway/static/root/assets/agents-jhErNtzi.js +0 -77
  210. package/dist/gateway/static/root/assets/apps-page-C0LcnI4h.js +0 -1
  211. package/dist/gateway/static/root/assets/automations-workspace-CBxiV34x.js +0 -8
  212. package/dist/gateway/static/root/assets/browser-automations-page-vJIrTxdi.js +0 -3
  213. package/dist/gateway/static/root/assets/browser-settings-page-in5Roh_E.js +0 -3
  214. package/dist/gateway/static/root/assets/capabilities-page-CiGx8wpQ.js +0 -2
  215. package/dist/gateway/static/root/assets/capabilities-settings-panel-a8kqjzQu.js +0 -8
  216. package/dist/gateway/static/root/assets/channels-C_CxcjKT.js +0 -1
  217. package/dist/gateway/static/root/assets/connectors-page-DCBO2CxK.js +0 -1
  218. package/dist/gateway/static/root/assets/device-pairing-wizard-Ctbgr50F.js +0 -1
  219. package/dist/gateway/static/root/assets/gateway-realtime-DkWCHVzI.js +0 -1
  220. package/dist/gateway/static/root/assets/gateway-settings-BsVOcmV5.js +0 -1
  221. package/dist/gateway/static/root/assets/highlight-code-C8eS9949.js +0 -1
  222. package/dist/gateway/static/root/assets/home-page-BZDZnmyc.js +0 -2
  223. package/dist/gateway/static/root/assets/index-Bys6njTY.js +0 -710
  224. package/dist/gateway/static/root/assets/index-Vsf0bj5e.css +0 -1
  225. package/dist/gateway/static/root/assets/local-app-workbench-page-Dk87jtcc.js +0 -1
  226. package/dist/gateway/static/root/assets/logs-page-D3gVdm8S.js +0 -2
  227. package/dist/gateway/static/root/assets/management-settings-BQNYFE4J.js +0 -1
  228. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-ChweJKTv.js +0 -1
  229. package/dist/gateway/static/root/assets/note-detail-panel-CYKwUCte.js +0 -5
  230. package/dist/gateway/static/root/assets/note-image-lightbox-BTSZb9ZT.js +0 -1
  231. package/dist/gateway/static/root/assets/notes-page-CJ5nhWfL.js +0 -8
  232. package/dist/gateway/static/root/assets/personal-page-DcW14lqn.js +0 -1
  233. package/dist/gateway/static/root/assets/phone-dependencies-card-D3l9uPFM.js +0 -1
  234. package/dist/gateway/static/root/assets/phone-model-picker-DOv38vBn.js +0 -1
  235. package/dist/gateway/static/root/assets/phone-settings-page-DUHp1q_9.js +0 -1
  236. package/dist/gateway/static/root/assets/plugin-details-dialog-BpfgDlVa.js +0 -1
  237. package/dist/gateway/static/root/assets/project-detail-page-GD8TxKad.js +0 -7
  238. package/dist/gateway/static/root/assets/remote-access-hub-D3el7lHK.js +0 -1
  239. package/dist/gateway/static/root/assets/runtime-tools-settings-panel-Dbskk6RG.js +0 -1
  240. package/dist/gateway/static/root/assets/sessions-page-07liaSHH.js +0 -1
  241. package/dist/gateway/static/root/assets/settings-advanced-gate-BGjU8rfN.js +0 -1
  242. package/dist/gateway/static/root/assets/settings-page-header-CYpuTXUW.js +0 -1
  243. package/dist/gateway/static/root/assets/setup-status-panel-DKo_VTx-.js +0 -1
  244. package/dist/gateway/static/root/assets/shares-settings-BODFqK8k.js +0 -1
  245. package/dist/gateway/static/root/assets/skill-reload-api-Ce6OUk2C.js +0 -1
  246. package/dist/gateway/static/root/assets/skills-page-B7ehOIML.js +0 -2
  247. package/dist/gateway/static/root/assets/system-settings-panel-CxJkZRT4.js +0 -1
  248. package/dist/gateway/static/root/assets/task-detail-page-CxRR0QuW.js +0 -2
  249. package/dist/gateway/static/root/assets/usage-page-uUEkO38r.js +0 -1
  250. package/dist/gateway/static/root/assets/user-model-page-ICUutbKL.js +0 -2
  251. package/dist/gateway/static/root/assets/xopc-cloud-account-card-CvT_W6YS.js +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{l as i,m as a,t as o,u as s}from"./chunk-KS7C4IRE-BvcCCgTW.js";import{t as c}from"./ellipsis-0k4rZLoy.js";import{t as l}from"./external-link-DjqjBmc3.js";import{t as u}from"./loader-circle-CifKLtgG.js";import{t as d}from"./messages-BYq0cPbn.js";import{t as f}from"./cn-0WouolD0.js";import{l as p,n as m}from"./locale-store-B7s2Hb35.js";import{a as h,i as g}from"./vendor-swr-BIWyz7Rc.js";import{t as _}from"./button-aIC072nz.js";import{t as v}from"./skeleton-BI5TyibZ.js";import{o as y}from"./gateway-realtime-DkWCHVzI.js";import{$a as b,A as x,Ad as S,As as C,Bc as w,D as T,El as E,F as D,Hc as O,Ic as k,Jc as A,O as j,P as M,R as N,Rc as P,Ua as F,Ul as I,Vc as L,Yd as R,aa as z,al as B,ao as V,ca as H,eo as U,il as ee,j as W,k as G,lc as te,ma as K,no as ne,nu as re,oa as q,sa as J,to as Y,ua as X,wl as ie,yo as ae,z as Z,zc as oe,zd as se}from"./index-Bys6njTY.js";import{n as ce,t as le}from"./capability-header-actions-D4Yq35fD.js";import{n as ue,r as de,t as fe}from"./plugin-presentation-CO5BFDGW.js";var pe=n(),me=`grid auto-rows-fr grid-cols-[repeat(auto-fill,minmax(min(100%,18rem),1fr))] items-stretch gap-4`,he=`relative h-full min-w-0 rounded-xl border border-edge bg-surface-panel p-4 transition-colors hover:border-edge-strong hover:bg-surface-hover/30`,ge=`absolute inset-0 cursor-pointer rounded-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,Q=e(t(),1);function _e(e){return e===`builtin`||e===`user`?e:`marketplace`}var $=r();function ve(e,t){let n=e.find(e=>e.id===t||e.pluginId===t||e.provenance?.packageName===t);return n?n.source===`bundled`?`bundled`:`user`:`absent`}var ye={debounced:``,detailPkg:null,quickInstallPkg:null,rowBusy:null,actionError:null,restartHint:null};function be({className:e,query:t}){let n=s(),r=i(),a=m(e=>e.language),o=d(a).extensionsPage,c=p(e=>!!e.conversationId),l=b(),{mutate:_}=h(),[x,C]=(0,Q.useReducer)(K,ye),{debounced:w,detailPkg:E,quickInstallPkg:O,rowBusy:k,actionError:A,restartHint:j}=x,M=c?`marketplace-${w}`:null;(0,Q.useEffect)(()=>{let e=window.setTimeout(()=>C({type:`patch`,patch:{debounced:t.trim()}}),300);return()=>window.clearTimeout(e)},[t]);let{data:P,isLoading:F,error:I}=g(M,()=>T(w),{revalidateOnFocus:!1}),L=(0,Q.useCallback)(()=>{_(`gateway-extensions-list`),y()},[_]),R=(0,Q.useCallback)(async(e,t)=>{C({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let n=await G({name:e,overwrite:t});L(),n.requiresGatewayRestart&&C({type:`patch`,patch:{restartHint:o.marketplaceRestartHint}})}catch(e){throw C({type:`patch`,patch:{actionError:e instanceof Error?e.message:o.marketplaceInstallFailed}}),e}finally{C({type:`patch`,patch:{rowBusy:null}})}},[o.marketplaceInstallFailed,o.marketplaceRestartHint,L]),z=(0,Q.useCallback)(async e=>{C({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let t=await W(e);L(),t.requiresGatewayRestart&&C({type:`patch`,patch:{restartHint:o.marketplaceRestartHint}})}catch(e){throw C({type:`patch`,patch:{actionError:e instanceof Error?e.message:o.marketplaceUninstallFailed}}),e}finally{C({type:`patch`,patch:{rowBusy:null}})}},[o.marketplaceRestartHint,o.marketplaceUninstallFailed,L]),V=P??[];return(0,$.jsxs)(`div`,{className:f(`flex flex-col gap-4`,e),children:[I?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:I instanceof Error?I.message:o.marketplaceLoadFailed}):null,A?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:A}):null,j?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:j}):null,F&&!P?(0,$.jsx)(`ul`,{className:me,"aria-label":o.marketplaceLoading,children:[0,1,2,3,4,5].map(e=>(0,$.jsxs)(`li`,{className:`rounded-xl border border-edge bg-surface-panel p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(v,{className:`size-10 shrink-0 rounded-xl`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,$.jsx)(v,{className:`h-5 w-full`}),(0,$.jsx)(v,{className:`h-3 w-2/3`})]}),(0,$.jsx)(v,{className:`h-9 w-16 shrink-0 rounded-lg`})]}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,$.jsx)(v,{className:`h-4 w-full`}),(0,$.jsx)(v,{className:`h-4 w-full`}),(0,$.jsx)(v,{className:`h-4 w-2/3`})]})]},e))}):(0,$.jsx)(`ul`,{className:me,children:V.length===0?(0,$.jsx)(`li`,{className:`col-span-full text-sm text-fg-muted`,children:o.marketplaceEmpty}):V.map(e=>{let t=ve(l,e.id),i=k===e.id,s=l.find(t=>t.pluginId===e.id||t.provenance?.packageName===e.id),c=e.localizations?.[a.startsWith(`zh`)?`zh-CN`:`en`],d=c?.displayName??e.name,p=c?.description??e.description;return(0,$.jsxs)(`li`,{className:he,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":`${d}, ${o.marketplaceDetailTitle}`,onClick:()=>s?.pluginId?n(N(s.pluginId,`installed`,!1,r.pathname+r.search)):C({type:`patch`,patch:{detailPkg:e.id}}),className:ge}),(0,$.jsxs)(`div`,{className:`pointer-events-none relative flex items-start gap-3`,children:[(0,$.jsx)(D,{iconUrl:e.branding?.iconUrl,fallback:re}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1.5`,children:[(0,$.jsx)(`h3`,{className:`line-clamp-2 break-words font-semibold leading-snug text-fg`,title:d,children:d}),e.verified?(0,$.jsx)(S,{className:`mt-0.5 size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null]}),(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-subtle`,children:[e.version?(0,$.jsxs)(`span`,{children:[`v`,e.version]}):null,t===`user`?(0,$.jsx)(`span`,{className:s&&de(s)?`text-amber-700 dark:text-amber-400`:`text-fg-muted`,children:s&&de(s)?a.startsWith(`zh`)?`需要授权`:`Authorization required`:o.marketplaceInstalled}):null]})]}),(0,$.jsx)(`div`,{role:`group`,className:`pointer-events-auto relative z-10 flex max-w-[45%] shrink-0 items-start`,children:t===`bundled`?(0,$.jsx)(`span`,{className:`rounded-md bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:o.marketplaceBuiltin}):t===`user`?(0,$.jsx)($.Fragment,{children:e.packageType===`plugin`?(0,$.jsx)(`button`,{type:`button`,onClick:()=>s?.pluginId&&fe(s)?n(Z(d,a.startsWith(`zh`))):s?.pluginId?n(N(s.pluginId,`installed`,de(s),r.pathname+r.search)):C({type:`patch`,patch:{detailPkg:e.id,quickInstallPkg:null}}),className:f(`inline-flex items-center justify-center 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`),children:s&&de(s)?a.startsWith(`zh`)?`去授权`:`Connect account`:s&&fe(s)?a.startsWith(`zh`)?`开始使用`:`Start using`:a.startsWith(`zh`)?`管理插件`:`Manage plugin`}):(0,$.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{window.confirm(o.marketplaceUninstallConfirm)&&z(e.id).catch(()=>{})},className:f(`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:[i?(0,$.jsx)(u,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(B,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),o.marketplaceUninstall]})}):(0,$.jsx)(`button`,{type:`button`,onClick:()=>C({type:`patch`,patch:e.packageType===`plugin`?{detailPkg:e.id,quickInstallPkg:e.id}:{detailPkg:e.id,quickInstallPkg:null}}),className:f(`inline-flex min-w-16 items-center justify-center rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg`,`transition-[transform,background-color] active:scale-[0.98]`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:e.packageType===`plugin`?a.startsWith(`zh`)?`安装`:`Install`:o.marketplaceReview})})]}),p?(0,$.jsx)(`p`,{className:`pointer-events-none relative mt-3 line-clamp-3 text-sm leading-relaxed text-fg-muted`,children:p}):null,(e.categories?.length??0)>0?(0,$.jsx)(`div`,{className:`pointer-events-none relative mt-3 flex flex-wrap gap-1.5`,children:e.categories?.map(e=>(0,$.jsx)(`span`,{className:`max-w-full truncate rounded-md border border-edge px-2 py-0.5 text-xs text-fg-muted`,children:e},e))}):null]},e.id)})}),E?(0,$.jsx)(xe,{packageName:E,autoInstall:O===E,copy:o,extensions:l,onClose:()=>C({type:`patch`,patch:{detailPkg:null,quickInstallPkg:null}}),onInstall:R,onUninstall:z}):null]})}function xe(e){let t=(0,pe.c)(98),{packageName:n,autoInstall:r,copy:i,extensions:a,onClose:s,onInstall:c,onUninstall:l}=e,[d,m]=(0,Q.useState)(!1),[h,_]=(0,Q.useState)(!1),y=p(Ee)?`ext-mp-detail-${n}`:null,b;t[0]===n?b=t[1]:(b=async()=>j(n),t[0]=n,t[1]=b);let x;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(x={revalidateOnFocus:!1},t[2]=x):x=t[2];let{data:S,error:C,isLoading:T}=g(y,b,x),E;t[3]!==a||t[4]!==n?(E=ve(a,n),t[3]=a,t[4]=n,t[5]=E):E=t[5];let D=E,N=D===`user`,F=S?.manifest?.permissions,I,z,V,H,U,W,G,K,ne,re,q,J;if(t[6]!==r||t[7]!==i||t[8]!==S||t[9]!==C||t[10]!==a||t[11]!==D||t[12]!==T||t[13]!==s||t[14]!==n||t[15]!==F||t[16]!==h){W=Symbol.for(`react.early_return_sentinel`);bb0:{let e=F&&typeof F==`object`&&!Array.isArray(F)?Object.entries(F):[],o;t[29]!==i||t[30]!==S?(o=S?.readme?.trim()||(S?.description?.trim()?`### ${S.name}\n\n${S.description}`:`*${i.marketplaceNoReadme}*`),t[29]=i,t[30]=S,t[31]=o):o=t[31];let c=o;if(S?.format===`agent-plugin`){let e;if(t[32]!==S||t[33]!==a||t[34]!==n){let r;t[36]!==S||t[37]!==n?(r=e=>e.provenance?.packageName===n||e.pluginId===S.manifest?.name,t[36]=S,t[37]=n,t[38]=r):r=t[38],e=a.find(r),t[32]=S,t[33]=a,t[34]=n,t[35]=e}else e=t[35];let i=`store:${n}`,o;t[39]!==r||t[40]!==S||t[41]!==s||t[42]!==e||t[43]!==i?(o=(0,$.jsx)(M,{extension:e,initialSource:i,marketplace:S,autoInstall:r,onClose:s}),t[39]=r,t[40]=S,t[41]=s,t[42]=e,t[43]=i,t[44]=o):o=t[44],W=o;break bb0}V=k,H=!0,t[45]===s?U=t[46]:(U=e=>!e&&s(),t[45]=s,t[46]=U),z=L,t[47]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,$.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[47]=J):J=t[47],I=P,ne=`xopc-dialog-content fixed left-1/2 top-1/2 z-[131] flex h-[min(44rem,calc(100vh-1.5rem))] 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-overlay`,re=Te;let l;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(R,{className:`size-5`}),t[48]=l):l=t[48];let u;t[49]!==i.detailBack||t[50]!==s?(u=(0,$.jsx)(`button`,{type:`button`,onClick:s,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":i.detailBack,children:l}),t[49]=i.detailBack,t[50]=s,t[51]=u):u=t[51];let d;t[52]===i.marketplaceDetailTitle?d=t[53]:(d=(0,$.jsx)(O,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:i.marketplaceDetailTitle}),t[52]=i.marketplaceDetailTitle,t[53]=d);let f;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(A,{className:`size-5`}),t[54]=f):f=t[54];let p;t[55]!==i.detailClose||t[56]!==s?(p=(0,$.jsx)(`button`,{type:`button`,onClick:s,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":i.detailClose,children:f}),t[55]=i.detailClose,t[56]=s,t[57]=p):p=t[57],t[58]!==u||t[59]!==d||t[60]!==p?(q=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[u,d,p]}),t[58]=u,t[59]=d,t[60]=p,t[61]=q):q=t[61],G=`min-h-0 flex-1 overflow-y-auto p-5`,K=T&&!S?(0,$.jsxs)(`div`,{className:`space-y-4`,"aria-label":i.marketplaceLoading,children:[(0,$.jsx)(v,{className:`h-6 w-48`}),(0,$.jsx)(v,{className:`h-4 w-28`}),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsx)(v,{className:`h-12`}),(0,$.jsx)(v,{className:`h-12`})]}),(0,$.jsx)(v,{className:`h-28 w-full`}),(0,$.jsx)(v,{className:`h-36 w-full`})]}):C?(0,$.jsxs)(`div`,{className:`rounded-lg border border-red-300/70 bg-red-50 p-4 text-sm dark:border-red-900 dark:bg-red-950/30`,children:[(0,$.jsx)(`p`,{className:`font-medium text-red-700 dark:text-red-300`,children:i.marketplaceDetailLoadFailed}),(0,$.jsx)(`p`,{className:`mt-1 break-words text-red-600 dark:text-red-400`,children:C instanceof Error?C.message:i.marketplaceLoadFailed})]}):S?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:S.name}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,$.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:S.id})}),(0,$.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-fg`,children:i.marketplaceAuthor}),(0,$.jsx)(`dd`,{children:S.author.username})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-fg`,children:i.marketplaceVersion}),(0,$.jsx)(`dd`,{children:S.latestVersion.version})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-fg`,children:i.marketplaceDownloads}),(0,$.jsx)(`dd`,{children:S.downloads})]})]}),D===`bundled`?null:(0,$.jsxs)(`section`,{className:`mt-5 space-y-3 rounded-lg border border-edge bg-surface-base p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[S.installability.available?(0,$.jsx)(ie,{className:`mt-0.5 size-5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-hidden":!0}):(0,$.jsx)(ee,{className:`mt-0.5 size-5 shrink-0 text-amber-600 dark:text-amber-400`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:S.installability.available?i.marketplaceRiskTitle:i.marketplaceUnavailableTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:S.installability.available?i.marketplaceCodeRisk:S.installability.reason??i.marketplaceUnavailableBody})]})]}),S.installability.available?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`dl`,{className:`grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-fg`,children:i.marketplaceIntegrity}),(0,$.jsx)(`dd`,{children:i.marketplaceIntegrityVerified})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`font-medium text-fg`,children:i.marketplaceDependencies}),(0,$.jsx)(`dd`,{children:S.packageSummary?.dependencyCount??0})]})]}),(0,$.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:i.marketplacePermissions}),e.length>0?(0,$.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.map(we)}):(0,$.jsx)(`p`,{className:`mt-1`,children:i.marketplacePermissionsNone})]}),(S.packageSummary?.lifecycleScripts.length??0)>0?(0,$.jsxs)(`p`,{className:`text-xs leading-relaxed text-amber-700 dark:text-amber-300`,children:[i.marketplaceLifecycleScripts,`: `,S.packageSummary?.lifecycleScripts.join(`, `)]}):null,(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>_(e.target.checked),className:`mt-0.5 size-4 rounded border-edge accent-[var(--color-accent)]`}),(0,$.jsx)(`span`,{children:i.marketplaceRiskConfirm})]})]}):null]}),S.readme?.trim()?(0,$.jsx)(`h4`,{className:`mb-2 mt-6 text-sm font-semibold text-fg`,children:i.marketplaceDetailReadmeHeading}):null,(0,$.jsx)(`div`,{className:`markdown-content min-w-0 break-words text-sm`,children:(0,$.jsx)(te,{content:c})})]}):null}t[6]=r,t[7]=i,t[8]=S,t[9]=C,t[10]=a,t[11]=D,t[12]=T,t[13]=s,t[14]=n,t[15]=F,t[16]=h,t[17]=I,t[18]=z,t[19]=V,t[20]=H,t[21]=U,t[22]=W,t[23]=G,t[24]=K,t[25]=ne,t[26]=re,t[27]=q,t[28]=J}else I=t[17],z=t[18],V=t[19],H=t[20],U=t[21],W=t[22],G=t[23],K=t[24],ne=t[25],re=t[26],q=t[27],J=t[28];if(W!==Symbol.for(`react.early_return_sentinel`))return W;let Y;t[62]!==G||t[63]!==K?(Y=(0,$.jsx)(`div`,{className:G,children:K}),t[62]=G,t[63]=K,t[64]=Y):Y=t[64];let X;t[65]!==d||t[66]!==i.marketplaceBuiltinGoBuiltin||t[67]!==i.marketplaceBuiltinManageHint||t[68]!==i.marketplaceInstall||t[69]!==i.marketplaceReinstall||t[70]!==i.marketplaceReinstallConfirm||t[71]!==i.marketplaceUninstall||t[72]!==i.marketplaceUninstallConfirm||t[73]!==S||t[74]!==D||t[75]!==s||t[76]!==c||t[77]!==l||t[78]!==n||t[79]!==h||t[80]!==N?(X=S?(0,$.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:D===`bundled`?(0,$.jsxs)(`div`,{className:`flex w-full flex-col items-stretch gap-2`,children:[(0,$.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:i.marketplaceBuiltinManageHint}),(0,$.jsx)(o,{to:`/capabilities/extensions?tab=builtin`,onClick:s,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:i.marketplaceBuiltinGoBuiltin})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{type:`button`,disabled:d||!S.installability.available||!h,onClick:()=>{N&&!window.confirm(i.marketplaceReinstallConfirm)||(m(!0),c(n,N).catch(Ce).finally(()=>m(!1)))},className:f(`inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium`,`bg-accent text-on-accent 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:[d?(0,$.jsx)(u,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,N?i.marketplaceReinstall:i.marketplaceInstall]}),N?(0,$.jsxs)(`button`,{type:`button`,disabled:d,onClick:()=>{window.confirm(i.marketplaceUninstallConfirm)&&(m(!0),l(n).then(()=>s()).catch(Se).finally(()=>m(!1)))},className:f(`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,$.jsx)(B,{className:`size-4 shrink-0`,"aria-hidden":!0}),i.marketplaceUninstall]}):null]})}):null,t[65]=d,t[66]=i.marketplaceBuiltinGoBuiltin,t[67]=i.marketplaceBuiltinManageHint,t[68]=i.marketplaceInstall,t[69]=i.marketplaceReinstall,t[70]=i.marketplaceReinstallConfirm,t[71]=i.marketplaceUninstall,t[72]=i.marketplaceUninstallConfirm,t[73]=S,t[74]=D,t[75]=s,t[76]=c,t[77]=l,t[78]=n,t[79]=h,t[80]=N,t[81]=X):X=t[81];let ae;t[82]!==I||t[83]!==Y||t[84]!==X||t[85]!==ne||t[86]!==re||t[87]!==q?(ae=(0,$.jsxs)(I,{className:ne,onOpenAutoFocus:re,children:[q,Y,X]}),t[82]=I,t[83]=Y,t[84]=X,t[85]=ne,t[86]=re,t[87]=q,t[88]=ae):ae=t[88];let Z;t[89]!==z||t[90]!==ae||t[91]!==J?(Z=(0,$.jsxs)(z,{children:[J,ae]}),t[89]=z,t[90]=ae,t[91]=J,t[92]=Z):Z=t[92];let oe;return t[93]!==V||t[94]!==H||t[95]!==U||t[96]!==Z?(oe=(0,$.jsx)(V,{defaultOpen:H,onOpenChange:U,children:Z}),t[93]=V,t[94]=H,t[95]=U,t[96]=Z,t[97]=oe):oe=t[97],oe}function Se(){}function Ce(){}function we(e){let[t,n]=e;return(0,$.jsxs)(`li`,{className:`break-words`,children:[(0,$.jsx)(`code`,{children:t}),`: `,Array.isArray(n)?n.join(`, `):String(n)]},t)}function Te(e){return e.preventDefault()}function Ee(e){return!!e.conversationId}function De({embedded:e=!1,onHeaderActionChange:t}){let n=s(),r=i(),l=m(e=>e.language),u=d(l),p=V(e=>e.setPageHeader),h=V(e=>e.clearPageHeader),g=b(),v=U(),[y,x]=a(),S=_e(y.get(`tab`)??(g.some(e=>e.source!==`bundled`)?`user`:null)),w=(0,Q.useRef)(!1),T=y.get(`q`)??``,[E,D]=(0,Q.useState)(S),[O,k]=(0,Q.useState)(T),[A,j]=(0,Q.useState)(null),[P,F]=(0,Q.useState)(!1),L=y.toString(),R=(0,Q.useRef)(L);if(R.current!==L){R.current=L;let e=_e(y.get(`tab`)),t=y.get(`q`)??``;D(t=>t===e?t:e),k(e=>e===t?e:t)}(0,Q.useEffect)(()=>{x(e=>{let t=new URLSearchParams(e),n=O.trim();return n?t.set(`q`,n):t.delete(`q`),E===`marketplace`?t.delete(`tab`):t.set(`tab`,E),t.toString()===e.toString()?e:t},{replace:!0})},[E,O,x]);let B=(0,Q.useMemo)(()=>g.filter(e=>e.source===`bundled`),[g]),ee=(0,Q.useMemo)(()=>g.filter(e=>e.source!==`bundled`),[g]);(0,Q.useEffect)(()=>{v||w.current||(w.current=!0,!y.has(`tab`)&&ee.length&&D(`user`))},[v,y,ee.length]);let W=E===`builtin`?B:ee,G=(0,Q.useMemo)(()=>{let e=O.trim().toLowerCase(),t=W;return e&&(t=t.filter(t=>(t.name??``).toLowerCase().includes(e)||t.id.toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e))),t.toSorted((e,t)=>e.hasUi===t.hasUi?(e.name||e.id).localeCompare(t.name||t.id,l):e.hasUi?-1:1)},[W,O,l]);(0,Q.useEffect)(()=>{j(e=>{if(!e)return e;let t=g.find(t=>t.id===e.id);return t?Oe(e)===Oe(t)&&e.active===t.active&&JSON.stringify(e)===JSON.stringify(t)?e:t:null})},[g]);let te=(0,Q.useMemo)(()=>({searchLabel:E===`marketplace`?u.extensionsPage.marketplaceSearchPlaceholder:u.extensionsPage.searchPlaceholder,search:(0,$.jsx)(ce,{value:O,onChange:k,placeholder:E===`marketplace`?u.extensionsPage.marketplaceSearchPlaceholder:u.extensionsPage.searchPlaceholder}),overflow:(0,$.jsxs)(H,{children:[(0,$.jsx)(X,{asChild:!0,children:(0,$.jsx)(_,{variant:`secondary`,className:`size-9 shrink-0 p-0`,"aria-label":u.capabilitiesHub.moreActions,title:u.capabilitiesHub.moreActions,children:(0,$.jsx)(c,{className:`size-4`,"aria-hidden":!0})})}),(0,$.jsx)(J,{children:(0,$.jsxs)(z,{align:`end`,sideOffset:6,className:`z-50 min-w-48 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:[(0,$.jsxs)(q,{className:f(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,C.transition),onSelect:()=>F(!0),children:[(0,$.jsx)(I,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),l.startsWith(`zh`)?`安装插件`:`Install plugin`]}),(0,$.jsx)(q,{asChild:!0,children:(0,$.jsxs)(o,{to:`/local-apps`,className:f(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,C.transition),children:[(0,$.jsx)(se,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),u.extensionsPage.openLocalApps]})})]})})]}),primary:(0,$.jsx)(_,{asChild:!0,variant:`primary`,className:`h-9 shrink-0`,children:(0,$.jsxs)(o,{to:`/local-apps/new`,"aria-label":u.extensionsPage.createLocalApp,children:[(0,$.jsx)(I,{className:`size-4`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:u.extensionsPage.createLocalApp})]})})}),[l,u.capabilitiesHub.moreActions,u.extensionsPage,E,O]);(0,Q.useLayoutEffect)(()=>e?(t?.(te),()=>t?.(null)):(p({startExtra:null,main:(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:u.extensionsPage.title})}),end:(0,$.jsx)(le,{contribution:te})}),()=>h()),[h,e,te,u.extensionsPage.title,t,p]);let K=[{id:`user`,label:u.extensionsPage.tabUser,count:v?void 0:ee.length},{id:`marketplace`,label:u.extensionsPage.tabMarketplace},{id:`builtin`,label:u.extensionsPage.tabBuiltin,count:v?void 0:B.length}];return(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,$.jsxs)(`div`,{className:f(`mx-auto w-full max-w-7xl px-4 sm:px-6 lg:px-8`,`pb-7 pt-3 lg:pb-9 lg:pt-4`),children:[(0,$.jsx)(`div`,{className:`mb-6 border-b border-edge-subtle pb-3`,children:(0,$.jsx)(ae,{items:K,activeTab:E,onChange:D,ariaLabel:u.extensionsPage.extensionsNavAria,tabIdPrefix:`extensions-tab`,panelIdPrefix:`extensions-panel`,className:`flex-wrap`})}),E===`marketplace`?(0,$.jsx)(be,{query:O}):v?(0,$.jsx)(Fe,{}):E===`builtin`&&B.length===0?(0,$.jsx)(Le,{message:u.extensionsPage.emptyBuiltin}):E===`user`&&ee.length===0?(0,$.jsx)(Le,{message:u.extensionsPage.emptyUser}):G.length===0?(0,$.jsx)(`p`,{className:`px-3 py-14 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:u.extensionsPage.noSearchResults}):(0,$.jsx)(`div`,{className:me,children:G.map(e=>(0,$.jsx)(je,{extension:e,copy:u.extensionsPage,onOpen:()=>e.pluginId?n(N(e.pluginId,`installed`,!1,r.pathname+r.search)):j(e)},e.id))})]}),A?A.format===`agent-plugin`?(0,$.jsx)(M,{extension:A,onClose:()=>j(null)},A.id):(0,$.jsx)(Ne,{extension:A,copy:u.extensionsPage,onClose:()=>j(null)},A.id):null,P?(0,$.jsx)(M,{onClose:()=>F(!1)}):null]})}function Oe(e){return e.activationEligible??e.active}function ke(e,t){return e.source===`bundled`?t.providerBundled:e.source===`global`?t.providerGlobal:e.source===`workspace`?t.providerWorkspace:t.providerOther}function Ae(e,t){let n=Oe(e);return n&&e.active?t.runStateLive:n&&!e.active?t.runStatePendingOn:!n&&e.active?t.runStatePendingOff:t.runStateOff}function je(e){let t=(0,pe.c)(56),{extension:n,copy:r,onOpen:a}=e,o=m(Me),c,l;t[0]!==n||t[1]!==o?(l=o.startsWith(`zh`),c=ue(n,l),t[0]=n,t[1]=o,t[2]=c,t[3]=l):(c=t[2],l=t[3]);let u=c,d;t[4]===n?d=t[5]:(d=de(n),t[4]=n,t[5]=d);let f=d,p=n.localizations?.[l?`zh-CN`:`en`]?.description??n.description,h=s(),g=i(),_;t[6]===n?_=t[7]:(_=!!n.pluginId&&fe(n),t[6]=n,t[7]=_);let v=_,y=f?l?`去授权`:`Connect account`:v?l?`开始使用`:`Start using`:l?`管理插件`:`Manage plugin`,b;t[8]!==v||t[9]!==n.pluginId||t[10]!==g||t[11]!==u||t[12]!==h||t[13]!==f||t[14]!==a||t[15]!==l?(b=()=>{v?h(Z(u,l)):f&&n.pluginId?h(N(n.pluginId,`installed`,!0,g.pathname+g.search)):a()},t[8]=v,t[9]=n.pluginId,t[10]=g,t[11]=u,t[12]=h,t[13]=f,t[14]=a,t[15]=l,t[16]=b):b=t[16];let x=b,C=`${u}, ${r.marketplaceDetailTitle}`,w;t[17]!==a||t[18]!==C?(w=(0,$.jsx)(`button`,{type:`button`,"aria-label":C,onClick:a,className:ge}),t[17]=a,t[18]=C,t[19]=w):w=t[19];let T=n.branding?.iconUrl,E;t[20]===T?E=t[21]:(E=(0,$.jsx)(D,{iconUrl:T,fallback:se}),t[20]=T,t[21]=E);let O;t[22]===u?O=t[23]:(O=(0,$.jsx)(`h2`,{className:`line-clamp-2 break-words font-semibold leading-snug text-fg`,title:u,children:u}),t[22]=u,t[23]=O);let k;t[24]===n.provenance?.publisherVerification?k=t[25]:(k=n.provenance?.publisherVerification===`verified`?(0,$.jsx)(S,{className:`mt-0.5 size-3.5 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null,t[24]=n.provenance?.publisherVerification,t[25]=k);let A;t[26]!==O||t[27]!==k?(A=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1.5`,children:[O,k]}),t[26]=O,t[27]=k,t[28]=A):A=t[28];let j;t[29]===n.version?j=t[30]:(j=n.version?(0,$.jsxs)(`span`,{children:[`v`,n.version]}):null,t[29]=n.version,t[30]=j);let M=f?`text-amber-700 dark:text-amber-400`:`text-fg-muted`,P=f?l?`需要授权`:`Authorization required`:Oe(n)?r.statusEnabled:r.runStateOff,F;t[31]!==M||t[32]!==P?(F=(0,$.jsx)(`span`,{className:M,children:P}),t[31]=M,t[32]=P,t[33]=F):F=t[33];let I;t[34]!==j||t[35]!==F?(I=(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-subtle`,children:[j,F]}),t[34]=j,t[35]=F,t[36]=I):I=t[36];let L;t[37]!==A||t[38]!==I?(L=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[A,I]}),t[37]=A,t[38]=I,t[39]=L):L=t[39];let R;t[40]!==y||t[41]!==x?(R=(0,$.jsx)(`div`,{className:`pointer-events-auto relative z-10 flex max-w-[45%] shrink-0 items-start`,children:(0,$.jsx)(`button`,{type:`button`,onClick:x,className:`inline-flex items-center justify-center rounded-lg border border-edge px-3 py-2 text-xs font-medium text-fg transition-colors hover:bg-surface-hover active:scale-[0.98] active:bg-surface-hover/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:y})}),t[40]=y,t[41]=x,t[42]=R):R=t[42];let z;t[43]!==L||t[44]!==R||t[45]!==E?(z=(0,$.jsxs)(`div`,{className:`pointer-events-none relative flex items-start gap-3`,children:[E,L,R]}),t[43]=L,t[44]=R,t[45]=E,t[46]=z):z=t[46];let B;t[47]!==r.cardNoDescription||t[48]!==p?(B=p?.trim()||r.cardNoDescription,t[47]=r.cardNoDescription,t[48]=p,t[49]=B):B=t[49];let V;t[50]===B?V=t[51]:(V=(0,$.jsx)(`p`,{className:`pointer-events-none relative mt-3 line-clamp-3 text-sm leading-relaxed text-fg-muted`,children:B}),t[50]=B,t[51]=V);let H;return t[52]!==z||t[53]!==V||t[54]!==w?(H=(0,$.jsxs)(`article`,{className:he,children:[w,z,V]}),t[52]=z,t[53]=V,t[54]=w,t[55]=H):H=t[55],H}function Me(e){return e.language}function Ne({extension:e,copy:t,onClose:n}){let{mutate:r}=h(),[i,a]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(null),[d,p]=(0,Q.useState)(!1),m=e.activationEligible===!0,g=(0,Q.useCallback)(async()=>{c(null),p(!1),a(`toggle`);try{let{requiresGatewayRestart:t}=await x({extensionId:e.id,enabled:!m});await r(`gateway-extensions-list`),y(),p(t)}catch(e){c(e instanceof Error?e.message:t.extensionToggleFailed)}finally{a(null)}},[m,t.extensionToggleFailed,e.id,r]),v=(0,Q.useCallback)(async()=>{if(!(e.source===`bundled`||!window.confirm(t.extensionUninstallConfirm))){c(null),p(!1),a(`uninstall`);try{await W(e.id),await r(`gateway-extensions-list`),y(),n()}catch(e){c(e instanceof Error?e.message:t.marketplaceUninstallFailed),a(null)}}},[t.extensionUninstallConfirm,t.marketplaceUninstallFailed,e.id,e.source,r,n]),b=e.ui?.contributions?.pages??[],S=e.ui?.contributions?.settingsPanels??[],C=e.ui?.contributions?.chatWidgets??[],T=b.find(e=>e.showInNav)??b[0],D=S[0],j=T?F(e.id,T):null,M=D?`/settings/ext/${e.id}/${D.id}`:e.hasConfigSchema||Y(e)?`/settings/ext/${e.id}`:null;return(0,$.jsx)(k,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,$.jsxs)(L,{children:[(0,$.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,$.jsxs)(P,{className:`xopc-dialog-content 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-overlay`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,$.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,$.jsx)(R,{className:`size-5`})}),(0,$.jsx)(O,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,$.jsxs)(oe,{className:`sr-only`,children:[e.name,` (`,e.id,`)`]}),(0,$.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,$.jsx)(A,{className:`size-5`})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,$.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,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:e.name}),(0,$.jsxs)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:[t.detailProviderPrefix,` `,ke(e,t)]}),e.version?(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[`v`,e.version]}):null]})]}),(0,$.jsx)(`p`,{className:`mt-5 text-sm leading-relaxed text-fg`,children:e.description?.trim()||t.detailNoDescription}),e.hasUi?null:(0,$.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.backendOnlyHint}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:Ae(e,t)}),e.source===`bundled`?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted shadow-surface dark:bg-surface-hover/20`,children:t.builtinConfigHint}):null,(0,$.jsxs)(`div`,{className:`mt-3 rounded-lg bg-surface-hover/40 p-3 shadow-surface dark:bg-surface-hover/20`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:t.builtinRuntimeToggle}),(0,$.jsx)(_,{type:`button`,variant:`secondary`,disabled:i!==null,onClick:()=>void g(),className:`shrink-0 py-1.5 text-xs`,children:i===`toggle`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(u,{className:`mr-1.5 size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),t.builtinToggleBusy]}):m?t.builtinToggleDisable:t.builtinToggleEnable})]}),s?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-rose-600 dark:text-rose-400`,children:s}):null,d?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.builtinToggleRestartHint}):null,e.source===`bundled`?null:(0,$.jsx)(`div`,{className:`mt-3 flex justify-end border-t border-edge-subtle pt-3`,children:(0,$.jsxs)(_,{type:`button`,variant:`ghost`,disabled:i!==null,onClick:()=>void v(),className:`text-danger hover:bg-danger-soft hover:text-danger`,children:[i===`uninstall`?(0,$.jsx)(u,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(B,{className:`size-3.5`,"aria-hidden":!0}),t.marketplaceUninstall]})})]}),e.hasUi&&(b.length>0||S.length>0||C.length>0)?(0,$.jsxs)(`section`,{className:`mt-8`,children:[(0,$.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-fg`,children:t.detailSectionFeatures}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,$.jsx)(Pe,{template:t.badgePages,count:b.length,hidden:b.length===0}),(0,$.jsx)(Pe,{template:t.badgeSettings,count:S.length,hidden:S.length===0}),(0,$.jsx)(Pe,{template:t.badgeWidgets,count:C.length,hidden:C.length===0})]})]}):null,ne(e)&&(j||M)?(0,$.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[j?(0,$.jsxs)(o,{to:j,onClick:n,className:f(`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,$.jsx)(l,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,M?(0,$.jsxs)(o,{to:M,onClick:n,className:f(`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,$.jsx)(E,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.openSettings]}):null]}):null,(0,$.jsx)(`p`,{className:`mt-6 text-[11px] leading-relaxed text-fg-muted`,children:t.restartNote})]})]})]})})}function Pe(e){let t=(0,pe.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,$.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 Fe(){let e=(0,pe.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:me,"aria-busy":`true`,children:Array.from({length:6},Ie)}),e[0]=t):t=e[0],t}function Ie(e,t){return(0,$.jsx)(v,{className:`h-32 rounded-xl`},t)}function Le(e){let t=(0,pe.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-col items-center justify-center rounded-xl border border-edge-subtle bg-surface-base px-4 py-12 text-center shadow-surface`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{De as ExtensionsPage};
@@ -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{m as i,t as a,u as o}from"./chunk-KS7C4IRE-BvcCCgTW.js";import{t as s}from"./check-DUBLcKHA.js";import{t as c}from"./chevron-down-ccbiQQz_.js";import{c as l,l as u,n as d,r as f,u as p}from"./popover-select-DGKUpVsz.js";import{t as m}from"./circle-check-C23XjkUj.js";import{t as h}from"./ellipsis-0k4rZLoy.js";import{t as g}from"./eye-CABVeTq0.js";import{t as _}from"./messages-BYq0cPbn.js";import{t as v}from"./cn-0WouolD0.js";import{a as y,i as b,n as x}from"./locale-store-B7s2Hb35.js";import{i as S}from"./vendor-swr-BIWyz7Rc.js";import{t as C}from"./button-aIC072nz.js";import{t as w}from"./skeleton-BI5TyibZ.js";import{a as T,c as E,i as D,o as O,s as ee}from"./dist-C3DSFZCi.js";import{$d as te,Al as k,An as A,Bc as j,Fa as M,Fd as N,Gl as ne,Ha as P,Hc as F,Ic as I,Il as re,Jc as ie,Lc as ae,Md as oe,Ql as se,Rc as ce,Su as le,Ul as ue,Vc as de,Xl as fe,Xu as L,_l as pe,aa as R,al as z,ao as B,c as V,ca as me,gu as H,ii as U,jd as he,lc as ge,oa as _e,qc as W,sa as ve,ta as G,ua as ye,wl as be,xd as xe,xl as Se,ya as Ce,yl as we}from"./index-Bys6njTY.js";import{a as Te,c as K,i as Ee,l as De,n as Oe,o as q,r as ke,s as Ae,t as J}from"./automation-display-BFN7zWBg.js";import{i as je,n as Me,r as Ne,t as Pe}from"./browser-automation-inputs-D6AccXaA.js";var Fe=n(),Y=e(t(),1),X=r(),Ie=Array.from({length:24},(e,t)=>t);function Le(e){let t=/^(\d{2}):(\d{2})$/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2]);return n>23||r>59?null:{hour:n,minute:r}}function Re(){let e=new Date;return{hour:e.getHours(),minute:e.getMinutes()}}function ze(e,t){return`${String(e).padStart(2,`0`)}:${String(t).padStart(2,`0`)}`}function Be(e){let t=(0,Fe.c)(80),{value:n,onChange:r,disabled:i,allowEmpty:a,clearLabel:o,ariaLabel:c,ariaLabelledBy:d,className:f,triggerClassName:m,id:h,name:g,minuteStep:_}=e,y=a===void 0?!1:a,b=_===void 0?1:_,x=Le(n),S=x??Re(),[C,w]=(0,Y.useState)(!1),[T,D]=(0,Y.useState)(null),[O,te]=(0,Y.useState)(S.hour),[k,A]=(0,Y.useState)(S.minute),j=(0,Y.useRef)([]),M=(0,Y.useRef)([]),N=u(),ne=l(T),P=p(N,ne!==null),F=Math.max(1,Math.min(60,Math.round(b))),I=Array.from({length:Math.ceil(60/F)},(e,t)=>t*F).filter(He),re;t[0]===r?re=t[1]:(re=(e,t,n)=>{let i=n===void 0?!1:n;te(e),A(t),r(ze(e,t)),i&&w(!1)},t[0]=r,t[1]=re);let ae=re,oe=Ve,se;t[2]===f?se=t[3]:(se=v(`relative min-w-0`,f),t[2]=f,t[3]=se);let ce=E,le;t[4]===n?le=t[5]:(le=e=>{if(e){let e=Le(n)??Re();te(e.hour),A(e.minute)}w(e)},t[4]=n,t[5]=le);let ue=y&&n&&`pr-9`,de=i&&`cursor-not-allowed opacity-50 hover:border-edge`,fe;t[6]!==ue||t[7]!==de||t[8]!==m?(fe=v(`box-border flex h-10 w-full min-w-0 items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 text-left text-sm text-fg`,`transition-colors hover:border-edge-strong focus-visible:border-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/20`,ue,de,m),t[6]=ue,t[7]=de,t[8]=m,t[9]=fe):fe=t[9];let L;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,X.jsx)(xe,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":`true`}),t[10]=L):L=t[10];let pe=!x&&`text-fg-subtle`,R;t[11]===pe?R=t[12]:(R=v(`tabular-nums`,pe),t[11]=pe,t[12]=R);let z=x?ze(x.hour,x.minute):`--:--`,B;t[13]!==R||t[14]!==z?(B=(0,X.jsx)(`span`,{className:R,children:z}),t[13]=R,t[14]=z,t[15]=B):B=t[15];let V;t[16]!==c||t[17]!==d||t[18]!==i||t[19]!==h||t[20]!==B||t[21]!==fe?(V=(0,X.jsx)(ee,{asChild:!0,children:(0,X.jsxs)(`button`,{ref:D,id:h,type:`button`,disabled:i,"aria-label":c,"aria-labelledby":d,"aria-haspopup":`listbox`,className:fe,children:[L,B]})}),t[16]=c,t[17]=d,t[18]=i,t[19]=h,t[20]=B,t[21]=fe,t[22]=V):V=t[22];let me=E,H=ne??void 0,U=E,he=v(P,`w-[18rem] overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover outline-none`),ge=e=>{e.preventDefault(),requestAnimationFrame(()=>j.current[O]?.focus())},_e;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,X.jsx)(xe,{className:`size-3.5`,"aria-hidden":`true`}),t[23]=_e):_e=t[23];let W=c??`HH:mm`,ve;t[24]===W?ve=t[25]:(ve=(0,X.jsxs)(`span`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[_e,W]}),t[24]=W,t[25]=ve);let G;t[26]!==O||t[27]!==k?(G=ze(O,k),t[26]=O,t[27]=k,t[28]=G):G=t[28];let ye;t[29]===G?ye=t[30]:(ye=(0,X.jsx)(`span`,{className:`font-mono text-base font-semibold tabular-nums text-fg`,children:G}),t[29]=G,t[30]=ye);let be;t[31]!==ve||t[32]!==ye?(be=(0,X.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle bg-surface-inset px-3 py-2.5`,children:[ve,ye]}),t[31]=ve,t[32]=ye,t[33]=be):be=t[33];let Se;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,X.jsx)(`div`,{className:`px-1 pb-1.5 text-[11px] font-semibold tracking-wider text-fg-subtle`,children:`HH`}),t[34]=Se):Se=t[34];let Ce=`${c??`HH:mm`} HH`,we=Ie.map((e,t)=>(0,X.jsx)(`button`,{ref:e=>{j.current[t]=e},type:`button`,role:`option`,"aria-selected":O===e,tabIndex:O===e?0:-1,className:v(`relative flex h-8 items-center justify-center rounded-md text-xs tabular-nums text-fg-muted transition-colors`,`hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/30`,O===e&&`bg-accent-soft font-semibold text-accent-fg`),onClick:()=>ae(e,k),onKeyDown:e=>oe(e,Ie,O,e=>ae(e,k),j),children:String(e).padStart(2,`0`)},e)),Te;t[35]!==Ce||t[36]!==we?(Te=(0,X.jsxs)(`div`,{className:`pr-2`,children:[Se,(0,X.jsx)(`div`,{role:`listbox`,"aria-label":Ce,className:`grid max-h-56 grid-cols-3 gap-1 overflow-y-auto pr-1`,children:we})]}),t[35]=Ce,t[36]=we,t[37]=Te):Te=t[37];let K;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,X.jsx)(`div`,{className:`px-1 pb-1.5 text-[11px] font-semibold tracking-wider text-fg-subtle`,children:`MM`}),t[38]=K):K=t[38];let Ee=`${c??`HH:mm`} MM`,De=I.map((e,t)=>(0,X.jsxs)(`button`,{ref:e=>{M.current[t]=e},type:`button`,role:`option`,"aria-selected":k===e,tabIndex:k===e?0:-1,className:v(`relative flex h-8 items-center justify-center rounded-md text-xs tabular-nums text-fg-muted transition-colors`,`hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/30`,k===e&&`bg-accent-soft font-semibold text-accent-fg`),onClick:()=>ae(O,e,!0),onKeyDown:e=>oe(e,I,k,e=>ae(O,e),M),children:[(0,X.jsx)(s,{className:v(`absolute left-0.5 size-3`,k!==e&&`invisible`),"aria-hidden":`true`}),String(e).padStart(2,`0`)]},e)),Oe;t[39]!==Ee||t[40]!==De?(Oe=(0,X.jsx)(`div`,{role:`listbox`,"aria-label":Ee,className:`grid max-h-56 grid-cols-3 gap-1 overflow-y-auto pr-1`,children:De}),t[39]=Ee,t[40]=De,t[41]=Oe):Oe=t[41];let q;t[42]!==K||t[43]!==Oe?(q=(0,X.jsxs)(`div`,{className:`pl-2`,children:[K,Oe]}),t[42]=K,t[43]=Oe,t[44]=q):q=t[44];let ke;t[45]!==Te||t[46]!==q?(ke=(0,X.jsxs)(`div`,{className:`grid grid-cols-2 divide-x divide-edge-subtle p-2`,children:[Te,q]}),t[45]=Te,t[46]=q,t[47]=ke):ke=t[47];let Ae;t[48]!==U.Content||t[49]!==he||t[50]!==ge||t[51]!==be||t[52]!==ke?(Ae=(0,X.jsxs)(U.Content,{side:`bottom`,align:`start`,sideOffset:6,collisionPadding:12,className:he,onOpenAutoFocus:ge,children:[be,ke]}),t[48]=U.Content,t[49]=he,t[50]=ge,t[51]=be,t[52]=ke,t[53]=Ae):Ae=t[53];let J;t[54]!==me.Portal||t[55]!==H||t[56]!==Ae?(J=(0,X.jsx)(me.Portal,{container:H,children:Ae}),t[54]=me.Portal,t[55]=H,t[56]=Ae,t[57]=J):J=t[57];let je;t[58]!==C||t[59]!==V||t[60]!==J||t[61]!==ce.Root||t[62]!==le?(je=(0,X.jsxs)(ce.Root,{open:C,onOpenChange:le,children:[V,J]}),t[58]=C,t[59]=V,t[60]=J,t[61]=ce.Root,t[62]=le,t[63]=je):je=t[63];let Me;t[64]!==y||t[65]!==c||t[66]!==o||t[67]!==i||t[68]!==r||t[69]!==n?(Me=y&&n?(0,X.jsx)(`button`,{type:`button`,disabled:i,"aria-label":o??c,title:o,className:`absolute right-1.5 top-1/2 flex size-7 -translate-y-1/2 items-center justify-center rounded-md text-fg-subtle hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/30 disabled:pointer-events-none`,onClick:()=>r(``),children:(0,X.jsx)(ie,{className:`size-3.5`,"aria-hidden":`true`})}):null,t[64]=y,t[65]=c,t[66]=o,t[67]=i,t[68]=r,t[69]=n,t[70]=Me):Me=t[70];let Ne;t[71]!==i||t[72]!==g||t[73]!==n?(Ne=g?(0,X.jsx)(`input`,{type:`hidden`,name:g,value:n,disabled:i}):null,t[71]=i,t[72]=g,t[73]=n,t[74]=Ne):Ne=t[74];let Pe;return t[75]!==se||t[76]!==je||t[77]!==Me||t[78]!==Ne?(Pe=(0,X.jsxs)(`div`,{className:se,children:[je,Me,Ne]}),t[75]=se,t[76]=je,t[77]=Me,t[78]=Ne,t[79]=Pe):Pe=t[79],Pe}function Ve(e,t,n,r,i){let a=null,o=Math.max(0,t.indexOf(n));if((e.key===`ArrowDown`||e.key===`ArrowRight`)&&(a=(o+1)%t.length),(e.key===`ArrowUp`||e.key===`ArrowLeft`)&&(a=(o-1+t.length)%t.length),e.key===`Home`&&(a=0),e.key===`End`&&(a=t.length-1),a===null)return;e.preventDefault();let s=t[a];r(s),i.current?.[a]?.focus()}function He(e){return e<60}function Ue(e){if(!e.trim())return null;try{return JSON.parse(e)}catch{return null}}function We(e){return typeof e.message==`string`&&e.message.trim()?e.message:typeof e.error==`string`&&e.error.trim()?e.error:e.error&&typeof e.error==`object`&&typeof e.error.message==`string`?e.error.message:`AI suggestion failed`}function Ge(e,t={}){let n=Ue(e.split(`
2
- `).filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).trimStart()).join(`
3
- `));if(!n)return null;if(n.type===`text_delta`&&typeof n.delta==`string`)return t.onDelta?.(n.delta),null;if(n.type===`thinking_delta`&&typeof n.delta==`string`)return t.onThinkingDelta?.(n.delta),null;if(n.type===`done`&&typeof n.text==`string`)return n.text;if(n.type===`error`)throw Error(We(n));return null}async function Ke(e,t={}){let n=await y(b(`/api/ai/text-assist`),{method:`POST`,headers:{Accept:`text/event-stream`},body:JSON.stringify(e)});if(!n.ok){let e=await n.json().catch(()=>({})),t=typeof e.error==`string`?e.error:e.error?.message;throw Error(t||`AI suggestion failed (${n.status})`)}if(!n.body){let e=await n.json().catch(()=>null);if(e?.text)return e;throw Error(`AI suggestion stream is empty`)}let r=n.body.getReader(),i=new TextDecoder,a=``,o=``,s=``;for(;;){let{done:e,value:n}=await r.read();if(n){a+=i.decode(n,{stream:!e});let r=a.split(/\r?\n\r?\n/);a=r.pop()??``;for(let e of r){let n=Ge(e,{onDelta:e=>{o+=e,t.onDelta?.(e)},onThinkingDelta:e=>{s+=e,t.onThinkingDelta?.(e)}});n!==null&&(o=n)}}if(e)break}if(a.trim()){let e=Ge(a,{onDelta:e=>{o+=e,t.onDelta?.(e)},onThinkingDelta:e=>{s+=e,t.onThinkingDelta?.(e)}});e!==null&&(o=e)}let c=o.trim();if(!c)throw Error(`AI returned an empty suggestion`);return{text:c,thinking:s.trim()||void 0}}function Z(){let[e,t]=(0,Y.useState)(``),[n,r]=(0,Y.useState)(``),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(null);return{suggestion:e,thinking:n,loading:i,error:o,generate:(0,Y.useCallback)(async e=>{a(!0),s(null),t(``),r(``);try{let n=await Ke(e,{onDelta:e=>{t(t=>t+e)},onThinkingDelta:e=>{r(t=>t+e)}});return t(n.text),r(n.thinking??``),n.text}catch(e){return s(e instanceof Error?e.message:`AI suggestion failed`),null}finally{a(!1)}},[]),reset:(0,Y.useCallback)(()=>{t(``),r(``),s(null),a(!1)},[])}}var qe=5;function Je(e){return e.startsWith(`zh`)?{title:`AI 优化文案`,buttonTitle:`优化文案`,current:`当前内容`,suggestion:`AI 建议`,editedSuggestion:`审核并编辑建议`,thinking:`模型思考`,thinkingLoading:`思考中`,edit:`编辑`,preview:`预览`,loading:`正在生成建议...`,empty:`暂无内容`,generate:`生成建议`,regenerate:`重新生成`,applyCurrent:`应用当前内容`,replace:`替换`,append:`追加`,cancel:`取消`,close:`关闭`}:{title:`AI text assist`,buttonTitle:`Improve text`,current:`Current`,suggestion:`Suggestion`,editedSuggestion:`Review and edit suggestion`,thinking:`Model thinking`,thinkingLoading:`Thinking`,edit:`Edit`,preview:`Preview`,loading:`Generating suggestion...`,empty:`No content`,generate:`Generate suggestion`,regenerate:`Regenerate`,applyCurrent:`Apply current`,replace:`Replace`,append:`Append`,cancel:`Cancel`,close:`Close`}}function Ye(e){let t=(0,Fe.c)(245),{value:n,onApply:r,fieldId:i,fieldLabel:a,scenario:o,format:s,intent:l,locale:u,context:d,disabled:f,className:p,showLabel:m}=e,h=o===void 0?`generic.text`:o,_=s===void 0?`plain`:s,y=l===void 0?`improve`:l,b=m===void 0?!0:m,[x,S]=(0,Y.useState)(!1),[w,T]=(0,Y.useState)(n),[E,D]=(0,Y.useState)(`preview`),[O,ee]=(0,Y.useState)(``),[te,k]=(0,Y.useState)(`edit`),[A,M]=(0,Y.useState)(!0),[N,ne]=(0,Y.useState)(!1),[oe,se]=(0,Y.useState)(null),le=(0,Y.useRef)(null),ue=(0,Y.useRef)(!0),{suggestion:fe,thinking:L,loading:R,error:z,generate:B,reset:V}=Z(),me;t[0]===u?me=t[1]:(me=Je(u),t[0]=u,t[1]=me);let H=me,U;t[2]!==R||t[3]!==L?(U=R&&L.trim().length>0,t[2]=R,t[3]=L,t[4]=U):U=t[4];let he=U,_e,W;t[5]!==x||t[6]!==n?(_e=()=>{x||T(n)},W=[x,n],t[5]=x,t[6]=n,t[7]=_e,t[8]=W):(_e=t[7],W=t[8]),(0,Y.useEffect)(_e,W);let ve,G;t[9]===fe?(ve=t[10],G=t[11]):(G=()=>{ee(fe)},ve=[fe],t[9]=fe,t[10]=ve,t[11]=G),(0,Y.useEffect)(G,ve);let ye,be;t[12]===L?(ye=t[13],be=t[14]):(ye=()=>{L.trim()&&M(!0)},be=[L],t[12]=L,t[13]=ye,t[14]=be),(0,Y.useEffect)(ye,be);let xe;t[15]!==he||t[16]!==A?(xe=()=>{let e=le.current;!e||!he||!A||ue.current&&(e.scrollTop=e.scrollHeight)},t[15]=he,t[16]=A,t[17]=xe):xe=t[17];let Se;t[18]!==he||t[19]!==L||t[20]!==A?(Se=[he,L,A],t[18]=he,t[19]=L,t[20]=A,t[21]=Se):Se=t[21],(0,Y.useLayoutEffect)(xe,Se);let Ce;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=()=>{let e=le.current;e&&(ue.current=e.scrollHeight-e.scrollTop-e.clientHeight<=qe)},t[22]=Ce):Ce=t[22];let Te=Ce,K;t[23]!==d||t[24]!==i||t[25]!==a||t[26]!==_||t[27]!==B||t[28]!==y||t[29]!==u||t[30]!==h?(K=async e=>{k(`edit`),M(!0),ue.current=!0,await B({intent:y,scenario:h,input:e,locale:u,field:{id:i,label:a,format:_},context:d})},t[23]=d,t[24]=i,t[25]=a,t[26]=_,t[27]=B,t[28]=y,t[29]=u,t[30]=h,t[31]=K):K=t[31];let Ee=K,De;t[32]!==V||t[33]!==n?(De=e=>{ne(!!e.currentTarget.closest(`[role="dialog"]`)),se(document.querySelector(`.app-main-surface`)),T(n),D(`preview`),ee(``),k(`edit`),M(!0),V(),S(!0)},t[32]=V,t[33]=n,t[34]=De):De=t[34];let Oe=De,q;t[35]!==w||t[36]!==Ee?(q=async()=>{await Ee(w)},t[35]=w,t[36]=Ee,t[37]=q):q=t[37];let ke=q,Ae;t[38]!==V||t[39]!==n?(Ae=()=>{S(!1),T(n),D(`preview`),ee(``),k(`edit`),M(!0),V()},t[38]=V,t[39]=n,t[40]=Ae):Ae=t[40];let J=Ae,je;t[41]!==J||t[42]!==w||t[43]!==r?(je=()=>{r(w),J()},t[41]=J,t[42]=w,t[43]=r,t[44]=je):je=t[44];let Me=je,Ne;t[45]!==J||t[46]!==O||t[47]!==r?(Ne=()=>{O.trim()&&(r(O),J())},t[45]=J,t[46]=O,t[47]=r,t[48]=Ne):Ne=t[48];let Pe=Ne,Ie;t[49]!==J||t[50]!==w||t[51]!==O||t[52]!==r?(Ie=()=>{if(!O.trim())return;let e=w.trimEnd();r(e?`${e}\n\n${O}`:O),J()},t[49]=J,t[50]=w,t[51]=O,t[52]=r,t[53]=Ie):Ie=t[53];let Le=Ie,Re;t[54]!==O||t[55]!==z||t[56]!==R?(Re=!R&&!z&&O.trim().length>0,t[54]=O,t[55]=z,t[56]=R,t[57]=Re):Re=t[57];let ze=Re,Be=w!==n,Ve;t[58]!==O||t[59]!==z||t[60]!==L?(Ve=O.trim().length>0||L.trim().length>0||!!z,t[58]=O,t[59]=z,t[60]=L,t[61]=Ve):Ve=t[61];let He=Ve,Ue=!b&&`size-7 p-0`,We;t[62]!==p||t[63]!==Ue?(We=v(`h-7 gap-1 px-2 text-xs`,Ue,p),t[62]=p,t[63]=Ue,t[64]=We):We=t[64];let Ge=f||R,Ke;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=(0,X.jsx)(we,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[65]=Ke):Ke=t[65];let Ye=b?H.buttonTitle:null,Qe;t[66]!==H.buttonTitle||t[67]!==Oe||t[68]!==We||t[69]!==Ge||t[70]!==Ye?(Qe=(0,X.jsxs)(C,{type:`button`,variant:`ghost`,className:We,title:H.buttonTitle,"aria-label":H.buttonTitle,disabled:Ge,onClick:Oe,children:[Ke,Ye]}),t[66]=H.buttonTitle,t[67]=Oe,t[68]=We,t[69]=Ge,t[70]=Ye,t[71]=Qe):Qe=t[71];let $e;t[72]===J?$e=t[73]:($e=e=>e?S(!0):J(),t[72]=J,t[73]=$e);let et=oe??void 0,tt=N?`bg-transparent`:`bg-scrim`,nt;t[74]===tt?nt=t[75]:(nt=v(`xopc-dialog-overlay absolute inset-0 z-[80]`,tt),t[74]=tt,t[75]=nt);let rt;t[76]===nt?rt=t[77]:(rt=(0,X.jsx)(j,{className:nt}),t[76]=nt,t[77]=rt);let it;t[78]===H.title?it=t[79]:(it=(0,X.jsx)(F,{className:`text-base font-semibold text-fg`,children:H.title}),t[78]=H.title,t[79]=it);let at;t[80]===Symbol.for(`react.memo_cache_sentinel`)?(at=(0,X.jsx)(ie,{className:`size-5`,strokeWidth:1.75}),t[80]=at):at=t[80];let ot;t[81]===H.close?ot=t[82]:(ot=(0,X.jsx)(ae,{asChild:!0,children:(0,X.jsx)(C,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":H.close,children:at})}),t[81]=H.close,t[82]=ot);let st;t[83]!==it||t[84]!==ot?(st=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[it,ot]}),t[83]=it,t[84]=ot,t[85]=st):st=t[85];let ct;t[86]===H.current?ct=t[87]:(ct=(0,X.jsx)(`div`,{className:`min-w-0 text-xs font-medium text-fg-muted`,children:H.current}),t[86]=H.current,t[87]=ct);let lt=H.current,ut=E===`edit`,dt=E===`edit`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,ft;t[88]===dt?ft=t[89]:(ft=v(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,dt),t[88]=dt,t[89]=ft);let pt,mt;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(pt=()=>D(`edit`),mt=(0,X.jsx)(pe,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[90]=pt,t[91]=mt):(pt=t[90],mt=t[91]);let ht;t[92]!==H.edit||t[93]!==ut||t[94]!==ft?(ht=(0,X.jsxs)(`button`,{"aria-pressed":ut,type:`button`,className:ft,onClick:pt,children:[mt,H.edit]}),t[92]=H.edit,t[93]=ut,t[94]=ft,t[95]=ht):ht=t[95];let gt=E===`preview`,_t=E===`preview`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,vt;t[96]===_t?vt=t[97]:(vt=v(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,_t),t[96]=_t,t[97]=vt);let yt,bt;t[98]===Symbol.for(`react.memo_cache_sentinel`)?(yt=()=>D(`preview`),bt=(0,X.jsx)(g,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[98]=yt,t[99]=bt):(yt=t[98],bt=t[99]);let xt;t[100]!==H.preview||t[101]!==gt||t[102]!==vt?(xt=(0,X.jsxs)(`button`,{"aria-pressed":gt,type:`button`,className:vt,onClick:yt,children:[bt,H.preview]}),t[100]=H.preview,t[101]=gt,t[102]=vt,t[103]=xt):xt=t[103];let St;t[104]!==H.current||t[105]!==ht||t[106]!==xt?(St=(0,X.jsxs)(P,{className:`flex shrink-0 items-center gap-1 rounded-lg border border-edge bg-surface-inset p-0.5`,role:`group`,"aria-label":lt,indicatorClassName:`rounded-md bg-surface-panel shadow-surface`,children:[ht,xt]}),t[104]=H.current,t[105]=ht,t[106]=xt,t[107]=St):St=t[107];let Ct;t[108]!==ct||t[109]!==St?(Ct=(0,X.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[ct,St]}),t[108]=ct,t[109]=St,t[110]=Ct):Ct=t[110];let wt;t[111]!==w||t[112]!==E||t[113]!==_||t[114]!==H.current||t[115]!==H.empty?(wt=E===`preview`?(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg`,children:_===`markdown`?(0,X.jsx)(ge,{content:w||H.empty,compact:!0,className:`text-sm`}):(0,X.jsx)(`pre`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg`,children:w||H.empty})}):(0,X.jsx)(`textarea`,{className:`min-h-0 flex-1 resize-none overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/25`,value:w,onChange:e=>T(e.currentTarget.value),placeholder:H.empty,"aria-label":H.current}),t[111]=w,t[112]=E,t[113]=_,t[114]=H.current,t[115]=H.empty,t[116]=wt):wt=t[116];let Tt;t[117]!==Ct||t[118]!==wt?(Tt=(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden`,children:[Ct,wt]}),t[117]=Ct,t[118]=wt,t[119]=Tt):Tt=t[119];let Et;t[120]===H.editedSuggestion?Et=t[121]:(Et=(0,X.jsx)(`span`,{children:H.editedSuggestion}),t[120]=H.editedSuggestion,t[121]=Et);let Dt;t[122]!==H.loading||t[123]!==R?(Dt=R?(0,X.jsx)(`span`,{className:`ml-2 font-normal`,children:H.loading}):null,t[122]=H.loading,t[123]=R,t[124]=Dt):Dt=t[124];let Ot;t[125]!==Et||t[126]!==Dt?(Ot=(0,X.jsxs)(`div`,{className:`min-w-0 text-xs font-medium text-fg-muted`,children:[Et,Dt]}),t[125]=Et,t[126]=Dt,t[127]=Ot):Ot=t[127];let kt=H.editedSuggestion,At=te===`edit`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,jt;t[128]===At?jt=t[129]:(jt=v(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,At),t[128]=At,t[129]=jt);let Mt=te===`edit`,Nt,Pt;t[130]===Symbol.for(`react.memo_cache_sentinel`)?(Nt=()=>k(`edit`),Pt=(0,X.jsx)(pe,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[130]=Nt,t[131]=Pt):(Nt=t[130],Pt=t[131]);let Ft;t[132]!==H.edit||t[133]!==jt||t[134]!==Mt?(Ft=(0,X.jsxs)(`button`,{type:`button`,className:jt,"aria-pressed":Mt,onClick:Nt,children:[Pt,H.edit]}),t[132]=H.edit,t[133]=jt,t[134]=Mt,t[135]=Ft):Ft=t[135];let It=te===`preview`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover`,Lt;t[136]===It?Lt=t[137]:(Lt=v(`inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-medium`,It),t[136]=It,t[137]=Lt);let Rt=te===`preview`,zt,Bt;t[138]===Symbol.for(`react.memo_cache_sentinel`)?(zt=()=>k(`preview`),Bt=(0,X.jsx)(g,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[138]=zt,t[139]=Bt):(zt=t[138],Bt=t[139]);let Vt;t[140]!==H.preview||t[141]!==Lt||t[142]!==Rt?(Vt=(0,X.jsxs)(`button`,{type:`button`,className:Lt,"aria-pressed":Rt,onClick:zt,children:[Bt,H.preview]}),t[140]=H.preview,t[141]=Lt,t[142]=Rt,t[143]=Vt):Vt=t[143];let Ht;t[144]!==H.editedSuggestion||t[145]!==Ft||t[146]!==Vt?(Ht=(0,X.jsxs)(P,{className:`flex shrink-0 items-center gap-1 rounded-lg border border-edge bg-surface-inset p-0.5`,role:`group`,"aria-label":kt,indicatorClassName:`rounded-md bg-surface-panel shadow-surface`,children:[Ft,Vt]}),t[144]=H.editedSuggestion,t[145]=Ft,t[146]=Vt,t[147]=Ht):Ht=t[147];let Ut;t[148]!==Ot||t[149]!==Ht?(Ut=(0,X.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[Ot,Ht]}),t[148]=Ot,t[149]=Ht,t[150]=Ut):Ut=t[150];let Wt=he?`opacity-100`:`pointer-events-none opacity-0`,Gt;t[151]===Wt?Gt=t[152]:(Gt=v(`absolute inset-0 min-h-0 transition-opacity duration-200 ease-out motion-reduce:transition-none`,Wt),t[151]=Wt,t[152]=Gt);let Kt=!he,qt;t[153]===Symbol.for(`react.memo_cache_sentinel`)?(qt=()=>M(Xe),t[153]=qt):qt=t[153];let Jt;t[154]!==H.thinkingLoading||t[155]!==R?(Jt=R?(0,X.jsxs)(`span`,{className:`ml-1 font-normal`,children:[`· `,H.thinkingLoading]}):null,t[154]=H.thinkingLoading,t[155]=R,t[156]=Jt):Jt=t[156];let Yt;t[157]!==H.thinking||t[158]!==Jt?(Yt=(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[H.thinking,Jt]}),t[157]=H.thinking,t[158]=Jt,t[159]=Yt):Yt=t[159];let Xt=A&&`rotate-180`,Zt;t[160]===Xt?Zt=t[161]:(Zt=v(`size-3.5 shrink-0 transition-transform`,Xt),t[160]=Xt,t[161]=Zt);let Qt;t[162]===Zt?Qt=t[163]:(Qt=(0,X.jsx)(c,{className:Zt,strokeWidth:1.75,"aria-hidden":!0}),t[162]=Zt,t[163]=Qt);let $t;t[164]!==Yt||t[165]!==Qt?($t=(0,X.jsxs)(`button`,{type:`button`,className:`flex shrink-0 items-center justify-between gap-2 px-2.5 py-2 text-left text-xs font-medium text-fg-muted hover:text-fg`,onClick:qt,children:[Yt,Qt]}),t[164]=Yt,t[165]=Qt,t[166]=$t):$t=t[166];let en;t[167]!==L||t[168]!==A?(en=A?(0,X.jsx)(`pre`,{ref:le,className:`min-h-0 flex-1 overflow-auto border-t border-edge px-2.5 py-2 whitespace-pre-wrap text-xs leading-5 text-fg-muted`,onScroll:Te,children:L}):null,t[167]=L,t[168]=A,t[169]=en):en=t[169];let tn;t[170]!==$t||t[171]!==en?(tn=(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col rounded-lg border border-edge bg-surface-inset/70`,children:[$t,en]}),t[170]=$t,t[171]=en,t[172]=tn):tn=t[172];let nn;t[173]!==Gt||t[174]!==Kt||t[175]!==tn?(nn=(0,X.jsx)(`div`,{className:Gt,"aria-hidden":Kt,children:tn}),t[173]=Gt,t[174]=Kt,t[175]=tn,t[176]=nn):nn=t[176];let rn=he?`pointer-events-none opacity-0`:`opacity-100`,an;t[177]===rn?an=t[178]:(an=v(`absolute inset-0 min-h-0 transition-opacity duration-200 ease-out motion-reduce:transition-none`,rn),t[177]=rn,t[178]=an);let on;t[179]!==O||t[180]!==z||t[181]!==_||t[182]!==H.empty||t[183]!==H.loading||t[184]!==H.suggestion||t[185]!==R||t[186]!==te?(on=z?(0,X.jsx)(`pre`,{className:`h-full min-h-0 overflow-auto whitespace-pre-wrap rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg-muted`,children:z}):te===`preview`?(0,X.jsx)(`div`,{className:`h-full min-h-0 overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg`,children:R&&!O.trim()?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:H.loading}):_===`markdown`?(0,X.jsx)(ge,{content:O||H.empty,compact:!0,className:`text-sm`}):(0,X.jsx)(`pre`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg`,children:O||H.empty})}):(0,X.jsx)(`textarea`,{className:`h-full min-h-0 w-full resize-none overflow-auto rounded-lg border border-edge bg-surface-base p-3 text-sm leading-6 text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/25 disabled:text-fg-muted`,value:O,onChange:e=>ee(e.currentTarget.value),disabled:R,placeholder:R?H.loading:H.empty,"aria-label":H.suggestion}),t[179]=O,t[180]=z,t[181]=_,t[182]=H.empty,t[183]=H.loading,t[184]=H.suggestion,t[185]=R,t[186]=te,t[187]=on):on=t[187];let sn;t[188]!==an||t[189]!==on?(sn=(0,X.jsx)(`div`,{className:an,children:on}),t[188]=an,t[189]=on,t[190]=sn):sn=t[190];let cn;t[191]!==nn||t[192]!==sn?(cn=(0,X.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[nn,sn]}),t[191]=nn,t[192]=sn,t[193]=cn):cn=t[193];let ln;t[194]!==Ut||t[195]!==cn?(ln=(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden`,children:[Ut,cn]}),t[194]=Ut,t[195]=cn,t[196]=ln):ln=t[196];let un;t[197]!==Tt||t[198]!==ln?(un=(0,X.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 gap-3 overflow-hidden p-4 md:grid-cols-2`,children:[Tt,ln]}),t[197]=Tt,t[198]=ln,t[199]=un):un=t[199];let Q;t[200]!==J||t[201]!==H.cancel?(Q=(0,X.jsx)(C,{type:`button`,variant:`secondary`,onClick:J,children:H.cancel}),t[200]=J,t[201]=H.cancel,t[202]=Q):Q=t[202];let $=!Be,dn;t[203]!==Me||t[204]!==H.applyCurrent||t[205]!==$?(dn=(0,X.jsx)(C,{type:`button`,variant:`secondary`,disabled:$,onClick:Me,children:H.applyCurrent}),t[203]=Me,t[204]=H.applyCurrent,t[205]=$,t[206]=dn):dn=t[206];let fn;t[207]===ke?fn=t[208]:(fn=()=>void ke(),t[207]=ke,t[208]=fn);let pn;t[209]===He?pn=t[210]:(pn=He?(0,X.jsx)(re,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}):(0,X.jsx)(we,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[209]=He,t[210]=pn);let mn=He?H.regenerate:H.generate,hn;t[211]!==R||t[212]!==pn||t[213]!==mn||t[214]!==fn?(hn=(0,X.jsxs)(C,{type:`button`,variant:`secondary`,disabled:R,onClick:fn,children:[pn,mn]}),t[211]=R,t[212]=pn,t[213]=mn,t[214]=fn,t[215]=hn):hn=t[215];let gn=!ze,_n;t[216]!==Le||t[217]!==H.append||t[218]!==gn?(_n=(0,X.jsx)(C,{type:`button`,variant:`secondary`,disabled:gn,onClick:Le,children:H.append}),t[216]=Le,t[217]=H.append,t[218]=gn,t[219]=_n):_n=t[219];let vn=!ze,yn;t[220]!==Pe||t[221]!==H.replace||t[222]!==vn?(yn=(0,X.jsx)(C,{type:`button`,variant:`primary`,disabled:vn,onClick:Pe,children:H.replace}),t[220]=Pe,t[221]=H.replace,t[222]=vn,t[223]=yn):yn=t[223];let bn;t[224]!==hn||t[225]!==_n||t[226]!==yn||t[227]!==Q||t[228]!==dn?(bn=(0,X.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-4 py-3`,children:[Q,dn,hn,_n,yn]}),t[224]=hn,t[225]=_n,t[226]=yn,t[227]=Q,t[228]=dn,t[229]=bn):bn=t[229];let xn;t[230]!==bn||t[231]!==st||t[232]!==un?(xn=(0,X.jsx)(`div`,{className:`absolute inset-0 z-[80] flex items-center justify-center p-4 pointer-events-none`,children:(0,X.jsxs)(ce,{className:`xopc-dialog-content-pane pointer-events-auto flex h-[min(78vh,38rem)] w-full max-w-4xl flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay shadow-popover outline-none`,onOpenAutoFocus:Ze,children:[st,un,bn]})}),t[230]=bn,t[231]=st,t[232]=un,t[233]=xn):xn=t[233];let Sn;t[234]!==xn||t[235]!==et||t[236]!==rt?(Sn=(0,X.jsxs)(de,{container:et,children:[rt,xn]}),t[234]=xn,t[235]=et,t[236]=rt,t[237]=Sn):Sn=t[237];let Cn;t[238]!==x||t[239]!==Sn||t[240]!==$e?(Cn=(0,X.jsx)(I,{open:x,onOpenChange:$e,children:Sn}),t[238]=x,t[239]=Sn,t[240]=$e,t[241]=Cn):Cn=t[241];let wn;return t[242]!==Cn||t[243]!==Qe?(wn=(0,X.jsxs)(X.Fragment,{children:[Qe,Cn]}),t[242]=Cn,t[243]=Qe,t[244]=wn):wn=t[244],wn}function Xe(e){return!e}function Ze(e){return e.preventDefault()}function Qe(e){return e.management!==void 0}var $e={name:``,description:``,projectId:``,triggerMode:`daily`,time:`09:00`,weekday:`1`,intervalValue:`1`,intervalUnit:`hour`,cronExpr:`0 9 * * *`,webhookSecretId:``,onceAt:``,eventType:``,eventSource:``,eventPayloadMatch:``,actionMode:`agent`,agentId:``,model:``,instruction:``,taskId:``,browserAutomationId:``,browserAutomationInputs:{},safetyMode:`suggest_only`,timeoutSeconds:`1800`,conversationMode:`new_session`,notificationPolicy:`attention`,resultWebhookEndpoint:``,resultWebhookSecretId:``,disableAfterFailures:`3`},et=[{value:`15`,unit:`minute`},{value:`30`,unit:`minute`},{value:`1`,unit:`hour`},{value:`6`,unit:`hour`},{value:`24`,unit:`hour`}];function tt(e){let[t,n]=e.time.split(`:`),r=Number.parseInt(t||`9`,10),i=Number.parseInt(n||`0`,10),a;if(e.triggerMode===`manual`)a={kind:`manual`};else if(e.triggerMode===`once`)a={kind:`schedule`,schedule:{kind:`once`,at:new Date(e.onceAt).toISOString()}};else if(e.triggerMode===`webhook`)a={kind:`webhook`,...e.webhookSecretId.trim()?{secretId:e.webhookSecretId.trim()}:{}};else if(e.triggerMode===`taskBlocked`)a={kind:`event`,eventType:`task.attention_required.v2`,source:`tasks`,payloadMatch:{reason:`blocked`}};else if(e.triggerMode===`noteCreated`)a={kind:`event`,eventType:`note.created`,source:`notes`};else if(e.triggerMode===`sessionUpdated`)a={kind:`event`,eventType:`session.transcript.updated`,source:`sessions`};else if(e.triggerMode===`event`){let t=e.eventPayloadMatch.trim()?JSON.parse(e.eventPayloadMatch):void 0;a={kind:`event`,eventType:e.eventType.trim(),...e.eventSource.trim()?{source:e.eventSource.trim()}:{},...t?{payloadMatch:t}:{}}}else a=e.triggerMode===`interval`?{kind:`schedule`,schedule:{kind:`interval`,everyMs:J(e.intervalValue,e.intervalUnit)}}:e.triggerMode===`weekly`?{kind:`schedule`,schedule:{kind:`cron`,expr:`${i} ${r} * * ${e.weekday}`}}:e.triggerMode===`cron`?{kind:`schedule`,schedule:{kind:`cron`,expr:e.cronExpr.trim()}}:{kind:`schedule`,schedule:{kind:`cron`,expr:`${i} ${r} * * *`}};let o=e.actionMode===`browser_automation`||e.actionMode===`task_command`?`auto_apply`:e.safetyMode,s;return s=e.actionMode===`browser_automation`?{kind:`browser_automation`,automationId:e.browserAutomationId.trim(),inputs:e.browserAutomationInputs}:e.actionMode===`task_command`?{kind:`task_command`,taskId:e.taskId.trim(),command:{type:`start`,executor:{kind:`agent`,agentId:e.agentId.trim()}}}:{kind:`agent`,instruction:e.instruction.trim(),...e.agentId.trim()?{agentId:e.agentId.trim()}:{},...e.model.trim()?{model:e.model.trim()}:{}},{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},...e.projectId.trim()?{projectId:e.projectId.trim()}:{},trigger:a,action:s,safety:{mode:o},conversationMode:e.conversationMode,delivery:{notificationPolicy:e.notificationPolicy,destinations:[{key:`gateway_event`,kind:`gateway_event`},...e.resultWebhookEndpoint.trim()&&e.resultWebhookSecretId.trim()?[{key:`result_webhook`,kind:`webhook`,endpoint:e.resultWebhookEndpoint.trim(),secretId:e.resultWebhookSecretId.trim()}]:[]]},reliability:{executionTimeoutSeconds:Math.max(1,Number.parseInt(e.timeoutSeconds,10)||1800),disableAfterConsecutiveFailures:Math.max(1,Number.parseInt(e.disableAfterFailures,10)||3)}}}function nt(e){let t=e.match(/^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+\*$/);if(t)return{triggerMode:`daily`,time:`${t[2].padStart(2,`0`)}:${t[1].padStart(2,`0`)}`,weekday:`1`,cronExpr:e};let n=e.match(/^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+([0-6])$/);return n?{triggerMode:`weekly`,time:`${n[2].padStart(2,`0`)}:${n[1].padStart(2,`0`)}`,weekday:n[3],cronExpr:e}:{triggerMode:`cron`,time:$e.time,weekday:$e.weekday,cronExpr:e}}function rt(e){let t=[[`week`,10080*6e4],[`day`,1440*6e4],[`hour`,60*6e4],[`minute`,6e4]],[n,r]=t.find(([,t])=>e>=t&&e%t===0)??t.at(-1);return{intervalValue:String(e/r),intervalUnit:n}}function it(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;let n=t.getTimezoneOffset()*6e4;return new Date(t.getTime()-n).toISOString().slice(0,16)}function at(e){let t=e.payloadMatch;return e.eventType===`task.attention_required.v2`&&e.source===`tasks`&&t?.reason===`blocked`?{triggerMode:`taskBlocked`}:e.eventType===`note.created`&&e.source===`notes`&&!t?{triggerMode:`noteCreated`}:e.eventType===`session.transcript.updated`&&e.source===`sessions`&&!t?{triggerMode:`sessionUpdated`}:{triggerMode:`event`,eventType:e.eventType,eventSource:e.source??``,eventPayloadMatch:t?JSON.stringify(t,null,2):``}}function ot(e){if(!e.trim())return!0;try{let t=JSON.parse(e);return!!t&&typeof t==`object`&&!Array.isArray(t)&&Object.values(t).every(e=>e===null||[`string`,`number`,`boolean`].includes(typeof e))}catch{return!1}}function st(e){let t={triggerMode:`manual`};if(e.trigger.kind===`webhook`)t={triggerMode:`webhook`,webhookSecretId:e.trigger.secretId??``};else if(e.trigger.kind===`event`)t=at(e.trigger);else if(e.trigger.kind===`schedule`){let n=e.trigger.schedule;n.kind===`cron`&&(t=nt(n.expr)),n.kind===`interval`&&(t={triggerMode:`interval`,...rt(n.everyMs)}),n.kind===`once`&&(t={triggerMode:`once`,onceAt:it(n.at)})}let n=e.action,r=e.reliability?.executionTimeoutSeconds??(`timeoutSeconds`in n?n.timeoutSeconds:void 0)??(n.kind===`browser_automation`?600:1800);return{...$e,...t,name:e.name,description:e.description??``,projectId:e.projectId??``,actionMode:n.kind===`system`?`agent`:n.kind,agentId:n.kind===`agent`?n.agentId??``:n.kind===`task_command`&&n.command.type===`start`&&n.command.executor.kind===`agent`?n.command.executor.agentId:``,model:n.kind===`agent`?n.model??``:``,instruction:n.kind===`agent`?n.instruction:``,taskId:n.kind===`task_command`?n.taskId:``,browserAutomationId:n.kind===`browser_automation`?n.automationId:``,browserAutomationInputs:n.kind===`browser_automation`?n.inputs??{}:{},safetyMode:e.safety?.mode??`auto_apply`,timeoutSeconds:String(r),conversationMode:e.conversationMode??`new_session`,notificationPolicy:e.delivery.notificationPolicy,resultWebhookEndpoint:e.delivery.destinations.find(e=>e.kind===`webhook`)?.endpoint??``,resultWebhookSecretId:e.delivery.destinations.find(e=>e.kind===`webhook`)?.secretId??``,disableAfterFailures:String(e.reliability?.disableAfterConsecutiveFailures??3)}}function ct(e,t){let n=tt(t),r=e.trigger.kind===`schedule`&&n.trigger.kind===`schedule`&&e.trigger.schedule.kind===n.trigger.schedule.kind?{...n.trigger,schedule:{...e.trigger.schedule,...n.trigger.schedule}}:n.trigger,i=n.action;e.action.kind===`agent`&&n.action.kind===`agent`?i={...e.action,...n.action,agentId:n.action.agentId,model:n.action.model}:e.action.kind===`browser_automation`&&n.action.kind===`browser_automation`?i={...e.action,...n.action}:e.action.kind===`task_command`&&n.action.kind===`task_command`&&(i=n.action);let a=e.delivery.destinations.filter(e=>e.kind===`gateway_event`),o=e.delivery.destinations.filter(e=>e.kind===`webhook`);return{...n,description:t.description.trim(),projectId:t.projectId.trim(),delivery:{notificationPolicy:t.notificationPolicy,destinations:[...a.length>0?a:[{key:`gateway_event`,kind:`gateway_event`}],...e.delivery.destinations.filter(e=>e.kind===`file`||e.kind===`card`),...o.slice(1),...t.resultWebhookEndpoint.trim()&&t.resultWebhookSecretId.trim()?[{key:o[0]?.key??`result_webhook`,kind:`webhook`,endpoint:t.resultWebhookEndpoint.trim(),secretId:t.resultWebhookSecretId.trim()}]:[]]},trigger:r,action:i,reliability:{...e.reliability,...n.reliability}}}function lt(e){return[`reminder`,`brief`,`review`,`followUp`].map(t=>{let n=e.scenarios[t];return{...n,requiresProject:t===`followUp`,form:{...$e,name:n.name,instruction:t===`reminder`?``:n.instruction,triggerMode:t===`reminder`?`once`:t===`review`?`weekly`:`daily`,time:t===`brief`?`08:30`:t===`review`?`17:00`:`09:00`,weekday:`5`,notificationPolicy:`all`}}})}var ut=`w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg focus-visible:outline-2 focus-visible:outline-accent`;function dt(e){let t=(0,Fe.c)(99),{form:n,setForm:r,labels:i,projects:a,projectLocked:o,source:s,requiresProject:c}=e,l;t[0]===r?l=t[1]:(l=e=>r(t=>({...t,...e})),t[0]=r,t[1]=l);let u=l,p;t[2]!==i.experience.source||t[3]!==s?(p=(0,X.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[i.experience.source,`: `,s]}),t[2]=i.experience.source,t[3]=s,t[4]=p):p=t[4];let m;t[5]===u?m=t[6]:(m=e=>u({name:e.target.value}),t[5]=u,t[6]=m);let h;t[7]!==n.name||t[8]!==m?(h=(0,X.jsx)(`input`,{className:ut,value:n.name,onChange:m}),t[7]=n.name,t[8]=m,t[9]=h):h=t[9];let g;t[10]!==i.form.name||t[11]!==h?(g=(0,X.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.form.name,h]}),t[10]=i.form.name,t[11]=h,t[12]=g):g=t[12];let _;t[13]===u?_=t[14]:(_=e=>u({instruction:e.target.value}),t[13]=u,t[14]=_);let v;t[15]!==n.instruction||t[16]!==_?(v=(0,X.jsx)(`textarea`,{className:ut,rows:5,value:n.instruction,onChange:_}),t[15]=n.instruction,t[16]=_,t[17]=v):v=t[17];let y;t[18]!==i.info.task||t[19]!==v?(y=(0,X.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.info.task,v]}),t[18]=i.info.task,t[19]=v,t[20]=y):y=t[20];let b;t[21]!==n.projectId||t[22]!==i.form.noProject||t[23]!==i.form.project||t[24]!==o||t[25]!==a||t[26]!==u?(b=!o&&(0,X.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.form.project,(0,X.jsxs)(d,{className:ut,value:n.projectId,onChange:e=>u({projectId:e.target.value}),children:[(0,X.jsx)(f,{value:``,children:i.form.noProject}),a.map(ft)]})]}),t[21]=n.projectId,t[22]=i.form.noProject,t[23]=i.form.project,t[24]=o,t[25]=a,t[26]=u,t[27]=b):b=t[27];let x;t[28]!==n.projectId||t[29]!==i.experience.projectRequired||t[30]!==c?(x=c&&!n.projectId?(0,X.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:i.experience.projectRequired}):null,t[28]=n.projectId,t[29]=i.experience.projectRequired,t[30]=c,t[31]=x):x=t[31];let S;t[32]===u?S=t[33]:(S=e=>u({triggerMode:e.target.value}),t[32]=u,t[33]=S);let C;t[34]===i.trigger.once?C=t[35]:(C=(0,X.jsx)(f,{value:`once`,children:i.trigger.once}),t[34]=i.trigger.once,t[35]=C);let w;t[36]===i.trigger.daily?w=t[37]:(w=(0,X.jsx)(f,{value:`daily`,children:i.trigger.daily}),t[36]=i.trigger.daily,t[37]=w);let T;t[38]===i.trigger.weekly?T=t[39]:(T=(0,X.jsx)(f,{value:`weekly`,children:i.trigger.weekly}),t[38]=i.trigger.weekly,t[39]=T);let E;t[40]!==n.triggerMode||t[41]!==S||t[42]!==C||t[43]!==w||t[44]!==T?(E=(0,X.jsxs)(d,{className:ut,value:n.triggerMode,onChange:S,children:[C,w,T]}),t[40]=n.triggerMode,t[41]=S,t[42]=C,t[43]=w,t[44]=T,t[45]=E):E=t[45];let D;t[46]!==i.form.trigger||t[47]!==E?(D=(0,X.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.form.trigger,E]}),t[46]=i.form.trigger,t[47]=E,t[48]=D):D=t[48];let O;t[49]!==n.onceAt||t[50]!==n.time||t[51]!==n.triggerMode||t[52]!==i.form.onceAt||t[53]!==i.form.time||t[54]!==u?(O=n.triggerMode===`once`?(0,X.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.form.onceAt,(0,X.jsx)(`input`,{type:`datetime-local`,className:ut,value:n.onceAt,onChange:e=>u({onceAt:e.target.value})})]}):(0,X.jsxs)(`div`,{className:`grid gap-2 text-sm text-fg`,children:[(0,X.jsx)(`span`,{children:i.form.time}),(0,X.jsx)(Be,{value:n.time,onChange:e=>u({time:e}),ariaLabel:i.form.time})]}),t[49]=n.onceAt,t[50]=n.time,t[51]=n.triggerMode,t[52]=i.form.onceAt,t[53]=i.form.time,t[54]=u,t[55]=O):O=t[55];let ee;t[56]!==n.triggerMode||t[57]!==n.weekday||t[58]!==i.form.day||t[59]!==i.weekdays||t[60]!==u?(ee=n.triggerMode===`weekly`&&(0,X.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.form.day,(0,X.jsx)(d,{className:ut,value:n.weekday,onChange:e=>u({weekday:e.target.value}),children:[`sunday`,`monday`,`tuesday`,`wednesday`,`thursday`,`friday`,`saturday`].map((e,t)=>(0,X.jsx)(f,{value:String(t),children:i.weekdays[e]},e))})]}),t[56]=n.triggerMode,t[57]=n.weekday,t[58]=i.form.day,t[59]=i.weekdays,t[60]=u,t[61]=ee):ee=t[61];let te;t[62]!==D||t[63]!==O||t[64]!==ee?(te=(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[D,O,ee]}),t[62]=D,t[63]=O,t[64]=ee,t[65]=te):te=t[65];let k;t[66]!==n.onceAt||t[67]!==n.triggerMode||t[68]!==i.experience.futureTime?(k=n.triggerMode===`once`&&n.onceAt&&new Date(n.onceAt).getTime()<=Date.now()?(0,X.jsx)(`p`,{role:`status`,className:`text-sm text-red-700 dark:text-red-300`,children:i.experience.futureTime}):null,t[66]=n.onceAt,t[67]=n.triggerMode,t[68]=i.experience.futureTime,t[69]=k):k=t[69];let A;t[70]===i.experience.scheduleNote?A=t[71]:(A=(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.experience.scheduleNote}),t[70]=i.experience.scheduleNote,t[71]=A);let j;t[72]===u?j=t[73]:(j=e=>u({notificationPolicy:e.target.value}),t[72]=u,t[73]=j);let M;t[74]===i.draft.notifyAll?M=t[75]:(M=(0,X.jsx)(f,{value:`all`,children:i.draft.notifyAll}),t[74]=i.draft.notifyAll,t[75]=M);let N;t[76]===i.draft.notifyAttention?N=t[77]:(N=(0,X.jsx)(f,{value:`attention`,children:i.draft.notifyAttention}),t[76]=i.draft.notifyAttention,t[77]=N);let ne;t[78]===i.draft.notifyNone?ne=t[79]:(ne=(0,X.jsx)(f,{value:`none`,children:i.draft.notifyNone}),t[78]=i.draft.notifyNone,t[79]=ne);let P;t[80]!==n.notificationPolicy||t[81]!==j||t[82]!==M||t[83]!==N||t[84]!==ne?(P=(0,X.jsxs)(d,{className:ut,value:n.notificationPolicy,onChange:j,children:[M,N,ne]}),t[80]=n.notificationPolicy,t[81]=j,t[82]=M,t[83]=N,t[84]=ne,t[85]=P):P=t[85];let F;t[86]!==i.draft.notifications||t[87]!==P?(F=(0,X.jsxs)(`label`,{className:`grid gap-2 text-sm text-fg`,children:[i.draft.notifications,P]}),t[86]=i.draft.notifications,t[87]=P,t[88]=F):F=t[88];let I;return t[89]!==x||t[90]!==te||t[91]!==p||t[92]!==k||t[93]!==A||t[94]!==F||t[95]!==g||t[96]!==y||t[97]!==b?(I=(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-4`,children:[p,g,y,b,x,te,k,A,F]}),t[89]=x,t[90]=te,t[91]=p,t[92]=k,t[93]=A,t[94]=F,t[95]=g,t[96]=y,t[97]=b,t[98]=I):I=t[98],I}function ft(e){return(0,X.jsx)(f,{value:e.id,children:e.name},e.id)}function pt(e,t){let n=new URLSearchParams({draft:e.trim()}),r=t?.trim();return r?n.set(`projectId`,r):n.set(`projectScope`,`none`),`/chat/new?${n.toString()}`}function mt(e,t){return t.reduce((t,n)=>n.automationId===e&&(!t||n.createdAtMs>t.createdAtMs)?n:t,void 0)}function ht(e,t){let n=mt(e.id,t),r=!!(e.state.lastRunAtMs&&(!n||e.state.lastRunAtMs>n.createdAtMs)),i=r?e.state.lastRunStatus:n?.status??e.state.lastRunStatus;return i!==`failed`&&i!==`timeout`?null:`${i}:${(r?e.state.lastRunAtMs:n?.createdAtMs??e.state.lastRunAtMs)??`unknown`}`}function gt(e,t){return ht(e,t)!==null}var _t=`xopc.automations.dismissedExecutionIssues`;function vt(){if(typeof window>`u`)return{};try{let e=JSON.parse(window.localStorage.getItem(_t)??`{}`);return!e||typeof e!=`object`||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`string`))}catch{return{}}}function yt(e,t,n){return e?q(e,n):t.never}function bt(e,t){return e.kind===`system`?e.capability===`home.advisor.refresh`?`Home AI suggestions refresh`:e.capability===`memory.temporal_sweep`?`Memory temporal sweep`:e.capability===`memory.daily_reconciliation`?`Memory daily reconciliation`:`Memory weekly knowledge maintenance`:e.kind===`browser_automation`?`Browser automation: ${e.automationId}`:e.kind===`task_command`?t.action.taskWithId.replace(`{id}`,e.taskId):e.agentId?t.action.agentWithId.replace(`{id}`,e.agentId):t.action.agent}function xt(e,t){return e.kind===`system`?`System`:e.kind===`browser_automation`?t.sources.browser:e.kind===`task_command`?t.sources.task:t.sources.agent}function St(e,t){return e===`browser_automation`?t.sources.browser:e===`task_command`?t.action.runTask:t.action.runAgent}function Ct(e,t){return e===`cron`?t.trigger.customCron:e===`event`?t.trigger.customEvent:t.trigger[e]}function wt(e){let t=(0,Fe.c)(8),{kind:n,className:r}=e;if(n===`system`){let e;return t[0]===r?e=t[1]:(e=(0,X.jsx)(W,{className:r,"aria-hidden":!0}),t[0]=r,t[1]=e),e}if(n===`browser_automation`){let e;return t[2]===r?e=t[3]:(e=(0,X.jsx)(le,{className:r,"aria-hidden":!0}),t[2]=r,t[3]=e),e}if(n===`task_command`){let e;return t[4]===r?e=t[5]:(e=(0,X.jsx)(m,{className:r,"aria-hidden":!0}),t[4]=r,t[5]=e),e}let i;return t[6]===r?i=t[7]:(i=(0,X.jsx)(we,{className:r,"aria-hidden":!0}),t[6]=r,t[7]=i),i}function Tt(e){return e.safety?.mode??`auto_apply`}function Et(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`||e===`cancelling`?`bg-blue-500/10 text-blue-700 dark:text-blue-300`:`bg-surface-hover text-fg-muted`}function Dt(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 Ot(e){return e.status===`running`||e.status===`queued`||e.status===`cancelling`}function kt(e){return e.status===`failed`||e.status===`timeout`}function At(e,t){return e.action.kind===`system`?bt(e.action,t):e.action.kind===`agent`?e.action.instruction:(e.action.kind,bt(e.action,t))}function jt(e){return e.description?.trim()??``}function Mt(e){return Ot(e)?0:kt(e)?1:e.status===`succeeded`?2:3}function Nt(e){return[...e].sort((e,t)=>{let n=Mt(e)-Mt(t);return n===0?t.createdAtMs-e.createdAtMs:n})}function Pt(){let e=(0,Fe.c)(6),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,X.jsx)(`section`,{className:`grid grid-cols-2 gap-px overflow-hidden rounded-xl border border-edge-subtle bg-edge-subtle xl:grid-cols-4`,children:Array.from({length:4}).map(It)}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,X.jsx)(w,{className:`h-4 w-36`}),(0,X.jsx)(w,{className:`h-3 w-56 max-w-full`})]}),(0,X.jsx)(w,{className:`h-7 w-20 rounded-full`})]}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,X.jsxs)(`section`,{className:`rounded-xl bg-surface-panel p-4 shadow-surface`,children:[n,(0,X.jsx)(`div`,{className:`mt-4 grid gap-2`,children:Array.from({length:6}).map(Ft)})]}),e[2]=r):r=e[2];let i,a;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,X.jsx)(w,{className:`h-4 w-32`}),a=(0,X.jsx)(w,{className:`mt-4 h-24 rounded-lg`}),e[3]=i,e[4]=a):(i=e[3],a=e[4]);let o;return e[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,X.jsxs)(`div`,{className:`grid gap-4`,"aria-hidden":`true`,children:[t,(0,X.jsxs)(`div`,{className:`grid min-h-0 items-start gap-4 xl:grid-cols-[minmax(18rem,0.8fr)_minmax(0,1.5fr)]`,children:[r,(0,X.jsxs)(`section`,{className:`hidden rounded-xl bg-surface-panel p-4 shadow-surface xl:block`,children:[i,a,(0,X.jsxs)(`div`,{className:`mt-4 grid gap-2`,children:[(0,X.jsx)(w,{className:`h-12 rounded-lg`}),(0,X.jsx)(w,{className:`h-12 rounded-lg`}),(0,X.jsx)(w,{className:`h-12 rounded-lg`})]})]})]})]}),e[5]=o):o=e[5],o}function Ft(e,t){return(0,X.jsx)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(w,{className:`size-4 rounded-full`}),(0,X.jsx)(w,{className:`h-4 w-32`}),(0,X.jsx)(w,{className:`h-5 w-20 rounded-full`})]}),(0,X.jsx)(w,{className:`mt-3 h-4 w-full`}),(0,X.jsx)(w,{className:`mt-2 h-4 w-3/5`})]}),(0,X.jsx)(w,{className:`h-8 w-24 rounded-md`})]})},t)}function It(e,t){return(0,X.jsxs)(`div`,{className:`flex min-h-12 items-center gap-2.5 bg-surface-base px-3 py-2.5`,children:[(0,X.jsx)(w,{className:`size-4 rounded-full`}),(0,X.jsx)(w,{className:`h-3 w-14`}),(0,X.jsx)(w,{className:`ml-auto h-4 w-10`})]},t)}function Lt({projectId:e,embedded:t=!1,title:n,subtitle:r}){let a=x(e=>e.language),s=_(a),l=s.automations,u=s.productNavigation.sections[`automation-triggers`],p=s.cron,h=B(e=>e.setPageHeader),g=B(e=>e.clearPageHeader),y=o(),[b,w]=i(),E=!t&&b.get(`view`)===`activity`,A=b.get(`run`)?.trim()??``,ne=b.get(`automation`)?.trim()??``,oe=b.get(`draft`)?.trim()??``,se=b.get(`action`)?.trim()??``,L=b.get(`taskId`)?.trim()??``,pe=b.get(`projectId`)?.trim()??``,z=e?.trim()||pe,U=!!e?.trim(),ge=b.get(`autogenerate`)===`1`,be=(0,Y.useRef)(``),xe=b.get(`status`),Te=xe===`active`||xe===`paused`||xe===`running`||xe===`attention`?xe:`all`,K=b.get(`ownership`)===`system`?`system`:`user`,Oe=b.get(`source`),q=Oe===`agent`||Oe===`task_command`||Oe===`browser_automation`?Oe:`all`,ke=b.get(`q`)??``,Ae=e=>w(t=>{let n=new URLSearchParams(t);return e===`all`?n.delete(`status`):n.set(`status`,e),n.delete(`automation`),n}),Ne=e=>w(t=>{let n=new URLSearchParams(t);return e===`user`?n.delete(`ownership`):n.set(`ownership`,e),n.delete(`automation`),n}),Pe=e=>w(t=>{let n=new URLSearchParams(t);return e?n.set(`q`,e):n.delete(`q`),n.delete(`automation`),n},{replace:!0}),Fe=e=>w(t=>{let n=new URLSearchParams(t);return e===`all`?n.delete(`source`):n.set(`source`,e),n.delete(`automation`),n}),Ie=()=>w(e=>{let t=new URLSearchParams(e);return t.delete(`status`),t.delete(`source`),t.delete(`q`),t.delete(`automation`),t}),[Le,Re]=(0,Y.useState)(null),[ze,Be]=(0,Y.useState)(!1),[Ve,He]=(0,Y.useState)(`blank`),[Ue,We]=(0,Y.useState)(null),[Ge,Ke]=(0,Y.useState)(!1),[Z,qe]=(0,Y.useState)($e),[Je,Ye]=(0,Y.useState)(null),[Xe,Ze]=(0,Y.useState)(null),[et,nt]=(0,Y.useState)(!1),[rt,it]=(0,Y.useState)(null),[at,ut]=(0,Y.useState)(``),[ft,yt]=(0,Y.useState)(null),[bt,xt]=(0,Y.useState)(!1),[St,Ct]=(0,Y.useState)(!1),[wt,Tt]=(0,Y.useState)(z),[Et,Dt]=(0,Y.useState)(`new_session`),[kt,Mt]=(0,Y.useState)(`attention`),[Ft,It]=(0,Y.useState)(null),[Lt,Vt]=(0,Y.useState)(!1),[Ht,Ut]=(0,Y.useState)(!1),[qt,Jt]=(0,Y.useState)(!1),[Yt,Xt]=(0,Y.useState)(null),[$t,en]=(0,Y.useState)(vt),tn=S([`automations`,z],()=>V.list(z?{projectId:z}:void 0),{keepPreviousData:!0,refreshInterval:15e3}),nn=S([`automation-runs`,z],()=>V.runs(50,void 0,z?{projectId:z}:void 0),{keepPreviousData:!0,refreshInterval:1e4}),rn=S(z?`automations-global-system-source`:null,()=>V.list(),{keepPreviousData:!0,refreshInterval:15e3}),an=S(z?`automation-runs-global-system-source`:null,()=>V.runs(50),{keepPreviousData:!0,refreshInterval:1e4}),on=S(rt?[`automation-history`,rt,z]:null,()=>V.runs(50,rt,z?{projectId:z}:void 0),{refreshInterval:1e4}),ln=S(Xe?`automation-run-events:${Xe}`:null,()=>V.runEvents(Xe),{refreshInterval:5e3}),un=S(`automation-browser-automations`,()=>je.list()),$=S(`automation-chat-agents`,Ce),dn=S(`automation-tasks`,V.tasks),fn=S(`automation-projects`,()=>M({sortBy:`name`,sortOrder:`asc`,limit:200})),pn=tn.isLoading&&!tn.data||nn.isLoading&&!nn.data||!!z&&rn.isLoading&&!rn.data||!!z&&an.isLoading&&!an.data,mn=!pn&&(tn.isLoading||nn.isLoading||rn.isLoading||an.isLoading),hn=tn.data?.automations??[],gn=z?rn.data?.automations??[]:hn,_n=(0,Y.useMemo)(()=>Nt(nn.data?.runs??[]),[nn.data?.runs]),vn=(0,Y.useMemo)(()=>z?Nt(an.data?.runs??[]):_n,[an.data?.runs,z,_n]),yn=(0,Y.useMemo)(()=>hn.filter(e=>!Qe(e)),[hn]),bn=(0,Y.useMemo)(()=>gn.filter(Qe),[gn]),xn=(0,Y.useMemo)(()=>[...yn,...bn],[bn,yn]),Sn=(0,Y.useMemo)(()=>new Set(bn.map(e=>e.id)),[bn]),Cn=(0,Y.useMemo)(()=>_n.filter(e=>!Sn.has(e.automationId)),[_n,Sn]),wn=(0,Y.useMemo)(()=>vn.filter(e=>Sn.has(e.automationId)),[vn,Sn]),Tn=(0,Y.useMemo)(()=>z?[..._n,...wn]:_n,[z,_n,wn]),En=(0,Y.useMemo)(()=>Tn.find(e=>e.id===Xe)??on.data?.runs.find(e=>e.id===Xe)??null,[Tn,Xe,on.data]),Dn=(0,Y.useMemo)(()=>xn.find(e=>e.id===rt)??null,[xn,rt]),On=(0,Y.useMemo)(()=>xn.find(e=>e.id===Ue)??null,[xn,Ue]),kn=(0,Y.useMemo)(()=>[...on.data?.runs??Tn].filter(e=>e.automationId===rt).sort((e,t)=>t.createdAtMs-e.createdAtMs),[Tn,rt,on.data]),An=ln.data?.events??[],jn=(0,Y.useMemo)(()=>Cn.filter(e=>!Ot(e)&&e.readAtMs==null),[Cn]),Mn=ke.trim().toLocaleLowerCase(),Nn=K===`system`?bn:yn,Pn=K===`system`?wn:Cn,Fn=(0,Y.useMemo)(()=>new Set(Pn.filter(Ot).map(e=>e.automationId)),[Pn]),In=(0,Y.useMemo)(()=>Nn.filter(e=>Te===`attention`&&!gt(e,Pn)||Te===`running`&&!Fn.has(e.id)||Te===`active`&&!e.enabled||Te===`paused`&&e.enabled||q!==`all`&&e.action.kind!==q?!1:Mn?[e.name,jt(e),At(e,l),Ee(e.trigger,l,p,a)].some(e=>e.toLocaleLowerCase().includes(Mn)):!0),[p,Te,l,a,Mn,Nn,Pn,Fn,q]),Ln=(0,Y.useMemo)(()=>(un.data?.automations??[]).filter(e=>e.enabled),[un.data]),Rn=$.data?.items??[],zn=(0,Y.useMemo)(()=>(dn.data?.items??[]).map(e=>e.task),[dn.data]),Bn=fn.data?.items??[],Vn=(0,Y.useMemo)(()=>Ln.find(e=>e.id===Z.browserAutomationId.trim())??null,[Ln,Z.browserAutomationId]),Hn=!!On?.management?.editable.includes(`trigger`),Un=[`daily`,`weekly`,`interval`,`cron`].includes(Z.triggerMode)&&(![`daily`,`weekly`].includes(Z.triggerMode)||/^(?:[01]\d|2[0-3]):[0-5]\d$/.test(Z.time))&&(Z.triggerMode!==`interval`||J(Z.intervalValue,Z.intervalUnit)>=6e4)&&(Z.triggerMode!==`cron`||!!Z.cronExpr.trim()),Wn=Hn?Un:!!Z.name.trim()&&(Z.triggerMode!==`once`||Number.isFinite(new Date(Z.onceAt).getTime())&&(!!On||new Date(Z.onceAt).getTime()>Date.now()))&&(![`daily`,`weekly`].includes(Z.triggerMode)||/^(?:[01]\d|2[0-3]):[0-5]\d$/.test(Z.time))&&(Z.triggerMode!==`event`||!!Z.eventType.trim()&&ot(Z.eventPayloadMatch))&&(Z.actionMode===`browser_automation`?Vn!==null&&Me(Vn,Z.browserAutomationInputs):Z.actionMode===`task_command`?!!(Z.taskId.trim()&&Z.agentId.trim()):!!Z.instruction.trim()),Gn=(0,Y.useMemo)(()=>lt(l),[l]),Kn=(0,Y.useMemo)(()=>yn.filter(e=>gt(e,Cn)),[yn,Cn]),qn=(0,Y.useMemo)(()=>Nn.filter(e=>gt(e,Pn)),[Nn,Pn]),Jn=Kn.some(e=>{let t=ht(e,Cn);return t!==null&&$t[e.id]!==t}),Yn=Pn.filter(Ot).length,Xn=Nn.filter(e=>e.enabled&&e.state.nextRunAtMs).sort((e,t)=>(e.state.nextRunAtMs??1/0)-(t.state.nextRunAtMs??1/0))[0],Zn=(0,Y.useMemo)(()=>({all:Nn.length,agent:Nn.filter(e=>e.action.kind===`agent`).length,task_command:Nn.filter(e=>e.action.kind===`task_command`).length,browser_automation:Nn.filter(e=>e.action.kind===`browser_automation`).length}),[Nn]),Qn=Number(Te!==`all`)+Number(q!==`all`),$n=(0,Y.useCallback)(()=>{en(e=>{let t={...e};for(let e of Kn){let n=ht(e,Cn);n&&(t[e.id]=n)}try{window.localStorage.setItem(_t,JSON.stringify(t))}catch{}return t})},[Kn,Cn]);(0,Y.useEffect)(()=>{if(!mn){if(In.length===0){it(null);return}if(ne&&In.some(e=>e.id===ne)){it(ne);return}rt&&In.some(e=>e.id===rt)||it(In[0].id)}},[ne,In,mn,rt]);let er=(0,Y.useCallback)(async()=>{await Promise.all([tn.mutate(),nn.mutate(),rn.mutate(),an.mutate(),on.mutate(),ln.mutate()])},[tn.mutate,rn.mutate,an.mutate,ln.mutate,nn.mutate,on.mutate]),tr=(0,Y.useCallback)(e=>{if(U){it(null),Ze(null);return}w(t=>{let n=new URLSearchParams(t);return e?n.set(`projectId`,e):n.delete(`projectId`),n.delete(`automation`),n.delete(`run`),n}),it(null),Ze(null)},[U,w]);(0,Y.useEffect)(()=>{U&&(Tt(z),qe(e=>e.projectId===z?e:{...e,projectId:z}))},[z,U]);let nr=(0,Y.useCallback)(e=>{if(We(null),Ke(!1),Ye(null),He(e),Be(!0),e===`blank`){qe({...$e,projectId:z});return}ut(``),yt(null),Ct(!1),Tt(z),Dt(`new_session`),Mt(`attention`)},[z]),rr=(0,Y.useCallback)(()=>{y(pt(l.createWithAssistantPrompt,z))},[l.createWithAssistantPrompt,y,z]),ir=e=>{Re(e),qe({...e.form,projectId:z}),We(null),Ke(!1),Ye(null),He(`quick`),Be(!0)},ar=(0,Y.useCallback)(e=>{qe(st(e)),We(e.id),Ke(!1),it(null),He(`blank`),Be(!0)},[]),or=(0,Y.useCallback)(()=>{ft&&(qe({...st(ft.automation),projectId:wt,conversationMode:Et,notificationPolicy:kt}),We(null),Ke(!0),He(`blank`))},[ft,Et,kt,wt]),sr=(0,Y.useCallback)(async()=>{Jt(!0),Ye(null);try{await er()}catch(e){Ye(e instanceof Error?e.message:String(e))}finally{Jt(!1)}},[l.feedback.actionFailed,er]);(0,Y.useEffect)(()=>{let e=xn.find(e=>e.id===ne);!e||!Qe(e)||K===`system`||w(e=>{let t=new URLSearchParams(e);return t.set(`ownership`,`system`),t},{replace:!0})},[ne,xn,K,w]),(0,Y.useEffect)(()=>{se===`create`&&(nr(`blank`),L&&qe(e=>({...e,actionMode:`task_command`,taskId:L,safetyMode:`auto_apply`})),w(e=>{let t=new URLSearchParams(e);return t.delete(`action`),t.delete(`taskId`),t},{replace:!0}))},[se,nr,w,L]),(0,Y.useEffect)(()=>{if(!oe)return;let e=`${a}:${ge?`auto`:`seed`}:${oe}`;be.current!==e&&(be.current=e,ut(oe),yt(null),Ct(!1),Tt(z),He(`draft`),Be(!0),w(e=>{let t=new URLSearchParams(e);return t.delete(`draft`),t.delete(`autogenerate`),t},{replace:!0}),ge&&(Ye(null),xt(!0),V.draft({prompt:oe,language:a}).then(e=>{yt(e.draft),Ct(!1)}).catch(e=>{Ye(e instanceof Error?e.message:String(e))}).finally(()=>{xt(!1)})))},[ge,oe,a,z,w]);let cr=(0,Y.useCallback)(e=>{let t=_n.find(t=>t.id===e)??on.data?.runs.find(t=>t.id===e);if(!t||Ot(t)||t.readAtMs!=null)return;let n=Date.now();nn.mutate(t=>t&&{...t,runs:t.runs.map(t=>t.id===e?{...t,readAtMs:n}:t)},!1),on.mutate(t=>t&&{...t,runs:t.runs.map(t=>t.id===e?{...t,readAtMs:n}:t)},!1),V.markRunRead(e).catch(e=>{Ye(e instanceof Error?e.message:String(e)),nn.mutate(),on.mutate()})},[_n,nn.mutate,on.data,on.mutate]),lr=(0,Y.useCallback)(e=>{cr(e),Ze(e),nt(!0),w(t=>{let n=new URLSearchParams(t);return n.set(`run`,e),n},{replace:!0})},[cr,w]),ur=(0,Y.useCallback)(e=>{it(e);let t=mt(e,Tn);w(t=>{let n=new URLSearchParams(t);return n.set(`automation`,e),n},{replace:!0}),t&&t.readAtMs==null&&!Ot(t)&&cr(t.id)},[Tn,cr,w]),dr=(0,Y.useCallback)(()=>{if(!Xn)return;it(Xn.id);let e=mt(Xn.id,Tn);w(e=>{let t=new URLSearchParams(e);return t.delete(`status`),t.delete(`source`),t.delete(`q`),t.set(`automation`,Xn.id),t},{replace:!0}),e&&e.readAtMs==null&&!Ot(e)&&cr(e.id)},[Tn,cr,Xn,w]);(0,Y.useEffect)(()=>{A&&(cr(A),Ze(A),nt(!0))},[cr,A]),(0,Y.useEffect)(()=>{It(null),Ut(!1)},[Xe]);async function fr(){if(Ye(null),Z.triggerMode===`once`&&!On&&new Date(Z.onceAt).getTime()<=Date.now()){Ye(l.experience.futureTime);return}if(!(!Wn||Yt)&&!(Ve===`quick`&&Le?.requiresProject&&!Z.projectId)){if(Ge&&ft){Xt(`draft:edit`);try{let e=tt(Z),{simulation:t}=await V.simulate(e);yt({...ft,automation:e,simulation:t}),Tt(Z.projectId),Dt(Z.conversationMode),Mt(Z.notificationPolicy),Ct(!1),Ke(!1),He(`draft`)}catch(e){Ye(e instanceof Error?e.message:String(e))}finally{Xt(null)}return}if(On){let e=On.id;await pr(`automation:${e}:edit`,()=>V.update(e,Hn?{trigger:ct(On,{...Z,instruction:`managed`}).trigger}:ct(On,Z)))&&(Be(!1),We(null),it(e));return}Xt(`automation:create`);try{let e=tt(Z),{automation:t}=await V.create(e);qe($e),Be(!1),w(e=>{let n=new URLSearchParams(e);return n.delete(`status`),n.delete(`q`),n.delete(`run`),n.set(`automation`,t.id),U||(t.projectId?n.set(`projectId`,t.projectId):n.delete(`projectId`)),n}),await er(),it(t.id)}catch(e){Ye(e instanceof Error?e.message:String(e))}finally{Xt(null)}}}async function pr(e,t){Ye(null),Xt(e);try{return await t(),await er(),!0}catch(e){return Ye(e instanceof Error?e.message:String(e)),!1}finally{Xt(null)}}async function mr(){await pr(`runs:read-all`,()=>V.markAllRunsRead(z||void 0))}async function hr(){let e=at.trim();if(e){Ye(null),xt(!0);try{yt((await V.draft({prompt:e,language:a})).draft),Ct(!1)}catch(e){Ye(e instanceof Error?e.message:String(e))}finally{xt(!1)}}}async function gr(){if(!ft)return;let e=``,t=``;await pr(`draft:publish`,async()=>{let{automation:n}=await V.create({...ft.automation,...wt?{projectId:wt}:{projectId:void 0},conversationMode:Et,delivery:{...ft.automation.delivery,notificationPolicy:kt}});yt(null),ut(``),Ct(!1),Be(!1),Ae(`all`),Pe(``),e=n.id,t=n.projectId??``})&&e&&(tr(t),it(e))}async function _r(){if(!ft)return;let e=``,t=``,n=``;await pr(`draft:test`,async()=>{let{automation:r}=await V.create({...ft.automation,...wt?{projectId:wt}:{projectId:void 0},conversationMode:Et,delivery:{...ft.automation.delivery,notificationPolicy:kt},enabled:!1}),{run:i}=await V.runNow(r.id);e=r.id,t=r.projectId??``,n=i.id,yt(null),ut(``),Ct(!1),Be(!1),Ae(`all`),Pe(``)})&&e&&n&&(tr(t),it(e),lr(n))}async function vr(e){Ye(null),Vt(!0),It(null),Ut(!1);try{It((await V.repairDraft(e.id,{language:a})).repair)}catch(e){Ye(e instanceof Error?e.message:String(e))}finally{Vt(!1)}}async function yr(e){Ft&&await pr(`run:${e.id}:repair`,async()=>{await V.update(e.automationId,Ft.patch),It(null),Ut(!1)})}let br=(0,Y.useMemo)(()=>(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(G,{className:`size-9 shrink-0 p-0`,loading:qt,label:l.refresh,onClick:sr}),(0,X.jsxs)(`div`,{className:`inline-flex h-9 shrink-0`,role:`group`,"aria-label":l.createOptions,children:[(0,X.jsxs)(C,{variant:`primary`,className:`h-9 rounded-r-none pr-2.5`,onClick:rr,children:[(0,X.jsx)(ue,{className:`size-4`,"aria-hidden":!0}),l.create]}),(0,X.jsxs)(me,{children:[(0,X.jsx)(ye,{asChild:!0,children:(0,X.jsx)(C,{variant:`primary`,className:`h-9 w-9 rounded-l-none border-l border-white/20 px-0`,"aria-label":l.createOptions,title:l.createOptions,children:(0,X.jsx)(c,{className:`size-4`,"aria-hidden":!0})})}),(0,X.jsx)(ve,{children:(0,X.jsxs)(R,{align:`end`,sideOffset:6,className:`z-70 min-w-52 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:[(0,X.jsxs)(_e,{className:`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,onSelect:rr,children:[(0,X.jsx)(H,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),l.createWithAssistant]}),(0,X.jsxs)(_e,{className:`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,onSelect:()=>nr(`blank`),children:[(0,X.jsx)(fe,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),l.setUpManually]})]})})]})]})]}),[l.create,l.createOptions,l.createWithAssistant,l.refresh,l.setUpManually,rr,nr,qt,sr]);return(0,Y.useLayoutEffect)(()=>{if(!t)return h({startExtra:null,main:(0,X.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:u}),end:br}),()=>g()},[g,t,br,u,h]),(0,X.jsxs)(`div`,{className:v(`flex min-h-0 min-w-0 flex-1 flex-col`,t?`bg-transparent`:`bg-surface-panel`),children:[(0,X.jsxs)(`div`,{className:v(`flex w-full flex-col gap-4`,t?`py-1`:`mx-auto max-w-[96rem] px-4 pb-7 pt-3 sm:px-6 lg:px-8 lg:pb-9 lg:pt-4`),children:[t?(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 rounded-xl border border-edge-subtle bg-surface-base px-4 py-3 shadow-surface`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(W,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n||l.title})]}),(0,X.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:r||l.subtitle})]}),br]}):null,Je||tn.error||nn.error||rn.error||an.error?(0,X.jsx)(`div`,{role:`alert`,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:Je||l.feedback.actionFailed}):null,E?pn?(0,X.jsx)(Pt,{}):(0,X.jsx)(Gt,{runs:Pn,ownership:K,labels:l,language:a,unreadCount:K===`user`?jn.length:0,loading:mn||qt,onOwnershipChange:Ne,onRefresh:sr,onSelectRun:lr}):(0,X.jsxs)(X.Fragment,{children:[pn?null:(0,X.jsxs)(`section`,{"aria-labelledby":`automation-overview-title`,children:[(0,X.jsx)(`h2`,{id:`automation-overview-title`,className:`sr-only`,children:l.overview.title}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-px overflow-hidden rounded-xl border border-edge-subtle bg-edge-subtle xl:grid-cols-4`,children:[(0,X.jsx)(Wt,{icon:(0,X.jsx)(W,{className:`size-4`,"aria-hidden":!0}),label:l.metrics.enabled,value:String(Nn.filter(e=>e.enabled).length),active:Te===`active`,onClick:()=>Ae(`active`)}),(0,X.jsx)(Wt,{icon:(0,X.jsx)(te,{className:`size-4`,"aria-hidden":!0}),label:l.metrics.running,value:String(Yn),active:Te===`running`,onClick:()=>Ae(`running`)}),(0,X.jsx)(Wt,{icon:(0,X.jsx)(he,{className:`size-4`,"aria-hidden":!0}),label:l.dashboard.needsAttention,value:String(qn.length),tone:qn.length>0?`danger`:`default`,active:Te===`attention`,onClick:()=>Ae(`attention`)}),(0,X.jsx)(Wt,{icon:(0,X.jsx)(N,{className:`size-4`,"aria-hidden":!0}),label:l.metrics.next,value:Xn?De(Xn.state.nextRunAtMs,a):`—`,onClick:Xn?dr:void 0})]})]}),!pn&&Jn&&K===`user`?(0,X.jsxs)(`div`,{className:`flex items-center rounded-lg border border-red-500/20 bg-red-500/5`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>Ae(`attention`),className:`flex min-w-0 flex-1 items-center gap-3 rounded-l-lg px-4 py-3 text-left focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,X.jsx)(he,{className:`size-4 shrink-0 text-red-700 dark:text-red-300`,"aria-hidden":!0}),(0,X.jsxs)(`span`,{className:`min-w-0 text-sm text-fg`,children:[(0,X.jsxs)(`span`,{className:`font-medium`,children:[l.experience.executionIssues,` · `,Kn.length]}),(0,X.jsx)(`span`,{className:`ml-2 text-fg-muted`,children:l.experience.issuesDescription})]})]}),(0,X.jsx)(`button`,{type:`button`,onClick:$n,className:`mr-2 rounded-md p-2 text-fg-muted hover:bg-red-500/10 hover:text-fg focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":l.close,title:l.close,children:(0,X.jsx)(ie,{className:`size-4`,"aria-hidden":!0})})]}):null,pn?(0,X.jsx)(Pt,{}):(0,X.jsxs)(`section`,{className:`grid min-h-0 items-start gap-4 xl:grid-cols-[minmax(18rem,0.8fr)_minmax(0,1.5fr)]`,"aria-busy":mn,children:[(0,X.jsxs)(`aside`,{className:`flex max-h-[42rem] flex-col overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface xl:sticky xl:top-20 xl:max-h-[calc(100vh-7rem)]`,children:[(0,X.jsxs)(`div`,{className:`shrink-0 border-b border-edge-subtle p-3`,children:[U?null:(0,X.jsxs)(d,{"aria-label":l.filters.project,className:Q,value:z,onChange:e=>tr(e.target.value),children:[(0,X.jsx)(f,{value:``,children:l.filters.allProjects}),Bn.map(e=>(0,X.jsx)(f,{value:e.id,children:e.name},e.id))]}),(0,X.jsxs)(`div`,{className:v(`flex items-center gap-2`,!U&&`mt-2`),children:[(0,X.jsxs)(`label`,{className:`flex min-w-0 flex-1 items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg-muted focus-within:border-accent`,children:[(0,X.jsx)(k,{className:`size-4 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent text-fg outline-none placeholder:text-fg-subtle`,value:ke,onChange:e=>Pe(e.target.value),placeholder:l.filters.search,"aria-label":l.filters.search})]}),(0,X.jsxs)(O,{children:[(0,X.jsx)(ee,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,className:v(`inline-flex h-10 shrink-0 items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-3 text-sm font-medium text-fg-muted transition-colors hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,Qn>0&&`border-accent/40 bg-accent/8 text-accent-fg`),"aria-label":l.filters.more,children:[(0,X.jsx)(Se,{className:`size-4`,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:l.filters.more}),Qn>0?(0,X.jsx)(`span`,{className:`inline-flex min-w-5 items-center justify-center rounded-full bg-accent px-1.5 text-[11px] leading-5 text-on-accent`,children:Qn}):null]})}),(0,X.jsx)(T,{children:(0,X.jsxs)(D,{align:`end`,sideOffset:6,className:`z-[90] w-[min(22rem,calc(100vw-2rem))] rounded-xl border border-edge bg-surface-overlay p-3 shadow-popover outline-none`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:l.filters.status}),(0,X.jsx)(P,{className:`mt-2 flex flex-wrap gap-1`,role:`group`,"aria-label":l.filters.status,indicatorClassName:`rounded-md bg-surface-active`,children:[{id:`all`,label:l.filters.all},{id:`active`,label:l.filters.active},{id:`running`,label:l.metrics.running},{id:`paused`,label:l.paused},{id:`attention`,label:l.experience.executionIssues}].map(e=>(0,X.jsx)(`button`,{type:`button`,className:v(`rounded-md px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,Te===e.id&&`bg-surface-active text-fg`),onClick:()=>Ae(e.id),"aria-pressed":Te===e.id,children:e.label},e.id))}),(0,X.jsxs)(`div`,{className:`mt-3 border-t border-edge-subtle pt-3`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:l.filters.executor}),(0,X.jsx)(P,{className:`mt-2 flex flex-wrap gap-1`,role:`group`,"aria-label":l.filters.executor,indicatorClassName:`rounded-md border border-edge bg-surface-active`,children:[{id:`all`,label:l.filters.allSources,icon:W},{id:`agent`,label:l.sources.agent,icon:we},{id:`task_command`,label:l.sources.task,icon:m},{id:`browser_automation`,label:l.sources.browser,icon:le}].map(e=>(0,X.jsxs)(`button`,{type:`button`,className:v(`flex min-h-8 items-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,q===e.id&&`border-edge bg-surface-active text-fg`),onClick:()=>Fe(e.id),"aria-pressed":q===e.id,children:[(0,X.jsx)(e.icon,{className:`size-3.5`,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:e.label}),(0,X.jsx)(`span`,{className:`text-fg-subtle`,children:Zn[e.id]})]},e.id))})]}),Qn>0?(0,X.jsx)(`div`,{className:`mt-3 flex justify-end border-t border-edge-subtle pt-3`,children:(0,X.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-accent-fg hover:underline`,onClick:Ie,children:l.filters.clear})}):null]})})]})]}),(0,X.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3`,children:[(0,X.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:l.filters.ownership}),(0,X.jsxs)(P,{className:`flex rounded-lg bg-surface-panel p-0.5`,role:`group`,"aria-label":l.filters.ownership,indicatorClassName:`rounded-md bg-surface-base shadow-sm`,children:[(0,X.jsxs)(`button`,{type:`button`,className:v(`rounded-md px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:text-fg`,K===`user`&&`bg-surface-base text-fg shadow-sm`),onClick:()=>Ne(`user`),"aria-pressed":K===`user`,children:[l.filters.userManaged,` · `,yn.length]}),(0,X.jsxs)(`button`,{type:`button`,className:v(`rounded-md px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:text-fg`,K===`system`&&`bg-surface-base text-fg shadow-sm`),onClick:()=>Ne(`system`),"aria-pressed":K===`system`,children:[l.system.title,` · `,bn.length]})]})]}),jn.length>0&&K===`user`?(0,X.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2 rounded-md bg-accent/8 px-2.5 py-1.5 text-xs text-accent-fg`,children:[(0,X.jsxs)(`span`,{children:[l.filters.unread,` · `,jn.length]}),(0,X.jsx)(`button`,{type:`button`,className:`font-medium hover:underline`,disabled:Yt===`runs:read-all`,onClick:()=>void mr(),children:l.filters.markAllRead})]}):null,(0,X.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3 text-xs text-fg-muted`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[mn?(0,X.jsx)(re,{className:`size-3 animate-spin`,"aria-hidden":!0}):null,mn?l.loading:l.filters.results.replace(`{count}`,String(In.length))]}),Te!==`all`||q!==`all`||Mn?(0,X.jsx)(`button`,{type:`button`,className:`font-medium text-accent-fg hover:underline`,onClick:Ie,children:l.filters.clear}):null]})]}),(0,X.jsx)(Kt,{automations:In,runs:Pn,labels:l,cronLabels:p,language:a,selectedAutomationId:rt,onOpenDetails:ur})]}),Dn?(0,X.jsx)(Qt,{automation:Dn,runs:kn,runsLoading:on.isLoading,runsError:on.error?l.feedback.actionFailed:void 0,labels:l,cronLabels:p,language:a,projects:Bn,busyAction:Yt,onEdit:ar,onSelectRun:lr,onAction:pr},Dn.id):(0,X.jsx)(`div`,{className:`min-h-[28rem] overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,children:K===`user`&&Nn.length===0?(0,X.jsxs)(`div`,{className:`p-5`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:l.experience.starterTemplates}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.experience.starterTemplatesDescription}),(0,X.jsx)(Rt,{templates:Gn,labels:l,onSelect:ir}),(0,X.jsx)(C,{className:`mt-4`,variant:`ghost`,onClick:()=>nr(`draft`),children:l.experience.custom})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(sn,{className:`min-h-56 rounded-none border-0 shadow-none`,icon:(0,X.jsx)(W,{className:`size-5`}),title:Nn.length===0?l.empty.automations:l.empty.filtered}),Nn.length>0?(0,X.jsx)(`div`,{className:`flex justify-center border-t border-edge-subtle p-4`,children:(0,X.jsx)(C,{variant:`ghost`,onClick:Ie,children:l.filters.clear})}):null]})})]}),!pn&&yn.length>0?(0,X.jsx)(`div`,{children:(0,X.jsxs)(C,{variant:`ghost`,onClick:()=>nr(`draft`),children:[(0,X.jsx)(ue,{className:`size-4`,"aria-hidden":!0}),l.experience.discover]})}):null]})]}),(0,X.jsx)(I,{open:ze,onOpenChange:e=>{Be(e),e||(We(null),Ke(!1))},children:(0,X.jsxs)(de,{children:[(0,X.jsx)(j,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,X.jsxs)(ce,{className:`xopc-dialog-content 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-overlay shadow-popover outline-none`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-5 py-4`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(F,{className:`text-base font-semibold text-fg`,children:Ve===`draft`?l.draft.title:On?l.editTitle:Ge?l.draft.editTitle:l.createTitle}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:Ve===`draft`?l.draft.subtitle:l.form.createFlowHint})]}),(0,X.jsx)(ae,{asChild:!0,children:(0,X.jsx)(C,{variant:`ghost`,"aria-label":l.close,children:(0,X.jsx)(ie,{className:`size-4`})})})]}),Je?(0,X.jsx)(`p`,{role:`alert`,className:`px-5 py-2 text-sm text-red-700 dark:text-red-300`,children:Je}):null,Ve===`draft`?(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,X.jsx)(Bt,{labels:l,prompt:at,draft:ft,loading:bt,approved:St,publishBusy:Yt===`draft:publish`,testBusy:Yt===`draft:test`,templates:Gn,projects:Bn,projectId:wt,conversationMode:Et,notificationPolicy:kt,onPromptChange:ut,onGenerate:hr,onEdit:or,onPublish:gr,onTest:_r,onProjectChange:Tt,onConversationModeChange:Dt,onNotificationPolicyChange:Mt,projectLocked:U,onApprovedChange:Ct,onDiscard:()=>{yt(null),Ct(!1)},onTemplateSelect:e=>{ir(e),qe({...e.form,projectId:wt})},onOpenAdvanced:()=>{qe({...$e,projectId:wt,conversationMode:Et,notificationPolicy:kt}),He(`blank`)}})}):(0,X.jsxs)(X.Fragment,{children:[Hn?(0,X.jsx)(zt,{form:Z,setForm:qe,labels:l}):Ve===`quick`&&Le?(0,X.jsx)(dt,{form:Z,setForm:qe,labels:l,projects:Bn,projectLocked:U,source:Le.source,requiresProject:Le.requiresProject}):(0,X.jsx)(cn,{form:Z,labels:l,setForm:qe,projects:Bn,browserAutomations:Ln,selectedBrowserAutomation:Vn,browserAutomationsLoading:un.isLoading,agentOptions:Rn,agentsLoading:$.isLoading,defaultAgentId:$.data?.defaultId??``,taskOptions:zn,tasksLoading:dn.isLoading,language:a,projectLocked:U}),(0,X.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2 border-t border-edge px-5 py-4`,children:[Ve===`quick`?(0,X.jsx)(C,{variant:`ghost`,onClick:()=>He(`blank`),children:l.draft.advancedCreate}):null,Ge?(0,X.jsx)(C,{variant:`ghost`,onClick:()=>{Ke(!1),He(`draft`)},children:l.cancel}):(0,X.jsx)(ae,{asChild:!0,children:(0,X.jsx)(C,{variant:`ghost`,children:l.cancel})}),(0,X.jsx)(C,{variant:`primary`,onClick:fr,disabled:!Wn||!!Yt||Ve===`quick`&&!!Le?.requiresProject&&!Z.projectId,children:Yt===`automation:create`||Yt===`draft:edit`||On&&Yt===`automation:${On.id}:edit`?l.feedback.working:On||Ge?l.save:l.experience.createEnabled})]})]})]})]})}),(0,X.jsx)(I,{open:et&&!!En,onOpenChange:e=>{nt(e),!e&&w(e=>{let t=new URLSearchParams(e);return t.delete(`run`),t},{replace:!0})},children:(0,X.jsxs)(de,{children:[(0,X.jsx)(j,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,X.jsxs)(ce,{className:`xopc-dialog-content 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-overlay shadow-popover outline-none`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,X.jsx)(F,{className:`truncate text-base font-semibold text-fg`,children:En?.automationName??l.dashboard.result}),(0,X.jsx)(ae,{asChild:!0,children:(0,X.jsx)(C,{variant:`ghost`,"aria-label":l.close,children:(0,X.jsx)(ie,{className:`size-4`})})})]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,X.jsx)(Zt,{className:`rounded-none border-0`,run:En,events:An,labels:l,cronLabels:p,language:a,loading:ln.isLoading,repairDraft:Ft,repairLoading:Lt,repairApproved:Ht,busyAction:Yt,onRepairApprovedChange:Ut,onSuggestRepair:vr,onApplyRepair:yr})})]})]})})]})}function Rt(e){let t=(0,Fe.c)(9),{templates:n,labels:r,onSelect:i}=e,a;if(t[0]!==r||t[1]!==i||t[2]!==n){let e;t[4]!==r||t[5]!==i?(e=e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>i(e),className:`rounded-lg border border-edge-subtle bg-surface-panel p-4 text-left hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,X.jsx)(N,{className:`mb-3 size-4 text-accent-fg`,"aria-hidden":!0}),(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.name}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.description}),(0,X.jsxs)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:[r.experience.source,`: `,e.source]})]},e.name),t[4]=r,t[5]=i,t[6]=e):e=t[6],a=n.map(e),t[0]=r,t[1]=i,t[2]=n,t[3]=a}else a=t[3];let o;return t[7]===a?o=t[8]:(o=(0,X.jsx)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:a}),t[7]=a,t[8]=o),o}function zt(e){let t=(0,Fe.c)(48),{form:n,setForm:r,labels:i}=e,a;t[0]===r?a=t[1]:(a=e=>r(t=>({...t,...e})),t[0]=r,t[1]=a);let o=a,s;t[2]!==i.form.trigger||t[3]!==i.form.triggerStepDescription?(s=(0,X.jsx)(dn,{step:`1`,title:i.form.trigger,description:i.form.triggerStepDescription}),t[2]=i.form.trigger,t[3]=i.form.triggerStepDescription,t[4]=s):s=t[4];let c;t[5]===o?c=t[6]:(c=e=>o({triggerMode:e.target.value}),t[5]=o,t[6]=c);let l;t[7]===i.trigger.daily?l=t[8]:(l=(0,X.jsx)(f,{value:`daily`,children:i.trigger.daily}),t[7]=i.trigger.daily,t[8]=l);let u;t[9]===i.trigger.weekly?u=t[10]:(u=(0,X.jsx)(f,{value:`weekly`,children:i.trigger.weekly}),t[9]=i.trigger.weekly,t[10]=u);let p;t[11]===i.trigger.interval?p=t[12]:(p=(0,X.jsx)(f,{value:`interval`,children:i.trigger.interval}),t[11]=i.trigger.interval,t[12]=p);let m;t[13]===i.trigger.customCron?m=t[14]:(m=(0,X.jsx)(f,{value:`cron`,children:i.trigger.customCron}),t[13]=i.trigger.customCron,t[14]=m);let h;t[15]!==n.triggerMode||t[16]!==c||t[17]!==l||t[18]!==u||t[19]!==p||t[20]!==m?(h=(0,X.jsxs)(d,{className:Q,value:n.triggerMode,onChange:c,children:[l,u,p,m]}),t[15]=n.triggerMode,t[16]=c,t[17]=l,t[18]=u,t[19]=p,t[20]=m,t[21]=h):h=t[21];let g;t[22]!==n.time||t[23]!==n.triggerMode||t[24]!==n.weekday||t[25]!==i.form.day||t[26]!==i.form.time||t[27]!==i.weekdays||t[28]!==o?(g=n.triggerMode===`daily`||n.triggerMode===`weekly`?(0,X.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,X.jsx)($,{label:i.form.time,children:(0,X.jsx)(Be,{value:n.time,onChange:e=>o({time:e}),ariaLabel:i.form.time})}),n.triggerMode===`weekly`?(0,X.jsx)($,{label:i.form.day,children:(0,X.jsxs)(d,{className:Q,value:n.weekday,onChange:e=>o({weekday:e.target.value}),children:[(0,X.jsx)(f,{value:`1`,children:i.weekdays.monday}),(0,X.jsx)(f,{value:`2`,children:i.weekdays.tuesday}),(0,X.jsx)(f,{value:`3`,children:i.weekdays.wednesday}),(0,X.jsx)(f,{value:`4`,children:i.weekdays.thursday}),(0,X.jsx)(f,{value:`5`,children:i.weekdays.friday}),(0,X.jsx)(f,{value:`6`,children:i.weekdays.saturday}),(0,X.jsx)(f,{value:`0`,children:i.weekdays.sunday})]})}):null]}):null,t[22]=n.time,t[23]=n.triggerMode,t[24]=n.weekday,t[25]=i.form.day,t[26]=i.form.time,t[27]=i.weekdays,t[28]=o,t[29]=g):g=t[29];let _;t[30]!==n.intervalUnit||t[31]!==n.intervalValue||t[32]!==n.triggerMode||t[33]!==i.form.intervalEvery||t[34]!==i.form.intervalUnits||t[35]!==o?(_=n.triggerMode===`interval`?(0,X.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-[minmax(0,1fr)_10rem]`,children:[(0,X.jsx)($,{label:i.form.intervalEvery,children:(0,X.jsx)(`input`,{className:Q,type:`number`,min:`1`,value:n.intervalValue,onChange:e=>o({intervalValue:e.target.value})})}),(0,X.jsx)($,{label:i.form.intervalUnits.minute,children:(0,X.jsxs)(d,{className:Q,value:n.intervalUnit,onChange:e=>o({intervalUnit:e.target.value}),children:[(0,X.jsx)(f,{value:`minute`,children:i.form.intervalUnits.minute}),(0,X.jsx)(f,{value:`hour`,children:i.form.intervalUnits.hour}),(0,X.jsx)(f,{value:`day`,children:i.form.intervalUnits.day}),(0,X.jsx)(f,{value:`week`,children:i.form.intervalUnits.week})]})})]}):null,t[30]=n.intervalUnit,t[31]=n.intervalValue,t[32]=n.triggerMode,t[33]=i.form.intervalEvery,t[34]=i.form.intervalUnits,t[35]=o,t[36]=_):_=t[36];let v;t[37]!==n.cronExpr||t[38]!==n.triggerMode||t[39]!==i.form.expression||t[40]!==o?(v=n.triggerMode===`cron`?(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)($,{label:i.form.expression,children:(0,X.jsx)(`input`,{className:Q,value:n.cronExpr,onChange:e=>o({cronExpr:e.target.value})})})}):null,t[37]=n.cronExpr,t[38]=n.triggerMode,t[39]=i.form.expression,t[40]=o,t[41]=v):v=t[41];let y;return t[42]!==_||t[43]!==v||t[44]!==s||t[45]!==h||t[46]!==g?(y=(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[s,h,g,_,v]}),t[42]=_,t[43]=v,t[44]=s,t[45]=h,t[46]=g,t[47]=y):y=t[47],y}function Bt(e){let t=(0,Fe.c)(110),{labels:n,prompt:r,draft:i,loading:a,approved:o,publishBusy:s,testBusy:c,templates:l,projects:u,projectId:p,conversationMode:m,notificationPolicy:h,onPromptChange:g,onGenerate:_,onEdit:y,onPublish:b,onTest:x,onProjectChange:S,onConversationModeChange:w,onNotificationPolicyChange:T,onApprovedChange:E,onDiscard:D,onTemplateSelect:O,onOpenAdvanced:ee,projectLocked:te}=e,k=s===void 0?!1:s,A=c===void 0?!1:c,j=te===void 0?!1:te,M=!!(i&&i.simulation.requiredConfirmations.length>0),N;t[0]!==i||t[1]!==n.draft.advancedCreate||t[2]!==n.draft.suggestions||t[3]!==n.draft.suggestionsDescription||t[4]!==n.experience||t[5]!==ee||t[6]!==O||t[7]!==l?(N=i?null:(0,X.jsxs)(`div`,{className:`mb-5 border-b border-edge-subtle pb-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.draft.suggestions}),(0,X.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:n.draft.suggestionsDescription})]}),(0,X.jsx)(C,{variant:`ghost`,onClick:ee,children:n.draft.advancedCreate})]}),(0,X.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:l.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`focus-visible:ring-2 focus-visible:ring-accent rounded-lg border border-edge-subtle bg-surface-panel p-3 text-left hover:bg-surface-hover`,onClick:()=>O(e),children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.name}),(0,X.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:e.description}),(0,X.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[n.experience.source,`: `,e.source]})]},e.name))})]}),t[0]=i,t[1]=n.draft.advancedCreate,t[2]=n.draft.suggestions,t[3]=n.draft.suggestionsDescription,t[4]=n.experience,t[5]=ee,t[6]=O,t[7]=l,t[8]=N):N=t[8];let P;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,X.jsx)(we,{className:`size-4 text-accent`}),t[9]=P):P=t[9];let F;t[10]===n.draft.title?F=t[11]:(F=(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[P,n.draft.title]}),t[10]=n.draft.title,t[11]=F);let I;t[12]===n.draft.subtitle?I=t[13]:(I=(0,X.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:n.draft.subtitle}),t[12]=n.draft.subtitle,t[13]=I);let re;t[14]!==F||t[15]!==I?(re=(0,X.jsxs)(`div`,{className:`min-w-0`,children:[F,I]}),t[14]=F,t[15]=I,t[16]=re):re=t[16];let ie;t[17]!==a||t[18]!==r?(ie=a||!r.trim(),t[17]=a,t[18]=r,t[19]=ie):ie=t[19];let ae;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,X.jsx)(we,{className:`size-4`}),t[20]=ae):ae=t[20];let oe=a?n.draft.generating:n.draft.generate,se;t[21]!==_||t[22]!==oe||t[23]!==ie?(se=(0,X.jsxs)(C,{variant:`primary`,onClick:_,disabled:ie,children:[ae,oe]}),t[21]=_,t[22]=oe,t[23]=ie,t[24]=se):se=t[24];let ce;t[25]!==se||t[26]!==re?(ce=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[re,se]}),t[25]=se,t[26]=re,t[27]=ce):ce=t[27];let le;t[28]===g?le=t[29]:(le=e=>g(e.target.value),t[28]=g,t[29]=le);let ue;t[30]!==n.draft.placeholder||t[31]!==n.draft.title||t[32]!==r||t[33]!==le?(ue=(0,X.jsx)(`textarea`,{"aria-label":n.draft.title,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:le,placeholder:n.draft.placeholder}),t[30]=n.draft.placeholder,t[31]=n.draft.title,t[32]=r,t[33]=le,t[34]=ue):ue=t[34];let de=j?`sm:grid-cols-2`:`sm:grid-cols-3`,L;t[35]===de?L=t[36]:(L=v(`mt-3 grid gap-3`,de),t[35]=de,t[36]=L);let pe;t[37]!==n.draft.noProject||t[38]!==n.draft.project||t[39]!==S||t[40]!==p||t[41]!==j||t[42]!==u?(pe=j?null:(0,X.jsx)($,{label:n.draft.project,children:(0,X.jsxs)(d,{className:Q,value:p,onChange:e=>S(e.target.value),children:[(0,X.jsx)(f,{value:``,children:n.draft.noProject}),u.map(Vt)]})}),t[37]=n.draft.noProject,t[38]=n.draft.project,t[39]=S,t[40]=p,t[41]=j,t[42]=u,t[43]=pe):pe=t[43];let R;t[44]===w?R=t[45]:(R=e=>w(e.target.value),t[44]=w,t[45]=R);let z;t[46]===n.draft.newConversation?z=t[47]:(z=(0,X.jsx)(f,{value:`new_session`,children:n.draft.newConversation}),t[46]=n.draft.newConversation,t[47]=z);let B;t[48]===n.draft.continuousConversation?B=t[49]:(B=(0,X.jsx)(f,{value:`continuous`,children:n.draft.continuousConversation}),t[48]=n.draft.continuousConversation,t[49]=B);let V;t[50]!==m||t[51]!==R||t[52]!==z||t[53]!==B?(V=(0,X.jsxs)(d,{className:Q,value:m,onChange:R,children:[z,B]}),t[50]=m,t[51]=R,t[52]=z,t[53]=B,t[54]=V):V=t[54];let me;t[55]!==n.draft.conversation||t[56]!==V?(me=(0,X.jsx)($,{label:n.draft.conversation,children:V}),t[55]=n.draft.conversation,t[56]=V,t[57]=me):me=t[57];let H;t[58]===T?H=t[59]:(H=e=>T(e.target.value),t[58]=T,t[59]=H);let U;t[60]===n.draft.notifyAttention?U=t[61]:(U=(0,X.jsx)(f,{value:`attention`,children:n.draft.notifyAttention}),t[60]=n.draft.notifyAttention,t[61]=U);let he;t[62]===n.draft.notifyAll?he=t[63]:(he=(0,X.jsx)(f,{value:`all`,children:n.draft.notifyAll}),t[62]=n.draft.notifyAll,t[63]=he);let ge;t[64]===n.draft.notifyNone?ge=t[65]:(ge=(0,X.jsx)(f,{value:`none`,children:n.draft.notifyNone}),t[64]=n.draft.notifyNone,t[65]=ge);let _e;t[66]!==h||t[67]!==H||t[68]!==U||t[69]!==he||t[70]!==ge?(_e=(0,X.jsxs)(d,{className:Q,value:h,onChange:H,children:[U,he,ge]}),t[66]=h,t[67]=H,t[68]=U,t[69]=he,t[70]=ge,t[71]=_e):_e=t[71];let W;t[72]!==n.draft.notifications||t[73]!==_e?(W=(0,X.jsx)($,{label:n.draft.notifications,children:_e}),t[72]=n.draft.notifications,t[73]=_e,t[74]=W):W=t[74];let ve;t[75]!==L||t[76]!==pe||t[77]!==me||t[78]!==W?(ve=(0,X.jsxs)(`div`,{className:L,children:[pe,me,W]}),t[75]=L,t[76]=pe,t[77]=me,t[78]=W,t[79]=ve):ve=t[79];let G;t[80]!==o||t[81]!==i||t[82]!==n.draft.approval||t[83]!==n.draft.assumptions||t[84]!==n.draft.discard||t[85]!==n.draft.edit||t[86]!==n.draft.publish||t[87]!==n.draft.review||t[88]!==n.draft.risks||t[89]!==n.draft.safety||t[90]!==n.draft.testOnce||t[91]!==n.draft.testing||t[92]!==n.feedback||t[93]!==n.info||t[94]!==n.none||t[95]!==E||t[96]!==D||t[97]!==y||t[98]!==b||t[99]!==x||t[100]!==k||t[101]!==M||t[102]!==A?(G=i?(0,X.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg bg-surface-base p-4 lg:grid-cols-[1fr_1fr]`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:i.automation.name}),i.automation.description?(0,X.jsx)(`div`,{className:`mt-1 text-sm text-fg-muted`,children:i.automation.description}):null,(0,X.jsxs)(`div`,{className:`mt-3 grid gap-2 text-sm`,children:[(0,X.jsx)(on,{label:n.info.when,value:i.simulation.triggerSummary}),(0,X.jsx)(on,{label:n.info.run,value:i.simulation.actionSummary})]})]}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:n.draft.review}),(0,X.jsx)(Ht,{title:n.draft.safety,items:[...i.simulation.safetyNotes,...i.simulation.requiredConfirmations],empty:n.none}),(0,X.jsx)(Ht,{title:n.draft.assumptions,items:i.assumptions,empty:n.none}),(0,X.jsx)(Ht,{title:n.draft.risks,items:i.risks,empty:n.none}),M?(0,X.jsxs)(`label`,{className:`mt-4 flex items-start gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{className:`mt-1`,type:`checkbox`,checked:o,onChange:e=>E(e.target.checked)}),(0,X.jsx)(`span`,{children:n.draft.approval})]}):null,(0,X.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,X.jsx)(C,{variant:`ghost`,onClick:D,children:n.draft.discard}),(0,X.jsxs)(C,{variant:`secondary`,onClick:y,children:[(0,X.jsx)(fe,{className:`size-4`}),n.draft.edit]}),(0,X.jsxs)(C,{variant:`secondary`,onClick:x,disabled:A||k||M&&!o,children:[(0,X.jsx)(ne,{className:`size-4`}),A?n.draft.testing:n.draft.testOnce]}),(0,X.jsx)(C,{variant:`primary`,onClick:b,disabled:k||M&&!o,children:k?n.feedback.working:n.draft.publish})]})]})]}):null,t[80]=o,t[81]=i,t[82]=n.draft.approval,t[83]=n.draft.assumptions,t[84]=n.draft.discard,t[85]=n.draft.edit,t[86]=n.draft.publish,t[87]=n.draft.review,t[88]=n.draft.risks,t[89]=n.draft.safety,t[90]=n.draft.testOnce,t[91]=n.draft.testing,t[92]=n.feedback,t[93]=n.info,t[94]=n.none,t[95]=E,t[96]=D,t[97]=y,t[98]=b,t[99]=x,t[100]=k,t[101]=M,t[102]=A,t[103]=G):G=t[103];let ye;return t[104]!==ce||t[105]!==ue||t[106]!==ve||t[107]!==G||t[108]!==N?(ye=(0,X.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[N,ce,ue,ve,G]}),t[104]=ce,t[105]=ue,t[106]=ve,t[107]=G,t[108]=N,t[109]=ye):ye=t[109],ye}function Vt(e){return(0,X.jsx)(f,{value:e.id,children:e.name},e.id)}function Ht(e){let t=(0,Fe.c)(10),{title:n,items:r,empty:i}=e,a;t[0]===n?a=t[1]:(a=(0,X.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(Ut):(0,X.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,X.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,X.jsxs)(`div`,{className:`mt-3`,children:[a,s]}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c}function Ut(e){return(0,X.jsxs)(`li`,{children:[`- `,e]},e)}function Wt(e){let t=(0,Fe.c)(25),{icon:n,label:r,value:i,tone:a,active:o,onClick:s}=e,c=a===void 0?`default`:a,l=c===`danger`?`text-red-600 dark:text-red-300`:`text-fg-subtle`,u;t[0]===l?u=t[1]:(u=v(`shrink-0`,l),t[0]=l,t[1]=u);let d;t[2]!==n||t[3]!==u?(d=(0,X.jsx)(`span`,{className:u,children:n}),t[2]=n,t[3]=u,t[4]=d):d=t[4];let f;t[5]===r?f=t[6]:(f=(0,X.jsx)(`span`,{className:`truncate text-xs font-medium text-fg-muted`,children:r}),t[5]=r,t[6]=f);let p=c===`danger`?`text-red-700 dark:text-red-300`:`text-fg`,m;t[7]===p?m=t[8]:(m=v(`ml-auto truncate text-sm font-semibold tabular-nums`,p),t[7]=p,t[8]=m);let h;t[9]!==m||t[10]!==i?(h=(0,X.jsx)(`span`,{className:m,children:i}),t[9]=m,t[10]=i,t[11]=h):h=t[11];let g;t[12]!==d||t[13]!==f||t[14]!==h?(g=(0,X.jsxs)(X.Fragment,{children:[d,f,h]}),t[12]=d,t[13]=f,t[14]=h,t[15]=g):g=t[15];let _=g,y=o&&`bg-accent/8`,b=s&&`cursor-pointer hover:bg-surface-hover focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,x;t[16]!==y||t[17]!==b?(x=v(`flex min-h-12 min-w-0 items-center gap-2.5 bg-surface-base px-3 py-2.5 text-left transition-colors`,y,b),t[16]=y,t[17]=b,t[18]=x):x=t[18];let S=x,C=`${r}: ${i}`,w;return t[19]!==C||t[20]!==o||t[21]!==S||t[22]!==_||t[23]!==s?(w=s?(0,X.jsx)(`button`,{type:`button`,className:S,onClick:s,"aria-label":C,"aria-pressed":o,children:_}):(0,X.jsx)(`div`,{className:S,"aria-label":C,children:_}),t[19]=C,t[20]=o,t[21]=S,t[22]=_,t[23]=s,t[24]=w):w=t[24],w}function Gt(e){let t=(0,Fe.c)(74),{runs:n,ownership:r,labels:i,language:a,unreadCount:o,loading:s,onOwnershipChange:c,onRefresh:l,onSelectRun:u}=e,d;t[0]===n?d=t[1]:(d=n.filter(Ot),t[0]=n,t[1]=d);let f=d.length,p;t[2]===n?p=t[3]:(p=n.filter(kt),t[2]=n,t[3]=p);let h=p.length,g;t[4]===i.dashboard.activity?g=t[5]:(g=(0,X.jsx)(`h2`,{id:`automation-activity-title`,className:`text-sm font-semibold text-fg`,children:i.dashboard.activity}),t[4]=i.dashboard.activity,t[5]=g);let _;t[6]===i.dashboard.activityDescription?_=t[7]:(_=(0,X.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:i.dashboard.activityDescription}),t[6]=i.dashboard.activityDescription,t[7]=_);let y;t[8]!==g||t[9]!==_?(y=(0,X.jsxs)(`div`,{className:`min-w-0`,children:[g,_]}),t[8]=g,t[9]=_,t[10]=y):y=t[10];let b=i.filters.ownership,x=r===`user`&&`bg-surface-base text-fg shadow-sm`,S;t[11]===x?S=t[12]:(S=v(`rounded-md px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:text-fg`,x),t[11]=x,t[12]=S);let C;t[13]===c?C=t[14]:(C=()=>c(`user`),t[13]=c,t[14]=C);let w=r===`user`,T;t[15]!==i.filters.userManaged||t[16]!==w||t[17]!==S||t[18]!==C?(T=(0,X.jsx)(`button`,{type:`button`,className:S,onClick:C,"aria-pressed":w,children:i.filters.userManaged}),t[15]=i.filters.userManaged,t[16]=w,t[17]=S,t[18]=C,t[19]=T):T=t[19];let E=r===`system`&&`bg-surface-base text-fg shadow-sm`,D;t[20]===E?D=t[21]:(D=v(`rounded-md px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:text-fg`,E),t[20]=E,t[21]=D);let O;t[22]===c?O=t[23]:(O=()=>c(`system`),t[22]=c,t[23]=O);let ee=r===`system`,k;t[24]!==i.system.title||t[25]!==D||t[26]!==O||t[27]!==ee?(k=(0,X.jsx)(`button`,{type:`button`,className:D,onClick:O,"aria-pressed":ee,children:i.system.title}),t[24]=i.system.title,t[25]=D,t[26]=O,t[27]=ee,t[28]=k):k=t[28];let A;t[29]!==i.filters.ownership||t[30]!==T||t[31]!==k?(A=(0,X.jsxs)(P,{className:`flex rounded-lg bg-surface-panel p-0.5`,role:`group`,"aria-label":b,indicatorClassName:`rounded-md bg-surface-base shadow-sm`,children:[T,k]}),t[29]=i.filters.ownership,t[30]=T,t[31]=k,t[32]=A):A=t[32];let j;t[33]!==i.refresh||t[34]!==s||t[35]!==l?(j=(0,X.jsx)(G,{className:`size-9 shrink-0 p-0`,loading:s,label:i.refresh,onClick:l}),t[33]=i.refresh,t[34]=s,t[35]=l,t[36]=j):j=t[36];let M;t[37]!==A||t[38]!==j?(M=(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[A,j]}),t[37]=A,t[38]=j,t[39]=M):M=t[39];let N;t[40]!==M||t[41]!==y?(N=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-edge-subtle px-4 py-3 sm:px-5`,children:[y,M]}),t[40]=M,t[41]=y,t[42]=N):N=t[42];let F;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,X.jsx)(te,{className:`size-4`,"aria-hidden":!0}),t[43]=F):F=t[43];let I=i.metrics.total,re=String(n.length),ie;t[44]!==i.metrics.total||t[45]!==re?(ie=(0,X.jsx)(Wt,{icon:F,label:I,value:re}),t[44]=i.metrics.total,t[45]=re,t[46]=ie):ie=t[46];let ae;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,X.jsx)(ne,{className:`size-4`,"aria-hidden":!0}),t[47]=ae):ae=t[47];let oe=i.metrics.running,se=String(f),ce;t[48]!==i.metrics.running||t[49]!==se?(ce=(0,X.jsx)(Wt,{icon:ae,label:oe,value:se}),t[48]=i.metrics.running,t[49]=se,t[50]=ce):ce=t[50];let le;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,X.jsx)(he,{className:`size-4`,"aria-hidden":!0}),t[51]=le):le=t[51];let ue=i.dashboard.needsAttention,de=String(h),fe=h>0?`danger`:`default`,L;t[52]!==i.dashboard.needsAttention||t[53]!==de||t[54]!==fe?(L=(0,X.jsx)(Wt,{icon:le,label:ue,value:de,tone:fe}),t[52]=i.dashboard.needsAttention,t[53]=de,t[54]=fe,t[55]=L):L=t[55];let pe;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,X.jsx)(m,{className:`size-4`,"aria-hidden":!0}),t[56]=pe):pe=t[56];let R=i.filters.unread,z=String(o),B;t[57]!==i.filters.unread||t[58]!==z?(B=(0,X.jsx)(Wt,{icon:pe,label:R,value:z}),t[57]=i.filters.unread,t[58]=z,t[59]=B):B=t[59];let V;t[60]!==ie||t[61]!==ce||t[62]!==L||t[63]!==B?(V=(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-px border-b border-edge-subtle bg-edge-subtle lg:grid-cols-4`,children:[ie,ce,L,B]}),t[60]=ie,t[61]=ce,t[62]=L,t[63]=B,t[64]=V):V=t[64];let me;t[65]!==i||t[66]!==a||t[67]!==u||t[68]!==n?(me=n.length===0?(0,X.jsx)(sn,{className:`min-h-64 rounded-none border-0 shadow-none`,icon:(0,X.jsx)(te,{className:`size-5`}),title:i.empty.runs}):(0,X.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:n.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`flex w-full min-w-0 items-start gap-3 px-4 py-3 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent sm:px-5`,onClick:()=>u(e.id),children:[(0,X.jsx)(`span`,{className:v(`mt-1.5 size-2 shrink-0 rounded-full`,Ot(e)?`bg-blue-500`:kt(e)?`bg-red-500`:`bg-emerald-500`),"aria-hidden":!0}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.automationName}),e.readAtMs==null&&!Ot(e)?(0,X.jsx)(`span`,{className:`size-2 shrink-0 rounded-full bg-blue-500`,children:(0,X.jsx)(`span`,{className:`sr-only`,children:i.filters.unread})}):null]}),(0,X.jsx)(`span`,{className:v(`mt-1 line-clamp-2 block text-sm text-fg-muted`,e.error&&`text-red-700 dark:text-red-300`),children:e.error||e.summary||i.status[e.status]}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:yt(e.createdAtMs,i,a)})]}),(0,X.jsx)(`span`,{className:v(`shrink-0 rounded-full px-2 py-0.5 text-xs`,Et(e.status)),children:i.status[e.status]})]},e.id))}),t[65]=i,t[66]=a,t[67]=u,t[68]=n,t[69]=me):me=t[69];let H;return t[70]!==N||t[71]!==V||t[72]!==me?(H=(0,X.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,"aria-labelledby":`automation-activity-title`,children:[N,V,me]}),t[70]=N,t[71]=V,t[72]=me,t[73]=H):H=t[73],H}function Kt(e){let t=(0,Fe.c)(20),{automations:n,runs:r,labels:i,cronLabels:a,language:o,selectedAutomationId:s,onOpenDetails:c}=e;if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(W,{className:`size-5`}),t[0]=e):e=t[0];let n;return t[1]===i.empty.filtered?n=t[2]:(n=(0,X.jsx)(sn,{className:`rounded-none border-0 shadow-none`,icon:e,title:i.empty.filtered}),t[1]=i.empty.filtered,t[2]=n),n}let l;if(t[3]!==n||t[4]!==a||t[5]!==i||t[6]!==o||t[7]!==c||t[8]!==r||t[9]!==s){let e;t[11]!==a||t[12]!==i||t[13]!==o||t[14]!==c||t[15]!==r||t[16]!==s?(e=e=>{let t=r.filter(t=>t.automationId===e.id).sort(qt),n=t.find(Ot),l=t[0];return(0,X.jsxs)(`button`,{type:`button`,className:v(`block w-full p-3 text-left outline-none hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,s===e.id&&`bg-surface-hover`),style:{contentVisibility:`auto`,containIntrinsicSize:`auto 130px`},"aria-current":s===e.id?`true`:void 0,onClick:()=>c(e.id),children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(`span`,{className:v(`size-2 shrink-0 rounded-full`,n?`bg-blue-500`:gt(e,t)?`bg-red-500`:e.enabled?`bg-emerald-500`:`bg-fg-subtle`)}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-fg`,children:e.name}),(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.enabled?i.enabled:i.paused}),l&&l.readAtMs==null&&!Ot(l)?(0,X.jsx)(`span`,{className:`ml-auto size-2 shrink-0 rounded-full bg-blue-500`,children:(0,X.jsx)(`span`,{className:`sr-only`,children:i.filters.unread})}):null]}),(0,X.jsxs)(`div`,{className:`mt-2 flex min-w-0 flex-wrap items-center gap-1.5 pl-4 text-xs`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge-subtle bg-surface-panel px-1.5 py-0.5 text-fg-muted`,children:[(0,X.jsx)(wt,{kind:e.action.kind,className:`size-3`}),xt(e.action,i)]}),(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1 rounded-md bg-surface-panel px-1.5 py-0.5 text-fg-muted`,children:[(0,X.jsx)(N,{className:`size-3 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`truncate`,children:Ee(e.trigger,i,a,o)})]})]}),(0,X.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center justify-between gap-2 pl-4 text-xs text-fg-subtle`,children:[(0,X.jsx)(`span`,{className:v(`line-clamp-2`,l?.error&&`text-red-700 dark:text-red-300`),children:l?l.error||l.summary||i.status[l.status]:e.state.lastError||(e.state.lastRunStatus?i.status[e.state.lastRunStatus]:i.experience.noRuns)}),l?.status?(0,X.jsx)(`span`,{className:v(`shrink-0 rounded-full px-1.5 py-0.5`,Et(l.status)),children:i.status[l.status]}):null]}),(0,X.jsxs)(`div`,{className:`mt-2 space-y-1 pl-4 text-xs text-fg-muted`,children:[l?(0,X.jsxs)(`div`,{children:[i.last,`: `,yt(l.createdAtMs,i,o)]}):null,(0,X.jsx)(`div`,{children:e.enabled?`${i.next}: ${ke(e,i,o)}`:i.paused})]})]},e.id)},t[11]=a,t[12]=i,t[13]=o,t[14]=c,t[15]=r,t[16]=s,t[17]=e):e=t[17],l=n.map(e),t[3]=n,t[4]=a,t[5]=i,t[6]=o,t[7]=c,t[8]=r,t[9]=s,t[10]=l}else l=t[10];let u;return t[18]===l?u=t[19]:(u=(0,X.jsx)(`div`,{className:`min-h-0 overflow-y-auto divide-y divide-edge-subtle`,children:l}),t[18]=l,t[19]=u),u}function qt(e,t){return t.createdAtMs-e.createdAtMs}function Jt(e,t){let n=t.events,r=e.data&&typeof e.data==`object`?e.data:{},i=typeof r.actionKind==`string`?r.actionKind:null,a=typeof r.status==`string`&&r.status in t.status?t.status[r.status]:null;switch(e.type){case`run.queued`:return e.message.toLowerCase().includes(`manual`)?n.manualQueued:e.message.toLowerCase().includes(`scheduled`)?n.scheduledQueued:n.eventQueued;case`run.started`:return n.runStarted;case`action.started`:return i?n.actionStarted.replace(`{kind}`,i):n.actionStartedFallback;case`action.completed`:return i?n.actionCompleted.replace(`{kind}`,i):n.actionCompletedFallback;case`action.failed`:return i?n.actionFailed.replace(`{kind}`,i):n.actionFailedFallback;case`run.completed`:return a?n.runCompleted.replace(`{status}`,a):n.runCompletedFallback;default:return e.message}}function Yt(e){let t=(0,Fe.c)(17),{value:n,labels:r,title:i,defaultExpanded:a}=e,[o,s]=(0,Y.useState)(a===void 0?!1:a),l;t[0]===n?l=t[1]:(l=JSON.stringify(n,null,2),t[0]=n,t[1]=l);let u=l,d;t[2]===u?d=t[3]:(d=u.split(`
4
- `),t[2]=u,t[3]=d);let f=d.length,p=u.length>720||f>18,m;t[4]!==p||t[5]!==u?(m=p?`${u.split(`
5
- `).slice(0,10).join(`
6
- `).trimEnd()}...`:u,t[4]=p,t[5]=u,t[6]=m):m=t[6];let h=m,g;t[7]!==o||t[8]!==p||t[9]!==r||t[10]!==i?(g=p?(0,X.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-2.5 py-2 text-left text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>s(Xt),"aria-expanded":o,children:[(0,X.jsx)(`span`,{children:i}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-accent-fg`,children:[o?r.details.hideDetails:r.details.showDetails,(0,X.jsx)(c,{className:v(`size-3.5 transition-transform`,o&&`rotate-180`),"aria-hidden":!0})]})]}):(0,X.jsx)(`div`,{className:`px-2.5 py-2 text-xs font-medium text-fg-muted`,children:i}),t[7]=o,t[8]=p,t[9]=r,t[10]=i,t[11]=g):g=t[11];let _=o||!p?u:h,y;t[12]===_?y=t[13]:(y=(0,X.jsx)(`pre`,{className:`whitespace-pre-wrap break-all px-2.5 pb-2 text-xs leading-relaxed text-fg-muted`,children:_}),t[12]=_,t[13]=y);let b;return t[14]!==g||t[15]!==y?(b=(0,X.jsxs)(`div`,{className:`mt-2 rounded-md border border-edge/70 bg-surface-inset/35`,children:[g,y]}),t[14]=g,t[15]=y,t[16]=b):b=t[16],b}function Xt(e){return!e}function Zt(e){let t=(0,Fe.c)(148),{className:n,run:r,events:i,labels:o,cronLabels:s,language:l,loading:u,repairDraft:d,repairLoading:f,repairApproved:p,busyAction:h,onRepairApprovedChange:g,onSuggestRepair:_,onApplyRepair:y}=e;if(!r){let e;t[0]===n?e=t[1]:(e=v(`flex min-h-64 flex-col justify-center rounded-lg border border-edge-subtle bg-surface-base px-4 text-center text-sm text-fg-muted shadow-surface`,n),t[0]=n,t[1]=e);let r;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,X.jsx)(te,{className:`mx-auto size-5`}),t[2]=r):r=t[2];let i;t[3]===o.selectRun?i=t[4]:(i=(0,X.jsx)(`div`,{className:`mt-2`,children:o.selectRun}),t[3]=o.selectRun,t[4]=i);let a;return t[5]!==e||t[6]!==i?(a=(0,X.jsxs)(`aside`,{className:e,children:[r,i]}),t[5]=e,t[6]=i,t[7]=a):a=t[7],a}let b=r.error||r.summary,x=r.conversationId?`/chat/${encodeURIComponent(r.conversationId)}`:null,S=(r.conversationId,o.runDetail.openConversation),T=r.conversationId?H:L,E=Ot(r)?te:r.status===`succeeded`?m:he,D;t[8]===n?D=t[9]:(D=v(`rounded-lg border border-edge-subtle bg-surface-base shadow-surface`,n),t[8]=n,t[9]=D);let O;t[10]===r.automationName?O=t[11]:(O=(0,X.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:r.automationName}),t[10]=r.automationName,t[11]=O);let ee;t[12]===r.id?ee=t[13]:(ee=r.id.slice(0,8),t[12]=r.id,t[13]=ee);let k;t[14]===ee?k=t[15]:(k=(0,X.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:ee}),t[14]=ee,t[15]=k);let A;t[16]!==O||t[17]!==k?(A=(0,X.jsxs)(`div`,{className:`min-w-0`,children:[O,k]}),t[16]=O,t[17]=k,t[18]=A):A=t[18];let j;t[19]===r.status?j=t[20]:(j=v(`shrink-0 rounded-full px-2 py-0.5 text-xs`,Et(r.status)),t[19]=r.status,t[20]=j);let M=o.status[r.status],N;t[21]!==j||t[22]!==M?(N=(0,X.jsx)(`span`,{className:j,children:M}),t[21]=j,t[22]=M,t[23]=N):N=t[23];let ne;t[24]!==A||t[25]!==N?(ne=(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[A,N]}),t[24]=A,t[25]=N,t[26]=ne):ne=t[26];let P;t[27]!==o||t[28]!==l||t[29]!==r.createdAtMs?(P=yt(r.createdAtMs,o,l),t[27]=o,t[28]=l,t[29]=r.createdAtMs,t[30]=P):P=t[30];let F;t[31]===P?F=t[32]:(F=(0,X.jsx)(`span`,{children:P}),t[31]=P,t[32]=F);let I;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,X.jsx)(`span`,{"aria-hidden":!0,children:`·`}),t[33]=I):I=t[33];let re=o.details.duration,ie;t[34]!==o||t[35]!==r.durationMs?(ie=Dt(r.durationMs,o),t[34]=o,t[35]=r.durationMs,t[36]=ie):ie=t[36];let ae;t[37]!==o.details.duration||t[38]!==ie?(ae=(0,X.jsxs)(`span`,{children:[re,` `,ie]}),t[37]=o.details.duration,t[38]=ie,t[39]=ae):ae=t[39];let se;t[40]!==F||t[41]!==ae?(se=(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-muted`,children:[F,I,ae]}),t[40]=F,t[41]=ae,t[42]=se):se=t[42];let ce;t[43]!==o.repair||t[44]!==_||t[45]!==f||t[46]!==r?(ce=r.status===`failed`||r.status===`timeout`||r.status===`cancelled`?(0,X.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,X.jsxs)(C,{variant:`secondary`,onClick:()=>_(r),disabled:f,children:[(0,X.jsx)(we,{className:`size-4`}),f?o.repair.generating:o.repair.suggest]})}):null,t[43]=o.repair,t[44]=_,t[45]=f,t[46]=r,t[47]=ce):ce=t[47];let ue;t[48]!==se||t[49]!==ce||t[50]!==ne?(ue=(0,X.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[ne,se,ce]}),t[48]=se,t[49]=ce,t[50]=ne,t[51]=ue):ue=t[51];let de;t[52]===r?de=t[53]:(de=Ot(r)?`text-blue-500`:kt(r)?`text-red-500`:r.status===`succeeded`?`text-emerald-500`:`text-fg-muted`,t[52]=r,t[53]=de);let fe;t[54]===de?fe=t[55]:(fe=v(`size-4`,de),t[54]=de,t[55]=fe);let pe;t[56]!==E||t[57]!==fe?(pe=(0,X.jsx)(E,{className:fe}),t[56]=E,t[57]=fe,t[58]=pe):pe=t[58];let R;t[59]!==o.runDetail.resultTitle||t[60]!==pe?(R=(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[pe,o.runDetail.resultTitle]}),t[59]=o.runDetail.resultTitle,t[60]=pe,t[61]=R):R=t[61];let z;t[62]!==T||t[63]!==S||t[64]!==x?(z=x?(0,X.jsx)(C,{asChild:!0,variant:`secondary`,className:`h-8 rounded-md px-2.5 text-xs`,children:(0,X.jsxs)(a,{to:x,children:[(0,X.jsx)(T,{className:`size-3.5`}),S,(0,X.jsx)(oe,{className:`size-3.5`})]})}):null,t[62]=T,t[63]=S,t[64]=x,t[65]=z):z=t[65];let B;t[66]!==R||t[67]!==z?(B=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[R,z]}),t[66]=R,t[67]=z,t[68]=B):B=t[68];let V=r.error&&`border-red-500/25 bg-red-500/5`,me;t[69]===V?me=t[70]:(me=v(`mt-3 max-h-80 overflow-y-auto rounded-lg border border-edge/70 bg-surface-inset/25 p-3`,V),t[69]=V,t[70]=me);let U;t[71]!==o.runDetail.noResult||t[72]!==o.runDetail.resultPending||t[73]!==b||t[74]!==r?(U=b?r.error?(0,X.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm leading-relaxed text-red-700 dark:text-red-300`,children:b}):(0,X.jsx)(ge,{content:b,compact:!0,className:`text-sm`}):(0,X.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:Ot(r)?o.runDetail.resultPending:o.runDetail.noResult}),t[71]=o.runDetail.noResult,t[72]=o.runDetail.resultPending,t[73]=b,t[74]=r,t[75]=U):U=t[75];let _e;t[76]!==me||t[77]!==U?(_e=(0,X.jsx)(`div`,{className:me,children:U}),t[76]=me,t[77]=U,t[78]=_e):_e=t[78];let W;t[79]!==B||t[80]!==_e?(W=(0,X.jsxs)(`section`,{className:`border-b border-edge p-4`,children:[B,_e]}),t[79]=B,t[80]=_e,t[81]=W):W=t[81];let ve;t[82]===o.runDetail.runInfo?ve=t[83]:(ve=(0,X.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:o.runDetail.runInfo}),t[82]=o.runDetail.runInfo,t[83]=ve);let G;t[84]!==s||t[85]!==o||t[86]!==l||t[87]!==r.manual||t[88]!==r.triggerSnapshot?(G=r.manual?o.trigger.manual:Ee(r.triggerSnapshot,o,s,l),t[84]=s,t[85]=o,t[86]=l,t[87]=r.manual,t[88]=r.triggerSnapshot,t[89]=G):G=t[89];let ye;t[90]!==o.explain.whyRan||t[91]!==G?(ye=(0,X.jsx)(rn,{label:o.explain.whyRan,value:G}),t[90]=o.explain.whyRan,t[91]=G,t[92]=ye):ye=t[92];let be=o.details.started,xe;t[93]!==o||t[94]!==l||t[95]!==r.startedAtMs?(xe=yt(r.startedAtMs,o,l),t[93]=o,t[94]=l,t[95]=r.startedAtMs,t[96]=xe):xe=t[96];let Se;t[97]!==o.details.started||t[98]!==xe?(Se=(0,X.jsx)(rn,{label:be,value:xe}),t[97]=o.details.started,t[98]=xe,t[99]=Se):Se=t[99];let Ce;t[100]!==o.details.model||t[101]!==r.model?(Ce=r.model?(0,X.jsx)(rn,{label:o.details.model,value:r.model}):null,t[100]=o.details.model,t[101]=r.model,t[102]=Ce):Ce=t[102];let Te;t[103]!==ye||t[104]!==Se||t[105]!==Ce?(Te=(0,X.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs text-fg-muted`,children:[ye,Se,Ce]}),t[103]=ye,t[104]=Se,t[105]=Ce,t[106]=Te):Te=t[106];let K;t[107]!==ve||t[108]!==Te?(K=(0,X.jsxs)(`section`,{className:`border-b border-edge p-4`,children:[ve,Te]}),t[107]=ve,t[108]=Te,t[109]=K):K=t[109];let De;t[110]!==h||t[111]!==o||t[112]!==y||t[113]!==g||t[114]!==p||t[115]!==d||t[116]!==r?(De=d?(0,X.jsxs)(`div`,{className:`border-b border-edge px-4 py-3`,children:[(0,X.jsx)(`div`,{className:`text-xs font-semibold uppercase text-fg-muted`,children:o.repair.title}),(0,X.jsx)(`div`,{className:`mt-2 text-sm text-fg`,children:d.explanation}),d.expectedEffect?(0,X.jsx)(`div`,{className:`mt-2 text-sm text-fg-muted`,children:d.expectedEffect}):null,(0,X.jsx)(Ht,{title:o.repair.risks,items:d.risks,empty:o.none}),(0,X.jsx)(Yt,{value:d.patch,labels:o,title:o.details.repairPatch}),d.requiresApproval?(0,X.jsxs)(`label`,{className:`mt-3 flex items-start gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{className:`mt-1`,type:`checkbox`,checked:p,onChange:e=>g(e.target.checked)}),(0,X.jsx)(`span`,{children:o.repair.approval})]}):null,(0,X.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,X.jsx)(C,{variant:`primary`,onClick:()=>y(r),disabled:h===`run:${r.id}:repair`||d.requiresApproval&&!p,children:h===`run:${r.id}:repair`?o.feedback.working:o.repair.apply})})]}):null,t[110]=h,t[111]=o,t[112]=y,t[113]=g,t[114]=p,t[115]=d,t[116]=r,t[117]=De):De=t[117];let Oe;t[118]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,X.jsx)(le,{className:`size-4 shrink-0`}),t[118]=Oe):Oe=t[118];let q;t[119]===o.runDetail.technicalEvents?q=t[120]:(q=(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-sm font-medium text-fg-muted`,children:[Oe,o.runDetail.technicalEvents]}),t[119]=o.runDetail.technicalEvents,t[120]=q);let ke;t[121]!==i.length||t[122]!==o.runDetail.eventCount?(ke=o.runDetail.eventCount.replace(`{count}`,String(i.length)),t[121]=i.length,t[122]=o.runDetail.eventCount,t[123]=ke):ke=t[123];let Ae;t[124]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=(0,X.jsx)(c,{className:`size-4 transition-transform group-open:rotate-180`}),t[124]=Ae):Ae=t[124];let J;t[125]===ke?J=t[126]:(J=(0,X.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs text-fg-muted`,children:[ke,Ae]}),t[125]=ke,t[126]=J);let je;t[127]!==q||t[128]!==J?(je=(0,X.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 rounded-md outline-none hover:text-fg focus-visible:ring-2 focus-visible:ring-accent`,children:[q,J]}),t[127]=q,t[128]=J,t[129]=je):je=t[129];let Me;t[130]===o.runDetail.technicalEventsDescription?Me=t[131]:(Me=(0,X.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-fg-muted`,children:o.runDetail.technicalEventsDescription}),t[130]=o.runDetail.technicalEventsDescription,t[131]=Me);let Ne;t[132]!==i||t[133]!==o||t[134]!==l||t[135]!==u?(Ne=(0,X.jsx)(`div`,{className:`mt-4`,children:u?(0,X.jsxs)(`div`,{className:`space-y-3`,"aria-label":o.loading,children:[(0,X.jsx)(w,{className:`h-10 w-full`}),(0,X.jsx)(w,{className:`h-10 w-4/5`}),(0,X.jsx)(w,{className:`h-10 w-11/12`})]}):i.length===0?(0,X.jsx)(`div`,{className:`text-sm text-fg-muted`,children:o.empty.events}):(0,X.jsx)(`ol`,{className:`space-y-3`,children:i.map(e=>(0,X.jsxs)(`li`,{className:`grid grid-cols-[0.75rem_1fr] gap-3`,children:[(0,X.jsx)(`span`,{className:v(`mt-1 size-2 rounded-full`,an(e.type))}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`text-sm text-fg`,children:Jt(e,o)}),(0,X.jsxs)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:[yt(e.createdAtMs,o,l),` · `,e.type]}),e.data&&typeof e.data==`object`?(0,X.jsxs)(`details`,{className:`group/event mt-2 rounded-md border border-edge/70 bg-surface-inset/35`,children:[(0,X.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 px-2.5 py-2 text-xs font-medium text-fg-muted outline-none hover:text-fg`,children:[o.details.eventData,(0,X.jsx)(c,{className:`size-3.5 transition-transform group-open/event:rotate-180`})]}),(0,X.jsx)(`pre`,{className:`max-h-72 overflow-auto whitespace-pre-wrap break-all border-t border-edge/70 px-2.5 py-2 text-xs leading-relaxed text-fg-muted`,children:JSON.stringify(e.data,null,2)})]}):null]})]},e.id))})}),t[132]=i,t[133]=o,t[134]=l,t[135]=u,t[136]=Ne):Ne=t[136];let Pe;t[137]!==je||t[138]!==Me||t[139]!==Ne?(Pe=(0,X.jsxs)(`details`,{className:`group px-4 py-3`,children:[je,Me,Ne]}),t[137]=je,t[138]=Me,t[139]=Ne,t[140]=Pe):Pe=t[140];let Y;return t[141]!==D||t[142]!==ue||t[143]!==W||t[144]!==K||t[145]!==De||t[146]!==Pe?(Y=(0,X.jsxs)(`aside`,{className:D,children:[ue,W,K,De,Pe]}),t[141]=D,t[142]=ue,t[143]=W,t[144]=K,t[145]=De,t[146]=Pe,t[147]=Y):Y=t[147],Y}function Qt(e){let t=(0,Fe.c)(146),{automation:n,runs:r,runsLoading:i,runsError:a,labels:o,cronLabels:s,language:c,projects:l,busyAction:u,onEdit:d,onSelectRun:f,onAction:p}=e,g=u===`automation:${n.id}:run`,_=u===`automation:${n.id}:toggle`,y=u===`automation:${n.id}:delete`,b;t[0]===n.management?b=t[1]:(b=!n.management||n.management.editable.includes(`enabled`),t[0]=n.management,t[1]=b);let x=b,S=!n.management||n.management.runnable,T;t[2]===n.management?T=t[3]:(T=!n.management||n.management.editable.includes(`trigger`),t[2]=n.management,t[3]=T);let E=T,D=!n.management||n.management.deletable,O;t[4]===n.name?O=t[5]:(O=(0,X.jsx)(`h2`,{className:`truncate text-lg font-semibold text-fg`,children:n.name}),t[4]=n.name,t[5]=O);let ee=n.enabled?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-surface-hover text-fg-muted`,k;t[6]===ee?k=t[7]:(k=v(`shrink-0 rounded-full px-2 py-0.5 text-xs`,ee),t[6]=ee,t[7]=k);let A=n.enabled?o.enabled:o.paused,j;t[8]!==k||t[9]!==A?(j=(0,X.jsx)(`span`,{className:k,children:A}),t[8]=k,t[9]=A,t[10]=j):j=t[10];let M;t[11]!==O||t[12]!==j?(M=(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[O,j]}),t[11]=O,t[12]=j,t[13]=M):M=t[13];let P;t[14]===n?P=t[15]:(P=jt(n)?(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:jt(n)}):null,t[14]=n,t[15]=P);let F;t[16]===n.action.kind?F=t[17]:(F=(0,X.jsx)(wt,{kind:n.action.kind,className:`size-3.5`}),t[16]=n.action.kind,t[17]=F);let I;t[18]!==n.action||t[19]!==o?(I=xt(n.action,o),t[18]=n.action,t[19]=o,t[20]=I):I=t[20];let ie;t[21]!==F||t[22]!==I?(ie=(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-md border border-edge-subtle bg-surface-base px-2 py-1`,children:[F,I]}),t[21]=F,t[22]=I,t[23]=ie):ie=t[23];let ae;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,X.jsx)(N,{className:`size-3.5`,"aria-hidden":!0}),t[24]=ae):ae=t[24];let oe;t[25]!==n.trigger||t[26]!==s||t[27]!==o||t[28]!==c?(oe=Ee(n.trigger,o,s,c),t[25]=n.trigger,t[26]=s,t[27]=o,t[28]=c,t[29]=oe):oe=t[29];let ce;t[30]===oe?ce=t[31]:(ce=(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-md border border-edge-subtle bg-surface-base px-2 py-1`,children:[ae,oe]}),t[30]=oe,t[31]=ce);let le;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,X.jsx)(L,{className:`size-3.5`,"aria-hidden":!0}),t[32]=le):le=t[32];let ue;t[33]!==n.projectId||t[34]!==o.info||t[35]!==l?(ue=l.find(e=>e.id===n.projectId)?.name??o.info.noProject,t[33]=n.projectId,t[34]=o.info,t[35]=l,t[36]=ue):ue=t[36];let de;t[37]===ue?de=t[38]:(de=(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-md border border-edge-subtle bg-surface-base px-2 py-1`,children:[le,ue]}),t[37]=ue,t[38]=de);let pe;t[39]!==ie||t[40]!==ce||t[41]!==de?(pe=(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[ie,ce,de]}),t[39]=ie,t[40]=ce,t[41]=de,t[42]=pe):pe=t[42];let B;t[43]!==pe||t[44]!==M||t[45]!==P?(B=(0,X.jsxs)(`div`,{className:`min-w-0`,children:[M,P,pe]}),t[43]=pe,t[44]=M,t[45]=P,t[46]=B):B=t[46];let H;t[47]!==n||t[48]!==u||t[49]!==D||t[50]!==E||t[51]!==S||t[52]!==x||t[53]!==y||t[54]!==o.dashboard.delete||t[55]!==o.dashboard.deleted||t[56]!==o.dashboard.pause||t[57]!==o.dashboard.resume||t[58]!==o.dashboard.resumed||t[59]!==o.dashboard.runNow||t[60]!==o.details||t[61]!==o.edit||t[62]!==o.experience.deleteConfirm||t[63]!==o.feedback||t[64]!==p||t[65]!==d||t[66]!==g||t[67]!==_?(H=x||S||E||D?(0,X.jsxs)(`div`,{className:`flex w-full flex-wrap items-center gap-2`,children:[x?(0,X.jsxs)(C,{variant:`secondary`,disabled:u!==null,onClick:()=>void p(`automation:${n.id}:toggle`,()=>n.enabled?V.pause(n.id):V.resume(n.id),n.enabled?o.feedback.paused:o.dashboard.resumed),children:[_?(0,X.jsx)(re,{className:`size-4 animate-spin`}):n.enabled?(0,X.jsx)(se,{className:`size-4`}):(0,X.jsx)(ne,{className:`size-4`}),n.enabled?o.dashboard.pause:o.dashboard.resume]}):null,S?(0,X.jsxs)(C,{variant:`primary`,disabled:u!==null,onClick:()=>void p(`automation:${n.id}:run`,()=>V.runNow(n.id),o.feedback.rerunQueued),children:[g?(0,X.jsx)(re,{className:`size-4 animate-spin`}):(0,X.jsx)(ne,{className:`size-4`}),o.dashboard.runNow]}):null,E||D?(0,X.jsxs)(me,{children:[(0,X.jsx)(ye,{asChild:!0,children:(0,X.jsx)(C,{variant:`ghost`,className:`size-9 p-0`,"aria-label":o.details.moreActions,children:(0,X.jsx)(h,{className:`size-4`})})}),(0,X.jsx)(ve,{children:(0,X.jsxs)(R,{align:`end`,className:`z-70 min-w-40 rounded-lg border border-edge bg-surface-overlay p-1 shadow-popover`,children:[E?(0,X.jsxs)(_e,{className:`flex cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover`,onSelect:()=>d(n),children:[(0,X.jsx)(fe,{className:`size-4`}),o.edit]}):null,D?(0,X.jsxs)(_e,{className:`flex cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-sm text-red-700 outline-none hover:bg-red-500/10 dark:text-red-300`,disabled:u!==null,onSelect:()=>{window.confirm(o.experience.deleteConfirm)&&p(`automation:${n.id}:delete`,()=>V.remove(n.id),o.dashboard.deleted)},children:[y?(0,X.jsx)(re,{className:`size-4 animate-spin`}):(0,X.jsx)(z,{className:`size-4`}),o.dashboard.delete]}):null]})})]}):null]}):null,t[47]=n,t[48]=u,t[49]=D,t[50]=E,t[51]=S,t[52]=x,t[53]=y,t[54]=o.dashboard.delete,t[55]=o.dashboard.deleted,t[56]=o.dashboard.pause,t[57]=o.dashboard.resume,t[58]=o.dashboard.resumed,t[59]=o.dashboard.runNow,t[60]=o.details,t[61]=o.edit,t[62]=o.experience.deleteConfirm,t[63]=o.feedback,t[64]=p,t[65]=d,t[66]=g,t[67]=_,t[68]=H):H=t[68];let U;t[69]!==B||t[70]!==H?(U=(0,X.jsxs)(`header`,{className:`flex flex-col items-start gap-3 border-b border-edge px-5 py-4`,children:[B,H]}),t[69]=B,t[70]=H,t[71]=U):U=t[71];let he;t[72]===o.dashboard.latestResult?he=t[73]:(he=(0,X.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:o.dashboard.latestResult}),t[72]=o.dashboard.latestResult,t[73]=he);let W;t[74]!==o.experience.viewResult||t[75]!==f||t[76]!==r[0]?(W=r[0]?(0,X.jsx)(C,{variant:`secondary`,onClick:()=>f(r[0].id),children:o.experience.viewResult}):null,t[74]=o.experience.viewResult,t[75]=f,t[76]=r[0],t[77]=W):W=t[77];let G;t[78]!==he||t[79]!==W?(G=(0,X.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[he,W]}),t[78]=he,t[79]=W,t[80]=G):G=t[80];let be;t[81]!==o||t[82]!==c||t[83]!==r[0]||t[84]!==a||t[85]!==i?(be=a?(0,X.jsx)(`p`,{role:`alert`,className:`text-sm text-red-700 dark:text-red-300`,children:a}):i?(0,X.jsx)(w,{className:`h-28 w-full`}):r[0]?(0,X.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge-subtle bg-surface-base p-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[(0,X.jsx)(`span`,{className:v(`rounded-full px-2 py-0.5`,Et(r[0].status)),children:o.status[r[0].status]}),yt(r[0].createdAtMs,o,c)]}),(0,X.jsx)(ge,{content:r[0].error||r[0].summary||(Ot(r[0])?o.runDetail.resultPending:o.runDetail.noResult),compact:!0})]}):(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.experience.noRuns}),t[81]=o,t[82]=c,t[83]=r[0],t[84]=a,t[85]=i,t[86]=be):be=t[86];let xe;t[87]!==n||t[88]!==o||t[89]!==c?(xe=n.enabled?`${o.next}: ${ke(n,o,c)}`:o.paused,t[87]=n,t[88]=o,t[89]=c,t[90]=xe):xe=t[90];let Se;t[91]===xe?Se=t[92]:(Se=(0,X.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:xe}),t[91]=xe,t[92]=Se);let Ce;t[93]!==G||t[94]!==be||t[95]!==Se?(Ce=(0,X.jsxs)(`section`,{children:[G,be,Se]}),t[93]=G,t[94]=be,t[95]=Se,t[96]=Ce):Ce=t[96];let we;t[97]===o.dashboard.runHistory?we=t[98]:(we=(0,X.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:o.dashboard.runHistory}),t[97]=o.dashboard.runHistory,t[98]=we);let Te;t[99]===o.dashboard.runHistoryDescription?Te=t[100]:(Te=(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o.dashboard.runHistoryDescription}),t[99]=o.dashboard.runHistoryDescription,t[100]=Te);let K;t[101]!==we||t[102]!==Te?(K=(0,X.jsxs)(`div`,{children:[we,Te]}),t[101]=we,t[102]=Te,t[103]=K):K=t[103];let De;t[104]===r.length?De=t[105]:(De=(0,X.jsx)(`span`,{className:`rounded-full bg-surface-base px-2.5 py-1 text-xs text-fg-muted`,children:r.length}),t[104]=r.length,t[105]=De);let Oe;t[106]!==K||t[107]!==De?(Oe=(0,X.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[K,De]}),t[106]=K,t[107]=De,t[108]=Oe):Oe=t[108];let q;t[109]!==o||t[110]!==c||t[111]!==f||t[112]!==r||t[113]!==i?(q=i?(0,X.jsx)(w,{className:`h-24 w-full`}):r.length===0?(0,X.jsx)(sn,{className:`min-h-24 py-6`,icon:(0,X.jsx)(te,{className:`size-5`}),title:o.empty.runs}):(0,X.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge-subtle bg-surface-base`,children:r.slice(0,8).map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`block w-full p-3 text-left hover:bg-surface-hover`,onClick:()=>f(e.id),children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[e.status===`succeeded`?(0,X.jsx)(m,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-300`}):(0,X.jsx)(te,{className:`size-4 shrink-0 text-fg-muted`}),(0,X.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:yt(e.createdAtMs,o,c)})]}),(0,X.jsx)(`span`,{className:v(`shrink-0 rounded-full px-2 py-0.5 text-xs`,Et(e.status)),children:o.status[e.status]})]}),(0,X.jsx)(`p`,{className:v(`mt-1 line-clamp-2 pl-6 text-sm text-fg-muted`,e.error&&`text-red-700 dark:text-red-300`),children:e.error||e.summary||bt(e.actionSnapshot,o)})]},e.id))}),t[109]=o,t[110]=c,t[111]=f,t[112]=r,t[113]=i,t[114]=q):q=t[114];let Ae;t[115]!==Oe||t[116]!==q?(Ae=(0,X.jsxs)(`section`,{className:`min-w-0`,children:[Oe,q]}),t[115]=Oe,t[116]=q,t[117]=Ae):Ae=t[117];let J;t[118]===o.experience.settings?J=t[119]:(J=(0,X.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:o.experience.settings}),t[118]=o.experience.settings,t[119]=J);let je;t[120]!==n||t[121]!==o?(je=At(n,o),t[120]=n,t[121]=o,t[122]=je):je=t[122];let Me;t[123]===je?Me=t[124]:(Me=(0,X.jsx)(ge,{content:je,compact:!0}),t[123]=je,t[124]=Me);let Ne;t[125]!==n||t[126]!==s||t[127]!==o||t[128]!==c||t[129]!==l?(Ne=(0,X.jsx)(en,{automation:n,labels:o,cronLabels:s,language:c,projects:l}),t[125]=n,t[126]=s,t[127]=o,t[128]=c,t[129]=l,t[130]=Ne):Ne=t[130];let Pe;t[131]!==Me||t[132]!==Ne?(Pe=(0,X.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[Me,Ne]}),t[131]=Me,t[132]=Ne,t[133]=Pe):Pe=t[133];let Y;t[134]!==J||t[135]!==Pe?(Y=(0,X.jsxs)(`details`,{className:`rounded-lg border border-edge-subtle p-4`,children:[J,Pe]}),t[134]=J,t[135]=Pe,t[136]=Y):Y=t[136];let Ie;t[137]!==Ae||t[138]!==Y?(Ie=(0,X.jsxs)(`div`,{className:`grid gap-5`,children:[Ae,Y]}),t[137]=Ae,t[138]=Y,t[139]=Ie):Ie=t[139];let Le;t[140]!==Ce||t[141]!==Ie?(Le=(0,X.jsxs)(`div`,{className:`grid gap-5 p-5`,children:[Ce,Ie]}),t[140]=Ce,t[141]=Ie,t[142]=Le):Le=t[142];let Re;return t[143]!==U||t[144]!==Le?(Re=(0,X.jsxs)(`article`,{className:`min-w-0 overflow-hidden rounded-xl border border-edge-subtle bg-surface-panel shadow-surface`,children:[U,Le]}),t[143]=U,t[144]=Le,t[145]=Re):Re=t[145],Re}function $t(e,t){return e===`suggest_only`?t.safety.suggestOnlyDescription:e===`ask_before_apply`?t.safety.askBeforeApplyDescription:t.safety.autoApplyDescription}function en(e){let t=(0,Fe.c)(146),{automation:n,labels:r,cronLabels:i,language:a,projects:o}=e,s,l,u,d,f,p,h,g,_,v,y;if(t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==a){let e=Tt(n),o;t[15]!==n||t[16]!==r||t[17]!==a?(o=ke(n,r,a),t[15]=n,t[16]=r,t[17]=a,t[18]=o):o=t[18];let c=o,b;t[19]!==n.state.nextRunAtMs||t[20]!==a?(b=n.state.nextRunAtMs?q(n.state.nextRunAtMs,a):void 0,t[19]=n.state.nextRunAtMs,t[20]=a,t[21]=b):b=t[21];let x=b;if(t[22]!==n.trigger.eventType||t[23]!==n.trigger.kind||t[24]!==n.trigger.schedule||t[25]!==n.trigger.secretId||t[26]!==n.trigger.source||t[27]!==r.info.anchor||t[28]!==r.info.calendarSchedule||t[29]!==r.info.eventSource||t[30]!==r.info.eventType||t[31]!==r.info.expression||t[32]!==r.info.fixedInterval||t[33]!==r.info.oneTimeSchedule||t[34]!==r.info.rawInterval||t[35]!==r.info.scheduleType||t[36]!==r.info.timezone||t[37]!==r.info.webhookSecret||t[38]!==a){if(y=[],n.trigger.kind===`schedule`){let e=n.trigger.schedule,i=e.kind===`interval`?r.info.fixedInterval:e.kind===`cron`?r.info.calendarSchedule:r.info.oneTimeSchedule,o;if(t[40]!==r.info.scheduleType||t[41]!==i?(o={label:r.info.scheduleType,value:i},t[40]=r.info.scheduleType,t[41]=i,t[42]=o):o=t[42],y.push(o),e.kind===`interval`){let n=`${e.everyMs} ms`,i;if(t[43]!==r.info.rawInterval||t[44]!==n?(i={label:r.info.rawInterval,value:n},t[43]=r.info.rawInterval,t[44]=n,t[45]=i):i=t[45],y.push(i),e.anchorMs){let n=r.info.anchor,i;t[46]!==a||t[47]!==e.anchorMs?(i=q(e.anchorMs,a),t[46]=a,t[47]=e.anchorMs,t[48]=i):i=t[48];let o;t[49]!==r.info.anchor||t[50]!==i?(o={label:n,value:i},t[49]=r.info.anchor,t[50]=i,t[51]=o):o=t[51],y.push(o)}}else if(e.kind===`cron`){let n;if(t[52]!==r.info.expression||t[53]!==e.expr?(n={label:r.info.expression,value:e.expr},t[52]=r.info.expression,t[53]=e.expr,t[54]=n):n=t[54],y.push(n),e.tz){let n;t[55]!==r.info.timezone||t[56]!==e.tz?(n={label:r.info.timezone,value:e.tz},t[55]=r.info.timezone,t[56]=e.tz,t[57]=n):n=t[57],y.push(n)}}else{let n;t[58]!==r.info.oneTimeSchedule||t[59]!==e.at?(n={label:r.info.oneTimeSchedule,value:e.at},t[58]=r.info.oneTimeSchedule,t[59]=e.at,t[60]=n):n=t[60],y.push(n)}}else if(n.trigger.kind===`event`){let e;if(t[61]!==n.trigger.eventType||t[62]!==r.info.eventType?(e={label:r.info.eventType,value:n.trigger.eventType},t[61]=n.trigger.eventType,t[62]=r.info.eventType,t[63]=e):e=t[63],y.push(e),n.trigger.source){let e;t[64]!==n.trigger.source||t[65]!==r.info.eventSource?(e={label:r.info.eventSource,value:n.trigger.source},t[64]=n.trigger.source,t[65]=r.info.eventSource,t[66]=e):e=t[66],y.push(e)}}else if(n.trigger.kind===`webhook`&&n.trigger.secretId){let e;t[67]!==n.trigger.secretId||t[68]!==r.info.webhookSecret?(e={label:r.info.webhookSecret,value:n.trigger.secretId},t[67]=n.trigger.secretId,t[68]=r.info.webhookSecret,t[69]=e):e=t[69],y.push(e)}t[22]=n.trigger.eventType,t[23]=n.trigger.kind,t[24]=n.trigger.schedule,t[25]=n.trigger.secretId,t[26]=n.trigger.source,t[27]=r.info.anchor,t[28]=r.info.calendarSchedule,t[29]=r.info.eventSource,t[30]=r.info.eventType,t[31]=r.info.expression,t[32]=r.info.fixedInterval,t[33]=r.info.oneTimeSchedule,t[34]=r.info.rawInterval,t[35]=r.info.scheduleType,t[36]=r.info.timezone,t[37]=r.info.webhookSecret,t[38]=a,t[39]=y}else y=t[39];_=`h-fit overflow-hidden rounded-xl border border-edge-subtle bg-surface-base shadow-surface`,t[70]===r.info.overview?v=t[71]:(v=(0,X.jsx)(`div`,{className:`border-b border-edge-subtle px-4 py-3`,children:(0,X.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.info.overview})}),t[70]=r.info.overview,t[71]=v),p=`grid gap-4 p-4`;let S;t[72]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,X.jsx)(N,{className:`size-4`,"aria-hidden":!0}),t[72]=S):S=t[72];let C=r.info.schedule,w;t[73]!==n.trigger||t[74]!==i||t[75]!==r||t[76]!==a?(w=Ee(n.trigger,r,i,a),t[73]=n.trigger,t[74]=i,t[75]=r,t[76]=a,t[77]=w):w=t[77];let T=n.enabled?`${r.info.nextRun}:${c}`:c;t[78]!==r.info.schedule||t[79]!==x||t[80]!==w||t[81]!==T?(h=(0,X.jsx)(nn,{icon:S,label:C,value:w,description:T,descriptionTitle:x}),t[78]=r.info.schedule,t[79]=x,t[80]=w,t[81]=T,t[82]=h):h=t[82];let E;t[83]===n.action.kind?E=t[84]:(E=n.action.kind===`browser_automation`?(0,X.jsx)(le,{className:`size-4`,"aria-hidden":!0}):n.action.kind===`task_command`?(0,X.jsx)(m,{className:`size-4`,"aria-hidden":!0}):(0,X.jsx)(W,{className:`size-4`,"aria-hidden":!0}),t[83]=n.action.kind,t[84]=E);let D=r.info.action,O;t[85]!==n.action||t[86]!==r?(O=bt(n.action,r),t[85]=n.action,t[86]=r,t[87]=O):O=t[87],t[88]!==r.info.action||t[89]!==E||t[90]!==O?(g=(0,X.jsx)(nn,{icon:E,label:D,value:O}),t[88]=r.info.action,t[89]=E,t[90]=O,t[91]=g):g=t[91],s=nn,t[92]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,X.jsx)(be,{className:`size-4`,"aria-hidden":!0}),t[92]=l):l=t[92],u=r.info.permission,d=r.safety[e],f=$t(e,r),t[0]=n,t[1]=i,t[2]=r,t[3]=a,t[4]=s,t[5]=l,t[6]=u,t[7]=d,t[8]=f,t[9]=p,t[10]=h,t[11]=g,t[12]=_,t[13]=v,t[14]=y}else s=t[4],l=t[5],u=t[6],d=t[7],f=t[8],p=t[9],h=t[10],g=t[11],_=t[12],v=t[13],y=t[14];let b;t[93]!==s||t[94]!==l||t[95]!==u||t[96]!==d||t[97]!==f?(b=(0,X.jsx)(s,{icon:l,label:u,value:d,description:f}),t[93]=s,t[94]=l,t[95]=u,t[96]=d,t[97]=f,t[98]=b):b=t[98];let x;t[99]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,X.jsx)(L,{className:`size-4`,"aria-hidden":!0}),t[99]=x):x=t[99];let S;t[100]!==n.projectId||t[101]!==r.info.noProject||t[102]!==o?(S=o.find(e=>e.id===n.projectId)?.name??r.info.noProject,t[100]=n.projectId,t[101]=r.info.noProject,t[102]=o,t[103]=S):S=t[103];let C;t[104]!==r.info.project||t[105]!==S?(C=(0,X.jsx)(nn,{icon:x,label:r.info.project,value:S}),t[104]=r.info.project,t[105]=S,t[106]=C):C=t[106];let w;t[107]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,X.jsx)(H,{className:`size-4`,"aria-hidden":!0}),t[107]=w):w=t[107];let T=n.conversationMode===`continuous`?r.info.continuousConversation:r.info.newConversation,E;t[108]!==r.info.conversation||t[109]!==T?(E=(0,X.jsx)(nn,{icon:w,label:r.info.conversation,value:T}),t[108]=r.info.conversation,t[109]=T,t[110]=E):E=t[110];let D;t[111]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,X.jsx)(he,{className:`size-4`,"aria-hidden":!0}),t[111]=D):D=t[111];let O=n.delivery.notificationPolicy===`all`?r.info.notifyAll:n.delivery.notificationPolicy===`none`?r.info.notifyNone:r.info.notifyAttention,ee;t[112]!==r.info.notifications||t[113]!==O?(ee=(0,X.jsx)(nn,{icon:D,label:r.info.notifications,value:O}),t[112]=r.info.notifications,t[113]=O,t[114]=ee):ee=t[114];let k;t[115]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,X.jsx)(te,{className:`size-4`,"aria-hidden":!0}),t[115]=k):k=t[115];let A=r.info.lastRun,j;t[116]!==n||t[117]!==r||t[118]!==a?(j=Oe(n,r,a),t[116]=n,t[117]=r,t[118]=a,t[119]=j):j=t[119];let M=n.state.lastRunStatus===`failed`||n.state.lastRunStatus===`timeout`?`danger`:`default`,ne;t[120]!==r.info.lastRun||t[121]!==j||t[122]!==M?(ne=(0,X.jsx)(nn,{icon:k,label:A,value:j,valueTone:M}),t[120]=r.info.lastRun,t[121]=j,t[122]=M,t[123]=ne):ne=t[123];let P;t[124]!==n.state.consecutiveFailures||t[125]!==n.state.lastError||t[126]!==r.dashboard?(P=n.state.consecutiveFailures?(0,X.jsxs)(`div`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,children:[r.dashboard.failures,`:`,n.state.consecutiveFailures,n.state.lastError?(0,X.jsx)(`p`,{className:`mt-1 break-words text-xs`,children:n.state.lastError}):null]}):n.state.lastError?(0,X.jsx)(`p`,{className:`break-words text-sm text-red-700 dark:text-red-300`,children:n.state.lastError}):null,t[124]=n.state.consecutiveFailures,t[125]=n.state.lastError,t[126]=r.dashboard,t[127]=P):P=t[127];let F;t[128]!==r.info.technicalDetails||t[129]!==y?(F=y.length>0?(0,X.jsxs)(`details`,{className:`group border-t border-edge-subtle pt-3`,children:[(0,X.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-2 text-sm text-fg-muted outline-none hover:text-fg focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,X.jsx)(`span`,{children:r.info.technicalDetails}),(0,X.jsx)(c,{className:`size-4 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,X.jsx)(`div`,{className:`mt-3 grid gap-2`,children:y.map(tn)})]}):null,t[128]=r.info.technicalDetails,t[129]=y,t[130]=F):F=t[130];let I;t[131]!==b||t[132]!==C||t[133]!==E||t[134]!==ee||t[135]!==ne||t[136]!==P||t[137]!==F||t[138]!==p||t[139]!==h||t[140]!==g?(I=(0,X.jsxs)(`div`,{className:p,children:[h,g,b,C,E,ee,ne,P,F]}),t[131]=b,t[132]=C,t[133]=E,t[134]=ee,t[135]=ne,t[136]=P,t[137]=F,t[138]=p,t[139]=h,t[140]=g,t[141]=I):I=t[141];let re;return t[142]!==I||t[143]!==_||t[144]!==v?(re=(0,X.jsxs)(`aside`,{className:_,children:[v,I]}),t[142]=I,t[143]=_,t[144]=v,t[145]=re):re=t[145],re}function tn(e){return(0,X.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,X.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.label}),(0,X.jsx)(`span`,{className:`break-all font-mono text-xs text-fg-muted`,children:e.value})]},`${e.label}:${e.value}`)}function nn(e){let t=(0,Fe.c)(19),{icon:n,label:r,value:i,description:a,descriptionTitle:o,valueTone:s}=e,c=s===void 0?`default`:s,l;t[0]===n?l=t[1]:(l=(0,X.jsx)(`span`,{className:`mt-0.5 text-fg-subtle`,children:n}),t[0]=n,t[1]=l);let u;t[2]===r?u=t[3]:(u=(0,X.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r}),t[2]=r,t[3]=u);let d=c===`danger`?`text-red-700 dark:text-red-300`:`text-fg`,f;t[4]===d?f=t[5]:(f=v(`mt-1 text-sm font-medium leading-5`,d),t[4]=d,t[5]=f);let p;t[6]!==f||t[7]!==i?(p=(0,X.jsx)(`div`,{className:f,children:i}),t[6]=f,t[7]=i,t[8]=p):p=t[8];let m;t[9]!==a||t[10]!==o?(m=a?(0,X.jsx)(`div`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,title:o,children:a}):null,t[9]=a,t[10]=o,t[11]=m):m=t[11];let h;t[12]!==u||t[13]!==p||t[14]!==m?(h=(0,X.jsxs)(`div`,{className:`min-w-0`,children:[u,p,m]}),t[12]=u,t[13]=p,t[14]=m,t[15]=h):h=t[15];let g;return t[16]!==l||t[17]!==h?(g=(0,X.jsxs)(`div`,{className:`grid grid-cols-[1.25rem_1fr] gap-2.5`,children:[l,h]}),t[16]=l,t[17]=h,t[18]=g):g=t[18],g}function rn(e){let t=(0,Fe.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,X.jsx)(`span`,{children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,X.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,X.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 an(e){return e.endsWith(`.failed`)?`bg-red-500`:e.endsWith(`.completed`)?`bg-emerald-500`:e.endsWith(`.started`)?`bg-blue-500`:`bg-fg-muted`}function on(e){let t=(0,Fe.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,X.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,X.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,X.jsxs)(`div`,{className:`min-w-0`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function sn(e){let t=(0,Fe.c)(8),{className:n,icon:r,title:i}=e,a;t[0]===n?a=t[1]:(a=v(`flex min-h-48 flex-col items-center justify-center text-fg-muted`,n),t[0]=n,t[1]=a);let o;t[2]===i?o=t[3]:(o=(0,X.jsx)(`div`,{className:`mt-2 text-sm`,children:i}),t[2]=i,t[3]=o);let s;return t[4]!==r||t[5]!==a||t[6]!==o?(s=(0,X.jsxs)(`div`,{className:a,children:[r,o]}),t[4]=r,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function cn(e){let t=(0,Fe.c)(326),{form:n,labels:r,setForm:i,projects:a,browserAutomations:o,selectedBrowserAutomation:s,browserAutomationsLoading:l,agentOptions:u,agentsLoading:p,defaultAgentId:m,taskOptions:h,tasksLoading:g,language:y,projectLocked:b}=e,x=b===void 0?!1:b,S=_(y).agentsSettings,C;t[0]===i?C=t[1]:(C=e=>i(t=>({...t,...e})),t[0]=i,t[1]=C);let w=C,T=J(n.intervalValue,n.intervalUnit),E=Date.now(),D;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(D=[1,2,3],t[2]=D):D=t[2];let O;t[3]!==T||t[4]!==E||t[5]!==y?(O=D.map(e=>De(E+T*e,y,E)),t[3]=T,t[4]=E,t[5]=y,t[6]=O):O=t[6];let ee=O,te;if(t[7]!==n.projectId||t[8]!==n.taskId||t[9]!==h){let e;t[11]!==n.projectId||t[12]!==n.taskId?(e=e=>e.id===n.taskId||e.phase!==`closed`&&(!n.projectId||e.projectId===n.projectId),t[11]=n.projectId,t[12]=n.taskId,t[13]=e):e=t[13],te=h.filter(e),t[7]=n.projectId,t[8]=n.taskId,t[9]=h,t[10]=te}else te=t[10];let k=te,j,M;t[14]!==m||t[15]!==n.actionMode||t[16]!==n.agentId||t[17]!==i?(j=()=>{n.actionMode!==`task_command`||n.agentId.trim()||!m||i(e=>({...e,agentId:m}))},M=[m,n.actionMode,n.agentId,i],t[14]=m,t[15]=n.actionMode,t[16]=n.agentId,t[17]=i,t[18]=j,t[19]=M):(j=t[18],M=t[19]),(0,Y.useEffect)(j,M);let N,ne;t[20]!==o||t[21]!==n.actionMode||t[22]!==n.browserAutomationId||t[23]!==i?(N=()=>{if(n.actionMode!==`browser_automation`||n.browserAutomationId.trim())return;let e=o[0];e&&i(t=>({...t,browserAutomationId:e.id,browserAutomationInputs:Ne(e)}))},ne=[o,n.actionMode,n.browserAutomationId,i],t[20]=o,t[21]=n.actionMode,t[22]=n.browserAutomationId,t[23]=i,t[24]=N,t[25]=ne):(N=t[24],ne=t[25]),(0,Y.useEffect)(N,ne);let P;t[26]===w?P=t[27]:(P=e=>w({name:e.target.value}),t[26]=w,t[27]=P);let F;t[28]!==n.name||t[29]!==P?(F=(0,X.jsx)(`input`,{className:Q,value:n.name,onChange:P}),t[28]=n.name,t[29]=P,t[30]=F):F=t[30];let I;t[31]!==r.form.name||t[32]!==F?(I=(0,X.jsx)($,{label:r.form.name,children:F}),t[31]=r.form.name,t[32]=F,t[33]=I):I=t[33];let re;t[34]===w?re=t[35]:(re=e=>w({description:e.target.value}),t[34]=w,t[35]=re);let ie;t[36]!==n.description||t[37]!==re?(ie=(0,X.jsx)(`input`,{className:Q,value:n.description,onChange:re}),t[36]=n.description,t[37]=re,t[38]=ie):ie=t[38];let ae;t[39]!==r.form.description||t[40]!==ie?(ae=(0,X.jsx)($,{label:r.form.description,children:ie}),t[39]=r.form.description,t[40]=ie,t[41]=ae):ae=t[41];let se;t[42]!==n.projectId||t[43]!==r.form.noProject||t[44]!==r.form.project||t[45]!==x||t[46]!==a||t[47]!==w?(se=x?null:(0,X.jsx)($,{label:r.form.project,children:(0,X.jsxs)(d,{className:Q,value:n.projectId,onChange:e=>w({projectId:e.target.value}),children:[(0,X.jsx)(f,{value:``,children:r.form.noProject}),a.map(un)]})}),t[42]=n.projectId,t[43]=r.form.noProject,t[44]=r.form.project,t[45]=x,t[46]=a,t[47]=w,t[48]=se):se=t[48];let ce=r.form.rulePreview,le;t[49]===r.form.rulePreview?le=t[50]:(le=(0,X.jsx)(`div`,{className:`text-xs font-medium text-accent-fg`,children:r.form.rulePreview}),t[49]=r.form.rulePreview,t[50]=le);let ue;t[51]!==n.triggerMode||t[52]!==r?(ue=Ct(n.triggerMode,r),t[51]=n.triggerMode,t[52]=r,t[53]=ue):ue=t[53];let de;t[54]===ue?de=t[55]:(de=(0,X.jsx)(`span`,{children:ue}),t[54]=ue,t[55]=de);let fe;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,X.jsx)(oe,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),t[56]=fe):fe=t[56];let L;t[57]!==n.actionMode||t[58]!==r?(L=St(n.actionMode,r),t[57]=n.actionMode,t[58]=r,t[59]=L):L=t[59];let pe;t[60]===L?pe=t[61]:(pe=(0,X.jsx)(`span`,{children:L}),t[60]=L,t[61]=pe);let R;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,X.jsx)(oe,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),t[62]=R):R=t[62];let z;t[63]!==n.projectId||t[64]!==r.form.noProject||t[65]!==r.form.project||t[66]!==a?(z=n.projectId?a.find(e=>e.id===n.projectId)?.name??r.form.project:r.form.noProject,t[63]=n.projectId,t[64]=r.form.noProject,t[65]=r.form.project,t[66]=a,t[67]=z):z=t[67];let B;t[68]===z?B=t[69]:(B=(0,X.jsx)(`span`,{children:z}),t[68]=z,t[69]=B);let V;t[70]!==de||t[71]!==pe||t[72]!==B?(V=(0,X.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-sm text-fg`,children:[de,fe,pe,R,B]}),t[70]=de,t[71]=pe,t[72]=B,t[73]=V):V=t[73];let me;t[74]!==r.form.rulePreview||t[75]!==le||t[76]!==V?(me=(0,X.jsxs)(`div`,{className:`rounded-xl border border-accent/20 bg-accent/5 px-4 py-3`,"aria-label":ce,children:[le,V]}),t[74]=r.form.rulePreview,t[75]=le,t[76]=V,t[77]=me):me=t[77];let H;t[78]!==r.form.trigger||t[79]!==r.form.triggerStepDescription?(H=(0,X.jsx)(dn,{step:`1`,title:r.form.trigger,description:r.form.triggerStepDescription}),t[78]=r.form.trigger,t[79]=r.form.triggerStepDescription,t[80]=H):H=t[80];let he;t[81]===w?he=t[82]:(he=e=>w({triggerMode:e.target.value}),t[81]=w,t[82]=he);let ge;t[83]===r.trigger.manual?ge=t[84]:(ge=(0,X.jsx)(f,{value:`manual`,children:r.trigger.manual}),t[83]=r.trigger.manual,t[84]=ge);let _e;t[85]===r.trigger.once?_e=t[86]:(_e=(0,X.jsx)(f,{value:`once`,children:r.trigger.once}),t[85]=r.trigger.once,t[86]=_e);let W;t[87]===r.trigger.daily?W=t[88]:(W=(0,X.jsx)(f,{value:`daily`,children:r.trigger.daily}),t[87]=r.trigger.daily,t[88]=W);let ve;t[89]===r.trigger.weekly?ve=t[90]:(ve=(0,X.jsx)(f,{value:`weekly`,children:r.trigger.weekly}),t[89]=r.trigger.weekly,t[90]=ve);let G;t[91]===r.trigger.interval?G=t[92]:(G=(0,X.jsx)(f,{value:`interval`,children:r.trigger.interval}),t[91]=r.trigger.interval,t[92]=G);let ye;t[93]===r.trigger.customCron?ye=t[94]:(ye=(0,X.jsx)(f,{value:`cron`,children:r.trigger.customCron}),t[93]=r.trigger.customCron,t[94]=ye);let be;t[95]===r.trigger.webhook?be=t[96]:(be=(0,X.jsx)(f,{value:`webhook`,children:r.trigger.webhook}),t[95]=r.trigger.webhook,t[96]=be);let xe;t[97]===r.trigger.taskBlocked?xe=t[98]:(xe=(0,X.jsx)(f,{value:`taskBlocked`,children:r.trigger.taskBlocked}),t[97]=r.trigger.taskBlocked,t[98]=xe);let Se;t[99]===r.trigger.noteCreated?Se=t[100]:(Se=(0,X.jsx)(f,{value:`noteCreated`,children:r.trigger.noteCreated}),t[99]=r.trigger.noteCreated,t[100]=Se);let Ce;t[101]===r.trigger.sessionUpdated?Ce=t[102]:(Ce=(0,X.jsx)(f,{value:`sessionUpdated`,children:r.trigger.sessionUpdated}),t[101]=r.trigger.sessionUpdated,t[102]=Ce);let we;t[103]===r.trigger.customEvent?we=t[104]:(we=(0,X.jsx)(f,{value:`event`,children:r.trigger.customEvent}),t[103]=r.trigger.customEvent,t[104]=we);let Ee;t[105]!==n.triggerMode||t[106]!==he||t[107]!==ge||t[108]!==_e||t[109]!==W||t[110]!==ve||t[111]!==G||t[112]!==ye||t[113]!==be||t[114]!==xe||t[115]!==Se||t[116]!==Ce||t[117]!==we?(Ee=(0,X.jsxs)(d,{className:Q,value:n.triggerMode,onChange:he,children:[ge,_e,W,ve,G,ye,be,xe,Se,Ce,we]}),t[105]=n.triggerMode,t[106]=he,t[107]=ge,t[108]=_e,t[109]=W,t[110]=ve,t[111]=G,t[112]=ye,t[113]=be,t[114]=xe,t[115]=Se,t[116]=Ce,t[117]=we,t[118]=Ee):Ee=t[118];let Oe;t[119]!==n.onceAt||t[120]!==n.triggerMode||t[121]!==r.form.onceAt||t[122]!==w?(Oe=n.triggerMode===`once`?(0,X.jsx)($,{label:r.form.onceAt,children:(0,X.jsx)(`input`,{className:Q,type:`datetime-local`,value:n.onceAt,onChange:e=>w({onceAt:e.target.value})})}):null,t[119]=n.onceAt,t[120]=n.triggerMode,t[121]=r.form.onceAt,t[122]=w,t[123]=Oe):Oe=t[123];let q;t[124]!==n.time||t[125]!==n.triggerMode||t[126]!==n.weekday||t[127]!==r.form.day||t[128]!==r.form.time||t[129]!==r.weekdays||t[130]!==w?(q=n.triggerMode===`daily`||n.triggerMode===`weekly`?(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,X.jsx)($,{label:r.form.time,children:(0,X.jsx)(Be,{value:n.time,onChange:e=>w({time:e}),ariaLabel:r.form.time})}),n.triggerMode===`weekly`?(0,X.jsx)($,{label:r.form.day,children:(0,X.jsxs)(d,{className:Q,value:n.weekday,onChange:e=>w({weekday:e.target.value}),children:[(0,X.jsx)(f,{value:`1`,children:r.weekdays.monday}),(0,X.jsx)(f,{value:`2`,children:r.weekdays.tuesday}),(0,X.jsx)(f,{value:`3`,children:r.weekdays.wednesday}),(0,X.jsx)(f,{value:`4`,children:r.weekdays.thursday}),(0,X.jsx)(f,{value:`5`,children:r.weekdays.friday}),(0,X.jsx)(f,{value:`6`,children:r.weekdays.saturday}),(0,X.jsx)(f,{value:`0`,children:r.weekdays.sunday})]})}):null]}):null,t[124]=n.time,t[125]=n.triggerMode,t[126]=n.weekday,t[127]=r.form.day,t[128]=r.form.time,t[129]=r.weekdays,t[130]=w,t[131]=q):q=t[131];let ke=n.triggerMode===`interval`?(0,X.jsxs)(`div`,{className:`grid gap-3 rounded-lg border border-edge-subtle bg-surface-base p-3`,children:[(0,X.jsx)($,{label:r.form.intervalEvery,children:(0,X.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[minmax(0,1fr)_10rem]`,children:[(0,X.jsx)(`input`,{className:Q,type:`number`,min:6e4/J(1,n.intervalUnit),step:`any`,inputMode:`decimal`,value:n.intervalValue,onChange:e=>w({intervalValue:e.target.value})}),(0,X.jsxs)(d,{className:Q,value:n.intervalUnit,onChange:e=>{let t=e.target.value;w({intervalValue:Te(n.intervalValue,n.intervalUnit,t),intervalUnit:t})},children:[(0,X.jsx)(f,{value:`minute`,children:r.form.intervalUnits.minute}),(0,X.jsx)(f,{value:`hour`,children:r.form.intervalUnits.hour}),(0,X.jsx)(f,{value:`day`,children:r.form.intervalUnits.day}),(0,X.jsx)(f,{value:`week`,children:r.form.intervalUnits.week})]})]})}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r.form.commonIntervals}),(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:et.map(e=>{let t=J(e.value,e.unit),n=t===T;return(0,X.jsx)(`button`,{type:`button`,"aria-pressed":n,className:v(`rounded-full border px-2.5 py-1 text-xs transition-colors`,n?`border-accent bg-accent/10 text-accent`:`border-edge-subtle text-fg-muted hover:border-edge hover:bg-surface-hover hover:text-fg`),onClick:()=>w({intervalValue:e.value,intervalUnit:e.unit}),children:Ae(t,y)},`${e.value}:${e.unit}`)})})]}),(0,X.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2.5`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:K(T,y)}),(0,X.jsxs)(`div`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:[r.form.nextThreeRuns,`:`,ee.join(y===`zh`?`、`:`, `)]}),(0,X.jsx)(`div`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:r.form.fixedIntervalHint})]})]}):null,je;t[132]!==n.cronExpr||t[133]!==n.triggerMode||t[134]!==r.form.expression||t[135]!==w?(je=n.triggerMode===`cron`?(0,X.jsx)($,{label:r.form.expression,children:(0,X.jsx)(`input`,{className:Q,value:n.cronExpr,onChange:e=>w({cronExpr:e.target.value})})}):null,t[132]=n.cronExpr,t[133]=n.triggerMode,t[134]=r.form.expression,t[135]=w,t[136]=je):je=t[136];let Me;t[137]!==n.triggerMode||t[138]!==n.webhookSecretId||t[139]!==r.form.secretId||t[140]!==w?(Me=n.triggerMode===`webhook`?(0,X.jsx)($,{label:r.form.secretId,children:(0,X.jsx)(`input`,{className:Q,value:n.webhookSecretId,onChange:e=>w({webhookSecretId:e.target.value})})}):null,t[137]=n.triggerMode,t[138]=n.webhookSecretId,t[139]=r.form.secretId,t[140]=w,t[141]=Me):Me=t[141];let Ie;t[142]!==n.eventPayloadMatch||t[143]!==n.eventSource||t[144]!==n.eventType||t[145]!==n.triggerMode||t[146]!==r.form.eventPayloadMatch||t[147]!==r.form.eventSource||t[148]!==r.form.eventType||t[149]!==r.form.invalidJsonObject||t[150]!==w?(Ie=n.triggerMode===`event`?(0,X.jsxs)(`div`,{className:`grid gap-3 rounded-lg border border-edge-subtle bg-surface-base p-3`,children:[(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,X.jsx)($,{label:r.form.eventType,children:(0,X.jsx)(`input`,{className:Q,value:n.eventType,onChange:e=>w({eventType:e.target.value})})}),(0,X.jsx)($,{label:r.form.eventSource,children:(0,X.jsx)(`input`,{className:Q,value:n.eventSource,onChange:e=>w({eventSource:e.target.value})})})]}),(0,X.jsxs)($,{label:r.form.eventPayloadMatch,children:[(0,X.jsx)(`textarea`,{className:v(Q,`min-h-24 resize-y font-mono text-xs`),value:n.eventPayloadMatch,onChange:e=>w({eventPayloadMatch:e.target.value}),placeholder:`{
7
- "status": "blocked"
8
- }`}),ot(n.eventPayloadMatch)?null:(0,X.jsx)(`span`,{className:`text-xs text-red-700 dark:text-red-300`,children:r.form.invalidJsonObject})]})]}):null,t[142]=n.eventPayloadMatch,t[143]=n.eventSource,t[144]=n.eventType,t[145]=n.triggerMode,t[146]=r.form.eventPayloadMatch,t[147]=r.form.eventSource,t[148]=r.form.eventType,t[149]=r.form.invalidJsonObject,t[150]=w,t[151]=Ie):Ie=t[151];let Le;t[152]!==r.form.action||t[153]!==r.form.actionStepDescription?(Le=(0,X.jsx)(dn,{step:`2`,title:r.form.action,description:r.form.actionStepDescription}),t[152]=r.form.action,t[153]=r.form.actionStepDescription,t[154]=Le):Le=t[154];let Re;t[155]!==n.timeoutSeconds||t[156]!==w?(Re=e=>{let t=e.target.value,r=Number.parseInt(n.timeoutSeconds,10);w({actionMode:t,...r===600||r===1800?{timeoutSeconds:t===`browser_automation`?`600`:`1800`}:{},...t===`browser_automation`||t===`task_command`?{safetyMode:`auto_apply`}:{}})},t[155]=n.timeoutSeconds,t[156]=w,t[157]=Re):Re=t[157];let ze;t[158]===r.action.runAgent?ze=t[159]:(ze=(0,X.jsx)(f,{value:`agent`,children:r.action.runAgent}),t[158]=r.action.runAgent,t[159]=ze);let Ve;t[160]===r.action.runTask?Ve=t[161]:(Ve=(0,X.jsx)(f,{value:`task_command`,children:r.action.runTask}),t[160]=r.action.runTask,t[161]=Ve);let He=y===`zh`?`浏览器自动化`:`Browser automation`,Ue;t[162]===He?Ue=t[163]:(Ue=(0,X.jsx)(f,{value:`browser_automation`,children:He}),t[162]=He,t[163]=Ue);let We;t[164]!==n.actionMode||t[165]!==Re||t[166]!==ze||t[167]!==Ve||t[168]!==Ue?(We=(0,X.jsxs)(d,{className:Q,value:n.actionMode,onChange:Re,children:[ze,Ve,Ue]}),t[164]=n.actionMode,t[165]=Re,t[166]=ze,t[167]=Ve,t[168]=Ue,t[169]=We):We=t[169];let Ge=n.actionMode===`browser_automation`?null:(0,X.jsx)($,{label:r.form.agent,children:(0,X.jsxs)(d,{className:Q,value:n.agentId,onChange:e=>w({agentId:e.target.value}),children:[(0,X.jsx)(f,{value:``,children:p?r.form.loadingAgents:r.form.defaultAgent}),u.map(e=>(0,X.jsx)(f,{value:e.id,children:A(e,S)},e.id))]})}),Ke;t[170]!==k||t[171]!==o||t[172]!==l||t[173]!==n.actionMode||t[174]!==n.agentId||t[175]!==n.browserAutomationId||t[176]!==n.browserAutomationInputs||t[177]!==n.description||t[178]!==n.instruction||t[179]!==n.model||t[180]!==n.name||t[181]!==n.taskId||t[182]!==n.triggerMode||t[183]!==r.form.defaultModel||t[184]!==r.form.instruction||t[185]!==r.form.loadingTasks||t[186]!==r.form.model||t[187]!==r.form.modelHint||t[188]!==r.form.noModels||t[189]!==r.form.noTasks||t[190]!==r.form.searchModels||t[191]!==r.form.task||t[192]!==r.form.taskClosed||t[193]!==r.form.taskContextHint||t[194]!==y||t[195]!==s||t[196]!==g||t[197]!==w?(Ke=n.actionMode===`agent`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)($,{label:r.form.model,children:[(0,X.jsx)(U,{value:n.model,onChange:e=>w({model:e}),placeholder:r.form.defaultModel,emptyLabel:r.form.defaultModel,searchPlaceholder:r.form.searchModels,noMatches:r.form.noModels,allowEmpty:!0,showProviderSettingsFooter:!0,contentAlign:`start`,className:`w-full`,ariaLabel:r.form.model}),(0,X.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:r.form.modelHint})]}),(0,X.jsxs)($,{label:r.form.instruction,children:[(0,X.jsx)(`div`,{className:`flex justify-end`,children:(0,X.jsx)(Ye,{value:n.instruction,onApply:e=>w({instruction:e}),fieldId:`automation.instruction`,fieldLabel:r.form.instruction,scenario:`automation.instruction`,locale:y,context:{automationName:n.name,automationDescription:n.description,triggerMode:n.triggerMode,agentId:n.agentId,model:n.model},showLabel:!1})}),(0,X.jsx)(`textarea`,{className:v(Q,`min-h-32 resize-y`),value:n.instruction,onChange:e=>w({instruction:e.target.value})})]})]}):n.actionMode===`task_command`?(0,X.jsx)(X.Fragment,{children:(0,X.jsxs)($,{label:r.form.task,children:[(0,X.jsxs)(d,{className:Q,value:n.taskId,onChange:e=>w({taskId:e.target.value}),disabled:g||k.length===0,children:[g?(0,X.jsx)(f,{value:``,children:r.form.loadingTasks}):null,!g&&k.length===0?(0,X.jsx)(f,{value:``,children:r.form.noTasks}):null,k.map(e=>(0,X.jsxs)(f,{value:e.id,disabled:e.phase===`closed`,children:[e.title,e.phase===`closed`?` · ${r.form.taskClosed}`:``]},e.id))]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:r.form.taskContextHint})]})}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{label:y===`zh`?`浏览器自动化`:`Browser automation`,children:(0,X.jsxs)(d,{className:Q,value:n.browserAutomationId,onChange:e=>{let t=o.find(t=>t.id===e.target.value);w({browserAutomationId:e.target.value,browserAutomationInputs:t?Ne(t):{}})},disabled:l||o.length===0,children:[o.length===0?(0,X.jsx)(f,{value:``,children:y===`zh`?`没有已启用的浏览器自动化`:`No enabled browser automations`}):null,o.map(ln)]})}),s&&Object.keys(s.inputs).length>0?(0,X.jsx)($,{label:y===`zh`?`运行时填写`:`Run inputs`,children:(0,X.jsx)(Pe,{automation:s,values:n.browserAutomationInputs,language:y,onChange:e=>w({browserAutomationInputs:e})})}):null]}),t[170]=k,t[171]=o,t[172]=l,t[173]=n.actionMode,t[174]=n.agentId,t[175]=n.browserAutomationId,t[176]=n.browserAutomationInputs,t[177]=n.description,t[178]=n.instruction,t[179]=n.model,t[180]=n.name,t[181]=n.taskId,t[182]=n.triggerMode,t[183]=r.form.defaultModel,t[184]=r.form.instruction,t[185]=r.form.loadingTasks,t[186]=r.form.model,t[187]=r.form.modelHint,t[188]=r.form.noModels,t[189]=r.form.noTasks,t[190]=r.form.searchModels,t[191]=r.form.task,t[192]=r.form.taskClosed,t[193]=r.form.taskContextHint,t[194]=y,t[195]=s,t[196]=g,t[197]=w,t[198]=Ke):Ke=t[198];let Z;t[199]===Symbol.for(`react.memo_cache_sentinel`)?(Z=(0,X.jsx)(`span`,{className:`flex size-6 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs text-fg-muted`,children:`3`}),t[199]=Z):Z=t[199];let qe;t[200]===r.form.advancedDescription?qe=t[201]:(qe=(0,X.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:r.form.advancedDescription}),t[200]=r.form.advancedDescription,t[201]=qe);let Je;t[202]!==r.form.advanced||t[203]!==qe?(Je=(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[Z,(0,X.jsxs)(`span`,{children:[r.form.advanced,qe]})]}),t[202]=r.form.advanced,t[203]=qe,t[204]=Je):Je=t[204];let Xe;t[205]===Symbol.for(`react.memo_cache_sentinel`)?(Xe=(0,X.jsx)(c,{className:`size-4 transition-transform group-open:rotate-180`}),t[205]=Xe):Xe=t[205];let Ze;t[206]===Je?Ze=t[207]:(Ze=(0,X.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-4 py-3 text-sm font-semibold text-fg outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[Je,Xe]}),t[206]=Je,t[207]=Ze);let Qe;t[208]!==n.actionMode||t[209]!==n.safetyMode||t[210]!==r.form.safety||t[211]!==r.safety||t[212]!==w?(Qe=n.actionMode!==`browser_automation`&&n.actionMode!==`task_command`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(dn,{title:r.form.safety}),(0,X.jsxs)($,{label:r.form.safety,children:[(0,X.jsxs)(d,{className:Q,value:n.safetyMode,onChange:e=>{let t=e.target.value;w({safetyMode:t})},children:[(0,X.jsx)(f,{value:`suggest_only`,children:r.safety.suggest_only}),(0,X.jsx)(f,{value:`ask_before_apply`,children:r.safety.ask_before_apply}),(0,X.jsx)(f,{value:`auto_apply`,children:r.safety.auto_apply})]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:n.safetyMode===`suggest_only`?r.safety.suggestOnlyDescription:n.safetyMode===`ask_before_apply`?r.safety.askBeforeApplyDescription:r.safety.autoApplyDescription})]})]}):null,t[208]=n.actionMode,t[209]=n.safetyMode,t[210]=r.form.safety,t[211]=r.safety,t[212]=w,t[213]=Qe):Qe=t[213];let $e;t[214]===r.form.results?$e=t[215]:($e=(0,X.jsx)(dn,{title:r.form.results}),t[214]=r.form.results,t[215]=$e);let tt;t[216]===w?tt=t[217]:(tt=e=>w({conversationMode:e.target.value}),t[216]=w,t[217]=tt);let nt;t[218]===r.form.newConversation?nt=t[219]:(nt=(0,X.jsx)(f,{value:`new_session`,children:r.form.newConversation}),t[218]=r.form.newConversation,t[219]=nt);let rt;t[220]===r.form.continuousConversation?rt=t[221]:(rt=(0,X.jsx)(f,{value:`continuous`,children:r.form.continuousConversation}),t[220]=r.form.continuousConversation,t[221]=rt);let it;t[222]!==n.conversationMode||t[223]!==tt||t[224]!==nt||t[225]!==rt?(it=(0,X.jsxs)(d,{className:Q,value:n.conversationMode,onChange:tt,children:[nt,rt]}),t[222]=n.conversationMode,t[223]=tt,t[224]=nt,t[225]=rt,t[226]=it):it=t[226];let at;t[227]!==r.form.conversation||t[228]!==it?(at=(0,X.jsx)($,{label:r.form.conversation,children:it}),t[227]=r.form.conversation,t[228]=it,t[229]=at):at=t[229];let st;t[230]===w?st=t[231]:(st=e=>w({notificationPolicy:e.target.value}),t[230]=w,t[231]=st);let ct;t[232]===r.form.notifyAttention?ct=t[233]:(ct=(0,X.jsx)(f,{value:`attention`,children:r.form.notifyAttention}),t[232]=r.form.notifyAttention,t[233]=ct);let lt;t[234]===r.form.notifyAll?lt=t[235]:(lt=(0,X.jsx)(f,{value:`all`,children:r.form.notifyAll}),t[234]=r.form.notifyAll,t[235]=lt);let ut;t[236]===r.form.notifyNone?ut=t[237]:(ut=(0,X.jsx)(f,{value:`none`,children:r.form.notifyNone}),t[236]=r.form.notifyNone,t[237]=ut);let dt;t[238]!==n.notificationPolicy||t[239]!==st||t[240]!==ct||t[241]!==lt||t[242]!==ut?(dt=(0,X.jsxs)(d,{className:Q,value:n.notificationPolicy,onChange:st,children:[ct,lt,ut]}),t[238]=n.notificationPolicy,t[239]=st,t[240]=ct,t[241]=lt,t[242]=ut,t[243]=dt):dt=t[243];let ft;t[244]!==r.form.notifications||t[245]!==dt?(ft=(0,X.jsx)($,{label:r.form.notifications,children:dt}),t[244]=r.form.notifications,t[245]=dt,t[246]=ft):ft=t[246];let pt;t[247]===w?pt=t[248]:(pt=e=>w({resultWebhookEndpoint:e.target.value}),t[247]=w,t[248]=pt);let mt;t[249]!==n.resultWebhookEndpoint||t[250]!==pt?(mt=(0,X.jsx)(`input`,{className:Q,value:n.resultWebhookEndpoint,onChange:pt}),t[249]=n.resultWebhookEndpoint,t[250]=pt,t[251]=mt):mt=t[251];let ht;t[252]===w?ht=t[253]:(ht=e=>w({resultWebhookSecretId:e.target.value}),t[252]=w,t[253]=ht);let gt;t[254]!==n.resultWebhookSecretId||t[255]!==r.form.resultWebhookSecretId||t[256]!==ht?(gt=(0,X.jsx)(`input`,{className:Q,value:n.resultWebhookSecretId,onChange:ht,placeholder:r.form.resultWebhookSecretId}),t[254]=n.resultWebhookSecretId,t[255]=r.form.resultWebhookSecretId,t[256]=ht,t[257]=gt):gt=t[257];let _t;t[258]!==mt||t[259]!==gt?(_t=(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[mt,gt]}),t[258]=mt,t[259]=gt,t[260]=_t):_t=t[260];let vt;t[261]!==r.form.resultWebhookEndpoint||t[262]!==_t?(vt=(0,X.jsx)($,{label:r.form.resultWebhookEndpoint,children:_t}),t[261]=r.form.resultWebhookEndpoint,t[262]=_t,t[263]=vt):vt=t[263];let yt;t[264]===r.form.reliability?yt=t[265]:(yt=(0,X.jsx)(dn,{title:r.form.reliability}),t[264]=r.form.reliability,t[265]=yt);let bt;t[266]===w?bt=t[267]:(bt=e=>w({timeoutSeconds:e.target.value}),t[266]=w,t[267]=bt);let xt;t[268]!==n.timeoutSeconds||t[269]!==bt?(xt=(0,X.jsx)(`input`,{className:Q,inputMode:`numeric`,value:n.timeoutSeconds,onChange:bt}),t[268]=n.timeoutSeconds,t[269]=bt,t[270]=xt):xt=t[270];let wt;t[271]!==r.form.timeoutSeconds||t[272]!==xt?(wt=(0,X.jsx)($,{label:r.form.timeoutSeconds,children:xt}),t[271]=r.form.timeoutSeconds,t[272]=xt,t[273]=wt):wt=t[273];let Tt;t[274]===w?Tt=t[275]:(Tt=e=>w({disableAfterFailures:e.target.value}),t[274]=w,t[275]=Tt);let Et;t[276]!==n.disableAfterFailures||t[277]!==Tt?(Et=(0,X.jsx)(`input`,{className:Q,inputMode:`numeric`,value:n.disableAfterFailures,onChange:Tt}),t[276]=n.disableAfterFailures,t[277]=Tt,t[278]=Et):Et=t[278];let Dt;t[279]!==r.form.disableAfterFailures||t[280]!==Et?(Dt=(0,X.jsx)($,{label:r.form.disableAfterFailures,children:Et}),t[279]=r.form.disableAfterFailures,t[280]=Et,t[281]=Dt):Dt=t[281];let Ot;t[282]!==wt||t[283]!==Dt?(Ot=(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[wt,Dt]}),t[282]=wt,t[283]=Dt,t[284]=Ot):Ot=t[284];let kt;t[285]===r.form.effectivePolicy?kt=t[286]:(kt=(0,X.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:r.form.effectivePolicy}),t[285]=r.form.effectivePolicy,t[286]=kt);let At=n.timeoutSeconds||`—`,jt;t[287]!==r.form.executionDeadline||t[288]!==At?(jt=(0,X.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[r.form.executionDeadline,`: `,At,`s`]}),t[287]=r.form.executionDeadline,t[288]=At,t[289]=jt):jt=t[289];let Mt;t[290]===r.form.downstreamTimeoutHint?Mt=t[291]:(Mt=(0,X.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-fg-subtle`,children:r.form.downstreamTimeoutHint}),t[290]=r.form.downstreamTimeoutHint,t[291]=Mt);let Nt;t[292]!==kt||t[293]!==jt||t[294]!==Mt?(Nt=(0,X.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-inset/40 px-3 py-2.5`,children:[kt,jt,Mt]}),t[292]=kt,t[293]=jt,t[294]=Mt,t[295]=Nt):Nt=t[295];let Pt;t[296]!==Qe||t[297]!==$e||t[298]!==at||t[299]!==ft||t[300]!==vt||t[301]!==yt||t[302]!==Ot||t[303]!==Nt?(Pt=(0,X.jsxs)(`div`,{className:`grid gap-4 border-t border-edge-subtle p-4`,children:[Qe,$e,at,ft,vt,yt,Ot,Nt]}),t[296]=Qe,t[297]=$e,t[298]=at,t[299]=ft,t[300]=vt,t[301]=yt,t[302]=Ot,t[303]=Nt,t[304]=Pt):Pt=t[304];let Ft;t[305]!==Ze||t[306]!==Pt?(Ft=(0,X.jsxs)(`details`,{className:`group rounded-xl border border-edge-subtle bg-surface-base`,children:[Ze,Pt]}),t[305]=Ze,t[306]=Pt,t[307]=Ft):Ft=t[307];let It;return t[308]!==I||t[309]!==ae||t[310]!==se||t[311]!==me||t[312]!==H||t[313]!==Ee||t[314]!==Oe||t[315]!==q||t[316]!==ke||t[317]!==je||t[318]!==Me||t[319]!==Ie||t[320]!==Le||t[321]!==We||t[322]!==Ge||t[323]!==Ke||t[324]!==Ft?(It=(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,X.jsxs)(`div`,{className:`grid gap-4`,children:[I,ae,se,me,H,Ee,Oe,q,ke,je,Me,Ie,Le,We,Ge,Ke,Ft]})}),t[308]=I,t[309]=ae,t[310]=se,t[311]=me,t[312]=H,t[313]=Ee,t[314]=Oe,t[315]=q,t[316]=ke,t[317]=je,t[318]=Me,t[319]=Ie,t[320]=Le,t[321]=We,t[322]=Ge,t[323]=Ke,t[324]=Ft,t[325]=It):It=t[325],It}function ln(e){return(0,X.jsx)(f,{value:e.id,children:e.name},e.id)}function un(e){return(0,X.jsx)(f,{value:e.id,children:e.name},e.id)}var Q=`min-h-11 w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-base sm:min-h-0 sm:text-sm text-fg outline-none focus:border-accent`;function $(e){let t=(0,Fe.c)(5),{label:n,children:r}=e,i;t[0]===n?i=t[1]:(i=(0,X.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,X.jsxs)(`div`,{className:`grid gap-1.5`,children:[i,r]}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function dn(e){let t=(0,Fe.c)(12),{title:n,step:r,description:i}=e,a;t[0]===r?a=t[1]:(a=r?(0,X.jsx)(`span`,{className:`flex size-6 shrink-0 items-center justify-center rounded-full bg-accent/10 text-xs font-semibold text-accent-fg`,children:r}):(0,X.jsx)(L,{className:`mt-0.5 size-4 text-fg-muted`}),t[0]=r,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,X.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n}),t[2]=n,t[3]=o);let s;t[4]===i?s=t[5]:(s=i?(0,X.jsx)(`p`,{className:`mt-0.5 text-xs leading-5 text-fg-muted`,children:i}):null,t[4]=i,t[5]=s);let c;t[6]!==o||t[7]!==s?(c=(0,X.jsxs)(`div`,{children:[o,s]}),t[6]=o,t[7]=s,t[8]=c):c=t[8];let l;return t[9]!==a||t[10]!==c?(l=(0,X.jsxs)(`div`,{className:`flex items-start gap-2 pt-2`,children:[a,c]}),t[9]=a,t[10]=c,t[11]=l):l=t[11],l}export{Lt as t};
@@ -1,3 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{u as r}from"./chunk-KS7C4IRE-BvcCCgTW.js";import{t as i}from"./popover-select-DGKUpVsz.js";import{t as a}from"./loader-circle-CifKLtgG.js";import{i as o,n as s,o as c}from"./locale-store-B7s2Hb35.js";import{t as l}from"./button-aIC072nz.js";import{t as u}from"./skeleton-BI5TyibZ.js";import{Bd as d,Bl as f,Dd as p,Ed as m,Gl as h,Jc as g,Qc as _,Xl as v,_ as y,al as b,ao as x,dd as S,hl as C,xd as w,y as T}from"./index-Bys6njTY.js";import{i as E,n as D,r as O,t as k}from"./browser-automation-inputs-D6AccXaA.js";var A=e(t(),1),j=n();function M({availability:e,endpointId:t,recordingBusy:n,onSelect:d,onRefresh:p,onStart:m,onClose:h}){let _=s(e=>e.language)===`zh`,v=r(),[b,x]=(0,A.useState)(),[S,C]=(0,A.useState)(!0),[w,E]=(0,A.useState)(!1),[D,O]=(0,A.useState)(``),[k,M]=(0,A.useState)(!1),N=e.endpoints.length>0,P=e.state===`update_required`;(0,A.useEffect)(()=>{let e=!1;if(N){C(!1);return}return c(o(`/api/browser/extension-status`)).then(t=>{e||x(t)}).catch(t=>{e||O(t instanceof Error?t.message:String(t))}).finally(()=>{e||C(!1)}),()=>{e=!0}},[N]);let F=async()=>{E(!0),O(``);try{(P||!b?.artifacts?.installed||b.artifacts.needsRefresh)&&await y(P||!!b?.artifacts?.needsRefresh),await T(b?.artifacts?.installed?`chrome`:`both`),M(!0),await p()}catch(e){O(e instanceof Error?e.message:String(e))}finally{E(!1)}};return(0,j.jsxs)(`section`,{role:`status`,"aria-live":`polite`,className:`mb-4 shrink-0 rounded-xl border border-edge bg-surface-base p-4`,children:[(0,j.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,j.jsx)(f,{className:`mt-0.5 size-5 shrink-0 text-accent`}),(0,j.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,j.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:N?_?`浏览器已连接`:`Browser connected`:P?_?`更新扩展后即可录制`:`Update the extension to record`:_?`连接 Chrome,录制你的操作`:`Connect Chrome to record your actions`}),(0,j.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:N?_?`在 Chrome 中切换到要录制的网页,然后开始录制。`:`Switch to the website you want to record in Chrome, then start recording.`:P?_?`当前扩展还不支持录制。更新扩展文件后,在 Chrome 扩展页重新加载 xopc。`:`Your connected extension does not support recording yet. Update its files, then reload xopc in Chrome Extensions.`:_?`录制需要 xopc Chrome 扩展。已有扩展请打开 xopc 侧栏,它会自动连接本机服务。`:`Recording uses the xopc Chrome extension. If already installed, open its side panel to connect to your local Gateway.`})]}),(0,j.jsx)(`button`,{type:`button`,disabled:w||n,onClick:h,"aria-label":_?`收起连接引导`:`Close connection guide`,className:`rounded p-1 text-fg-muted hover:bg-surface-hover`,children:(0,j.jsx)(g,{className:`size-4`})})]}),k&&!N&&(0,j.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:b?.artifacts?.installed?_?`重新加载后打开 xopc 侧栏。连接状态会自动更新。`:`After reloading, open the xopc side panel. Connection status updates automatically.`:_?`在 Chrome 扩展页开启开发者模式,点击“加载已解压的扩展程序”,选择已打开的扩展目录,再打开 xopc 侧栏。连接状态会自动更新。`:`Enable Developer mode in Chrome Extensions, choose Load unpacked and select the opened extension folder, then open the xopc side panel. Connection status updates automatically.`}),N&&e.endpoints.length>1&&(0,j.jsx)(`div`,{className:`mt-3 max-w-sm`,children:(0,j.jsx)(i,{value:t??``,ariaLabel:_?`选择录制浏览器`:`Choose a browser to record`,placeholder:_?`选择浏览器`:`Choose a browser`,allowEmpty:!1,options:e.endpoints.map(e=>({value:e.endpointId,label:e.displayName})),onChange:d})}),(0,j.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[N?(0,j.jsx)(l,{onClick:m,disabled:n||!t&&e.endpoints.length>1,children:_?`开始录制`:`Start recording`}):S?(0,j.jsx)(u,{className:`h-9 w-32 rounded-lg`}):b?.artifacts?.extensionDir?(0,j.jsxs)(l,{onClick:()=>void F(),disabled:w,children:[w&&(0,j.jsx)(a,{className:`size-4 animate-spin`}),P?_?`更新并打开扩展页`:`Update and open extensions`:b.artifacts.installed?_?`打开 Chrome 扩展页`:`Open Chrome Extensions`:_?`安装 Chrome 扩展`:`Install Chrome extension`]}):(0,j.jsx)(l,{onClick:()=>v(`/settings/agent-browser`),children:_?`设置浏览器连接`:`Set up browser connection`}),!N&&(0,j.jsx)(l,{variant:`secondary`,disabled:w,onClick:()=>void p().catch(e=>O(e instanceof Error?e.message:String(e))),children:_?`检查连接`:`Check connection`})]}),D&&(0,j.jsx)(`p`,{className:`mt-2 text-sm text-danger`,role:`alert`,children:D})]})}var N={en:{record:`Record my actions`,finishRecording:`Finish and save`,recording:`Recording`,syncing:`Saved locally, syncing…`,verified:`Result verified`,saved:`Saved draft`,unknown:`Check the business result before repeating`,title:`Browser automations`,subtitle:`Let your assistant repeat routine actions on the web.`,emptyTitle:`No browser automations yet`,emptyBody:`Tell your assistant what to do on the web. Once it works, save it and run it again whenever you need.`,create:`Create with assistant`,edit:`Edit with assistant`,run:`Run now`,stop:`Stop`,enable:`Enable`,pause:`Pause`,enabled:`Enabled`,paused:`Paused`,inputs:`Before running`,noInputs:`This automation is ready to run.`,history:`Recent activity`,delete:`Delete automation`,confirmDelete:`Delete this browser automation?`,required:`Please complete all required fields.`,queued:`Waiting to start`,running:`Running`,succeeded:`Completed`,failed:`Needs attention`,cancelled:`Stopped`,result:`Result`,read:`Reads information`,draft:`Edits the page locally`,external_effect:`Affects an external system`,destructive:`Destructive action`,sensitive:`Sensitive action`,createPrompt:`Help me create a reusable browser automation. Ask what I want the browser to do, perform it once with me, then save the successful steps. Keep all technical details hidden.`,editPrompt:`Help me update the browser automation "{name}" (id: {id}). Ask what should change, test the new browser steps, then save it.`},zh:{record:`录制我的操作`,finishRecording:`完成并保存`,recording:`正在录制`,syncing:`已保存到本机,正在同步…`,verified:`结果已验证`,saved:`已保存草稿`,unknown:`结果待检查,请先检查业务结果再重复运行`,title:`浏览器自动化`,subtitle:`让助手自动重复完成网页上的固定操作。`,emptyTitle:`还没有浏览器自动化`,emptyBody:`告诉助手你希望在网页上自动完成什么。成功执行一次后,即可保存并重复运行。`,create:`让助手帮我创建`,edit:`让助手帮我修改`,run:`立即运行`,stop:`停止`,enable:`启用`,pause:`暂停`,enabled:`已启用`,paused:`已暂停`,inputs:`运行前需要填写`,noInputs:`这个自动化可以直接运行。`,history:`最近运行`,delete:`删除自动化`,confirmDelete:`确定删除这个浏览器自动化吗?`,required:`请填写所有必填内容。`,queued:`等待开始`,running:`正在运行`,succeeded:`已完成`,failed:`需要处理`,cancelled:`已停止`,result:`运行结果`,read:`仅读取信息`,draft:`仅在页面内编辑`,external_effect:`会影响外部系统`,destructive:`破坏性操作`,sensitive:`包含敏感操作`,createPrompt:`请帮我创建一个可重复运行的浏览器自动化。先询问我希望浏览器完成什么,陪我实际执行成功一次,然后保存成功步骤。不要让我处理技术细节。`,editPrompt:`请帮我修改浏览器自动化“{name}”(id:{id})。先询问我要修改什么,实际测试新的浏览器步骤,然后保存。`}};function P(e){return e!==`queued`&&e!==`running`}function F(e){return e==null?`-`:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?e.map(e=>`• ${F(e)}`).join(`
2
- `):typeof e==`object`?Object.entries(e).map(([e,t])=>`${e}: ${F(t)}`).join(`
3
- `):String(e)}function I(){let e=s(e=>e.language),t=N[e],n=r(),i=x(e=>e.setPageHeader),a=x(e=>e.clearPageHeader),[o,c]=(0,A.useState)(null),[f,g]=(0,A.useState)(),[y,T]=(0,A.useState)({}),[I,L]=(0,A.useState)([]),[R,z]=(0,A.useState)(),[B,V]=(0,A.useState)(``),[H,U]=(0,A.useState)(!1),[W,ee]=(0,A.useState)(),[G,K]=(0,A.useState)(),[q,J]=(0,A.useState)(),Y=(0,A.useMemo)(()=>o?.find(e=>e.id===f),[f,o]),X=(0,A.useCallback)(async()=>{let e=await E.list();c(e.automations),g(t=>t&&e.automations.some(e=>e.id===t)?t:e.automations[0]?.id)},[]);(0,A.useEffect)(()=>{X().catch(e=>V(String(e)))},[X]),(0,A.useEffect)(()=>{Y&&(T(O(Y)),z(void 0),V(``),E.listRuns(Y.id).then(e=>L(e.runs)).catch(e=>V(String(e))))},[Y?.id,Y?.revision]),(0,A.useEffect)(()=>{if(!R||P(R.status))return;let e=window.setInterval(()=>{E.getRun(R.id).then(({run:e})=>{z(e),P(e.status)&&Y&&(E.listRuns(Y.id).then(e=>L(e.runs)),X())}).catch(e=>V(String(e)))},700);return()=>window.clearInterval(e)},[R,Y]);let Z=(0,A.useCallback)(async()=>{U(!0),V(``);try{let e=W&&[`recording`,`paused`].includes(W.state),t=G;if(!e){let e=await E.recordingAvailability();if(e.endpoints.length===1?t=e.endpoints[0].endpointId:e.endpoints.some(e=>e.endpointId===t)||(t=void 0),K(t),!t){J(e);return}}let n=await E.recording(e?`finish`:`start`,t);ee(n.value),K(n.endpointId),J(void 0)}catch(e){let t=e.body;t?.code&&[`connect_required`,`update_required`,`choose_browser`].includes(t.code)?J({state:t.code,endpoints:t.endpoints??[]}):V(e instanceof Error?e.message:String(e))}finally{U(!1)}},[W,G]),te=(0,A.useCallback)(async()=>{let e=await E.recordingAvailability();J(e),K(t=>e.endpoints.length===1?e.endpoints[0].endpointId:e.endpoints.some(e=>e.endpointId===t)?t:void 0)},[]);(0,A.useEffect)(()=>{if(!q)return;let e=!1,t=window.setInterval(()=>{E.recordingAvailability().then(t=>{e||(J(t),K(e=>t.endpoints.length===1?t.endpoints[0].endpointId:t.endpoints.some(t=>t.endpointId===e)?e:void 0))}).catch(()=>void 0)},3e3);return()=>{e=!0,window.clearInterval(t)}},[!!q]),(0,A.useEffect)(()=>{if(!W||W.automationId)return;let e=!1,t=window.setInterval(()=>{E.recording(`status`,G).then(async t=>{let n=t.value.find(e=>e.id===W.id);!e&&n&&(ee(n),n.automationId&&(await X(),e||g(n.automationId)))}).catch(t=>{e||V(String(t))})},1500);return()=>{e=!0,window.clearInterval(t)}},[W,G,X]);let Q=(0,A.useCallback)(e=>{n(`/chat/new?draft=${encodeURIComponent(e)}`)},[n]),ne=(0,A.useMemo)(()=>(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[B&&(0,j.jsx)(`span`,{role:`alert`,className:`max-w-64 truncate text-xs text-red-600`,title:B,children:B}),W?.state===`stopped`&&!W.automationId&&(0,j.jsx)(`span`,{role:`status`,className:`text-xs text-fg-muted`,children:W.error||t.syncing}),(0,j.jsxs)(l,{variant:`secondary`,disabled:H,onClick:()=>void Z(),children:[(0,j.jsx)(_,{className:`size-4`}),W&&[`recording`,`paused`].includes(W.state)?t.finishRecording:t.record]}),(0,j.jsxs)(l,{onClick:()=>Q(t.createPrompt),children:[(0,j.jsx)(d,{className:`size-4`}),t.create]})]}),[Q,t,H,Z,W,B]);(0,A.useLayoutEffect)(()=>(i({startExtra:null,main:(0,j.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),end:ne}),()=>a()),[a,ne,i,t.title]);let re=async()=>{if(Y){U(!0);try{await E.setEnabled(Y.id,!Y.enabled),await X()}catch(e){V(String(e))}finally{U(!1)}}},ie=async()=>{if(Y){if(!D(Y,y)){V(t.required);return}U(!0);try{let{run:e}=await E.run(Y.id,y);z(e),V(``)}catch(e){V(String(e))}finally{U(!1)}}},ae=async()=>{if(!(!Y||!window.confirm(t.confirmDelete))){U(!0);try{await E.remove(Y.id),g(void 0),L([]),await X()}catch(e){V(String(e))}finally{U(!1)}}},$=q&&(0,j.jsx)(M,{availability:q,endpointId:G,recordingBusy:H,onSelect:K,onRefresh:te,onStart:()=>void Z(),onClose:()=>J(void 0)});return o===null?(0,j.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel px-4 pb-4 pt-3 sm:px-6 sm:pb-6 lg:pt-4`,children:[$,(0,j.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[280px_minmax(0,1fr)]`,children:[(0,j.jsx)(u,{className:`h-[420px] rounded-xl`}),(0,j.jsx)(u,{className:`h-[420px] rounded-xl`})]})]}):o.length===0?(0,j.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel px-4 pb-4 pt-3 sm:px-6 sm:pb-6 lg:pt-4`,children:[$,(0,j.jsxs)(`div`,{className:`m-auto max-w-md py-12 text-center`,children:[(0,j.jsx)(d,{className:`mx-auto size-10 text-accent`}),(0,j.jsx)(`h2`,{className:`mt-4 text-lg font-semibold text-fg`,children:t.emptyTitle}),(0,j.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:t.emptyBody}),(0,j.jsxs)(l,{className:`mt-5`,onClick:()=>Q(t.createPrompt),children:[(0,j.jsx)(d,{className:`size-4`}),t.create]})]})]}):(0,j.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel px-4 pb-4 pt-3 sm:px-6 sm:pb-6 lg:pt-4`,children:[$,(0,j.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-4 lg:grid-cols-[280px_minmax(0,1fr)]`,children:[(0,j.jsx)(`aside`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge bg-surface-base p-2`,children:o.map(e=>(0,j.jsxs)(`button`,{onClick:()=>g(e.id),className:`mb-1 w-full rounded-lg p-3 text-left ${f===e.id?`bg-accent-soft text-accent-fg`:`hover:bg-surface-hover`}`,children:[(0,j.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.name}),(0,j.jsxs)(`span`,{className:`mt-1 flex items-center gap-1.5 text-xs text-fg-muted`,children:[e.enabled?(0,j.jsx)(m,{className:`size-3.5 text-emerald-600`}):(0,j.jsx)(p,{className:`size-3.5`}),e.enabled?t.enabled:t.paused]})]},e.id))}),Y&&(0,j.jsxs)(`main`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge bg-surface-base p-5 sm:p-6`,children:[(0,j.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:Y.name}),Y.description&&(0,j.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:Y.description}),(0,j.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs`,children:[(0,j.jsx)(`span`,{className:`rounded-full bg-surface-inset px-2.5 py-1 text-fg-muted`,children:t[Y.risk]}),(0,j.jsx)(`span`,{className:`rounded-full bg-surface-inset px-2.5 py-1 text-fg-muted`,children:Y.verified?t.verified:t.saved}),Y.domains.map(e=>(0,j.jsxs)(`span`,{className:`flex items-center gap-1 rounded-full bg-surface-inset px-2.5 py-1 text-fg-muted`,children:[(0,j.jsx)(S,{className:`size-3`}),e]},e))]})]}),(0,j.jsxs)(`div`,{className:`flex gap-2`,children:[(0,j.jsxs)(l,{variant:`secondary`,disabled:H,onClick:()=>void re(),children:[Y.enabled?(0,j.jsx)(p,{className:`size-4`}):(0,j.jsx)(m,{className:`size-4`}),Y.enabled?t.pause:t.enable]}),(0,j.jsxs)(l,{variant:`secondary`,onClick:()=>Q(t.editPrompt.replace(`{name}`,Y.name).replace(`{id}`,Y.id)),children:[(0,j.jsx)(v,{className:`size-4`}),t.edit]})]})]}),(0,j.jsxs)(`section`,{className:`mt-7 max-w-xl`,children:[(0,j.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.inputs}),Object.keys(Y.inputs).length===0?(0,j.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:t.noInputs}):(0,j.jsx)(`div`,{className:`mt-3`,children:(0,j.jsx)(k,{automation:Y,values:y,language:e,onChange:T})}),(0,j.jsxs)(`div`,{className:`mt-5 flex gap-2`,children:[(0,j.jsxs)(l,{variant:`primary`,disabled:!Y.enabled||H||!!(R&&!P(R.status)),onClick:()=>void ie(),children:[(0,j.jsx)(h,{className:`size-4`}),t.run]}),R&&!P(R.status)&&(0,j.jsxs)(l,{variant:`secondary`,onClick:()=>void E.cancel(R.id),children:[(0,j.jsx)(C,{className:`size-4`}),t.stop]})]}),B&&(0,j.jsx)(`p`,{className:`mt-3 text-sm text-red-700 dark:text-red-300`,children:B})]}),R&&(0,j.jsxs)(`section`,{className:`mt-7 rounded-xl border border-edge bg-surface-inset p-4`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,j.jsx)(w,{className:`size-4`}),R.businessOutcome===`verified`?t.verified:t[R.status]]}),R.businessOutcome===`unknown`&&(0,j.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:t.unknown}),R.error&&(0,j.jsx)(`p`,{className:`mt-2 text-sm text-red-700 dark:text-red-300`,children:R.error}),R.status===`succeeded`&&R.result!==void 0&&(0,j.jsxs)(`div`,{className:`mt-3`,children:[(0,j.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:t.result}),(0,j.jsx)(`pre`,{className:`mt-2 max-h-64 overflow-auto whitespace-pre-wrap text-sm text-fg`,children:F(R.result)})]})]}),(0,j.jsxs)(`section`,{className:`mt-8`,children:[(0,j.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.history}),(0,j.jsx)(`div`,{className:`mt-2 divide-y divide-edge`,children:I.slice(0,10).map(e=>(0,j.jsxs)(`button`,{className:`flex w-full items-center justify-between gap-3 py-3 text-left text-sm hover:text-accent`,onClick:()=>z(e),children:[(0,j.jsx)(`span`,{children:t[e.status]}),(0,j.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[new Date(e.createdAtMs).toLocaleString(),e.durationMs?` · ${Math.max(1,Math.round(e.durationMs/1e3))}s`:``]})]},e.id))})]}),(0,j.jsx)(`div`,{className:`mt-8 border-t border-edge pt-4`,children:(0,j.jsxs)(l,{variant:`ghost`,className:`text-red-700 dark:text-red-300`,disabled:H,onClick:()=>void ae(),children:[(0,j.jsx)(b,{className:`size-4`}),t.delete]})})]})]})]})}export{I as BrowserAutomationsPage};