@xopcai/xopc 0.0.93 → 0.0.94

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 (356) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/feishu/src/outbound/media-load.js +1 -1
  3. package/dist/extensions/feishu/src/workflow-progress.js +1 -1
  4. package/dist/extensions/telegram/src/plugin.js +1 -1
  5. package/dist/extensions/telegram/src/routing-integration.js +2 -2
  6. package/dist/extensions/telegram/src/workflow-progress.js +1 -1
  7. package/dist/extensions/telegram/xopc.extension.json +1 -1
  8. package/dist/extensions/weixin/src/api/api.js +2 -2
  9. package/dist/extensions/weixin/src/auth/accounts.js +1 -1
  10. package/dist/extensions/weixin/src/cdn/upload.js +1 -1
  11. package/dist/extensions/weixin/src/media/data-url.js +1 -1
  12. package/dist/extensions/weixin/src/messaging/debug-mode.js +1 -1
  13. package/dist/extensions/weixin/src/messaging/inbound.js +1 -1
  14. package/dist/extensions/weixin/src/messaging/process-message.js +1 -1
  15. package/dist/extensions/weixin/src/plugin.js +1 -1
  16. package/dist/extensions/weixin/src/storage/sync-buf.js +1 -1
  17. package/dist/extensions/weixin/src/workflow-progress.js +1 -1
  18. package/dist/gateway/static/root/assets/agents-OqhbJkMf.js +222 -0
  19. package/dist/gateway/static/root/assets/apps-page-OHXW9XP8.js +1 -0
  20. package/dist/gateway/static/root/assets/channels-settings-4N2R-jof.js +1 -0
  21. package/dist/gateway/static/root/assets/{channels-status-swr-CsGkK9h9.js → channels-status-swr-Bv6f9kDq.js} +1 -1
  22. package/dist/gateway/static/root/assets/{cron-api-CyAm0xJT.js → cron-api-BtaQaHJq.js} +1 -1
  23. package/dist/gateway/static/root/assets/cron-page-Dah32HJK.js +1 -0
  24. package/dist/gateway/static/root/assets/{dist-DHwVV8XK.js → dist-BJfD9Qvs.js} +1 -1
  25. package/dist/gateway/static/root/assets/{extension-debug-page-BK8kcc4F.js → extension-debug-page-DnYuMzmH.js} +1 -1
  26. package/dist/gateway/static/root/assets/{extension-page-Cf8X_QUc.js → extension-page-CJfc-6XV.js} +1 -1
  27. package/dist/gateway/static/root/assets/{extension-settings-page-C5-YLMmy.js → extension-settings-page-BxdfYQMG.js} +1 -1
  28. package/dist/gateway/static/root/assets/{fetch-BAPnkYbC.js → fetch-B0aeeY0q.js} +1 -1
  29. package/dist/gateway/static/root/assets/{field-primitives-8p7ucXa1.js → field-primitives-DOLHwowi.js} +1 -1
  30. package/dist/gateway/static/root/assets/{heartbeat-config-api-CpgW2sGp.js → heartbeat-config-api-Bj2INAf5.js} +1 -1
  31. package/dist/gateway/static/root/assets/index-Bj_l8QDp.css +1 -0
  32. package/dist/gateway/static/root/assets/{index-Do52EfZK.js → index-DuQ1XPoA.js} +99 -98
  33. package/dist/gateway/static/root/assets/logs-page-AsOgLNJE.js +2 -0
  34. package/dist/gateway/static/root/assets/{note-detail-page-WLM6FUIi.js → note-detail-page-24J4mVP-.js} +3 -3
  35. package/dist/gateway/static/root/assets/{note-time-EFyIVhec.js → note-time-JBszYV3s.js} +1 -1
  36. package/dist/gateway/static/root/assets/{notes-page-BYPVYcYn.js → notes-page-BApAirFB.js} +1 -1
  37. package/dist/gateway/static/root/assets/sessions-page-DX9huWsA.js +1 -0
  38. package/dist/gateway/static/root/assets/{settings-advanced-gate-CEs8pGh6.js → settings-advanced-gate-DWvhsTuz.js} +1 -1
  39. package/dist/gateway/static/root/assets/{settings-form-section-C6cGTVwK.js → settings-form-section-CxMjaMiy.js} +1 -1
  40. package/dist/gateway/static/root/assets/settings-page-4VmUTzQs.js +3 -0
  41. package/dist/gateway/static/root/assets/{share-preview-page-tnIfJ4K6.js → share-preview-page-IX0TJvRd.js} +1 -1
  42. package/dist/gateway/static/root/assets/skills-page-CGKGKfwe.js +2 -0
  43. package/dist/gateway/static/root/assets/{theme-store-D6EsNTPr.js → theme-store-Cg_SuBw0.js} +1 -1
  44. package/dist/gateway/static/root/assets/{url-CTjpm0Uz.js → url-BHHmdJYc.js} +2 -2
  45. package/dist/gateway/static/root/assets/{utils-C86AVfY-.js → utils-BmlcxR2j.js} +1 -1
  46. package/dist/gateway/static/root/assets/voice-api-key-field-DaGm2N4J.js +1 -0
  47. package/dist/gateway/static/root/assets/{workflow-page.utils-DsEriMFW.js → workflow-page.utils-D0vsIGHD.js} +1 -1
  48. package/dist/gateway/static/root/assets/workflows-page-BFCrD3nw.js +27 -0
  49. package/dist/gateway/static/root/index.html +5 -5
  50. package/dist/package.js +1 -1
  51. package/dist/src/agent/agent-manager.js +7 -7
  52. package/dist/src/agent/agent-scope.js +1 -1
  53. package/dist/src/agent/bootstrap/load-bootstrap-files.js +1 -1
  54. package/dist/src/agent/context/workspace-seed.js +2 -2
  55. package/dist/src/agent/goals/goal-run-store.js +4 -4
  56. package/dist/src/agent/goals/persistent-goal-service.js +1 -1
  57. package/dist/src/agent/goals/post-turn.js +2 -2
  58. package/dist/src/agent/image/load-image-media.js +2 -2
  59. package/dist/src/agent/inbound/turn-dispatcher.d.ts +1 -0
  60. package/dist/src/agent/inbound/turn-dispatcher.js +3 -0
  61. package/dist/src/agent/inbound/turn-dispatcher.js.map +1 -1
  62. package/dist/src/agent/ipc/bus.js +1 -1
  63. package/dist/src/agent/ipc/inbox.js +2 -2
  64. package/dist/src/agent/ipc/socket.js +1 -1
  65. package/dist/src/agent/lifecycle/handlers/compaction.js +1 -1
  66. package/dist/src/agent/lifecycle/handlers/compaction.js.map +1 -1
  67. package/dist/src/agent/mcp/bundle-mcp-materialize.js +2 -2
  68. package/dist/src/agent/mcp/bundle-mcp-materialize.js.map +1 -1
  69. package/dist/src/agent/mcp/bundle-mcp-runtime.js +18 -5
  70. package/dist/src/agent/mcp/bundle-mcp-runtime.js.map +1 -1
  71. package/dist/src/agent/mcp/mcp-transport-config.js +11 -4
  72. package/dist/src/agent/mcp/mcp-transport-config.js.map +1 -1
  73. package/dist/src/agent/mcp/mcp-transport.js +2 -2
  74. package/dist/src/agent/mcp/mcp-transport.js.map +1 -1
  75. package/dist/src/agent/memory/builtin-memory-store.js +1 -1
  76. package/dist/src/agent/memory/dreaming/deep-promotion.js +1 -1
  77. package/dist/src/agent/memory/dreaming/events.js +1 -1
  78. package/dist/src/agent/memory/dreaming/last-run.js +1 -1
  79. package/dist/src/agent/memory/dreaming/light-sweep.js +1 -1
  80. package/dist/src/agent/memory/dreaming/preview.js +1 -1
  81. package/dist/src/agent/memory/dreaming/rem-patterns.js +1 -1
  82. package/dist/src/agent/memory/dreaming/short-term-store.js +1 -1
  83. package/dist/src/agent/memory/dreaming/utils.js +1 -1
  84. package/dist/src/agent/memory/plugin-discovery.js +1 -1
  85. package/dist/src/agent/models/manager.js +1 -1
  86. package/dist/src/agent/prompt/service-prompt-builder.js +2 -2
  87. package/dist/src/agent/reply/post-compaction-context.js +1 -1
  88. package/dist/src/agent/reply/workspace-boundary-read.js +1 -1
  89. package/dist/src/agent/sandbox/path-policy.js +2 -2
  90. package/dist/src/agent/service/build-direct-message-content.js +1 -1
  91. package/dist/src/agent/service/process-direct-streaming.d.ts +1 -0
  92. package/dist/src/agent/service/process-direct-streaming.js +15 -12
  93. package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
  94. package/dist/src/agent/service.d.ts +4 -2
  95. package/dist/src/agent/service.js +24 -8
  96. package/dist/src/agent/service.js.map +1 -1
  97. package/dist/src/agent/service.types.d.ts +3 -1
  98. package/dist/src/agent/session/session-inspector.js +1 -1
  99. package/dist/src/agent/skills/config.js +1 -1
  100. package/dist/src/agent/skills/hub-hash.js +2 -2
  101. package/dist/src/agent/skills/hub-lock.js +1 -1
  102. package/dist/src/agent/skills/hub-pull.js +2 -2
  103. package/dist/src/agent/skills/index.js +1 -1
  104. package/dist/src/agent/skills/managed-store.js +1 -1
  105. package/dist/src/agent/skills/scanner.js +1 -1
  106. package/dist/src/agent/skills/skill-manage-ops.js +1 -1
  107. package/dist/src/agent/skills/skill-manager.js +1 -1
  108. package/dist/src/agent/tools/browser/tool/browser-use-tool.js +1 -1
  109. package/dist/src/agent/tools/browser/tool/browser-use-tool.js.map +1 -1
  110. package/dist/src/agent/tools/dreaming-tool.js +1 -1
  111. package/dist/src/agent/tools/factory.js +1 -1
  112. package/dist/src/agent/tools/image-generate-tool.js +1 -1
  113. package/dist/src/agent/tools/search/registry.js +1 -1
  114. package/dist/src/agent/tools/search/registry.js.map +1 -1
  115. package/dist/src/agent/tools/send-media.js +1 -1
  116. package/dist/src/agent/tools/session-search-tool.js +1 -1
  117. package/dist/src/agent/tools/session-search-tool.js.map +1 -1
  118. package/dist/src/agent/tools/skill-manage-tool.js +1 -1
  119. package/dist/src/agent/tools/workflow-tool.js +2 -2
  120. package/dist/src/agent/tools/workflow-tool.js.map +1 -1
  121. package/dist/src/agent/tools/write.js +1 -1
  122. package/dist/src/agent/workflow/catalog.js +1 -1
  123. package/dist/src/agent/workflow/progress-broker.js +1 -1
  124. package/dist/src/agent/workflow/progress-broker.js.map +1 -1
  125. package/dist/src/agent/workflow/subagent-runner.js +1 -1
  126. package/dist/src/agent/workflow/subagent-runner.js.map +1 -1
  127. package/dist/src/auth/credentials.js +3 -3
  128. package/dist/src/auth/profiles/store.js +1 -1
  129. package/dist/src/auth/sync-provider-auth.js +1 -1
  130. package/dist/src/browser/cache-dir-policy.js +1 -1
  131. package/dist/src/browser/cdp-local-launcher.js +2 -2
  132. package/dist/src/browser/providers/browser-ext-install.js +3 -3
  133. package/dist/src/browser/providers/cloakbrowser.js +4 -4
  134. package/dist/src/browser/providers/playwright-doctor.js +1 -1
  135. package/dist/src/browser/stealth.js +1 -1
  136. package/dist/src/channels/attachments/inbound-persist.js +1 -1
  137. package/dist/src/channels/attachments/outbound-tts-persist.js +1 -1
  138. package/dist/src/channels/outbound/persist-store.js +1 -1
  139. package/dist/src/channels/pairing/allow-from-file.js +1 -1
  140. package/dist/src/channels/pairing/pairing-store.js +2 -2
  141. package/dist/src/channels/pipeline.js +3 -2
  142. package/dist/src/channels/pipeline.js.map +1 -1
  143. package/dist/src/chat-commands/agent-edit.js +2 -2
  144. package/dist/src/chat-commands/builtins/config.js +2 -2
  145. package/dist/src/chat-commands/context.js +1 -1
  146. package/dist/src/cli/cli-log-level-preset.d.ts +1 -1
  147. package/dist/src/cli/cli-log-level-preset.js +2 -2
  148. package/dist/src/cli/cli-log-level-preset.js.map +1 -1
  149. package/dist/src/cli/commands/config.js +1 -1
  150. package/dist/src/cli/commands/doctor/checks/config-health.js +1 -1
  151. package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
  152. package/dist/src/cli/commands/doctor/checks/session-integrity.js +2 -2
  153. package/dist/src/cli/commands/doctor/checks/state-integrity.js +1 -1
  154. package/dist/src/cli/commands/doctor/checks/workspace-status.js +1 -1
  155. package/dist/src/cli/commands/extension-dev.js +1 -1
  156. package/dist/src/cli/commands/extension-marketplace.js +1 -1
  157. package/dist/src/cli/commands/extension-pack.js +1 -1
  158. package/dist/src/cli/commands/gateway/logs.js +1 -1
  159. package/dist/src/cli/commands/image.js +1 -1
  160. package/dist/src/cli/commands/init.js +4 -4
  161. package/dist/src/cli/commands/logs.js +3 -3
  162. package/dist/src/cli/commands/logs.js.map +1 -1
  163. package/dist/src/cli/commands/onboard.js +1 -1
  164. package/dist/src/cli/utils/init-workspace-core.js +2 -2
  165. package/dist/src/commands/agents.config.js +1 -1
  166. package/dist/src/config/agent-profile.js +1 -1
  167. package/dist/src/config/gateway-bind.js +1 -1
  168. package/dist/src/config/index.js +5 -5
  169. package/dist/src/config/loader.js +2 -2
  170. package/dist/src/config/models-json.js +2 -2
  171. package/dist/src/config/paths-state.js +1 -1
  172. package/dist/src/config/profile.js +2 -2
  173. package/dist/src/config/workspace-path.js +1 -1
  174. package/dist/src/cron/executor.js +9 -6
  175. package/dist/src/cron/executor.js.map +1 -1
  176. package/dist/src/cron/persistence.js +1 -1
  177. package/dist/src/cron/run-log-store.js +1 -1
  178. package/dist/src/daemon/constants.js +1 -1
  179. package/dist/src/daemon/install-plan.js +2 -2
  180. package/dist/src/daemon/launchd.js +2 -2
  181. package/dist/src/daemon/schtasks.js +2 -2
  182. package/dist/src/daemon/systemd.js +2 -2
  183. package/dist/src/extensions/bundle-mcp.js +1 -1
  184. package/dist/src/extensions/discover-extensions.js +1 -1
  185. package/dist/src/extensions/health.js +1 -1
  186. package/dist/src/extensions/loader.js +1 -1
  187. package/dist/src/extensions/lockfile.js +2 -2
  188. package/dist/src/extensions/update.js +1 -1
  189. package/dist/src/gateway/agents-admin.js +3 -3
  190. package/dist/src/gateway/file-path-classifier.js +2 -2
  191. package/dist/src/gateway/heartbeat/service.js +1 -1
  192. package/dist/src/gateway/hono/app.js +4 -1
  193. package/dist/src/gateway/hono/app.js.map +1 -1
  194. package/dist/src/gateway/hono/lib/config-payload.js +1 -1
  195. package/dist/src/gateway/hono/lib/extension-store.js +2 -2
  196. package/dist/src/gateway/hono/lib/route-logger.d.ts +6 -0
  197. package/dist/src/gateway/hono/lib/route-logger.js +31 -0
  198. package/dist/src/gateway/hono/lib/route-logger.js.map +1 -0
  199. package/dist/src/gateway/hono/lib/static-ui.js +2 -2
  200. package/dist/src/gateway/hono/middleware/auth.js +16 -3
  201. package/dist/src/gateway/hono/middleware/auth.js.map +1 -1
  202. package/dist/src/gateway/hono/middleware/logger.js +1 -1
  203. package/dist/src/gateway/hono/middleware/logger.js.map +1 -1
  204. package/dist/src/gateway/hono/middleware/route-errors.d.ts +5 -0
  205. package/dist/src/gateway/hono/middleware/route-errors.js +27 -0
  206. package/dist/src/gateway/hono/middleware/route-errors.js.map +1 -0
  207. package/dist/src/gateway/hono/oauth.js +1 -1
  208. package/dist/src/gateway/hono/routes/agent-stream.js +6 -0
  209. package/dist/src/gateway/hono/routes/agent-stream.js.map +1 -1
  210. package/dist/src/gateway/hono/routes/agents.js +1 -1
  211. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
  212. package/dist/src/gateway/hono/routes/browser-install.js +2 -4
  213. package/dist/src/gateway/hono/routes/browser-install.js.map +1 -1
  214. package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
  215. package/dist/src/gateway/hono/routes/config.js +25 -11
  216. package/dist/src/gateway/hono/routes/config.js.map +1 -1
  217. package/dist/src/gateway/hono/routes/cron.js +5 -0
  218. package/dist/src/gateway/hono/routes/cron.js.map +1 -1
  219. package/dist/src/gateway/hono/routes/dreaming.js +1 -1
  220. package/dist/src/gateway/hono/routes/host-fs.js +4 -6
  221. package/dist/src/gateway/hono/routes/host-fs.js.map +1 -1
  222. package/dist/src/gateway/hono/routes/lazy-bundles.js +14 -1
  223. package/dist/src/gateway/hono/routes/lazy-bundles.js.map +1 -1
  224. package/dist/src/gateway/hono/routes/lazy-fallback.js +3 -0
  225. package/dist/src/gateway/hono/routes/lazy-fallback.js.map +1 -1
  226. package/dist/src/gateway/hono/routes/logs.js +39 -7
  227. package/dist/src/gateway/hono/routes/logs.js.map +1 -1
  228. package/dist/src/gateway/hono/routes/mcp.d.ts +3 -0
  229. package/dist/src/gateway/hono/routes/mcp.js +107 -0
  230. package/dist/src/gateway/hono/routes/mcp.js.map +1 -0
  231. package/dist/src/gateway/hono/routes/models.js +1 -1
  232. package/dist/src/gateway/hono/routes/sessions.js +6 -0
  233. package/dist/src/gateway/hono/routes/sessions.js.map +1 -1
  234. package/dist/src/gateway/hono/routes/shares.js +1 -1
  235. package/dist/src/gateway/hono/routes/update.js +2 -4
  236. package/dist/src/gateway/hono/routes/update.js.map +1 -1
  237. package/dist/src/gateway/hono/routes/voice.js +2 -4
  238. package/dist/src/gateway/hono/routes/voice.js.map +1 -1
  239. package/dist/src/gateway/hono/routes/workspace.js +4 -6
  240. package/dist/src/gateway/hono/routes/workspace.js.map +1 -1
  241. package/dist/src/gateway/hono/sse.js +9 -2
  242. package/dist/src/gateway/hono/sse.js.map +1 -1
  243. package/dist/src/gateway/lock.js +3 -3
  244. package/dist/src/gateway/ports.js +1 -1
  245. package/dist/src/gateway/service/agent-runner.js +3 -3
  246. package/dist/src/gateway/service/agent-runner.js.map +1 -1
  247. package/dist/src/gateway/service/config-coordinator.js +14 -6
  248. package/dist/src/gateway/service/config-coordinator.js.map +1 -1
  249. package/dist/src/gateway/service/marketplace-service.js +3 -3
  250. package/dist/src/gateway/service/marketplace-service.js.map +1 -1
  251. package/dist/src/gateway/service/run-gateway-agent.js +22 -5
  252. package/dist/src/gateway/service/run-gateway-agent.js.map +1 -1
  253. package/dist/src/gateway/service/sse-hub.js +1 -1
  254. package/dist/src/gateway/service/sse-hub.js.map +1 -1
  255. package/dist/src/gateway/service.js +13 -6
  256. package/dist/src/gateway/service.js.map +1 -1
  257. package/dist/src/gateway/workspace-fs-file-list.js +1 -1
  258. package/dist/src/heartbeat/index.js +1 -1
  259. package/dist/src/infra/brew.js +1 -1
  260. package/dist/src/infra/package-json.js +1 -1
  261. package/dist/src/infra/package-update-steps.js +1 -1
  262. package/dist/src/infra/path-env.js +2 -2
  263. package/dist/src/infra/restart.js +2 -2
  264. package/dist/src/infra/stable-node-path.js +1 -1
  265. package/dist/src/infra/update-check.js +1 -1
  266. package/dist/src/infra/update-global.js +1 -1
  267. package/dist/src/infra/update-lock.js +3 -3
  268. package/dist/src/infra/update-runner.js +1 -1
  269. package/dist/src/infra/update-startup.js +2 -2
  270. package/dist/src/infra/write-file-atomic.js +2 -2
  271. package/dist/src/mcp/channel-bridge.js +26 -2
  272. package/dist/src/mcp/channel-bridge.js.map +1 -1
  273. package/dist/src/mcp/gateway-http-client.js +24 -2
  274. package/dist/src/mcp/gateway-http-client.js.map +1 -1
  275. package/dist/src/notes/store.js +2 -2
  276. package/dist/src/providers/auth-runtime/auth-profile-store.js +1 -1
  277. package/dist/src/providers/index.js +2 -2
  278. package/dist/src/providers/model-registry.js +1 -1
  279. package/dist/src/session/config-store.js +12 -6
  280. package/dist/src/session/config-store.js.map +1 -1
  281. package/dist/src/session/index.d.ts +1 -1
  282. package/dist/src/session/index.js +2 -2
  283. package/dist/src/session/init-session-turn.js +2 -2
  284. package/dist/src/session/manager.js +8 -1
  285. package/dist/src/session/manager.js.map +1 -1
  286. package/dist/src/session/parity/jsonl-transcript-io.js +2 -2
  287. package/dist/src/session/parity/sessions-json-file.js +1 -1
  288. package/dist/src/session/parity/transcript-file-lock.js +2 -2
  289. package/dist/src/session/parity/transcript-paths.js +1 -1
  290. package/dist/src/session/resolve-session.js +4 -4
  291. package/dist/src/session/search-index-cache.js +1 -1
  292. package/dist/src/session/search-index.js +1 -1
  293. package/dist/src/session/session-title.d.ts +19 -3
  294. package/dist/src/session/session-title.js +84 -9
  295. package/dist/src/session/session-title.js.map +1 -1
  296. package/dist/src/session/store.js +6 -6
  297. package/dist/src/share/share-auto.js +2 -2
  298. package/dist/src/share/share-store.js +3 -3
  299. package/dist/src/share/share-thumbnail.js +2 -2
  300. package/dist/src/share/share-zip.js +1 -1
  301. package/dist/src/share/site-share-store.js +3 -3
  302. package/dist/src/share/site-static-serve.js +1 -1
  303. package/dist/src/tui/clipboard-image.js +3 -3
  304. package/dist/src/tui/theme-manager.js +1 -1
  305. package/dist/src/tui/tui-keybindings-file.js +1 -1
  306. package/dist/src/tui/tui-scoped-models.js +2 -2
  307. package/dist/src/tui/tui-settings.js +1 -1
  308. package/dist/src/tui/tui.js +3 -3
  309. package/dist/src/tunnel/frpc-binary.js +3 -3
  310. package/dist/src/tunnel/frpc-config.js +1 -1
  311. package/dist/src/tunnel/frpc-extract.js +1 -1
  312. package/dist/src/tunnel/tunnel-state.js +1 -1
  313. package/dist/src/utils/index.js +4 -4
  314. package/dist/src/utils/logger/audit.js +1 -1
  315. package/dist/src/utils/logger/config.js +2 -6
  316. package/dist/src/utils/logger/config.js.map +1 -1
  317. package/dist/src/utils/logger/context.d.ts +3 -22
  318. package/dist/src/utils/logger/context.js +4 -32
  319. package/dist/src/utils/logger/context.js.map +1 -1
  320. package/dist/src/utils/logger/index.d.ts +4 -7
  321. package/dist/src/utils/logger/index.js +9 -28
  322. package/dist/src/utils/logger/index.js.map +1 -1
  323. package/dist/src/utils/logger/log-store.d.ts +14 -32
  324. package/dist/src/utils/logger/log-store.js +68 -119
  325. package/dist/src/utils/logger/log-store.js.map +1 -1
  326. package/dist/src/utils/logger/log-stream.d.ts +5 -70
  327. package/dist/src/utils/logger/log-stream.js +67 -178
  328. package/dist/src/utils/logger/log-stream.js.map +1 -1
  329. package/dist/src/utils/logger/pino-record.d.ts +8 -0
  330. package/dist/src/utils/logger/pino-record.js +83 -0
  331. package/dist/src/utils/logger/pino-record.js.map +1 -0
  332. package/dist/src/utils/logger/rotation.js +1 -1
  333. package/dist/src/utils/logger/stats.d.ts +1 -1
  334. package/dist/src/utils/logger/stats.js +2 -2
  335. package/dist/src/utils/logger/stats.js.map +1 -1
  336. package/dist/src/utils/logger/streams.js +18 -0
  337. package/dist/src/utils/logger/streams.js.map +1 -1
  338. package/dist/src/utils/logger/types.d.ts +0 -9
  339. package/dist/src/utils/logger/types.js.map +1 -1
  340. package/dist/src/utils/logger.js +4 -4
  341. package/dist/src/voice/tts/audio.js +1 -1
  342. package/dist/src/voice/tts/providers/edge-speech.js +2 -2
  343. package/dist/src/workflows/store/event-store.js +1 -1
  344. package/dist/src/workflows/store/run-store.js +1 -1
  345. package/package.json +2 -1
  346. package/dist/gateway/static/root/assets/agents-C7tTJLP9.js +0 -222
  347. package/dist/gateway/static/root/assets/apps-page-BbzdMyrg.js +0 -1
  348. package/dist/gateway/static/root/assets/channels-settings-B49vG2hE.js +0 -1
  349. package/dist/gateway/static/root/assets/cron-page-Bjx7IOdR.js +0 -1
  350. package/dist/gateway/static/root/assets/index-CwDdudZM.css +0 -1
  351. package/dist/gateway/static/root/assets/logs-page-BxukQ-J-.js +0 -1
  352. package/dist/gateway/static/root/assets/sessions-page-BFD2_-Cl.js +0 -1
  353. package/dist/gateway/static/root/assets/settings-page-BiP5iH46.js +0 -2
  354. package/dist/gateway/static/root/assets/skills-page-CNDctFIn.js +0 -2
  355. package/dist/gateway/static/root/assets/voice-api-key-field-CalxUkxm.js +0 -1
  356. package/dist/gateway/static/root/assets/workflows-page-D2fRxXJG.js +0 -27
@@ -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{i,o as a,t as o}from"./url-CTjpm0Uz.js";import{a as s,i as c}from"./vendor-swr-BIWyz7Rc.js";import{a as l,n as u,t as d}from"./fetch-BAPnkYbC.js";import{Ao as f,Ci as p,Da as m,Dr as h,Dt as g,Er as _,Go as v,Ji as y,N as b,Or as x,Pn as S,Tr as C,Wi as w,Xo as T,_r as E,br as D,fi as O,kr as k,li as A,ma as j,oa as M,so as N,ui as P,vr as F,wo as I,wr as ee,xr as L,yr as R,zo as z,zr as B}from"./index-Do52EfZK.js";var V=e(t(),1),H=n();function U(e){return e===`builtin`||e===`user`?e:`marketplace`}async function W(e){try{let t=await e.json();if(typeof t.error==`string`)return t.error;if(t.error&&typeof t.error==`object`&&typeof t.error.message==`string`)return t.error.message;if(typeof t.message==`string`)return t.message}catch{}return e.statusText||`HTTP ${e.status}`}async function te(e){let t=await d(o(`/api/marketplace/packages/${encodeURIComponent(e.trim())}`),{cache:`no-store`});if(!t.ok)throw Error(await W(t));let n=await t.json();if(!n.ok||!n.payload?.id)throw Error(n.error??`Invalid response`);return n.payload}async function G(e){let t=await d(o(`/api/marketplace/install`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await W(t));let n=await t.json();if(!n.ok||!n.payload?.extensionId)throw Error(n.error??`Invalid response`);return n.payload}async function K(e){let t=await d(o(`/api/extensions/bundled/activation`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e.extensionId.trim(),enabled:e.enabled})});if(!t.ok)throw Error(await W(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error?.message??`Invalid response`);return n.payload}async function q(e){let t=await d(o(`/api/marketplace/uninstall`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({extensionId:e})});if(!t.ok)throw Error(await W(t));let n=await t.json();if(!n.ok||!n.payload)throw Error(n.error??`Invalid response`);return n.payload}var J=r();function Y(e,t){let n=e.find(e=>e.id===t);return n?n.source===`bundled`?`bundled`:`user`:`absent`}var X={q:``,debounced:``,detailPkg:null,rowBusy:null,actionError:null,restartHint:null};function ne({className:e}){let t=a(i(e=>e.language)).appsPage,n=l(e=>!!e.token),r=F(),{mutate:d}=s(),[f,h]=(0,V.useReducer)(b,X),{q:_,debounced:v,detailPkg:x,rowBusy:S,actionError:C,restartHint:w}=f,T=n?`marketplace-${v}`:null;(0,V.useEffect)(()=>{let e=window.setTimeout(()=>h({type:`patch`,patch:{debounced:_.trim()}}),300);return()=>window.clearTimeout(e)},[_]);let{data:E,isLoading:D,error:O}=c(T,async()=>u(v.length>0?o(`/api/marketplace?q=${encodeURIComponent(v)}`):o(`/api/marketplace`)),{revalidateOnFocus:!1}),k=(0,V.useCallback)(()=>{d(`gateway-extensions-list`),g()},[d]),A=(0,V.useCallback)(async(e,n)=>{h({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let r=await G({name:e,overwrite:n});k(),r.requiresGatewayRestart&&h({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw h({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceInstallFailed}}),e}finally{h({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceInstallFailed,t.marketplaceRestartHint,k]),M=(0,V.useCallback)(async e=>{h({type:`patch`,patch:{actionError:null,restartHint:null,rowBusy:e}});try{let n=await q(e);k(),n.requiresGatewayRestart&&h({type:`patch`,patch:{restartHint:t.marketplaceRestartHint}})}catch(e){throw h({type:`patch`,patch:{actionError:e instanceof Error?e.message:t.marketplaceUninstallFailed}}),e}finally{h({type:`patch`,patch:{rowBusy:null}})}},[t.marketplaceRestartHint,t.marketplaceUninstallFailed,k]),N=E?.extensions??[];return(0,J.jsxs)(`div`,{className:P(`flex flex-col gap-4`,e),children:[(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(y,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,J.jsx)(`input`,{type:`search`,value:_,onChange:e=>h({type:`patch`,patch:{q:e.target.value}}),placeholder:t.marketplaceSearchPlaceholder,className:`ui-input h-10 w-full rounded-lg border border-edge bg-surface-base pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted`})]}),O?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:O instanceof Error?O.message:t.marketplaceLoadFailed}):null,C?(0,J.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:C}):null,w?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:w}):null,D&&!E?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):(0,J.jsx)(`ul`,{className:`flex flex-col gap-3`,children:N.length===0?(0,J.jsx)(`li`,{className:`text-sm text-fg-muted`,children:t.marketplaceEmpty}):N.map(e=>{let n=Y(r,e.id),i=S===e.id;return(0,J.jsx)(`li`,{className:`list-none`,children:(0,J.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-label":`${e.name}, ${t.marketplaceDetailTitle}`,onClick:()=>h({type:`patch`,patch:{detailPkg:e.id}}),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),h({type:`patch`,patch:{detailPkg:e.id}}))},className:P(`flex w-full cursor-pointer flex-wrap items-start gap-3 rounded-xl border border-edge bg-surface-base p-4 text-left shadow-surface`,`transition-[transform,background-color,border-color,box-shadow] duration-150 ease-out`,`hover:border-edge-subtle hover:bg-surface-hover/40`,`active:scale-[0.992] active:bg-surface-hover/55`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`dark:hover:bg-surface-hover/25 dark:active:bg-surface-hover/35`),children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(`h3`,{className:`font-semibold text-fg`,children:e.name}),e.verified?(0,J.jsx)(I,{className:`size-4 shrink-0 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75,"aria-label":`Verified`}):null,e.version?(0,J.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e.version}):null]}),e.description?(0,J.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-fg-muted`,children:e.description}):null,(0,J.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:(e.categories??[]).map(e=>(0,J.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e))}),(0,J.jsxs)(`p`,{className:`mt-2 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,J.jsx)(j,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,J.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:e.npmPackage})]})]}),(0,J.jsx)(`div`,{role:`group`,className:`flex shrink-0 flex-col items-end gap-2 sm:min-w-[9rem]`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:n===`bundled`?(0,J.jsx)(`span`,{className:`rounded-md bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.marketplaceBuiltin}):n===`user`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`text-[11px] font-medium text-fg-muted`,children:t.marketplaceInstalled}),(0,J.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{window.confirm(t.marketplaceUninstallConfirm)&&M(e.id).catch(()=>{})},className:P(`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,J.jsx)(m,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,J.jsx)(p,{className:`size-3.5`,strokeWidth:2,"aria-hidden":!0}),t.marketplaceUninstall]})]}):(0,J.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>{A(e.id,!1).catch(()=>{})},className:P(`inline-flex w-full items-center justify-center rounded-lg bg-accent px-3 py-2 text-xs font-medium text-white`,`shadow-surface transition-[transform,background-color] active:scale-[0.98]`,`hover:bg-accent-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,`disabled:pointer-events-none disabled:opacity-50`),children:[i?(0,J.jsx)(m,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):null,t.marketplaceInstall]})})]})},e.id)})}),x?(0,J.jsx)(re,{packageName:x,copy:t,extensions:r,onClose:()=>h({type:`patch`,patch:{detailPkg:null}}),onInstall:A,onUninstall:M}):null]})}function re(e){let t=(0,H.c)(61),{packageName:n,copy:r,extensions:i,onClose:a,onInstall:o,onUninstall:s}=e,[u,d]=(0,V.useState)(!1),f=l(se)?`ext-mp-detail-${n}`:null,g;t[0]===n?g=t[1]:(g=async()=>te(n),t[0]=n,t[1]=g);let y;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(y={revalidateOnFocus:!1},t[2]=y):y=t[2];let{data:b,error:C,isLoading:w}=c(f,g,y),T;t[3]!==i||t[4]!==n?(T=Y(i,n),t[3]=i,t[4]=n,t[5]=T):T=t[5];let E=T,D=E===`user`,A;t[6]!==r.marketplaceNoReadme||t[7]!==b?(A=b?.readme?.trim()||(b?.description?.trim()?`### ${b.name}\n\n${b.description}`:`*${r.marketplaceNoReadme}*`),t[6]=r.marketplaceNoReadme,t[7]=b,t[8]=A):A=t[8];let j=A,M;t[9]===a?M=t[10]:(M=e=>!e&&a(),t[9]=a,t[10]=M);let N;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,J.jsx)(_,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),t[11]=N):N=t[11];let F;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,J.jsx)(z,{className:`size-5`}),t[12]=F):F=t[12];let I;t[13]!==r.detailBack||t[14]!==a?(I=(0,J.jsx)(`button`,{type:`button`,onClick:a,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailBack,children:F}),t[13]=r.detailBack,t[14]=a,t[15]=I):I=t[15];let L;t[16]===r.marketplaceDetailTitle?L=t[17]:(L=(0,J.jsx)(k,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:r.marketplaceDetailTitle}),t[16]=r.marketplaceDetailTitle,t[17]=L);let R;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,J.jsx)(O,{className:`size-5`}),t[18]=R):R=t[18];let B;t[19]!==r.detailClose||t[20]!==a?(B=(0,J.jsx)(`button`,{type:`button`,onClick:a,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":r.detailClose,children:R}),t[19]=r.detailClose,t[20]=a,t[21]=B):B=t[21];let U;t[22]!==B||t[23]!==I||t[24]!==L?(U=(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[I,L,B]}),t[22]=B,t[23]=I,t[24]=L,t[25]=U):U=t[25];let W;t[26]!==r.marketplaceAuthor||t[27]!==r.marketplaceDetailLoadFailed||t[28]!==r.marketplaceDetailReadmeHeading||t[29]!==r.marketplaceDownloads||t[30]!==r.marketplaceVersion||t[31]!==b||t[32]!==C||t[33]!==w||t[34]!==j?(W=w&&!b?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`…`}):C?(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.marketplaceDetailLoadFailed}):b?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:b.name}),(0,J.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,J.jsx)(`code`,{className:`rounded bg-surface-panel px-1 py-0.5`,children:b.id})}),(0,J.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs text-fg-muted sm:grid-cols-2`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceAuthor}),(0,J.jsx)(`dd`,{children:b.author.username})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceVersion}),(0,J.jsx)(`dd`,{children:b.latestVersion.version})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`dt`,{className:`font-medium text-fg`,children:r.marketplaceDownloads}),(0,J.jsx)(`dd`,{children:b.downloads})]})]}),b.readme?.trim()?(0,J.jsx)(`h4`,{className:`mb-2 mt-6 text-sm font-semibold text-fg`,children:r.marketplaceDetailReadmeHeading}):null,(0,J.jsx)(`div`,{className:`markdown-content min-w-0 break-words text-sm`,children:(0,J.jsx)(S,{content:j})})]}):null,t[26]=r.marketplaceAuthor,t[27]=r.marketplaceDetailLoadFailed,t[28]=r.marketplaceDetailReadmeHeading,t[29]=r.marketplaceDownloads,t[30]=r.marketplaceVersion,t[31]=b,t[32]=C,t[33]=w,t[34]=j,t[35]=W):W=t[35];let G;t[36]===W?G=t[37]:(G=(0,J.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:W}),t[36]=W,t[37]=G);let K;t[38]!==u||t[39]!==r.marketplaceBuiltinGoBuiltin||t[40]!==r.marketplaceBuiltinManageHint||t[41]!==r.marketplaceInstall||t[42]!==r.marketplaceReinstall||t[43]!==r.marketplaceReinstallConfirm||t[44]!==r.marketplaceUninstall||t[45]!==r.marketplaceUninstallConfirm||t[46]!==b||t[47]!==E||t[48]!==a||t[49]!==o||t[50]!==s||t[51]!==n||t[52]!==D?(K=b?(0,J.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-edge-subtle px-5 py-4`,children:E===`bundled`?(0,J.jsxs)(`div`,{className:`flex w-full flex-col items-stretch gap-2`,children:[(0,J.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:r.marketplaceBuiltinManageHint}),(0,J.jsx)(v,{to:`/apps?tab=builtin`,onClick:a,className:`inline-flex w-fit items-center justify-center rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.marketplaceBuiltinGoBuiltin})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{D&&!window.confirm(r.marketplaceReinstallConfirm)||(d(!0),o(n,D).catch(ae).finally(()=>d(!1)))},className:P(`inline-flex items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium`,`bg-accent text-white shadow-surface hover:bg-accent-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,`disabled:pointer-events-none disabled:opacity-50`),children:[u?(0,J.jsx)(m,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,D?r.marketplaceReinstall:r.marketplaceInstall]}),D?(0,J.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>{window.confirm(r.marketplaceUninstallConfirm)&&(d(!0),s(n).then(()=>a()).catch(ie).finally(()=>d(!1)))},className:P(`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,J.jsx)(p,{className:`size-4 shrink-0`,"aria-hidden":!0}),r.marketplaceUninstall]}):null]})}):null,t[38]=u,t[39]=r.marketplaceBuiltinGoBuiltin,t[40]=r.marketplaceBuiltinManageHint,t[41]=r.marketplaceInstall,t[42]=r.marketplaceReinstall,t[43]=r.marketplaceReinstallConfirm,t[44]=r.marketplaceUninstall,t[45]=r.marketplaceUninstallConfirm,t[46]=b,t[47]=E,t[48]=a,t[49]=o,t[50]=s,t[51]=n,t[52]=D,t[53]=K):K=t[53];let q;t[54]!==U||t[55]!==G||t[56]!==K?(q=(0,J.jsxs)(h,{children:[N,(0,J.jsxs)(ee,{className:`fixed left-1/2 top-1/2 z-[131] flex max-h-[min(90vh,44rem)] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,onOpenAutoFocus:oe,children:[U,G,K]})]}),t[54]=U,t[55]=G,t[56]=K,t[57]=q):q=t[57];let X;return t[58]!==q||t[59]!==M?(X=(0,J.jsx)(x,{defaultOpen:!0,onOpenChange:M,children:q}),t[58]=q,t[59]=M,t[60]=X):X=t[60],X}function ie(){}function ae(){}function oe(e){return e.preventDefault()}function se(e){return!!e.token}function ce(){let e=i(e=>e.language),t=a(e),n=B(e=>e.setPageHeader),r=B(e=>e.clearPageHeader),o=F(),s=R(),[c,l]=T(),u=U(c.get(`tab`)),d=c.get(`q`)??``,[f,p]=(0,V.useState)(u),[m,h]=(0,V.useState)(d),[g,_]=(0,V.useState)(null),v=c.toString(),b=(0,V.useRef)(v);if(b.current!==v){b.current=v;let e=U(c.get(`tab`)),t=c.get(`q`)??``;p(t=>t===e?t:e),h(e=>e===t?e:t)}(0,V.useEffect)(()=>{l(e=>{let t=new URLSearchParams(e),n=m.trim();return n?t.set(`q`,n):t.delete(`q`),f===`marketplace`?t.delete(`tab`):t.set(`tab`,f),t.toString()===e.toString()?e:t},{replace:!0})},[f,m,l]);let x=(0,V.useMemo)(()=>o.filter(e=>e.source===`bundled`),[o]),S=(0,V.useMemo)(()=>o.filter(e=>e.source!==`bundled`),[o]),C=f===`builtin`?x:S,w=(0,V.useMemo)(()=>{let t=m.trim().toLowerCase(),n=C;return t&&(n=n.filter(e=>(e.name??``).toLowerCase().includes(t)||e.id.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t))),n.toSorted((t,n)=>t.hasUi===n.hasUi?(t.name||t.id).localeCompare(n.name||n.id,e):t.hasUi?-1:1)},[C,m,e]);if((0,V.useEffect)(()=>{_(e=>{if(!e)return e;let t=o.find(t=>t.id===e.id);return t?Z(e)===Z(t)&&e.active===t.active?e:t:null})},[o]),(0,V.useLayoutEffect)(()=>(n({startExtra:null,main:(0,J.jsx)(`div`,{className:`min-w-0`,children:(0,J.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.appsPage.title})}),end:null}),()=>r()),[r,t.appsPage.title,n]),s&&f!==`marketplace`)return(0,J.jsx)(pe,{});let E=f!==`marketplace`&&C.length>0;return(0,J.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,J.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[(0,J.jsxs)(`div`,{className:`mb-5 flex flex-col gap-3 border-b border-edge-subtle pb-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge-subtle`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-x-1 gap-y-1`,role:`tablist`,"aria-label":t.appsPage.appsNavAria,children:[(0,J.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":f===`marketplace`,className:P(`relative max-w-full rounded-md px-3 py-2 text-left text-sm font-medium transition-colors sm:text-center`,f===`marketplace`?`text-fg`:`text-fg-muted hover:text-fg`,f===`marketplace`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>p(`marketplace`),children:t.appsPage.tabMarketplace}),(0,J.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":f===`builtin`,className:P(`relative rounded-md px-3 py-2 text-sm font-medium transition-colors`,f===`builtin`?`text-fg`:`text-fg-muted hover:text-fg`,f===`builtin`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>p(`builtin`),children:[t.appsPage.tabBuiltin,(0,J.jsxs)(`span`,{className:`ml-1 tabular-nums text-fg-muted`,children:[`(`,x.length,`)`]})]}),(0,J.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":f===`user`,className:P(`relative rounded-md px-3 py-2 text-sm font-medium transition-colors`,f===`user`?`text-fg`:`text-fg-muted hover:text-fg`,f===`user`&&`after:absolute after:bottom-0 after:left-1/2 after:h-0.5 after:w-9 after:-translate-x-1/2 after:rounded-full after:bg-accent`),onClick:()=>p(`user`),children:[t.appsPage.tabUser,(0,J.jsxs)(`span`,{className:`ml-1 tabular-nums text-fg-muted`,children:[`(`,S.length,`)`]})]})]}),E?(0,J.jsxs)(`div`,{className:`relative w-full min-w-0 sm:max-w-xs`,children:[(0,J.jsx)(y,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,J.jsx)(`input`,{type:`search`,value:m,onChange:e=>h(e.target.value),placeholder:t.appsPage.searchPlaceholder,className:`w-full rounded-lg border border-edge bg-surface-base py-2 pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,autoComplete:`off`})]}):null]}),f===`marketplace`?(0,J.jsx)(ne,{}):f===`builtin`&&x.length===0?(0,J.jsx)(he,{message:t.appsPage.emptyBuiltin}):f===`user`&&S.length===0?(0,J.jsx)(he,{message:t.appsPage.emptyUser}):w.length===0?(0,J.jsx)(`p`,{className:`rounded-xl border border-dashed border-edge-subtle bg-surface-hover/30 px-4 py-8 text-center text-sm text-fg-muted dark:bg-surface-hover/15`,children:t.appsPage.noSearchResults}):(0,J.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:w.map(e=>(0,J.jsx)(de,{extension:e,copy:t.appsPage,showSourceBadge:f===`user`,onOpen:()=>_(e)},e.id))})]}),g?(0,J.jsx)(fe,{extension:g,copy:t.appsPage,onClose:()=>_(null)},g.id):null]})}function Z(e){return e.activationEligible??e.active}function Q(e,t){return e.source===`bundled`?t.providerBundled:e.source===`global`?t.providerGlobal:e.source===`workspace`?t.providerWorkspace:t.providerOther}function le(e,t){return e.source===`global`?t.badgeSourceGlobal:e.source===`workspace`?t.badgeSourceWorkspace:t.badgeSourceOther}function ue(e,t){let n=Z(e);return n&&e.active?t.runStateLive:n&&!e.active?t.runStatePendingOn:!n&&e.active?t.runStatePendingOff:t.runStateOff}function de(e){let t=(0,H.c)(45),{extension:n,copy:r,showSourceBadge:i,onOpen:a}=e,o;t[0]===n?o=t[1]:(o=Z(n),t[0]=n,t[1]=o);let s=o,c=n.hasUi?r.cardTooltipHasUi:r.cardTooltipNoUi,l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=P(`group flex w-full flex-col rounded-xl border border-edge bg-surface-base p-4 text-left shadow-sm transition-colors`,`hover:border-edge-subtle hover:bg-surface-hover/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,`dark:hover:bg-surface-hover/25`),t[2]=l):l=t[2];let u=n.name||n.id,d;t[3]===u?d=t[4]:(d=u.charAt(0).toUpperCase(),t[3]=u,t[4]=d);let p;t[5]===d?p=t[6]:(p=(0,J.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-base font-semibold text-accent-fg`,"aria-hidden":!0,children:d}),t[5]=d,t[6]=p);let m;t[7]===n.name?m=t[8]:(m=(0,J.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.name}),t[7]=n.name,t[8]=m);let h;t[9]===n.version?h=t[10]:(h=n.version?(0,J.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[`v`,n.version]}):null,t[9]=n.version,t[10]=h);let g;t[11]!==m||t[12]!==h?(g=(0,J.jsxs)(`div`,{className:`min-w-0`,children:[m,h]}),t[11]=m,t[12]=h,t[13]=g):g=t[13];let _;t[14]!==r.statusEnabled||t[15]!==s?(_=s?(0,J.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:[(0,J.jsx)(f,{className:`size-3`,strokeWidth:2.5,"aria-hidden":!0}),r.statusEnabled]}):(0,J.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-full border-2 border-accent text-accent`,"aria-hidden":!0,children:(0,J.jsx)(M,{className:`size-4`,strokeWidth:2.5})}),t[14]=r.statusEnabled,t[15]=s,t[16]=_):_=t[16];let v;t[17]!==g||t[18]!==_?(v=(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[g,_]}),t[17]=g,t[18]=_,t[19]=v):v=t[19];let y;t[20]!==r.cardNoDescription||t[21]!==n.description?(y=n.description?.trim()||r.cardNoDescription,t[20]=r.cardNoDescription,t[21]=n.description,t[22]=y):y=t[22];let b;t[23]===y?b=t[24]:(b=(0,J.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:y}),t[23]=y,t[24]=b);let x=n.hasUi?r.badgeKindUi:r.badgeKindBackend,S;t[25]!==x||t[26]!==c?(S=(0,J.jsx)(`span`,{title:c,className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:x}),t[25]=x,t[26]=c,t[27]=S):S=t[27];let C;t[28]!==r||t[29]!==n||t[30]!==i?(C=n.source===`bundled`?(0,J.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:r.badgeBundled}):i?(0,J.jsx)(`span`,{title:Q(n,r),className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-fg-muted`,children:le(n,r)}):null,t[28]=r,t[29]=n,t[30]=i,t[31]=C):C=t[31];let w;t[32]!==S||t[33]!==C?(w=(0,J.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[S,C]}),t[32]=S,t[33]=C,t[34]=w):w=t[34];let T;t[35]!==v||t[36]!==b||t[37]!==w?(T=(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[v,b,w]}),t[35]=v,t[36]=b,t[37]=w,t[38]=T):T=t[38];let E;t[39]!==T||t[40]!==p?(E=(0,J.jsxs)(`div`,{className:`flex gap-3`,children:[p,T]}),t[39]=T,t[40]=p,t[41]=E):E=t[41];let D;return t[42]!==a||t[43]!==E?(D=(0,J.jsx)(`button`,{type:`button`,onClick:a,className:l,children:E}),t[42]=a,t[43]=E,t[44]=D):D=t[44],D}function fe({extension:e,copy:t,onClose:n}){let{mutate:r}=s(),[i,a]=(0,V.useState)(!1),[o,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1),d=e.activationEligible===!0,f=(0,V.useCallback)(async()=>{if(e.source===`bundled`){c(null),u(!1),a(!0);try{let{requiresGatewayRestart:t}=await K({extensionId:e.id,enabled:!d});await r(`gateway-extensions-list`),g(),u(t)}catch(e){c(e instanceof Error?e.message:t.builtinToggleFailed)}finally{a(!1)}}},[d,t.builtinToggleFailed,e.id,e.source,r]),p=e.ui?.contributions?.pages??[],y=e.ui?.contributions?.settingsPanels??[],b=e.ui?.contributions?.chatWidgets??[],S=e.ui?.contributions?.sidebarPanels??[],T=p.find(e=>e.showInNav)??p[0],j=y[0],M=T?E(e.id,T):null,F=j?`/settings/ext/${e.id}/${j.id}`:e.hasConfigSchema||D(e)?`/settings/ext/${e.id}`:null;return(0,J.jsx)(x,{defaultOpen:!0,onOpenChange:e=>!e&&n(),children:(0,J.jsxs)(h,{children:[(0,J.jsx)(_,{className:`xopc-dialog-overlay fixed inset-0 z-[130] bg-scrim`}),(0,J.jsxs)(ee,{className:`fixed left-1/2 top-1/2 z-[131] flex max-h-[min(90vh,44rem)] w-[min(42rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-elevated`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[(0,J.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,J.jsx)(z,{className:`size-5`})}),(0,J.jsx)(k,{className:`min-w-0 flex-1 truncate text-center text-sm font-semibold text-fg`,children:t.detailTitle}),(0,J.jsxs)(C,{className:`sr-only`,children:[e.name,` (`,e.id,`)`]}),(0,J.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,J.jsx)(O,{className:`size-5`})})]}),(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start gap-4`,children:[(0,J.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,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`h3`,{className:`text-lg font-semibold text-fg`,children:e.name}),(0,J.jsxs)(`p`,{className:`mt-0.5 text-sm text-fg-muted`,children:[t.detailProviderPrefix,` `,Q(e,t)]}),e.version?(0,J.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[`v`,e.version]}):null]})]}),(0,J.jsx)(`p`,{className:`mt-5 text-sm leading-relaxed text-fg`,children:e.description?.trim()||t.detailNoDescription}),e.hasUi?null:(0,J.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.backendOnlyHint}),(0,J.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:ue(e,t)}),e.source===`bundled`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`mt-4 rounded-lg border border-edge-subtle bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted dark:bg-surface-hover/20`,children:t.builtinConfigHint}),(0,J.jsxs)(`div`,{className:`mt-3 rounded-lg border border-edge-subtle bg-surface-hover/40 p-3 dark:bg-surface-hover/20`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,J.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:t.builtinRuntimeToggle}),(0,J.jsx)(A,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>void f(),className:`shrink-0 py-1.5 text-xs`,children:i?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(m,{className:`mr-1.5 size-3.5 shrink-0 animate-spin`,"aria-hidden":!0}),t.builtinToggleBusy]}):d?t.builtinToggleDisable:t.builtinToggleEnable})]}),o?(0,J.jsx)(`p`,{className:`mt-2 text-xs text-rose-600 dark:text-rose-400`,children:o}):null,l?(0,J.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.builtinToggleRestartHint}):null]})]}):(0,J.jsx)(`p`,{className:`mt-4 rounded-lg border border-edge-subtle bg-surface-hover/40 px-3 py-2 text-xs text-fg-muted dark:bg-surface-hover/20`,children:t.cliManageHint}),e.hasUi&&(p.length>0||y.length>0||b.length>0)?(0,J.jsxs)(`section`,{className:`mt-8`,children:[(0,J.jsx)(`h4`,{className:`mb-3 text-sm font-semibold text-fg`,children:t.detailSectionFeatures}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,J.jsx)($,{template:t.badgePages,count:p.length,hidden:p.length===0}),(0,J.jsx)($,{template:t.badgeSettings,count:y.length,hidden:y.length===0}),(0,J.jsx)($,{template:t.badgeWidgets,count:b.length,hidden:b.length===0}),(0,J.jsx)($,{template:t.badgeSidebar,count:S.length,hidden:S.length===0})]})]}):null,L(e)&&(M||F)?(0,J.jsxs)(`div`,{className:`mt-6 flex flex-wrap gap-2 border-t border-edge-subtle pt-4`,children:[M?(0,J.jsxs)(v,{to:M,onClick:n,className:P(`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,J.jsx)(N,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.open]}):null,F?(0,J.jsxs)(v,{to:F,onClick:n,className:P(`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,J.jsx)(w,{className:`size-4 shrink-0 opacity-80`,"aria-hidden":!0}),t.openSettings]}):null]}):null,(0,J.jsx)(`p`,{className:`mt-6 text-[11px] leading-relaxed text-fg-muted`,children:t.restartNote})]})]})]})})}function $(e){let t=(0,H.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,J.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 pe(){let e=(0,H.c)(5),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,J.jsx)(`div`,{className:`mb-6 h-8 w-40 max-w-full animate-pulse rounded-md bg-surface-hover`}),n=(0,J.jsx)(`div`,{className:`mb-2 h-4 w-full max-w-md animate-pulse rounded bg-surface-hover`}),r=(0,J.jsx)(`div`,{className:`mb-5 h-9 w-full max-w-lg animate-pulse rounded-full bg-surface-hover`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=[`ap0`,`ap1`,`ap2`,`ap3`,`ap4`,`ap5`],e[3]=i):i=e[3];let a;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,J.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,J.jsxs)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-8`,children:[t,n,r,(0,J.jsx)(`div`,{className:`mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:i.map(me)})]})}),e[4]=a):a=e[4],a}function me(e){return(0,J.jsx)(`div`,{className:`h-36 animate-pulse rounded-xl border border-edge bg-surface-base`},e)}function he(e){let t=(0,H.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,J.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-col items-center justify-center rounded-xl border border-dashed border-edge-subtle bg-surface-hover/40 px-4 py-12 text-center dark:bg-surface-hover/20`,children:(0,J.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{ce as AppsPage};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{i,o as a,t as o}from"./url-CTjpm0Uz.js";import{i as s}from"./vendor-swr-BIWyz7Rc.js";import{t as c}from"./copy-Dv6d4Dvw.js";import{a as l,n as u}from"./fetch-BAPnkYbC.js";import{Ao as d,B as f,Cr as p,Dr as m,Er as h,Jo as g,Or as _,Qr as v,Sr as y,Tr as b,Wr as x,Xo as S,Yo as C,Yr as w,Zr as T,ai as E,an as D,ao as O,cr as k,dr as A,ei as j,fi as M,gr as N,in as P,ko as ee,kr as F,kt as I,li as L,on as R,oo as te,rn as ne,so as z,ta as B,ti as V,ui as H,wr as U,z as W,zr as G}from"./index-Do52EfZK.js";import{a as K,c as re,i as q,o as ie,r as ae,s as oe,t as J}from"./utils-C86AVfY-.js";import{n as Y,r as se,t as ce}from"./field-primitives-8p7ucXa1.js";import{_ as le,a as ue,c as de,d as fe,f as pe,g as me,h as he,i as ge,l as _e,m as ve,n as ye,o as be,p as xe,r as X,s as Se,t as Ce,u as we,v as Te,y as Ee}from"./channels-status-swr-CsGkK9h9.js";var Z=e(t(),1),Q=n(),$=r();function De(e){switch(e){case`running`:return`bg-success-soft text-success`;case`offline`:return`bg-amber-100 text-amber-900 dark:bg-amber-950/60 dark:text-amber-200`;case`disabled`:return`bg-surface-hover text-fg-muted`;default:return`bg-surface-hover text-fg-muted`}}function Oe(e,t){switch(t){case`running`:return e.hubStatusRunning;case`offline`:return e.hubStatusOffline;case`disabled`:return e.hubStatusDisabled;default:return e.hubStatusNotConfigured}}function ke(e,t){switch(t){case`setup`:return e.hubSetupButton;case`fix`:return e.hubFixButton;case`pairing`:return e.hubPairingButton;default:return e.hubManageButton}}function Ae(e){let t=(0,Q.c)(62),{channelId:n,title:r,subtitle:i,vm:a,toggleDisabled:o,onOpen:s,onReviewPairing:c,onToggle:l,ch:u}=e,d=a.configured&&a.manageable,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=H(`flex h-full min-h-0 flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-panel p-4 shadow-sm transition-colors`,`hover:border-edge`),t[0]=f):f=t[0];let p=a.status===`running`?`bg-accent-soft`:`bg-surface-base`,m;t[1]===p?m=t[2]:(m=H(`flex size-11 shrink-0 items-center justify-center rounded-xl ring-1 ring-edge-subtle/40`,p),t[1]=p,t[2]=m);let h;t[3]===n?h=t[4]:(h=(0,$.jsx)(N,{sourceChannel:n,className:`size-5`}),t[3]=n,t[4]=h);let g;t[5]!==m||t[6]!==h?(g=(0,$.jsx)(`div`,{className:m,"aria-hidden":!0,children:h}),t[5]=m,t[6]=h,t[7]=g):g=t[7];let _;t[8]===r?_=t[9]:(_=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r}),t[8]=r,t[9]=_);let v;t[10]===a.status?v=t[11]:(v=H(`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium`,De(a.status)),t[10]=a.status,t[11]=v);let y;t[12]!==u||t[13]!==a.status?(y=Oe(u,a.status),t[12]=u,t[13]=a.status,t[14]=y):y=t[14];let b;t[15]!==v||t[16]!==y?(b=(0,$.jsx)(`span`,{className:v,children:y}),t[15]=v,t[16]=y,t[17]=b):b=t[17];let x;t[18]!==u||t[19]!==c||t[20]!==a.pendingPairing?(x=a.pendingPairing>0?(0,$.jsx)(`button`,{type:`button`,className:H(`inline-flex items-center rounded-full bg-amber-100 px-2 py-0.5 text-xs font-medium text-amber-900 dark:bg-amber-950/60 dark:text-amber-200`,V.press),onClick:e=>{e.stopPropagation(),c()},children:u.hubPairingPendingBadge.replace(`{{count}}`,String(a.pendingPairing))}):null,t[18]=u,t[19]=c,t[20]=a.pendingPairing,t[21]=x):x=t[21];let S;t[22]!==x||t[23]!==b?(S=(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5`,children:[b,x]}),t[22]=x,t[23]=b,t[24]=S):S=t[24];let C;t[25]!==S||t[26]!==_?(C=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[_,S]}),t[25]=S,t[26]=_,t[27]=C):C=t[27];let w;t[28]!==u||t[29]!==l||t[30]!==d||t[31]!==r||t[32]!==o||t[33]!==a.enabled?(w=d?(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":a.enabled,"aria-label":`${r} — ${u.enableChannelAria}`,disabled:o,className:H(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,V.press,a.enabled?`justify-end bg-accent`:`justify-start bg-surface-hover`,o&&`cursor-not-allowed opacity-50`),onClick:e=>{e.stopPropagation(),l(!a.enabled)},children:(0,$.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`})}):null,t[28]=u,t[29]=l,t[30]=d,t[31]=r,t[32]=o,t[33]=a.enabled,t[34]=w):w=t[34];let T;t[35]!==C||t[36]!==w||t[37]!==g?(T=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[g,C,w]}),t[35]=C,t[36]=w,t[37]=g,t[38]=T):T=t[38];let E;t[39]===i?E=t[40]:(E=(0,$.jsx)(`p`,{className:`line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:i}),t[39]=i,t[40]=E);let D;t[41]===a.summaryLines?D=t[42]:(D=a.summaryLines.length>0?(0,$.jsx)(`ul`,{className:`mt-1.5 space-y-0.5`,children:a.summaryLines.map(je)}):null,t[41]=a.summaryLines,t[42]=D);let O;t[43]!==E||t[44]!==D?(O=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[E,D]}),t[43]=E,t[44]=D,t[45]=O):O=t[45];let k;t[46]!==s||t[47]!==c||t[48]!==a.manageable||t[49]!==a.pendingPairing||t[50]!==a.primaryAction?(k=()=>{if(a.manageable&&(a.primaryAction===`pairing`||a.pendingPairing>0)){c();return}s()},t[46]=s,t[47]=c,t[48]=a.manageable,t[49]=a.pendingPairing,t[50]=a.primaryAction,t[51]=k):k=t[51];let A;t[52]!==u||t[53]!==a.primaryAction?(A=ke(u,a.primaryAction),t[52]=u,t[53]=a.primaryAction,t[54]=A):A=t[54];let j;t[55]!==k||t[56]!==A?(j=(0,$.jsx)(`div`,{className:`mt-auto`,children:(0,$.jsx)(L,{type:`button`,variant:`primary`,className:`w-full`,onClick:k,children:A})}),t[55]=k,t[56]=A,t[57]=j):j=t[57];let M;return t[58]!==T||t[59]!==O||t[60]!==j?(M=(0,$.jsxs)(`article`,{className:f,children:[T,O,j]}),t[58]=T,t[59]=O,t[60]=j,t[61]=M):M=t[61],M}function je(e){return(0,$.jsx)(`li`,{className:`text-xs text-fg-muted`,children:e},e)}function Me(e){let t=(0,Q.c)(17),{catalog:n,cards:r,ch:i,saving:a,onOpenChannel:o,onToggleChannel:s}=e,c;t[0]===r?c=t[1]:(c=new Map(r.map(Ne)),t[0]=r,t[1]=c);let l=c,u;if(t[2]!==l||t[3]!==n||t[4]!==i||t[5]!==o||t[6]!==s||t[7]!==a){let e;t[9]!==l||t[10]!==i||t[11]!==o||t[12]!==s||t[13]!==a?(e=e=>{let t=l.get(e.id);return t?(0,$.jsx)(`li`,{className:`h-full min-h-0`,children:(0,$.jsx)(Ae,{channelId:e.id,title:e.title,subtitle:e.subtitle,vm:t,toggleDisabled:a||!t.manageable,onOpen:()=>o(e.id),onReviewPairing:()=>o(e.id,{scrollToPairing:!0}),onToggle:t=>s(e.id,t),ch:i})},e.id):null},t[9]=l,t[10]=i,t[11]=o,t[12]=s,t[13]=a,t[14]=e):e=t[14],u=n.map(e),t[2]=l,t[3]=n,t[4]=i,t[5]=o,t[6]=s,t[7]=a,t[8]=u}else u=t[8];let d;return t[15]===u?d=t[16]:(d=(0,$.jsx)(`ul`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-[repeat(auto-fill,minmax(280px,1fr))]`,role:`list`,children:u}),t[15]=u,t[16]=d),d}function Ne(e){return[e.id,e]}var Pe=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function Fe(){let e=(0,Q.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:H(`size-11 shrink-0 rounded-xl`,Pe)}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,$.jsx)(`div`,{className:H(`h-4 w-2/5`,Pe)}),(0,$.jsx)(`div`,{className:H(`h-5 w-16 rounded-full`,Pe)})]}),(0,$.jsx)(`div`,{className:H(`h-6 w-10 shrink-0 rounded-full`,Pe)})]}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:H(`h-3 w-full`,Pe)}),(0,$.jsx)(`div`,{className:H(`h-3 w-[88%]`,Pe)})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(`div`,{className:`flex h-full min-h-[13.5rem] flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-panel p-4 shadow-sm dark:border-edge-subtle`,"aria-hidden":!0,children:[n,r,(0,$.jsx)(`div`,{className:`mt-auto`,children:(0,$.jsx)(`div`,{className:H(`h-10 w-full rounded-lg`,Pe)})})]}),e[3]=i):i=e[3],i}function Ie(e){let t=(0,Q.c)(2),{count:n}=e,r=n===void 0?3:n,i;return t[0]===r?i=t[1]:(i=(0,$.jsx)(`ul`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,role:`list`,"aria-busy":!0,children:Array.from({length:r},Le)}),t[0]=r,t[1]=i),i}function Le(e,t){return(0,$.jsx)(`li`,{className:`h-full min-h-0`,children:(0,$.jsx)(Fe,{})},t)}function Re(e,t=!1){return e===`drawer`?H(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,W):H(`fixed left-1/2 top-1/2 flex max-h-[min(90vh,52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`max-h-[min(90vh,48rem)] w-[min(calc(100%-2rem),36rem)]`,W,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function ze(e){let t=(0,Q.c)(30),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:s,srDescription:c,closeAriaLabel:l,children:u,footer:d,wide:g,headerExtra:v}=e,y=g===void 0?!1:g,x=n===`drawer`,S;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(h,{className:H(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,f)}),t[0]=S):S=t[0];let C;t[1]!==n||t[2]!==y?(C=Re(n,y),t[1]=n,t[2]=y,t[3]=C):C=t[3];let w;t[4]===s?w=t[5]:(w=s?(0,$.jsx)(F,{className:`sr-only`,children:s}):null,t[4]=s,t[5]=w);let T;t[6]===c?T=t[7]:(T=c?(0,$.jsx)(b,{className:`sr-only`,children:c}):null,t[6]=c,t[7]=T);let E;t[8]!==l||t[9]!==o||t[10]!==v||t[11]!==x||t[12]!==a?(E=x?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,$.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,$.jsx)(p,{asChild:!0,children:(0,$.jsx)(L,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":l,children:(0,$.jsx)(M,{className:`size-5`,strokeWidth:1.75})})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(p,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:H(j,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":l,children:(0,$.jsx)(M,{className:`size-4`})})}),v]}),t[8]=l,t[9]=o,t[10]=v,t[11]=x,t[12]=a,t[13]=E):E=t[13];let D=x?`px-4 py-4`:`p-6`,O;t[14]===D?O=t[15]:(O=H(`min-h-0 flex-1 overflow-y-auto`,D),t[14]=D,t[15]=O);let k;t[16]!==u||t[17]!==O?(k=(0,$.jsx)(`div`,{className:O,children:u}),t[16]=u,t[17]=O,t[18]=k):k=t[18];let A;t[19]!==d||t[20]!==C||t[21]!==w||t[22]!==T||t[23]!==E||t[24]!==k?(A=(0,$.jsxs)(m,{children:[S,(0,$.jsxs)(U,{className:C,onOpenAutoFocus:Be,children:[w,T,E,k,d]})]}),t[19]=d,t[20]=C,t[21]=w,t[22]=T,t[23]=E,t[24]=k,t[25]=A):A=t[25];let N;return t[26]!==i||t[27]!==r||t[28]!==A?(N=(0,$.jsx)(_,{open:r,onOpenChange:i,children:A}),t[26]=i,t[27]=r,t[28]=A,t[29]=N):N=t[29],N}function Be(e){return e.preventDefault()}function Ve(e){let t=(0,Q.c)(52),{open:n,onOpenChange:r,entry:i,vm:a,ch:o,language:s}=e,c=a.status===`running`?o.hubStatusRunning:a.status===`offline`?o.hubStatusOffline:a.status===`disabled`?o.hubStatusDisabled:o.hubStatusNotConfigured,l=i.title,u=i.subtitle,d=o.modalCancel,f;t[0]===i.title?f=t[1]:(f=(0,$.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-fg`,children:i.title}),t[0]=i.title,t[1]=f);let p;t[2]===i.subtitle?p=t[3]:(p=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i.subtitle}),t[2]=i.subtitle,t[3]=p);let m;t[4]!==f||t[5]!==p?(m=(0,$.jsxs)(`div`,{className:`border-b border-edge-subtle px-6 pb-4 pt-6 dark:border-edge-subtle`,children:[f,p]}),t[4]=f,t[5]=p,t[6]=m):m=t[6];let h;t[7]===o.hubExtensionManageHint?h=t[8]:(h=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.hubExtensionManageHint}),t[7]=o.hubExtensionManageHint,t[8]=h);let g;t[9]===o.hubExtensionStatusLabel?g=t[10]:(g=(0,$.jsx)(`dt`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:o.hubExtensionStatusLabel}),t[9]=o.hubExtensionStatusLabel,t[10]=g);let _;t[11]===c?_=t[12]:(_=(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:c}),t[11]=c,t[12]=_);let v;t[13]!==g||t[14]!==_?(v=(0,$.jsxs)(`div`,{children:[g,_]}),t[13]=g,t[14]=_,t[15]=v):v=t[15];let y;t[16]===o.hubExtensionEnabledLabel?y=t[17]:(y=(0,$.jsx)(`dt`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:o.hubExtensionEnabledLabel}),t[16]=o.hubExtensionEnabledLabel,t[17]=y);let b=a.enabled?o.hubExtensionYes:o.hubExtensionNo,S;t[18]===b?S=t[19]:(S=(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:b}),t[18]=b,t[19]=S);let C;t[20]!==y||t[21]!==S?(C=(0,$.jsxs)(`div`,{children:[y,S]}),t[20]=y,t[21]=S,t[22]=C):C=t[22];let w;t[23]===o.hubExtensionConnectedLabel?w=t[24]:(w=(0,$.jsx)(`dt`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:o.hubExtensionConnectedLabel}),t[23]=o.hubExtensionConnectedLabel,t[24]=w);let T=a.connected?o.hubExtensionYes:o.hubExtensionNo,E;t[25]===T?E=t[26]:(E=(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:T}),t[25]=T,t[26]=E);let D;t[27]!==w||t[28]!==E?(D=(0,$.jsxs)(`div`,{children:[w,E]}),t[27]=w,t[28]=E,t[29]=D):D=t[29];let O;t[30]!==v||t[31]!==C||t[32]!==D?(O=(0,$.jsxs)(`dl`,{className:`grid gap-3 text-sm`,children:[v,C,D]}),t[30]=v,t[31]=C,t[32]=D,t[33]=O):O=t[33];let k;t[34]===s?k=t[35]:(k=x(s,`channels`),t[34]=s,t[35]=k);let A;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(z,{className:`ml-2 size-3.5`}),t[36]=A):A=t[36];let j;t[37]!==o.hubViewDocs||t[38]!==k?(j=(0,$.jsx)(L,{type:`button`,variant:`secondary`,asChild:!0,children:(0,$.jsxs)(`a`,{href:k,target:`_blank`,rel:`noreferrer`,children:[o.hubViewDocs,A]})}),t[37]=o.hubViewDocs,t[38]=k,t[39]=j):j=t[39];let M;t[40]!==O||t[41]!==j||t[42]!==h?(M=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[h,O,j]}),t[40]=O,t[41]=j,t[42]=h,t[43]=M):M=t[43];let N;return t[44]!==o.modalCancel||t[45]!==i.subtitle||t[46]!==i.title||t[47]!==r||t[48]!==n||t[49]!==M||t[50]!==m?(N=(0,$.jsx)(ze,{presentation:`modal`,open:n,onOpenChange:r,srTitle:l,srDescription:u,closeAriaLabel:d,headerExtra:m,children:M}),t[44]=o.modalCancel,t[45]=i.subtitle,t[46]=i.title,t[47]=r,t[48]=n,t[49]=M,t[50]=m,t[51]=N):N=t[51],N}var He=(0,Z.memo)(function(e){let t=(0,Q.c)(15),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,$.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s=n.refresh,c=n.refresh,l=r&&`animate-spin`,u;t[3]===l?u=t[4]:(u=H(`size-4`,l),t[3]=l,t[4]=u);let d;t[5]===u?d=t[6]:(d=(0,$.jsx)(B,{className:u,"aria-hidden":!0}),t[5]=u,t[6]=d);let f;t[7]!==n.refresh||t[8]!==a||t[9]!==r||t[10]!==d?(f=(0,$.jsx)(L,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:r,title:s,"aria-label":c,onClick:a,children:d}),t[7]=n.refresh,t[8]=a,t[9]=r,t[10]=d,t[11]=f):f=t[11];let p;return t[12]!==o||t[13]!==f?(p=(0,$.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,f]}),t[12]=o,t[13]=f,t[14]=p):p=t[14],p});function Ue(e){let t=(0,Q.c)(27),{accountIds:n,routes:r,defaultAgentId:o,agentItems:s,disabled:c,onChange:l,ch:u}=e,d=i(We),f,p,m,h,g;if(t[0]!==n||t[1]!==s||t[2]!==u||t[3]!==o||t[4]!==c||t[5]!==d||t[6]!==l||t[7]!==r){g=Symbol.for(`react.early_return_sentinel`);bb0:{let e=a(d).agentsSettings;if(n.length===0){g=null;break bb0}let i=s.length>0?s:[{id:o}];m=`space-y-3 border-t border-edge-subtle pt-4 dark:border-edge`;let _;t[13]===u.agentRoutingTitle?_=t[14]:(_=(0,$.jsx)(Y,{children:u.agentRoutingTitle}),t[13]=u.agentRoutingTitle,t[14]=_);let v;t[15]===u.agentRoutingHint?v=t[16]:(v=(0,$.jsx)(ce,{children:u.agentRoutingHint}),t[15]=u.agentRoutingHint,t[16]=v),t[17]!==_||t[18]!==v?(h=(0,$.jsxs)(`div`,{children:[_,v]}),t[17]=_,t[18]=v,t[19]=h):h=t[19],f=`space-y-2`,p=n.map(t=>(0,$.jsxs)(`div`,{className:`grid grid-cols-1 items-start gap-2 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2.5 sm:grid-cols-2 sm:items-center dark:border-edge`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.agentRoutingAccountLabel}),(0,$.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-sm text-fg`,title:t,children:t})]}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:`agent-route-${t}`,children:u.agentRoutingAgentLabel}),(0,$.jsx)(`select`,{id:`agent-route-${t}`,className:H(J(),E),disabled:c,value:(r[t]??o).toLowerCase(),onChange:e=>l(t,e.target.value),children:i.map(t=>(0,$.jsx)(`option`,{value:t.id,children:`${I(t,e)} (${t.id})`},t.id))})]})]},t))}t[0]=n,t[1]=s,t[2]=u,t[3]=o,t[4]=c,t[5]=d,t[6]=l,t[7]=r,t[8]=f,t[9]=p,t[10]=m,t[11]=h,t[12]=g}else f=t[8],p=t[9],m=t[10],h=t[11],g=t[12];if(g!==Symbol.for(`react.early_return_sentinel`))return g;let _;t[20]!==f||t[21]!==p?(_=(0,$.jsx)(`div`,{className:f,children:p}),t[20]=f,t[21]=p,t[22]=_):_=t[22];let v;return t[23]!==m||t[24]!==h||t[25]!==_?(v=(0,$.jsxs)(`div`,{className:m,children:[h,_]}),t[23]=m,t[24]=h,t[25]=_,t[26]=v):v=t[26],v}function We(e){return e.language}function Ge(e){return e===`telegram`?`pairing`:`open`}function Ke(e,t,n){return n?.dmPolicy?n.dmPolicy:t??Ge(e)}function qe(e,t){if(e===`telegram`){let e=Te(t);return e.length>0?e:[`default`]}if(e===`weixin`){let e=Ee(t);return e.length>0?e:[`default`]}let n=le(t);return n.length>0?n:[`default`]}function Je(e){return e?.enabled!==!1}function Ye(e,t,n){let r=t.accounts?.[n];return Ke(e,t.dmPolicy,r)}function Xe(e,t){return qe(e,t).some(n=>{let r=t.accounts?.[n];return Je(r)?Ye(e,t,n)===`pairing`:!1})}function Ze(e){return!e.configured||!e.channelEnabled||!e.usesPairing?0:e.summaryPending}function Qe(e){let{channel:t,accountId:n,messages:r,mutate:i,setCodeBySender:a,setBusySender:o,setFeedback:s}=e,c=(0,Z.useCallback)(async(e,t)=>{o(e),s(null);try{let n=await t();a(t=>{let n={...t};return delete n[e],n}),s({kind:`ok`,text:r.pairingApproved.replace(`{{id}}`,n.senderId)}),await i()}catch(e){let t=e instanceof Error?e.message:r.pairingInvalid;s({kind:`err`,text:t.includes(`PAIRING`)?r.pairingInvalid:t})}finally{o(null)}},[r.pairingApproved,r.pairingInvalid,i,o,a,s]);return{approveByCode:(0,Z.useCallback)((e,r)=>{let i=r.trim().toUpperCase();i&&c(e,()=>ue({channel:t,accountId:n,code:i}))},[n,t,c]),quickApprove:(0,Z.useCallback)(e=>{c(e,()=>ge({channel:t,accountId:n,senderId:e}))},[n,t,c])}}var $e=[`channels-pairing-requested`,`channels-pairing-refreshed`,`channels-pairing-approved`,`channels-pairing-revoked`,`channels-pairing-dismissed`],et=`channel-pairing-summary`;function tt(e){let t=()=>e();for(let e of $e)window.addEventListener(e,t);return()=>{for(let e of $e)window.removeEventListener(e,t)}}function nt(e,t){let n=(0,Q.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return tt(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,Z.useEffect)(i,a)}function rt(e){return`channel-pairing-${e}`}function it(e){requestAnimationFrame(()=>{document.getElementById(rt(e))?.scrollIntoView({behavior:`smooth`,block:`start`})})}function at(e,t){let n=Date.parse(e)-Date.now();if(!Number.isFinite(n))return e;let r=Math.max(1,Math.round(Math.abs(n)/6e4));if(n<=0)return t.startsWith(`zh`)?`已过期`:`expired`;if(r<60)return t.startsWith(`zh`)?`${r} 分钟后`:`in ${r} min`;let i=Math.round(r/60);return t.startsWith(`zh`)?`${i} 小时后`:`in ${i} h`}function ot(e,t){return`channel-pairing-${e}-${t}`}var st={codeBySender:{},busySender:null,dismissingId:null,revokingId:null,feedback:null};function ct(e,t){switch(t.type){case`setCodeBySender`:return{...e,codeBySender:t.updater(e.codeBySender)};case`setBusySender`:return{...e,busySender:t.value};case`setDismissingId`:return{...e,dismissingId:t.value};case`setRevokingId`:return{...e,revokingId:t.value};case`setFeedback`:return{...e,feedback:t.value};case`clearSenderCode`:{let n={...e.codeBySender};return delete n[t.senderId],{...e,codeBySender:n}}}}function lt({channel:e,accountIds:t,channelConfig:n,active:r,ch:i,language:a,onPairedChange:o}){let c=J,l=(0,Z.useMemo)(()=>{let e=(t??[`default`]).filter(Boolean);return e.length>0?e:[`default`]},[t]),u=(0,Z.useMemo)(()=>Xe(e,n),[e,n]),d=(0,Z.useCallback)(t=>Ye(e,n,t),[e,n]),[f,p]=(0,Z.useState)(l[0]??`default`),[m,h]=(0,Z.useState)(l);l!==m&&(h(l),l.includes(f)||p(l[0]??`default`));let[g,_]=(0,Z.useReducer)(ct,st),{codeBySender:v,busySender:y,dismissingId:b,revokingId:x,feedback:S}=g,C=d(f)===`pairing`,w=(0,Z.useRef)(o);w.current=o;let{data:T,error:E,isLoading:D,mutate:O}=s(r&&u&&C?ot(e,f):null,()=>de(e,f),{revalidateOnFocus:!0,onSuccess:e=>{w.current?.(e.paired.fromCredentials.length)}});nt((0,Z.useCallback)(()=>{O()},[O]),r&&u&&C);let k=T?.paired.fromCredentials??[],A=(0,Z.useCallback)(e=>{_({type:`setCodeBySender`,updater:typeof e==`function`?e:()=>e})},[]),j=(0,Z.useCallback)(e=>{_({type:`setBusySender`,value:typeof e==`function`?e(g.busySender):e})},[g.busySender]),N=(0,Z.useCallback)(e=>{_({type:`setFeedback`,value:typeof e==`function`?e(g.feedback):e})},[g.feedback]),{approveByCode:P,quickApprove:ee}=Qe({channel:e,accountId:f,messages:{pairingApproved:i.pairingApproved,pairingInvalid:i.pairingInvalid},mutate:O,setCodeBySender:A,setBusySender:j,setFeedback:N}),F=(0,Z.useCallback)(async t=>{_({type:`setDismissingId`,value:t}),_({type:`setFeedback`,value:null});try{await be({channel:e,accountId:f,senderId:t}),_({type:`clearSenderCode`,senderId:t}),_({type:`setFeedback`,value:{kind:`ok`,text:i.pairingDismissed.replace(`{{id}}`,t)}}),await O()}catch(e){_({type:`setFeedback`,value:{kind:`err`,text:e instanceof Error?e.message:i.pairingDismissError}})}finally{_({type:`setDismissingId`,value:null})}},[f,e,i.pairingDismissed,i.pairingDismissError,O]),I=(0,Z.useCallback)(async t=>{_({type:`setRevokingId`,value:t}),_({type:`setFeedback`,value:null});try{await me({channel:e,accountId:f,senderId:t}),_({type:`setFeedback`,value:{kind:`ok`,text:i.pairingRevoked.replace(`{{id}}`,t)}}),await O()}catch(e){_({type:`setFeedback`,value:{kind:`err`,text:e instanceof Error?e.message:i.pairingRevokeError}})}finally{_({type:`setRevokingId`,value:null})}},[f,e,i.pairingRevoked,i.pairingRevokeError,O]);if(!u)return null;if(!C)return(0,$.jsxs)(`div`,{id:rt(e),className:`space-y-2 rounded-xl border border-edge-subtle bg-surface-base/50 p-4 dark:border-edge`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.pairingTitle}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.pairingAccountNotPairing.replace(`{{account}}`,f)}),l.length>1?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:i.pairingAccountLabel}),(0,$.jsx)(`select`,{className:c(),value:f,onChange:e=>p(e.target.value),children:l.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))})]}):null]});let R=T?.pending??[],te=T?.paired.fromConfig??[];return(0,$.jsxs)(`div`,{id:rt(e),className:`space-y-3 rounded-xl border border-edge-subtle bg-surface-base/50 p-4 dark:border-edge`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:i.pairingTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:i.pairingSubtitle})]}),(0,$.jsx)(L,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":i.pairingRefresh,disabled:D,onClick:()=>void O(),children:(0,$.jsx)(B,{className:H(`size-4 text-fg-muted`,D&&`animate-spin`)})})]}),l.length>1?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:i.pairingAccountLabel}),(0,$.jsx)(`select`,{className:c(),value:f,onChange:e=>p(e.target.value),children:l.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))})]}):null,(0,$.jsx)(ce,{children:i.pairingSetupHint}),E?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:i.pairingLoadError}):null,S?(0,$.jsx)(`p`,{className:H(`text-xs`,S.kind===`ok`?`text-success`:`text-red-600 dark:text-red-400`),children:S.text}):null,(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{children:i.pairingPendingTitle}),R.length>0?(0,$.jsx)(ce,{children:i.pairingQuickApproveHint}):null,R.length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.pairingPendingEmpty}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:R.map(e=>{let t=v[e.senderId]??``,n=y===e.senderId,r=b===e.senderId;return(0,$.jsxs)(`li`,{className:H(`rounded-lg border bg-surface-panel p-3 dark:border-edge`,e.isStale?`border-amber-300/50 dark:border-amber-800/50`:`border-edge`),children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-xs text-fg`,children:e.senderId}),(0,$.jsxs)(`span`,{className:`text-[11px] text-fg-muted`,children:[e.isStale?(0,$.jsx)(`span`,{className:`text-amber-800 dark:text-amber-200`,children:i.pairingStaleItem}):null,e.isStale?` · `:null,i.pairingExpiresHint.replace(`{{time}}`,at(e.expiresAt,a))]})]}),e.codeLast4?(0,$.jsx)(`p`,{className:`mt-1 text-[11px] text-fg-muted`,children:i.pairingCodeHint.replace(`{{suffix}}`,e.codeLast4)}):null,(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,$.jsx)(L,{type:`button`,variant:`secondary`,className:`shrink-0 text-xs`,disabled:n||r,onClick:()=>void ee(e.senderId),children:n?i.pairingApproving:i.pairingQuickApprove}),(0,$.jsx)(`input`,{className:H(c(),`min-w-0 flex-1 font-mono text-xs uppercase`),value:t,autoComplete:`off`,spellCheck:!1,maxLength:8,placeholder:i.pairingCodePlaceholder,onChange:t=>A(n=>({...n,[e.senderId]:t.target.value.toUpperCase()})),onKeyDown:n=>{n.key===`Enter`&&P(e.senderId,t)}}),(0,$.jsx)(L,{type:`button`,variant:`primary`,className:`shrink-0 text-xs`,disabled:n||r||!t.trim(),onClick:()=>P(e.senderId,t),children:n?i.pairingApproving:i.pairingApprove}),(0,$.jsx)(L,{type:`button`,variant:`ghost`,className:`shrink-0 text-xs text-fg-muted hover:text-danger`,disabled:n||r,onClick:()=>void F(e.senderId),children:r?i.pairingDismissing:i.pairingDismiss})]})]},e.senderId)})})]}),(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle pt-3 dark:border-edge-subtle`,children:[(0,$.jsx)(Y,{children:i.pairedTitle}),(0,$.jsxs)(`div`,{className:`grid gap-3 text-xs sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,children:i.pairedFromConfig}),(0,$.jsx)(`p`,{className:`mt-0.5 font-mono text-fg`,children:te.length?te.join(`, `):i.pairedEmpty})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,children:i.pairedFromCredentials}),k.length===0?(0,$.jsx)(`p`,{className:`mt-0.5 font-mono text-fg`,children:i.pairedEmpty}):(0,$.jsx)(`ul`,{className:`mt-1 space-y-1`,children:k.map(e=>(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-fg`,children:e}),(0,$.jsx)(L,{type:`button`,variant:`ghost`,className:`size-7 shrink-0 p-0 text-fg-muted hover:text-danger`,"aria-label":i.pairingRevokeAria.replace(`{{id}}`,e),disabled:x===e,onClick:()=>void I(e),children:(0,$.jsx)(M,{className:`size-3.5`})})]},e))})]})]})]})]})}function ut(e){let t=(0,Q.c)(347),{ch:n,form:r,baseline:i,showFeishuWebhookSecrets:a,setShowFeishuWebhookSecrets:o,feishuWebhookCopied:s,copyFeishuWebhookConfig:l,updateFeishu:u,updateChannelAgentRoute:f,feishuAccountsDraft:p,setFeishuAccountsDraft:m,feishuAccountsError:h,onFeishuAccountsBlur:g,dmOpts:_,groupOpts:v,chatAgents:y,saving:b,language:x,dialogOpen:S,pairingFocus:C}=e,E=C===void 0?!1:C,D=r.feishu,k;t[0]===D?k=t[1]:(k=le(D),t[0]=D,t[1]=k);let A=k,j;t[2]===A?j=t[3]:(j=A.length>0?A:[`default`],t[2]=A,t[3]=j);let M=j,N=i?.feishu?.appSecret??``,P;t[4]!==n.copied||t[5]!==n.copy||t[6]!==n.hide||t[7]!==n.show?(P=w({show:n.show,hide:n.hide,copy:n.copy,copied:n.copied}),t[4]=n.copied,t[5]=n.copy,t[6]=n.hide,t[7]=n.show,t[8]=P):P=t[8];let F=P,I=(0,Z.useRef)(null),R,ne;t[9]===E?(R=t[10],ne=t[11]):(R=()=>{if(!E)return;let e=I.current;e&&(e.open=!0);let t=window.setTimeout(pt,80);return()=>window.clearTimeout(t)},ne=[E],t[9]=E,t[10]=R,t[11]=ne),(0,Z.useEffect)(R,ne);let z;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(ee,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),t[12]=z):z=t[12];let B;t[13]===n.advancedShow?B=t[14]:(B=(0,$.jsx)(`summary`,{className:`cursor-pointer list-none rounded-xl px-3 py-2.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[z,n.advancedShow]})}),t[13]=n.advancedShow,t[14]=B);let V;t[15]===n.feishuAdvancedHint?V=t[16]:(V=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:n.feishuAdvancedHint}),t[15]=n.feishuAdvancedHint,t[16]=V);let U;t[17]===u?U=t[18]:(U=e=>u({enabled:e.target.checked}),t[17]=u,t[18]=U);let W;t[19]!==D.enabled||t[20]!==U?(W=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:D.enabled,onChange:U}),t[19]=D.enabled,t[20]=U,t[21]=W):W=t[21];let G;t[22]===n.enableFeishuAria?G=t[23]:(G=(0,$.jsx)(`span`,{children:n.enableFeishuAria}),t[22]=n.enableFeishuAria,t[23]=G);let K;t[24]!==W||t[25]!==G?(K=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[W,G]}),t[24]=W,t[25]=G,t[26]=K):K=t[26];let re;t[27]===u?re=t[28]:(re=e=>u({dmPolicy:e}),t[27]=u,t[28]=re);let q;t[29]!==n.dmPolicy||t[30]!==_||t[31]!==D.dmPolicy||t[32]!==re?(q=(0,$.jsx)(se,{label:n.dmPolicy,value:D.dmPolicy,onChange:re,options:_}),t[29]=n.dmPolicy,t[30]=_,t[31]=D.dmPolicy,t[32]=re,t[33]=q):q=t[33];let ae;t[34]!==n||t[35]!==S||t[36]!==D||t[37]!==x||t[38]!==M?(ae=(0,$.jsx)(lt,{channel:`feishu`,accountIds:M,channelConfig:D,active:S,ch:n,language:x}),t[34]=n,t[35]=S,t[36]=D,t[37]=x,t[38]=M,t[39]=ae):ae=t[39];let ue;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[40]=ue):ue=t[40];let de;t[41]===n.feishuAppId?de=t[42]:(de=(0,$.jsxs)(Y,{children:[n.feishuAppId,ue]}),t[41]=n.feishuAppId,t[42]=de);let fe;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(fe=H(J(),`min-w-0 flex-1 font-mono text-xs`),t[43]=fe):fe=t[43];let pe;t[44]===u?pe=t[45]:(pe=e=>u({appId:e.target.value}),t[44]=u,t[45]=pe);let me;t[46]!==D.appId||t[47]!==pe?(me=(0,$.jsx)(`input`,{className:fe,value:D.appId,onChange:pe,placeholder:`cli_xxx`}),t[46]=D.appId,t[47]=pe,t[48]=me):me=t[48];let he;t[49]===n.feishuAppIdDesc?he=t[50]:(he=(0,$.jsx)(ce,{children:n.feishuAppIdDesc}),t[49]=n.feishuAppIdDesc,t[50]=he);let ge;t[51]!==de||t[52]!==me||t[53]!==he?(ge=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[de,me,he]}),t[51]=de,t[52]=me,t[53]=he,t[54]=ge):ge=t[54];let _e;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[55]=_e):_e=t[55];let ve;t[56]===n.feishuAppSecret?ve=t[57]:(ve=(0,$.jsxs)(Y,{children:[n.feishuAppSecret,_e]}),t[56]=n.feishuAppSecret,t[57]=ve);let ye=D.appSecret,be;t[58]===u?be=t[59]:(be=e=>u({appSecret:e}),t[58]=u,t[59]=be);let xe;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(xe=H(J(),`text-xs`),t[60]=xe):xe=t[60];let X;t[61]!==N||t[62]!==D.appSecret||t[63]!==F||t[64]!==be?(X=(0,$.jsx)(T,{value:ye,onChange:be,placeholder:`••••••••`,labels:F,baselineValue:N,inputClassName:xe}),t[61]=N,t[62]=D.appSecret,t[63]=F,t[64]=be,t[65]=X):X=t[65];let Se;t[66]===n.feishuAppSecretDesc?Se=t[67]:(Se=(0,$.jsx)(ce,{children:n.feishuAppSecretDesc}),t[66]=n.feishuAppSecretDesc,t[67]=Se);let Ce;t[68]!==ve||t[69]!==X||t[70]!==Se?(Ce=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[ve,X,Se]}),t[68]=ve,t[69]=X,t[70]=Se,t[71]=Ce):Ce=t[71];let we;t[72]===n.feishuDomain?we=t[73]:(we=(0,$.jsx)(Y,{children:n.feishuDomain}),t[72]=n.feishuDomain,t[73]=we);let Te;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(Te=J(),t[74]=Te):Te=t[74];let Ee=String(D.domain||`feishu`),De;t[75]===u?De=t[76]:(De=e=>u({domain:e.target.value}),t[75]=u,t[76]=De);let Oe,ke;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,$.jsx)(`option`,{value:`feishu`,children:`feishu`}),ke=(0,$.jsx)(`option`,{value:`lark`,children:`lark`}),t[77]=Oe,t[78]=ke):(Oe=t[77],ke=t[78]);let Ae;t[79]!==Ee||t[80]!==De?(Ae=(0,$.jsxs)(`select`,{className:Te,value:Ee,onChange:De,children:[Oe,ke]}),t[79]=Ee,t[80]=De,t[81]=Ae):Ae=t[81];let je;t[82]!==we||t[83]!==Ae?(je=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[we,Ae]}),t[82]=we,t[83]=Ae,t[84]=je):je=t[84];let Me;t[85]===n.connectionMode?Me=t[86]:(Me=(0,$.jsx)(Y,{children:n.connectionMode}),t[85]=n.connectionMode,t[86]=Me);let Ne;t[87]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=J(),t[87]=Ne):Ne=t[87];let Pe;t[88]===u?Pe=t[89]:(Pe=e=>u({connectionMode:e.target.value}),t[88]=u,t[89]=Pe);let Fe,Ie;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=(0,$.jsx)(`option`,{value:`websocket`,children:`websocket`}),Ie=(0,$.jsx)(`option`,{value:`webhook`,children:`webhook`}),t[90]=Fe,t[91]=Ie):(Fe=t[90],Ie=t[91]);let Le;t[92]!==D.connectionMode||t[93]!==Pe?(Le=(0,$.jsxs)(`select`,{className:Ne,value:D.connectionMode,onChange:Pe,children:[Fe,Ie]}),t[92]=D.connectionMode,t[93]=Pe,t[94]=Le):Le=t[94];let Re;t[95]===n.connectionModeDesc?Re=t[96]:(Re=(0,$.jsx)(ce,{children:n.connectionModeDesc}),t[95]=n.connectionModeDesc,t[96]=Re);let ze;t[97]!==Me||t[98]!==Le||t[99]!==Re?(ze=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Me,Le,Re]}),t[97]=Me,t[98]=Le,t[99]=Re,t[100]=ze):ze=t[100];let Be;t[101]!==je||t[102]!==ze?(Be=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[je,ze]}),t[101]=je,t[102]=ze,t[103]=Be):Be=t[103];let Ve;t[104]!==n.copied||t[105]!==n.copy||t[106]!==n.encryptKey||t[107]!==n.encryptKeyDesc||t[108]!==n.hide||t[109]!==n.show||t[110]!==n.verificationToken||t[111]!==n.verificationTokenDesc||t[112]!==n.webhookHost||t[113]!==n.webhookPath||t[114]!==n.webhookPathDesc||t[115]!==n.webhookPort||t[116]!==n.webhookTitle||t[117]!==l||t[118]!==s||t[119]!==D.connectionMode||t[120]!==D.encryptKey||t[121]!==D.verificationToken||t[122]!==D.webhookHost||t[123]!==D.webhookPath||t[124]!==D.webhookPort||t[125]!==o||t[126]!==a||t[127]!==u?(Ve=D.connectionMode===`webhook`?(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.webhookTitle}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(L,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>o(ft),children:[a?(0,$.jsx)(te,{className:`size-3.5`}):(0,$.jsx)(O,{className:`size-3.5`}),a?n.hide:n.show]}),(0,$.jsxs)(L,{type:`button`,variant:`secondary`,className:`px-2 py-1 text-xs`,onClick:()=>void l(),children:[s?(0,$.jsx)(d,{className:`size-3.5`}):(0,$.jsx)(c,{className:`size-3.5`}),s?n.copied:n.copy]})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:n.verificationToken}),(0,$.jsx)(`input`,{className:H(J(),`min-w-0 flex-1 font-mono text-xs`),type:a?`text`:`password`,autoComplete:`off`,value:D.verificationToken??``,onChange:e=>u({verificationToken:e.target.value})}),(0,$.jsx)(ce,{children:n.verificationTokenDesc})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:n.encryptKey}),(0,$.jsx)(`input`,{className:H(J(),`min-w-0 flex-1 font-mono text-xs`),type:a?`text`:`password`,autoComplete:`off`,value:D.encryptKey??``,onChange:e=>u({encryptKey:e.target.value})}),(0,$.jsx)(ce,{children:n.encryptKeyDesc})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:col-span-2`,children:[(0,$.jsx)(Y,{children:n.webhookHost}),(0,$.jsx)(`input`,{className:H(J(),`min-w-0 flex-1 font-mono text-xs`),value:D.webhookHost??``,onChange:e=>u({webhookHost:e.target.value}),placeholder:`127.0.0.1`})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:n.webhookPort}),(0,$.jsx)(`input`,{className:H(J(),`min-w-0 flex-1 font-mono text-xs`),type:`number`,inputMode:`numeric`,value:String(D.webhookPort??``),onChange:e=>u({webhookPort:Number(e.target.value||`0`)||0}),placeholder:`3000`})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,$.jsx)(Y,{children:n.webhookPath}),(0,$.jsx)(`input`,{className:H(J(),`min-w-0 flex-1 font-mono text-xs`),value:D.webhookPath??``,onChange:e=>u({webhookPath:e.target.value}),placeholder:`/feishu/events`}),(0,$.jsx)(ce,{children:n.webhookPathDesc})]})]}):null,t[104]=n.copied,t[105]=n.copy,t[106]=n.encryptKey,t[107]=n.encryptKeyDesc,t[108]=n.hide,t[109]=n.show,t[110]=n.verificationToken,t[111]=n.verificationTokenDesc,t[112]=n.webhookHost,t[113]=n.webhookPath,t[114]=n.webhookPathDesc,t[115]=n.webhookPort,t[116]=n.webhookTitle,t[117]=l,t[118]=s,t[119]=D.connectionMode,t[120]=D.encryptKey,t[121]=D.verificationToken,t[122]=D.webhookHost,t[123]=D.webhookPath,t[124]=D.webhookPort,t[125]=o,t[126]=a,t[127]=u,t[128]=Ve):Ve=t[128];let He;t[129]===n.renderMode?He=t[130]:(He=(0,$.jsx)(Y,{children:n.renderMode}),t[129]=n.renderMode,t[130]=He);let We;t[131]===Symbol.for(`react.memo_cache_sentinel`)?(We=J(),t[131]=We):We=t[131];let Ge;t[132]===u?Ge=t[133]:(Ge=e=>u({renderMode:e.target.value}),t[132]=u,t[133]=Ge);let Ke,qe,Je;t[134]===Symbol.for(`react.memo_cache_sentinel`)?(Ke=(0,$.jsx)(`option`,{value:`auto`,children:`auto`}),qe=(0,$.jsx)(`option`,{value:`raw`,children:`raw`}),Je=(0,$.jsx)(`option`,{value:`card`,children:`card`}),t[134]=Ke,t[135]=qe,t[136]=Je):(Ke=t[134],qe=t[135],Je=t[136]);let Ye;t[137]!==D.renderMode||t[138]!==Ge?(Ye=(0,$.jsxs)(`select`,{className:We,value:D.renderMode,onChange:Ge,children:[Ke,qe,Je]}),t[137]=D.renderMode,t[138]=Ge,t[139]=Ye):Ye=t[139];let Xe;t[140]!==He||t[141]!==Ye?(Xe=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[He,Ye]}),t[140]=He,t[141]=Ye,t[142]=Xe):Xe=t[142];let Ze;t[143]===n.reactionNotifications?Ze=t[144]:(Ze=(0,$.jsx)(Y,{children:n.reactionNotifications}),t[143]=n.reactionNotifications,t[144]=Ze);let Qe;t[145]===Symbol.for(`react.memo_cache_sentinel`)?(Qe=J(),t[145]=Qe):Qe=t[145];let $e;t[146]===u?$e=t[147]:($e=e=>u({reactionNotifications:e.target.value}),t[146]=u,t[147]=$e);let et,tt,nt;t[148]===Symbol.for(`react.memo_cache_sentinel`)?(et=(0,$.jsx)(`option`,{value:`off`,children:`off`}),tt=(0,$.jsx)(`option`,{value:`own`,children:`own`}),nt=(0,$.jsx)(`option`,{value:`all`,children:`all`}),t[148]=et,t[149]=tt,t[150]=nt):(et=t[148],tt=t[149],nt=t[150]);let rt;t[151]!==D.reactionNotifications||t[152]!==$e?(rt=(0,$.jsxs)(`select`,{className:Qe,value:D.reactionNotifications,onChange:$e,children:[et,tt,nt]}),t[151]=D.reactionNotifications,t[152]=$e,t[153]=rt):rt=t[153];let it;t[154]!==Ze||t[155]!==rt?(it=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ze,rt]}),t[154]=Ze,t[155]=rt,t[156]=it):it=t[156];let at;t[157]!==Xe||t[158]!==it?(at=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Xe,it]}),t[157]=Xe,t[158]=it,t[159]=at):at=t[159];let ot;t[160]===u?ot=t[161]:(ot=e=>u({streaming:e.target.checked}),t[160]=u,t[161]=ot);let st;t[162]!==D.streaming||t[163]!==ot?(st=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:D.streaming,onChange:ot}),t[162]=D.streaming,t[163]=ot,t[164]=st):st=t[164];let ct;t[165]!==n.enableStreaming||t[166]!==st?(ct=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[st,n.enableStreaming]}),t[165]=n.enableStreaming,t[166]=st,t[167]=ct):ct=t[167];let ut;t[168]===n.groupPolicy?ut=t[169]:(ut=(0,$.jsx)(Y,{children:n.groupPolicy}),t[168]=n.groupPolicy,t[169]=ut);let mt;t[170]===Symbol.for(`react.memo_cache_sentinel`)?(mt=J(),t[170]=mt):mt=t[170];let ht=D.groupPolicy,gt;t[171]===u?gt=t[172]:(gt=e=>u({groupPolicy:e.target.value}),t[171]=u,t[172]=gt);let _t;t[173]===v?_t=t[174]:(_t=v.map(dt),t[173]=v,t[174]=_t);let vt;t[175]!==D.groupPolicy||t[176]!==gt||t[177]!==_t?(vt=(0,$.jsx)(`select`,{className:mt,value:ht,onChange:gt,children:_t}),t[175]=D.groupPolicy,t[176]=gt,t[177]=_t,t[178]=vt):vt=t[178];let yt;t[179]!==ut||t[180]!==vt?(yt=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[ut,vt]}),t[179]=ut,t[180]=vt,t[181]=yt):yt=t[181];let bt;t[182]===u?bt=t[183]:(bt=e=>u({requireMention:e.target.checked}),t[182]=u,t[183]=bt);let xt;t[184]!==D.requireMention||t[185]!==bt?(xt=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:D.requireMention,onChange:bt}),t[184]=D.requireMention,t[185]=bt,t[186]=xt):xt=t[186];let St;t[187]!==n.requireMention||t[188]!==xt?(St=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[xt,n.requireMention]}),t[187]=n.requireMention,t[188]=xt,t[189]=St):St=t[189];let Ct;t[190]===n.allowFromDm?Ct=t[191]:(Ct=(0,$.jsx)(Y,{children:n.allowFromDm}),t[190]=n.allowFromDm,t[191]=Ct);let wt;t[192]===Symbol.for(`react.memo_cache_sentinel`)?(wt=H(J(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[192]=wt):wt=t[192];let Tt;t[193]===D.allowFrom?Tt=t[194]:(Tt=ie(D.allowFrom),t[193]=D.allowFrom,t[194]=Tt);let Et;t[195]===u?Et=t[196]:(Et=e=>u({allowFrom:oe(e.target.value)}),t[195]=u,t[196]=Et);let Dt;t[197]!==Tt||t[198]!==Et?(Dt=(0,$.jsx)(`textarea`,{className:wt,rows:2,placeholder:`ou_xxx, on_xxx`,value:Tt,onChange:Et}),t[197]=Tt,t[198]=Et,t[199]=Dt):Dt=t[199];let Ot;t[200]===n.allowFromDmDesc?Ot=t[201]:(Ot=(0,$.jsx)(ce,{children:n.allowFromDmDesc}),t[200]=n.allowFromDmDesc,t[201]=Ot);let kt;t[202]!==Ct||t[203]!==Dt||t[204]!==Ot?(kt=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ct,Dt,Ot]}),t[202]=Ct,t[203]=Dt,t[204]=Ot,t[205]=kt):kt=t[205];let At;t[206]===n.allowFromGroups?At=t[207]:(At=(0,$.jsx)(Y,{children:n.allowFromGroups}),t[206]=n.allowFromGroups,t[207]=At);let jt;t[208]===Symbol.for(`react.memo_cache_sentinel`)?(jt=H(J(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[208]=jt):jt=t[208];let Mt;t[209]===D.groupAllowFrom?Mt=t[210]:(Mt=ie(D.groupAllowFrom),t[209]=D.groupAllowFrom,t[210]=Mt);let Nt;t[211]===u?Nt=t[212]:(Nt=e=>u({groupAllowFrom:oe(e.target.value)}),t[211]=u,t[212]=Nt);let Pt;t[213]!==Mt||t[214]!==Nt?(Pt=(0,$.jsx)(`textarea`,{className:jt,rows:2,placeholder:`oc_xxx, oc_yyy`,value:Mt,onChange:Nt}),t[213]=Mt,t[214]=Nt,t[215]=Pt):Pt=t[215];let Ft;t[216]===n.allowFromGroupsDesc?Ft=t[217]:(Ft=(0,$.jsx)(ce,{children:n.allowFromGroupsDesc}),t[216]=n.allowFromGroupsDesc,t[217]=Ft);let It;t[218]!==At||t[219]!==Pt||t[220]!==Ft?(It=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[At,Pt,Ft]}),t[218]=At,t[219]=Pt,t[220]=Ft,t[221]=It):It=t[221];let Lt;t[222]===n.historyLimit?Lt=t[223]:(Lt=(0,$.jsx)(Y,{children:n.historyLimit}),t[222]=n.historyLimit,t[223]=Lt);let Rt;t[224]===Symbol.for(`react.memo_cache_sentinel`)?(Rt=H(J(),`min-w-0 flex-1 font-mono text-xs`),t[224]=Rt):Rt=t[224];let zt=String(D.historyLimit),Bt;t[225]===u?Bt=t[226]:(Bt=e=>u({historyLimit:Number(e.target.value||`0`)||0}),t[225]=u,t[226]=Bt);let Vt;t[227]!==zt||t[228]!==Bt?(Vt=(0,$.jsx)(`input`,{className:Rt,type:`number`,inputMode:`numeric`,value:zt,onChange:Bt}),t[227]=zt,t[228]=Bt,t[229]=Vt):Vt=t[229];let Ht;t[230]!==Lt||t[231]!==Vt?(Ht=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Lt,Vt]}),t[230]=Lt,t[231]=Vt,t[232]=Ht):Ht=t[232];let Ut;t[233]===n.textChunkLimit?Ut=t[234]:(Ut=(0,$.jsx)(Y,{children:n.textChunkLimit}),t[233]=n.textChunkLimit,t[234]=Ut);let Wt;t[235]===Symbol.for(`react.memo_cache_sentinel`)?(Wt=H(J(),`min-w-0 flex-1 font-mono text-xs`),t[235]=Wt):Wt=t[235];let Gt=String(D.textChunkLimit),Kt;t[236]===u?Kt=t[237]:(Kt=e=>u({textChunkLimit:Number(e.target.value||`0`)||0}),t[236]=u,t[237]=Kt);let qt;t[238]!==Gt||t[239]!==Kt?(qt=(0,$.jsx)(`input`,{className:Wt,type:`number`,inputMode:`numeric`,value:Gt,onChange:Kt}),t[238]=Gt,t[239]=Kt,t[240]=qt):qt=t[240];let Jt;t[241]!==Ut||t[242]!==qt?(Jt=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ut,qt]}),t[241]=Ut,t[242]=qt,t[243]=Jt):Jt=t[243];let Yt;t[244]!==Jt||t[245]!==Ht?(Yt=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Ht,Jt]}),t[244]=Jt,t[245]=Ht,t[246]=Yt):Yt=t[246];let Xt;t[247]===n.feishuToolsTitle?Xt=t[248]:(Xt=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.feishuToolsTitle}),t[247]=n.feishuToolsTitle,t[248]=Xt);let Zt;t[249]===n.feishuToolDoc?Zt=t[250]:(Zt=[`doc`,n.feishuToolDoc],t[249]=n.feishuToolDoc,t[250]=Zt);let Qt;t[251]===n.feishuToolWiki?Qt=t[252]:(Qt=[`wiki`,n.feishuToolWiki],t[251]=n.feishuToolWiki,t[252]=Qt);let $t;t[253]===n.feishuToolDrive?$t=t[254]:($t=[`drive`,n.feishuToolDrive],t[253]=n.feishuToolDrive,t[254]=$t);let en;t[255]===n.feishuToolPerm?en=t[256]:(en=[`perm`,n.feishuToolPerm],t[255]=n.feishuToolPerm,t[256]=en);let tn;t[257]===n.feishuToolBitable?tn=t[258]:(tn=[`bitable`,n.feishuToolBitable],t[257]=n.feishuToolBitable,t[258]=tn);let nn;t[259]===n.feishuToolScopes?nn=t[260]:(nn=[`scopes`,n.feishuToolScopes],t[259]=n.feishuToolScopes,t[260]=nn);let rn;t[261]!==Zt||t[262]!==Qt||t[263]!==$t||t[264]!==en||t[265]!==tn||t[266]!==nn?(rn=[Zt,Qt,$t,en,tn,nn],t[261]=Zt,t[262]=Qt,t[263]=$t,t[264]=en,t[265]=tn,t[266]=nn,t[267]=rn):rn=t[267];let an=rn,on;t[268]!==D.tools||t[269]!==an||t[270]!==u?(on=(0,$.jsx)(`div`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:an.map(e=>{let[t,n]=e;return(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:!!D.tools?.[t],onChange:e=>u({tools:{...D.tools,[t]:e.target.checked}})}),n]},t)})}),t[268]=D.tools,t[269]=an,t[270]=u,t[271]=on):on=t[271];let sn;t[272]===n.feishuToolsDesc?sn=t[273]:(sn=(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsx)(ce,{children:n.feishuToolsDesc})}),t[272]=n.feishuToolsDesc,t[273]=sn);let cn;t[274]!==Xt||t[275]!==on||t[276]!==sn?(cn=(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[Xt,on,sn]}),t[274]=Xt,t[275]=on,t[276]=sn,t[277]=cn):cn=t[277];let ln;t[278]===n.feishuActionsTitle?ln=t[279]:(ln=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.feishuActionsTitle}),t[278]=n.feishuActionsTitle,t[279]=ln);let un=!!D.actions?.reactions,dn;t[280]!==D.actions||t[281]!==u?(dn=e=>u({actions:{...D.actions,reactions:e.target.checked}}),t[280]=D.actions,t[281]=u,t[282]=dn):dn=t[282];let fn;t[283]!==un||t[284]!==dn?(fn=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:un,onChange:dn}),t[283]=un,t[284]=dn,t[285]=fn):fn=t[285];let pn;t[286]!==n.feishuActionReactions||t[287]!==fn?(pn=(0,$.jsxs)(`label`,{className:`mt-2 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[fn,n.feishuActionReactions]}),t[286]=n.feishuActionReactions,t[287]=fn,t[288]=pn):pn=t[288];let mn;t[289]!==ln||t[290]!==pn?(mn=(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface px-4 py-3 dark:border-edge-subtle`,children:[ln,pn]}),t[289]=ln,t[290]=pn,t[291]=mn):mn=t[291];let hn;t[292]===D?hn=t[293]:(hn=le(D),t[292]=D,t[293]=hn);let gn;t[294]===y?.items?gn=t[295]:(gn=y?.items??[],t[294]=y?.items,t[295]=gn);let _n;t[296]===f?_n=t[297]:(_n=(e,t)=>f(`feishu`,e,t),t[296]=f,t[297]=_n);let vn;t[298]!==n||t[299]!==r.channelAgentRoutes.feishu||t[300]!==r.defaultAgentId||t[301]!==b||t[302]!==hn||t[303]!==gn||t[304]!==_n?(vn=(0,$.jsx)(Ue,{accountIds:hn,routes:r.channelAgentRoutes.feishu,defaultAgentId:r.defaultAgentId,agentItems:gn,disabled:b,onChange:_n,ch:n}),t[298]=n,t[299]=r.channelAgentRoutes.feishu,t[300]=r.defaultAgentId,t[301]=b,t[302]=hn,t[303]=gn,t[304]=_n,t[305]=vn):vn=t[305];let yn;t[306]===n.multiAccountJson?yn=t[307]:(yn=(0,$.jsx)(Y,{children:n.multiAccountJson}),t[306]=n.multiAccountJson,t[307]=yn);let bn;t[308]===Symbol.for(`react.memo_cache_sentinel`)?(bn=H(J(),`min-h-[140px] resize-y font-mono text-xs`),t[308]=bn):bn=t[308];let xn;t[309]===m?xn=t[310]:(xn=e=>m(e.target.value),t[309]=m,t[310]=xn);let Sn;t[311]!==p||t[312]!==g||t[313]!==xn?(Sn=(0,$.jsx)(`textarea`,{className:bn,spellCheck:!1,value:p,onChange:xn,onBlur:g,placeholder:`{ "default": { "appId": "...", "appSecret": "...", "enabled": true } }`}),t[311]=p,t[312]=g,t[313]=xn,t[314]=Sn):Sn=t[314];let Cn;t[315]!==n.multiAccountJsonDesc||t[316]!==h?(Cn=h?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:h}):(0,$.jsx)(ce,{children:n.multiAccountJsonDesc}),t[315]=n.multiAccountJsonDesc,t[316]=h,t[317]=Cn):Cn=t[317];let wn;t[318]!==yn||t[319]!==Sn||t[320]!==Cn?(wn=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[yn,Sn,Cn]}),t[318]=yn,t[319]=Sn,t[320]=Cn,t[321]=wn):wn=t[321];let Tn;t[322]!==Yt||t[323]!==cn||t[324]!==mn||t[325]!==vn||t[326]!==wn||t[327]!==ge||t[328]!==Ce||t[329]!==Be||t[330]!==Ve||t[331]!==at||t[332]!==ct||t[333]!==yt||t[334]!==St||t[335]!==kt||t[336]!==It?(Tn=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[ge,Ce,Be,Ve,at,ct,yt,St,kt,It,Yt,cn,mn,vn,wn]}),t[322]=Yt,t[323]=cn,t[324]=mn,t[325]=vn,t[326]=wn,t[327]=ge,t[328]=Ce,t[329]=Be,t[330]=Ve,t[331]=at,t[332]=ct,t[333]=yt,t[334]=St,t[335]=kt,t[336]=It,t[337]=Tn):Tn=t[337];let En;t[338]!==K||t[339]!==Tn||t[340]!==q||t[341]!==ae||t[342]!==V?(En=(0,$.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[V,K,q,ae,Tn]}),t[338]=K,t[339]=Tn,t[340]=q,t[341]=ae,t[342]=V,t[343]=En):En=t[343];let Dn;return t[344]!==En||t[345]!==B?(Dn=(0,$.jsxs)(`details`,{ref:I,className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[B,En]}),t[344]=En,t[345]=B,t[346]=Dn):Dn=t[346],Dn}function dt(e){return(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value)}function ft(e){return!e}function pt(){return it(`feishu`)}var mt=e(X(),1);function ht(e){let t=(0,Q.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,$.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,$.jsx)(L,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,$.jsx)(L,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,$.jsx)(L,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,$.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}var gt={width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}},_t={sessionKey:null,qrUrl:null};function vt({ch:e,onSetupSuccess:t,onOpenChange:n,closeOnSetupSuccess:r,moreSettings:i}){let[a,o]=(0,Z.useState)(`feishu`),[s,c]=(0,Z.useState)(0),[l,u]=(0,Z.useState)(null),d=(0,Z.useRef)(t),f=(0,Z.useRef)(n);d.current=t,f.current=n;let p=y(()=>we({domain:a}).then(e=>({sessionKey:e.sessionKey,qrUrl:e.qrUrl})),[s,a],{initial:_t,errorData:_t}),m=p.data.sessionKey,h=p.data.qrUrl,g=p.loading,_=p.error instanceof Error?p.error.message:p.error?String(p.error):null,v=l??_,b=(0,Z.useCallback)(e=>{u(null),o(e),c(e=>e+1)},[]);(0,Z.useEffect)(()=>{if(!m)return;let e=!1,t,n=async()=>{try{let n=await fe(m);if(e||n.phase===`polling`)return;if(n.phase===`done`){t!==void 0&&(window.clearInterval(t),t=void 0),p.setData(_t),n.ok?(r&&f.current(!1),d.current({appId:n.appId,domain:n.domain,openId:n.openId})):u(n.message);return}n.phase===`unknown`&&(t!==void 0&&window.clearInterval(t),u(n.message),p.setData(_t))}catch(n){e||(t!==void 0&&window.clearInterval(t),u(n instanceof Error?n.message:`Request failed`),p.setData(_t))}};return t=window.setInterval(()=>void n(),3e3),n(),()=>{e=!0,t!==void 0&&window.clearInterval(t)}},[m,r,p.setData]);let x=y(()=>mt.toDataURL(h,gt),[h],{enabled:!!h,initial:null,errorData:null}),S=x.data,C=x.error!==null&&!x.loading,w=!!(h&&m),T=!v&&!w;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`p`,{className:`text-base font-semibold tracking-tight text-fg`,children:e.feishuQrModalTitle}),(0,$.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:e.feishuQrModalSubtitle})]}),(0,$.jsxs)(`div`,{className:`mt-6 flex min-h-[17.5rem] flex-col items-center justify-center gap-3`,children:[v?(0,$.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:v}):null,!v&&(w||T)?(0,$.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:T?e.feishuQrStarting:e.feishuQrScanHint}),(0,$.jsxs)(`div`,{className:H(`relative flex size-52 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-edge-subtle bg-white p-3 dark:border-edge`,T&&`bg-surface-muted/40 dark:bg-surface-base`),children:[T?(0,$.jsx)(`div`,{className:`absolute inset-3 animate-pulse rounded-md bg-surface-muted dark:bg-surface-hover`,"aria-hidden":!0}):null,w&&h&&!v&&S&&!C?(0,$.jsx)(`img`,{src:S,alt:``,className:`relative z-[1] size-full object-contain`}):null,w&&h&&!v&&!S&&!C&&!T?(0,$.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:e.feishuQrEncoding}):null,w&&h&&!v&&C?(0,$.jsxs)(`div`,{className:`relative z-[1] flex size-full flex-col items-center justify-center gap-2 px-1`,children:[(0,$.jsx)(`p`,{className:`text-center text-xs text-fg-muted`,children:e.feishuQrImageError}),(0,$.jsxs)(`a`,{href:h,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent underline-offset-2 hover:underline`,children:[(0,$.jsx)(z,{className:`size-3 shrink-0`}),e.feishuQrOpenLink]})]}):null]})]}):null]}),(0,$.jsx)(`div`,{className:`mx-auto mt-4 flex w-full max-w-[20rem] justify-center px-1`,role:`group`,"aria-label":e.feishuRegionSwitchAria,children:(0,$.jsxs)(`div`,{className:`inline-flex w-full rounded-full border border-edge bg-surface-muted/60 p-1 dark:border-edge dark:bg-surface-base`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:g,className:H(`min-w-0 flex-1 rounded-full px-3 py-2 text-center text-sm font-medium transition-colors`,V.press,a===`feishu`?`bg-surface-panel text-fg shadow-sm dark:bg-surface-panel`:`text-fg-muted hover:text-fg`),onClick:()=>b(`feishu`),children:e.feishuRegionChina}),(0,$.jsx)(`button`,{type:`button`,disabled:g,className:H(`min-w-0 flex-1 rounded-full px-3 py-2 text-center text-sm font-medium transition-colors`,V.press,a===`lark`?`bg-surface-panel text-fg shadow-sm dark:bg-surface-panel`:`text-fg-muted hover:text-fg`),onClick:()=>b(`lark`),children:e.feishuRegionInternational})]})}),(0,$.jsx)(`div`,{className:`mt-6`,children:(0,$.jsx)(L,{type:`button`,variant:`secondary`,className:`h-11 w-full rounded-full border-0 bg-fg text-surface-panel hover:opacity-90 dark:bg-fg dark:text-surface-panel`,disabled:g,onClick:()=>b(a),children:g?e.feishuQrStarting:e.feishuQrRegenerate})}),i?(0,$.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:i}):null]})}function yt(e){let t=(0,Q.c)(26),{open:n,onOpenChange:r,ch:i,onSetupSuccess:a,moreSettings:o,settingsDirty:s,settingsSaving:c,onSettingsDiscard:l,onSettingsSave:u,presentation:d,closeOnSetupSuccess:f}=e,p=s===void 0?!1:s,m=c===void 0?!1:c,h=d===void 0?`modal`:d,g=f===void 0?!0:f,_;t[0]!==i||t[1]!==o||t[2]!==r||t[3]!==l||t[4]!==u||t[5]!==p||t[6]!==m?(_=o&&l&&u?(0,$.jsx)(ht,{ch:i,dirty:p,saving:m,showCancel:!1,onCancel:()=>r(!1),onDiscard:l,onSave:u}):void 0,t[0]=i,t[1]=o,t[2]=r,t[3]=l,t[4]=u,t[5]=p,t[6]=m,t[7]=_):_=t[7];let v;t[8]!==i||t[9]!==g||t[10]!==o||t[11]!==r||t[12]!==a||t[13]!==n?(v=n?(0,$.jsx)(vt,{ch:i,onSetupSuccess:a,onOpenChange:r,closeOnSetupSuccess:g,moreSettings:o},`active`):null,t[8]=i,t[9]=g,t[10]=o,t[11]=r,t[12]=a,t[13]=n,t[14]=v):v=t[14];let y;return t[15]!==i.feishuQrCloseAria||t[16]!==i.feishuQrModalSubtitle||t[17]!==i.feishuQrModalTitle||t[18]!==i.feishuSubtitle||t[19]!==i.feishuTitle||t[20]!==r||t[21]!==n||t[22]!==h||t[23]!==_||t[24]!==v?(y=(0,$.jsx)(ze,{presentation:h,open:n,onOpenChange:r,title:i.feishuTitle,description:i.feishuSubtitle,srTitle:i.feishuQrModalTitle,srDescription:i.feishuQrModalSubtitle,closeAriaLabel:i.feishuQrCloseAria,wide:!0,footer:_,children:v}),t[15]=i.feishuQrCloseAria,t[16]=i.feishuQrModalSubtitle,t[17]=i.feishuQrModalTitle,t[18]=i.feishuSubtitle,t[19]=i.feishuTitle,t[20]=r,t[21]=n,t[22]=h,t[23]=_,t[24]=v,t[25]=y):y=t[25],y}function bt(e){let t=(0,Q.c)(25),{ch:n,usesPairing:r,tokenReady:i,pairingComplete:a}=e;if(!r)return null;let o=i,s=a,c=!o,l=o&&!s,u;t[0]!==c||t[1]!==o?(u=(0,$.jsx)(xt,{done:o,current:c,index:1}),t[0]=c,t[1]=o,t[2]=u):u=t[2];let d=o&&`text-fg-muted`,f;t[3]===d?f=t[4]:(f=H(`text-fg`,d),t[3]=d,t[4]=f);let p;t[5]!==n.telegramSetupStepToken||t[6]!==f?(p=(0,$.jsx)(`span`,{className:f,children:n.telegramSetupStepToken}),t[5]=n.telegramSetupStepToken,t[6]=f,t[7]=p):p=t[7];let m;t[8]!==u||t[9]!==p?(m=(0,$.jsxs)(`li`,{className:`flex items-start gap-2`,children:[u,p]}),t[8]=u,t[9]=p,t[10]=m):m=t[10];let h;t[11]!==l||t[12]!==s?(h=(0,$.jsx)(xt,{done:s,current:l,index:2}),t[11]=l,t[12]=s,t[13]=h):h=t[13];let g=s&&`text-fg-muted`,_;t[14]===g?_=t[15]:(_=H(`text-fg`,g),t[14]=g,t[15]=_);let v;t[16]!==n.telegramSetupStepPairing||t[17]!==_?(v=(0,$.jsx)(`span`,{className:_,children:n.telegramSetupStepPairing}),t[16]=n.telegramSetupStepPairing,t[17]=_,t[18]=v):v=t[18];let y;t[19]!==h||t[20]!==v?(y=(0,$.jsxs)(`li`,{className:`flex items-start gap-2`,children:[h,v]}),t[19]=h,t[20]=v,t[21]=y):y=t[21];let b;return t[22]!==y||t[23]!==m?(b=(0,$.jsxs)(`ol`,{className:`space-y-2 rounded-xl border border-accent/25 bg-accent-soft/20 px-4 py-3 text-xs`,children:[m,y]}),t[22]=y,t[23]=m,t[24]=b):b=t[24],b}function xt(e){let t=(0,Q.c)(7),{done:n,current:r,index:i}=e,a=n&&`border-success bg-success text-white`,o=!n&&r&&`border-accent bg-accent text-white`,s=!n&&!r&&`border-edge text-fg-muted`,c;t[0]!==a||t[1]!==o||t[2]!==s?(c=H(`mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border text-[10px] font-semibold`,a,o,s),t[0]=a,t[1]=o,t[2]=s,t[3]=c):c=t[3];let l=n?`✓`:String(i),u;return t[4]!==c||t[5]!==l?(u=(0,$.jsx)(`span`,{className:c,"aria-hidden":!0,children:l}),t[4]=c,t[5]=l,t[6]=u):u=t[6],u}function St(e){let t=(0,Q.c)(115),{tg:n,updateTelegram:r,ch:i,groupOpts:a,replyOpts:o,streamOpts:s,tgAccountsDraft:c,setTgAccountsDraft:l,tgAccountsError:u,onTgAccountsBlur:d}=e,f;t[0]===i.apiRoot?f=t[1]:(f=(0,$.jsx)(Y,{children:i.apiRoot}),t[0]=i.apiRoot,t[1]=f);let p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=J(),t[2]=p):p=t[2];let m;t[3]===r?m=t[4]:(m=e=>r({apiRoot:e.target.value}),t[3]=r,t[4]=m);let h;t[5]!==m||t[6]!==n.apiRoot?(h=(0,$.jsx)(`input`,{className:p,value:n.apiRoot,onChange:m,placeholder:`https://api.telegram.org`}),t[5]=m,t[6]=n.apiRoot,t[7]=h):h=t[7];let g;t[8]!==f||t[9]!==h?(g=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[f,h]}),t[8]=f,t[9]=h,t[10]=g):g=t[10];let _;t[11]===i.proxy?_=t[12]:(_=(0,$.jsx)(Y,{children:i.proxy}),t[11]=i.proxy,t[12]=_);let v;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(v=J(),t[13]=v):v=t[13];let y;t[14]===r?y=t[15]:(y=e=>r({proxy:e.target.value}),t[14]=r,t[15]=y);let b;t[16]!==y||t[17]!==n.proxy?(b=(0,$.jsx)(`input`,{className:v,value:n.proxy,onChange:y,placeholder:`http://proxy.example.com:8080`}),t[16]=y,t[17]=n.proxy,t[18]=b):b=t[18];let x;t[19]!==_||t[20]!==b?(x=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[_,b]}),t[19]=_,t[20]=b,t[21]=x):x=t[21];let S;t[22]===r?S=t[23]:(S=e=>r({groupPolicy:e}),t[22]=r,t[23]=S);let C;t[24]!==i.groupPolicy||t[25]!==a||t[26]!==S||t[27]!==n.groupPolicy?(C=(0,$.jsx)(se,{label:i.groupPolicy,value:n.groupPolicy,onChange:S,options:a}),t[24]=i.groupPolicy,t[25]=a,t[26]=S,t[27]=n.groupPolicy,t[28]=C):C=t[28];let w;t[29]===r?w=t[30]:(w=e=>r({replyToMode:e}),t[29]=r,t[30]=w);let T;t[31]!==i.replyToMode||t[32]!==o||t[33]!==w||t[34]!==n.replyToMode?(T=(0,$.jsx)(se,{label:i.replyToMode,value:n.replyToMode,onChange:w,options:o}),t[31]=i.replyToMode,t[32]=o,t[33]=w,t[34]=n.replyToMode,t[35]=T):T=t[35];let E;t[36]===r?E=t[37]:(E=e=>r({streamMode:e}),t[36]=r,t[37]=E);let D;t[38]!==i.streamMode||t[39]!==s||t[40]!==E||t[41]!==n.streamMode?(D=(0,$.jsx)(se,{label:i.streamMode,value:n.streamMode,onChange:E,options:s}),t[38]=i.streamMode,t[39]=s,t[40]=E,t[41]=n.streamMode,t[42]=D):D=t[42];let O;t[43]===i.allowFromGroups?O=t[44]:(O=(0,$.jsx)(Y,{children:i.allowFromGroups}),t[43]=i.allowFromGroups,t[44]=O);let k;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(k=H(J(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[45]=k):k=t[45];let A;t[46]===n.groupAllowFrom?A=t[47]:(A=ie(n.groupAllowFrom),t[46]=n.groupAllowFrom,t[47]=A);let j;t[48]===r?j=t[49]:(j=e=>r({groupAllowFrom:oe(e.target.value)}),t[48]=r,t[49]=j);let M;t[50]!==A||t[51]!==j?(M=(0,$.jsx)(`textarea`,{className:k,rows:2,placeholder:`-1001234567890`,value:A,onChange:j}),t[50]=A,t[51]=j,t[52]=M):M=t[52];let N;t[53]!==O||t[54]!==M?(N=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[O,M]}),t[53]=O,t[54]=M,t[55]=N):N=t[55];let P;t[56]===i.historyLimit?P=t[57]:(P=(0,$.jsx)(Y,{children:i.historyLimit}),t[56]=i.historyLimit,t[57]=P);let ee;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(ee=J(),t[58]=ee):ee=t[58];let F;t[59]===r?F=t[60]:(F=e=>r({historyLimit:parseInt(e.target.value,10)||50}),t[59]=r,t[60]=F);let I;t[61]!==F||t[62]!==n.historyLimit?(I=(0,$.jsx)(`input`,{type:`number`,min:10,max:200,className:ee,value:n.historyLimit,onChange:F}),t[61]=F,t[62]=n.historyLimit,t[63]=I):I=t[63];let L;t[64]!==P||t[65]!==I?(L=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[P,I]}),t[64]=P,t[65]=I,t[66]=L):L=t[66];let R;t[67]===i.textChunkLimit?R=t[68]:(R=(0,$.jsx)(Y,{children:i.textChunkLimit}),t[67]=i.textChunkLimit,t[68]=R);let te;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(te=J(),t[69]=te):te=t[69];let ne;t[70]===r?ne=t[71]:(ne=e=>r({textChunkLimit:parseInt(e.target.value,10)||4e3}),t[70]=r,t[71]=ne);let z;t[72]!==ne||t[73]!==n.textChunkLimit?(z=(0,$.jsx)(`input`,{type:`number`,min:1e3,max:1e4,step:100,className:te,value:n.textChunkLimit,onChange:ne}),t[72]=ne,t[73]=n.textChunkLimit,t[74]=z):z=t[74];let B;t[75]!==R||t[76]!==z?(B=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[R,z]}),t[75]=R,t[76]=z,t[77]=B):B=t[77];let V;t[78]!==L||t[79]!==B?(V=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[L,B]}),t[78]=L,t[79]=B,t[80]=V):V=t[80];let U;t[81]===r?U=t[82]:(U=e=>r({debug:e.target.checked}),t[81]=r,t[82]=U);let W;t[83]!==U||t[84]!==n.debug?(W=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.debug,onChange:U}),t[83]=U,t[84]=n.debug,t[85]=W):W=t[85];let G;t[86]!==i.telegramDebug||t[87]!==W?(G=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[W,i.telegramDebug]}),t[86]=i.telegramDebug,t[87]=W,t[88]=G):G=t[88];let K;t[89]===i.multiAccountJson?K=t[90]:(K=(0,$.jsx)(Y,{children:i.multiAccountJson}),t[89]=i.multiAccountJson,t[90]=K);let re;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(re=H(J(),`min-h-[140px] resize-y font-mono text-xs`),t[91]=re):re=t[91];let q;t[92]===l?q=t[93]:(q=e=>l(e.target.value),t[92]=l,t[93]=q);let ae;t[94]!==d||t[95]!==q||t[96]!==c?(ae=(0,$.jsx)(`textarea`,{className:re,spellCheck:!1,value:c,onChange:q,onBlur:d,placeholder:`{ "personal": { "accountId": "personal", "botToken": "...", ... } }`}),t[94]=d,t[95]=q,t[96]=c,t[97]=ae):ae=t[97];let le;t[98]!==i.multiAccountJsonDesc||t[99]!==u?(le=u?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:u}):(0,$.jsx)(ce,{children:i.multiAccountJsonDesc}),t[98]=i.multiAccountJsonDesc,t[99]=u,t[100]=le):le=t[100];let ue;t[101]!==K||t[102]!==ae||t[103]!==le?(ue=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[K,ae,le]}),t[101]=K,t[102]=ae,t[103]=le,t[104]=ue):ue=t[104];let de;return t[105]!==x||t[106]!==C||t[107]!==T||t[108]!==D||t[109]!==N||t[110]!==V||t[111]!==G||t[112]!==ue||t[113]!==g?(de=(0,$.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[g,x,C,T,D,N,V,G,ue]}),t[105]=x,t[106]=C,t[107]=T,t[108]=D,t[109]=N,t[110]=V,t[111]=G,t[112]=ue,t[113]=g,t[114]=de):de=t[114],de}function Ct(e){let t=(0,Q.c)(151),{open:n,onOpenChange:r,presentation:i,ch:a,form:o,baseline:s,tgAdvanced:c,setTgAdvanced:l,updateTelegram:u,updateChannelAgentRoute:d,tgAccountsDraft:f,setTgAccountsDraft:p,tgAccountsError:m,onTgAccountsBlur:h,dmOpts:g,groupOpts:_,replyOpts:v,streamOpts:y,chatAgents:b,saving:x,dirty:S,save:C,discard:E,language:D,scrollToPairingOnOpen:O,closeOnSave:k}=e,A=i===void 0?`modal`:i,j=O===void 0?!1:O,M=k===void 0?!0:k,N=o.telegram,P;t[0]===s?P=t[1]:(P=s?re(s.telegram):``,t[0]=s,t[1]=P);let F=P,I=re(N),R;t[2]!==a.copied||t[3]!==a.copy||t[4]!==a.hide||t[5]!==a.show?(R=w({show:a.show,hide:a.hide,copy:a.copy,copied:a.copied}),t[2]=a.copied,t[3]=a.copy,t[4]=a.hide,t[5]=a.show,t[6]=R):R=t[6];let te=R,[ne,z]=(0,Z.useState)(0),B=!!I.trim()&&N.enabled,V;t[7]===N?V=t[8]:(V=Te(N),t[7]=N,t[8]=V);let U=V,W,G;t[9]!==n||t[10]!==j?(W=()=>{if(!n||!j)return;let e=window.setTimeout(Tt,80);return()=>window.clearTimeout(e)},G=[n,j],t[9]=n,t[10]=j,t[11]=W,t[12]=G):(W=t[11],G=t[12]),(0,Z.useEffect)(W,G);let K=a.telegramTitle,q=a.telegramSubtitle,ae=a.telegramTitle,le=a.telegramSubtitle,ue=a.modalCancel,de;t[13]!==a.telegramSubtitle||t[14]!==a.telegramTitle||t[15]!==A?(de=A===`modal`?(0,$.jsxs)(`div`,{className:`border-b border-edge-subtle px-6 pb-4 pt-6 dark:border-edge-subtle`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-fg`,children:a.telegramTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.telegramSubtitle})]}):void 0,t[13]=a.telegramSubtitle,t[14]=a.telegramTitle,t[15]=A,t[16]=de):de=t[16];let fe;t[17]===r?fe=t[18]:(fe=()=>r(!1),t[17]=r,t[18]=fe);let pe;t[19]!==M||t[20]!==r||t[21]!==C?(pe=async()=>{await C()&&M&&r(!1)},t[19]=M,t[20]=r,t[21]=C,t[22]=pe):pe=t[22];let me;t[23]!==a||t[24]!==S||t[25]!==E||t[26]!==x||t[27]!==fe||t[28]!==pe?(me=(0,$.jsx)(ht,{ch:a,dirty:S,saving:x,onCancel:fe,onDiscard:E,onSave:pe}),t[23]=a,t[24]=S,t[25]=E,t[26]=x,t[27]=fe,t[28]=pe,t[29]=me):me=t[29];let he;t[30]===u?he=t[31]:(he=e=>u({enabled:e.target.checked}),t[30]=u,t[31]=he);let ge;t[32]!==he||t[33]!==N.enabled?(ge=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:N.enabled,onChange:he}),t[32]=he,t[33]=N.enabled,t[34]=ge):ge=t[34];let _e;t[35]===a.enableTelegramAria?_e=t[36]:(_e=(0,$.jsx)(`span`,{children:a.enableTelegramAria}),t[35]=a.enableTelegramAria,t[36]=_e);let ve;t[37]!==ge||t[38]!==_e?(ve=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[ge,_e]}),t[37]=ge,t[38]=_e,t[39]=ve):ve=t[39];let ye;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[40]=ye):ye=t[40];let be;t[41]===a.telegramToken?be=t[42]:(be=(0,$.jsxs)(Y,{children:[a.telegramToken,ye]}),t[41]=a.telegramToken,t[42]=be);let xe;t[43]!==N.accounts||t[44]!==u?(xe=e=>{let t=N.accounts?.default??Se(`default`);u({accounts:{...N.accounts,default:{...t,accountId:`default`,botToken:e}}})},t[43]=N.accounts,t[44]=u,t[45]=xe):xe=t[45];let X;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(X=H(J(),`text-xs`),t[46]=X):X=t[46];let Ce;t[47]!==te||t[48]!==xe||t[49]!==F||t[50]!==I?(Ce=(0,$.jsx)(T,{value:I,onChange:xe,placeholder:`123456789:ABCdefGHIjklMNOpqrsTUVwxyz`,labels:te,baselineValue:F,inputClassName:X}),t[47]=te,t[48]=xe,t[49]=F,t[50]=I,t[51]=Ce):Ce=t[51];let we;t[52]===a.telegramTokenDesc?we=t[53]:(we=(0,$.jsx)(ce,{children:a.telegramTokenDesc}),t[52]=a.telegramTokenDesc,t[53]=we);let Ee;t[54]!==be||t[55]!==Ce||t[56]!==we?(Ee=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[be,Ce,we]}),t[54]=be,t[55]=Ce,t[56]=we,t[57]=Ee):Ee=t[57];let De;t[58]===N?De=t[59]:(De=Xe(`telegram`,N),t[58]=N,t[59]=De);let Oe=ne>0,ke;t[60]!==a||t[61]!==De||t[62]!==Oe||t[63]!==B?(ke=(0,$.jsx)(bt,{ch:a,usesPairing:De,tokenReady:B,pairingComplete:Oe}),t[60]=a,t[61]=De,t[62]=Oe,t[63]=B,t[64]=ke):ke=t[64];let Ae;t[65]===u?Ae=t[66]:(Ae=e=>u({dmPolicy:e}),t[65]=u,t[66]=Ae);let je;t[67]!==a.dmPolicy||t[68]!==g||t[69]!==Ae||t[70]!==N.dmPolicy?(je=(0,$.jsx)(se,{label:a.dmPolicy,value:N.dmPolicy,onChange:Ae,options:g}),t[67]=a.dmPolicy,t[68]=g,t[69]=Ae,t[70]=N.dmPolicy,t[71]=je):je=t[71];let Me;t[72]!==a||t[73]!==D||t[74]!==n||t[75]!==z||t[76]!==N||t[77]!==U?(Me=(0,$.jsx)(lt,{channel:`telegram`,accountIds:U,channelConfig:N,active:n,ch:a,language:D,onPairedChange:z}),t[72]=a,t[73]=D,t[74]=n,t[75]=z,t[76]=N,t[77]=U,t[78]=Me):Me=t[78];let Ne;t[79]===a.allowFromDm?Ne=t[80]:(Ne=(0,$.jsx)(Y,{children:a.allowFromDm}),t[79]=a.allowFromDm,t[80]=Ne);let Pe;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=H(J(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[81]=Pe):Pe=t[81];let Fe;t[82]===N.allowFrom?Fe=t[83]:(Fe=ie(N.allowFrom),t[82]=N.allowFrom,t[83]=Fe);let Ie;t[84]===u?Ie=t[85]:(Ie=e=>u({allowFrom:oe(e.target.value)}),t[84]=u,t[85]=Ie);let Le;t[86]!==Fe||t[87]!==Ie?(Le=(0,$.jsx)(`textarea`,{className:Pe,rows:2,placeholder:`123456789, 987654321`,value:Fe,onChange:Ie}),t[86]=Fe,t[87]=Ie,t[88]=Le):Le=t[88];let Re;t[89]===a.allowFromDmDesc?Re=t[90]:(Re=(0,$.jsx)(ce,{children:a.allowFromDmDesc}),t[89]=a.allowFromDmDesc,t[90]=Re);let Be;t[91]!==Ne||t[92]!==Le||t[93]!==Re?(Be=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[Ne,Le,Re]}),t[91]=Ne,t[92]=Le,t[93]=Re,t[94]=Be):Be=t[94];let Ve;t[95]===N?Ve=t[96]:(Ve=Te(N),t[95]=N,t[96]=Ve);let He;t[97]===b?.items?He=t[98]:(He=b?.items??[],t[97]=b?.items,t[98]=He);let We;t[99]===d?We=t[100]:(We=(e,t)=>d(`telegram`,e,t),t[99]=d,t[100]=We);let Ge;t[101]!==a||t[102]!==o.channelAgentRoutes.telegram||t[103]!==o.defaultAgentId||t[104]!==x||t[105]!==Ve||t[106]!==He||t[107]!==We?(Ge=(0,$.jsx)(Ue,{accountIds:Ve,routes:o.channelAgentRoutes.telegram,defaultAgentId:o.defaultAgentId,agentItems:He,disabled:x,onChange:We,ch:a}),t[101]=a,t[102]=o.channelAgentRoutes.telegram,t[103]=o.defaultAgentId,t[104]=x,t[105]=Ve,t[106]=He,t[107]=We,t[108]=Ge):Ge=t[108];let Ke;t[109]===l?Ke=t[110]:(Ke=()=>l(wt),t[109]=l,t[110]=Ke);let qe=c&&`rotate-180`,Je;t[111]===qe?Je=t[112]:(Je=H(`mr-1 size-4 transition-transform`,qe),t[111]=qe,t[112]=Je);let Ye;t[113]===Je?Ye=t[114]:(Ye=(0,$.jsx)(ee,{className:Je}),t[113]=Je,t[114]=Ye);let Ze=c?a.advancedHide:a.advancedShow,Qe;t[115]!==Ke||t[116]!==Ye||t[117]!==Ze?(Qe=(0,$.jsxs)(L,{type:`button`,variant:`ghost`,className:`-ml-2 h-auto justify-start px-2 py-1 text-sm text-fg-muted hover:text-fg`,onClick:Ke,children:[Ye,Ze]}),t[115]=Ke,t[116]=Ye,t[117]=Ze,t[118]=Qe):Qe=t[118];let $e;t[119]!==a||t[120]!==_||t[121]!==h||t[122]!==v||t[123]!==p||t[124]!==y||t[125]!==N||t[126]!==f||t[127]!==m||t[128]!==c||t[129]!==u?($e=c?(0,$.jsx)(St,{tg:N,updateTelegram:u,ch:a,groupOpts:_,replyOpts:v,streamOpts:y,tgAccountsDraft:f,setTgAccountsDraft:p,tgAccountsError:m,onTgAccountsBlur:h}):null,t[119]=a,t[120]=_,t[121]=h,t[122]=v,t[123]=p,t[124]=y,t[125]=N,t[126]=f,t[127]=m,t[128]=c,t[129]=u,t[130]=$e):$e=t[130];let et;t[131]!==Ee||t[132]!==ke||t[133]!==je||t[134]!==Me||t[135]!==Be||t[136]!==Ge||t[137]!==Qe||t[138]!==$e?(et=(0,$.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[Ee,ke,je,Me,Be,Ge,Qe,$e]}),t[131]=Ee,t[132]=ke,t[133]=je,t[134]=Me,t[135]=Be,t[136]=Ge,t[137]=Qe,t[138]=$e,t[139]=et):et=t[139];let tt;return t[140]!==a.modalCancel||t[141]!==a.telegramSubtitle||t[142]!==a.telegramTitle||t[143]!==r||t[144]!==n||t[145]!==A||t[146]!==de||t[147]!==me||t[148]!==ve||t[149]!==et?(tt=(0,$.jsxs)(ze,{presentation:A,open:n,onOpenChange:r,title:K,description:q,srTitle:ae,srDescription:le,closeAriaLabel:ue,wide:!0,headerExtra:de,footer:me,children:[ve,et]}),t[140]=a.modalCancel,t[141]=a.telegramSubtitle,t[142]=a.telegramTitle,t[143]=r,t[144]=n,t[145]=A,t[146]=de,t[147]=me,t[148]=ve,t[149]=et,t[150]=tt):tt=t[150],tt}function wt(e){return!e}function Tt(){return it(`telegram`)}var Et=[{id:`telegram`,titleKey:`telegramTitle`,subtitleKey:`telegramSubtitle`},{id:`weixin`,titleKey:`weixinTitle`,subtitleKey:`weixinSubtitle`},{id:`feishu`,titleKey:`feishuTitle`,subtitleKey:`feishuSubtitle`}];function Dt(){return o(`/api/channels/meta`)}async function Ot(){return(await u(Dt())).payload?.channels??[]}var kt=new Map(Et.map(e=>[e.id,e])),At=new Map(Et.map((e,t)=>[e.id,t]));function jt(e,t){return{title:t[e.titleKey],subtitle:t[e.subtitleKey]}}function Mt(e,t){let n=new Map;for(let r of e??[]){let e=kt.get(r.id),i=e?jt(e,t):{title:r.label,subtitle:r.description||t.hubExtensionSubtitle};n.set(r.id,{id:r.id,title:i.title,subtitle:i.subtitle,manageable:r.manageable,order:r.order})}if(n.size===0)return Et.map((e,n)=>{let r=jt(e,t);return{id:e.id,title:r.title,subtitle:r.subtitle,manageable:!0,order:n}});for(let e of Et){if(n.has(e.id))continue;let r=jt(e,t);n.set(e.id,{id:e.id,title:r.title,subtitle:r.subtitle,manageable:!0,order:At.get(e.id)??0})}return Array.from(n.values()).sort((e,t)=>e.order===t.order?e.id.localeCompare(t.id):e.order-t.order)}function Nt(e,t){let n=(0,Q.c)(11),r;n[0]===e?r=n[1]:(r=e?Dt():null,n[0]=e,n[1]=r);let i;n[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={revalidateOnFocus:!1},n[2]=i):i=n[2];let{data:a,error:o,isLoading:c,mutate:l}=s(r,Ot,i),u;n[3]!==t||n[4]!==a?(u=Mt(a,t),n[3]=t,n[4]=a,n[5]=u):u=n[5];let d=u,f;return n[6]!==d||n[7]!==o||n[8]!==c||n[9]!==l?(f={entries:d,isLoading:c,error:o,mutate:l},n[6]=d,n[7]=o,n[8]=c,n[9]=l,n[10]=f):f=n[10],f}function Pt(e,t){return e.find(e=>e.name===t)?.connected??!1}function Ft(e,t){return e.find(e=>e.name===t)?.enabled??!1}function It(e,t){let n=e&&typeof e==`object`?e.channels:void 0,r=n&&typeof n==`object`&&!Array.isArray(n)?n[t]:void 0;return!r||typeof r!=`object`?!1:Object.keys(r).length>0}function Lt(e,t,n){return e?t?n?`running`:`offline`:`disabled`:`not_configured`}function Rt(e,t,n){return n?e===`not_configured`?`setup`:t>0?`pairing`:e===`offline`?`fix`:`manage`:`manage`}function zt(e,t){return e.policy.dm[t]}function Bt(e,t){return e.hubSummaryAccountCount.replace(`{{count}}`,String(t))}function Vt(e,t){let n=t.telegram,r=[e.hubSummaryDm.replace(`{{policy}}`,zt(e,n.dmPolicy))],i=Te(n).length;return i>0&&r.push(Bt(e,i)),r}function Ht(e,t){let n=t.weixin,r=[e.hubSummaryDm.replace(`{{policy}}`,zt(e,n.dmPolicy))];r.push(e.hubSummaryStream.replace(`{{mode}}`,e.policy.stream[n.streamMode]));let i=Ee(n).length;return i>0&&r.push(Bt(e,i)),r}function Ut(e,t){let n=t.feishu,r=n.connectionMode===`webhook`?e.hubConnectionWebhook:e.hubConnectionWebsocket,i=[e.hubSummaryConnection.replace(`{{mode}}`,r)],a=le(n).length;return a>0&&i.push(Bt(e,a)),i}function Wt(e,t){return t[e]}function Gt(e){let{id:t,form:n,connected:r,pairingSummary:i,ch:a}=e,o=n.telegram,s=n.weixin,c=n.feishu,l=t===`telegram`?q(o):t===`weixin`?K(s):ae(c),u=t===`telegram`?o.enabled:t===`weixin`?s.enabled:c.enabled,d=Ze({configured:l,channelEnabled:u,usesPairing:Xe(t,t===`telegram`?o:t===`weixin`?s:c),summaryPending:Wt(t,i).pending}),f=Lt(l,u,r);return{id:t,manageable:!0,configured:l,enabled:u,connected:r,status:f,summaryLines:l?t===`telegram`?Vt(a,n):t===`weixin`?Ht(a,n):Ut(a,n):[],pendingPairing:d,primaryAction:Rt(f,d,!0)}}function Kt(e){let{id:t,config:n,statuses:r,ch:i}=e,a=It(n,t),o=Ft(r,t),s=Pt(r,t);return{id:t,manageable:!1,configured:a,enabled:o,connected:s,status:Lt(a,o,s),summaryLines:a?[i.hubExtensionConfiguredHint]:[],pendingPairing:0,primaryAction:`manage`}}function qt(e){return D(e.id)?Gt({id:e.id,form:e.form,connected:Pt(e.statuses,e.id),pairingSummary:e.pairingSummary,ch:e.ch}):Kt({id:e.id,config:e.config,statuses:e.statuses,ch:e.ch})}function Jt(e){return e.catalogIds.map(t=>qt({id:t,form:e.form,config:e.config,statuses:e.statuses,pairingSummary:e.pairingSummary,ch:e.ch}))}var Yt=`channels-status`;function Xt(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Zt(e){let t=t=>e(t.detail);return window.addEventListener(Yt,t),()=>window.removeEventListener(Yt,t)}function Qt(e,t){let n=(0,Q.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Zt(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,Z.useEffect)(i,a)}var $t={telegram:{pending:0,stale:0,atCapacity:!1},feishu:{pending:0,stale:0,atCapacity:!1},weixin:{pending:0,stale:0,atCapacity:!1}};function en(e){let t=(0,Q.c)(8),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={revalidateOnFocus:!0},t[0]=n):n=t[0];let{data:r,mutate:i,isLoading:a,error:o}=s(e?et:null,_e,n),c;t[1]===i?c=t[2]:(c=()=>{i()},t[1]=i,t[2]=c);let l=c;nt(l,e);let u=r??$t,d;return t[3]!==o||t[4]!==a||t[5]!==l||t[6]!==u?(d={summary:u,isLoading:a,error:o,refresh:l},t[3]=o,t[4]=a,t[5]=l,t[6]=u,t[7]=d):d=t[7],d}var tn=3e4;function nn(e){let t=(0,Q.c)(25),{hasToken:n,form:r,ch:i}=e,{data:a,mutate:o}=A(n),{entries:c,mutate:l}=Nt(n,i),u;t[0]===n?u=t[1]:(u=n?Ce():null,t[0]=n,t[1]=u);let d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d={revalidateOnFocus:!0,refreshInterval:tn},t[2]=d):d=t[2];let{data:f,mutate:p}=s(u,ye,d),m;t[3]===f?m=t[4]:(m=f===void 0?[]:f,t[3]=f,t[4]=m);let h=m,g;t[5]===p?g=t[6]:(g=e=>{let t=Xt(e);if(t){p(t,{revalidate:!1});return}p()},t[5]=p,t[6]=g),Qt(g,n);let{summary:_,refresh:v}=en(n),y;t[7]===c?y=t[8]:(y=c.map(rn),t[7]=c,t[8]=y);let b=y,x=a?.payload?.config,S;bb0:{if(!r||b.length===0){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[9]=e):e=t[9],S=e;break bb0}let e;t[10]!==b||t[11]!==i||t[12]!==x||t[13]!==r||t[14]!==_||t[15]!==h?(e=Jt({catalogIds:b,form:r,config:x,statuses:h,pairingSummary:_,ch:i}),t[10]=b,t[11]=i,t[12]=x,t[13]=r,t[14]=_,t[15]=h,t[16]=e):e=t[16],S=e}let C=S,w;t[17]!==l||t[18]!==o||t[19]!==p||t[20]!==v?(w=()=>{p(),l(),o(),v()},t[17]=l,t[18]=o,t[19]=p,t[20]=v,t[21]=w):w=t[21];let T=w,E;return t[22]!==C||t[23]!==T?(E={cards:C,refreshAll:T},t[22]=C,t[23]=T,t[24]=E):E=t[24],E}function rn(e){return e.id}var an={form:null,baseline:null,tgAccountsDraft:``,tgAccountsError:``,wxAccountsDraft:``,wxAccountsError:``,feishuAccountsDraft:``,feishuAccountsError:``};function on(e){return{tgAccountsDraft:JSON.stringify(e.telegram.accounts??{},null,2),tgAccountsError:``,wxAccountsDraft:JSON.stringify(e.weixin.accounts??{},null,2),wxAccountsError:``,feishuAccountsDraft:JSON.stringify(e.feishu?.accounts??{},null,2),feishuAccountsError:``}}function sn(e,t){switch(t.type){case`reset`:return an;case`load`:{let e=structuredClone(t.payload);return{form:e,baseline:structuredClone(e),...on(e)}}case`commitSaved`:{let e=structuredClone(t.payload);return{form:e,baseline:structuredClone(e),...on(e)}}case`discard`:{if(!e.baseline)return e;let t=structuredClone(e.baseline);return{form:t,baseline:e.baseline,...on(t)}}case`updateTelegram`:return e.form?{...e,form:{...e.form,telegram:{...e.form.telegram,...t.patch}}}:e;case`updateWeixin`:return e.form?{...e,form:{...e.form,weixin:{...e.form.weixin,...t.patch}}}:e;case`updateFeishu`:return e.form?{...e,form:{...e.form,feishu:{...e.form.feishu,...t.patch}}}:e;case`updateChannelAgentRoute`:{if(!e.form)return e;let n=t.channel===`telegram`?`telegram`:t.channel===`weixin`?`weixin`:`feishu`;return{...e,form:{...e.form,channelAgentRoutes:{...e.form.channelAgentRoutes,[n]:{...e.form.channelAgentRoutes[n],[t.accountId]:t.agentId.trim().toLowerCase()}}}}}case`setTgAccountsDraft`:return{...e,tgAccountsDraft:t.value};case`setWxAccountsDraft`:return{...e,wxAccountsDraft:t.value};case`setFeishuAccountsDraft`:return{...e,feishuAccountsDraft:t.value};case`setTgAccountsError`:return{...e,tgAccountsError:t.value};case`setWxAccountsError`:return{...e,wxAccountsError:t.value};case`setFeishuAccountsError`:return{...e,feishuAccountsError:t.value};case`applyTgAccounts`:return e.form?{...e,form:{...e.form,telegram:{...e.form.telegram,accounts:t.accounts}},tgAccountsError:``}:e;case`applyWxAccounts`:return e.form?{...e,form:{...e.form,weixin:{...e.form.weixin,accounts:t.accounts}},wxAccountsError:``}:e;case`applyFeishuAccounts`:return e.form?{...e,form:{...e.form,feishu:{...e.form.feishu,accounts:t.accounts}},feishuAccountsError:``}:e;case`restoreForm`:return{...e,form:structuredClone(t.payload)}}}function cn(){let e=i(e=>e.language),t=a(e),n=t.channelsSettings,r=!!l(e=>e.token),o=(0,Z.useRef)(!1),[c,u]=(0,Z.useReducer)(sn,an),[d,f]=(0,Z.useState)({hasToken:r,parsed:null}),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),[_,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(!1),[O,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(!1),[P,ee]=(0,Z.useState)(!1),[F,I]=(0,Z.useState)(!1),[L,R]=(0,Z.useState)(!1),{data:te}=s(r?`gateway-chat-agents-ch`:null,k,{revalidateOnFocus:!1}),{data:ne,error:z,isLoading:B,mutate:V}=A(r),H=(0,Z.useMemo)(()=>ne?.payload?.config===void 0?null:ve(ne.payload.config),[ne]);(r!==d.hasToken||H!==d.parsed)&&(f({hasToken:r,parsed:H}),r?H!==null&&!o.current&&(u({type:`load`,payload:H}),y(!1)):(o.current=!1,u({type:`reset`}),y(!1)));let{form:U,baseline:W,tgAccountsDraft:G,tgAccountsError:K,wxAccountsDraft:q,wxAccountsError:ie,feishuAccountsDraft:ae,feishuAccountsError:oe}=c,J=(0,Z.useMemo)(()=>!U||!W?!1:JSON.stringify(U)!==JSON.stringify(W),[U,W]),Y=!!(r&&B&&ne===void 0&&!z),se=z instanceof Error?z.message:z?String(z):null,ce=(0,Z.useCallback)((e,t,n)=>{o.current=!0,u({type:`updateChannelAgentRoute`,channel:e,accountId:t,agentId:n})},[]),le=(0,Z.useCallback)(e=>{o.current=!0,u({type:`updateTelegram`,patch:e})},[]),ue=(0,Z.useCallback)(e=>{o.current=!0,u({type:`updateWeixin`,patch:e})},[]),de=(0,Z.useCallback)(e=>{o.current=!0,u({type:`updateFeishu`,patch:e})},[]),fe=(0,Z.useCallback)(async()=>{if(!U||p)return!1;m(!0),g(null),y(!1);try{let e=await he(U);return o.current=!1,u({type:`commitSaved`,payload:e}),y(!0),window.setTimeout(()=>y(!1),2500),!0}catch(e){return g(e instanceof Error?e.message:n.saveError),!1}finally{m(!1)}},[U,p,n.saveError]),pe=(0,Z.useCallback)(()=>{W&&(o.current=!1,u({type:`discard`}),g(null),y(!1))},[W]),me=(0,Z.useCallback)(async(e,t)=>{if(!U||p)return;let r=U,i=e===`weixin`?{...U,weixin:{...U.weixin,enabled:t}}:e===`telegram`?{...U,telegram:{...U.telegram,enabled:t}}:{...U,feishu:{...U.feishu,enabled:t}};o.current=!0,u(e===`weixin`?{type:`updateWeixin`,patch:{enabled:t}}:e===`telegram`?{type:`updateTelegram`,patch:{enabled:t}}:{type:`updateFeishu`,patch:{enabled:t}}),m(!0),g(null);try{let e=await he(i);o.current=!1,u({type:`commitSaved`,payload:e})}catch(e){g(e instanceof Error?e.message:n.saveError),o.current=!0,u({type:`restoreForm`,payload:r})}finally{m(!1)}},[U,p,n.saveError]),ge=(0,Z.useCallback)(async()=>{let e=U?re(U.telegram):``;e&&await v(e)&&(ee(!0),window.setTimeout(()=>ee(!1),2e3))},[U]),_e=(0,Z.useCallback)(e=>{de({appId:e.appId,domain:e.domain,enabled:!0}),V(),C(n.feishuQrSetupSuccess),window.setTimeout(()=>C(null),4e3)},[de,V,n.feishuQrSetupSuccess]),ye=(0,Z.useCallback)(async()=>{let e=U?.feishu?.appSecret;e&&await v(e)&&(I(!0),window.setTimeout(()=>I(!1),2e3))},[U]),be=(0,Z.useCallback)(async()=>{let e=U?.feishu;if(!e)return;let t={connectionMode:e.connectionMode,verificationToken:e.verificationToken||``,encryptKey:e.encryptKey||``,webhookHost:e.webhookHost||``,webhookPort:e.webhookPort||0,webhookPath:e.webhookPath||``};await v(JSON.stringify(t,null,2))&&(R(!0),window.setTimeout(()=>R(!1),2e3))},[U]);return{language:e,m:t,ch:n,hasToken:r,loading:Y,fetchError:se,mutate:V,form:U,baseline:W,dirty:J,saving:p,error:h,saveOk:_,weixinSuccessBanner:b,setWeixinSuccessBanner:x,feishuSetupSuccessBanner:S,tgAdvanced:w,setTgAdvanced:T,showToken:E,setShowToken:D,showFeishuSecret:O,setShowFeishuSecret:j,showFeishuWebhookSecrets:M,setShowFeishuWebhookSecrets:N,copied:P,feishuCopied:F,feishuWebhookCopied:L,tgAccountsDraft:G,setTgAccountsDraft:(0,Z.useCallback)(e=>{u({type:`setTgAccountsDraft`,value:e})},[]),tgAccountsError:K,wxAccountsDraft:q,setWxAccountsDraft:(0,Z.useCallback)(e=>{u({type:`setWxAccountsDraft`,value:e})},[]),wxAccountsError:ie,feishuAccountsDraft:ae,setFeishuAccountsDraft:(0,Z.useCallback)(e=>{u({type:`setFeishuAccountsDraft`,value:e})},[]),feishuAccountsError:oe,chatAgents:te,updateChannelAgentRoute:ce,updateTelegram:le,updateWeixin:ue,updateFeishu:de,save:fe,discard:pe,toggleChannelEnabled:me,copyToken:ge,handleFeishuQrSetupSuccess:_e,copyFeishuSecret:ye,copyFeishuWebhookConfig:be,onTgAccountsBlur:(0,Z.useCallback)(()=>{if(!U)return;let e=G.trim();if(!e){o.current=!0,u({type:`applyTgAccounts`,accounts:{}});return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);o.current=!0,u({type:`applyTgAccounts`,accounts:t})}catch(e){u({type:`setTgAccountsError`,value:e instanceof Error?e.message:n.jsonInvalid})}},[U,G,n.jsonObjectAccounts,n.jsonInvalid]),onWxAccountsBlur:(0,Z.useCallback)(()=>{if(!U)return;let e=q.trim();if(!e){o.current=!0,u({type:`applyWxAccounts`,accounts:{}});return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);o.current=!0,u({type:`applyWxAccounts`,accounts:t})}catch(e){u({type:`setWxAccountsError`,value:e instanceof Error?e.message:n.jsonInvalid})}},[U,q,n.jsonObjectAccounts,n.jsonInvalid]),onFeishuAccountsBlur:(0,Z.useCallback)(()=>{if(!U)return;let e=ae.trim();if(!e){o.current=!0,u({type:`applyFeishuAccounts`,accounts:{}});return}try{let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(n.jsonObjectAccounts);o.current=!0,u({type:`applyFeishuAccounts`,accounts:t})}catch(e){u({type:`setFeishuAccountsError`,value:e instanceof Error?e.message:n.jsonInvalid})}},[U,ae,n.jsonObjectAccounts,n.jsonInvalid]),dmOpts:(0,Z.useMemo)(()=>[`pairing`,`allowlist`,`open`,`disabled`].map(e=>({value:e,label:n.policy.dm[e]})),[n.policy.dm]),groupOpts:(0,Z.useMemo)(()=>[`open`,`disabled`,`allowlist`].map(e=>({value:e,label:n.policy.group[e]})),[n.policy.group]),replyOpts:(0,Z.useMemo)(()=>[`off`,`first`,`all`].map(e=>({value:e,label:n.policy.reply[e]})),[n.policy.reply]),streamOpts:(0,Z.useMemo)(()=>[`off`,`partial`,`block`].map(e=>({value:e,label:n.policy.stream[e]})),[n.policy.stream])}}var ln={width:208,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}},un={sessionKey:null,qrcodeUrl:null};function dn({ch:e,onLoginSuccess:t,onOpenChange:n,closeOnLoginSuccess:r,moreSettings:i}){let[a,o]=(0,Z.useState)(0),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(null),d=(0,Z.useRef)(t),f=(0,Z.useRef)(n);d.current=t,f.current=n;let p=y(()=>pe().then(e=>({sessionKey:e.sessionKey,qrcodeUrl:e.qrcodeUrl})),[a],{initial:un,errorData:un}),m=p.data.sessionKey,h=p.data.qrcodeUrl,g=p.loading,_=p.error instanceof Error?p.error.message:p.error?String(p.error):null,v=l??_,b=(0,Z.useCallback)(()=>{u(null),c(null),o(e=>e+1)},[]);(0,Z.useEffect)(()=>{if(!m)return;let t=!1,n,i=async()=>{try{let i=await xe(m);if(t)return;if(i.phase===`polling`){p.setData(e=>({...e,qrcodeUrl:i.qrcodeUrl})),c(i.qrStatus===`scaned`?e.weixinQrLoginScanned:null);return}if(i.phase===`done`){n!==void 0&&(window.clearInterval(n),n=void 0),p.setData(un),i.ok?(r&&f.current(!1),await d.current()):u(i.message);return}i.phase===`unknown`&&c(null)}catch(e){t||(n!==void 0&&window.clearInterval(n),u(e instanceof Error?e.message:`Request failed`),p.setData(un))}};return n=window.setInterval(()=>void i(),2e3),i(),()=>{t=!0,n!==void 0&&window.clearInterval(n)}},[m,e.weixinQrLoginScanned,r,p.setData]);let x=y(()=>mt.toDataURL(h,ln),[h],{enabled:!!h,initial:null,errorData:null}),S=x.data,C=x.error!==null&&!x.loading,w=!!(h&&m),T=!v&&!w;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`p`,{className:`text-base font-semibold tracking-tight text-fg`,children:e.weixinQrModalTitle}),(0,$.jsx)(`p`,{className:`mt-1.5 text-sm text-fg-muted`,children:e.weixinQrModalSubtitle})]}),(0,$.jsxs)(`div`,{className:`mt-6 flex min-h-[17.5rem] flex-col items-center justify-center gap-3`,children:[v?(0,$.jsx)(`p`,{className:`text-center text-sm text-red-600 dark:text-red-400`,children:v}):null,!v&&(w||T)?(0,$.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-3`,children:[(0,$.jsx)(`p`,{className:H(`min-h-[1.25rem] text-center text-sm`,s&&!T?`text-accent`:`text-fg-muted`),children:T?e.weixinQrLoginBusy:s??`\xA0`}),(0,$.jsxs)(`div`,{className:H(`relative flex size-52 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-edge-subtle bg-white p-3 dark:border-edge`,T&&`bg-surface-muted/40 dark:bg-surface-base`),children:[T?(0,$.jsx)(`div`,{className:`absolute inset-3 animate-pulse rounded-md bg-surface-muted dark:bg-surface-hover`,"aria-hidden":!0}):null,w&&h&&!v&&S&&!C?(0,$.jsx)(`img`,{src:S,alt:``,className:`relative z-[1] size-full object-contain`}):null,w&&h&&!v&&!S&&!C&&!T?(0,$.jsx)(`p`,{className:`relative z-[1] px-2 text-center text-sm text-fg-muted`,children:e.weixinQrEncoding}):null,w&&h&&!v&&C?(0,$.jsxs)(`div`,{className:`relative z-[1] flex size-full flex-col items-center justify-center gap-2 px-1`,children:[(0,$.jsx)(`p`,{className:`text-center text-xs text-fg-muted`,children:e.weixinQrImageError}),(0,$.jsxs)(`a`,{href:h,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent underline-offset-2 hover:underline`,children:[(0,$.jsx)(z,{className:`size-3 shrink-0`}),e.weixinQrOpenLink]})]}):null]})]}):null]}),(0,$.jsx)(`div`,{className:`mt-6`,children:(0,$.jsx)(L,{type:`button`,variant:`secondary`,className:`h-11 w-full rounded-full border-0 bg-fg text-surface-panel hover:opacity-90 dark:bg-fg dark:text-surface-panel`,disabled:g,onClick:b,children:g?e.weixinQrLoginBusy:e.weixinQrRegenerate})}),i?(0,$.jsx)(`div`,{className:`mt-6 border-t border-edge-subtle pt-4 dark:border-edge-subtle`,children:i}):null]})}function fn(e){let t=(0,Q.c)(26),{open:n,onOpenChange:r,ch:i,onLoginSuccess:a,moreSettings:o,settingsDirty:s,settingsSaving:c,onSettingsDiscard:l,onSettingsSave:u,presentation:d,closeOnLoginSuccess:f}=e,p=s===void 0?!1:s,m=c===void 0?!1:c,h=d===void 0?`modal`:d,g=f===void 0?!0:f,_;t[0]!==i||t[1]!==o||t[2]!==r||t[3]!==l||t[4]!==u||t[5]!==p||t[6]!==m?(_=o&&l&&u?(0,$.jsx)(ht,{ch:i,dirty:p,saving:m,showCancel:!1,onCancel:()=>r(!1),onDiscard:l,onSave:u}):void 0,t[0]=i,t[1]=o,t[2]=r,t[3]=l,t[4]=u,t[5]=p,t[6]=m,t[7]=_):_=t[7];let v;t[8]!==i||t[9]!==g||t[10]!==o||t[11]!==a||t[12]!==r||t[13]!==n?(v=n?(0,$.jsx)(dn,{ch:i,onLoginSuccess:a,onOpenChange:r,closeOnLoginSuccess:g,moreSettings:o},`active`):null,t[8]=i,t[9]=g,t[10]=o,t[11]=a,t[12]=r,t[13]=n,t[14]=v):v=t[14];let y;return t[15]!==i.weixinQrModalCloseAria||t[16]!==i.weixinQrModalSubtitle||t[17]!==i.weixinQrModalTitle||t[18]!==i.weixinSubtitle||t[19]!==i.weixinTitle||t[20]!==r||t[21]!==n||t[22]!==h||t[23]!==_||t[24]!==v?(y=(0,$.jsx)(ze,{presentation:h,open:n,onOpenChange:r,title:i.weixinTitle,description:i.weixinSubtitle,srTitle:i.weixinQrModalTitle,srDescription:i.weixinQrModalSubtitle,closeAriaLabel:i.weixinQrModalCloseAria,wide:!0,footer:_,children:v}),t[15]=i.weixinQrModalCloseAria,t[16]=i.weixinQrModalSubtitle,t[17]=i.weixinQrModalTitle,t[18]=i.weixinSubtitle,t[19]=i.weixinTitle,t[20]=r,t[21]=n,t[22]=h,t[23]=_,t[24]=v,t[25]=y):y=t[25],y}function pn(e){let t=(0,Q.c)(108),{wx:n,updateWeixin:r,ch:i,streamOpts:a,wxAccountsDraft:o,setWxAccountsDraft:s,wxAccountsError:c,onWxAccountsBlur:l,channelAgentRoutesWx:u,defaultAgentId:d,agentItems:f,onAgentRouteChange:p,routingDisabled:m}=e,h;t[0]===i.weixinAllowFrom?h=t[1]:(h=(0,$.jsx)(Y,{children:i.weixinAllowFrom}),t[0]=i.weixinAllowFrom,t[1]=h);let g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=H(J(),`min-h-[2.75rem] resize-y font-mono text-xs`),t[2]=g):g=t[2];let _;t[3]===n.allowFrom?_=t[4]:(_=n.allowFrom.join(`, `),t[3]=n.allowFrom,t[4]=_);let v;t[5]===r?v=t[6]:(v=e=>r({allowFrom:e.target.value.split(/[,\n]/).flatMap(mn)}),t[5]=r,t[6]=v);let y;t[7]!==_||t[8]!==v?(y=(0,$.jsx)(`textarea`,{className:g,rows:2,placeholder:`wxid_..., openid_...`,value:_,onChange:v}),t[7]=_,t[8]=v,t[9]=y):y=t[9];let b;t[10]===i.weixinAllowFromDesc?b=t[11]:(b=(0,$.jsx)(ce,{children:i.weixinAllowFromDesc}),t[10]=i.weixinAllowFromDesc,t[11]=b);let x;t[12]!==h||t[13]!==y||t[14]!==b?(x=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[h,y,b]}),t[12]=h,t[13]=y,t[14]=b,t[15]=x):x=t[15];let S;t[16]===r?S=t[17]:(S=e=>r({streamMode:e}),t[16]=r,t[17]=S);let C;t[18]!==i.streamMode||t[19]!==a||t[20]!==S||t[21]!==n.streamMode?(C=(0,$.jsx)(se,{label:i.streamMode,value:n.streamMode,onChange:S,options:a}),t[18]=i.streamMode,t[19]=a,t[20]=S,t[21]=n.streamMode,t[22]=C):C=t[22];let w;t[23]===i.historyLimit?w=t[24]:(w=(0,$.jsx)(Y,{children:i.historyLimit}),t[23]=i.historyLimit,t[24]=w);let T;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(T=J(),t[25]=T):T=t[25];let E;t[26]===r?E=t[27]:(E=e=>r({historyLimit:parseInt(e.target.value,10)||50}),t[26]=r,t[27]=E);let D;t[28]!==E||t[29]!==n.historyLimit?(D=(0,$.jsx)(`input`,{type:`number`,min:10,max:200,className:T,value:n.historyLimit,onChange:E}),t[28]=E,t[29]=n.historyLimit,t[30]=D):D=t[30];let O;t[31]!==w||t[32]!==D?(O=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[w,D]}),t[31]=w,t[32]=D,t[33]=O):O=t[33];let k;t[34]===i.textChunkLimit?k=t[35]:(k=(0,$.jsx)(Y,{children:i.textChunkLimit}),t[34]=i.textChunkLimit,t[35]=k);let A;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(A=J(),t[36]=A):A=t[36];let j;t[37]===r?j=t[38]:(j=e=>r({textChunkLimit:parseInt(e.target.value,10)||4e3}),t[37]=r,t[38]=j);let M;t[39]!==j||t[40]!==n.textChunkLimit?(M=(0,$.jsx)(`input`,{type:`number`,min:1e3,max:1e4,step:100,className:A,value:n.textChunkLimit,onChange:j}),t[39]=j,t[40]=n.textChunkLimit,t[41]=M):M=t[41];let N;t[42]!==k||t[43]!==M?(N=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[k,M]}),t[42]=k,t[43]=M,t[44]=N):N=t[44];let P;t[45]!==O||t[46]!==N?(P=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[O,N]}),t[45]=O,t[46]=N,t[47]=P):P=t[47];let ee;t[48]===i.weixinRouteTag?ee=t[49]:(ee=(0,$.jsx)(Y,{children:i.weixinRouteTag}),t[48]=i.weixinRouteTag,t[49]=ee);let F;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(F=J(),t[50]=F):F=t[50];let I;t[51]===r?I=t[52]:(I=e=>r({routeTag:e.target.value}),t[51]=r,t[52]=I);let L;t[53]!==i.routeTagPlaceholder||t[54]!==I||t[55]!==n.routeTag?(L=(0,$.jsx)(`input`,{className:F,value:n.routeTag,onChange:I,placeholder:i.routeTagPlaceholder}),t[53]=i.routeTagPlaceholder,t[54]=I,t[55]=n.routeTag,t[56]=L):L=t[56];let R;t[57]===i.weixinRouteTagDesc?R=t[58]:(R=(0,$.jsx)(ce,{children:i.weixinRouteTagDesc}),t[57]=i.weixinRouteTagDesc,t[58]=R);let te;t[59]!==ee||t[60]!==L||t[61]!==R?(te=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[ee,L,R]}),t[59]=ee,t[60]=L,t[61]=R,t[62]=te):te=t[62];let ne;t[63]===r?ne=t[64]:(ne=e=>r({debug:e.target.checked}),t[63]=r,t[64]=ne);let z;t[65]!==ne||t[66]!==n.debug?(z=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.debug,onChange:ne}),t[65]=ne,t[66]=n.debug,t[67]=z):z=t[67];let B;t[68]!==i.weixinDebug||t[69]!==z?(B=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[z,i.weixinDebug]}),t[68]=i.weixinDebug,t[69]=z,t[70]=B):B=t[70];let V;t[71]===i.weixinDebugDesc?V=t[72]:(V=(0,$.jsx)(ce,{children:i.weixinDebugDesc}),t[71]=i.weixinDebugDesc,t[72]=V);let U;t[73]===i.weixinAccountsJson?U=t[74]:(U=(0,$.jsx)(Y,{children:i.weixinAccountsJson}),t[73]=i.weixinAccountsJson,t[74]=U);let W;t[75]===Symbol.for(`react.memo_cache_sentinel`)?(W=H(J(),`min-h-[140px] resize-y font-mono text-xs`),t[75]=W):W=t[75];let G;t[76]===s?G=t[77]:(G=e=>s(e.target.value),t[76]=s,t[77]=G);let K;t[78]!==l||t[79]!==G||t[80]!==o?(K=(0,$.jsx)(`textarea`,{className:W,spellCheck:!1,value:o,onChange:G,onBlur:l,placeholder:`{ "personal": { "name": "...", "cdnBaseUrl": "...", "enabled": true } }`}),t[78]=l,t[79]=G,t[80]=o,t[81]=K):K=t[81];let re;t[82]!==i.weixinAccountsJsonDesc||t[83]!==c?(re=c?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:c}):(0,$.jsx)(ce,{children:i.weixinAccountsJsonDesc}),t[82]=i.weixinAccountsJsonDesc,t[83]=c,t[84]=re):re=t[84];let q;t[85]!==U||t[86]!==K||t[87]!==re?(q=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[U,K,re]}),t[85]=U,t[86]=K,t[87]=re,t[88]=q):q=t[88];let ie;t[89]===n?ie=t[90]:(ie=Ee(n),t[89]=n,t[90]=ie);let ae;t[91]!==f||t[92]!==i||t[93]!==u||t[94]!==d||t[95]!==p||t[96]!==m||t[97]!==ie?(ae=(0,$.jsx)(Ue,{accountIds:ie,routes:u,defaultAgentId:d,agentItems:f,disabled:m,onChange:p,ch:i}),t[91]=f,t[92]=i,t[93]=u,t[94]=d,t[95]=p,t[96]=m,t[97]=ie,t[98]=ae):ae=t[98];let oe;return t[99]!==P||t[100]!==te||t[101]!==B||t[102]!==V||t[103]!==q||t[104]!==ae||t[105]!==x||t[106]!==C?(oe=(0,$.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle pt-4 dark:border-edge`,children:[x,C,P,te,B,V,q,ae]}),t[99]=P,t[100]=te,t[101]=B,t[102]=V,t[103]=q,t[104]=ae,t[105]=x,t[106]=C,t[107]=oe):oe=t[107],oe}function mn(e){let t=e.trim();return t?[t]:[]}function hn(e){let t=(0,Q.c)(60),{ch:n,wx:r,updateWeixin:i,dmOpts:a,streamOpts:o,wxAccountsDraft:s,setWxAccountsDraft:c,wxAccountsError:l,onWxAccountsBlur:u,form:d,chatAgents:f,onAgentRouteChange:p,saving:m,language:h,dialogOpen:g,pairingFocus:_}=e,v=_===void 0?!1:_,y;t[0]===r?y=t[1]:(y=Ee(r),t[0]=r,t[1]=y);let b=y,x;t[2]===b?x=t[3]:(x=b.length>0?b:[`default`],t[2]=b,t[3]=x);let S=x,C=(0,Z.useRef)(null),w,T;t[4]===v?(w=t[5],T=t[6]):(w=()=>{if(!v)return;let e=C.current;e&&(e.open=!0);let t=window.setTimeout(gn,80);return()=>window.clearTimeout(t)},T=[v],t[4]=v,t[5]=w,t[6]=T),(0,Z.useEffect)(w,T);let E;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(ee,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`}),t[7]=E):E=t[7];let D;t[8]===n.advancedShow?D=t[9]:(D=(0,$.jsx)(`summary`,{className:`cursor-pointer list-none rounded-xl px-3 py-2.5 text-sm font-medium text-fg transition-colors hover:bg-surface-hover group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[E,n.advancedShow]})}),t[8]=n.advancedShow,t[9]=D);let O;t[10]===n.weixinAdvancedHint?O=t[11]:(O=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:n.weixinAdvancedHint}),t[10]=n.weixinAdvancedHint,t[11]=O);let k;t[12]===i?k=t[13]:(k=e=>i({enabled:e.target.checked}),t[12]=i,t[13]=k);let A;t[14]!==k||t[15]!==r.enabled?(A=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.enabled,onChange:k}),t[14]=k,t[15]=r.enabled,t[16]=A):A=t[16];let j;t[17]===n.enableWeixinAria?j=t[18]:(j=(0,$.jsx)(`span`,{children:n.enableWeixinAria}),t[17]=n.enableWeixinAria,t[18]=j);let M;t[19]!==A||t[20]!==j?(M=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[A,j]}),t[19]=A,t[20]=j,t[21]=M):M=t[21];let N;t[22]===i?N=t[23]:(N=e=>i({dmPolicy:e}),t[22]=i,t[23]=N);let P;t[24]!==n.dmPolicy||t[25]!==a||t[26]!==N||t[27]!==r.dmPolicy?(P=(0,$.jsx)(se,{label:n.dmPolicy,value:r.dmPolicy,onChange:N,options:a}),t[24]=n.dmPolicy,t[25]=a,t[26]=N,t[27]=r.dmPolicy,t[28]=P):P=t[28];let F;t[29]!==n||t[30]!==g||t[31]!==h||t[32]!==S||t[33]!==r?(F=(0,$.jsx)(lt,{channel:`weixin`,accountIds:S,channelConfig:r,active:g,ch:n,language:h}),t[29]=n,t[30]=g,t[31]=h,t[32]=S,t[33]=r,t[34]=F):F=t[34];let I;t[35]===f?.items?I=t[36]:(I=f?.items??[],t[35]=f?.items,t[36]=I);let L;t[37]!==n||t[38]!==d.channelAgentRoutes.weixin||t[39]!==d.defaultAgentId||t[40]!==p||t[41]!==u||t[42]!==m||t[43]!==c||t[44]!==o||t[45]!==I||t[46]!==i||t[47]!==r||t[48]!==s||t[49]!==l?(L=(0,$.jsx)(`div`,{className:`[&>div]:border-0 [&>div]:pt-0`,children:(0,$.jsx)(pn,{wx:r,updateWeixin:i,ch:n,streamOpts:o,wxAccountsDraft:s,setWxAccountsDraft:c,wxAccountsError:l,onWxAccountsBlur:u,channelAgentRoutesWx:d.channelAgentRoutes.weixin,defaultAgentId:d.defaultAgentId,agentItems:I,onAgentRouteChange:p,routingDisabled:m})}),t[37]=n,t[38]=d.channelAgentRoutes.weixin,t[39]=d.defaultAgentId,t[40]=p,t[41]=u,t[42]=m,t[43]=c,t[44]=o,t[45]=I,t[46]=i,t[47]=r,t[48]=s,t[49]=l,t[50]=L):L=t[50];let R;t[51]!==M||t[52]!==P||t[53]!==F||t[54]!==L||t[55]!==O?(R=(0,$.jsxs)(`div`,{className:`space-y-4 border-t border-edge-subtle px-3 pb-3 pt-3 dark:border-edge-subtle`,children:[O,M,P,F,L]}),t[51]=M,t[52]=P,t[53]=F,t[54]=L,t[55]=O,t[56]=R):R=t[56];let te;return t[57]!==R||t[58]!==D?(te=(0,$.jsxs)(`details`,{ref:C,className:`group rounded-xl border border-edge-subtle bg-surface-base open:pb-3 dark:border-edge`,children:[D,R]}),t[57]=R,t[58]=D,t[59]=te):te=t[59],te}function gn(){return it(`weixin`)}function _n(){let e=g(),{channelId:t}=C(),[n]=S(),{language:r,m:i,ch:a,hasToken:o,loading:s,fetchError:c,mutate:l,form:u,baseline:d,dirty:f,saving:p,error:m,saveOk:h,weixinSuccessBanner:_,setWeixinSuccessBanner:v,feishuSetupSuccessBanner:y,tgAdvanced:b,setTgAdvanced:w,showToken:T,setShowToken:E,showFeishuSecret:O,setShowFeishuSecret:k,showFeishuWebhookSecrets:A,setShowFeishuWebhookSecrets:j,copied:M,feishuCopied:N,feishuWebhookCopied:ee,tgAccountsDraft:F,setTgAccountsDraft:I,tgAccountsError:te,wxAccountsDraft:B,setWxAccountsDraft:V,wxAccountsError:H,feishuAccountsDraft:U,setFeishuAccountsDraft:W,feishuAccountsError:G,chatAgents:K,updateChannelAgentRoute:re,updateTelegram:q,updateWeixin:ie,updateFeishu:ae,save:oe,discard:J,toggleChannelEnabled:Y,copyToken:se,handleFeishuQrSetupSuccess:ce,copyFeishuSecret:le,copyFeishuWebhookConfig:ue,onTgAccountsBlur:de,onWxAccountsBlur:fe,onFeishuAccountsBlur:pe,dmOpts:me,groupOpts:he,replyOpts:ge,streamOpts:_e}=cn(),[ve,ye]=(0,Z.useState)(!1),{entries:be}=Nt(o,a),xe=(0,Z.useMemo)(()=>new Map(be.map(e=>[e.id,e])),[be]),X=R(t),Se=n.get(`pairing`)===`1`,Ce=!!(X&&xe.has(X)),{cards:we,refreshAll:Te}=nn({hasToken:o,form:u,ch:a}),Ee=X?xe.get(X):void 0,Q=X?we.find(e=>e.id===X):void 0;(0,Z.useEffect)(()=>{!X||be.length===0||xe.has(X)||e(ne,{replace:!0})},[X,xe,be.length,e]);let De=(0,Z.useCallback)((t,n)=>{e(P(t,{pairing:n?.scrollToPairing}))},[e]),Oe=(0,Z.useCallback)(()=>{e(ne)},[e]),ke=(0,Z.useCallback)(e=>{e||Oe()},[Oe]),Ae=(0,Z.useCallback)(async()=>{await l(),v(a.weixinQrLoginSuccess),window.setTimeout(()=>v(null),4e3)},[a.weixinQrLoginSuccess,l,v]),je=(0,Z.useCallback)(async()=>{ye(!0);try{Te(),await l()}finally{ye(!1)}},[l,Te]);if(!o)return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(vn,{title:i.settingsSections.channels,hasToken:o,ch:a,refreshing:ve,saveOk:h,onRefresh:je}),(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:i.settingsSections.channels}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.needToken})]})]});if(s)return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(vn,{title:i.settingsSections.channels,hasToken:o,ch:a,refreshing:ve,saveOk:h,onRefresh:je}),(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`h-7 w-40 animate-pulse rounded-md bg-surface-hover motion-reduce:animate-none dark:bg-surface-active/50`}),(0,$.jsx)(`div`,{className:`h-4 w-full max-w-md animate-pulse rounded-md bg-surface-hover motion-reduce:animate-none dark:bg-surface-active/50`})]}),(0,$.jsx)(Ie,{}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.loading})]})]});if(!u)return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(vn,{title:i.settingsSections.channels,hasToken:o,ch:a,refreshing:ve,saveOk:h,onRefresh:je}),(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:m??c??a.loadError}),(0,$.jsx)(L,{type:`button`,variant:`secondary`,onClick:()=>void l(),children:a.retry})]})]});let Ne=u.weixin,Pe=Se&&X===`weixin`,Fe=Se&&X===`feishu`,Le=(0,$.jsx)(hn,{ch:a,wx:Ne,updateWeixin:ie,dmOpts:me,streamOpts:_e,wxAccountsDraft:B,setWxAccountsDraft:V,wxAccountsError:H,onWxAccountsBlur:fe,form:u,chatAgents:K,onAgentRouteChange:(e,t)=>re(`weixin`,e,t),saving:p,language:r,dialogOpen:Ce&&X===`weixin`,pairingFocus:Pe}),Re=(0,$.jsx)(ut,{ch:a,form:u,baseline:d,showFeishuSecret:O,setShowFeishuSecret:k,showFeishuWebhookSecrets:A,setShowFeishuWebhookSecrets:j,feishuCopied:N,feishuWebhookCopied:ee,copyFeishuSecret:le,copyFeishuWebhookConfig:ue,updateFeishu:ae,updateChannelAgentRoute:re,feishuAccountsDraft:U,setFeishuAccountsDraft:W,feishuAccountsError:G,onFeishuAccountsBlur:pe,dmOpts:me,groupOpts:he,chatAgents:K,saving:p,language:r,dialogOpen:Ce&&X===`feishu`,pairingFocus:Fe});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(vn,{title:i.settingsSections.channels,hasToken:o,ch:a,refreshing:ve,saveOk:h,onRefresh:je}),(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,$.jsxs)(`a`,{href:x(r,`channels`),target:`_blank`,rel:`noreferrer`,className:`inline-flex w-fit items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[a.docsLink,(0,$.jsx)(z,{className:`size-3.5`})]}),m?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:m}):null,_?(0,$.jsx)(`p`,{className:`text-xs text-accent`,children:_}):null,y?(0,$.jsx)(`div`,{className:`rounded-xl border border-success/30 bg-success-soft px-4 py-3 text-sm text-success`,children:y}):null,ve?(0,$.jsx)(Ie,{count:Math.max(be.length,3)}):(0,$.jsx)(Me,{catalog:be,cards:we,ch:a,saving:p,onOpenChannel:De,onToggleChannel:(e,t)=>{D(e)&&Y(e,t)}}),X===`weixin`?(0,$.jsx)(fn,{open:Ce,onOpenChange:ke,ch:a,onLoginSuccess:Ae,moreSettings:Le,settingsDirty:f,settingsSaving:p,onSettingsDiscard:J,onSettingsSave:oe}):null,X===`telegram`?(0,$.jsx)(Ct,{open:Ce,onOpenChange:e=>{e||Oe()},ch:a,form:u,baseline:d,tgAdvanced:b,setTgAdvanced:w,showToken:T,setShowToken:E,copied:M,copyToken:se,updateTelegram:q,updateChannelAgentRoute:re,tgAccountsDraft:F,setTgAccountsDraft:I,tgAccountsError:te,onTgAccountsBlur:de,dmOpts:me,groupOpts:he,replyOpts:ge,streamOpts:_e,chatAgents:K,saving:p,dirty:f,save:oe,discard:J,language:r,scrollToPairingOnOpen:Se,closeOnSave:!1}):null,X===`feishu`?(0,$.jsx)(yt,{open:Ce,onOpenChange:e=>{e||Oe()},ch:a,onSetupSuccess:ce,moreSettings:Re,settingsDirty:f,settingsSaving:p,onSettingsDiscard:J,onSettingsSave:oe}):null,Ee&&Q&&!Ee.manageable?(0,$.jsx)(Ve,{open:Ce,onOpenChange:e=>{e||Oe()},entry:Ee,vm:Q,ch:a,language:r}):null]})]})}function vn(e){let t=(0,Q.c)(12),{title:n,hasToken:r,ch:i,refreshing:a,saveOk:o,onRefresh:s}=e,c=G(bn),l=G(yn),u;t[0]!==i||t[1]!==s||t[2]!==a||t[3]!==o?(u=(0,$.jsx)(He,{ch:i,refreshing:a,saveOk:o,onRefresh:s}),t[0]=i,t[1]=s,t[2]=a,t[3]=o,t[4]=u):u=t[4];let d=u,f,p;return t[5]!==d||t[6]!==l||t[7]!==r||t[8]!==c||t[9]!==n?(f=()=>r?(c({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:n})}),end:d}),()=>l()):(l(),()=>l()),p=[d,l,r,c,n],t[5]=d,t[6]=l,t[7]=r,t[8]=c,t[9]=n,t[10]=f,t[11]=p):(f=t[10],p=t[11]),(0,Z.useLayoutEffect)(f,p),null}function yn(e){return e.clearPageHeader}function bn(e){return e.setPageHeader}export{_n as ChannelsSettingsPanel};
@@ -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{i,o as a,t as o}from"./url-CTjpm0Uz.js";import{i as s}from"./vendor-swr-BIWyz7Rc.js";import{t as c}from"./copy-Dv6d4Dvw.js";import{i as l}from"./theme-store-D6EsNTPr.js";import{a as u,n as d}from"./fetch-BAPnkYbC.js";import{$a as f,A as p,Ao as m,Ci as h,Cr as g,Da as _,Do as v,Dr as y,Er as b,F as x,Fi as S,Fn as C,Gi as w,Go as T,I as E,Ia as D,Ji as O,N as k,Or as A,P as j,Pn as M,Qr as N,Sa as P,Sr as F,Tr as I,Ua as L,Vr as R,Xo as z,_o as B,a as V,ai as H,ao as U,ca as W,ci as G,cr as K,dr as q,fi as ee,h as te,hr as ne,ii as re,jo as J,ko as ie,kr as ae,kt as oe,li as Y,lo as se,lr as ce,mr as le,oa as ue,si as de,ta as fe,ti as pe,ui as X,ur as me,wr as he,zr as ge}from"./index-Do52EfZK.js";import{n as _e,t as ve}from"./settings-form-section-C6cGTVwK.js";import{a as ye,c as be,d as xe,f as Se,l as Ce,n as we,o as Te,r as Ee,s as De,t as Oe,u as ke}from"./settings-advanced-gate-CEs8pGh6.js";import{a as Ae,c as je,d as Me,f as Ne,i as Pe,l as Fe,m as Ie,n as Le,o as Re,p as ze,r as Be,s as Ve,t as He,u as Ue}from"./cron-api-CyAm0xJT.js";import{s as We,t as Ge}from"./heartbeat-config-api-CpgW2sGp.js";import{m as Ke,p as qe,t as Je}from"./workflow-page.utils-DsEriMFW.js";import{i as Ye,n as Xe,o as Ze,r as Qe,t as $e}from"./dist-DHwVV8XK.js";var Z=e(t(),1),Q=n(),$=r();function et(e){let t=(0,Q.c)(25),{open:n,onOpenChange:r,action:i,c:a,onDismiss:o,onConfirm:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[70] bg-scrim`}),t[0]=c):c=t[0];let l=i===`delete`?a.delete:a.runNow,u;t[1]===l?u=t[2]:(u=(0,$.jsx)(ae,{className:`text-base font-semibold text-fg`,children:l}),t[1]=l,t[2]=u);let d=i===`delete`?a.confirmDelete:a.confirmRun,f;t[3]===d?f=t[4]:(f=(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:d}),t[3]=d,t[4]=f);let p;t[5]!==a.cancel||t[6]!==o?(p=(0,$.jsx)(Y,{type:`button`,variant:`secondary`,onClick:o,children:a.cancel}),t[5]=a.cancel,t[6]=o,t[7]=p):p=t[7];let m=i===`delete`?`bg-red-600 hover:bg-red-700`:void 0,h;t[8]===s?h=t[9]:(h=()=>void s(),t[8]=s,t[9]=h);let g=i===`delete`?a.delete:a.runNow,_;t[10]!==m||t[11]!==h||t[12]!==g?(_=(0,$.jsx)(Y,{type:`button`,variant:`primary`,className:m,onClick:h,children:g}),t[10]=m,t[11]=h,t[12]=g,t[13]=_):_=t[13];let v;t[14]!==_||t[15]!==p?(v=(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[p,_]}),t[14]=_,t[15]=p,t[16]=v):v=t[16];let x;t[17]!==v||t[18]!==u||t[19]!==f?(x=(0,$.jsxs)(y,{children:[c,(0,$.jsx)(`div`,{className:`fixed inset-0 z-[70] flex items-center justify-center p-4 pointer-events-none`,children:(0,$.jsxs)(he,{className:`xopc-dialog-content-pane pointer-events-auto relative w-full max-w-md rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`,children:[u,f,v]})})]}),t[17]=v,t[18]=u,t[19]=f,t[20]=x):x=t[20];let S;return t[21]!==r||t[22]!==n||t[23]!==x?(S=(0,$.jsx)(A,{open:n,onOpenChange:r,children:x}),t[21]=r,t[22]=n,t[23]=x,t[24]=S):S=t[24],S}var tt={enabled:!0,maxConcurrentJobs:5,defaultTimezone:`UTC`,historyRetentionDays:7,enableMetrics:!0};function nt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function rt(e){let t=nt(e)?e:{},n=nt(t.cron)?t.cron:{};return{enabled:n.enabled!==!1,maxConcurrentJobs:typeof n.maxConcurrentJobs==`number`&&Number.isFinite(n.maxConcurrentJobs)?Math.max(1,Math.min(100,Math.floor(n.maxConcurrentJobs))):tt.maxConcurrentJobs,defaultTimezone:typeof n.defaultTimezone==`string`&&n.defaultTimezone.trim()?n.defaultTimezone.trim():tt.defaultTimezone,historyRetentionDays:typeof n.historyRetentionDays==`number`&&Number.isFinite(n.historyRetentionDays)?Math.max(1,Math.min(365,Math.floor(n.historyRetentionDays))):tt.historyRetentionDays,enableMetrics:n.enableMetrics!==!1}}async function it(e){await d(o(`/api/config`),{method:`PATCH`,body:JSON.stringify({cron:e})}),me()}function at(){return X(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,G,`dark:border-edge`)}function ot(){return{form:null,baseline:null,saving:!1,error:null,saveOk:!1,dirty:!1}}function st(e,t){switch(t.type){case`sync`:return{...e,form:structuredClone(t.parsed),baseline:structuredClone(t.parsed),saveOk:!1,dirty:!1};case`patch`:return e.form?{...e,form:{...e.form,...t.patch},dirty:!0,saveOk:!1}:e;case`discard`:return e.baseline?{...e,form:structuredClone(e.baseline),dirty:!1}:e;case`saveStart`:return{...e,saving:!0,error:null};case`saveSuccess`:return e.form?{...e,saving:!1,baseline:structuredClone(e.form),dirty:!1,saveOk:!0}:{...e,saving:!1};case`saveError`:return{...e,saving:!1,error:t.error};case`clearSaveOk`:return{...e,saveOk:!1}}}function ct({hasToken:e}){let t=a(i(e=>e.language)).cron.globals,{data:n,isLoading:r}=q(e),o=(0,Z.useMemo)(()=>n?.payload?.config===void 0?null:structuredClone(rt(n.payload.config)),[n]),[s,c]=(0,Z.useReducer)(st,void 0,ot),l=(0,Z.useRef)(o);e&&o!==null&&!s.dirty&&l.current!==o&&(l.current=o,c({type:`sync`,parsed:o}));let u=(0,Z.useMemo)(()=>!!(s.form&&s.baseline&&JSON.stringify(s.form)!==JSON.stringify(s.baseline)),[s.form,s.baseline]),d=(0,Z.useCallback)(e=>{c({type:`patch`,patch:e})},[]),f=(0,Z.useCallback)(async()=>{if(!(!s.form||s.saving)){c({type:`saveStart`});try{await it(s.form),c({type:`saveSuccess`}),window.setTimeout(()=>c({type:`clearSaveOk`}),2500)}catch(e){c({type:`saveError`,error:e instanceof Error?e.message:t.saveError})}}},[t.saveError,s.form,s.saving]);return!e||!s.form?r?(0,$.jsx)(ve,{children:(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(_,{className:`size-4 animate-spin`}),t.loading]})}):null:(0,$.jsxs)(ve,{children:[(0,$.jsx)(_e,{icon:B,title:t.title,subtitle:t.hint}),(0,$.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-end gap-2`,children:[s.saveOk?(0,$.jsx)(`span`,{className:`text-sm text-fg-muted`,children:t.saved}):null,(0,$.jsx)(Y,{type:`button`,variant:`secondary`,disabled:!u||s.saving,onClick:()=>c({type:`discard`}),children:t.discard}),(0,$.jsx)(Y,{type:`button`,variant:`primary`,disabled:!u||s.saving,onClick:()=>void f(),children:s.saving?t.saving:t.save})]}),s.error?(0,$.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:s.error}):null,(0,$.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg sm:col-span-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:s.form.enabled,onChange:e=>d({enabled:e.target.checked})}),t.enabled]}),(0,$.jsxs)(Oe,{children:[(0,$.jsx)(lt,{label:t.maxConcurrent,value:s.form.maxConcurrentJobs,min:1,max:100,disabled:!s.form.enabled,onChange:e=>d({maxConcurrentJobs:e})}),(0,$.jsx)(lt,{label:t.timezone,text:!0,value:s.form.defaultTimezone,disabled:!s.form.enabled,onTextChange:e=>d({defaultTimezone:e})}),(0,$.jsx)(lt,{label:t.retentionDays,value:s.form.historyRetentionDays,min:1,max:365,disabled:!s.form.enabled,onChange:e=>d({historyRetentionDays:e})}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:s.form.enableMetrics,disabled:!s.form.enabled,onChange:e=>d({enableMetrics:e.target.checked})}),t.metrics]})]})]})]})}function lt(e){let t=(0,Q.c)(13),{label:n,value:r,min:i,max:a,disabled:o,text:s,onChange:c,onTextChange:l}=e,u;t[0]===n?u=t[1]:(u=(0,$.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=u);let d;t[2]!==o||t[3]!==a||t[4]!==i||t[5]!==c||t[6]!==l||t[7]!==s||t[8]!==r?(d=s?(0,$.jsx)(`input`,{className:X(at(),`font-mono text-xs`),value:String(r),disabled:o,onChange:e=>l?.(e.target.value)}):(0,$.jsx)(`input`,{type:`number`,min:i,max:a,disabled:o,className:X(at(),`max-w-xs font-mono text-xs`),value:typeof r==`number`?r:0,onChange:e=>{let t=Number(e.target.value);Number.isFinite(t)&&c&&i!==void 0&&a!==void 0&&c(Math.max(i,Math.min(a,Math.floor(t))))}}),t[2]=o,t[3]=a,t[4]=i,t[5]=c,t[6]=l,t[7]=s,t[8]=r,t[9]=d):d=t[9];let f;return t[10]!==u||t[11]!==d?(f=(0,$.jsxs)(`div`,{children:[u,d]}),t[10]=u,t[11]=d,t[12]=f):f=t[12],f}var ut=`*/5 * * * *`,dt=2100*1e3;function ft(e){let t=new Date(e);return t.setHours(0,0,0,0),t}function pt(e){let t=ft(e),n=t.getDay(),r=n===0?-6:1-n;return t.setDate(t.getDate()+r),t}function mt(e){return new Date(e.getFullYear(),e.getMonth(),1,0,0,0,0)}function ht(e){let t=e?.trim();t&&window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:t},bubbles:!0}))}function gt(e){let t=e?.trim();t&&(window.location.hash=`/workflows?run=${encodeURIComponent(t)}`)}function _t(e){return X(`w-full rounded-md border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-disabled`,re,e&&`cursor-not-allowed opacity-60`)}function vt(){return X(de,H)}var yt=X(de,`w-full text-xs sm:w-auto sm:min-w-[11rem] sm:max-w-[17rem] sm:shrink-0`),bt=X(de,`w-auto min-w-[9rem] max-w-[14rem] shrink-0 text-xs`);function xt(e){return e===`settings`?`settings`:e===`system`||e===`systemTasks`?`systemTasks`:e===`history`?`history`:`myTasks`}function St(e){return e===`myTasks`?null:e===`systemTasks`?`system`:e===`history`?`history`:`settings`}function Ct(e){switch(e){case`success`:return`bg-emerald-500/15 text-emerald-800 dark:text-emerald-300`;case`failed`:return`bg-red-500/15 text-red-800 dark:text-red-300`;case`running`:return`bg-accent/15 text-accent`;case`cancelled`:return`bg-surface-hover text-fg-muted`;default:return`bg-surface-hover text-fg-muted`}}function wt(e,t){return e.payload.kind===`workflowRun`?t.taskKindWorkflowRun:e.payload.kind===`agentTurn`?t.taskKindMessage:t.modeDirectOption}function Tt(e){return e.length===0?null:e.find(e=>e.status===`failed`)?.id??e[0]?.id??null}function Et(e){let t=(0,Q.c)(56),{row:n,expanded:r,onToggle:i,c:a,statusLabels:o}=e,s=n.error||n.summary||n.output||``,c;t[0]===s?c=t[1]:(c=s.trim(),t[0]=s,t[1]=c);let l=c,u=l.length>0,d;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`div`,{className:`mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover`,children:(0,$.jsx)(B,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0})}),t[2]=d):d=t[2];let p=n.startedAt,m;t[3]===n.startedAt?m=t[4]:(m=xe(n.startedAt),t[3]=n.startedAt,t[4]=m);let h;t[5]!==n.startedAt||t[6]!==m?(h=(0,$.jsx)(`time`,{className:`text-sm font-medium text-fg`,dateTime:p,children:m}),t[5]=n.startedAt,t[6]=m,t[7]=h):h=t[7];let g;t[8]===n.status?g=t[9]:(g=X(`inline-flex rounded-md px-2 py-0.5 text-xs font-medium`,Ct(n.status)),t[8]=n.status,t[9]=g);let _;t[10]!==n.status||t[11]!==o?(_=ye(n.status,o),t[10]=n.status,t[11]=o,t[12]=_):_=t[12];let v;t[13]!==g||t[14]!==_?(v=(0,$.jsx)(`span`,{className:g,children:_}),t[13]=g,t[14]=_,t[15]=v):v=t[15];let y;t[16]===n.duration?y=t[17]:(y=De(n.duration),t[16]=n.duration,t[17]=y);let b;t[18]===y?b=t[19]:(b=(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:y}),t[18]=y,t[19]=b);let x;t[20]!==b||t[21]!==h||t[22]!==v?(x=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[h,v,b]}),t[20]=b,t[21]=h,t[22]=v,t[23]=x):x=t[23];let S;t[24]!==l||t[25]!==r||t[26]!==u?(S=!r&&u?(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:l}):null,t[24]=l,t[25]=r,t[26]=u,t[27]=S):S=t[27];let C;t[28]!==l||t[29]!==r||t[30]!==u?(C=r&&u?(0,$.jsx)(`pre`,{className:`mt-2 max-h-40 overflow-y-auto whitespace-pre-wrap break-words rounded-lg border border-edge-subtle bg-surface-panel/80 p-2.5 font-mono text-xs leading-relaxed text-fg-muted`,children:l}):null,t[28]=l,t[29]=r,t[30]=u,t[31]=C):C=t[31];let w;t[32]!==x||t[33]!==S||t[34]!==C?(w=(0,$.jsxs)(`div`,{className:`flex items-start gap-3 px-3 py-3`,children:[d,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[x,S,C]})]}),t[32]=x,t[33]=S,t[34]=C,t[35]=w):w=t[35];let T;t[36]!==a||t[37]!==r||t[38]!==u||t[39]!==i?(T=u?(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:i,children:[(0,$.jsx)(ie,{className:X(`size-3.5 transition-transform`,r&&`rotate-180`),strokeWidth:1.75,"aria-hidden":!0}),r?a.detailCollapseRun:a.detailExpandRun]}):null,t[36]=a,t[37]=r,t[38]=u,t[39]=i,t[40]=T):T=t[40];let E;t[41]!==a||t[42]!==n.workflowRunId?(E=n.workflowRunId?.trim()?(0,$.jsxs)(Y,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5 px-2.5 text-xs`,title:a.openWorkflowTitle,onClick:()=>gt(n.workflowRunId),children:[(0,$.jsx)(f,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),a.openWorkflow]}):null,t[41]=a,t[42]=n.workflowRunId,t[43]=E):E=t[43];let D;t[44]!==a||t[45]!==n.sessionKey?(D=n.sessionKey?.trim()?(0,$.jsxs)(Y,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5 px-2.5 text-xs`,title:a.openChatTitle,onClick:()=>ht(n.sessionKey),children:[(0,$.jsx)(P,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),a.openChat]}):null,t[44]=a,t[45]=n.sessionKey,t[46]=D):D=t[46];let O;t[47]!==E||t[48]!==D?(O=(0,$.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[E,D]}),t[47]=E,t[48]=D,t[49]=O):O=t[49];let k;t[50]!==T||t[51]!==O?(k=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-edge-subtle px-3 py-2 dark:border-edge-subtle`,children:[T,O]}),t[50]=T,t[51]=O,t[52]=k):k=t[52];let A;return t[53]!==w||t[54]!==k?(A=(0,$.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-base dark:border-edge-subtle`,children:[w,k]}),t[53]=w,t[54]=k,t[55]=A):A=t[55],A}function Dt(e){let t=(0,Q.c)(13),{icon:n,label:r,value:i,valueClassName:a}=e,o;t[0]===n?o=t[1]:(o=(0,$.jsx)(n,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=n,t[1]=o);let s;t[2]!==r||t[3]!==o?(s=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:[o,r]}),t[2]=r,t[3]=o,t[4]=s):s=t[4];let c;t[5]===a?c=t[6]:(c=X(`mt-1 truncate text-sm font-medium text-fg`,a),t[5]=a,t[6]=c);let l;t[7]!==c||t[8]!==i?(l=(0,$.jsx)(`p`,{className:c,children:i}),t[7]=c,t[8]=i,t[9]=l):l=t[9];let u;return t[10]!==s||t[11]!==l?(u=(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-edge-subtle bg-surface-base/80 px-3 py-2.5 dark:border-edge-subtle`,children:[s,l]}),t[10]=s,t[11]=l,t[12]=u):u=t[12],u}function Ot({open:e,onDismiss:t,detailJob:n,detailLoading:r,detailHistory:i,c:a,localeTag:o,scheduleBadgeLabels:s,chatWorkingDirNotSet:l,statusLabels:u,onEdit:d,onRunNow:f,onToggle:p,onDelete:v}){let[x,S]=(0,Z.useState)(!1),[C,T]=(0,Z.useState)(null),[E,D]=(0,Z.useState)(!1),O=(0,Z.useMemo)(()=>{let e=0,t=0;for(let n of i)n.status===`success`&&(e+=1),n.status===`failed`&&(t+=1);return{success:e,failed:t}},[i]),k=i[0]??null;(0,Z.useEffect)(()=>{if(!e){S(!1),T(null),D(!1);return}T(Tt(i))},[e,n?.id,i]);let j=(0,Z.useCallback)(async()=>{n?.schedule&&await N(n.schedule)&&(D(!0),window.setTimeout(()=>D(!1),1500))},[n?.schedule]),P=n?ke(n,o,s):`—`;return(0,$.jsx)(A,{open:e,onOpenChange:e=>{e||t()},children:(0,$.jsxs)(y,{children:[(0,$.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim backdrop-blur-[1px]`}),(0,$.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center p-4 pointer-events-none`,children:(0,$.jsxs)(he,{className:X(`xopc-dialog-content-pane pointer-events-auto relative flex w-full max-w-lg flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,`max-h-[min(85vh,44rem)]`,`dark:border-edge`),"aria-describedby":void 0,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(ae,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n?.name?.trim()||n?.id||`—`}),n?(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:P}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[n?(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n.enabled,"aria-label":n.enabled?a.enabled:a.disabled,className:X(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,n.enabled?`justify-end bg-accent`:`justify-start bg-surface-hover`),onClick:()=>p(n,!n.enabled),children:(0,$.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`})}):null,(0,$.jsx)(g,{asChild:!0,children:(0,$.jsx)(Y,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":a.close,children:(0,$.jsx)(ee,{className:`size-5`,strokeWidth:1.75})})})]})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-4`,children:r?(0,$.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,$.jsx)(_,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):n?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.scheduleLabel}),(0,$.jsxs)(`div`,{className:`mt-2 rounded-xl border border-edge-subtle bg-surface-base/80 px-3 py-3 dark:border-edge-subtle`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`min-w-0 flex-1 text-sm font-medium leading-relaxed text-fg`,children:P}),(0,$.jsx)(Y,{type:`button`,variant:`secondary`,className:`size-8 shrink-0 p-0`,title:a.detailCopySchedule,"aria-label":a.detailCopySchedule,onClick:()=>void j(),children:E?(0,$.jsx)(m,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`,strokeWidth:1.75}):(0,$.jsx)(c,{className:`size-3.5`,strokeWidth:1.75})})]}),(0,$.jsxs)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:[(0,$.jsxs)(`span`,{className:`font-medium text-fg-subtle`,children:[a.detailCronTechnical,`: `]}),(0,$.jsx)(`code`,{className:`font-mono`,children:n.schedule})]})]})]}),(0,$.jsxs)(`section`,{"aria-label":a.statsRegion,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(Dt,{icon:J,label:a.nextRun,value:n.next_run?be(n.next_run,a.timeLabels):`—`}),(0,$.jsx)(Dt,{icon:B,label:a.detailLastRun,value:k?ye(k.status,u):a.detailNoRecentRuns,valueClassName:k?.status===`failed`?`text-red-700 dark:text-red-300`:k?.status===`success`?`text-emerald-800 dark:text-emerald-300`:void 0})]}),i.length>0?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:a.detailRunCount.replace(`{{success}}`,String(O.success)).replace(`{{failed}}`,String(O.failed))}):null]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.detailWhatItDoes}),(0,$.jsxs)(`div`,{className:`mt-2 rounded-xl border border-edge-subtle bg-surface-base/80 p-3 dark:border-edge-subtle`,children:[(0,$.jsx)(`div`,{className:`mb-2 inline-flex rounded-md bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:wt(n,a)}),(0,$.jsx)(`div`,{className:`min-w-0 break-words text-fg [&_.markdown-body]:text-sm [&_.markdown-body]:leading-relaxed`,children:(0,$.jsx)(M,{content:Le(n),compact:!0,className:`text-sm`})})]})]}),(0,$.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base/35`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-start justify-between gap-3 px-4 py-3 text-left`,"aria-expanded":x,onClick:()=>S(e=>!e),children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(w,{className:`size-4 shrink-0 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.detailRunSettings})]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:a.detailRunSettingsHint})]}),(0,$.jsx)(ie,{className:X(`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform`,x&&`rotate-180`),"aria-hidden":!0})]}),x?(0,$.jsxs)(`dl`,{className:`grid gap-3 border-t border-edge px-4 py-4 text-sm`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:a.mode}),(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:n.sessionTarget===`isolated`?a.modeAgentOption:a.modeDirectOption})]}),n.sessionTarget===`isolated`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:a.agentProfile}),(0,$.jsx)(`dd`,{className:`mt-1 font-mono text-sm text-fg`,children:n.agentId?.trim()?n.agentId.trim():a.agentProfileDefault})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:a.workingDirectoryLabel}),(0,$.jsx)(`dd`,{className:`mt-1 break-all font-mono text-xs text-fg`,children:n.workingDirectory?.trim()?n.workingDirectory.trim():l})]})]}):null,n.delivery?.channel===`local`||n.sessionTarget===`isolated`&&!n.delivery?.to?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:a.deliveryTarget}),(0,$.jsx)(`dd`,{className:`mt-1 text-fg`,children:n.delivery?.channel===`local`?a.deliveryTargetLocalChannel:a.deliveryLocalOnly})]}):n.delivery?.to?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:a.deliveryTarget}),(0,$.jsxs)(`dd`,{className:`mt-1 break-words text-fg`,children:[(0,$.jsx)(`code`,{className:`text-xs`,children:n.delivery?.channel??``}),` → `,Te(n,a.channelLocal)]})]}):null,n.model?.trim()?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:a.model}),(0,$.jsx)(`dd`,{className:`mt-1 font-mono text-sm text-fg`,children:n.model.trim()})]}):null]}):null]}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.detailRunHistory}),i.length>0?(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:i.length}):null]}),i.length===0?(0,$.jsxs)(`div`,{className:`mt-2 rounded-xl border border-dashed border-edge-subtle px-4 py-8 text-center dark:border-edge-subtle`,children:[(0,$.jsx)(B,{className:`mx-auto size-8 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:a.noRunsYet})]}):(0,$.jsx)(`ul`,{className:`mt-2 space-y-2`,children:i.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsx)(Et,{row:e,expanded:C===e.id,onToggle:()=>T(t=>t===e.id?null:e.id),c:a,statusLabels:u})},e.id))})]})]}):null}),n&&!r?(0,$.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(Y,{type:`button`,className:`gap-1.5`,onClick:()=>f(n),children:[(0,$.jsx)(W,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),a.runNow]}),(0,$.jsx)(Y,{type:`button`,variant:`secondary`,onClick:()=>d(n),children:a.edit}),(0,$.jsxs)(Y,{type:`button`,variant:`secondary`,className:`ml-auto text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`,onClick:()=>v(n),children:[(0,$.jsx)(h,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),a.delete]})]})}):null]})})]})})}function kt(e){let t=(0,Q.c)(31),{value:n,onChange:r,disabled:i,wd:a,placeholder:o,title:s,maxWidthClass:c,clearLabel:l,onClear:u}=e,d;t[0]!==r||t[1]!==n?(d={initialPath:n,onPicked:r},t[0]=r,t[1]=n,t[2]=d):d=t[2];let f=j(d),m;t[3]===n?m=t[4]:(m=n.trim(),t[3]=n,t[4]=m);let h=m,g=s??(h?`${h}\n${a.chooseFolder}`:`${o??a.notSet}\n${a.selectWorkingDirectory}`),_=i||f.picking,v=o??a.notSet,y;t[5]!==c||t[6]!==f.pick||t[7]!==g||t[8]!==_||t[9]!==v||t[10]!==n?(y=(0,$.jsx)(x,{value:n,onPick:f.pick,disabled:_,placeholder:v,title:g,maxWidthClass:c}),t[5]=c,t[6]=f.pick,t[7]=g,t[8]=_,t[9]=v,t[10]=n,t[11]=y):y=t[11];let b;t[12]!==l||t[13]!==i||t[14]!==u||t[15]!==f.picking||t[16]!==h?(b=l&&h&&u?(0,$.jsx)(`button`,{type:`button`,disabled:i||f.picking,className:`text-xs font-medium text-accent hover:underline disabled:opacity-50`,onClick:u,children:l}):null,t[12]=l,t[13]=i,t[14]=u,t[15]=f.picking,t[16]=h,t[17]=b):b=t[17];let S;t[18]!==y||t[19]!==b?(S=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[y,b]}),t[18]=y,t[19]=b,t[20]=S):S=t[20];let C;t[21]!==f.confirmPick||t[22]!==f.hasNativePicker||t[23]!==f.modalOpen||t[24]!==f.setModalOpen||t[25]!==h||t[26]!==a?(C=f.hasNativePicker?null:(0,$.jsx)(p,{open:f.modalOpen,onOpenChange:f.setModalOpen,initialAbsolutePath:h||void 0,onConfirm:f.confirmPick,wd:a}),t[21]=f.confirmPick,t[22]=f.hasNativePicker,t[23]=f.modalOpen,t[24]=f.setModalOpen,t[25]=h,t[26]=a,t[27]=C):C=t[27];let w;return t[28]!==S||t[29]!==C?(w=(0,$.jsxs)($.Fragment,{children:[S,C]}),t[28]=S,t[29]=C,t[30]=w):w=t[30],w}function At(e,t){return e[t]??t}function jt(e,t){let n=V[e]??[];if(n.length===0)return{};let r=t&&typeof t==`object`&&!Array.isArray(t)?t:{},i={};for(let e of n){let t=r[e.key];t!=null&&(i[e.key]=String(t))}return i}function Mt(e,t){return(V[e]??[]).every(e=>!e.required||!!t[e.key]?.trim())}function Nt(e){let t=(0,Q.c)(12),{examples:n,labels:r,onSelect:i}=e;if(n.length===0)return null;let a;t[0]===r.examplePrompts?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:r.examplePrompts}),t[0]=r.examplePrompts,t[1]=a);let o;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`rounded-lg border border-edge bg-surface-base/50 px-3 py-2 text-left text-xs text-fg-muted hover:bg-surface-hover`,children:e.text},`${e.field}:${e.text}`),t[5]=i,t[6]=e),o=n.map(e),t[2]=n,t[3]=i,t[4]=o}else o=t[4];let s;t[7]===o?s=t[8]:(s=(0,$.jsx)(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:o}),t[7]=o,t[8]=s);let c;return t[9]!==a||t[10]!==s?(c=(0,$.jsxs)(`div`,{children:[a,s]}),t[9]=a,t[10]=s,t[11]=c):c=t[11],c}function Pt(e){let t=(0,Q.c)(33),{workflowName:n,language:r,argValues:i,onArgValuesChange:o,goal:s,onGoalChange:c,examplePrompts:l,showGoal:u,inputClassName:d}=e,f;t[0]===l?f=t[1]:(f=l===void 0?[]:l,t[0]=l,t[1]=f);let p=f,m=u===void 0?!0:u,h,g,_,v,y,b,x;if(t[2]!==i||t[3]!==p||t[4]!==s||t[5]!==d||t[6]!==r||t[7]!==o||t[8]!==c||t[9]!==m||t[10]!==n){_=a(r).workflows;let e=V[n]??[];g=e.length>0;let l=X(`mt-1.5 w-full rounded-xl border border-edge bg-surface-base px-3 py-2 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,d),u;t[18]!==i||t[19]!==o||t[20]!==c?(u=e=>{qe(e,c,e=>{o(e(i))})},t[18]=i,t[19]=o,t[20]=c,t[21]=u):u=t[21],h=u,v=`flex flex-col gap-3`,y=e.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`span`,{className:`text-xs font-medium text-fg-muted`,children:[At(_.args,e.labelKey),e.required?` *`:``]}),e.multiline?(0,$.jsx)(`textarea`,{value:i[e.key]??``,onChange:t=>o({...i,[e.key]:t.target.value}),placeholder:At(_.args,e.placeholderKey),className:X(l,`min-h-20 resize-y`)}):(0,$.jsx)(`input`,{value:i[e.key]??``,onChange:t=>o({...i,[e.key]:t.target.value}),placeholder:At(_.args,e.placeholderKey),className:l})]},e.key)),b=g&&p.length>0?(0,$.jsx)(Nt,{examples:p,labels:_,onSelect:h}):null,x=m?(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:_.goalLabel}),(0,$.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),placeholder:_.goalPlaceholder,className:X(l,`min-h-20 resize-y`)})]}):null,t[2]=i,t[3]=p,t[4]=s,t[5]=d,t[6]=r,t[7]=o,t[8]=c,t[9]=m,t[10]=n,t[11]=h,t[12]=g,t[13]=_,t[14]=v,t[15]=y,t[16]=b,t[17]=x}else h=t[11],g=t[12],_=t[13],v=t[14],y=t[15],b=t[16],x=t[17];let S;t[22]!==h||t[23]!==p||t[24]!==g||t[25]!==_?(S=!g&&p.length>0?(0,$.jsx)(Nt,{examples:p,labels:_,onSelect:h}):null,t[22]=h,t[23]=p,t[24]=g,t[25]=_,t[26]=S):S=t[26];let C;return t[27]!==v||t[28]!==y||t[29]!==b||t[30]!==x||t[31]!==S?(C=(0,$.jsxs)(`div`,{className:v,children:[y,b,x,S]}),t[27]=v,t[28]=y,t[29]=b,t[30]=x,t[31]=S,t[32]=C):C=t[32],C}function Ft(e){let t=(0,Q.c)(190),{open:n,onRequestClose:r,c:a,chatM:o,agentsMessages:s,isDark:c,channels:l,sessionChatIds:u,cronAgentSelectOptions:d,defaultModelResolver:f,formMode:p,formJobId:m,formName:h,onFormNameChange:_,formSchedule:v,onFormScheduleChange:x,formSubmitting:w,formTaskKind:T,onFormTaskKindChange:D,workflowDefinitions:O,workflowDefinitionsLoading:k,formWorkflowDefinitionId:j,onFormWorkflowDefinitionIdChange:N,formWorkflowGoal:P,onFormWorkflowGoalChange:F,formWorkflowArgValues:I,onFormWorkflowArgValuesChange:L,formSessionTarget:R,onFormSessionTargetChange:z,formAgentLocalOnly:B,onFormAgentLocalOnlyChange:V,formModel:H,onFormModelUserChange:W,formAgentId:G,onFormAgentIdChange:K,formWorkingDirectory:q,onFormWorkingDirectoryChange:te,formChannel:ne,onFormChannelChange:re,formChatId:J,onFormChatIdChange:ie,formMessage:se,onFormMessageChange:ce,formMessageMdMode:le,onSetMessageMdMode:ue,messageEditorNonce:de,needsDeliveryChat:pe,showChannelPicker:me,canSubmit:ge,onSubmit:_e,onRefreshRecipients:ve}=e,ye=i(zt),be,xe;if(t[0]!==j||t[1]!==ye||t[2]!==O){let e;t[5]===j?e=t[6]:(e=e=>e.id===j.trim(),t[5]=j,t[6]=e),be=O.find(e),xe=be?Ke(be,ye):null,t[0]=j,t[1]=ye,t[2]=O,t[3]=be,t[4]=xe}else be=t[3],xe=t[4];let Se=xe,we;t[7]===r?we=t[8]:(we=e=>!e&&r(),t[7]=r,t[8]=we);let Te;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(Te=(0,$.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[9]=Te):Te=t[9];let Ee=p===`edit`?a.editJob:a.addJob,De;t[10]===Ee?De=t[11]:(De=(0,$.jsx)(ae,{className:`text-base font-semibold text-fg`,children:Ee}),t[10]=Ee,t[11]=De);let Oe;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=(0,$.jsx)(ee,{className:`size-5`,strokeWidth:1.75}),t[12]=Oe):Oe=t[12];let ke;t[13]===a.close?ke=t[14]:(ke=(0,$.jsx)(g,{asChild:!0,children:(0,$.jsx)(Y,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":a.close,children:Oe})}),t[13]=a.close,t[14]=ke);let Ae;t[15]!==De||t[16]!==ke?(Ae=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3`,children:[De,ke]}),t[15]=De,t[16]=ke,t[17]=Ae):Ae=t[17];let je;t[18]===a.name?je=t[19]:(je=(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.name}),t[18]=a.name,t[19]=je);let Me;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(Me=_t(),t[20]=Me):Me=t[20];let Ne;t[21]===_?Ne=t[22]:(Ne=e=>_(e.target.value),t[21]=_,t[22]=Ne);let Pe;t[23]!==a.namePlaceholder||t[24]!==h||t[25]!==Ne?(Pe=(0,$.jsx)(`input`,{type:`text`,className:Me,value:h,onChange:Ne,placeholder:a.namePlaceholder}),t[23]=a.namePlaceholder,t[24]=h,t[25]=Ne,t[26]=Pe):Pe=t[26];let Fe;t[27]!==Pe||t[28]!==je?(Fe=(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[je,Pe]}),t[27]=Pe,t[28]=je,t[29]=Fe):Fe=t[29];let Ie;t[30]!==a.schedulePicker||t[31]!==v||t[32]!==w||t[33]!==x?(Ie=(0,$.jsx)(We,{value:v,onChange:x,disabled:w,labels:a.schedulePicker}),t[30]=a.schedulePicker,t[31]=v,t[32]=w,t[33]=x,t[34]=Ie):Ie=t[34];let Le;t[35]===a.taskKind?Le=t[36]:(Le=(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.taskKind}),t[35]=a.taskKind,t[36]=Le);let Re;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(Re=vt(),t[37]=Re):Re=t[37];let ze;t[38]===D?ze=t[39]:(ze=e=>D(e.target.value),t[38]=D,t[39]=ze);let Be;t[40]===a.taskKindMessage?Be=t[41]:(Be=(0,$.jsx)(`option`,{value:`message`,children:a.taskKindMessage}),t[40]=a.taskKindMessage,t[41]=Be);let Ve;t[42]===a.taskKindWorkflowRun?Ve=t[43]:(Ve=(0,$.jsx)(`option`,{value:`workflowRun`,children:a.taskKindWorkflowRun}),t[42]=a.taskKindWorkflowRun,t[43]=Ve);let He;t[44]!==w||t[45]!==T||t[46]!==ze||t[47]!==Be||t[48]!==Ve?(He=(0,$.jsxs)(`select`,{className:Re,value:T,disabled:w,onChange:ze,children:[Be,Ve]}),t[44]=w,t[45]=T,t[46]=ze,t[47]=Be,t[48]=Ve,t[49]=He):He=t[49];let Ue;t[50]!==Le||t[51]!==He?(Ue=(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[Le,He]}),t[50]=Le,t[51]=He,t[52]=Ue):Ue=t[52];let Ge;t[53]!==s||t[54]!==a.agentProfile||t[55]!==a.agentProfileDefault||t[56]!==a.agentProfileHint||t[57]!==a.channel||t[58]!==a.channelLocal||t[59]!==a.lastActiveLabels||t[60]!==a.noRecentChatsOption||t[61]!==a.recipient||t[62]!==a.recipientPlaceholder||t[63]!==a.refreshList||t[64]!==a.refreshRecipientHint||t[65]!==a.selectRecipient||t[66]!==a.workflowDefinition||t[67]!==a.workflowDefinitionCustom||t[68]!==a.workflowDefinitionMissing||t[69]!==a.workflowDefinitionPlaceholder||t[70]!==a.workflowDefinitionsEmpty||t[71]!==a.workflowDefinitionsLoading||t[72]!==a.workflowDeliveryHint||t[73]!==a.workflowLocalOnly||t[74]!==a.workflowLocalOnlyHint||t[75]!==l||t[76]!==d||t[77]!==G||t[78]!==B||t[79]!==ne||t[80]!==J||t[81]!==w||t[82]!==T||t[83]!==I||t[84]!==j||t[85]!==P||t[86]!==ye||t[87]!==pe||t[88]!==K||t[89]!==V||t[90]!==re||t[91]!==ie||t[92]!==L||t[93]!==N||t[94]!==F||t[95]!==ve||t[96]!==be||t[97]!==Se||t[98]!==u||t[99]!==me||t[100]!==O||t[101]!==k?(Ge=T===`workflowRun`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.workflowDefinition}),(0,$.jsxs)(`select`,{className:vt(),value:j,disabled:w||k,onChange:e=>N(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:k?a.workflowDefinitionsLoading:a.workflowDefinitionPlaceholder}),j.trim()&&!O.some(e=>e.id===j.trim())?(0,$.jsx)(`option`,{value:j,children:j}):null,O.map(e=>(0,$.jsxs)(`option`,{value:e.id,children:[e.title,e.metadata.source===`user`?` (${a.workflowDefinitionCustom})`:``]},e.id))]}),!k&&O.length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.workflowDefinitionsEmpty}):null,Se?(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:Se.description}):j.trim()&&!be?(0,$.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:a.workflowDefinitionMissing}):null]}),j.trim()?(0,$.jsx)(Pt,{workflowName:j.trim(),language:ye,argValues:I,onArgValuesChange:L,goal:P,onGoalChange:F,examplePrompts:Se?.examplePrompts??[],inputClassName:_t()}):null,(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.agentProfile}),(0,$.jsxs)(`select`,{className:vt(),value:G,disabled:w,onChange:e=>K(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:a.agentProfileDefault}),d.map(e=>(0,$.jsx)(`option`,{value:e.id,children:`${e.id} — ${oe(e,s)}`},e.id))]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.agentProfileHint})]}),(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md bg-surface-hover/45 px-3 py-2 dark:bg-surface-hover/30`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:X(`ui-checkbox`,`mt-0.5`),checked:B,onChange:e=>V(e.target.checked),"aria-label":a.workflowLocalOnly}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:a.workflowLocalOnly}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.workflowLocalOnlyHint})]})]}),me?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.channel}),(0,$.jsxs)(`select`,{className:vt(),value:ne,onChange:e=>re(e.target.value),children:[(0,$.jsx)(`option`,{value:`local`,children:a.channelLocal}),l.map(Lt)]})]}),pe?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.recipient}),(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,title:a.refreshRecipientHint,onClick:()=>void ve(),children:[(0,$.jsx)(fe,{className:`size-3.5`,strokeWidth:1.75}),a.refreshList]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch sm:gap-2`,children:[(0,$.jsx)(`input`,{type:`text`,className:X(_t(),`min-w-0 w-full sm:flex-1`),value:J,onChange:e=>ie(e.target.value),placeholder:a.recipientPlaceholder}),(0,$.jsxs)(`select`,{className:yt,value:J,onChange:e=>{let t=e.target.value;t&&ie(t)},children:[(0,$.jsx)(`option`,{value:``,children:a.selectRecipient}),u.length>0?u.map(e=>(0,$.jsx)(`option`,{value:e.chatId,children:Ce(e,a.lastActiveLabels)},`${e.channel}-${e.chatId}`)):(0,$.jsx)(`option`,{value:``,disabled:!0,children:a.noRecentChatsOption})]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.workflowDeliveryHint})]}):null]}):null]}):null,t[53]=s,t[54]=a.agentProfile,t[55]=a.agentProfileDefault,t[56]=a.agentProfileHint,t[57]=a.channel,t[58]=a.channelLocal,t[59]=a.lastActiveLabels,t[60]=a.noRecentChatsOption,t[61]=a.recipient,t[62]=a.recipientPlaceholder,t[63]=a.refreshList,t[64]=a.refreshRecipientHint,t[65]=a.selectRecipient,t[66]=a.workflowDefinition,t[67]=a.workflowDefinitionCustom,t[68]=a.workflowDefinitionMissing,t[69]=a.workflowDefinitionPlaceholder,t[70]=a.workflowDefinitionsEmpty,t[71]=a.workflowDefinitionsLoading,t[72]=a.workflowDeliveryHint,t[73]=a.workflowLocalOnly,t[74]=a.workflowLocalOnlyHint,t[75]=l,t[76]=d,t[77]=G,t[78]=B,t[79]=ne,t[80]=J,t[81]=w,t[82]=T,t[83]=I,t[84]=j,t[85]=P,t[86]=ye,t[87]=pe,t[88]=K,t[89]=V,t[90]=re,t[91]=ie,t[92]=L,t[93]=N,t[94]=F,t[95]=ve,t[96]=be,t[97]=Se,t[98]=u,t[99]=me,t[100]=O,t[101]=k,t[102]=Ge):Ge=t[102];let qe;t[103]!==s||t[104]!==a.agentLocalOnly||t[105]!==a.agentLocalOnlyHint||t[106]!==a.agentProfile||t[107]!==a.agentProfileDefault||t[108]!==a.agentProfileHint||t[109]!==a.channel||t[110]!==a.channelLocal||t[111]!==a.enterManuallyOrSelect||t[112]!==a.lastActiveLabels||t[113]!==a.message||t[114]!==a.messageEdit||t[115]!==a.messageMarkdownHint||t[116]!==a.messagePlaceholder||t[117]!==a.messagePreview||t[118]!==a.mode||t[119]!==a.modeAgent||t[120]!==a.modeAgentOption||t[121]!==a.modeDirect||t[122]!==a.modeDirectOption||t[123]!==a.model||t[124]!==a.noRecentChats||t[125]!==a.noRecentChatsOption||t[126]!==a.recipient||t[127]!==a.recipientPlaceholder||t[128]!==a.refreshList||t[129]!==a.refreshRecipientHint||t[130]!==a.selectRecipient||t[131]!==a.workingDirectoryHint||t[132]!==a.workingDirectoryLabel||t[133]!==a.workingDirectoryReset||t[134]!==l||t[135]!==o||t[136]!==d||t[137]!==f||t[138]!==G||t[139]!==B||t[140]!==ne||t[141]!==J||t[142]!==m||t[143]!==se||t[144]!==le||t[145]!==H||t[146]!==R||t[147]!==w||t[148]!==T||t[149]!==q||t[150]!==c||t[151]!==de||t[152]!==pe||t[153]!==K||t[154]!==V||t[155]!==re||t[156]!==ie||t[157]!==ce||t[158]!==W||t[159]!==z||t[160]!==te||t[161]!==ve||t[162]!==ue||t[163]!==u||t[164]!==me?(qe=T===`message`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.mode}),(0,$.jsxs)(`select`,{className:vt(),value:R,onChange:e=>{let t=e.target.value;z(t,f,H.trim())},children:[(0,$.jsx)(`option`,{value:`main`,children:a.modeDirectOption}),(0,$.jsx)(`option`,{value:`isolated`,children:a.modeAgentOption})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:R===`main`?a.modeDirect:a.modeAgent})]}),R===`isolated`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.model}),(0,$.jsx)(E,{value:H,placeholder:o.modelPlaceholder,searchPlaceholder:o.modelSearchPlaceholder,noMatches:o.modelNoMatches,className:`w-full max-w-none min-w-0`,popoverContentClassName:`z-[70]`,onChange:W})]}),(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.agentProfile}),(0,$.jsxs)(`select`,{className:vt(),value:G,disabled:w,onChange:e=>K(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:a.agentProfileDefault}),d.map(e=>(0,$.jsx)(`option`,{value:e.id,children:`${e.id} — ${oe(e,s)}`},e.id))]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.agentProfileHint})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.workingDirectoryLabel}),(0,$.jsx)(kt,{value:q,onChange:te,disabled:w,wd:o.workingDirectory,placeholder:o.workingDirectory.notSet,maxWidthClass:`max-w-[min(16rem,48vw)]`,clearLabel:a.workingDirectoryReset,onClear:()=>te(``)}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.workingDirectoryHint})]}),(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md bg-surface-hover/45 px-3 py-2 dark:bg-surface-hover/30`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:X(`ui-checkbox`,`mt-0.5`),checked:B,onChange:e=>V(e.target.checked),"aria-label":a.agentLocalOnly}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:a.agentLocalOnly}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.agentLocalOnlyHint})]})]})]}):null,me?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.channel}),(0,$.jsxs)(`select`,{className:vt(),value:ne,onChange:e=>{let t=e.target.value;re(t)},children:[(0,$.jsx)(`option`,{value:`local`,children:a.channelLocal}),l.map(It)]})]}),pe?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:a.recipient}),(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,className:`h-7 gap-1 px-2 text-xs`,title:a.refreshRecipientHint,onClick:()=>void ve(),children:[(0,$.jsx)(fe,{className:`size-3.5`,strokeWidth:1.75}),a.refreshList]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch sm:gap-2`,children:[(0,$.jsx)(`input`,{type:`text`,className:X(_t(),`min-w-0 w-full sm:flex-1`),value:J,onChange:e=>ie(e.target.value),placeholder:a.recipientPlaceholder}),(0,$.jsxs)(`select`,{className:yt,value:J,onChange:e=>{let t=e.target.value;t&&ie(t)},children:[(0,$.jsx)(`option`,{value:``,children:a.selectRecipient}),u.length>0?u.map(e=>(0,$.jsx)(`option`,{value:e.chatId,children:Ce(e,a.lastActiveLabels)},`${e.channel}-${e.chatId}`)):(0,$.jsx)(`option`,{value:``,disabled:!0,children:a.noRecentChatsOption})]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:u.length>0?a.enterManuallyOrSelect:a.noRecentChats})]}):null]}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,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-muted`,children:a.message}),(0,$.jsxs)(`div`,{className:`inline-flex rounded-lg border border-edge bg-surface-base p-0.5 dark:border-edge`,children:[(0,$.jsxs)(`button`,{type:`button`,className:X(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,le===`edit`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>ue(`edit`),children:[(0,$.jsx)(S,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),a.messageEdit]}),(0,$.jsxs)(`button`,{type:`button`,className:X(`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium`,le===`preview`?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover`),onClick:()=>ue(`preview`),children:[(0,$.jsx)(U,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),a.messagePreview]})]})]}),(0,$.jsx)(`div`,{className:X(`overflow-hidden rounded-md border border-edge bg-surface-base dark:border-edge`,w&&`pointer-events-none opacity-60`),children:le===`edit`?(0,$.jsx)(C,{initialContent:se,onChange:ce,isDark:c,className:`h-[min(18rem,40vh)] min-h-[12rem]`},`cron-msg-${m??`new`}-${de}`):(0,$.jsx)(`div`,{className:`h-[min(18rem,40vh)] min-h-[12rem] max-h-[min(24rem,50vh)] overflow-y-auto px-3 py-2`,children:se.trim()?(0,$.jsx)(M,{content:se,compact:!0,className:`text-sm`}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.messagePlaceholder})})}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.messageMarkdownHint})]})]}):null,t[103]=s,t[104]=a.agentLocalOnly,t[105]=a.agentLocalOnlyHint,t[106]=a.agentProfile,t[107]=a.agentProfileDefault,t[108]=a.agentProfileHint,t[109]=a.channel,t[110]=a.channelLocal,t[111]=a.enterManuallyOrSelect,t[112]=a.lastActiveLabels,t[113]=a.message,t[114]=a.messageEdit,t[115]=a.messageMarkdownHint,t[116]=a.messagePlaceholder,t[117]=a.messagePreview,t[118]=a.mode,t[119]=a.modeAgent,t[120]=a.modeAgentOption,t[121]=a.modeDirect,t[122]=a.modeDirectOption,t[123]=a.model,t[124]=a.noRecentChats,t[125]=a.noRecentChatsOption,t[126]=a.recipient,t[127]=a.recipientPlaceholder,t[128]=a.refreshList,t[129]=a.refreshRecipientHint,t[130]=a.selectRecipient,t[131]=a.workingDirectoryHint,t[132]=a.workingDirectoryLabel,t[133]=a.workingDirectoryReset,t[134]=l,t[135]=o,t[136]=d,t[137]=f,t[138]=G,t[139]=B,t[140]=ne,t[141]=J,t[142]=m,t[143]=se,t[144]=le,t[145]=H,t[146]=R,t[147]=w,t[148]=T,t[149]=q,t[150]=c,t[151]=de,t[152]=pe,t[153]=K,t[154]=V,t[155]=re,t[156]=ie,t[157]=ce,t[158]=W,t[159]=z,t[160]=te,t[161]=ve,t[162]=ue,t[163]=u,t[164]=me,t[165]=qe):qe=t[165];let Je;t[166]!==Fe||t[167]!==Ie||t[168]!==Ue||t[169]!==Ge||t[170]!==qe?(Je=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[Fe,Ie,Ue,Ge,qe]})}),t[166]=Fe,t[167]=Ie,t[168]=Ue,t[169]=Ge,t[170]=qe,t[171]=Je):Je=t[171];let Ye;t[172]!==a.cancel||t[173]!==r?(Ye=(0,$.jsx)(Y,{type:`button`,variant:`secondary`,onClick:r,children:a.cancel}),t[172]=a.cancel,t[173]=r,t[174]=Ye):Ye=t[174];let Xe=w||!ge,Ze=w?a.loading:p===`edit`?a.save:a.create,Qe;t[175]!==_e||t[176]!==Xe||t[177]!==Ze?(Qe=(0,$.jsx)(Y,{type:`button`,variant:`primary`,disabled:Xe,onClick:_e,children:Ze}),t[175]=_e,t[176]=Xe,t[177]=Ze,t[178]=Qe):Qe=t[178];let $e;t[179]!==Ye||t[180]!==Qe?($e=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-4 py-3`,children:[Ye,Qe]}),t[179]=Ye,t[180]=Qe,t[181]=$e):$e=t[181];let Z;t[182]!==Je||t[183]!==$e||t[184]!==Ae?(Z=(0,$.jsxs)(y,{children:[Te,(0,$.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center p-4 pointer-events-none`,children:(0,$.jsxs)(he,{className:`xopc-dialog-content-pane pointer-events-auto relative flex h-[min(90vh,800px)] w-full max-w-md flex-col rounded-xl border border-edge bg-surface-panel shadow-popover outline-none sm:max-w-lg lg:max-w-xl dark:border-edge`,onOpenAutoFocus:Rt,children:[Ae,Je,$e]})})]}),t[182]=Je,t[183]=$e,t[184]=Ae,t[185]=Z):Z=t[185];let et;return t[186]!==n||t[187]!==we||t[188]!==Z?(et=(0,$.jsx)($.Fragment,{children:(0,$.jsx)(A,{open:n,onOpenChange:we,children:Z})}),t[186]=n,t[187]=we,t[188]=Z,t[189]=et):et=t[189],et}function It(e){return(0,$.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:`(disabled)`]},e.name)}function Lt(e){return(0,$.jsxs)(`option`,{value:e.name,disabled:!e.enabled,children:[e.name,` `,e.enabled?``:`(disabled)`]},e.name)}function Rt(e){return e.preventDefault()}function zt(e){return e.language}function Bt(e){let t=(0,Q.c)(76),{c:n,mainTab:r,onMainTabChange:i,jobSort:a,onJobSortChange:o,historyRange:s,onHistoryRangeChange:c,historyJobFilter:l,onHistoryJobFilterChange:u,historyStatusFilter:d,onHistoryStatusFilterChange:f,jobs:p}=e,m=n.title,h=r===`myTasks`,g=r===`myTasks`?`text-fg`:`text-fg-muted hover:text-fg`,_;t[0]===g?_=t[1]:(_=X(`rounded-md px-3 py-2 text-sm font-medium transition-colors`,g),t[0]=g,t[1]=_);let v;t[2]===i?v=t[3]:(v=()=>i(`myTasks`),t[2]=i,t[3]=v);let y;t[4]!==n.tabMyTasks||t[5]!==h||t[6]!==_||t[7]!==v?(y=(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":h,className:_,onClick:v,children:n.tabMyTasks}),t[4]=n.tabMyTasks,t[5]=h,t[6]=_,t[7]=v,t[8]=y):y=t[8];let b=r===`systemTasks`,x=r===`systemTasks`?`text-fg`:`text-fg-muted hover:text-fg`,S;t[9]===x?S=t[10]:(S=X(`rounded-md px-3 py-2 text-sm font-medium transition-colors`,x),t[9]=x,t[10]=S);let C;t[11]===i?C=t[12]:(C=()=>i(`systemTasks`),t[11]=i,t[12]=C);let w;t[13]!==n.tabSystemTasks||t[14]!==C||t[15]!==b||t[16]!==S?(w=(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":b,className:S,onClick:C,children:n.tabSystemTasks}),t[13]=n.tabSystemTasks,t[14]=C,t[15]=b,t[16]=S,t[17]=w):w=t[17];let T=r===`history`,E=r===`history`?`text-fg`:`text-fg-muted hover:text-fg`,D;t[18]===E?D=t[19]:(D=X(`rounded-md px-3 py-2 text-sm font-medium transition-colors`,E),t[18]=E,t[19]=D);let O;t[20]===i?O=t[21]:(O=()=>i(`history`),t[20]=i,t[21]=O);let k;t[22]!==n.tabRunHistory||t[23]!==T||t[24]!==D||t[25]!==O?(k=(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":T,className:D,onClick:O,children:n.tabRunHistory}),t[22]=n.tabRunHistory,t[23]=T,t[24]=D,t[25]=O,t[26]=k):k=t[26];let A=r===`settings`,j=r===`settings`?`text-fg`:`text-fg-muted hover:text-fg`,M;t[27]===j?M=t[28]:(M=X(`rounded-md px-3 py-2 text-sm font-medium transition-colors`,j),t[27]=j,t[28]=M);let N;t[29]===i?N=t[30]:(N=()=>i(`settings`),t[29]=i,t[30]=N);let P;t[31]!==n.globals.title||t[32]!==A||t[33]!==M||t[34]!==N?(P=(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":A,className:M,onClick:N,children:n.globals.title}),t[31]=n.globals.title,t[32]=A,t[33]=M,t[34]=N,t[35]=P):P=t[35];let F;t[36]!==n.title||t[37]!==w||t[38]!==k||t[39]!==P||t[40]!==y?(F=(0,$.jsxs)(`div`,{className:`flex gap-1`,role:`tablist`,"aria-label":m,children:[y,w,k,P]}),t[36]=n.title,t[37]=w,t[38]=k,t[39]=P,t[40]=y,t[41]=F):F=t[41];let I=r===`history`?`flex-nowrap overflow-x-auto pb-0.5 sm:justify-end`:`flex-wrap sm:justify-end`,L;t[42]===I?L=t[43]:(L=X(`flex min-w-0 items-center gap-2`,I),t[42]=I,t[43]=L);let R;t[44]!==n.sortCreatedAsc||t[45]!==n.sortCreatedDesc||t[46]!==a||t[47]!==r||t[48]!==o?(R=r===`myTasks`||r===`systemTasks`?(0,$.jsxs)(`select`,{className:bt,value:a,onChange:e=>o(e.target.value),"aria-label":n.sortCreatedDesc,children:[(0,$.jsx)(`option`,{value:`created_desc`,children:n.sortCreatedDesc}),(0,$.jsx)(`option`,{value:`created_asc`,children:n.sortCreatedAsc})]}):null,t[44]=n.sortCreatedAsc,t[45]=n.sortCreatedDesc,t[46]=a,t[47]=r,t[48]=o,t[49]=R):R=t[49];let z;t[50]!==n.execStatusCancelled||t[51]!==n.execStatusFailed||t[52]!==n.execStatusRunning||t[53]!==n.execStatusSuccess||t[54]!==n.filterAllStatuses||t[55]!==n.filterAllTasks||t[56]!==n.historyRangeDay||t[57]!==n.historyRangeMonth||t[58]!==n.historyRangeWeek||t[59]!==n.runHistoryTitle||t[60]!==l||t[61]!==s||t[62]!==d||t[63]!==p||t[64]!==r||t[65]!==u||t[66]!==c||t[67]!==f?(z=r===`history`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:X(ne,`shrink-0`),role:`group`,"aria-label":n.runHistoryTitle,children:[`day`,`week`,`month`].map(e=>(0,$.jsx)(`button`,{type:`button`,className:X(le,`px-2.5 py-1`,s===e&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,s===e&&`text-fg`),onClick:()=>c(e),children:e===`day`?n.historyRangeDay:e===`week`?n.historyRangeWeek:n.historyRangeMonth},e))}),(0,$.jsxs)(`select`,{className:bt,value:l,onChange:e=>u(e.target.value),"aria-label":n.filterAllTasks,children:[(0,$.jsx)(`option`,{value:``,children:n.filterAllTasks}),p.map(Vt)]}),(0,$.jsxs)(`select`,{className:bt,value:d,onChange:e=>f(e.target.value),"aria-label":n.filterAllStatuses,children:[(0,$.jsx)(`option`,{value:``,children:n.filterAllStatuses}),(0,$.jsx)(`option`,{value:`success`,children:n.execStatusSuccess}),(0,$.jsx)(`option`,{value:`failed`,children:n.execStatusFailed}),(0,$.jsx)(`option`,{value:`cancelled`,children:n.execStatusCancelled}),(0,$.jsx)(`option`,{value:`running`,children:n.execStatusRunning})]})]}):null,t[50]=n.execStatusCancelled,t[51]=n.execStatusFailed,t[52]=n.execStatusRunning,t[53]=n.execStatusSuccess,t[54]=n.filterAllStatuses,t[55]=n.filterAllTasks,t[56]=n.historyRangeDay,t[57]=n.historyRangeMonth,t[58]=n.historyRangeWeek,t[59]=n.runHistoryTitle,t[60]=l,t[61]=s,t[62]=d,t[63]=p,t[64]=r,t[65]=u,t[66]=c,t[67]=f,t[68]=z):z=t[68];let B;t[69]!==L||t[70]!==R||t[71]!==z?(B=(0,$.jsxs)(`div`,{className:L,children:[R,z]}),t[69]=L,t[70]=R,t[71]=z,t[72]=B):B=t[72];let V;return t[73]!==F||t[74]!==B?(V=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-edge-subtle pb-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge-subtle`,children:[F,B]}),t[73]=F,t[74]=B,t[75]=V):V=t[75],V}function Vt(e){return(0,$.jsx)(`option`,{value:e.id,children:e.name||e.id},e.id)}function Ht(e){let t=(0,Q.c)(23),{c:n,loading:r,runHistoryLoading:i,onRefresh:a,onOpenTemplatePicker:o,onAddJob:s}=e,c=r||i,l=n.refresh,u=n.refresh,d;t[0]===a?d=t[1]:(d=()=>void a(),t[0]=a,t[1]=d);let f=c&&`animate-spin`,p;t[2]===f?p=t[3]:(p=X(`size-4`,f),t[2]=f,t[3]=p);let m;t[4]===p?m=t[5]:(m=(0,$.jsx)(fe,{className:p,strokeWidth:1.75}),t[4]=p,t[5]=m);let h;t[6]!==c||t[7]!==n.refresh||t[8]!==d||t[9]!==m?(h=(0,$.jsx)(Y,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:c,title:l,"aria-label":u,onClick:d,children:m}),t[6]=c,t[7]=n.refresh,t[8]=d,t[9]=m,t[10]=h):h=t[10];let g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(D,{className:`size-4`,strokeWidth:1.75}),t[11]=g):g=t[11];let _;t[12]!==n.fromTemplate||t[13]!==o?(_=(0,$.jsxs)(Y,{type:`button`,variant:`secondary`,className:`gap-2`,onClick:o,children:[g,n.fromTemplate]}),t[12]=n.fromTemplate,t[13]=o,t[14]=_):_=t[14];let v;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(ue,{className:`size-4`,strokeWidth:1.75}),t[15]=v):v=t[15];let y;t[16]!==n.addJob||t[17]!==s?(y=(0,$.jsxs)(Y,{type:`button`,variant:`primary`,className:`gap-2`,onClick:s,children:[v,n.addJob]}),t[16]=n.addJob,t[17]=s,t[18]=y):y=t[18];let b;return t[19]!==y||t[20]!==h||t[21]!==_?(b=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[h,_,y]}),t[19]=y,t[20]=h,t[21]=_,t[22]=b):b=t[22],b}function Ut(e){let t=(0,Q.c)(46),{c:n,runHistoryLoading:r,runHistory:i,filteredRunHistory:a,jobs:o,onRefreshHistory:s,onOpenJobDetail:c,statusLabels:l}=e,u;t[0]===n.tabRunHistory?u=t[1]:(u=(0,$.jsx)(`h2`,{id:`cron-history-panel`,className:`sr-only`,children:n.tabRunHistory}),t[0]=n.tabRunHistory,t[1]=u);let d;t[2]===n.runHistoryHint?d=t[3]:(d=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.runHistoryHint}),t[2]=n.runHistoryHint,t[3]=d);let f;t[4]!==u||t[5]!==d?(f=(0,$.jsxs)(`div`,{children:[u,d]}),t[4]=u,t[5]=d,t[6]=f):f=t[6];let p=n.refresh,m=n.refresh,h;t[7]===s?h=t[8]:(h=()=>void s(),t[7]=s,t[8]=h);let g=r&&`animate-spin`,v;t[9]===g?v=t[10]:(v=X(`size-4`,g),t[9]=g,t[10]=v);let y;t[11]===v?y=t[12]:(y=(0,$.jsx)(fe,{className:v,strokeWidth:1.75}),t[11]=v,t[12]=y);let b;t[13]!==n.refresh||t[14]!==r||t[15]!==h||t[16]!==y?(b=(0,$.jsx)(Y,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:r,title:p,"aria-label":m,onClick:h,children:y}),t[13]=n.refresh,t[14]=r,t[15]=h,t[16]=y,t[17]=b):b=t[17];let x;t[18]!==b||t[19]!==f?(x=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[f,b]}),t[18]=b,t[19]=f,t[20]=x):x=t[20];let S;t[21]!==n.colChat||t[22]!==n.colDetail||t[23]!==n.colDuration||t[24]!==n.colJob||t[25]!==n.colStarted||t[26]!==n.colWorkflow||t[27]!==n.emptyHistoryHint||t[28]!==n.emptyHistoryTitle||t[29]!==n.noRunsYet||t[30]!==n.openChat||t[31]!==n.openChatTitle||t[32]!==n.openWorkflow||t[33]!==n.openWorkflowTitle||t[34]!==n.runHistoryHint||t[35]!==n.status||t[36]!==a||t[37]!==o||t[38]!==c||t[39]!==i||t[40]!==r||t[41]!==l?(S=r&&i.length===0?(0,$.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,$.jsx)(_,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):a.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center rounded-2xl border border-dashed border-edge-subtle px-6 py-16 text-center dark:border-edge-subtle`,children:[(0,$.jsx)(B,{className:`mb-4 size-14 text-fg-disabled`,strokeWidth:1.1,"aria-hidden":!0}),(0,$.jsx)(`h3`,{className:`text-base font-semibold text-fg`,children:i.length===0?n.emptyHistoryTitle:n.noRunsYet}),(0,$.jsx)(`p`,{className:`mt-2 max-w-sm text-sm text-fg-muted`,children:i.length===0?n.emptyHistoryHint:n.runHistoryHint})]}):(0,$.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-edge-subtle bg-surface-base dark:border-edge-subtle`,children:(0,$.jsxs)(`table`,{className:`w-full min-w-[700px] border-collapse text-left text-sm`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{className:`border-b border-edge text-xs font-medium text-fg-muted`,children:[(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colStarted}),(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colJob}),(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.status}),(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colDuration}),(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colDetail}),(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colWorkflow}),(0,$.jsx)(`th`,{className:`px-3 py-2.5 font-medium`,children:n.colChat})]})}),(0,$.jsx)(`tbody`,{children:a.map(e=>(0,$.jsxs)(`tr`,{className:`border-b border-edge/60 last:border-0`,children:[(0,$.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5 text-fg`,children:(0,$.jsx)(`time`,{dateTime:e.startedAt,children:xe(e.startedAt)})}),(0,$.jsx)(`td`,{className:`max-w-[10rem] truncate px-3 py-2.5`,children:o.some(t=>t.id===e.jobId)?(0,$.jsx)(`button`,{type:`button`,className:`text-left text-accent hover:underline`,onClick:()=>{let t=o.find(t=>t.id===e.jobId);t&&c(t)},children:e.jobName||e.jobId}):(0,$.jsx)(`span`,{className:`text-fg-muted`,children:e.jobName||e.jobId})}),(0,$.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,$.jsx)(`span`,{className:X(`inline-flex rounded-md px-2 py-0.5 text-xs font-medium`,e.status===`success`&&`bg-emerald-500/15 text-emerald-800 dark:text-emerald-300`,e.status===`failed`&&`bg-red-500/15 text-red-800 dark:text-red-300`,e.status===`running`&&`bg-accent/15 text-accent`,e.status===`cancelled`&&`bg-surface-hover text-fg-muted`),children:ye(e.status,l)})}),(0,$.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5 text-fg-muted`,children:De(e.duration)}),(0,$.jsx)(`td`,{className:`max-w-xs truncate px-3 py-2.5 text-fg-muted`,title:e.summary||e.error||``,children:Se(e.summary||e.error,96)}),(0,$.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5`,children:e.workflowRunId?.trim()?(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-accent hover:underline`,title:n.openWorkflowTitle,"aria-label":n.openWorkflowTitle,onClick:()=>gt(e.workflowRunId),children:n.openWorkflow}):(0,$.jsx)(`span`,{className:`text-fg-disabled`,children:`—`})}),(0,$.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5`,children:e.sessionKey?.trim()?(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-accent hover:underline`,title:n.openChatTitle,"aria-label":n.openChatTitle,onClick:()=>ht(e.sessionKey),children:n.openChat}):(0,$.jsx)(`span`,{className:`text-fg-disabled`,children:`—`})})]},e.id))})]})}),t[21]=n.colChat,t[22]=n.colDetail,t[23]=n.colDuration,t[24]=n.colJob,t[25]=n.colStarted,t[26]=n.colWorkflow,t[27]=n.emptyHistoryHint,t[28]=n.emptyHistoryTitle,t[29]=n.noRunsYet,t[30]=n.openChat,t[31]=n.openChatTitle,t[32]=n.openWorkflow,t[33]=n.openWorkflowTitle,t[34]=n.runHistoryHint,t[35]=n.status,t[36]=a,t[37]=o,t[38]=c,t[39]=i,t[40]=r,t[41]=l,t[42]=S):S=t[42];let C;return t[43]!==x||t[44]!==S?(C=(0,$.jsxs)(`section`,{"aria-labelledby":`cron-history-panel`,className:`flex flex-col gap-3`,children:[x,S]}),t[43]=x,t[44]=S,t[45]=C):C=t[45],C}function Wt(e){let t=(0,Q.c)(77),{job:n,c:r,localeTag:i,scheduleBadgeLabels:a,absorbCardClickJobIdRef:o,scheduleAbsorbNextMenuCardClick:s,onOpenDetail:c,onToggle:l,onEdit:u,onRunNow:d,onDelete:f}=e,p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=X(`flex h-full min-h-0 cursor-pointer flex-col rounded-xl border border-edge-subtle bg-surface-base text-left transition-colors duration-150 ease-out dark:border-edge-subtle`,`hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`),t[0]=p):p=t[0];let m,h;t[1]!==o||t[2]!==n||t[3]!==c?(m=()=>{if(o.current===n.id){o.current=null;return}c(n)},h=e=>{if(e.key===`Enter`||e.key===` `){if(e.preventDefault(),o.current===n.id){o.current=null;return}c(n)}},t[1]=o,t[2]=n,t[3]=c,t[4]=m,t[5]=h):(m=t[4],h=t[5]);let g=n.enabled,_=n.enabled?`justify-end bg-accent`:`justify-start bg-surface-hover`,v;t[6]===_?v=t[7]:(v=X(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,_),t[6]=_,t[7]=v);let y;t[8]!==n||t[9]!==l?(y=e=>{e.stopPropagation(),l(n,!n.enabled)},t[8]=n,t[9]=l,t[10]=y):y=t[10];let b;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`}),t[11]=b):b=t[11];let x;t[12]!==n.enabled||t[13]!==v||t[14]!==y?(x=(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":g,className:v,onClick:y,children:b}),t[12]=n.enabled,t[13]=v,t[14]=y,t[15]=x):x=t[15];let S;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(se,{className:`size-4`,strokeWidth:1.75}),t[16]=S):S=t[16];let C;t[17]===r.jobCardMenuAria?C=t[18]:(C=(0,$.jsx)(Ze,{asChild:!0,children:(0,$.jsx)(Y,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":r.jobCardMenuAria,onClick:Kt,children:S})}),t[17]=r.jobCardMenuAria,t[18]=C);let w;t[19]!==n||t[20]!==u||t[21]!==s?(w=()=>{s(n.id),u(n)},t[19]=n,t[20]=u,t[21]=s,t[22]=w):w=t[22];let T;t[23]!==r.edit||t[24]!==w?(T=(0,$.jsx)(Xe,{className:`cursor-pointer select-none rounded-lg px-2 py-1.5 text-sm text-fg outline-none data-highlighted:bg-surface-hover`,onSelect:w,children:r.edit}),t[23]=r.edit,t[24]=w,t[25]=T):T=t[25];let E;t[26]!==n||t[27]!==d||t[28]!==s?(E=()=>{s(n.id),d(n)},t[26]=n,t[27]=d,t[28]=s,t[29]=E):E=t[29];let D;t[30]!==r.runNow||t[31]!==E?(D=(0,$.jsx)(Xe,{className:`cursor-pointer select-none rounded-lg px-2 py-1.5 text-sm text-fg outline-none data-highlighted:bg-surface-hover`,onSelect:E,children:r.runNow}),t[30]=r.runNow,t[31]=E,t[32]=D):D=t[32];let O;t[33]!==n||t[34]!==f||t[35]!==s?(O=()=>{s(n.id),f(n)},t[33]=n,t[34]=f,t[35]=s,t[36]=O):O=t[36];let k;t[37]!==r.delete||t[38]!==O?(k=(0,$.jsx)(Xe,{className:`cursor-pointer select-none rounded-lg px-2 py-1.5 text-sm text-red-600 outline-none data-highlighted:bg-red-500/10 dark:text-red-400`,onSelect:O,children:r.delete}),t[37]=r.delete,t[38]=O,t[39]=k):k=t[39];let A;t[40]!==T||t[41]!==D||t[42]!==k?(A=(0,$.jsx)(Qe,{children:(0,$.jsxs)($e,{className:`z-50 min-w-[10rem] rounded-xl border border-edge-subtle bg-surface-panel p-1 shadow-elevated dark:border-edge-subtle`,sideOffset:4,align:`end`,onCloseAutoFocus:Gt,children:[T,D,k]})}),t[40]=T,t[41]=D,t[42]=k,t[43]=A):A=t[43];let j;t[44]!==C||t[45]!==A?(j=(0,$.jsxs)(Ye,{children:[C,A]}),t[44]=C,t[45]=A,t[46]=j):j=t[46];let N;t[47]!==j||t[48]!==x?(N=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2 px-4 pt-3`,children:[x,j]}),t[47]=j,t[48]=x,t[49]=N):N=t[49];let P=n.name||n.id,F;t[50]===P?F=t[51]:(F=(0,$.jsx)(`h3`,{className:`line-clamp-2 font-semibold text-fg`,children:P}),t[50]=P,t[51]=F);let I;t[52]===n?I=t[53]:(I=Le(n),t[52]=n,t[53]=I);let L;t[54]===n?L=t[55]:(L=Le(n),t[54]=n,t[55]=L);let R;t[56]===L?R=t[57]:(R=(0,$.jsx)(M,{content:L,compact:!0}),t[56]=L,t[57]=R);let z;t[58]!==I||t[59]!==R?(z=(0,$.jsx)(`div`,{className:`max-h-[4.5rem] overflow-hidden text-sm text-fg-muted [&_.markdown-body]:text-sm [&_.markdown-body]:leading-snug`,title:I,children:R}),t[58]=I,t[59]=R,t[60]=z):z=t[60];let V;t[61]!==F||t[62]!==z?(V=(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col gap-2 px-4 pb-3 pt-2`,children:[F,z]}),t[61]=F,t[62]=z,t[63]=V):V=t[63];let H;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(B,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),t[64]=H):H=t[64];let U;t[65]!==n||t[66]!==i||t[67]!==a?(U=ke(n,i,a),t[65]=n,t[66]=i,t[67]=a,t[68]=U):U=t[68];let W;t[69]===U?W=t[70]:(W=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 border-t border-edge-subtle/90 px-4 py-2.5 text-xs text-fg-muted dark:border-edge-subtle`,children:[H,(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:U})]}),t[69]=U,t[70]=W);let G;return t[71]!==m||t[72]!==N||t[73]!==V||t[74]!==h||t[75]!==W?(G=(0,$.jsxs)(`article`,{role:`button`,tabIndex:0,className:p,onClick:m,onKeyDown:h,children:[N,V,W]}),t[71]=m,t[72]=N,t[73]=V,t[74]=h,t[75]=W,t[76]=G):G=t[76],G}function Gt(e){return e.preventDefault()}function Kt(e){return e.stopPropagation()}function qt(e){let t=(0,Q.c)(134),{c:n,language:r,localeTag:i,scheduleBadgeLabels:o,loading:s,sortedSystemJobs:c,heartbeat:l,keepAwake:u,wakeSupported:d,onWakeUnsupportedClick:f,onKeepAwakeToggle:p,absorbCardClickJobIdRef:m,scheduleAbsorbNextMenuCardClick:h,onOpenDetail:g,onToggle:y,onEdit:b,onRunNow:x,onDelete:S}=e,C,w,E,D,O,k,A,j,M,N,P,F;if(t[0]!==n.disabled||t[1]!==n.enabled||t[2]!==n.keepAwake||t[3]!==n.systemHeartbeatEvery||t[4]!==n.systemHeartbeatHint||t[5]!==n.systemHeartbeatInterval||t[6]!==n.systemHeartbeatSettingsLink||t[7]!==n.systemHeartbeatStatus||t[8]!==n.systemHeartbeatTitle||t[9]!==n.systemTasksIntro||t[10]!==n.tabSystemTasks||t[11]!==n.wakeBanner||t[12]!==n.wakeLockUnavailable||t[13]!==l.enabled||t[14]!==l.intervalMs||t[15]!==u||t[16]!==r||t[17]!==i||t[18]!==p||t[19]!==f||t[20]!==d){let e=Ee(l.intervalMs,i,a(r).heartbeatSettings.intervalPresets);P=`cron-system-tasks-panel`,F=`flex flex-col gap-4`,t[33]===n.tabSystemTasks?w=t[34]:(w=(0,$.jsx)(`h2`,{id:`cron-system-tasks-panel`,className:`sr-only`,children:n.tabSystemTasks}),t[33]=n.tabSystemTasks,t[34]=w),t[35]===n.systemTasksIntro?E=t[36]:(E=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.systemTasksIntro}),t[35]=n.systemTasksIntro,t[36]=E);let o;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(L,{className:`mt-0.5 size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}),t[37]=o):o=t[37];let s;t[38]===n.wakeBanner?s=t[39]:(s=(0,$.jsxs)(`div`,{className:`flex gap-3 text-sm text-fg`,children:[o,(0,$.jsx)(`p`,{className:`text-pretty text-fg-muted`,children:n.wakeBanner})]}),t[38]=n.wakeBanner,t[39]=s);let c;t[40]===n.keepAwake?c=t[41]:(c=(0,$.jsx)(`span`,{className:`text-sm text-fg`,children:n.keepAwake}),t[40]=n.keepAwake,t[41]=c);let m=!d,h=d?void 0:n.wakeLockUnavailable,g=u?`justify-end bg-accent`:`justify-start bg-surface-hover`,_=!d&&`cursor-not-allowed opacity-50`,y;t[42]!==g||t[43]!==_?(y=X(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,g,_),t[42]=g,t[43]=_,t[44]=y):y=t[44];let b;t[45]!==p||t[46]!==f||t[47]!==d?(b=()=>{d?p():f()},t[45]=p,t[46]=f,t[47]=d,t[48]=b):b=t[48];let x;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`}),t[49]=x):x=t[49];let S;t[50]!==u||t[51]!==m||t[52]!==h||t[53]!==y||t[54]!==b?(S=(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":u,disabled:m,title:h,className:y,onClick:b,children:x}),t[50]=u,t[51]=m,t[52]=h,t[53]=y,t[54]=b,t[55]=S):S=t[55];let I;t[56]!==c||t[57]!==S?(I=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 sm:pl-4`,children:[c,S]}),t[56]=c,t[57]=S,t[58]=I):I=t[58],t[59]!==s||t[60]!==I?(D=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent/5 px-4 py-3 dark:border-accent/30 dark:bg-accent/10 sm:flex-row sm:items-center sm:justify-between`,children:[s,I]}),t[59]=s,t[60]=I,t[61]=D):D=t[61],M=`rounded-xl border border-edge bg-surface-base p-4 dark:bg-surface-hover/20`;let R;t[62]===n.systemHeartbeatTitle?R=t[63]:(R=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.systemHeartbeatTitle}),t[62]=n.systemHeartbeatTitle,t[63]=R);let z;t[64]===n.systemHeartbeatHint?z=t[65]:(z=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.systemHeartbeatHint}),t[64]=n.systemHeartbeatHint,t[65]=z);let B;t[66]!==R||t[67]!==z?(B=(0,$.jsxs)(`div`,{children:[R,z]}),t[66]=R,t[67]=z,t[68]=B):B=t[68];let V;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(v,{className:`size-3.5 opacity-70`,"aria-hidden":!0}),t[69]=V):V=t[69];let H;t[70]===n.systemHeartbeatSettingsLink?H=t[71]:(H=(0,$.jsx)(Y,{type:`button`,variant:`ghost`,className:`shrink-0 gap-1 self-start px-2 py-1.5 text-xs`,asChild:!0,children:(0,$.jsxs)(T,{to:`/settings/heartbeat`,children:[n.systemHeartbeatSettingsLink,V]})}),t[70]=n.systemHeartbeatSettingsLink,t[71]=H),t[72]!==B||t[73]!==H?(N=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 sm:flex-row sm:items-start sm:justify-between`,children:[B,H]}),t[72]=B,t[73]=H,t[74]=N):N=t[74],A=`mt-3 grid gap-2 text-sm sm:grid-cols-2`;let U;t[75]===n.systemHeartbeatStatus?U=t[76]:(U=(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.systemHeartbeatStatus}),t[75]=n.systemHeartbeatStatus,t[76]=U);let W=l.enabled?n.enabled:n.disabled,G;t[77]===W?G=t[78]:(G=(0,$.jsx)(`dd`,{className:`text-fg`,children:W}),t[77]=W,t[78]=G),t[79]!==U||t[80]!==G?(j=(0,$.jsxs)(`div`,{children:[U,G]}),t[79]=U,t[80]=G,t[81]=j):j=t[81],t[82]===n.systemHeartbeatInterval?k=t[83]:(k=(0,$.jsx)(`dt`,{className:`text-xs font-medium text-fg-muted`,children:n.systemHeartbeatInterval}),t[82]=n.systemHeartbeatInterval,t[83]=k),C=`text-fg`;let K;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(K=/\{\{value\}\}/g,t[84]=K):K=t[84],O=n.systemHeartbeatEvery.replace(K,e),t[0]=n.disabled,t[1]=n.enabled,t[2]=n.keepAwake,t[3]=n.systemHeartbeatEvery,t[4]=n.systemHeartbeatHint,t[5]=n.systemHeartbeatInterval,t[6]=n.systemHeartbeatSettingsLink,t[7]=n.systemHeartbeatStatus,t[8]=n.systemHeartbeatTitle,t[9]=n.systemTasksIntro,t[10]=n.tabSystemTasks,t[11]=n.wakeBanner,t[12]=n.wakeLockUnavailable,t[13]=l.enabled,t[14]=l.intervalMs,t[15]=u,t[16]=r,t[17]=i,t[18]=p,t[19]=f,t[20]=d,t[21]=C,t[22]=w,t[23]=E,t[24]=D,t[25]=O,t[26]=k,t[27]=A,t[28]=j,t[29]=M,t[30]=N,t[31]=P,t[32]=F}else C=t[21],w=t[22],E=t[23],D=t[24],O=t[25],k=t[26],A=t[27],j=t[28],M=t[29],N=t[30],P=t[31],F=t[32];let I;t[85]!==C||t[86]!==O?(I=(0,$.jsx)(`dd`,{className:C,children:O}),t[85]=C,t[86]=O,t[87]=I):I=t[87];let R;t[88]!==I||t[89]!==k?(R=(0,$.jsxs)(`div`,{children:[k,I]}),t[88]=I,t[89]=k,t[90]=R):R=t[90];let z;t[91]!==R||t[92]!==A||t[93]!==j?(z=(0,$.jsxs)(`dl`,{className:A,children:[j,R]}),t[91]=R,t[92]=A,t[93]=j,t[94]=z):z=t[94];let B;t[95]!==z||t[96]!==M||t[97]!==N?(B=(0,$.jsxs)(`div`,{className:M,children:[N,z]}),t[95]=z,t[96]=M,t[97]=N,t[98]=B):B=t[98];let V;t[99]===n.systemDreamingTitle?V=t[100]:(V=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.systemDreamingTitle}),t[99]=n.systemDreamingTitle,t[100]=V);let H;t[101]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(v,{className:`size-3.5 opacity-70`,"aria-hidden":!0}),t[101]=H):H=t[101];let U;t[102]===n.systemDreamingSettingsLink?U=t[103]:(U=(0,$.jsx)(Y,{type:`button`,variant:`ghost`,className:`shrink-0 gap-1 self-start px-2 py-1.5 text-xs`,asChild:!0,children:(0,$.jsxs)(T,{to:`/settings/dreams`,children:[n.systemDreamingSettingsLink,H]})}),t[102]=n.systemDreamingSettingsLink,t[103]=U);let W;t[104]!==V||t[105]!==U?(W=(0,$.jsxs)(`div`,{className:`mb-2 flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between`,children:[V,U]}),t[104]=V,t[105]=U,t[106]=W):W=t[106];let G;t[107]===n.systemDreamingHint?G=t[108]:(G=(0,$.jsx)(`p`,{className:`mb-3 text-xs text-fg-muted`,children:n.systemDreamingHint}),t[107]=n.systemDreamingHint,t[108]=G);let K;t[109]!==m||t[110]!==n||t[111]!==s||t[112]!==i||t[113]!==S||t[114]!==b||t[115]!==g||t[116]!==x||t[117]!==y||t[118]!==h||t[119]!==o||t[120]!==c?(K=s&&c.length===0?(0,$.jsx)(`div`,{className:`flex justify-center py-12`,"aria-busy":`true`,children:(0,$.jsx)(_,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):c.length===0?(0,$.jsx)(`p`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/30 px-3 py-4 text-sm text-fg-muted dark:border-edge-subtle`,children:n.systemDreamingEmpty}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-[repeat(auto-fill,minmax(280px,1fr))]`,children:c.map(e=>(0,$.jsx)(Wt,{job:e,c:n,localeTag:i,scheduleBadgeLabels:o,absorbCardClickJobIdRef:m,scheduleAbsorbNextMenuCardClick:h,onOpenDetail:g,onToggle:y,onEdit:b,onRunNow:x,onDelete:S},e.id))}),t[109]=m,t[110]=n,t[111]=s,t[112]=i,t[113]=S,t[114]=b,t[115]=g,t[116]=x,t[117]=y,t[118]=h,t[119]=o,t[120]=c,t[121]=K):K=t[121];let q;t[122]!==W||t[123]!==G||t[124]!==K?(q=(0,$.jsxs)(`div`,{children:[W,G,K]}),t[122]=W,t[123]=G,t[124]=K,t[125]=q):q=t[125];let ee;return t[126]!==w||t[127]!==E||t[128]!==D||t[129]!==B||t[130]!==q||t[131]!==P||t[132]!==F?(ee=(0,$.jsxs)(`section`,{"aria-labelledby":P,className:F,children:[w,E,D,B,q]}),t[126]=w,t[127]=E,t[128]=D,t[129]=B,t[130]=q,t[131]=P,t[132]=F,t[133]=ee):ee=t[133],ee}function Jt(e,t){let n=e.templates;if(!n||typeof n!=`object`)return;let r=n[t];if(!r||typeof r!=`object`)return;let i=r.title?.trim(),a=r.prompt?.trim();if(!(!i||!a))return{title:i,description:(r.description??``).trim(),prompt:a}}var Yt=[`daily`,`monitoring`,`reports`,`automation`],Xt=[{templateId:`morning_briefing`,category:`daily`,defaultSchedule:`0 7 * * 1-5`,defaultSessionTarget:`isolated`},{templateId:`standup_prep`,category:`daily`,defaultSchedule:`0 8 * * 1-5`,defaultSessionTarget:`isolated`},{templateId:`meeting_prep`,category:`daily`,defaultSchedule:`0 9 * * 1-5`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`meeting_prep`},{templateId:`end_of_day_wrap_up`,category:`daily`,defaultSchedule:`0 18 * * 1-5`,defaultSessionTarget:`isolated`},{templateId:`inbox_triage`,category:`daily`,defaultSchedule:`30 8 * * 1-5`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`inbox_triage`},{templateId:`competitor_watch`,category:`monitoring`,defaultSchedule:`0 9 * * 1`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`competitor_scan`},{templateId:`trending_topics_monitor`,category:`monitoring`,defaultSchedule:`0 10 * * 1-5`,defaultSessionTarget:`isolated`},{templateId:`tech_radar_stack`,category:`monitoring`,defaultSchedule:`0 11 * * 3`,defaultSessionTarget:`isolated`},{templateId:`dependency_check_audit`,category:`monitoring`,defaultSchedule:`0 9 * * 0`,defaultSessionTarget:`isolated`},{templateId:`weekly_review`,category:`reports`,defaultSchedule:`0 17 * * 5`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`weekly_review`},{templateId:`code_quality_report`,category:`reports`,defaultSchedule:`0 14 * * 1`,defaultSessionTarget:`isolated`},{templateId:`git_activity_summary`,category:`reports`,defaultSchedule:`0 9 * * 1`,defaultSessionTarget:`isolated`},{templateId:`user_feedback_digest`,category:`reports`,defaultSchedule:`0 16 * * 5`,defaultSessionTarget:`isolated`},{templateId:`content_repurpose`,category:`reports`,defaultSchedule:`0 11 * * 4`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`content_repurpose`},{templateId:`stale_todo_or_issue_sweep`,category:`automation`,defaultSchedule:`0 10 * * 2`,defaultSessionTarget:`isolated`},{templateId:`release_notes_or_changelog_draft`,category:`automation`,defaultSchedule:`0 10 * * 4`,defaultSessionTarget:`isolated`},{templateId:`client_proposal`,category:`automation`,defaultSchedule:`0 10 * * 2`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`client_proposal`},{templateId:`offer_design`,category:`automation`,defaultSchedule:`0 14 1 * *`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`offer_design`},{templateId:`decision_compare`,category:`automation`,defaultSchedule:`0 15 * * 3`,defaultSessionTarget:`isolated`,taskKind:`workflowRun`,workflowDefinitionId:`decision_compare`},{templateId:`workspace_cleanup_suggestions`,category:`automation`,defaultSchedule:`30 18 * * 5`,defaultSessionTarget:`isolated`},{templateId:`smoke_or_ci_health_reminder`,category:`automation`,defaultSchedule:`0 8 * * 1`,defaultSessionTarget:`isolated`}];function Zt(e){return Xt.find(t=>t.templateId===e)}function Qt(e,t,n){let r=t.trim().toLowerCase();return Xt.filter(t=>{if(n!==`all`&&t.category!==n)return!1;if(!r)return!0;let i=Jt(e,t.templateId);return[t.templateId,i?.title,i?.description,e.templateCategories[t.category]].filter(Boolean).join(` `).toLowerCase().includes(r)})}function $t(e){let t=new Map;for(let n of e){let e=t.get(n.category)??[];e.push(n),t.set(n.category,e)}return Yt.flatMap(e=>{let n=t.get(e);return n?.length?[{category:e,items:n}]:[]})}function en(e){let t=(0,Q.c)(23),{template:n,cron:r,localeTag:i,scheduleBadgeLabels:a,onSelectTemplate:o}=e,s;t[0]!==r||t[1]!==n.templateId?(s=Jt(r,n.templateId),t[0]=r,t[1]=n.templateId,t[2]=s):s=t[2];let c=s;if(!c)return null;let l;t[3]!==i||t[4]!==a||t[5]!==n.defaultSchedule?(l=ke({schedule:n.defaultSchedule,timezone:void 0,next_run:void 0},i,a),t[3]=i,t[4]=a,t[5]=n.defaultSchedule,t[6]=l):l=t[6];let u=l,d;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(d=X(`flex h-full flex-col gap-1.5 rounded-xl border border-edge-subtle bg-surface-base p-4 text-left transition-colors`,`hover:border-accent/40 hover:bg-surface-hover`,pe.focusRingPanel),t[7]=d):d=t[7];let f;t[8]!==o||t[9]!==n.templateId?(f=()=>o(n.templateId),t[8]=o,t[9]=n.templateId,t[10]=f):f=t[10];let p=`${r.templateCategories[n.category]} — ${c.title}`,m;t[11]===c.title?m=t[12]:(m=(0,$.jsx)(`span`,{className:`font-semibold text-fg`,children:c.title}),t[11]=c.title,t[12]=m);let h;t[13]===c.description?h=t[14]:(h=(0,$.jsx)(`span`,{className:`line-clamp-2 text-sm text-fg-muted`,children:c.description}),t[13]=c.description,t[14]=h);let g;t[15]===u?g=t[16]:(g=(0,$.jsx)(`span`,{className:`mt-auto flex items-center gap-1 pt-1 text-xs text-fg-muted`,children:(0,$.jsx)(`span`,{className:`tabular-nums`,children:u})}),t[15]=u,t[16]=g);let _;return t[17]!==f||t[18]!==p||t[19]!==m||t[20]!==h||t[21]!==g?(_=(0,$.jsxs)(`button`,{type:`button`,className:d,onClick:f,"aria-label":p,children:[m,h,g]}),t[17]=f,t[18]=p,t[19]=m,t[20]=h,t[21]=g,t[22]=_):_=t[22],_}function tn(e){let t=(0,Q.c)(49),{cron:n,localeTag:r,scheduleBadgeLabels:i,categoryFilter:a,onCategoryFilterChange:o,onSelectTemplate:s,variant:c}=e,l=c===void 0?`embedded`:c,[u,d]=(0,Z.useState)(``),f;t[0]!==a||t[1]!==n||t[2]!==u?(f=Qt(n,u,a),t[0]=a,t[1]=n,t[2]=u,t[3]=f):f=t[3];let p=f,m;t[4]===p?m=t[5]:(m=$t(p),t[4]=p,t[5]=m);let h=m,g;t[6]!==a||t[7]!==u?(g=a===`all`&&!u.trim(),t[6]=a,t[7]=u,t[8]=g):g=t[8];let _=g,v;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(O,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=v):v=t[9];let y;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>d(e.target.value),t[10]=y):y=t[10];let b=n.templateSearchPlaceholder,x;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(x=X(`h-10 w-full rounded-xl border border-edge bg-surface-base py-2 pl-10 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,pe.focusRingPanel),t[11]=x):x=t[11];let S;t[12]!==n.templateSearchPlaceholder||t[13]!==u?(S=(0,$.jsxs)(`div`,{className:`relative`,children:[v,(0,$.jsx)(`input`,{value:u,onChange:y,placeholder:b,className:x})]}),t[12]=n.templateSearchPlaceholder,t[13]=u,t[14]=S):S=t[14];let C=n.fromTemplate,w=a===`all`?`secondary`:`ghost`,T;t[15]===o?T=t[16]:(T=()=>o(`all`),t[15]=o,t[16]=T);let E;t[17]!==n.templateFilterAll||t[18]!==w||t[19]!==T?(E=(0,$.jsx)(Y,{type:`button`,variant:w,className:`h-8 rounded-full px-3 py-1.5 text-xs`,onClick:T,children:n.templateFilterAll}),t[17]=n.templateFilterAll,t[18]=w,t[19]=T,t[20]=E):E=t[20];let D;t[21]!==a||t[22]!==n.templateCategories||t[23]!==o?(D=Yt.map(e=>(0,$.jsx)(Y,{type:`button`,variant:a===e?`secondary`:`ghost`,className:`h-8 rounded-full px-3 py-1.5 text-xs`,onClick:()=>o(e),children:n.templateCategories[e]},e)),t[21]=a,t[22]=n.templateCategories,t[23]=o,t[24]=D):D=t[24];let k;t[25]!==n.fromTemplate||t[26]!==E||t[27]!==D?(k=(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":C,children:[E,D]}),t[25]=n.fromTemplate,t[26]=E,t[27]=D,t[28]=k):k=t[28];let A;t[29]!==k||t[30]!==S?(A=(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-4`,children:[S,k]}),t[29]=k,t[30]=S,t[31]=A):A=t[31];let j=A,M;t[32]!==n||t[33]!==p||t[34]!==h||t[35]!==r||t[36]!==s||t[37]!==i||t[38]!==_||t[39]!==l?(M=p.length===0?(0,$.jsx)(`div`,{className:X(`text-center text-sm text-fg-muted`,l===`dialog`&&`flex h-full flex-col items-center justify-center px-4 py-12`),children:n.templatesEmptyHint}):_?(0,$.jsx)(`div`,{className:`flex flex-col gap-6 pb-1`,children:h.map(e=>(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:n.templateCategories[e.category]}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:e.items.map(e=>(0,$.jsx)(en,{template:e,cron:n,localeTag:r,scheduleBadgeLabels:i,onSelectTemplate:s},e.templateId))})]},e.category))}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 pb-1 sm:grid-cols-2 xl:grid-cols-3`,children:p.map(e=>(0,$.jsx)(en,{template:e,cron:n,localeTag:r,scheduleBadgeLabels:i,onSelectTemplate:s},e.templateId))}),t[32]=n,t[33]=p,t[34]=h,t[35]=r,t[36]=s,t[37]=i,t[38]=_,t[39]=l,t[40]=M):M=t[40];let N=M;if(l===`dialog`){let e;t[41]===N?e=t[42]:(e=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:N}),t[41]=N,t[42]=e);let n;return t[43]!==j||t[44]!==e?(n=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-4`,children:[j,e]}),t[43]=j,t[44]=e,t[45]=n):n=t[45],n}let P;return t[46]!==j||t[47]!==N?(P=(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[j,N]}),t[46]=j,t[47]=N,t[48]=P):P=t[48],P}function nn(e){let t=(0,Q.c)(49),{c:n,localeTag:r,scheduleBadgeLabels:i,loading:a,jobsCount:o,sortedJobs:s,templateCategoryFilter:c,onTemplateCategoryFilterChange:l,onSelectTemplate:u,keepAwake:d,wakeSupported:f,onWakeUnsupportedClick:p,onKeepAwakeToggle:m,absorbCardClickJobIdRef:h,scheduleAbsorbNextMenuCardClick:g,onOpenDetail:v,onToggle:y,onEdit:b,onAddJob:x,onRunNow:S,onDelete:C}=e,w;t[0]===n.tabMyTasks?w=t[1]:(w=(0,$.jsx)(`h2`,{id:`cron-tasks-panel`,className:`sr-only`,children:n.tabMyTasks}),t[0]=n.tabMyTasks,t[1]=w);let T;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(L,{className:`mt-0.5 size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=T):T=t[2];let E;t[3]===n.wakeBanner?E=t[4]:(E=(0,$.jsxs)(`div`,{className:`flex gap-3 text-sm text-fg`,children:[T,(0,$.jsx)(`p`,{className:`text-pretty text-fg-muted`,children:n.wakeBanner})]}),t[3]=n.wakeBanner,t[4]=E);let D;t[5]===n.keepAwake?D=t[6]:(D=(0,$.jsx)(`span`,{className:`text-sm text-fg`,children:n.keepAwake}),t[5]=n.keepAwake,t[6]=D);let O=!f,k=f?void 0:n.wakeLockUnavailable,A=d?`justify-end bg-accent`:`justify-start bg-surface-hover`,j=!f&&`cursor-not-allowed opacity-50`,M;t[7]!==A||t[8]!==j?(M=X(`inline-flex h-6 w-10 shrink-0 items-center rounded-full border border-edge p-0.5 transition-colors`,A,j),t[7]=A,t[8]=j,t[9]=M):M=t[9];let N;t[10]!==m||t[11]!==p||t[12]!==f?(N=()=>{f?m():p()},t[10]=m,t[11]=p,t[12]=f,t[13]=N):N=t[13];let P;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(`span`,{className:`size-4 rounded-full bg-surface-panel shadow-surface ring-1 ring-edge/40 dark:ring-edge/55`}),t[14]=P):P=t[14];let F;t[15]!==d||t[16]!==N||t[17]!==O||t[18]!==k||t[19]!==M?(F=(0,$.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":d,disabled:O,title:k,className:M,onClick:N,children:P}),t[15]=d,t[16]=N,t[17]=O,t[18]=k,t[19]=M,t[20]=F):F=t[20];let I;t[21]!==F||t[22]!==D?(I=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 sm:pl-4`,children:[D,F]}),t[21]=F,t[22]=D,t[23]=I):I=t[23];let R;t[24]!==I||t[25]!==E?(R=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent/5 px-4 py-3 dark:border-accent/30 dark:bg-accent/10 sm:flex-row sm:items-center sm:justify-between`,children:[E,I]}),t[24]=I,t[25]=E,t[26]=R):R=t[26];let z;t[27]!==h||t[28]!==n||t[29]!==o||t[30]!==a||t[31]!==r||t[32]!==x||t[33]!==C||t[34]!==b||t[35]!==v||t[36]!==S||t[37]!==u||t[38]!==l||t[39]!==y||t[40]!==g||t[41]!==i||t[42]!==s||t[43]!==c?(z=a&&o===0?(0,$.jsx)(`div`,{className:`flex justify-center py-16`,"aria-busy":`true`,children:(0,$.jsx)(_,{className:`size-8 animate-spin text-accent`,strokeWidth:1.75})}):o===0?(0,$.jsxs)(`div`,{className:`flex flex-col gap-6 rounded-2xl bg-surface-base px-4 py-8 dark:bg-surface-hover/25 sm:px-6 sm:py-10`,children:[(0,$.jsx)(`div`,{className:`w-full max-w-6xl`,children:(0,$.jsx)(tn,{cron:n,localeTag:r,scheduleBadgeLabels:i,categoryFilter:c,onCategoryFilterChange:l,onSelectTemplate:u})}),(0,$.jsx)(`div`,{className:`flex justify-center`,children:(0,$.jsx)(Y,{type:`button`,variant:`primary`,onClick:x,children:n.emptyStateCta})})]}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-[repeat(auto-fill,minmax(280px,1fr))]`,children:s.map(e=>(0,$.jsx)(Wt,{job:e,c:n,localeTag:r,scheduleBadgeLabels:i,absorbCardClickJobIdRef:h,scheduleAbsorbNextMenuCardClick:g,onOpenDetail:e=>void v(e),onToggle:(e,t)=>void y(e,t),onEdit:b,onRunNow:S,onDelete:C},e.id))}),t[27]=h,t[28]=n,t[29]=o,t[30]=a,t[31]=r,t[32]=x,t[33]=C,t[34]=b,t[35]=v,t[36]=S,t[37]=u,t[38]=l,t[39]=y,t[40]=g,t[41]=i,t[42]=s,t[43]=c,t[44]=z):z=t[44];let B;return t[45]!==w||t[46]!==R||t[47]!==z?(B=(0,$.jsxs)(`section`,{"aria-labelledby":`cron-tasks-panel`,className:`flex flex-col gap-4`,children:[w,R,z]}),t[45]=w,t[46]=R,t[47]=z,t[48]=B):B=t[48],B}function rn(e){let t=(0,Q.c)(29),{open:n,onOpenChange:r,c:i,localeTag:a,scheduleBadgeLabels:o,categoryFilter:s,onCategoryFilterChange:c,onSelectTemplate:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(b,{className:`xopc-dialog-overlay fixed inset-0 z-[62] bg-scrim`}),t[0]=u):u=t[0];let d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=X(`xopc-dialog-content-pane pointer-events-auto relative flex h-[min(90vh,840px)] w-full max-w-5xl flex-col`,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,pe.focusRingPanel),t[1]=d):d=t[1];let f;t[2]===i.fromTemplate?f=t[3]:(f=(0,$.jsx)(ae,{className:`text-lg font-semibold text-fg`,children:i.fromTemplate}),t[2]=i.fromTemplate,t[3]=f);let p;t[4]===i.templatePickerHint?p=t[5]:(p=(0,$.jsx)(I,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:i.templatePickerHint}),t[4]=i.templatePickerHint,t[5]=p);let m;t[6]!==f||t[7]!==p?(m=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[f,p]}),t[6]=f,t[7]=p,t[8]=m):m=t[8];let h;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(ee,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[9]=h):h=t[9];let _;t[10]===i.close?_=t[11]:(_=(0,$.jsx)(g,{asChild:!0,children:(0,$.jsx)(Y,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":i.close,children:h})}),t[10]=i.close,t[11]=_);let v;t[12]!==m||t[13]!==_?(v=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge-subtle px-6 py-5`,children:[m,_]}),t[12]=m,t[13]=_,t[14]=v):v=t[14];let x;t[15]!==i||t[16]!==s||t[17]!==a||t[18]!==c||t[19]!==l||t[20]!==o?(x=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-6 py-5`,children:(0,$.jsx)(tn,{variant:`dialog`,cron:i,localeTag:a,scheduleBadgeLabels:o,categoryFilter:s,onCategoryFilterChange:c,onSelectTemplate:l})}),t[15]=i,t[16]=s,t[17]=a,t[18]=c,t[19]=l,t[20]=o,t[21]=x):x=t[21];let S;t[22]!==v||t[23]!==x?(S=(0,$.jsxs)(y,{children:[u,(0,$.jsx)(`div`,{className:`fixed inset-0 z-[62] flex items-center justify-center p-4 pointer-events-none`,children:(0,$.jsxs)(he,{className:d,onOpenAutoFocus:an,children:[v,x]})})]}),t[22]=v,t[23]=x,t[24]=S):S=t[24];let C;return t[25]!==r||t[26]!==n||t[27]!==S?(C=(0,$.jsx)(A,{open:n,onOpenChange:r,children:S}),t[25]=r,t[26]=n,t[27]=S,t[28]=C):C=t[28],C}function an(e){return e.preventDefault()}function on(){return{formOpen:!1,formMode:`add`,formJobId:null,formName:``,formSchedule:ut,formChannel:`local`,formChatId:``,formMessage:``,formMessageMdMode:`edit`,formTaskKind:`message`,formWorkflowDefinitionId:``,formWorkflowGoal:``,formWorkflowArgValues:{},messageEditorNonce:0,formSessionTarget:`main`,formAgentId:``,formAgentLocalOnly:!1,formWorkingDirectory:``,formModel:``,formSubmitting:!1}}function sn(e,t){switch(t.type){case`patch`:return{...e,...t.patch};case`replace`:return t.state;case`setMessageMdMode`:return{...e,formMessageMdMode:t.mode,messageEditorNonce:t.mode===`edit`?e.messageEditorNonce+1:e.messageEditorNonce}}}function cn(e,t){let n=on();if(n.formOpen=!0,n.formMode=e?`edit`:`add`,n.formJobId=e?.id??null,!e)return n.formModel=t(),n;n.formName=e.name||``,n.formSchedule=e.schedule&&String(e.schedule).trim()||`*/5 * * * *`;let r=Le(e);if(n.formMessage=r??``,e.payload.kind===`workflowRun`){n.formTaskKind=`workflowRun`,n.formWorkflowDefinitionId=e.payload.definitionId,n.formWorkflowGoal=e.payload.goal||``,n.formWorkflowArgValues=jt(e.payload.definitionId,e.payload.inputEnvelope?.payload??e.payload.input??{});let t=e.payload.agentId?.trim().toLowerCase();t&&(n.formAgentId=t)}n.formSessionTarget=e.sessionTarget||`main`,n.formAgentId=(e.sessionTarget||`main`)===`isolated`&&e.agentId?.trim()?e.agentId.trim().toLowerCase():``,n.formWorkingDirectory=(e.sessionTarget||`main`)===`isolated`&&e.workingDirectory?.trim()?e.workingDirectory.trim():``;let i=e.payload?.kind===`agentTurn`&&e.payload.model?.trim()?e.payload.model.trim():``;n.formModel=e.model?.trim()||i||t();let a=e.delivery?.channel===`local`,o=(e.sessionTarget||`main`)===`isolated`&&!a&&(!e.delivery?.to||e.delivery.mode===`none`);if(n.formAgentLocalOnly=o,a)n.formChannel=`local`,n.formChatId=``;else if(e.delivery&&e.delivery.mode!==`none`&&e.delivery.to)n.formChannel=e.delivery.channel||`telegram`,n.formChatId=e.delivery.to||``;else if(o)n.formChannel=`telegram`,n.formChatId=``;else{let e=r.split(`:`);e.length>=3&&[`telegram`,`cli`,`gateway`,`local`].includes(e[0])?(n.formChannel=e[0],n.formChatId=e[1],n.formMessage=e.slice(2).join(`:`)):(n.formChannel=`telegram`,n.formChatId=``)}return n.formMessageMdMode=`edit`,n.messageEditorNonce=1,n}function ln(e){let{m:t,defaultModelForForm:n,channels:r,chatAgents:i}=e,[a,o]=(0,Z.useReducer)(sn,void 0,on),s=(0,Z.useRef)(!1),c=(0,Z.useMemo)(()=>new Set([`local`,...r.map(e=>e.name)]),[r]);if(a.formOpen&&a.formMode===`add`&&!c.has(a.formChannel)&&o({type:`patch`,patch:{formChannel:`local`}}),a.formOpen&&a.formMode===`add`&&!s.current){let e=n();e&&e!==a.formModel&&o({type:`patch`,patch:{formModel:e}})}let l=F(()=>Fe(a.formChannel),[a.formChannel],{enabled:a.formOpen&&a.formChannel!==`local`,initial:[],errorData:[]}),u=a.formChannel===`local`?[]:l.data,d=(0,Z.useMemo)(()=>{let e=new Set(i.map(e=>e.id)),t=[...i],n=a.formAgentId.trim().toLowerCase();return n&&!e.has(n)&&t.push({id:n}),t},[i,a.formAgentId]),f=a.formChannel!==`local`&&(a.formTaskKind===`message`&&(a.formSessionTarget===`main`||a.formSessionTarget===`isolated`&&!a.formAgentLocalOnly)||a.formTaskKind===`workflowRun`&&!a.formAgentLocalOnly),p=a.formTaskKind===`workflowRun`?!a.formAgentLocalOnly:a.formTaskKind===`message`&&(a.formSessionTarget===`main`||a.formSessionTarget===`isolated`&&!a.formAgentLocalOnly),m=a.formTaskKind===`workflowRun`?!!a.formWorkflowDefinitionId.trim()&&Mt(a.formWorkflowDefinitionId.trim(),a.formWorkflowArgValues):!!a.formMessage.trim(),h=!!a.formName.trim()&&!!a.formSchedule.trim()&&m&&(!f||!!a.formChatId.trim()),g=(0,Z.useCallback)(e=>{s.current=!1,o({type:`replace`,state:cn(e,n)})},[n]),_=(0,Z.useCallback)(e=>{o({type:`setMessageMdMode`,mode:e})},[]),v=(0,Z.useCallback)(e=>{let r=Zt(e),i=r?Jt(t.cron,e):void 0;if(!r||!i)return!1;let a=r.taskKind===`workflowRun`&&!!r.workflowDefinitionId;return s.current=!1,o({type:`replace`,state:{...on(),formOpen:!0,formMode:`add`,formName:i.title,formSchedule:r.defaultSchedule,formMessage:a?``:i.prompt,formTaskKind:a?`workflowRun`:`message`,formWorkflowDefinitionId:a?r.workflowDefinitionId:``,formWorkflowGoal:a?i.description:``,formSessionTarget:r.defaultSessionTarget,formModel:n(),formAgentLocalOnly:a,messageEditorNonce:1}}),!0},[n,t.cron]),y=(0,Z.useCallback)(()=>{s.current=!1,o({type:`replace`,state:on()})},[]),b=(0,Z.useCallback)((e,t,n)=>{let r={formSessionTarget:e};e===`main`?(r.formAgentLocalOnly=!1,r.formAgentId=``,r.formWorkingDirectory=``):e===`isolated`&&!n&&(r.formModel=t()),o({type:`patch`,patch:r})},[]),x=(0,Z.useCallback)(e=>{o({type:`patch`,patch:{formChannel:e,formChatId:``,...e===`local`?{formAgentLocalOnly:!1}:{}}})},[]),S=(0,Z.useCallback)(e=>{s.current=!0,o({type:`patch`,patch:{formModel:e}})},[]),C=(0,Z.useCallback)(()=>{Fe(a.formChannel).then(l.setData)},[a.formChannel,l.setData]),w=(0,Z.useCallback)(e=>{o({type:`patch`,patch:e})},[]);return{formOpen:a.formOpen,formMode:a.formMode,formJobId:a.formJobId,formName:a.formName,formSchedule:a.formSchedule,formChannel:a.formChannel,formChatId:a.formChatId,formMessage:a.formMessage,formMessageMdMode:a.formMessageMdMode,formTaskKind:a.formTaskKind,formWorkflowDefinitionId:a.formWorkflowDefinitionId,formWorkflowGoal:a.formWorkflowGoal,formWorkflowArgValues:a.formWorkflowArgValues,messageEditorNonce:a.messageEditorNonce,formSessionTarget:a.formSessionTarget,formAgentId:a.formAgentId,formAgentLocalOnly:a.formAgentLocalOnly,formWorkingDirectory:a.formWorkingDirectory,formModel:a.formModel,formSubmitting:a.formSubmitting,sessionChatIds:u,setFormName:e=>w({formName:e}),setFormSchedule:e=>w({formSchedule:e}),setFormChatId:e=>w({formChatId:e}),setFormMessage:e=>w({formMessage:e}),setFormTaskKind:e=>w(e===`workflowRun`?{formTaskKind:e,formSessionTarget:`isolated`,formAgentLocalOnly:!1}:{formTaskKind:e}),setFormWorkflowDefinitionId:e=>w({formWorkflowDefinitionId:e,formWorkflowArgValues:{}}),setFormWorkflowGoal:e=>w({formWorkflowGoal:e}),setFormWorkflowArgValues:e=>w({formWorkflowArgValues:e}),setFormAgentId:e=>w({formAgentId:e}),setFormAgentLocalOnly:e=>w({formAgentLocalOnly:e}),setFormWorkingDirectory:e=>w({formWorkingDirectory:e}),setFormSubmitting:e=>w({formSubmitting:e}),canSubmit:h,needsDeliveryChat:f,showChannelPicker:p,cronAgentSelectOptions:d,openForm:g,closeForm:y,applyCronTemplate:v,setMessageMdMode:_,handleFormSessionTargetChange:b,handleFormChannelChange:x,handleFormModelUserChange:S,refreshRecipientsList:C}}function un(e){let{onUnavailable:t}=e,[n,r]=(0,Z.useState)(!1),i=(0,Z.useRef)(null),a=(0,Z.useRef)(`none`),o=(0,Z.useRef)(n),s=typeof navigator<`u`&&`wakeLock`in navigator,c=s||R(),l=(0,Z.useCallback)(async()=>{if(a.current===`electron`){try{await window.electronAPI?.cron?.setDisplaySleepPrevented?.(!1)}catch{}a.current=`none`;return}try{await i.current?.release()}catch{}i.current=null,a.current=`none`},[]),u=(0,Z.useCallback)(async()=>{let e=typeof window<`u`?window.electronAPI?.cron?.setDisplaySleepPrevented:void 0;if(e)try{await e(!0),a.current=`electron`;return}catch{t(),r(!1);return}if(s)try{let e=await navigator.wakeLock.request(`screen`);i.current=e,a.current=`navigator`,e.addEventListener(`release`,()=>{i.current=null,a.current=`none`})}catch{t(),r(!1)}},[t,s]);return o.current=n,(0,Z.useEffect)(()=>{if(!n){l();return}u();let e=()=>{document.visibilityState===`visible`&&o.current&&u()};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e),l()}},[n,u,l]),{keepAwake:n,setKeepAwake:r,featureAvailable:c}}function dn(e){let{hasToken:t,failMessages:n,isHistoryTab:r}=e,[i,a]=(0,Z.useState)([]),[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)([]),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)([]),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)([]),[v,y]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(null),w=(0,Z.useCallback)(async()=>{x(!0),C(null);try{a(await Ue())}catch(e){C(e instanceof Error?e.message:n.failedToLoadJobs)}finally{x(!1)}},[n.failedToLoadJobs]),T=(0,Z.useCallback)(async()=>{try{let[e,t,n,r,i]=await Promise.all([Pe(),je(),Ae(),ce(),K().catch(()=>null)]);s(e),l(t),d(n.model||``),h(r.payload?.config??null),i&&p(i.items)}catch{}},[]),E=(0,Z.useCallback)(async()=>{y(!0);try{_(await Be(400))}catch{}finally{y(!1)}},[]);return(0,Z.useEffect)(()=>{t&&(w(),T())},[t,w,T]),(0,Z.useEffect)(()=>{if(!t)return;let e=()=>{ce().then(e=>{h(e.payload?.config??null)})};return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[t]),(0,Z.useEffect)(()=>{!t||!r||E()},[t,r,E]),{jobs:i,channels:o,availableModels:c,defaultModel:u,chatAgents:f,gatewayConfigRaw:m,runHistory:g,runHistoryLoading:v,loading:b,error:S,setError:C,userCronJobs:(0,Z.useMemo)(()=>i.filter(e=>!we(e)),[i]),systemCronJobs:(0,Z.useMemo)(()=>i.filter(e=>we(e)),[i]),heartbeatFromConfig:(0,Z.useMemo)(()=>Ge(m),[m]),loadJobs:w,loadAux:T,loadRunHistoryOnly:E,refreshAll:(0,Z.useCallback)(()=>{w(),T(),E()},[w,T,E])}}function fn(e,t){let n=[...e];return n.sort((e,n)=>{let r=new Date(e.created_at).getTime(),i=new Date(n.created_at).getTime();return t===`created_desc`?i-r:r-i}),n}function pn(e,t,n,r){let i=new Date,a=t===`day`?ft(i):t===`week`?pt(i):mt(i);return e.filter(e=>!(new Date(e.startedAt)<a||n&&e.jobId!==n||r&&e.status!==r))}var mn={mainTab:`myTasks`,jobSort:`created_desc`,historyRange:`day`,historyJobFilter:``,historyStatusFilter:``,detailOpen:!1,detailJob:null,detailHistory:[],detailLoading:!1,confirmOpen:!1,templatePickerOpen:!1,templateCategoryFilter:`all`};function hn(){let e=i(e=>e.language),t=a(e),n=t.cron,r=t.chat,o=u(e=>e.token),c=!!o,d=l(e=>e.resolved)===`dark`,f=e===`zh`?`zh-CN`:`en-US`,[p,m]=z(),[h,g]=(0,Z.useReducer)(k,p,e=>({...mn,mainTab:xt(e.get(`tab`))})),{mainTab:_,jobSort:v,historyRange:y,historyJobFilter:b,historyStatusFilter:x,detailOpen:S,detailJob:C,detailHistory:w,detailLoading:T,confirmOpen:E,templatePickerOpen:D,templateCategoryFilter:O}=h,A=xt(p.get(`tab`));(0,Z.useEffect)(()=>{A!==_&&g({type:`patch`,patch:{mainTab:A}})},[A,_]);let j=(0,Z.useCallback)(e=>{g({type:`patch`,patch:{mainTab:e}}),m(t=>{let n=new URLSearchParams(t),r=St(e);return r?n.set(`tab`,r):n.delete(`tab`),n},{replace:!0})},[m]),M=dn({hasToken:c,failMessages:{failedToLoadJobs:n.failedToLoadJobs},isHistoryTab:_===`history`}),{setError:N}=M,P=un({onUnavailable:()=>N(n.wakeLockUnavailable)}),F=(0,Z.useCallback)(()=>M.defaultModel||(M.availableModels.length>0?M.availableModels[0].id:``),[M.defaultModel,M.availableModels]),I=ln({m:t,defaultModelForForm:F,channels:M.channels,chatAgents:M.chatAgents}),L=s(c&&I.formOpen?[`workflow-definitions-cron`,o]:null,te,{revalidateOnFocus:!1}),R=L.data??[],B=(0,Z.useRef)(null),V=(0,Z.useRef)(null),H=(0,Z.useCallback)((e,t)=>{B.current=e,V.current=t,g({type:`patch`,patch:{confirmOpen:!0}})},[]),U=(0,Z.useCallback)(()=>{g({type:`patch`,patch:{confirmOpen:!1}}),V.current=null,B.current=null},[]),W=(0,Z.useRef)(null),G=(0,Z.useCallback)(e=>{W.current=e,window.setTimeout(()=>{W.current===e&&(W.current=null)},400)},[]),K=(0,Z.useCallback)(e=>{I.applyCronTemplate(e)&&g({type:`patch`,patch:{templatePickerOpen:!1}})},[I]),q=async()=>{if(!I.formName.trim()){N(n.nameRequired);return}if(!I.formSchedule.trim()){N(n.scheduleRequired);return}if(I.formTaskKind===`message`&&!I.formMessage.trim()){N(n.scheduleRequired);return}if(I.formTaskKind===`workflowRun`&&!I.formWorkflowDefinitionId.trim()){N(n.workflowDefinitionRequired);return}if(I.formTaskKind===`workflowRun`&&!Mt(I.formWorkflowDefinitionId.trim(),I.formWorkflowArgValues)){N(n.workflowArgsRequired);return}if(I.needsDeliveryChat&&!I.formChatId.trim()){N(n.chatIdRequired);return}I.setFormSubmitting(!0),N(null);try{let e=I.formMessage.trim(),t=I.formModel.trim(),n=I.formAgentId.trim().toLowerCase(),r=I.formWorkingDirectory.trim(),i=I.formTaskKind===`workflowRun`,a=I.formTaskKind===`message`&&I.formSessionTarget===`isolated`,o=i?`isolated`:I.formSessionTarget,s;s=i?I.formAgentLocalOnly?{mode:`none`}:I.formChannel===`local`?{mode:`direct`,channel:`local`}:{mode:`direct`,channel:I.formChannel,to:I.formChatId.trim()}:I.formSessionTarget===`isolated`&&I.formAgentLocalOnly?{mode:`none`}:I.formChannel===`local`?{mode:`direct`,channel:`local`}:{mode:`direct`,channel:I.formChannel,to:I.formChatId.trim()};let c;if(i){let e=I.formWorkflowDefinitionId.trim(),t=Je(I.formWorkflowArgValues);c={kind:`workflowRun`,definitionId:e,...t===void 0?{}:{inputEnvelope:{payload:t}},...I.formWorkflowGoal.trim()?{goal:I.formWorkflowGoal.trim()}:{},...n?{agentId:n}:{}}}else c=a?{kind:`agentTurn`,message:e,...t?{model:t}:{}}:{kind:`systemEvent`,text:e};let l=o===`main`?null:n||null,u={name:I.formName.trim(),schedule:I.formSchedule.trim(),sessionTarget:o,model:a&&t?t:void 0,...i?{timeout:dt}:{},delivery:s,payload:c,...I.formMode===`edit`?{agentId:l,workingDirectory:a&&r||null}:{...o===`isolated`&&n?{agentId:n}:{},...a&&r?{workingDirectory:r}:{}}};if(I.formMode===`edit`&&I.formJobId)await Ie(I.formJobId,u);else{let{schedule:e,agentId:t,workingDirectory:n,...r}=u;await He(e,{...r,...t==null?{}:{agentId:t},...n?{workingDirectory:n}:{}})}I.closeForm(),await M.loadJobs()}catch(e){N(e instanceof Error?e.message:I.formMode===`edit`?n.failedToUpdateJob:n.failedToCreateJob)}finally{I.setFormSubmitting(!1)}},ee=async e=>{g({type:`patch`,patch:{detailOpen:!0,detailJob:e,detailLoading:!0,detailHistory:[]}});try{let t=await Ve(e.id);t&&g({type:`patch`,patch:{detailJob:t,detailHistory:await Re(e.id,20)}})}catch{}finally{g({type:`patch`,patch:{detailLoading:!1}})}},ne=(0,Z.useCallback)(()=>{g({type:`patch`,patch:{detailOpen:!1,detailJob:null}})},[]),re=(0,Z.useCallback)(()=>{g({type:`patch`,patch:{templateCategoryFilter:`all`,templatePickerOpen:!0}})},[]),J=async(e,t)=>{try{await ze(e.id,t),C?.id===e.id&&g({type:`patch`,patch:{detailJob:{...C,enabled:t}}}),await Promise.all([M.loadJobs(),M.loadAux()])}catch(e){N(e instanceof Error?e.message:n.failedToToggleJob)}},ie=async()=>{let e=V.current,t=B.current;if(!(!e||!t)){U();try{t===`run`?await Ne(e):(await Me(e),C?.id===e&&g({type:`patch`,patch:{detailOpen:!1,detailJob:null}})),await Promise.all([M.loadJobs(),M.loadAux(),M.loadRunHistoryOnly()])}catch(e){N(e instanceof Error?e.message:n.actionFailed)}}};(0,Z.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(I.formOpen?I.closeForm():S&&g({type:`patch`,patch:{detailOpen:!1,detailJob:null}}))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[I,S]);let ae=(0,Z.useMemo)(()=>({running:n.execStatusRunning,success:n.execStatusSuccess,failed:n.execStatusFailed,cancelled:n.execStatusCancelled}),[n.execStatusCancelled,n.execStatusFailed,n.execStatusRunning,n.execStatusSuccess]),oe=(0,Z.useMemo)(()=>fn(M.userCronJobs,v),[M.userCronJobs,v]),Y=(0,Z.useMemo)(()=>fn(M.systemCronJobs,v),[M.systemCronJobs,v]),se=(0,Z.useMemo)(()=>pn(M.runHistory,y,b,x),[M.runHistory,y,b,x]),ce=n.scheduleBadge;return c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(gn,{hasToken:c,c:n,loading:M.loading,runHistoryLoading:M.runHistoryLoading,onRefresh:M.refreshAll,onOpenTemplatePicker:re,onAddJob:()=>I.openForm()}),(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:[(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6 sm:px-8`,children:[M.error?(0,$.jsx)(`div`,{className:`rounded-xl border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,role:`alert`,children:M.error}):null,(0,$.jsx)(Bt,{c:n,mainTab:_,onMainTabChange:j,jobSort:v,onJobSortChange:e=>g({type:`patch`,patch:{jobSort:e}}),historyRange:y,onHistoryRangeChange:e=>g({type:`patch`,patch:{historyRange:e}}),historyJobFilter:b,onHistoryJobFilterChange:e=>g({type:`patch`,patch:{historyJobFilter:e}}),historyStatusFilter:x,onHistoryStatusFilterChange:e=>g({type:`patch`,patch:{historyStatusFilter:e}}),jobs:M.jobs}),_===`myTasks`?(0,$.jsx)(nn,{c:n,localeTag:f,scheduleBadgeLabels:ce,loading:M.loading,jobsCount:M.userCronJobs.length,sortedJobs:oe,templateCategoryFilter:O,onTemplateCategoryFilterChange:e=>g({type:`patch`,patch:{templateCategoryFilter:e}}),onSelectTemplate:K,keepAwake:P.keepAwake,wakeSupported:P.featureAvailable,onWakeUnsupportedClick:()=>N(n.wakeLockUnavailable),onKeepAwakeToggle:()=>P.setKeepAwake(e=>!e),absorbCardClickJobIdRef:W,scheduleAbsorbNextMenuCardClick:G,onOpenDetail:e=>void ee(e),onToggle:(e,t)=>void J(e,t),onEdit:e=>I.openForm(e),onAddJob:()=>I.openForm(),onRunNow:e=>H(`run`,e.id),onDelete:e=>H(`delete`,e.id)}):_===`systemTasks`?(0,$.jsx)(qt,{c:n,language:e,localeTag:f,scheduleBadgeLabels:ce,loading:M.loading,sortedSystemJobs:Y,heartbeat:M.heartbeatFromConfig,keepAwake:P.keepAwake,wakeSupported:P.featureAvailable,onWakeUnsupportedClick:()=>N(n.wakeLockUnavailable),onKeepAwakeToggle:()=>P.setKeepAwake(e=>!e),absorbCardClickJobIdRef:W,scheduleAbsorbNextMenuCardClick:G,onOpenDetail:e=>void ee(e),onToggle:(e,t)=>void J(e,t),onEdit:e=>I.openForm(e),onRunNow:e=>H(`run`,e.id),onDelete:e=>H(`delete`,e.id)}):_===`history`?(0,$.jsx)(Ut,{c:n,runHistoryLoading:M.runHistoryLoading,runHistory:M.runHistory,filteredRunHistory:se,jobs:M.jobs,onRefreshHistory:()=>void M.loadRunHistoryOnly(),onOpenJobDetail:e=>void ee(e),statusLabels:ae}):(0,$.jsx)(ct,{hasToken:c})]}),(0,$.jsx)(Ft,{open:I.formOpen,onRequestClose:I.closeForm,c:n,chatM:r,agentsMessages:t.agentsSettings,isDark:d,channels:M.channels,sessionChatIds:I.sessionChatIds,cronAgentSelectOptions:I.cronAgentSelectOptions,defaultModelResolver:F,formMode:I.formMode,formJobId:I.formJobId,formName:I.formName,onFormNameChange:I.setFormName,formSchedule:I.formSchedule,onFormScheduleChange:I.setFormSchedule,formSubmitting:I.formSubmitting,formTaskKind:I.formTaskKind,onFormTaskKindChange:I.setFormTaskKind,workflowDefinitions:R,workflowDefinitionsLoading:L.isLoading,formWorkflowDefinitionId:I.formWorkflowDefinitionId,onFormWorkflowDefinitionIdChange:I.setFormWorkflowDefinitionId,formWorkflowGoal:I.formWorkflowGoal,onFormWorkflowGoalChange:I.setFormWorkflowGoal,formWorkflowArgValues:I.formWorkflowArgValues,onFormWorkflowArgValuesChange:I.setFormWorkflowArgValues,formSessionTarget:I.formSessionTarget,onFormSessionTargetChange:I.handleFormSessionTargetChange,formAgentLocalOnly:I.formAgentLocalOnly,onFormAgentLocalOnlyChange:I.setFormAgentLocalOnly,formModel:I.formModel,onFormModelUserChange:I.handleFormModelUserChange,formAgentId:I.formAgentId,onFormAgentIdChange:I.setFormAgentId,formWorkingDirectory:I.formWorkingDirectory,onFormWorkingDirectoryChange:I.setFormWorkingDirectory,formChannel:I.formChannel,onFormChannelChange:I.handleFormChannelChange,formChatId:I.formChatId,onFormChatIdChange:I.setFormChatId,formMessage:I.formMessage,onFormMessageChange:I.setFormMessage,formMessageMdMode:I.formMessageMdMode,onSetMessageMdMode:I.setMessageMdMode,messageEditorNonce:I.messageEditorNonce,needsDeliveryChat:I.needsDeliveryChat,showChannelPicker:I.showChannelPicker,canSubmit:I.canSubmit,onSubmit:()=>void q(),onRefreshRecipients:I.refreshRecipientsList}),(0,$.jsx)(rn,{open:D,onOpenChange:e=>{g({type:`patch`,patch:{templatePickerOpen:e,...e?{templateCategoryFilter:`all`}:{}}})},c:n,localeTag:f,scheduleBadgeLabels:ce,categoryFilter:O,onCategoryFilterChange:e=>g({type:`patch`,patch:{templateCategoryFilter:e}}),onSelectTemplate:K}),(0,$.jsx)(Ot,{open:S,onDismiss:ne,detailJob:C,detailLoading:T,detailHistory:w,c:n,localeTag:f,scheduleBadgeLabels:ce,chatWorkingDirNotSet:r.workingDirectory.notSet,statusLabels:ae,onEdit:e=>{ne(),I.openForm(e)},onRunNow:e=>H(`run`,e.id),onToggle:(e,t)=>void J(e,t),onDelete:e=>H(`delete`,e.id)}),(0,$.jsx)(et,{open:E,onOpenChange:e=>g({type:`patch`,patch:{confirmOpen:e}}),action:B.current,c:n,onDismiss:U,onConfirm:ie})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(gn,{hasToken:c,c:n,loading:M.loading,runHistoryLoading:M.runHistoryLoading,onRefresh:M.refreshAll,onOpenTemplatePicker:re,onAddJob:()=>I.openForm()}),(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-app-main px-4 py-16 text-center text-sm text-fg-muted sm:px-8`,children:n.needToken})]})}function gn(e){let t=(0,Q.c)(14),{hasToken:n,c:r,loading:i,runHistoryLoading:a,onRefresh:o,onOpenTemplatePicker:s,onAddJob:c}=e,l=ge(vn),u=ge(_n),d;t[0]!==r||t[1]!==i||t[2]!==c||t[3]!==s||t[4]!==o||t[5]!==a?(d=(0,$.jsx)(Ht,{c:r,loading:i,runHistoryLoading:a,onRefresh:o,onOpenTemplatePicker:s,onAddJob:c}),t[0]=r,t[1]=i,t[2]=c,t[3]=s,t[4]=o,t[5]=a,t[6]=d):d=t[6];let f=d,p,m;return t[7]!==r.title||t[8]!==u||t[9]!==f||t[10]!==n||t[11]!==l?(p=()=>n?(l({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:r.title})}),end:f}),()=>u()):(u(),()=>u()),m=[r.title,u,f,n,l],t[7]=r.title,t[8]=u,t[9]=f,t[10]=n,t[11]=l,t[12]=p,t[13]=m):(p=t[12],m=t[13]),(0,Z.useLayoutEffect)(p,m),null}function _n(e){return e.clearPageHeader}function vn(e){return e.setPageHeader}export{hn as CronPage};