@poolzin/pool-bot 2026.1.26 → 2026.1.30

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 (1186) hide show
  1. package/CHANGELOG.md +76 -1116
  2. package/LICENSE +21 -0
  3. package/README.md +58 -37
  4. package/assets/chrome-extension/README.md +2 -2
  5. package/assets/chrome-extension/background.js +5 -5
  6. package/assets/chrome-extension/manifest.json +3 -3
  7. package/assets/chrome-extension/options.html +5 -6
  8. package/assets/chrome-extension/options.js +1 -1
  9. package/dist/acp/client.js +5 -5
  10. package/dist/acp/server.js +1 -1
  11. package/dist/acp/types.js +2 -2
  12. package/dist/agents/agent-paths.js +3 -3
  13. package/dist/agents/auth-health.js +2 -6
  14. package/dist/agents/auth-profiles/doctor.js +1 -1
  15. package/dist/agents/auth-profiles/external-cli-sync.js +5 -150
  16. package/dist/agents/auth-profiles/oauth.js +26 -7
  17. package/dist/agents/auth-profiles/paths.js +3 -3
  18. package/dist/agents/auth-profiles/store.js +5 -13
  19. package/dist/agents/bash-tools.shared.js +8 -1
  20. package/dist/agents/cli-backends.js +8 -0
  21. package/dist/agents/cli-runner/helpers.js +3 -3
  22. package/dist/agents/cli-runner.js +2 -2
  23. package/dist/agents/compaction.js +3 -0
  24. package/dist/agents/context.js +4 -4
  25. package/dist/agents/docs-path.js +3 -3
  26. package/dist/agents/identity.js +1 -1
  27. package/dist/agents/memory-search.js +7 -2
  28. package/dist/agents/minimax-vlm.js +1 -1
  29. package/dist/agents/model-auth.js +1 -1
  30. package/dist/agents/model-catalog.js +4 -4
  31. package/dist/agents/model-fallback.js +22 -0
  32. package/dist/agents/model-selection.js +1 -1
  33. package/dist/agents/models-config.js +3 -3
  34. package/dist/agents/models-config.providers.js +4 -4
  35. package/dist/agents/pi-embedded-helpers/openai.js +1 -1
  36. package/dist/agents/pi-embedded-runner/cache-ttl.js +1 -1
  37. package/dist/agents/pi-embedded-runner/compact.js +8 -8
  38. package/dist/agents/pi-embedded-runner/extensions.js +5 -0
  39. package/dist/agents/pi-embedded-runner/model.js +2 -2
  40. package/dist/agents/pi-embedded-runner/run/attempt.js +10 -6
  41. package/dist/agents/pi-embedded-runner/run.js +4 -4
  42. package/dist/agents/pi-embedded-runner/sandbox-info.js +1 -4
  43. package/dist/agents/pi-embedded-runner/utils.js +1 -1
  44. package/dist/agents/pi-embedded-utils.js +7 -1
  45. package/dist/agents/pi-extensions/compaction-safeguard-runtime.js +20 -0
  46. package/dist/agents/pi-extensions/compaction-safeguard.js +32 -3
  47. package/dist/agents/pi-tools.js +25 -15
  48. package/dist/agents/pi-tools.policy.js +34 -1
  49. package/dist/agents/pi-tools.read.js +2 -2
  50. package/dist/agents/{clawdbot-tools.js → poolbot-tools.js} +2 -5
  51. package/dist/agents/sandbox/browser.js +5 -7
  52. package/dist/agents/sandbox/config.js +0 -12
  53. package/dist/agents/sandbox/constants.js +8 -8
  54. package/dist/agents/sandbox/context.js +3 -3
  55. package/dist/agents/sandbox/docker.js +8 -8
  56. package/dist/agents/sandbox/runtime-status.js +1 -1
  57. package/dist/agents/session-transcript-repair.js +1 -1
  58. package/dist/agents/session-write-lock.js +68 -0
  59. package/dist/agents/skills/config.js +9 -8
  60. package/dist/agents/skills/env-overrides.js +1 -1
  61. package/dist/agents/skills/frontmatter.js +15 -14
  62. package/dist/agents/skills/workspace.js +7 -7
  63. package/dist/agents/skills-install.js +1 -1
  64. package/dist/agents/skills-status.js +12 -12
  65. package/dist/agents/subagent-registry.store.js +2 -2
  66. package/dist/agents/system-prompt.js +24 -35
  67. package/dist/agents/tool-images.js +1 -1
  68. package/dist/agents/tool-policy.js +8 -2
  69. package/dist/agents/tools/browser-tool.js +19 -79
  70. package/dist/agents/tools/browser-tool.schema.js +1 -2
  71. package/dist/agents/tools/cron-tool.js +44 -1
  72. package/dist/agents/tools/discord-actions-guild.js +5 -1
  73. package/dist/agents/tools/image-tool.js +2 -2
  74. package/dist/agents/tools/memory-tool.js +2 -1
  75. package/dist/agents/tools/message-tool.js +1 -0
  76. package/dist/agents/tools/sessions-send-helpers.js +17 -2
  77. package/dist/agents/tools/telegram-actions.js +93 -1
  78. package/dist/agents/tools/web-fetch.js +123 -103
  79. package/dist/agents/tools/web-search.js +7 -7
  80. package/dist/agents/workspace.js +36 -0
  81. package/dist/auto-reply/commands-registry.data.js +68 -3
  82. package/dist/auto-reply/commands-registry.js +14 -11
  83. package/dist/auto-reply/reply/agent-runner-execution.js +21 -3
  84. package/dist/auto-reply/reply/agent-runner-memory.js +5 -0
  85. package/dist/auto-reply/reply/bash-command.js +2 -2
  86. package/dist/auto-reply/reply/commands-context-report.js +2 -2
  87. package/dist/auto-reply/reply/commands-info.js +50 -5
  88. package/dist/auto-reply/reply/commands-session.js +4 -4
  89. package/dist/auto-reply/reply/commands-tts.js +61 -63
  90. package/dist/auto-reply/reply/directive-handling.shared.js +1 -1
  91. package/dist/auto-reply/reply/dispatch-from-config.js +65 -1
  92. package/dist/auto-reply/reply/followup-runner.js +5 -0
  93. package/dist/auto-reply/reply/get-reply-inline-actions.js +2 -2
  94. package/dist/auto-reply/reply/get-reply-run.js +4 -0
  95. package/dist/auto-reply/reply/groups.js +1 -1
  96. package/dist/auto-reply/reply/history.js +23 -0
  97. package/dist/auto-reply/reply/reply-elevated.js +1 -1
  98. package/dist/auto-reply/reply/session-updates.js +6 -1
  99. package/dist/auto-reply/reply/stage-sandbox-media.js +1 -1
  100. package/dist/auto-reply/status.js +142 -50
  101. package/dist/browser/bridge-server.js +1 -3
  102. package/dist/browser/client-actions-core.js +13 -7
  103. package/dist/browser/client-actions-observe.js +14 -8
  104. package/dist/browser/client-actions-state.js +21 -15
  105. package/dist/browser/client-fetch.js +74 -61
  106. package/dist/browser/client.js +19 -21
  107. package/dist/browser/config.js +13 -26
  108. package/dist/browser/constants.js +1 -1
  109. package/dist/browser/control-service.js +72 -0
  110. package/dist/browser/extension-relay.js +3 -3
  111. package/dist/browser/pw-session.js +41 -4
  112. package/dist/browser/pw-tools-core.downloads.js +1 -1
  113. package/dist/browser/pw-tools-core.interactions.js +5 -5
  114. package/dist/browser/pw-tools-core.responses.js +1 -1
  115. package/dist/browser/routes/agent.act.js +13 -0
  116. package/dist/browser/routes/agent.debug.js +1 -1
  117. package/dist/browser/routes/basic.js +0 -1
  118. package/dist/browser/routes/dispatcher.js +86 -0
  119. package/dist/browser/server-context.js +3 -3
  120. package/dist/browser/server.js +7 -9
  121. package/dist/build-info.json +3 -3
  122. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  123. package/dist/canvas-host/a2ui/a2ui.bundle.js +1620 -1618
  124. package/dist/canvas-host/a2ui/index.html +28 -28
  125. package/dist/canvas-host/a2ui.js +27 -21
  126. package/dist/canvas-host/server.js +66 -32
  127. package/dist/channels/plugins/actions/discord/handle-action.guild-admin.js +5 -1
  128. package/dist/channels/plugins/actions/telegram.js +60 -7
  129. package/dist/channels/plugins/catalog.js +6 -4
  130. package/dist/channels/plugins/group-mentions.js +48 -1
  131. package/dist/channels/plugins/helpers.js +2 -2
  132. package/dist/channels/plugins/message-action-names.js +1 -0
  133. package/dist/channels/plugins/onboarding/imessage.js +1 -1
  134. package/dist/channels/plugins/onboarding/signal.js +2 -2
  135. package/dist/channels/plugins/onboarding/slack.js +4 -4
  136. package/dist/channels/plugins/onboarding/telegram.js +17 -9
  137. package/dist/channels/plugins/onboarding/whatsapp.js +4 -4
  138. package/dist/channels/plugins/outbound/telegram.js +38 -0
  139. package/dist/channels/plugins/pairing-message.js +1 -1
  140. package/dist/channels/plugins/status-issues/bluebubbles.js +1 -1
  141. package/dist/channels/plugins/status-issues/whatsapp.js +2 -2
  142. package/dist/channels/registry.js +1 -1
  143. package/dist/cli/acp-cli.js +2 -2
  144. package/dist/cli/argv.js +14 -7
  145. package/dist/cli/banner.js +3 -1
  146. package/dist/cli/browser-cli-actions-input/register.element.js +72 -44
  147. package/dist/cli/browser-cli-actions-input/register.files-downloads.js +55 -35
  148. package/dist/cli/browser-cli-actions-input/register.form-wait-eval.js +41 -28
  149. package/dist/cli/browser-cli-actions-input/register.navigation.js +23 -14
  150. package/dist/cli/browser-cli-actions-input/shared.js +10 -3
  151. package/dist/cli/browser-cli-actions-observe.js +29 -21
  152. package/dist/cli/browser-cli-debug.js +49 -35
  153. package/dist/cli/browser-cli-examples.js +29 -29
  154. package/dist/cli/browser-cli-extension.js +8 -8
  155. package/dist/cli/browser-cli-inspect.js +23 -17
  156. package/dist/cli/browser-cli-manage.js +106 -56
  157. package/dist/cli/browser-cli-shared.js +34 -1
  158. package/dist/cli/browser-cli-state.cookies-storage.js +53 -39
  159. package/dist/cli/browser-cli-state.js +90 -64
  160. package/dist/cli/browser-cli.js +4 -5
  161. package/dist/cli/channels-cli.js +1 -1
  162. package/dist/cli/cli-name.js +26 -0
  163. package/dist/cli/command-format.js +11 -7
  164. package/dist/cli/config-cli.js +2 -2
  165. package/dist/cli/cron-cli/register.js +1 -1
  166. package/dist/cli/daemon-cli/install.js +1 -1
  167. package/dist/cli/daemon-cli/register.js +1 -1
  168. package/dist/cli/daemon-cli/shared.js +5 -3
  169. package/dist/cli/daemon-cli/status.print.js +6 -6
  170. package/dist/cli/directory-cli.js +1 -1
  171. package/dist/cli/dns-cli.js +7 -7
  172. package/dist/cli/docs-cli.js +2 -2
  173. package/dist/cli/exec-approvals-cli.js +2 -2
  174. package/dist/cli/gateway-cli/dev.js +4 -4
  175. package/dist/cli/gateway-cli/register.js +1 -1
  176. package/dist/cli/gateway-cli/run.js +11 -8
  177. package/dist/cli/gateway-cli/shared.js +4 -4
  178. package/dist/cli/hooks-cli.js +3 -3
  179. package/dist/cli/logs-cli.js +3 -3
  180. package/dist/cli/memory-cli.js +1 -1
  181. package/dist/cli/models-cli.js +2 -2
  182. package/dist/cli/node-cli/daemon.js +2 -2
  183. package/dist/cli/node-cli/register.js +1 -1
  184. package/dist/cli/nodes-camera.js +3 -1
  185. package/dist/cli/nodes-canvas.js +3 -1
  186. package/dist/cli/nodes-cli/register.canvas.js +1 -1
  187. package/dist/cli/nodes-cli/register.js +1 -1
  188. package/dist/cli/nodes-screen.js +1 -1
  189. package/dist/cli/pairing-cli.js +3 -3
  190. package/dist/cli/plugin-registry.js +2 -2
  191. package/dist/cli/plugins-cli.js +3 -3
  192. package/dist/cli/profile.js +2 -2
  193. package/dist/cli/program/command-registry.js +5 -0
  194. package/dist/cli/program/config-guard.js +1 -1
  195. package/dist/cli/program/help.js +15 -16
  196. package/dist/cli/program/message/register.send.js +2 -1
  197. package/dist/cli/program/preaction.js +4 -2
  198. package/dist/cli/program/register.agent.js +12 -12
  199. package/dist/cli/program/register.completion.js +355 -0
  200. package/dist/cli/program/register.configure.js +1 -1
  201. package/dist/cli/program/register.maintenance.js +4 -4
  202. package/dist/cli/program/register.message.js +5 -5
  203. package/dist/cli/program/register.onboard.js +5 -3
  204. package/dist/cli/program/register.setup.js +2 -2
  205. package/dist/cli/program/register.status-health-sessions.js +13 -13
  206. package/dist/cli/run-main.js +11 -4
  207. package/dist/cli/sandbox-cli.js +19 -19
  208. package/dist/cli/security-cli.js +18 -8
  209. package/dist/cli/skills-cli.js +3 -3
  210. package/dist/cli/system-cli.js +1 -1
  211. package/dist/cli/tagline.js +1 -1
  212. package/dist/cli/tui-cli.js +1 -1
  213. package/dist/cli/update-cli.js +58 -42
  214. package/dist/cli/webhooks-cli.js +6 -6
  215. package/dist/commands/agent-via-gateway.js +1 -1
  216. package/dist/commands/agent.js +2 -1
  217. package/dist/commands/agents.command-shared.js +1 -1
  218. package/dist/commands/agents.commands.add.js +2 -3
  219. package/dist/commands/agents.commands.list.js +1 -1
  220. package/dist/commands/auth-choice-options.js +4 -54
  221. package/dist/commands/auth-choice.apply.anthropic.js +6 -109
  222. package/dist/commands/auth-choice.apply.openai.js +1 -33
  223. package/dist/commands/auth-choice.apply.plugin-provider.js +2 -2
  224. package/dist/commands/channels/list.js +2 -2
  225. package/dist/commands/channels/shared.js +1 -1
  226. package/dist/commands/channels/status.js +1 -1
  227. package/dist/commands/chutes-oauth.js +1 -1
  228. package/dist/commands/configure.channels.js +4 -4
  229. package/dist/commands/configure.gateway-auth.js +1 -8
  230. package/dist/commands/configure.gateway.js +1 -10
  231. package/dist/commands/configure.wizard.js +11 -11
  232. package/dist/commands/daemon-install-helpers.js +1 -1
  233. package/dist/commands/dashboard.js +1 -1
  234. package/dist/commands/docs.js +5 -5
  235. package/dist/commands/doctor-auth.js +122 -3
  236. package/dist/commands/doctor-config-flow.js +7 -7
  237. package/dist/commands/doctor-format.js +2 -2
  238. package/dist/commands/doctor-gateway-daemon-flow.js +1 -1
  239. package/dist/commands/doctor-gateway-services.js +3 -3
  240. package/dist/commands/doctor-platform-notes.js +1 -1
  241. package/dist/commands/doctor-security.js +48 -1
  242. package/dist/commands/doctor-state-integrity.js +3 -3
  243. package/dist/commands/doctor-ui.js +2 -2
  244. package/dist/commands/doctor-update.js +4 -4
  245. package/dist/commands/doctor-workspace-status.js +2 -2
  246. package/dist/commands/doctor-workspace.js +4 -4
  247. package/dist/commands/doctor.js +13 -12
  248. package/dist/commands/gateway-status.js +2 -2
  249. package/dist/commands/models/auth.js +23 -22
  250. package/dist/commands/models/list.probe.js +2 -2
  251. package/dist/commands/models/list.registry.js +4 -4
  252. package/dist/commands/models/list.status-command.js +8 -9
  253. package/dist/commands/onboard-auth.credentials.js +2 -2
  254. package/dist/commands/onboard-channels.js +3 -3
  255. package/dist/commands/onboard-helpers.js +4 -4
  256. package/dist/commands/onboard-hooks.js +4 -4
  257. package/dist/commands/onboard-non-interactive/local/auth-choice.js +38 -34
  258. package/dist/commands/onboard-non-interactive/local/gateway-config.js +7 -4
  259. package/dist/commands/onboard-non-interactive/local.js +1 -1
  260. package/dist/commands/onboard-non-interactive/remote.js +1 -1
  261. package/dist/commands/onboard-non-interactive.js +1 -1
  262. package/dist/commands/onboard-remote.js +2 -2
  263. package/dist/commands/onboard-skills.js +2 -2
  264. package/dist/commands/onboard.js +25 -4
  265. package/dist/commands/onboarding/plugin-install.js +2 -2
  266. package/dist/commands/reset.js +3 -3
  267. package/dist/commands/sandbox-display.js +1 -1
  268. package/dist/commands/sandbox-explain.js +2 -2
  269. package/dist/commands/setup.js +2 -2
  270. package/dist/commands/signal-install.js +2 -2
  271. package/dist/commands/status-all/diagnosis.js +1 -1
  272. package/dist/commands/status-all/report-lines.js +1 -1
  273. package/dist/commands/status-all.js +3 -3
  274. package/dist/commands/status.command.js +9 -9
  275. package/dist/commands/status.update.js +3 -3
  276. package/dist/commands/uninstall.js +4 -4
  277. package/dist/compat/legacy-names.js +5 -0
  278. package/dist/config/config.js +1 -1
  279. package/dist/config/group-policy.js +69 -0
  280. package/dist/config/io.js +17 -5
  281. package/dist/config/legacy.migrations.part-3.js +3 -0
  282. package/dist/config/logging.js +3 -3
  283. package/dist/config/paths.js +44 -14
  284. package/dist/config/schema.js +23 -11
  285. package/dist/config/sessions/transcript.js +1 -1
  286. package/dist/config/types.js +1 -1
  287. package/dist/config/types.poolbot.js +1 -0
  288. package/dist/config/validation.js +2 -2
  289. package/dist/config/version.js +4 -4
  290. package/dist/config/zod-schema.agent-defaults.js +1 -0
  291. package/dist/config/zod-schema.agent-runtime.js +39 -7
  292. package/dist/config/zod-schema.hooks.js +2 -0
  293. package/dist/config/zod-schema.js +9 -3
  294. package/dist/config/zod-schema.providers-core.js +23 -0
  295. package/dist/config/zod-schema.providers-whatsapp.js +3 -0
  296. package/dist/control-ui/assets/index-CIRDm-Lu.css +1 -0
  297. package/dist/control-ui/assets/{index-Cl-Y9zqE.js → index-CmNMuoem.js} +620 -578
  298. package/dist/control-ui/assets/index-CmNMuoem.js.map +1 -0
  299. package/dist/control-ui/index.html +4 -4
  300. package/dist/cron/isolated-agent/run.js +38 -3
  301. package/dist/daemon/constants.js +16 -16
  302. package/dist/daemon/inspect.js +12 -12
  303. package/dist/daemon/paths.js +1 -1
  304. package/dist/daemon/program-args.js +1 -1
  305. package/dist/daemon/systemd-hints.js +1 -1
  306. package/dist/daemon/systemd-unit.js +1 -1
  307. package/dist/discord/monitor/listeners.js +25 -1
  308. package/dist/discord/monitor/native-command.js +7 -5
  309. package/dist/discord/monitor/presence-cache.js +38 -0
  310. package/dist/discord/monitor/provider.js +21 -7
  311. package/dist/entry.js +4 -4
  312. package/dist/gateway/auth.js +52 -19
  313. package/dist/gateway/hooks/index.js +53 -0
  314. package/dist/gateway/hooks/lifecycle-hooks-integration.js +256 -0
  315. package/dist/gateway/hooks/lifecycle-hooks.js +236 -0
  316. package/dist/gateway/hooks/progressive-disclosure-details.js +237 -0
  317. package/dist/gateway/hooks/progressive-disclosure-index.js +354 -0
  318. package/dist/gateway/hooks/progressive-disclosure-timeline.js +231 -0
  319. package/dist/gateway/hooks/progressive-disclosure-types.js +65 -0
  320. package/dist/gateway/hooks/progressive-disclosure.js +242 -0
  321. package/dist/gateway/hooks/tool-usage-capture.js +253 -0
  322. package/dist/gateway/hooks/tool-usage-storage.js +144 -0
  323. package/dist/gateway/hooks-mapping.js +18 -4
  324. package/dist/gateway/hooks.js +5 -7
  325. package/dist/gateway/http-utils.js +3 -5
  326. package/dist/gateway/net.js +1 -1
  327. package/dist/gateway/openai-http.js +3 -3
  328. package/dist/gateway/openresponses-http.js +4 -4
  329. package/dist/gateway/protocol/client-info.js +5 -5
  330. package/dist/gateway/protocol/schema/logs-chat.js +1 -1
  331. package/dist/gateway/server/health-state.js +3 -3
  332. package/dist/gateway/server/hooks.js +1 -0
  333. package/dist/gateway/server/ws-connection/message-handler.js +44 -35
  334. package/dist/gateway/server-browser.js +14 -3
  335. package/dist/gateway/server-chat.js +28 -2
  336. package/dist/gateway/server-discovery-runtime.js +25 -17
  337. package/dist/gateway/server-discovery.js +5 -5
  338. package/dist/gateway/server-http.js +9 -3
  339. package/dist/gateway/server-methods/agent.js +2 -0
  340. package/dist/gateway/server-methods/browser.js +204 -0
  341. package/dist/gateway/server-methods/chat.js +5 -0
  342. package/dist/gateway/server-methods/config.js +8 -8
  343. package/dist/gateway/server-methods/logs.js +1 -1
  344. package/dist/gateway/server-methods/nodes.js +2 -0
  345. package/dist/gateway/server-methods/skills.js +3 -3
  346. package/dist/gateway/server-methods/update.js +2 -2
  347. package/dist/gateway/server-methods-list.js +1 -0
  348. package/dist/gateway/server-methods.js +3 -0
  349. package/dist/gateway/server-plugins.js +2 -2
  350. package/dist/gateway/server-restart-sentinel.js +10 -5
  351. package/dist/gateway/server-runtime-config.js +5 -2
  352. package/dist/gateway/server.impl.js +11 -6
  353. package/dist/gateway/session-utils.fs.js +1 -1
  354. package/dist/gateway/session-utils.js +31 -11
  355. package/dist/gateway/test-helpers.mocks.js +5 -5
  356. package/dist/gateway/test-helpers.server.js +30 -11
  357. package/dist/gateway/tools-invoke-http.js +15 -8
  358. package/dist/hooks/bundled/boot-md/HOOK.md +3 -3
  359. package/dist/hooks/bundled/command-logger/HOOK.md +12 -12
  360. package/dist/hooks/bundled/command-logger/handler.js +1 -1
  361. package/dist/hooks/bundled/session-memory/HOOK.md +4 -4
  362. package/dist/hooks/bundled/session-memory/handler.js +2 -2
  363. package/dist/hooks/bundled/soul-evil/HOOK.md +5 -5
  364. package/dist/hooks/bundled-dir.js +1 -1
  365. package/dist/hooks/config.js +8 -7
  366. package/dist/hooks/frontmatter.js +16 -15
  367. package/dist/hooks/gmail-ops.js +4 -4
  368. package/dist/hooks/hooks-status.js +13 -13
  369. package/dist/hooks/install.js +8 -7
  370. package/dist/hooks/internal-hooks.js +1 -1
  371. package/dist/hooks/llm-slug-generator.js +1 -1
  372. package/dist/hooks/loader.js +3 -3
  373. package/dist/hooks/plugin-hooks.js +8 -8
  374. package/dist/hooks/workspace.js +10 -9
  375. package/dist/imessage/monitor/monitor-provider.js +16 -3
  376. package/dist/index.js +4 -4
  377. package/dist/infra/agent-events.js +3 -0
  378. package/dist/infra/bonjour-discovery.js +9 -9
  379. package/dist/infra/bonjour.js +19 -12
  380. package/dist/infra/device-identity.js +1 -1
  381. package/dist/infra/dotenv.js +1 -1
  382. package/dist/infra/exec-approvals.js +2 -2
  383. package/dist/infra/fs-safe.js +76 -0
  384. package/dist/infra/gateway-lock.js +1 -1
  385. package/dist/infra/heartbeat-visibility.js +14 -0
  386. package/dist/infra/heartbeat-wake.js +2 -2
  387. package/dist/infra/machine-name.js +1 -1
  388. package/dist/infra/net/ssrf.js +77 -1
  389. package/dist/infra/outbound/message-action-spec.js +1 -0
  390. package/dist/infra/outbound/targets.js +1 -1
  391. package/dist/infra/path-env.js +7 -7
  392. package/dist/infra/{clawdbot-root.js → poolbot-root.js} +3 -2
  393. package/dist/infra/ports-format.js +2 -2
  394. package/dist/infra/ports.js +2 -2
  395. package/dist/infra/provider-usage.auth.js +2 -4
  396. package/dist/infra/provider-usage.fetch.claude.js +1 -1
  397. package/dist/infra/provider-usage.fetch.minimax.js +1 -1
  398. package/dist/infra/restart-sentinel.js +1 -1
  399. package/dist/infra/restart.js +1 -1
  400. package/dist/infra/retry-policy.js +4 -1
  401. package/dist/infra/runtime-guard.js +2 -2
  402. package/dist/infra/shell-env.js +1 -1
  403. package/dist/infra/skills-remote.js +3 -3
  404. package/dist/infra/tailscale.js +63 -1
  405. package/dist/infra/tls/gateway.js +1 -1
  406. package/dist/infra/unhandled-rejections.js +89 -2
  407. package/dist/infra/update-check.js +2 -4
  408. package/dist/infra/update-global.js +5 -5
  409. package/dist/infra/update-runner.js +32 -8
  410. package/dist/infra/update-startup.js +3 -3
  411. package/dist/infra/warnings.js +1 -1
  412. package/dist/infra/widearea-dns.js +10 -10
  413. package/dist/line/monitor.js +1 -5
  414. package/dist/line/signature.js +11 -0
  415. package/dist/line/webhook.js +2 -6
  416. package/dist/logging/logger.js +4 -4
  417. package/dist/macos/gateway-daemon.js +2 -2
  418. package/dist/macos/relay.js +4 -4
  419. package/dist/media/host.js +1 -1
  420. package/dist/media/image-ops.js +1 -1
  421. package/dist/media/input-files.js +40 -32
  422. package/dist/media/server.js +39 -15
  423. package/dist/media/store.js +109 -53
  424. package/dist/media-understanding/attachments.js +1 -1
  425. package/dist/media-understanding/providers/image.js +2 -2
  426. package/dist/media-understanding/runner.js +33 -1
  427. package/dist/memory/batch-gemini.js +1 -1
  428. package/dist/memory/batch-openai.js +1 -1
  429. package/dist/memory/embeddings.js +1 -1
  430. package/dist/memory/index.js +5 -0
  431. package/dist/memory/manager.js +25 -2
  432. package/dist/node-host/runner.js +60 -56
  433. package/dist/pairing/pairing-messages.js +2 -2
  434. package/dist/plugin-sdk/index.js +1 -0
  435. package/dist/plugins/cli.js +2 -2
  436. package/dist/plugins/discovery.js +6 -5
  437. package/dist/plugins/install.js +8 -7
  438. package/dist/plugins/loader.js +10 -4
  439. package/dist/plugins/manifest-registry.js +2 -2
  440. package/dist/plugins/manifest.js +16 -1
  441. package/dist/plugins/providers.js +2 -2
  442. package/dist/plugins/registry.js +5 -5
  443. package/dist/plugins/runtime.js +1 -1
  444. package/dist/plugins/services.js +3 -3
  445. package/dist/plugins/status.js +2 -2
  446. package/dist/plugins/tools.js +2 -2
  447. package/dist/plugins/update.js +3 -3
  448. package/dist/providers/qwen-portal-oauth.js +1 -1
  449. package/dist/routing/session-key.js +17 -12
  450. package/dist/security/audit-extra.js +116 -69
  451. package/dist/security/audit-fs.js +78 -0
  452. package/dist/security/audit.js +121 -88
  453. package/dist/security/external-content.js +143 -0
  454. package/dist/security/fix.js +93 -8
  455. package/dist/security/windows-acl.js +162 -0
  456. package/dist/slack/monitor/media.js +32 -4
  457. package/dist/slack/monitor/message-handler/dispatch.js +2 -1
  458. package/dist/slack/monitor/slash.js +3 -3
  459. package/dist/slack/monitor.test-helpers.js +1 -1
  460. package/dist/telegram/api-logging.js +24 -0
  461. package/dist/telegram/bot/delivery.js +139 -22
  462. package/dist/telegram/bot-handlers.js +70 -8
  463. package/dist/telegram/bot-message-context.js +79 -21
  464. package/dist/telegram/bot-message-dispatch.js +64 -0
  465. package/dist/telegram/bot-native-commands.js +244 -94
  466. package/dist/telegram/bot.js +18 -2
  467. package/dist/telegram/fetch.js +25 -1
  468. package/dist/telegram/monitor.js +11 -3
  469. package/dist/telegram/network-config.js +23 -0
  470. package/dist/telegram/network-errors.js +103 -0
  471. package/dist/telegram/send.js +148 -4
  472. package/dist/telegram/sticker-cache.js +202 -0
  473. package/dist/telegram/webhook-set.js +13 -6
  474. package/dist/telegram/webhook.js +8 -3
  475. package/dist/terminal/links.js +1 -1
  476. package/dist/tts/tts.js +27 -22
  477. package/dist/tui/components/filterable-select-list.js +1 -1
  478. package/dist/tui/components/searchable-select-list.js +2 -1
  479. package/dist/tui/gateway-chat.js +1 -1
  480. package/dist/tui/tui.js +1 -1
  481. package/dist/utils.js +1 -1
  482. package/dist/version.js +1 -1
  483. package/dist/web/active-listener.js +1 -1
  484. package/dist/web/auth-store.js +1 -1
  485. package/dist/web/auto-reply/monitor/process-message.js +1 -1
  486. package/dist/web/auto-reply/monitor.js +1 -1
  487. package/dist/web/login.js +1 -1
  488. package/dist/web/session.js +2 -2
  489. package/dist/wizard/onboarding.finalize.js +24 -21
  490. package/dist/wizard/onboarding.gateway-config.js +1 -11
  491. package/dist/wizard/onboarding.js +22 -11
  492. package/docs/CNAME +1 -1
  493. package/docs/RELEASE_WORKFLOW.md +133 -0
  494. package/docs/RELEASE_WORKFOTS_COMPARISON.md +151 -0
  495. package/docs/WHATSAPP-HEARTBEAT-TROUBLESHOOTING.md +319 -0
  496. package/docs/WORKFOTS_OPTIMIZATION.md +138 -0
  497. package/docs/_config.yml +2 -2
  498. package/docs/_layouts/default.html +9 -9
  499. package/docs/adr/002-model-fallback-router.md +104 -0
  500. package/docs/assets/terminal.css +3 -0
  501. package/docs/assets/theme.js +1 -1
  502. package/docs/automation/auth-monitoring.md +7 -7
  503. package/docs/automation/cron-jobs.md +17 -17
  504. package/docs/automation/cron-vs-heartbeat.md +8 -8
  505. package/docs/automation/gmail-pubsub.md +23 -21
  506. package/docs/automation/poll.md +7 -7
  507. package/docs/automation/webhook.md +13 -8
  508. package/docs/bedrock.md +10 -10
  509. package/docs/brave-search.md +1 -1
  510. package/docs/broadcast-groups.md +4 -4
  511. package/docs/channels/bluebubbles.md +13 -12
  512. package/docs/channels/discord.md +21 -16
  513. package/docs/channels/googlechat.md +16 -16
  514. package/docs/channels/imessage.md +12 -12
  515. package/docs/channels/index.md +6 -4
  516. package/docs/channels/line.md +183 -0
  517. package/docs/channels/location.md +1 -1
  518. package/docs/channels/matrix.md +15 -15
  519. package/docs/channels/mattermost.md +8 -8
  520. package/docs/channels/msteams.md +30 -26
  521. package/docs/channels/nextcloud-talk.md +7 -7
  522. package/docs/channels/nostr.md +9 -9
  523. package/docs/channels/signal.md +9 -9
  524. package/docs/channels/slack.md +15 -13
  525. package/docs/channels/telegram.md +149 -20
  526. package/docs/channels/tlon.md +5 -5
  527. package/docs/channels/troubleshooting.md +2 -2
  528. package/docs/channels/twitch.md +366 -0
  529. package/docs/channels/whatsapp.md +25 -25
  530. package/docs/channels/zalo.md +8 -8
  531. package/docs/channels/zalouser.md +12 -12
  532. package/docs/cli/acp.md +24 -24
  533. package/docs/cli/agent.md +6 -6
  534. package/docs/cli/agents.md +9 -9
  535. package/docs/cli/approvals.md +14 -14
  536. package/docs/cli/browser.md +33 -35
  537. package/docs/cli/channels.md +21 -21
  538. package/docs/cli/config.md +15 -15
  539. package/docs/cli/configure.md +6 -6
  540. package/docs/cli/cron.md +5 -5
  541. package/docs/cli/dashboard.md +4 -4
  542. package/docs/cli/devices.md +13 -13
  543. package/docs/cli/directory.md +12 -12
  544. package/docs/cli/dns.md +5 -5
  545. package/docs/cli/docs.md +5 -5
  546. package/docs/cli/doctor.md +6 -6
  547. package/docs/cli/gateway.md +24 -24
  548. package/docs/cli/health.md +5 -5
  549. package/docs/cli/hooks.md +34 -34
  550. package/docs/cli/index.md +46 -52
  551. package/docs/cli/logs.md +6 -6
  552. package/docs/cli/memory.md +11 -11
  553. package/docs/cli/message.md +11 -11
  554. package/docs/cli/models.md +17 -17
  555. package/docs/cli/node.md +14 -14
  556. package/docs/cli/nodes.md +14 -14
  557. package/docs/cli/onboard.md +7 -6
  558. package/docs/cli/pairing.md +4 -4
  559. package/docs/cli/plugins.md +16 -16
  560. package/docs/cli/reset.md +5 -5
  561. package/docs/cli/sandbox.md +28 -28
  562. package/docs/cli/security.md +5 -5
  563. package/docs/cli/sessions.md +5 -5
  564. package/docs/cli/setup.md +6 -6
  565. package/docs/cli/skills.md +6 -6
  566. package/docs/cli/status.md +7 -7
  567. package/docs/cli/system.md +6 -6
  568. package/docs/cli/tui.md +5 -5
  569. package/docs/cli/uninstall.md +5 -5
  570. package/docs/cli/update.md +20 -20
  571. package/docs/cli/voicecall.md +9 -9
  572. package/docs/cli/webhooks.md +5 -5
  573. package/docs/concepts/agent-loop.md +5 -5
  574. package/docs/concepts/agent-workspace.md +20 -20
  575. package/docs/concepts/agent.md +12 -12
  576. package/docs/concepts/architecture.md +1 -1
  577. package/docs/concepts/channel-routing.md +4 -4
  578. package/docs/concepts/compaction.md +5 -5
  579. package/docs/concepts/context.md +6 -6
  580. package/docs/concepts/group-messages.md +6 -6
  581. package/docs/concepts/groups.md +41 -5
  582. package/docs/concepts/markdown-formatting.md +3 -3
  583. package/docs/concepts/memory.md +14 -14
  584. package/docs/concepts/messages.md +4 -4
  585. package/docs/concepts/model-failover.md +14 -14
  586. package/docs/concepts/model-providers.md +22 -22
  587. package/docs/concepts/models.md +27 -27
  588. package/docs/concepts/multi-agent.md +18 -18
  589. package/docs/concepts/oauth.md +31 -58
  590. package/docs/concepts/presence.md +2 -2
  591. package/docs/concepts/retry.md +1 -1
  592. package/docs/concepts/session-pruning.md +1 -1
  593. package/docs/concepts/session-tool.md +4 -4
  594. package/docs/concepts/session.md +14 -14
  595. package/docs/concepts/streaming.md +3 -3
  596. package/docs/concepts/system-prompt.md +11 -11
  597. package/docs/concepts/timezone.md +2 -2
  598. package/docs/concepts/typebox.md +2 -2
  599. package/docs/concepts/typing-indicators.md +2 -2
  600. package/docs/concepts/usage-tracking.md +3 -3
  601. package/docs/date-time.md +2 -2
  602. package/docs/debug/node-issue.md +4 -4
  603. package/docs/debugging.md +14 -14
  604. package/docs/diagnostics/flags.md +5 -5
  605. package/docs/docs.json +37 -7
  606. package/docs/environment.md +4 -4
  607. package/docs/experiments/plans/cron-add-hardening.md +1 -1
  608. package/docs/experiments/plans/openresponses-gateway.md +2 -2
  609. package/docs/experiments/research/memory.md +6 -6
  610. package/docs/gateway/authentication.md +33 -57
  611. package/docs/gateway/background-process.md +1 -1
  612. package/docs/gateway/bonjour.md +21 -21
  613. package/docs/gateway/bridge-protocol.md +2 -2
  614. package/docs/gateway/cli-backends.md +13 -12
  615. package/docs/gateway/configuration-examples.md +14 -14
  616. package/docs/gateway/configuration.md +145 -132
  617. package/docs/gateway/discovery.md +6 -6
  618. package/docs/gateway/doctor.md +26 -26
  619. package/docs/gateway/gateway-lock.md +1 -1
  620. package/docs/gateway/health.md +11 -11
  621. package/docs/gateway/heartbeat.md +5 -5
  622. package/docs/gateway/index.md +56 -56
  623. package/docs/gateway/local-models.md +2 -2
  624. package/docs/gateway/logging.md +8 -8
  625. package/docs/gateway/multiple-gateways.md +23 -23
  626. package/docs/gateway/openai-http-api.md +10 -10
  627. package/docs/gateway/openresponses-http-api.md +10 -10
  628. package/docs/gateway/pairing.md +8 -8
  629. package/docs/gateway/protocol.md +5 -4
  630. package/docs/gateway/remote-gateway-readme.md +13 -13
  631. package/docs/gateway/remote.md +4 -4
  632. package/docs/gateway/sandbox-vs-tool-policy-vs-elevated.md +10 -7
  633. package/docs/gateway/sandboxing.md +8 -6
  634. package/docs/gateway/security/formal-verification.md +107 -0
  635. package/docs/gateway/{security.md → security/index.md} +151 -71
  636. package/docs/gateway/tailscale.md +16 -35
  637. package/docs/gateway/tools-invoke-http-api.md +3 -3
  638. package/docs/gateway/troubleshooting.md +108 -113
  639. package/docs/help/faq.md +326 -335
  640. package/docs/help/troubleshooting.md +15 -15
  641. package/docs/hooks/soul-evil.md +2 -2
  642. package/docs/hooks.md +60 -60
  643. package/docs/index.md +35 -35
  644. package/docs/install/ansible.md +35 -35
  645. package/docs/install/development-channels.md +10 -10
  646. package/docs/install/docker.md +31 -31
  647. package/docs/install/index.md +28 -27
  648. package/docs/install/installer.md +21 -21
  649. package/docs/install/migrating.md +190 -0
  650. package/docs/install/nix.md +17 -17
  651. package/docs/install/node.md +7 -6
  652. package/docs/install/uninstall.md +29 -29
  653. package/docs/install/updating.md +50 -49
  654. package/docs/logging.md +58 -58
  655. package/docs/multi-agent-sandbox-tools.md +7 -7
  656. package/docs/network.md +1 -1
  657. package/docs/nodes/audio.md +2 -2
  658. package/docs/nodes/camera.md +18 -18
  659. package/docs/nodes/images.md +4 -4
  660. package/docs/nodes/index.md +55 -55
  661. package/docs/nodes/location-command.md +2 -2
  662. package/docs/nodes/media-understanding.md +5 -5
  663. package/docs/nodes/talk.md +1 -1
  664. package/docs/nodes/voicewake.md +2 -2
  665. package/docs/northflank.mdx +53 -0
  666. package/docs/perplexity.md +2 -2
  667. package/docs/platforms/android.md +13 -13
  668. package/docs/platforms/digitalocean.md +243 -0
  669. package/docs/platforms/exe-dev.md +23 -23
  670. package/docs/platforms/fly.md +129 -18
  671. package/docs/platforms/gcp.md +498 -0
  672. package/docs/platforms/hetzner.md +30 -30
  673. package/docs/platforms/index.md +9 -9
  674. package/docs/platforms/ios.md +13 -13
  675. package/docs/platforms/linux.md +11 -11
  676. package/docs/platforms/mac/bundled-gateway.md +14 -14
  677. package/docs/platforms/mac/canvas.md +14 -14
  678. package/docs/platforms/mac/child-process.md +9 -9
  679. package/docs/platforms/mac/dev-setup.md +11 -11
  680. package/docs/platforms/mac/health.md +2 -2
  681. package/docs/platforms/mac/icon.md +1 -1
  682. package/docs/platforms/mac/logging.md +7 -7
  683. package/docs/platforms/mac/menu-bar.md +1 -1
  684. package/docs/platforms/mac/peekaboo.md +9 -9
  685. package/docs/platforms/mac/permissions.md +3 -3
  686. package/docs/platforms/mac/release.md +20 -20
  687. package/docs/platforms/mac/remote.md +14 -14
  688. package/docs/platforms/mac/signing.md +7 -7
  689. package/docs/platforms/mac/skills.md +4 -4
  690. package/docs/platforms/mac/voice-overlay.md +2 -2
  691. package/docs/platforms/mac/webchat.md +2 -2
  692. package/docs/platforms/mac/xpc.md +4 -4
  693. package/docs/platforms/macos-vm.md +27 -27
  694. package/docs/platforms/macos.md +20 -20
  695. package/docs/platforms/oracle.md +291 -0
  696. package/docs/platforms/raspberry-pi.md +354 -0
  697. package/docs/platforms/windows.md +11 -11
  698. package/docs/plugin.md +64 -64
  699. package/docs/plugins/agent-tools.md +1 -1
  700. package/docs/plugins/manifest.md +4 -4
  701. package/docs/plugins/voice-call.md +15 -12
  702. package/docs/plugins/zalouser.md +9 -9
  703. package/docs/prose.md +9 -9
  704. package/docs/providers/anthropic.md +23 -27
  705. package/docs/providers/claude-max-api-proxy.md +145 -0
  706. package/docs/providers/deepgram.md +2 -2
  707. package/docs/providers/github-copilot.md +11 -11
  708. package/docs/providers/glm.md +4 -4
  709. package/docs/providers/index.md +7 -3
  710. package/docs/providers/minimax.md +9 -9
  711. package/docs/providers/models.md +3 -3
  712. package/docs/providers/moonshot.md +2 -2
  713. package/docs/providers/ollama.md +11 -11
  714. package/docs/providers/openai.md +9 -13
  715. package/docs/providers/opencode.md +3 -3
  716. package/docs/providers/openrouter.md +3 -3
  717. package/docs/providers/qwen.md +6 -6
  718. package/docs/providers/synthetic.md +4 -4
  719. package/docs/providers/venice.md +21 -21
  720. package/docs/providers/vercel-ai-gateway.md +5 -4
  721. package/docs/providers/zai.md +5 -5
  722. package/docs/railway.mdx +5 -5
  723. package/docs/refactor/exec-host.md +5 -5
  724. package/docs/refactor/plugin-sdk.md +12 -12
  725. package/docs/refactor/strict-config.md +11 -11
  726. package/docs/reference/AGENTS.default.md +10 -10
  727. package/docs/reference/RELEASING.md +27 -27
  728. package/docs/reference/api-usage-costs.md +6 -6
  729. package/docs/reference/device-models.md +7 -7
  730. package/docs/reference/rpc.md +3 -3
  731. package/docs/reference/session-management-compaction.md +19 -19
  732. package/docs/reference/templates/AGENTS.dev.md +1 -1
  733. package/docs/reference/templates/BOOT.md +1 -1
  734. package/docs/reference/templates/TOOLS.dev.md +1 -1
  735. package/docs/reference/templates/USER.dev.md +2 -2
  736. package/docs/reference/test.md +2 -2
  737. package/docs/reference/transcript-hygiene.md +1 -1
  738. package/docs/render.mdx +158 -0
  739. package/docs/scripts.md +1 -1
  740. package/docs/security/formal-verification.md +107 -0
  741. package/docs/start/getting-started.md +31 -25
  742. package/docs/start/hubs.md +2 -2
  743. package/docs/start/lore.md +74 -38
  744. package/docs/start/onboarding.md +7 -7
  745. package/docs/start/pairing.md +10 -10
  746. package/docs/start/{clawd.md → poolbot.md} +29 -29
  747. package/docs/start/setup.md +30 -17
  748. package/docs/start/showcase.md +32 -32
  749. package/docs/start/wizard.md +29 -26
  750. package/docs/testing.md +12 -12
  751. package/docs/token-use.md +7 -7
  752. package/docs/tools/agent-send.md +10 -10
  753. package/docs/tools/browser-linux-troubleshooting.md +10 -10
  754. package/docs/tools/browser-login.md +4 -4
  755. package/docs/tools/browser.md +135 -241
  756. package/docs/tools/chrome-extension.md +31 -48
  757. package/docs/tools/creating-skills.md +4 -4
  758. package/docs/tools/elevated.md +1 -0
  759. package/docs/tools/exec-approvals.md +8 -5
  760. package/docs/tools/exec.md +15 -4
  761. package/docs/tools/firecrawl.md +2 -2
  762. package/docs/tools/index.md +18 -15
  763. package/docs/tools/llm-task.md +1 -1
  764. package/docs/tools/lobster.md +23 -11
  765. package/docs/tools/{clawdhub.md → poolhub.md} +7 -7
  766. package/docs/tools/skills-config.md +2 -2
  767. package/docs/tools/skills.md +39 -31
  768. package/docs/tools/slash-commands.md +10 -8
  769. package/docs/tools/web.md +8 -8
  770. package/docs/tts.md +11 -11
  771. package/docs/tui.md +7 -7
  772. package/docs/vps.md +6 -1
  773. package/docs/web/control-ui.md +13 -12
  774. package/docs/web/dashboard.md +8 -4
  775. package/docs/web/index.md +6 -5
  776. package/docs/web/webchat.md +1 -1
  777. package/extensions/bluebubbles/index.ts +3 -3
  778. package/extensions/bluebubbles/package.json +5 -5
  779. package/extensions/bluebubbles/src/accounts.ts +9 -9
  780. package/extensions/bluebubbles/src/actions.test.ts +22 -22
  781. package/extensions/bluebubbles/src/actions.ts +6 -6
  782. package/extensions/bluebubbles/src/attachments.ts +2 -2
  783. package/extensions/bluebubbles/src/channel.ts +17 -17
  784. package/extensions/bluebubbles/src/chat.ts +2 -2
  785. package/extensions/bluebubbles/src/config-schema.ts +1 -1
  786. package/extensions/bluebubbles/src/media-send.ts +2 -2
  787. package/extensions/bluebubbles/src/monitor.test.ts +56 -50
  788. package/extensions/bluebubbles/src/monitor.ts +181 -6
  789. package/extensions/bluebubbles/src/onboarding.ts +9 -9
  790. package/extensions/bluebubbles/src/reactions.ts +2 -2
  791. package/extensions/bluebubbles/src/runtime.ts +1 -1
  792. package/extensions/bluebubbles/src/send.ts +2 -2
  793. package/extensions/copilot-proxy/README.md +2 -2
  794. package/extensions/copilot-proxy/index.ts +1 -1
  795. package/extensions/copilot-proxy/package.json +4 -4
  796. package/extensions/diagnostics-otel/index.ts +3 -3
  797. package/extensions/diagnostics-otel/package.json +4 -4
  798. package/extensions/diagnostics-otel/src/service.test.ts +15 -15
  799. package/extensions/diagnostics-otel/src/service.ts +85 -85
  800. package/extensions/discord/index.ts +3 -3
  801. package/extensions/discord/package.json +4 -4
  802. package/extensions/discord/src/channel.ts +1 -1
  803. package/extensions/discord/src/runtime.ts +1 -1
  804. package/extensions/google-antigravity-auth/README.md +2 -2
  805. package/extensions/google-antigravity-auth/index.ts +9 -2
  806. package/extensions/google-antigravity-auth/package.json +4 -4
  807. package/extensions/google-gemini-cli-auth/README.md +2 -2
  808. package/extensions/google-gemini-cli-auth/index.ts +1 -1
  809. package/extensions/google-gemini-cli-auth/oauth.ts +2 -2
  810. package/extensions/google-gemini-cli-auth/package.json +4 -4
  811. package/extensions/googlechat/index.ts +4 -4
  812. package/extensions/googlechat/node_modules/.bin/poolbot +21 -0
  813. package/extensions/googlechat/package.json +7 -7
  814. package/extensions/googlechat/src/accounts.ts +9 -9
  815. package/extensions/googlechat/src/actions.ts +8 -8
  816. package/extensions/googlechat/src/api.ts +1 -1
  817. package/extensions/googlechat/src/channel.ts +23 -23
  818. package/extensions/googlechat/src/monitor.ts +9 -9
  819. package/extensions/googlechat/src/onboarding.ts +11 -11
  820. package/extensions/googlechat/src/runtime.ts +1 -1
  821. package/extensions/googlechat/src/types.config.ts +1 -1
  822. package/extensions/imessage/index.ts +3 -3
  823. package/extensions/imessage/package.json +4 -4
  824. package/extensions/imessage/src/channel.ts +1 -1
  825. package/extensions/imessage/src/runtime.ts +1 -1
  826. package/extensions/line/index.ts +3 -3
  827. package/extensions/line/node_modules/.bin/poolbot +21 -0
  828. package/extensions/line/package.json +6 -6
  829. package/extensions/line/src/card-command.ts +3 -3
  830. package/extensions/line/src/channel.logout.test.ts +4 -4
  831. package/extensions/line/src/channel.sendPayload.test.ts +8 -8
  832. package/extensions/line/src/channel.ts +5 -5
  833. package/extensions/line/src/runtime.ts +1 -1
  834. package/extensions/llm-task/README.md +1 -1
  835. package/extensions/llm-task/index.ts +2 -2
  836. package/extensions/llm-task/package.json +4 -4
  837. package/extensions/llm-task/src/llm-task-tool.ts +5 -5
  838. package/extensions/lobster/index.ts +2 -2
  839. package/extensions/lobster/package.json +3 -3
  840. package/extensions/lobster/src/lobster-tool.test.ts +26 -6
  841. package/extensions/lobster/src/lobster-tool.ts +24 -6
  842. package/extensions/matrix/CHANGELOG.md +9 -9
  843. package/extensions/matrix/index.ts +3 -3
  844. package/extensions/matrix/node_modules/.bin/markdown-it +0 -0
  845. package/extensions/matrix/node_modules/.bin/poolbot +21 -0
  846. package/extensions/matrix/package.json +7 -7
  847. package/extensions/matrix/src/actions.ts +1 -1
  848. package/extensions/matrix/src/channel.directory.test.ts +1 -1
  849. package/extensions/matrix/src/channel.ts +1 -1
  850. package/extensions/matrix/src/config-schema.ts +1 -1
  851. package/extensions/matrix/src/directory-live.ts +1 -1
  852. package/extensions/matrix/src/group-mentions.ts +1 -1
  853. package/extensions/matrix/src/matrix/accounts.ts +1 -1
  854. package/extensions/matrix/src/matrix/actions/messages.ts +1 -1
  855. package/extensions/matrix/src/matrix/actions/reactions.ts +1 -1
  856. package/extensions/matrix/src/matrix/actions/room.ts +3 -3
  857. package/extensions/matrix/src/matrix/actions/summary.ts +1 -1
  858. package/extensions/matrix/src/matrix/actions/types.ts +1 -1
  859. package/extensions/matrix/src/matrix/active-client.ts +1 -1
  860. package/extensions/matrix/src/matrix/client/config.ts +2 -2
  861. package/extensions/matrix/src/matrix/client/create-client.ts +2 -2
  862. package/extensions/matrix/src/matrix/client/logging.ts +1 -1
  863. package/extensions/matrix/src/matrix/client/shared.ts +3 -3
  864. package/extensions/matrix/src/matrix/deps.ts +5 -5
  865. package/extensions/matrix/src/matrix/monitor/allowlist.ts +1 -1
  866. package/extensions/matrix/src/matrix/monitor/auto-join.ts +3 -3
  867. package/extensions/matrix/src/matrix/monitor/direct.ts +1 -1
  868. package/extensions/matrix/src/matrix/monitor/events.ts +2 -2
  869. package/extensions/matrix/src/matrix/monitor/handler.ts +8 -8
  870. package/extensions/matrix/src/matrix/monitor/index.ts +2 -2
  871. package/extensions/matrix/src/matrix/monitor/location.ts +2 -2
  872. package/extensions/matrix/src/matrix/monitor/media.test.ts +3 -3
  873. package/extensions/matrix/src/matrix/monitor/media.ts +3 -3
  874. package/extensions/matrix/src/matrix/monitor/replies.ts +2 -2
  875. package/extensions/matrix/src/matrix/monitor/room-info.ts +1 -1
  876. package/extensions/matrix/src/matrix/monitor/rooms.ts +1 -1
  877. package/extensions/matrix/src/matrix/monitor/threads.ts +1 -1
  878. package/extensions/matrix/src/matrix/monitor/types.ts +1 -1
  879. package/extensions/matrix/src/matrix/poll-types.ts +1 -1
  880. package/extensions/matrix/src/matrix/probe.ts +1 -1
  881. package/extensions/matrix/src/matrix/send/client.ts +2 -2
  882. package/extensions/matrix/src/matrix/send/media.ts +1 -1
  883. package/extensions/matrix/src/matrix/send/targets.test.ts +1 -1
  884. package/extensions/matrix/src/matrix/send/targets.ts +1 -1
  885. package/extensions/matrix/src/matrix/send/types.ts +2 -2
  886. package/extensions/matrix/src/matrix/send.test.ts +3 -3
  887. package/extensions/matrix/src/matrix/send.ts +4 -4
  888. package/extensions/matrix/src/onboarding.ts +3 -3
  889. package/extensions/matrix/src/outbound.ts +1 -1
  890. package/extensions/matrix/src/resolve-targets.ts +1 -1
  891. package/extensions/matrix/src/runtime.ts +1 -1
  892. package/extensions/matrix/src/tool-actions.ts +1 -1
  893. package/extensions/matrix/src/types.ts +1 -1
  894. package/extensions/mattermost/index.ts +3 -3
  895. package/extensions/mattermost/package.json +5 -5
  896. package/extensions/mattermost/src/channel.ts +1 -1
  897. package/extensions/mattermost/src/config-schema.ts +1 -1
  898. package/extensions/mattermost/src/group-mentions.ts +1 -1
  899. package/extensions/mattermost/src/mattermost/accounts.ts +9 -9
  900. package/extensions/mattermost/src/mattermost/monitor-helpers.ts +5 -5
  901. package/extensions/mattermost/src/mattermost/monitor.ts +4 -4
  902. package/extensions/mattermost/src/onboarding-helpers.ts +4 -4
  903. package/extensions/mattermost/src/onboarding.ts +4 -4
  904. package/extensions/mattermost/src/runtime.ts +1 -1
  905. package/extensions/mattermost/src/types.ts +1 -1
  906. package/extensions/memory-core/index.ts +3 -3
  907. package/extensions/memory-core/node_modules/.bin/poolbot +21 -0
  908. package/extensions/memory-core/package.json +5 -5
  909. package/extensions/memory-lancedb/config.ts +2 -2
  910. package/extensions/memory-lancedb/index.test.ts +2 -2
  911. package/extensions/memory-lancedb/index.ts +4 -4
  912. package/extensions/memory-lancedb/node_modules/.bin/openai +0 -0
  913. package/extensions/memory-lancedb/package.json +4 -4
  914. package/extensions/memory-lancedb/{clawdbot.plugin.json → poolbot.plugin.json} +1 -1
  915. package/extensions/msteams/CHANGELOG.md +7 -7
  916. package/extensions/msteams/index.ts +3 -3
  917. package/extensions/msteams/node_modules/.bin/poolbot +21 -0
  918. package/extensions/msteams/package.json +6 -6
  919. package/extensions/msteams/src/attachments.test.ts +1 -1
  920. package/extensions/msteams/src/channel.directory.test.ts +2 -2
  921. package/extensions/msteams/src/channel.ts +3 -3
  922. package/extensions/msteams/src/conversation-store-fs.test.ts +3 -3
  923. package/extensions/msteams/src/directory-live.ts +1 -1
  924. package/extensions/msteams/src/graph-upload.ts +4 -4
  925. package/extensions/msteams/src/media-helpers.ts +1 -1
  926. package/extensions/msteams/src/messenger.test.ts +1 -1
  927. package/extensions/msteams/src/messenger.ts +1 -1
  928. package/extensions/msteams/src/monitor-handler/message-handler.ts +1 -1
  929. package/extensions/msteams/src/monitor-handler.ts +2 -2
  930. package/extensions/msteams/src/monitor.ts +3 -3
  931. package/extensions/msteams/src/onboarding.ts +11 -11
  932. package/extensions/msteams/src/outbound.ts +1 -1
  933. package/extensions/msteams/src/policy.test.ts +1 -1
  934. package/extensions/msteams/src/policy.ts +50 -5
  935. package/extensions/msteams/src/polls-store.test.ts +1 -1
  936. package/extensions/msteams/src/polls.test.ts +4 -4
  937. package/extensions/msteams/src/polls.ts +8 -8
  938. package/extensions/msteams/src/probe.test.ts +1 -1
  939. package/extensions/msteams/src/probe.ts +1 -1
  940. package/extensions/msteams/src/reply-dispatcher.ts +36 -36
  941. package/extensions/msteams/src/runtime.ts +1 -1
  942. package/extensions/msteams/src/send-context.ts +2 -2
  943. package/extensions/msteams/src/send.ts +5 -5
  944. package/extensions/msteams/src/token.ts +1 -1
  945. package/extensions/nextcloud-talk/index.ts +3 -3
  946. package/extensions/nextcloud-talk/package.json +5 -5
  947. package/extensions/nextcloud-talk/src/accounts.ts +1 -1
  948. package/extensions/nextcloud-talk/src/channel.ts +8 -8
  949. package/extensions/nextcloud-talk/src/config-schema.ts +1 -1
  950. package/extensions/nextcloud-talk/src/inbound.ts +8 -8
  951. package/extensions/nextcloud-talk/src/monitor.ts +1 -1
  952. package/extensions/nextcloud-talk/src/onboarding.ts +2 -2
  953. package/extensions/nextcloud-talk/src/policy.ts +2 -2
  954. package/extensions/nextcloud-talk/src/room-info.ts +1 -1
  955. package/extensions/nextcloud-talk/src/runtime.ts +1 -1
  956. package/extensions/nextcloud-talk/src/types.ts +1 -1
  957. package/extensions/nostr/CHANGELOG.md +4 -4
  958. package/extensions/nostr/README.md +3 -3
  959. package/extensions/nostr/index.ts +6 -6
  960. package/extensions/nostr/node_modules/.bin/poolbot +21 -0
  961. package/extensions/nostr/package.json +6 -6
  962. package/extensions/nostr/src/channel.ts +2 -2
  963. package/extensions/nostr/src/config-schema.ts +1 -1
  964. package/extensions/nostr/src/nostr-state-store.test.ts +3 -3
  965. package/extensions/nostr/src/runtime.ts +1 -1
  966. package/extensions/nostr/src/types.ts +4 -4
  967. package/extensions/open-prose/index.ts +2 -2
  968. package/extensions/open-prose/package.json +3 -3
  969. package/extensions/open-prose/skills/prose/SKILL.md +5 -5
  970. package/extensions/open-prose/skills/prose/prose.md +4 -4
  971. package/extensions/qwen-portal-auth/README.md +2 -2
  972. package/extensions/qwen-portal-auth/index.ts +1 -1
  973. package/extensions/signal/index.ts +3 -3
  974. package/extensions/signal/package.json +4 -4
  975. package/extensions/signal/src/channel.ts +1 -1
  976. package/extensions/signal/src/runtime.ts +1 -1
  977. package/extensions/slack/index.ts +3 -3
  978. package/extensions/slack/package.json +4 -4
  979. package/extensions/slack/src/channel.ts +1 -1
  980. package/extensions/slack/src/runtime.ts +1 -1
  981. package/extensions/telegram/index.ts +3 -3
  982. package/extensions/telegram/package.json +4 -4
  983. package/extensions/telegram/src/channel.ts +3 -3
  984. package/extensions/telegram/src/runtime.ts +1 -1
  985. package/extensions/tlon/README.md +1 -1
  986. package/extensions/tlon/index.ts +3 -3
  987. package/extensions/tlon/package.json +5 -5
  988. package/extensions/tlon/src/channel.ts +15 -15
  989. package/extensions/tlon/src/config-schema.ts +1 -1
  990. package/extensions/tlon/src/monitor/discovery.ts +1 -1
  991. package/extensions/tlon/src/monitor/history.ts +1 -1
  992. package/extensions/tlon/src/monitor/index.ts +3 -3
  993. package/extensions/tlon/src/onboarding.ts +4 -4
  994. package/extensions/tlon/src/runtime.ts +1 -1
  995. package/extensions/tlon/src/types.ts +3 -3
  996. package/extensions/tlon/src/urbit/send.ts +19 -6
  997. package/extensions/twitch/CHANGELOG.md +21 -0
  998. package/extensions/twitch/README.md +89 -0
  999. package/extensions/twitch/index.ts +20 -0
  1000. package/extensions/twitch/node_modules/.bin/poolbot +21 -0
  1001. package/extensions/twitch/package.json +20 -0
  1002. package/extensions/twitch/poolbot.plugin.json +9 -0
  1003. package/extensions/twitch/src/access-control.test.ts +489 -0
  1004. package/extensions/twitch/src/access-control.ts +154 -0
  1005. package/extensions/twitch/src/actions.ts +173 -0
  1006. package/extensions/twitch/src/client-manager-registry.ts +115 -0
  1007. package/extensions/twitch/src/config-schema.ts +82 -0
  1008. package/extensions/twitch/src/config.test.ts +88 -0
  1009. package/extensions/twitch/src/config.ts +116 -0
  1010. package/extensions/twitch/src/monitor.ts +257 -0
  1011. package/extensions/twitch/src/onboarding.test.ts +311 -0
  1012. package/extensions/twitch/src/onboarding.ts +411 -0
  1013. package/extensions/twitch/src/outbound.test.ts +373 -0
  1014. package/extensions/twitch/src/outbound.ts +186 -0
  1015. package/extensions/twitch/src/plugin.test.ts +39 -0
  1016. package/extensions/twitch/src/plugin.ts +274 -0
  1017. package/extensions/twitch/src/probe.test.ts +198 -0
  1018. package/extensions/twitch/src/probe.ts +118 -0
  1019. package/extensions/twitch/src/resolver.ts +137 -0
  1020. package/extensions/twitch/src/runtime.ts +14 -0
  1021. package/extensions/twitch/src/send.test.ts +289 -0
  1022. package/extensions/twitch/src/send.ts +136 -0
  1023. package/extensions/twitch/src/status.test.ts +270 -0
  1024. package/extensions/twitch/src/status.ts +176 -0
  1025. package/extensions/twitch/src/token.test.ts +171 -0
  1026. package/extensions/twitch/src/token.ts +87 -0
  1027. package/extensions/twitch/src/twitch-client.test.ts +574 -0
  1028. package/extensions/twitch/src/twitch-client.ts +277 -0
  1029. package/extensions/twitch/src/types.ts +141 -0
  1030. package/extensions/twitch/src/utils/markdown.ts +92 -0
  1031. package/extensions/twitch/src/utils/twitch.ts +78 -0
  1032. package/extensions/twitch/test/setup.ts +7 -0
  1033. package/extensions/voice-call/CHANGELOG.md +13 -12
  1034. package/extensions/voice-call/README.md +15 -14
  1035. package/extensions/voice-call/index.ts +11 -9
  1036. package/extensions/voice-call/package.json +4 -4
  1037. package/extensions/voice-call/{clawdbot.plugin.json → poolbot.plugin.json} +3 -3
  1038. package/extensions/voice-call/src/cli.ts +1 -1
  1039. package/extensions/voice-call/src/config.test.ts +204 -0
  1040. package/extensions/voice-call/src/config.ts +61 -4
  1041. package/extensions/voice-call/src/core-bridge.ts +10 -8
  1042. package/extensions/voice-call/src/manager.test.ts +2 -2
  1043. package/extensions/voice-call/src/providers/twilio/webhook.ts +2 -1
  1044. package/extensions/voice-call/src/providers/twilio.ts +2 -2
  1045. package/extensions/voice-call/src/response-generator.ts +1 -1
  1046. package/extensions/voice-call/src/runtime.ts +26 -15
  1047. package/extensions/voice-call/src/types.ts +1 -0
  1048. package/extensions/voice-call/src/webhook-security.test.ts +52 -0
  1049. package/extensions/voice-call/src/webhook-security.ts +16 -5
  1050. package/extensions/voice-call/src/webhook.ts +1 -0
  1051. package/extensions/whatsapp/index.ts +3 -3
  1052. package/extensions/whatsapp/package.json +4 -4
  1053. package/extensions/whatsapp/src/channel.ts +1 -1
  1054. package/extensions/whatsapp/src/runtime.ts +1 -1
  1055. package/extensions/zalo/CHANGELOG.md +9 -9
  1056. package/extensions/zalo/README.md +3 -3
  1057. package/extensions/zalo/index.ts +3 -3
  1058. package/extensions/zalo/node_modules/.bin/poolbot +21 -0
  1059. package/extensions/zalo/package.json +6 -6
  1060. package/extensions/zalo/src/accounts.ts +9 -9
  1061. package/extensions/zalo/src/actions.ts +6 -6
  1062. package/extensions/zalo/src/channel.directory.test.ts +2 -2
  1063. package/extensions/zalo/src/channel.ts +20 -20
  1064. package/extensions/zalo/src/config-schema.ts +1 -1
  1065. package/extensions/zalo/src/monitor.ts +9 -9
  1066. package/extensions/zalo/src/monitor.webhook.test.ts +2 -2
  1067. package/extensions/zalo/src/onboarding.ts +27 -27
  1068. package/extensions/zalo/src/runtime.ts +1 -1
  1069. package/extensions/zalo/src/send.ts +2 -2
  1070. package/extensions/zalo/src/status-issues.ts +1 -1
  1071. package/extensions/zalo/src/token.ts +1 -1
  1072. package/extensions/zalouser/CHANGELOG.md +4 -4
  1073. package/extensions/zalouser/README.md +17 -17
  1074. package/extensions/zalouser/index.ts +3 -3
  1075. package/extensions/zalouser/node_modules/.bin/poolbot +21 -0
  1076. package/extensions/zalouser/package.json +6 -6
  1077. package/extensions/zalouser/src/accounts.ts +10 -10
  1078. package/extensions/zalouser/src/channel.ts +27 -27
  1079. package/extensions/zalouser/src/config-schema.ts +1 -1
  1080. package/extensions/zalouser/src/monitor.ts +5 -5
  1081. package/extensions/zalouser/src/onboarding.ts +32 -32
  1082. package/extensions/zalouser/src/runtime.ts +1 -1
  1083. package/extensions/zalouser/src/status-issues.ts +2 -2
  1084. package/git-hooks/pre-commit +0 -0
  1085. package/package.json +78 -89
  1086. package/skills/1password/SKILL.md +3 -3
  1087. package/skills/apple-notes/SKILL.md +2 -2
  1088. package/skills/apple-reminders/SKILL.md +1 -1
  1089. package/skills/bear-notes/SKILL.md +1 -1
  1090. package/skills/bird/SKILL.md +1 -1
  1091. package/skills/blogwatcher/SKILL.md +1 -1
  1092. package/skills/blucli/SKILL.md +1 -1
  1093. package/skills/bluebubbles/SKILL.md +2 -2
  1094. package/skills/camsnap/SKILL.md +1 -1
  1095. package/skills/canvas/SKILL.md +15 -15
  1096. package/skills/coding-agent/SKILL.md +6 -6
  1097. package/skills/discord/SKILL.md +6 -5
  1098. package/skills/eightctl/SKILL.md +1 -1
  1099. package/skills/food-order/SKILL.md +1 -1
  1100. package/skills/gemini/SKILL.md +1 -1
  1101. package/skills/gifgrep/SKILL.md +1 -1
  1102. package/skills/github/SKILL.md +1 -0
  1103. package/skills/gog/SKILL.md +1 -1
  1104. package/skills/goplaces/SKILL.md +1 -1
  1105. package/skills/himalaya/SKILL.md +1 -1
  1106. package/skills/imsg/SKILL.md +1 -1
  1107. package/skills/local-places/SKILL.md +1 -1
  1108. package/skills/mcporter/SKILL.md +1 -1
  1109. package/skills/model-usage/SKILL.md +1 -1
  1110. package/skills/nano-banana-pro/SKILL.md +10 -5
  1111. package/skills/nano-banana-pro/scripts/generate_image.py +42 -27
  1112. package/skills/nano-pdf/SKILL.md +1 -1
  1113. package/skills/notion/SKILL.md +1 -1
  1114. package/skills/obsidian/SKILL.md +1 -1
  1115. package/skills/openai-image-gen/SKILL.md +1 -1
  1116. package/skills/openai-whisper/SKILL.md +1 -1
  1117. package/skills/openai-whisper-api/SKILL.md +2 -2
  1118. package/skills/openhue/SKILL.md +1 -1
  1119. package/skills/oracle/SKILL.md +1 -1
  1120. package/skills/ordercli/SKILL.md +1 -1
  1121. package/skills/peekaboo/SKILL.md +1 -1
  1122. package/skills/{clawdhub → poolhub}/SKILL.md +2 -2
  1123. package/skills/sag/SKILL.md +1 -1
  1124. package/skills/session-logs/SKILL.md +7 -7
  1125. package/skills/sherpa-onnx-tts/SKILL.md +6 -6
  1126. package/skills/sherpa-onnx-tts/bin/sherpa-onnx-tts +0 -0
  1127. package/skills/slack/SKILL.md +4 -3
  1128. package/skills/songsee/SKILL.md +1 -1
  1129. package/skills/sonoscli/SKILL.md +1 -1
  1130. package/skills/spotify-player/SKILL.md +1 -1
  1131. package/skills/summarize/SKILL.md +1 -1
  1132. package/skills/things-mac/SKILL.md +3 -3
  1133. package/skills/tmux/SKILL.md +7 -7
  1134. package/skills/tmux/scripts/find-sessions.sh +1 -1
  1135. package/skills/tmux/scripts/wait-for-text.sh +0 -0
  1136. package/skills/trello/SKILL.md +2 -2
  1137. package/skills/video-frames/SKILL.md +1 -1
  1138. package/skills/voice-call/SKILL.md +4 -4
  1139. package/skills/wacli/SKILL.md +2 -2
  1140. package/skills/weather/SKILL.md +1 -1
  1141. package/skills/webgpu-threejs-tsl/REFERENCE.md +283 -0
  1142. package/skills/webgpu-threejs-tsl/SKILL.md +91 -0
  1143. package/skills/webgpu-threejs-tsl/docs/compute-shaders.md +404 -0
  1144. package/skills/webgpu-threejs-tsl/docs/core-concepts.md +453 -0
  1145. package/skills/webgpu-threejs-tsl/docs/materials.md +353 -0
  1146. package/skills/webgpu-threejs-tsl/docs/post-processing.md +434 -0
  1147. package/skills/webgpu-threejs-tsl/docs/wgsl-integration.md +324 -0
  1148. package/skills/webgpu-threejs-tsl/examples/basic-setup.js +87 -0
  1149. package/skills/webgpu-threejs-tsl/examples/custom-material.js +170 -0
  1150. package/skills/webgpu-threejs-tsl/examples/earth-shader.js +292 -0
  1151. package/skills/webgpu-threejs-tsl/examples/particle-system.js +259 -0
  1152. package/skills/webgpu-threejs-tsl/examples/post-processing.js +199 -0
  1153. package/skills/webgpu-threejs-tsl/templates/compute-shader.js +305 -0
  1154. package/skills/webgpu-threejs-tsl/templates/webgpu-project.js +276 -0
  1155. package/dist/cli/browser-cli-serve.js +0 -91
  1156. package/dist/control-ui/assets/index-Cl-Y9zqE.js.map +0 -1
  1157. package/dist/control-ui/assets/index-DEPfFcOb.css +0 -1
  1158. package/docs/POOL-BOT.md +0 -119
  1159. /package/dist/{config/types.clawdbot.js → browser/routes/types.js} +0 -0
  1160. /package/docs/{whatsapp-clawd.jpg → whatsapp-poolbot.jpg} +0 -0
  1161. /package/extensions/bluebubbles/{clawdbot.plugin.json → poolbot.plugin.json} +0 -0
  1162. /package/extensions/copilot-proxy/{clawdbot.plugin.json → poolbot.plugin.json} +0 -0
  1163. /package/extensions/diagnostics-otel/{clawdbot.plugin.json → poolbot.plugin.json} +0 -0
  1164. /package/extensions/discord/{clawdbot.plugin.json → poolbot.plugin.json} +0 -0
  1165. /package/extensions/google-antigravity-auth/{clawdbot.plugin.json → poolbot.plugin.json} +0 -0
  1166. /package/extensions/google-gemini-cli-auth/{clawdbot.plugin.json → poolbot.plugin.json} +0 -0
  1167. /package/extensions/googlechat/{clawdbot.plugin.json → poolbot.plugin.json} +0 -0
  1168. /package/extensions/imessage/{clawdbot.plugin.json → poolbot.plugin.json} +0 -0
  1169. /package/extensions/line/{clawdbot.plugin.json → poolbot.plugin.json} +0 -0
  1170. /package/extensions/llm-task/{clawdbot.plugin.json → poolbot.plugin.json} +0 -0
  1171. /package/extensions/lobster/{clawdbot.plugin.json → poolbot.plugin.json} +0 -0
  1172. /package/extensions/matrix/{clawdbot.plugin.json → poolbot.plugin.json} +0 -0
  1173. /package/extensions/mattermost/{clawdbot.plugin.json → poolbot.plugin.json} +0 -0
  1174. /package/extensions/memory-core/{clawdbot.plugin.json → poolbot.plugin.json} +0 -0
  1175. /package/extensions/msteams/{clawdbot.plugin.json → poolbot.plugin.json} +0 -0
  1176. /package/extensions/nextcloud-talk/{clawdbot.plugin.json → poolbot.plugin.json} +0 -0
  1177. /package/extensions/nostr/{clawdbot.plugin.json → poolbot.plugin.json} +0 -0
  1178. /package/extensions/open-prose/{clawdbot.plugin.json → poolbot.plugin.json} +0 -0
  1179. /package/extensions/qwen-portal-auth/{clawdbot.plugin.json → poolbot.plugin.json} +0 -0
  1180. /package/extensions/signal/{clawdbot.plugin.json → poolbot.plugin.json} +0 -0
  1181. /package/extensions/slack/{clawdbot.plugin.json → poolbot.plugin.json} +0 -0
  1182. /package/extensions/telegram/{clawdbot.plugin.json → poolbot.plugin.json} +0 -0
  1183. /package/extensions/tlon/{clawdbot.plugin.json → poolbot.plugin.json} +0 -0
  1184. /package/extensions/whatsapp/{clawdbot.plugin.json → poolbot.plugin.json} +0 -0
  1185. /package/extensions/zalo/{clawdbot.plugin.json → poolbot.plugin.json} +0 -0
  1186. /package/extensions/zalouser/{clawdbot.plugin.json → poolbot.plugin.json} +0 -0
@@ -1,66 +1,66 @@
1
- (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function s(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();const qt=globalThis,Ts=qt.ShadowRoot&&(qt.ShadyCSS===void 0||qt.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Cs=Symbol(),Pi=new WeakMap;let qa=class{constructor(t,n,s){if(this._$cssResult$=!0,s!==Cs)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=n}get styleSheet(){let t=this.o;const n=this.t;if(Ts&&t===void 0){const s=n!==void 0&&n.length===1;s&&(t=Pi.get(n)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&Pi.set(n,t))}return t}toString(){return this.cssText}};const Or=e=>new qa(typeof e=="string"?e:e+"",void 0,Cs),Dr=(e,...t)=>{const n=e.length===1?e[0]:t.reduce((s,i,a)=>s+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+e[a+1],e[0]);return new qa(n,e,Cs)},Br=(e,t)=>{if(Ts)e.adoptedStyleSheets=t.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of t){const s=document.createElement("style"),i=qt.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=n.cssText,e.appendChild(s)}},Ni=Ts?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const s of t.cssRules)n+=s.cssText;return Or(n)})(e):e;const{is:Fr,defineProperty:Ur,getOwnPropertyDescriptor:Kr,getOwnPropertyNames:Hr,getOwnPropertySymbols:zr,getPrototypeOf:jr}=Object,nn=globalThis,Oi=nn.trustedTypes,qr=Oi?Oi.emptyScript:"",Vr=nn.reactiveElementPolyfillSupport,bt=(e,t)=>e,Gt={toAttribute(e,t){switch(t){case Boolean:e=e?qr:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=e!==null;break;case Number:n=e===null?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch{n=null}}return n}},Es=(e,t)=>!Fr(e,t),Di={attribute:!0,type:String,converter:Gt,reflect:!1,useDefault:!1,hasChanged:Es};Symbol.metadata??=Symbol("metadata"),nn.litPropertyMetadata??=new WeakMap;let Ye=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,n=Di){if(n.state&&(n.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((n=Object.create(n)).wrapped=!0),this.elementProperties.set(t,n),!n.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,n);i!==void 0&&Ur(this.prototype,t,i)}}static getPropertyDescriptor(t,n,s){const{get:i,set:a}=Kr(this.prototype,t)??{get(){return this[n]},set(o){this[n]=o}};return{get:i,set(o){const c=i?.call(this);a?.call(this,o),this.requestUpdate(t,c,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Di}static _$Ei(){if(this.hasOwnProperty(bt("elementProperties")))return;const t=jr(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(bt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(bt("properties"))){const n=this.properties,s=[...Hr(n),...zr(n)];for(const i of s)this.createProperty(i,n[i])}const t=this[Symbol.metadata];if(t!==null){const n=litPropertyMetadata.get(t);if(n!==void 0)for(const[s,i]of n)this.elementProperties.set(s,i)}this._$Eh=new Map;for(const[n,s]of this.elementProperties){const i=this._$Eu(n,s);i!==void 0&&this._$Eh.set(i,n)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const n=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const i of s)n.unshift(Ni(i))}else t!==void 0&&n.push(Ni(t));return n}static _$Eu(t,n){const s=n.attribute;return s===!1?void 0:typeof s=="string"?s:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,n=this.constructor.elementProperties;for(const s of n.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Br(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,n,s){this._$AK(t,s)}_$ET(t,n){const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(i!==void 0&&s.reflect===!0){const a=(s.converter?.toAttribute!==void 0?s.converter:Gt).toAttribute(n,s.type);this._$Em=t,a==null?this.removeAttribute(i):this.setAttribute(i,a),this._$Em=null}}_$AK(t,n){const s=this.constructor,i=s._$Eh.get(t);if(i!==void 0&&this._$Em!==i){const a=s.getPropertyOptions(i),o=typeof a.converter=="function"?{fromAttribute:a.converter}:a.converter?.fromAttribute!==void 0?a.converter:Gt;this._$Em=i;const c=o.fromAttribute(n,a.type);this[i]=c??this._$Ej?.get(i)??c,this._$Em=null}}requestUpdate(t,n,s,i=!1,a){if(t!==void 0){const o=this.constructor;if(i===!1&&(a=this[t]),s??=o.getPropertyOptions(t),!((s.hasChanged??Es)(a,n)||s.useDefault&&s.reflect&&a===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,s))))return;this.C(t,n,s)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,n,{useDefault:s,reflect:i,wrapped:a},o){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,o??n??this[t]),a!==!0||o!==void 0)||(this._$AL.has(t)||(this.hasUpdated||s||(n=void 0),this._$AL.set(t,n)),i===!0&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(n){Promise.reject(n)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[i,a]of this._$Ep)this[i]=a;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[i,a]of s){const{wrapped:o}=a,c=this[i];o!==!0||this._$AL.has(i)||c===void 0||this.C(i,void 0,a,c)}}let t=!1;const n=this._$AL;try{t=this.shouldUpdate(n),t?(this.willUpdate(n),this._$EO?.forEach(s=>s.hostUpdate?.()),this.update(n)):this._$EM()}catch(s){throw t=!1,this._$EM(),s}t&&this._$AE(n)}willUpdate(t){}_$AE(t){this._$EO?.forEach(n=>n.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(n=>this._$ET(n,this[n])),this._$EM()}updated(t){}firstUpdated(t){}};Ye.elementStyles=[],Ye.shadowRootOptions={mode:"open"},Ye[bt("elementProperties")]=new Map,Ye[bt("finalized")]=new Map,Vr?.({ReactiveElement:Ye}),(nn.reactiveElementVersions??=[]).push("2.1.2");const Ls=globalThis,Bi=e=>e,Yt=Ls.trustedTypes,Fi=Yt?Yt.createPolicy("lit-html",{createHTML:e=>e}):void 0,Va="$lit$",xe=`lit$${Math.random().toFixed(9).slice(2)}$`,Wa="?"+xe,Wr=`<${Wa}>`,Oe=document,$t=()=>Oe.createComment(""),xt=e=>e===null||typeof e!="object"&&typeof e!="function",Ms=Array.isArray,Gr=e=>Ms(e)||typeof e?.[Symbol.iterator]=="function",On=`[
2
- \f\r]`,rt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ui=/-->/g,Ki=/>/g,Le=RegExp(`>|${On}(?:([^\\s"'>=/]+)(${On}*=${On}*(?:[^
3
- \f\r"'\`<>=]|("|')|))|$)`,"g"),Hi=/'/g,zi=/"/g,Ga=/^(?:script|style|textarea|title)$/i,Yr=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),r=Yr(1),Se=Symbol.for("lit-noChange"),g=Symbol.for("lit-nothing"),ji=new WeakMap,Pe=Oe.createTreeWalker(Oe,129);function Ya(e,t){if(!Ms(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return Fi!==void 0?Fi.createHTML(t):t}const Qr=(e,t)=>{const n=e.length-1,s=[];let i,a=t===2?"<svg>":t===3?"<math>":"",o=rt;for(let c=0;c<n;c++){const l=e[c];let p,d,u=-1,h=0;for(;h<l.length&&(o.lastIndex=h,d=o.exec(l),d!==null);)h=o.lastIndex,o===rt?d[1]==="!--"?o=Ui:d[1]!==void 0?o=Ki:d[2]!==void 0?(Ga.test(d[2])&&(i=RegExp("</"+d[2],"g")),o=Le):d[3]!==void 0&&(o=Le):o===Le?d[0]===">"?(o=i??rt,u=-1):d[1]===void 0?u=-2:(u=o.lastIndex-d[2].length,p=d[1],o=d[3]===void 0?Le:d[3]==='"'?zi:Hi):o===zi||o===Hi?o=Le:o===Ui||o===Ki?o=rt:(o=Le,i=void 0);const v=o===Le&&e[c+1].startsWith("/>")?" ":"";a+=o===rt?l+Wr:u>=0?(s.push(p),l.slice(0,u)+Va+l.slice(u)+xe+v):l+xe+(u===-2?c:v)}return[Ya(e,a+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]};let ts=class Qa{constructor({strings:t,_$litType$:n},s){let i;this.parts=[];let a=0,o=0;const c=t.length-1,l=this.parts,[p,d]=Qr(t,n);if(this.el=Qa.createElement(p,s),Pe.currentNode=this.el.content,n===2||n===3){const u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(i=Pe.nextNode())!==null&&l.length<c;){if(i.nodeType===1){if(i.hasAttributes())for(const u of i.getAttributeNames())if(u.endsWith(Va)){const h=d[o++],v=i.getAttribute(u).split(xe),w=/([.?@])?(.*)/.exec(h);l.push({type:1,index:a,name:w[2],strings:v,ctor:w[1]==="."?Jr:w[1]==="?"?Xr:w[1]==="@"?el:an}),i.removeAttribute(u)}else u.startsWith(xe)&&(l.push({type:6,index:a}),i.removeAttribute(u));if(Ga.test(i.tagName)){const u=i.textContent.split(xe),h=u.length-1;if(h>0){i.textContent=Yt?Yt.emptyScript:"";for(let v=0;v<h;v++)i.append(u[v],$t()),Pe.nextNode(),l.push({type:2,index:++a});i.append(u[h],$t())}}}else if(i.nodeType===8)if(i.data===Wa)l.push({type:2,index:a});else{let u=-1;for(;(u=i.data.indexOf(xe,u+1))!==-1;)l.push({type:7,index:a}),u+=xe.length-1}a++}}static createElement(t,n){const s=Oe.createElement("template");return s.innerHTML=t,s}};function Je(e,t,n=e,s){if(t===Se)return t;let i=s!==void 0?n._$Co?.[s]:n._$Cl;const a=xt(t)?void 0:t._$litDirective$;return i?.constructor!==a&&(i?._$AO?.(!1),a===void 0?i=void 0:(i=new a(e),i._$AT(e,n,s)),s!==void 0?(n._$Co??=[])[s]=i:n._$Cl=i),i!==void 0&&(t=Je(e,i._$AS(e,t.values),i,s)),t}class Zr{constructor(t,n){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:n},parts:s}=this._$AD,i=(t?.creationScope??Oe).importNode(n,!0);Pe.currentNode=i;let a=Pe.nextNode(),o=0,c=0,l=s[0];for(;l!==void 0;){if(o===l.index){let p;l.type===2?p=new sn(a,a.nextSibling,this,t):l.type===1?p=new l.ctor(a,l.name,l.strings,this,t):l.type===6&&(p=new tl(a,this,t)),this._$AV.push(p),l=s[++c]}o!==l?.index&&(a=Pe.nextNode(),o++)}return Pe.currentNode=Oe,i}p(t){let n=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,n),n+=s.strings.length-2):s._$AI(t[n])),n++}}let sn=class Za{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,n,s,i){this.type=2,this._$AH=g,this._$AN=void 0,this._$AA=t,this._$AB=n,this._$AM=s,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&t?.nodeType===11&&(t=n.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,n=this){t=Je(this,t,n),xt(t)?t===g||t==null||t===""?(this._$AH!==g&&this._$AR(),this._$AH=g):t!==this._$AH&&t!==Se&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Gr(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==g&&xt(this._$AH)?this._$AA.nextSibling.data=t:this.T(Oe.createTextNode(t)),this._$AH=t}$(t){const{values:n,_$litType$:s}=t,i=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=ts.createElement(Ya(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(n);else{const a=new Zr(i,this),o=a.u(this.options);a.p(n),this.T(o),this._$AH=a}}_$AC(t){let n=ji.get(t.strings);return n===void 0&&ji.set(t.strings,n=new ts(t)),n}k(t){Ms(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let s,i=0;for(const a of t)i===n.length?n.push(s=new Za(this.O($t()),this.O($t()),this,this.options)):s=n[i],s._$AI(a),i++;i<n.length&&(this._$AR(s&&s._$AB.nextSibling,i),n.length=i)}_$AR(t=this._$AA.nextSibling,n){for(this._$AP?.(!1,!0,n);t!==this._$AB;){const s=Bi(t).nextSibling;Bi(t).remove(),t=s}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}};class an{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,s,i,a){this.type=1,this._$AH=g,this._$AN=void 0,this.element=t,this.name=n,this._$AM=i,this.options=a,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=g}_$AI(t,n=this,s,i){const a=this.strings;let o=!1;if(a===void 0)t=Je(this,t,n,0),o=!xt(t)||t!==this._$AH&&t!==Se,o&&(this._$AH=t);else{const c=t;let l,p;for(t=a[0],l=0;l<a.length-1;l++)p=Je(this,c[s+l],n,l),p===Se&&(p=this._$AH[l]),o||=!xt(p)||p!==this._$AH[l],p===g?t=g:t!==g&&(t+=(p??"")+a[l+1]),this._$AH[l]=p}o&&!i&&this.j(t)}j(t){t===g?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let Jr=class extends an{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===g?void 0:t}},Xr=class extends an{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==g)}},el=class extends an{constructor(t,n,s,i,a){super(t,n,s,i,a),this.type=5}_$AI(t,n=this){if((t=Je(this,t,n,0)??g)===Se)return;const s=this._$AH,i=t===g&&s!==g||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,a=t!==g&&(s===g||i);i&&this.element.removeEventListener(this.name,this,s),a&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},tl=class{constructor(t,n,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=n,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){Je(this,t)}};const nl={I:sn},sl=Ls.litHtmlPolyfillSupport;sl?.(ts,sn),(Ls.litHtmlVersions??=[]).push("3.3.2");const il=(e,t,n)=>{const s=n?.renderBefore??t;let i=s._$litPart$;if(i===void 0){const a=n?.renderBefore??null;s._$litPart$=i=new sn(t.insertBefore($t(),a),a,void 0,n??{})}return i._$AI(e),i};const Is=globalThis;let Ze=class extends Ye{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=il(n,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Se}};Ze._$litElement$=!0,Ze.finalized=!0,Is.litElementHydrateSupport?.({LitElement:Ze});const al=Is.litElementPolyfillSupport;al?.({LitElement:Ze});(Is.litElementVersions??=[]).push("4.2.2");const Ja=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const ol={attribute:!0,type:String,converter:Gt,reflect:!1,hasChanged:Es},rl=(e=ol,t,n)=>{const{kind:s,metadata:i}=n;let a=globalThis.litPropertyMetadata.get(i);if(a===void 0&&globalThis.litPropertyMetadata.set(i,a=new Map),s==="setter"&&((e=Object.create(e)).wrapped=!0),a.set(n.name,e),s==="accessor"){const{name:o}=n;return{set(c){const l=t.get.call(this);t.set.call(this,c),this.requestUpdate(o,l,e,!0,c)},init(c){return c!==void 0&&this.C(o,void 0,e,c),c}}}if(s==="setter"){const{name:o}=n;return function(c){const l=this[o];t.call(this,c),this.requestUpdate(o,l,e,!0,c)}}throw Error("Unsupported decorator location: "+s)};function on(e){return(t,n)=>typeof n=="object"?rl(e,t,n):((s,i,a)=>{const o=i.hasOwnProperty(a);return i.constructor.createProperty(a,s),o?Object.getOwnPropertyDescriptor(i,a):void 0})(e,t,n)}function y(e){return on({...e,state:!0,attribute:!1})}const ll=50,cl=200,dl="Assistant";function qi(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function ns(e){const t=qi(e?.name,ll)??dl,n=qi(e?.avatar??void 0,cl)??null;return{agentId:typeof e?.agentId=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function ul(){return ns(typeof window>"u"?{}:{name:window.__CLAWDBOT_ASSISTANT_NAME__,avatar:window.__CLAWDBOT_ASSISTANT_AVATAR__})}const Xa="clawdbot.control.settings.v1";function pl(){const t={gatewayUrl:`${location.protocol==="https:"?"wss":"ws"}://${location.host}`,token:"",sessionKey:"main",lastActiveSessionKey:"main",theme:"system",chatFocusMode:!1,chatShowThinking:!0,splitRatio:.6,navCollapsed:!1,navGroupsCollapsed:{}};try{const n=localStorage.getItem(Xa);if(!n)return t;const s=JSON.parse(n);return{gatewayUrl:typeof s.gatewayUrl=="string"&&s.gatewayUrl.trim()?s.gatewayUrl.trim():t.gatewayUrl,token:typeof s.token=="string"?s.token:t.token,sessionKey:typeof s.sessionKey=="string"&&s.sessionKey.trim()?s.sessionKey.trim():t.sessionKey,lastActiveSessionKey:typeof s.lastActiveSessionKey=="string"&&s.lastActiveSessionKey.trim()?s.lastActiveSessionKey.trim():typeof s.sessionKey=="string"&&s.sessionKey.trim()||t.lastActiveSessionKey,theme:s.theme==="light"||s.theme==="dark"||s.theme==="system"?s.theme:t.theme,chatFocusMode:typeof s.chatFocusMode=="boolean"?s.chatFocusMode:t.chatFocusMode,chatShowThinking:typeof s.chatShowThinking=="boolean"?s.chatShowThinking:t.chatShowThinking,splitRatio:typeof s.splitRatio=="number"&&s.splitRatio>=.4&&s.splitRatio<=.7?s.splitRatio:t.splitRatio,navCollapsed:typeof s.navCollapsed=="boolean"?s.navCollapsed:t.navCollapsed,navGroupsCollapsed:typeof s.navGroupsCollapsed=="object"&&s.navGroupsCollapsed!==null?s.navGroupsCollapsed:t.navGroupsCollapsed}}catch{return t}}function fl(e){localStorage.setItem(Xa,JSON.stringify(e))}function eo(e){const t=(e??"").trim();if(!t)return null;const n=t.split(":").filter(Boolean);if(n.length<3||n[0]!=="agent")return null;const s=n[1]?.trim(),i=n.slice(2).join(":");return!s||!i?null:{agentId:s,rest:i}}const hl=[{label:"Chat",tabs:["chat"]},{label:"Control",tabs:["overview","channels","instances","sessions","cron"]},{label:"Agent",tabs:["skills","nodes"]},{label:"Settings",tabs:["config","debug","logs"]}],to={overview:"/overview",channels:"/channels",instances:"/instances",sessions:"/sessions",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",config:"/config",debug:"/debug",logs:"/logs"},no=new Map(Object.entries(to).map(([e,t])=>[t,e]));function rn(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function kt(e){if(!e)return"/";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t}function Rs(e,t=""){const n=rn(t),s=to[e];return n?`${n}${s}`:s}function so(e,t=""){const n=rn(t);let s=e||"/";n&&(s===n?s="/":s.startsWith(`${n}/`)&&(s=s.slice(n.length)));let i=kt(s).toLowerCase();return i.endsWith("/index.html")&&(i="/"),i==="/"?"chat":no.get(i)??null}function gl(e){let t=kt(e);if(t.endsWith("/index.html")&&(t=kt(t.slice(0,-11))),t==="/")return"";const n=t.split("/").filter(Boolean);if(n.length===0)return"";for(let s=0;s<n.length;s++){const i=`/${n.slice(s).join("/")}`.toLowerCase();if(no.has(i)){const a=n.slice(0,s);return a.length?`/${a.join("/")}`:""}}return`/${n.join("/")}`}function vl(e){switch(e){case"chat":return"messageSquare";case"overview":return"barChart";case"channels":return"link";case"instances":return"radio";case"sessions":return"fileText";case"cron":return"loader";case"skills":return"zap";case"nodes":return"monitor";case"config":return"settings";case"debug":return"bug";case"logs":return"scrollText";default:return"folder"}}function ss(e){switch(e){case"overview":return"Overview";case"channels":return"Channels";case"instances":return"Instances";case"sessions":return"Sessions";case"cron":return"Cron Jobs";case"skills":return"Skills";case"nodes":return"Nodes";case"chat":return"Chat";case"config":return"Config";case"debug":return"Debug";case"logs":return"Logs";default:return"Control"}}function ml(e){switch(e){case"overview":return"Gateway status, entry points, and a fast health read.";case"channels":return"Manage channels and settings.";case"instances":return"Presence beacons from connected clients and nodes.";case"sessions":return"Inspect active sessions and adjust per-session defaults.";case"cron":return"Schedule wakeups and recurring agent runs.";case"skills":return"Manage skill availability and API key injection.";case"nodes":return"Paired devices, capabilities, and command exposure.";case"chat":return"Direct gateway chat session for quick interventions.";case"config":return"Edit ~/.clawdbot/clawdbot.json safely.";case"debug":return"Gateway snapshots, events, and manual RPC calls.";case"logs":return"Live tail of the gateway file logs.";default:return""}}const Q={messageSquare:r`<svg viewBox="0 0 24 24"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>`,barChart:r`<svg viewBox="0 0 24 24"><line x1="12" x2="12" y1="20" y2="10"/><line x1="18" x2="18" y1="20" y2="4"/><line x1="6" x2="6" y1="20" y2="16"/></svg>`,link:r`<svg viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,radio:r`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="2"/><path d="M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"/></svg>`,fileText:r`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><line x1="16" x2="8" y1="13" y2="13"/><line x1="16" x2="8" y1="17" y2="17"/><line x1="10" x2="8" y1="9" y2="9"/></svg>`,zap:r`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:r`<svg viewBox="0 0 24 24"><rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/></svg>`,settings:r`<svg viewBox="0 0 24 24"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg>`,bug:r`<svg viewBox="0 0 24 24"><path d="m8 2 1.88 1.88"/><path d="M14.12 3.88 16 2"/><path d="M9 7.13v-1a3.003 3.003 0 1 1 6 0v1"/><path d="M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6"/><path d="M12 20v-9"/><path d="M6.53 9C4.6 8.8 3 7.1 3 5"/><path d="M6 13H2"/><path d="M3 21c0-2.1 1.7-3.9 3.8-4"/><path d="M20.97 5c0 2.1-1.6 3.8-3.5 4"/><path d="M22 13h-4"/><path d="M17.2 17c2.1.1 3.8 1.9 3.8 4"/></svg>`,scrollText:r`<svg viewBox="0 0 24 24"><path d="M8 21h12a2 2 0 0 0 2-2v-2H10v2a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v3h4"/><path d="M19 17V5a2 2 0 0 0-2-2H4"/><path d="M15 8h-5"/><path d="M15 12h-5"/></svg>`,folder:r`<svg viewBox="0 0 24 24"><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/></svg>`,menu:r`<svg viewBox="0 0 24 24"><line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="18" y2="18"/></svg>`,x:r`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:r`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:r`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,search:r`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:r`<svg viewBox="0 0 24 24"><path d="M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z"/><path d="M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z"/><path d="M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4"/><path d="M17.599 6.5a3 3 0 0 0 .399-1.375"/><path d="M6.003 5.125A3 3 0 0 0 6.401 6.5"/><path d="M3.477 10.896a4 4 0 0 1 .585-.396"/><path d="M19.938 10.5a4 4 0 0 1 .585.396"/><path d="M6 18a4 4 0 0 1-1.967-.516"/><path d="M19.967 17.484A4 4 0 0 1 18 18"/></svg>`,book:r`<svg viewBox="0 0 24 24"><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"/></svg>`,loader:r`<svg viewBox="0 0 24 24"><path d="M12 2v4"/><path d="m16.2 7.8 2.9-2.9"/><path d="M18 12h4"/><path d="m16.2 16.2 2.9 2.9"/><path d="M12 18v4"/><path d="m4.9 19.1 2.9-2.9"/><path d="M2 12h4"/><path d="m4.9 4.9 2.9 2.9"/></svg>`,wrench:r`<svg viewBox="0 0 24 24"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/></svg>`,fileCode:r`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><path d="m10 13-2 2 2 2"/><path d="m14 17 2-2-2-2"/></svg>`,edit:r`<svg viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,penLine:r`<svg viewBox="0 0 24 24"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>`,paperclip:r`<svg viewBox="0 0 24 24"><path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>`,globe:r`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/></svg>`,image:r`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>`,smartphone:r`<svg viewBox="0 0 24 24"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/></svg>`,plug:r`<svg viewBox="0 0 24 24"><path d="M12 22v-5"/><path d="M9 8V2"/><path d="M15 8V2"/><path d="M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z"/></svg>`,circle:r`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,puzzle:r`<svg viewBox="0 0 24 24"><path d="M19.439 7.85c-.049.322.059.648.289.878l1.568 1.568c.47.47.706 1.087.706 1.704s-.235 1.233-.706 1.704l-1.611 1.611a.98.98 0 0 1-.837.276c-.47-.07-.802-.48-.968-.925a2.501 2.501 0 1 0-3.214 3.214c.446.166.855.497.925.968a.979.979 0 0 1-.276.837l-1.61 1.61a2.404 2.404 0 0 1-1.705.707 2.402 2.402 0 0 1-1.704-.706l-1.568-1.568a1.026 1.026 0 0 0-.877-.29c-.493.074-.84.504-1.02.968a2.5 2.5 0 1 1-3.237-3.237c.464-.18.894-.527.967-1.02a1.026 1.026 0 0 0-.289-.877l-1.568-1.568A2.402 2.402 0 0 1 1.998 12c0-.617.236-1.234.706-1.704L4.23 8.77c.24-.24.581-.353.917-.303.515.076.874.54 1.02 1.02a2.5 2.5 0 1 0 3.237-3.237c-.48-.146-.944-.505-1.02-1.02a.98.98 0 0 1 .303-.917l1.526-1.526A2.402 2.402 0 0 1 11.998 2c.617 0 1.234.236 1.704.706l1.568 1.568c.23.23.556.338.877.29.493-.074.84-.504 1.02-.968a2.5 2.5 0 1 1 3.236 3.236c-.464.18-.894.527-.967 1.02Z"/></svg>`},bl=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,Dt=/<\s*\/?\s*final\b[^>]*>/gi,Vi=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function yl(e,t){return e.trimStart()}function wl(e,t){if(!e||!bl.test(e))return e;let n=e;Dt.test(n)?(Dt.lastIndex=0,n=n.replace(Dt,"")):Dt.lastIndex=0,Vi.lastIndex=0;let s="",i=0,a=!1;for(const o of n.matchAll(Vi)){const c=o.index??0,l=o[1]==="/";a?l&&(a=!1):(s+=n.slice(i,c),l||(a=!0)),i=c+o[0].length}return s+=n.slice(i),yl(s)}function At(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString()}function O(e){if(!e&&e!==0)return"n/a";const t=Date.now()-e;if(t<0)return"just now";const n=Math.round(t/1e3);if(n<60)return`${n}s ago`;const s=Math.round(n/60);if(s<60)return`${s}m ago`;const i=Math.round(s/60);return i<48?`${i}h ago`:`${Math.round(i/24)}d ago`}function io(e){if(!e&&e!==0)return"n/a";if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.round(t/60);if(n<60)return`${n}m`;const s=Math.round(n/60);return s<48?`${s}h`:`${Math.round(s/24)}d`}function is(e){return!e||e.length===0?"none":e.filter(t=>!!(t&&t.trim())).join(", ")}function as(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function ao(e,t){return e.length<=t?{text:e,truncated:!1,total:e.length}:{text:e.slice(0,Math.max(0,t)),truncated:!0,total:e.length}}function Qt(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Dn(e){return wl(e)}const $l=/^\[([^\]]+)\]\s*/,xl=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],Bn=new WeakMap,Fn=new WeakMap;function kl(e){return/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}Z\b/.test(e)||/\d{4}-\d{2}-\d{2} \d{2}:\d{2}\b/.test(e)?!0:xl.some(t=>e.startsWith(`${t} `))}function Un(e){const t=e.match($l);if(!t)return e;const n=t[1]??"";return kl(n)?e.slice(t[0].length):e}function os(e){const t=e,n=typeof t.role=="string"?t.role:"",s=t.content;if(typeof s=="string")return n==="assistant"?Dn(s):Un(s);if(Array.isArray(s)){const i=s.map(a=>{const o=a;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(a=>typeof a=="string");if(i.length>0){const a=i.join(`
4
- `);return n==="assistant"?Dn(a):Un(a)}}return typeof t.text=="string"?n==="assistant"?Dn(t.text):Un(t.text):null}function oo(e){if(!e||typeof e!="object")return os(e);const t=e;if(Bn.has(t))return Bn.get(t)??null;const n=os(e);return Bn.set(t,n),n}function Wi(e){const n=e.content,s=[];if(Array.isArray(n))for(const c of n){const l=c;if(l.type==="thinking"&&typeof l.thinking=="string"){const p=l.thinking.trim();p&&s.push(p)}}if(s.length>0)return s.join(`
5
- `);const i=Sl(e);if(!i)return null;const o=[...i.matchAll(/<\s*think(?:ing)?\s*>([\s\S]*?)<\s*\/\s*think(?:ing)?\s*>/gi)].map(c=>(c[1]??"").trim()).filter(Boolean);return o.length>0?o.join(`
6
- `):null}function Al(e){if(!e||typeof e!="object")return Wi(e);const t=e;if(Fn.has(t))return Fn.get(t)??null;const n=Wi(e);return Fn.set(t,n),n}function Sl(e){const t=e,n=t.content;if(typeof n=="string")return n;if(Array.isArray(n)){const s=n.map(i=>{const a=i;return a.type==="text"&&typeof a.text=="string"?a.text:null}).filter(i=>typeof i=="string");if(s.length>0)return s.join(`
7
- `)}return typeof t.text=="string"?t.text:null}function _l(e){const t=e.trim();if(!t)return"";const n=t.split(/\r?\n/).map(s=>s.trim()).filter(Boolean).map(s=>`_${s}_`);return n.length?["_Reasoning:_",...n].join(`
8
- `):""}function Gi(e){e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<e.length;n++)t+=e[n].toString(16).padStart(2,"0");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Tl(){const e=new Uint8Array(16),t=Date.now();for(let n=0;n<e.length;n++)e[n]=Math.floor(Math.random()*256);return e[0]^=t&255,e[1]^=t>>>8&255,e[2]^=t>>>16&255,e[3]^=t>>>24&255,e}function Ps(e=globalThis.crypto){if(e&&typeof e.randomUUID=="function")return e.randomUUID();if(e&&typeof e.getRandomValues=="function"){const t=new Uint8Array(16);return e.getRandomValues(t),Gi(t)}return Gi(Tl())}async function Xe(e){if(!(!e.client||!e.connected)){e.chatLoading=!0,e.lastError=null;try{const t=await e.client.request("chat.history",{sessionKey:e.sessionKey,limit:200});e.chatMessages=Array.isArray(t.messages)?t.messages:[],e.chatThinkingLevel=t.thinkingLevel??null}catch(t){e.lastError=String(t)}finally{e.chatLoading=!1}}}async function Cl(e,t){if(!e.client||!e.connected)return!1;const n=t.trim();if(!n)return!1;const s=Date.now();e.chatMessages=[...e.chatMessages,{role:"user",content:[{type:"text",text:n}],timestamp:s}],e.chatSending=!0,e.lastError=null;const i=Ps();e.chatRunId=i,e.chatStream="",e.chatStreamStartedAt=s;try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:n,deliver:!1,idempotencyKey:i}),!0}catch(a){const o=String(a);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=o,e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:"Error: "+o}],timestamp:Date.now()}],!1}finally{e.chatSending=!1}}async function El(e){if(!e.client||!e.connected)return!1;const t=e.chatRunId;try{return await e.client.request("chat.abort",t?{sessionKey:e.sessionKey,runId:t}:{sessionKey:e.sessionKey}),!0}catch(n){return e.lastError=String(n),!1}}function Ll(e,t){if(!t||t.sessionKey!==e.sessionKey||t.runId&&e.chatRunId&&t.runId!==e.chatRunId)return null;if(t.state==="delta"){const n=os(t.message);if(typeof n=="string"){const s=e.chatStream??"";(!s||n.length>=s.length)&&(e.chatStream=n)}}else t.state==="final"||t.state==="aborted"?(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null):t.state==="error"&&(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.lastError=t.errorMessage??"chat error");return t.state}async function st(e){if(!(!e.client||!e.connected)&&!e.sessionsLoading){e.sessionsLoading=!0,e.sessionsError=null;try{const t={includeGlobal:e.sessionsIncludeGlobal,includeUnknown:e.sessionsIncludeUnknown},n=Qt(e.sessionsFilterActive,0),s=Qt(e.sessionsFilterLimit,0);n>0&&(t.activeMinutes=n),s>0&&(t.limit=s);const i=await e.client.request("sessions.list",t);i&&(e.sessionsResult=i)}catch(t){e.sessionsError=String(t)}finally{e.sessionsLoading=!1}}}async function Ml(e,t,n){if(!e.client||!e.connected)return;const s={key:t};"label"in n&&(s.label=n.label),"thinkingLevel"in n&&(s.thinkingLevel=n.thinkingLevel),"verboseLevel"in n&&(s.verboseLevel=n.verboseLevel),"reasoningLevel"in n&&(s.reasoningLevel=n.reasoningLevel);try{await e.client.request("sessions.patch",s),await st(e)}catch(i){e.sessionsError=String(i)}}async function Il(e,t){if(!(!e.client||!e.connected||e.sessionsLoading||!window.confirm(`Delete session "${t}"?
9
-
10
- Deletes the session entry and archives its transcript.`))){e.sessionsLoading=!0,e.sessionsError=null;try{await e.client.request("sessions.delete",{key:t,deleteTranscript:!0}),await st(e)}catch(s){e.sessionsError=String(s)}finally{e.sessionsLoading=!1}}}const Yi=50,Rl=80,Pl=12e4;function Nl(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.text=="string")return t.text;const n=t.content;if(!Array.isArray(n))return null;const s=n.map(i=>{if(!i||typeof i!="object")return null;const a=i;return a.type==="text"&&typeof a.text=="string"?a.text:null}).filter(i=>!!i);return s.length===0?null:s.join(`
11
- `)}function Qi(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=Nl(e);let n;if(typeof e=="string")n=e;else if(t)n=t;else try{n=JSON.stringify(e,null,2)}catch{n=String(e)}const s=ao(n,Pl);return s.truncated?`${s.text}
12
-
13
- … truncated (${s.total} chars, showing first ${s.text.length}).`:s.text}function Ol(e){const t=[];return t.push({type:"toolcall",name:e.name,arguments:e.args??{}}),e.output&&t.push({type:"toolresult",name:e.name,text:e.output}),{role:"assistant",toolCallId:e.toolCallId,runId:e.runId,content:t,timestamp:e.startedAt}}function Dl(e){if(e.toolStreamOrder.length<=Yi)return;const t=e.toolStreamOrder.length-Yi,n=e.toolStreamOrder.splice(0,t);for(const s of n)e.toolStreamById.delete(s)}function Bl(e){e.chatToolMessages=e.toolStreamOrder.map(t=>e.toolStreamById.get(t)?.message).filter(t=>!!t)}function rs(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),Bl(e)}function Fl(e,t=!1){if(t){rs(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>rs(e),Rl))}function Ns(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],rs(e)}const Ul=5e3;function Kl(e,t){const n=t.data??{},s=typeof n.phase=="string"?n.phase:"";e.compactionClearTimer!=null&&(window.clearTimeout(e.compactionClearTimer),e.compactionClearTimer=null),s==="start"?e.compactionStatus={active:!0,startedAt:Date.now(),completedAt:null}:s==="end"&&(e.compactionStatus={active:!1,startedAt:e.compactionStatus?.startedAt??null,completedAt:Date.now()},e.compactionClearTimer=window.setTimeout(()=>{e.compactionStatus=null,e.compactionClearTimer=null},Ul))}function Hl(e,t){if(!t)return;if(t.stream==="compaction"){Kl(e,t);return}if(t.stream!=="tool")return;const n=typeof t.sessionKey=="string"?t.sessionKey:void 0;if(n&&n!==e.sessionKey||!n&&e.chatRunId&&t.runId!==e.chatRunId||e.chatRunId&&t.runId!==e.chatRunId||!e.chatRunId)return;const s=t.data??{},i=typeof s.toolCallId=="string"?s.toolCallId:"";if(!i)return;const a=typeof s.name=="string"?s.name:"tool",o=typeof s.phase=="string"?s.phase:"",c=o==="start"?s.args:void 0,l=o==="update"?Qi(s.partialResult):o==="result"?Qi(s.result):void 0,p=Date.now();let d=e.toolStreamById.get(i);d?(d.name=a,c!==void 0&&(d.args=c),l!==void 0&&(d.output=l),d.updatedAt=p):(d={toolCallId:i,runId:t.runId,sessionKey:n,name:a,args:c,output:l,startedAt:typeof t.ts=="number"?t.ts:p,updatedAt:p,message:{}},e.toolStreamById.set(i,d),e.toolStreamOrder.push(i)),d.message=Ol(d),Dl(e),Fl(e,o==="result")}function ln(e,t=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);const n=()=>{const s=e.querySelector(".chat-thread");if(s){const i=getComputedStyle(s).overflowY;if(i==="auto"||i==="scroll"||s.scrollHeight-s.clientHeight>1)return s}return document.scrollingElement??document.documentElement};e.updateComplete.then(()=>{e.chatScrollFrame=requestAnimationFrame(()=>{e.chatScrollFrame=null;const s=n();if(!s)return;const i=s.scrollHeight-s.scrollTop-s.clientHeight;if(!(t||e.chatUserNearBottom||i<200))return;t&&(e.chatHasAutoScrolled=!0),s.scrollTop=s.scrollHeight,e.chatUserNearBottom=!0;const o=t?150:120;e.chatScrollTimeout=window.setTimeout(()=>{e.chatScrollTimeout=null;const c=n();if(!c)return;const l=c.scrollHeight-c.scrollTop-c.clientHeight;(t||e.chatUserNearBottom||l<200)&&(c.scrollTop=c.scrollHeight,e.chatUserNearBottom=!0)},o)})})}function ro(e,t=!1){e.logsScrollFrame&&cancelAnimationFrame(e.logsScrollFrame),e.updateComplete.then(()=>{e.logsScrollFrame=requestAnimationFrame(()=>{e.logsScrollFrame=null;const n=e.querySelector(".log-stream");if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;(t||s<80)&&(n.scrollTop=n.scrollHeight)})})}function zl(e,t){const n=t.currentTarget;if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;e.chatUserNearBottom=s<200}function jl(e,t){const n=t.currentTarget;if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;e.logsAtBottom=s<80}function ql(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function Vl(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
1
+ (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function s(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();const qt=globalThis,Cs=qt.ShadowRoot&&(qt.ShadyCSS===void 0||qt.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Es=Symbol(),Pi=new WeakMap;let Wa=class{constructor(t,n,s){if(this._$cssResult$=!0,s!==Es)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=n}get styleSheet(){let t=this.o;const n=this.t;if(Cs&&t===void 0){const s=n!==void 0&&n.length===1;s&&(t=Pi.get(n)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&Pi.set(n,t))}return t}toString(){return this.cssText}};const Dr=e=>new Wa(typeof e=="string"?e:e+"",void 0,Es),Br=(e,...t)=>{const n=e.length===1?e[0]:t.reduce((s,i,a)=>s+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+e[a+1],e[0]);return new Wa(n,e,Es)},Fr=(e,t)=>{if(Cs)e.adoptedStyleSheets=t.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(const n of t){const s=document.createElement("style"),i=qt.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=n.cssText,e.appendChild(s)}},Ni=Cs?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const s of t.cssRules)n+=s.cssText;return Dr(n)})(e):e;const{is:Ur,defineProperty:Kr,getOwnPropertyDescriptor:Hr,getOwnPropertyNames:zr,getOwnPropertySymbols:jr,getPrototypeOf:qr}=Object,nn=globalThis,Oi=nn.trustedTypes,Wr=Oi?Oi.emptyScript:"",Vr=nn.reactiveElementPolyfillSupport,yt=(e,t)=>e,Gt={toAttribute(e,t){switch(t){case Boolean:e=e?Wr:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=e!==null;break;case Number:n=e===null?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch{n=null}}return n}},Ls=(e,t)=>!Ur(e,t),Di={attribute:!0,type:String,converter:Gt,reflect:!1,useDefault:!1,hasChanged:Ls};Symbol.metadata??=Symbol("metadata"),nn.litPropertyMetadata??=new WeakMap;let Ye=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,n=Di){if(n.state&&(n.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((n=Object.create(n)).wrapped=!0),this.elementProperties.set(t,n),!n.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,n);i!==void 0&&Kr(this.prototype,t,i)}}static getPropertyDescriptor(t,n,s){const{get:i,set:a}=Hr(this.prototype,t)??{get(){return this[n]},set(o){this[n]=o}};return{get:i,set(o){const l=i?.call(this);a?.call(this,o),this.requestUpdate(t,l,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Di}static _$Ei(){if(this.hasOwnProperty(yt("elementProperties")))return;const t=qr(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(yt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(yt("properties"))){const n=this.properties,s=[...zr(n),...jr(n)];for(const i of s)this.createProperty(i,n[i])}const t=this[Symbol.metadata];if(t!==null){const n=litPropertyMetadata.get(t);if(n!==void 0)for(const[s,i]of n)this.elementProperties.set(s,i)}this._$Eh=new Map;for(const[n,s]of this.elementProperties){const i=this._$Eu(n,s);i!==void 0&&this._$Eh.set(i,n)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const n=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const i of s)n.unshift(Ni(i))}else t!==void 0&&n.push(Ni(t));return n}static _$Eu(t,n){const s=n.attribute;return s===!1?void 0:typeof s=="string"?s:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,n=this.constructor.elementProperties;for(const s of n.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Fr(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,n,s){this._$AK(t,s)}_$ET(t,n){const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(i!==void 0&&s.reflect===!0){const a=(s.converter?.toAttribute!==void 0?s.converter:Gt).toAttribute(n,s.type);this._$Em=t,a==null?this.removeAttribute(i):this.setAttribute(i,a),this._$Em=null}}_$AK(t,n){const s=this.constructor,i=s._$Eh.get(t);if(i!==void 0&&this._$Em!==i){const a=s.getPropertyOptions(i),o=typeof a.converter=="function"?{fromAttribute:a.converter}:a.converter?.fromAttribute!==void 0?a.converter:Gt;this._$Em=i;const l=o.fromAttribute(n,a.type);this[i]=l??this._$Ej?.get(i)??l,this._$Em=null}}requestUpdate(t,n,s,i=!1,a){if(t!==void 0){const o=this.constructor;if(i===!1&&(a=this[t]),s??=o.getPropertyOptions(t),!((s.hasChanged??Ls)(a,n)||s.useDefault&&s.reflect&&a===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,s))))return;this.C(t,n,s)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,n,{useDefault:s,reflect:i,wrapped:a},o){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,o??n??this[t]),a!==!0||o!==void 0)||(this._$AL.has(t)||(this.hasUpdated||s||(n=void 0),this._$AL.set(t,n)),i===!0&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(n){Promise.reject(n)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[i,a]of this._$Ep)this[i]=a;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[i,a]of s){const{wrapped:o}=a,l=this[i];o!==!0||this._$AL.has(i)||l===void 0||this.C(i,void 0,a,l)}}let t=!1;const n=this._$AL;try{t=this.shouldUpdate(n),t?(this.willUpdate(n),this._$EO?.forEach(s=>s.hostUpdate?.()),this.update(n)):this._$EM()}catch(s){throw t=!1,this._$EM(),s}t&&this._$AE(n)}willUpdate(t){}_$AE(t){this._$EO?.forEach(n=>n.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(n=>this._$ET(n,this[n])),this._$EM()}updated(t){}firstUpdated(t){}};Ye.elementStyles=[],Ye.shadowRootOptions={mode:"open"},Ye[yt("elementProperties")]=new Map,Ye[yt("finalized")]=new Map,Vr?.({ReactiveElement:Ye}),(nn.reactiveElementVersions??=[]).push("2.1.2");const Is=globalThis,Bi=e=>e,Yt=Is.trustedTypes,Fi=Yt?Yt.createPolicy("lit-html",{createHTML:e=>e}):void 0,Va="$lit$",xe=`lit$${Math.random().toFixed(9).slice(2)}$`,Ga="?"+xe,Gr=`<${Ga}>`,Oe=document,$t=()=>Oe.createComment(""),xt=e=>e===null||typeof e!="object"&&typeof e!="function",Ms=Array.isArray,Yr=e=>Ms(e)||typeof e?.[Symbol.iterator]=="function",Dn=`[
2
+ \f\r]`,rt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ui=/-->/g,Ki=/>/g,Le=RegExp(`>|${Dn}(?:([^\\s"'>=/]+)(${Dn}*=${Dn}*(?:[^
3
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Hi=/'/g,zi=/"/g,Ya=/^(?:script|style|textarea|title)$/i,Qr=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),c=Qr(1),Se=Symbol.for("lit-noChange"),h=Symbol.for("lit-nothing"),ji=new WeakMap,Pe=Oe.createTreeWalker(Oe,129);function Qa(e,t){if(!Ms(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return Fi!==void 0?Fi.createHTML(t):t}const Zr=(e,t)=>{const n=e.length-1,s=[];let i,a=t===2?"<svg>":t===3?"<math>":"",o=rt;for(let l=0;l<n;l++){const r=e[l];let p,d,u=-1,g=0;for(;g<r.length&&(o.lastIndex=g,d=o.exec(r),d!==null);)g=o.lastIndex,o===rt?d[1]==="!--"?o=Ui:d[1]!==void 0?o=Ki:d[2]!==void 0?(Ya.test(d[2])&&(i=RegExp("</"+d[2],"g")),o=Le):d[3]!==void 0&&(o=Le):o===Le?d[0]===">"?(o=i??rt,u=-1):d[1]===void 0?u=-2:(u=o.lastIndex-d[2].length,p=d[1],o=d[3]===void 0?Le:d[3]==='"'?zi:Hi):o===zi||o===Hi?o=Le:o===Ui||o===Ki?o=rt:(o=Le,i=void 0);const v=o===Le&&e[l+1].startsWith("/>")?" ":"";a+=o===rt?r+Gr:u>=0?(s.push(p),r.slice(0,u)+Va+r.slice(u)+xe+v):r+xe+(u===-2?l:v)}return[Qa(e,a+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]};let ns=class Za{constructor({strings:t,_$litType$:n},s){let i;this.parts=[];let a=0,o=0;const l=t.length-1,r=this.parts,[p,d]=Zr(t,n);if(this.el=Za.createElement(p,s),Pe.currentNode=this.el.content,n===2||n===3){const u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(i=Pe.nextNode())!==null&&r.length<l;){if(i.nodeType===1){if(i.hasAttributes())for(const u of i.getAttributeNames())if(u.endsWith(Va)){const g=d[o++],v=i.getAttribute(u).split(xe),w=/([.?@])?(.*)/.exec(g);r.push({type:1,index:a,name:w[2],strings:v,ctor:w[1]==="."?Xr:w[1]==="?"?el:w[1]==="@"?tl:an}),i.removeAttribute(u)}else u.startsWith(xe)&&(r.push({type:6,index:a}),i.removeAttribute(u));if(Ya.test(i.tagName)){const u=i.textContent.split(xe),g=u.length-1;if(g>0){i.textContent=Yt?Yt.emptyScript:"";for(let v=0;v<g;v++)i.append(u[v],$t()),Pe.nextNode(),r.push({type:2,index:++a});i.append(u[g],$t())}}}else if(i.nodeType===8)if(i.data===Ga)r.push({type:2,index:a});else{let u=-1;for(;(u=i.data.indexOf(xe,u+1))!==-1;)r.push({type:7,index:a}),u+=xe.length-1}a++}}static createElement(t,n){const s=Oe.createElement("template");return s.innerHTML=t,s}};function Je(e,t,n=e,s){if(t===Se)return t;let i=s!==void 0?n._$Co?.[s]:n._$Cl;const a=xt(t)?void 0:t._$litDirective$;return i?.constructor!==a&&(i?._$AO?.(!1),a===void 0?i=void 0:(i=new a(e),i._$AT(e,n,s)),s!==void 0?(n._$Co??=[])[s]=i:n._$Cl=i),i!==void 0&&(t=Je(e,i._$AS(e,t.values),i,s)),t}class Jr{constructor(t,n){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:n},parts:s}=this._$AD,i=(t?.creationScope??Oe).importNode(n,!0);Pe.currentNode=i;let a=Pe.nextNode(),o=0,l=0,r=s[0];for(;r!==void 0;){if(o===r.index){let p;r.type===2?p=new sn(a,a.nextSibling,this,t):r.type===1?p=new r.ctor(a,r.name,r.strings,this,t):r.type===6&&(p=new nl(a,this,t)),this._$AV.push(p),r=s[++l]}o!==r?.index&&(a=Pe.nextNode(),o++)}return Pe.currentNode=Oe,i}p(t){let n=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,n),n+=s.strings.length-2):s._$AI(t[n])),n++}}let sn=class Ja{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,n,s,i){this.type=2,this._$AH=h,this._$AN=void 0,this._$AA=t,this._$AB=n,this._$AM=s,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const n=this._$AM;return n!==void 0&&t?.nodeType===11&&(t=n.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,n=this){t=Je(this,t,n),xt(t)?t===h||t==null||t===""?(this._$AH!==h&&this._$AR(),this._$AH=h):t!==this._$AH&&t!==Se&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Yr(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==h&&xt(this._$AH)?this._$AA.nextSibling.data=t:this.T(Oe.createTextNode(t)),this._$AH=t}$(t){const{values:n,_$litType$:s}=t,i=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=ns.createElement(Qa(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(n);else{const a=new Jr(i,this),o=a.u(this.options);a.p(n),this.T(o),this._$AH=a}}_$AC(t){let n=ji.get(t.strings);return n===void 0&&ji.set(t.strings,n=new ns(t)),n}k(t){Ms(this._$AH)||(this._$AH=[],this._$AR());const n=this._$AH;let s,i=0;for(const a of t)i===n.length?n.push(s=new Ja(this.O($t()),this.O($t()),this,this.options)):s=n[i],s._$AI(a),i++;i<n.length&&(this._$AR(s&&s._$AB.nextSibling,i),n.length=i)}_$AR(t=this._$AA.nextSibling,n){for(this._$AP?.(!1,!0,n);t!==this._$AB;){const s=Bi(t).nextSibling;Bi(t).remove(),t=s}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}};class an{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,n,s,i,a){this.type=1,this._$AH=h,this._$AN=void 0,this.element=t,this.name=n,this._$AM=i,this.options=a,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=h}_$AI(t,n=this,s,i){const a=this.strings;let o=!1;if(a===void 0)t=Je(this,t,n,0),o=!xt(t)||t!==this._$AH&&t!==Se,o&&(this._$AH=t);else{const l=t;let r,p;for(t=a[0],r=0;r<a.length-1;r++)p=Je(this,l[s+r],n,r),p===Se&&(p=this._$AH[r]),o||=!xt(p)||p!==this._$AH[r],p===h?t=h:t!==h&&(t+=(p??"")+a[r+1]),this._$AH[r]=p}o&&!i&&this.j(t)}j(t){t===h?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let Xr=class extends an{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===h?void 0:t}},el=class extends an{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==h)}},tl=class extends an{constructor(t,n,s,i,a){super(t,n,s,i,a),this.type=5}_$AI(t,n=this){if((t=Je(this,t,n,0)??h)===Se)return;const s=this._$AH,i=t===h&&s!==h||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,a=t!==h&&(s===h||i);i&&this.element.removeEventListener(this.name,this,s),a&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},nl=class{constructor(t,n,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=n,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){Je(this,t)}};const sl={I:sn},il=Is.litHtmlPolyfillSupport;il?.(ns,sn),(Is.litHtmlVersions??=[]).push("3.3.2");const al=(e,t,n)=>{const s=n?.renderBefore??t;let i=s._$litPart$;if(i===void 0){const a=n?.renderBefore??null;s._$litPart$=i=new sn(t.insertBefore($t(),a),a,void 0,n??{})}return i._$AI(e),i};const Rs=globalThis;let Ze=class extends Ye{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=al(n,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Se}};Ze._$litElement$=!0,Ze.finalized=!0,Rs.litElementHydrateSupport?.({LitElement:Ze});const ol=Rs.litElementPolyfillSupport;ol?.({LitElement:Ze});(Rs.litElementVersions??=[]).push("4.2.2");const Xa=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const rl={attribute:!0,type:String,converter:Gt,reflect:!1,hasChanged:Ls},ll=(e=rl,t,n)=>{const{kind:s,metadata:i}=n;let a=globalThis.litPropertyMetadata.get(i);if(a===void 0&&globalThis.litPropertyMetadata.set(i,a=new Map),s==="setter"&&((e=Object.create(e)).wrapped=!0),a.set(n.name,e),s==="accessor"){const{name:o}=n;return{set(l){const r=t.get.call(this);t.set.call(this,l),this.requestUpdate(o,r,e,!0,l)},init(l){return l!==void 0&&this.C(o,void 0,e,l),l}}}if(s==="setter"){const{name:o}=n;return function(l){const r=this[o];t.call(this,l),this.requestUpdate(o,r,e,!0,l)}}throw Error("Unsupported decorator location: "+s)};function on(e){return(t,n)=>typeof n=="object"?ll(e,t,n):((s,i,a)=>{const o=i.hasOwnProperty(a);return i.constructor.createProperty(a,s),o?Object.getOwnPropertyDescriptor(i,a):void 0})(e,t,n)}function b(e){return on({...e,state:!0,attribute:!1})}const cl=50,dl=200,ul="Assistant";function qi(e,t){if(typeof e!="string")return;const n=e.trim();if(n)return n.length<=t?n:n.slice(0,t)}function ss(e){const t=qi(e?.name,cl)??ul,n=qi(e?.avatar??void 0,dl)??null;return{agentId:typeof e?.agentId=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function pl(){return ss(typeof window>"u"?{}:{name:window.__CLAWDBOT_ASSISTANT_NAME__,avatar:window.__CLAWDBOT_ASSISTANT_AVATAR__})}const eo="moltbot.control.settings.v1";function fl(){const t={gatewayUrl:`${location.protocol==="https:"?"wss":"ws"}://${location.host}`,token:"",sessionKey:"main",lastActiveSessionKey:"main",theme:"system",chatFocusMode:!1,chatShowThinking:!0,splitRatio:.6,navCollapsed:!1,navGroupsCollapsed:{}};try{const n=localStorage.getItem(eo);if(!n)return t;const s=JSON.parse(n);return{gatewayUrl:typeof s.gatewayUrl=="string"&&s.gatewayUrl.trim()?s.gatewayUrl.trim():t.gatewayUrl,token:typeof s.token=="string"?s.token:t.token,sessionKey:typeof s.sessionKey=="string"&&s.sessionKey.trim()?s.sessionKey.trim():t.sessionKey,lastActiveSessionKey:typeof s.lastActiveSessionKey=="string"&&s.lastActiveSessionKey.trim()?s.lastActiveSessionKey.trim():typeof s.sessionKey=="string"&&s.sessionKey.trim()||t.lastActiveSessionKey,theme:s.theme==="light"||s.theme==="dark"||s.theme==="system"?s.theme:t.theme,chatFocusMode:typeof s.chatFocusMode=="boolean"?s.chatFocusMode:t.chatFocusMode,chatShowThinking:typeof s.chatShowThinking=="boolean"?s.chatShowThinking:t.chatShowThinking,splitRatio:typeof s.splitRatio=="number"&&s.splitRatio>=.4&&s.splitRatio<=.7?s.splitRatio:t.splitRatio,navCollapsed:typeof s.navCollapsed=="boolean"?s.navCollapsed:t.navCollapsed,navGroupsCollapsed:typeof s.navGroupsCollapsed=="object"&&s.navGroupsCollapsed!==null?s.navGroupsCollapsed:t.navGroupsCollapsed}}catch{return t}}function hl(e){localStorage.setItem(eo,JSON.stringify(e))}function to(e){const t=(e??"").trim();if(!t)return null;const n=t.split(":").filter(Boolean);if(n.length<3||n[0]!=="agent")return null;const s=n[1]?.trim(),i=n.slice(2).join(":");return!s||!i?null:{agentId:s,rest:i}}const gl=[{label:"Chat",tabs:["chat"]},{label:"Control",tabs:["overview","channels","instances","sessions","cron"]},{label:"Agent",tabs:["skills","nodes"]},{label:"Settings",tabs:["config","debug","logs"]}],no={overview:"/overview",channels:"/channels",instances:"/instances",sessions:"/sessions",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",config:"/config",debug:"/debug",logs:"/logs"},so=new Map(Object.entries(no).map(([e,t])=>[t,e]));function rn(e){if(!e)return"";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t==="/"?"":(t.endsWith("/")&&(t=t.slice(0,-1)),t)}function kt(e){if(!e)return"/";let t=e.trim();return t.startsWith("/")||(t=`/${t}`),t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t}function Ps(e,t=""){const n=rn(t),s=no[e];return n?`${n}${s}`:s}function io(e,t=""){const n=rn(t);let s=e||"/";n&&(s===n?s="/":s.startsWith(`${n}/`)&&(s=s.slice(n.length)));let i=kt(s).toLowerCase();return i.endsWith("/index.html")&&(i="/"),i==="/"?"chat":so.get(i)??null}function vl(e){let t=kt(e);if(t.endsWith("/index.html")&&(t=kt(t.slice(0,-11))),t==="/")return"";const n=t.split("/").filter(Boolean);if(n.length===0)return"";for(let s=0;s<n.length;s++){const i=`/${n.slice(s).join("/")}`.toLowerCase();if(so.has(i)){const a=n.slice(0,s);return a.length?`/${a.join("/")}`:""}}return`/${n.join("/")}`}function ml(e){switch(e){case"chat":return"messageSquare";case"overview":return"barChart";case"channels":return"link";case"instances":return"radio";case"sessions":return"fileText";case"cron":return"loader";case"skills":return"zap";case"nodes":return"monitor";case"config":return"settings";case"debug":return"bug";case"logs":return"scrollText";default:return"folder"}}function is(e){switch(e){case"overview":return"Overview";case"channels":return"Channels";case"instances":return"Instances";case"sessions":return"Sessions";case"cron":return"Cron Jobs";case"skills":return"Skills";case"nodes":return"Nodes";case"chat":return"Chat";case"config":return"Config";case"debug":return"Debug";case"logs":return"Logs";default:return"Control"}}function yl(e){switch(e){case"overview":return"Gateway status, entry points, and a fast health read.";case"channels":return"Manage channels and settings.";case"instances":return"Presence beacons from connected clients and nodes.";case"sessions":return"Inspect active sessions and adjust per-session defaults.";case"cron":return"Schedule wakeups and recurring agent runs.";case"skills":return"Manage skill availability and API key injection.";case"nodes":return"Paired devices, capabilities, and command exposure.";case"chat":return"Direct gateway chat session for quick interventions.";case"config":return"Edit ~/.clawdbot/moltbot.json safely.";case"debug":return"Gateway snapshots, events, and manual RPC calls.";case"logs":return"Live tail of the gateway file logs.";default:return""}}const V={messageSquare:c`<svg viewBox="0 0 24 24"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>`,barChart:c`<svg viewBox="0 0 24 24"><line x1="12" x2="12" y1="20" y2="10"/><line x1="18" x2="18" y1="20" y2="4"/><line x1="6" x2="6" y1="20" y2="16"/></svg>`,link:c`<svg viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,radio:c`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="2"/><path d="M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"/></svg>`,fileText:c`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><line x1="16" x2="8" y1="13" y2="13"/><line x1="16" x2="8" y1="17" y2="17"/><line x1="10" x2="8" y1="9" y2="9"/></svg>`,zap:c`<svg viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>`,monitor:c`<svg viewBox="0 0 24 24"><rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/></svg>`,settings:c`<svg viewBox="0 0 24 24"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg>`,bug:c`<svg viewBox="0 0 24 24"><path d="m8 2 1.88 1.88"/><path d="M14.12 3.88 16 2"/><path d="M9 7.13v-1a3.003 3.003 0 1 1 6 0v1"/><path d="M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6"/><path d="M12 20v-9"/><path d="M6.53 9C4.6 8.8 3 7.1 3 5"/><path d="M6 13H2"/><path d="M3 21c0-2.1 1.7-3.9 3.8-4"/><path d="M20.97 5c0 2.1-1.6 3.8-3.5 4"/><path d="M22 13h-4"/><path d="M17.2 17c2.1.1 3.8 1.9 3.8 4"/></svg>`,scrollText:c`<svg viewBox="0 0 24 24"><path d="M8 21h12a2 2 0 0 0 2-2v-2H10v2a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v3h4"/><path d="M19 17V5a2 2 0 0 0-2-2H4"/><path d="M15 8h-5"/><path d="M15 12h-5"/></svg>`,folder:c`<svg viewBox="0 0 24 24"><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/></svg>`,menu:c`<svg viewBox="0 0 24 24"><line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="18" y2="18"/></svg>`,x:c`<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,check:c`<svg viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,copy:c`<svg viewBox="0 0 24 24"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`,search:c`<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,brain:c`<svg viewBox="0 0 24 24"><path d="M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z"/><path d="M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z"/><path d="M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4"/><path d="M17.599 6.5a3 3 0 0 0 .399-1.375"/><path d="M6.003 5.125A3 3 0 0 0 6.401 6.5"/><path d="M3.477 10.896a4 4 0 0 1 .585-.396"/><path d="M19.938 10.5a4 4 0 0 1 .585.396"/><path d="M6 18a4 4 0 0 1-1.967-.516"/><path d="M19.967 17.484A4 4 0 0 1 18 18"/></svg>`,book:c`<svg viewBox="0 0 24 24"><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"/></svg>`,loader:c`<svg viewBox="0 0 24 24"><path d="M12 2v4"/><path d="m16.2 7.8 2.9-2.9"/><path d="M18 12h4"/><path d="m16.2 16.2 2.9 2.9"/><path d="M12 18v4"/><path d="m4.9 19.1 2.9-2.9"/><path d="M2 12h4"/><path d="m4.9 4.9 2.9 2.9"/></svg>`,wrench:c`<svg viewBox="0 0 24 24"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/></svg>`,fileCode:c`<svg viewBox="0 0 24 24"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><path d="m10 13-2 2 2 2"/><path d="m14 17 2-2-2-2"/></svg>`,edit:c`<svg viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,penLine:c`<svg viewBox="0 0 24 24"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>`,paperclip:c`<svg viewBox="0 0 24 24"><path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>`,globe:c`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/></svg>`,image:c`<svg viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>`,smartphone:c`<svg viewBox="0 0 24 24"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/></svg>`,plug:c`<svg viewBox="0 0 24 24"><path d="M12 22v-5"/><path d="M9 8V2"/><path d="M15 8V2"/><path d="M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z"/></svg>`,circle:c`<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/></svg>`,puzzle:c`<svg viewBox="0 0 24 24"><path d="M19.439 7.85c-.049.322.059.648.289.878l1.568 1.568c.47.47.706 1.087.706 1.704s-.235 1.233-.706 1.704l-1.611 1.611a.98.98 0 0 1-.837.276c-.47-.07-.802-.48-.968-.925a2.501 2.501 0 1 0-3.214 3.214c.446.166.855.497.925.968a.979.979 0 0 1-.276.837l-1.61 1.61a2.404 2.404 0 0 1-1.705.707 2.402 2.402 0 0 1-1.704-.706l-1.568-1.568a1.026 1.026 0 0 0-.877-.29c-.493.074-.84.504-1.02.968a2.5 2.5 0 1 1-3.237-3.237c.464-.18.894-.527.967-1.02a1.026 1.026 0 0 0-.289-.877l-1.568-1.568A2.402 2.402 0 0 1 1.998 12c0-.617.236-1.234.706-1.704L4.23 8.77c.24-.24.581-.353.917-.303.515.076.874.54 1.02 1.02a2.5 2.5 0 1 0 3.237-3.237c-.48-.146-.944-.505-1.02-1.02a.98.98 0 0 1 .303-.917l1.526-1.526A2.402 2.402 0 0 1 11.998 2c.617 0 1.234.236 1.704.706l1.568 1.568c.23.23.556.338.877.29.493-.074.84-.504 1.02-.968a2.5 2.5 0 1 1 3.236 3.236c-.464.18-.894.527-.967 1.02Z"/></svg>`},bl=/<\s*\/?\s*(?:think(?:ing)?|thought|antthinking|final)\b/i,Dt=/<\s*\/?\s*final\b[^>]*>/gi,Wi=/<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^>]*>/gi;function wl(e,t){return e.trimStart()}function $l(e,t){if(!e||!bl.test(e))return e;let n=e;Dt.test(n)?(Dt.lastIndex=0,n=n.replace(Dt,"")):Dt.lastIndex=0,Wi.lastIndex=0;let s="",i=0,a=!1;for(const o of n.matchAll(Wi)){const l=o.index??0,r=o[1]==="/";a?r&&(a=!1):(s+=n.slice(i,l),r||(a=!0)),i=l+o[0].length}return s+=n.slice(i),wl(s)}function At(e){return!e&&e!==0?"n/a":new Date(e).toLocaleString()}function O(e){if(!e&&e!==0)return"n/a";const t=Date.now()-e;if(t<0)return"just now";const n=Math.round(t/1e3);if(n<60)return`${n}s ago`;const s=Math.round(n/60);if(s<60)return`${s}m ago`;const i=Math.round(s/60);return i<48?`${i}h ago`:`${Math.round(i/24)}d ago`}function ao(e){if(!e&&e!==0)return"n/a";if(e<1e3)return`${e}ms`;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.round(t/60);if(n<60)return`${n}m`;const s=Math.round(n/60);return s<48?`${s}h`:`${Math.round(s/24)}d`}function as(e){return!e||e.length===0?"none":e.filter(t=>!!(t&&t.trim())).join(", ")}function os(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function oo(e,t){return e.length<=t?{text:e,truncated:!1,total:e.length}:{text:e.slice(0,Math.max(0,t)),truncated:!0,total:e.length}}function Qt(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Bn(e){return $l(e)}const xl=/^\[([^\]]+)\]\s*/,kl=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],Fn=new WeakMap,Un=new WeakMap;function Al(e){return/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}Z\b/.test(e)||/\d{4}-\d{2}-\d{2} \d{2}:\d{2}\b/.test(e)?!0:kl.some(t=>e.startsWith(`${t} `))}function Kn(e){const t=e.match(xl);if(!t)return e;const n=t[1]??"";return Al(n)?e.slice(t[0].length):e}function rs(e){const t=e,n=typeof t.role=="string"?t.role:"",s=t.content;if(typeof s=="string")return n==="assistant"?Bn(s):Kn(s);if(Array.isArray(s)){const i=s.map(a=>{const o=a;return o.type==="text"&&typeof o.text=="string"?o.text:null}).filter(a=>typeof a=="string");if(i.length>0){const a=i.join(`
4
+ `);return n==="assistant"?Bn(a):Kn(a)}}return typeof t.text=="string"?n==="assistant"?Bn(t.text):Kn(t.text):null}function ro(e){if(!e||typeof e!="object")return rs(e);const t=e;if(Fn.has(t))return Fn.get(t)??null;const n=rs(e);return Fn.set(t,n),n}function Vi(e){const n=e.content,s=[];if(Array.isArray(n))for(const l of n){const r=l;if(r.type==="thinking"&&typeof r.thinking=="string"){const p=r.thinking.trim();p&&s.push(p)}}if(s.length>0)return s.join(`
5
+ `);const i=_l(e);if(!i)return null;const o=[...i.matchAll(/<\s*think(?:ing)?\s*>([\s\S]*?)<\s*\/\s*think(?:ing)?\s*>/gi)].map(l=>(l[1]??"").trim()).filter(Boolean);return o.length>0?o.join(`
6
+ `):null}function Sl(e){if(!e||typeof e!="object")return Vi(e);const t=e;if(Un.has(t))return Un.get(t)??null;const n=Vi(e);return Un.set(t,n),n}function _l(e){const t=e,n=t.content;if(typeof n=="string")return n;if(Array.isArray(n)){const s=n.map(i=>{const a=i;return a.type==="text"&&typeof a.text=="string"?a.text:null}).filter(i=>typeof i=="string");if(s.length>0)return s.join(`
7
+ `)}return typeof t.text=="string"?t.text:null}function Tl(e){const t=e.trim();if(!t)return"";const n=t.split(/\r?\n/).map(s=>s.trim()).filter(Boolean).map(s=>`_${s}_`);return n.length?["_Reasoning:_",...n].join(`
8
+ `):""}let Gi=!1;function Yi(e){e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<e.length;n++)t+=e[n].toString(16).padStart(2,"0");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Cl(){const e=new Uint8Array(16),t=Date.now();for(let n=0;n<e.length;n++)e[n]=Math.floor(Math.random()*256);return e[0]^=t&255,e[1]^=t>>>8&255,e[2]^=t>>>16&255,e[3]^=t>>>24&255,e}function El(){Gi||(Gi=!0,console.warn("[uuid] crypto API missing; falling back to weak randomness"))}function Ns(e=globalThis.crypto){if(e&&typeof e.randomUUID=="function")return e.randomUUID();if(e&&typeof e.getRandomValues=="function"){const t=new Uint8Array(16);return e.getRandomValues(t),Yi(t)}return El(),Yi(Cl())}async function Xe(e){if(!(!e.client||!e.connected)){e.chatLoading=!0,e.lastError=null;try{const t=await e.client.request("chat.history",{sessionKey:e.sessionKey,limit:200});e.chatMessages=Array.isArray(t.messages)?t.messages:[],e.chatThinkingLevel=t.thinkingLevel??null}catch(t){e.lastError=String(t)}finally{e.chatLoading=!1}}}function Ll(e){const t=/^data:([^;]+);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function Il(e,t,n){if(!e.client||!e.connected)return!1;const s=t.trim(),i=n&&n.length>0;if(!s&&!i)return!1;const a=Date.now(),o=[];if(s&&o.push({type:"text",text:s}),i)for(const p of n)o.push({type:"image",source:{type:"base64",media_type:p.mimeType,data:p.dataUrl}});e.chatMessages=[...e.chatMessages,{role:"user",content:o,timestamp:a}],e.chatSending=!0,e.lastError=null;const l=Ns();e.chatRunId=l,e.chatStream="",e.chatStreamStartedAt=a;const r=i?n.map(p=>{const d=Ll(p.dataUrl);return d?{type:"image",mimeType:d.mimeType,content:d.content}:null}).filter(p=>p!==null):void 0;try{return await e.client.request("chat.send",{sessionKey:e.sessionKey,message:s,deliver:!1,idempotencyKey:l,attachments:r}),!0}catch(p){const d=String(p);return e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,e.lastError=d,e.chatMessages=[...e.chatMessages,{role:"assistant",content:[{type:"text",text:"Error: "+d}],timestamp:Date.now()}],!1}finally{e.chatSending=!1}}async function Ml(e){if(!e.client||!e.connected)return!1;const t=e.chatRunId;try{return await e.client.request("chat.abort",t?{sessionKey:e.sessionKey,runId:t}:{sessionKey:e.sessionKey}),!0}catch(n){return e.lastError=String(n),!1}}function Rl(e,t){if(!t||t.sessionKey!==e.sessionKey)return null;if(t.runId&&e.chatRunId&&t.runId!==e.chatRunId)return t.state==="final"?"final":null;if(t.state==="delta"){const n=rs(t.message);if(typeof n=="string"){const s=e.chatStream??"";(!s||n.length>=s.length)&&(e.chatStream=n)}}else t.state==="final"||t.state==="aborted"?(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null):t.state==="error"&&(e.chatStream=null,e.chatRunId=null,e.chatStreamStartedAt=null,e.lastError=t.errorMessage??"chat error");return t.state}async function st(e){if(!(!e.client||!e.connected)&&!e.sessionsLoading){e.sessionsLoading=!0,e.sessionsError=null;try{const t={includeGlobal:e.sessionsIncludeGlobal,includeUnknown:e.sessionsIncludeUnknown},n=Qt(e.sessionsFilterActive,0),s=Qt(e.sessionsFilterLimit,0);n>0&&(t.activeMinutes=n),s>0&&(t.limit=s);const i=await e.client.request("sessions.list",t);i&&(e.sessionsResult=i)}catch(t){e.sessionsError=String(t)}finally{e.sessionsLoading=!1}}}async function Pl(e,t,n){if(!e.client||!e.connected)return;const s={key:t};"label"in n&&(s.label=n.label),"thinkingLevel"in n&&(s.thinkingLevel=n.thinkingLevel),"verboseLevel"in n&&(s.verboseLevel=n.verboseLevel),"reasoningLevel"in n&&(s.reasoningLevel=n.reasoningLevel);try{await e.client.request("sessions.patch",s),await st(e)}catch(i){e.sessionsError=String(i)}}async function Nl(e,t){if(!(!e.client||!e.connected||e.sessionsLoading||!window.confirm(`Delete session "${t}"?
9
+
10
+ Deletes the session entry and archives its transcript.`))){e.sessionsLoading=!0,e.sessionsError=null;try{await e.client.request("sessions.delete",{key:t,deleteTranscript:!0}),await st(e)}catch(s){e.sessionsError=String(s)}finally{e.sessionsLoading=!1}}}const Qi=50,Ol=80,Dl=12e4;function Bl(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.text=="string")return t.text;const n=t.content;if(!Array.isArray(n))return null;const s=n.map(i=>{if(!i||typeof i!="object")return null;const a=i;return a.type==="text"&&typeof a.text=="string"?a.text:null}).filter(i=>!!i);return s.length===0?null:s.join(`
11
+ `)}function Zi(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=Bl(e);let n;if(typeof e=="string")n=e;else if(t)n=t;else try{n=JSON.stringify(e,null,2)}catch{n=String(e)}const s=oo(n,Dl);return s.truncated?`${s.text}
12
+
13
+ … truncated (${s.total} chars, showing first ${s.text.length}).`:s.text}function Fl(e){const t=[];return t.push({type:"toolcall",name:e.name,arguments:e.args??{}}),e.output&&t.push({type:"toolresult",name:e.name,text:e.output}),{role:"assistant",toolCallId:e.toolCallId,runId:e.runId,content:t,timestamp:e.startedAt}}function Ul(e){if(e.toolStreamOrder.length<=Qi)return;const t=e.toolStreamOrder.length-Qi,n=e.toolStreamOrder.splice(0,t);for(const s of n)e.toolStreamById.delete(s)}function Kl(e){e.chatToolMessages=e.toolStreamOrder.map(t=>e.toolStreamById.get(t)?.message).filter(t=>!!t)}function ls(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),Kl(e)}function Hl(e,t=!1){if(t){ls(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>ls(e),Ol))}function ln(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],ls(e)}const zl=5e3;function jl(e,t){const n=t.data??{},s=typeof n.phase=="string"?n.phase:"";e.compactionClearTimer!=null&&(window.clearTimeout(e.compactionClearTimer),e.compactionClearTimer=null),s==="start"?e.compactionStatus={active:!0,startedAt:Date.now(),completedAt:null}:s==="end"&&(e.compactionStatus={active:!1,startedAt:e.compactionStatus?.startedAt??null,completedAt:Date.now()},e.compactionClearTimer=window.setTimeout(()=>{e.compactionStatus=null,e.compactionClearTimer=null},zl))}function ql(e,t){if(!t)return;if(t.stream==="compaction"){jl(e,t);return}if(t.stream!=="tool")return;const n=typeof t.sessionKey=="string"?t.sessionKey:void 0;if(n&&n!==e.sessionKey||!n&&e.chatRunId&&t.runId!==e.chatRunId||e.chatRunId&&t.runId!==e.chatRunId||!e.chatRunId)return;const s=t.data??{},i=typeof s.toolCallId=="string"?s.toolCallId:"";if(!i)return;const a=typeof s.name=="string"?s.name:"tool",o=typeof s.phase=="string"?s.phase:"",l=o==="start"?s.args:void 0,r=o==="update"?Zi(s.partialResult):o==="result"?Zi(s.result):void 0,p=Date.now();let d=e.toolStreamById.get(i);d?(d.name=a,l!==void 0&&(d.args=l),r!==void 0&&(d.output=r),d.updatedAt=p):(d={toolCallId:i,runId:t.runId,sessionKey:n,name:a,args:l,output:r,startedAt:typeof t.ts=="number"?t.ts:p,updatedAt:p,message:{}},e.toolStreamById.set(i,d),e.toolStreamOrder.push(i)),d.message=Fl(d),Ul(e),Hl(e,o==="result")}function cn(e,t=!1){e.chatScrollFrame&&cancelAnimationFrame(e.chatScrollFrame),e.chatScrollTimeout!=null&&(clearTimeout(e.chatScrollTimeout),e.chatScrollTimeout=null);const n=()=>{const s=e.querySelector(".chat-thread");if(s){const i=getComputedStyle(s).overflowY;if(i==="auto"||i==="scroll"||s.scrollHeight-s.clientHeight>1)return s}return document.scrollingElement??document.documentElement};e.updateComplete.then(()=>{e.chatScrollFrame=requestAnimationFrame(()=>{e.chatScrollFrame=null;const s=n();if(!s)return;const i=s.scrollHeight-s.scrollTop-s.clientHeight;if(!(t||e.chatUserNearBottom||i<200))return;t&&(e.chatHasAutoScrolled=!0),s.scrollTop=s.scrollHeight,e.chatUserNearBottom=!0;const o=t?150:120;e.chatScrollTimeout=window.setTimeout(()=>{e.chatScrollTimeout=null;const l=n();if(!l)return;const r=l.scrollHeight-l.scrollTop-l.clientHeight;(t||e.chatUserNearBottom||r<200)&&(l.scrollTop=l.scrollHeight,e.chatUserNearBottom=!0)},o)})})}function lo(e,t=!1){e.logsScrollFrame&&cancelAnimationFrame(e.logsScrollFrame),e.updateComplete.then(()=>{e.logsScrollFrame=requestAnimationFrame(()=>{e.logsScrollFrame=null;const n=e.querySelector(".log-stream");if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;(t||s<80)&&(n.scrollTop=n.scrollHeight)})})}function Wl(e,t){const n=t.currentTarget;if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;e.chatUserNearBottom=s<200}function Vl(e,t){const n=t.currentTarget;if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;e.logsAtBottom=s<80}function Gl(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function Yl(e,t){if(e.length===0)return;const n=new Blob([`${e.join(`
14
14
  `)}
15
- `],{type:"text/plain"}),s=URL.createObjectURL(n),i=document.createElement("a"),a=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");i.href=s,i.download=`clawdbot-logs-${t}-${a}.log`,i.click(),URL.revokeObjectURL(s)}function Wl(e){if(typeof ResizeObserver>"u")return;const t=e.querySelector(".topbar");if(!t)return;const n=()=>{const{height:s}=t.getBoundingClientRect();e.style.setProperty("--topbar-height",`${s}px`)};n(),e.topbarObserver=new ResizeObserver(()=>n()),e.topbarObserver.observe(t)}function De(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function et(e){return`${JSON.stringify(e,null,2).trimEnd()}
16
- `}function lo(e,t,n){if(t.length===0)return;let s=e;for(let a=0;a<t.length-1;a+=1){const o=t[a],c=t[a+1];if(typeof o=="number"){if(!Array.isArray(s))return;s[o]==null&&(s[o]=typeof c=="number"?[]:{}),s=s[o]}else{if(typeof s!="object"||s==null)return;const l=s;l[o]==null&&(l[o]=typeof c=="number"?[]:{}),s=l[o]}}const i=t[t.length-1];if(typeof i=="number"){Array.isArray(s)&&(s[i]=n);return}typeof s=="object"&&s!=null&&(s[i]=n)}function co(e,t){if(t.length===0)return;let n=e;for(let i=0;i<t.length-1;i+=1){const a=t[i];if(typeof a=="number"){if(!Array.isArray(n))return;n=n[a]}else{if(typeof n!="object"||n==null)return;n=n[a]}if(n==null)return}const s=t[t.length-1];if(typeof s=="number"){Array.isArray(n)&&n.splice(s,1);return}typeof n=="object"&&n!=null&&delete n[s]}async function be(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});Yl(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function uo(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});Gl(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function Gl(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function Yl(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?et(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=et(e.configForm):e.configRaw=n,e.configValid=typeof t.valid=="boolean"?t.valid:null,e.configIssues=Array.isArray(t.issues)?t.issues:[],e.configFormDirty||(e.configForm=De(t.config??{}),e.configFormOriginal=De(t.config??{}),e.configRawOriginal=n)}async function ls(e){if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const t=e.configFormMode==="form"&&e.configForm?et(e.configForm):e.configRaw,n=e.configSnapshot?.hash;if(!n){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.set",{raw:t,baseHash:n}),e.configFormDirty=!1,await be(e)}catch(t){e.lastError=String(t)}finally{e.configSaving=!1}}}async function Ql(e){if(!(!e.client||!e.connected)){e.configApplying=!0,e.lastError=null;try{const t=e.configFormMode==="form"&&e.configForm?et(e.configForm):e.configRaw,n=e.configSnapshot?.hash;if(!n){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.apply",{raw:t,baseHash:n,sessionKey:e.applySessionKey}),e.configFormDirty=!1,await be(e)}catch(t){e.lastError=String(t)}finally{e.configApplying=!1}}}async function Zl(e){if(!(!e.client||!e.connected)){e.updateRunning=!0,e.lastError=null;try{await e.client.request("update.run",{sessionKey:e.applySessionKey})}catch(t){e.lastError=String(t)}finally{e.updateRunning=!1}}}function Bt(e,t,n){const s=De(e.configForm??e.configSnapshot?.config??{});lo(s,t,n),e.configForm=s,e.configFormDirty=!0,e.configFormMode==="form"&&(e.configRaw=et(s))}function Zi(e,t){const n=De(e.configForm??e.configSnapshot?.config??{});co(n,t),e.configForm=n,e.configFormDirty=!0,e.configFormMode==="form"&&(e.configRaw=et(n))}async function Tt(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("cron.status",{});e.cronStatus=t}catch(t){e.cronError=String(t)}}async function cn(e){if(!(!e.client||!e.connected)&&!e.cronLoading){e.cronLoading=!0,e.cronError=null;try{const t=await e.client.request("cron.list",{includeDisabled:!0});e.cronJobs=Array.isArray(t.jobs)?t.jobs:[]}catch(t){e.cronError=String(t)}finally{e.cronLoading=!1}}}function Jl(e){if(e.scheduleKind==="at"){const n=Date.parse(e.scheduleAt);if(!Number.isFinite(n))throw new Error("Invalid run time.");return{kind:"at",atMs:n}}if(e.scheduleKind==="every"){const n=Qt(e.everyAmount,0);if(n<=0)throw new Error("Invalid interval amount.");const s=e.everyUnit;return{kind:"every",everyMs:n*(s==="minutes"?6e4:s==="hours"?36e5:864e5)}}const t=e.cronExpr.trim();if(!t)throw new Error("Cron expression required.");return{kind:"cron",expr:t,tz:e.cronTz.trim()||void 0}}function Xl(e){if(e.payloadKind==="systemEvent"){const i=e.payloadText.trim();if(!i)throw new Error("System event text required.");return{kind:"systemEvent",text:i}}const t=e.payloadText.trim();if(!t)throw new Error("Agent message required.");const n={kind:"agentTurn",message:t};e.deliver&&(n.deliver=!0),e.channel&&(n.channel=e.channel),e.to.trim()&&(n.to=e.to.trim());const s=Qt(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function ec(e){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const t=Jl(e.cronForm),n=Xl(e.cronForm),s=e.cronForm.agentId.trim(),i={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:s||void 0,enabled:e.cronForm.enabled,schedule:t,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:n,isolation:e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?{postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:void 0};if(!i.name)throw new Error("Name required.");await e.client.request("cron.add",i),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await cn(e),await Tt(e)}catch(t){e.cronError=String(t)}finally{e.cronBusy=!1}}}async function tc(e,t,n){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.update",{id:t.id,patch:{enabled:n}}),await cn(e),await Tt(e)}catch(s){e.cronError=String(s)}finally{e.cronBusy=!1}}}async function nc(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.run",{id:t.id,mode:"force"}),await po(e,t.id)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function sc(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.remove",{id:t.id}),e.cronRunsJobId===t.id&&(e.cronRunsJobId=null,e.cronRuns=[]),await cn(e),await Tt(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function po(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("cron.runs",{id:t,limit:50});e.cronRunsJobId=t,e.cronRuns=Array.isArray(n.entries)?n.entries:[]}catch(n){e.cronError=String(n)}}async function oe(e,t){if(!(!e.client||!e.connected)&&!e.channelsLoading){e.channelsLoading=!0,e.channelsError=null;try{const n=await e.client.request("channels.status",{probe:t,timeoutMs:8e3});e.channelsSnapshot=n,e.channelsLastSuccess=Date.now()}catch(n){e.channelsError=String(n)}finally{e.channelsLoading=!1}}}async function ic(e,t){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{const n=await e.client.request("web.login.start",{force:t,timeoutMs:3e4});e.whatsappLoginMessage=n.message??null,e.whatsappLoginQrDataUrl=n.qrDataUrl??null,e.whatsappLoginConnected=null}catch(n){e.whatsappLoginMessage=String(n),e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function ac(e){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{const t=await e.client.request("web.login.wait",{timeoutMs:12e4});e.whatsappLoginMessage=t.message??null,e.whatsappLoginConnected=t.connected??null,t.connected&&(e.whatsappLoginQrDataUrl=null)}catch(t){e.whatsappLoginMessage=String(t),e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function oc(e){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{await e.client.request("channels.logout",{channel:"whatsapp"}),e.whatsappLoginMessage="Logged out.",e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}catch(t){e.whatsappLoginMessage=String(t)}finally{e.whatsappBusy=!1}}}async function dn(e){if(!(!e.client||!e.connected)&&!e.debugLoading){e.debugLoading=!0;try{const[t,n,s,i]=await Promise.all([e.client.request("status",{}),e.client.request("health",{}),e.client.request("models.list",{}),e.client.request("last-heartbeat",{})]);e.debugStatus=t,e.debugHealth=n;const a=s;e.debugModels=Array.isArray(a?.models)?a?.models:[],e.debugHeartbeat=i}catch(t){e.debugCallError=String(t)}finally{e.debugLoading=!1}}}async function rc(e){if(!(!e.client||!e.connected)){e.debugCallError=null,e.debugCallResult=null;try{const t=e.debugCallParams.trim()?JSON.parse(e.debugCallParams):{},n=await e.client.request(e.debugCallMethod.trim(),t);e.debugCallResult=JSON.stringify(n,null,2)}catch(t){e.debugCallError=String(t)}}}const lc=2e3,cc=new Set(["trace","debug","info","warn","error","fatal"]);function dc(e){if(typeof e!="string")return null;const t=e.trim();if(!t.startsWith("{")||!t.endsWith("}"))return null;try{const n=JSON.parse(t);return!n||typeof n!="object"?null:n}catch{return null}}function uc(e){if(typeof e!="string")return null;const t=e.toLowerCase();return cc.has(t)?t:null}function pc(e){if(!e.trim())return{raw:e,message:e};try{const t=JSON.parse(e),n=t&&typeof t._meta=="object"&&t._meta!==null?t._meta:null,s=typeof t.time=="string"?t.time:typeof n?.date=="string"?n?.date:null,i=uc(n?.logLevelName??n?.level),a=typeof t[0]=="string"?t[0]:typeof n?.name=="string"?n?.name:null,o=dc(a);let c=null;o&&(typeof o.subsystem=="string"?c=o.subsystem:typeof o.module=="string"&&(c=o.module)),!c&&a&&a.length<120&&(c=a);let l=null;return typeof t[1]=="string"?l=t[1]:!o&&typeof t[0]=="string"?l=t[0]:typeof t.message=="string"&&(l=t.message),{raw:e,time:s,level:i,subsystem:c,message:l??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function Os(e,t){if(!(!e.client||!e.connected)&&!(e.logsLoading&&!t?.quiet)){t?.quiet||(e.logsLoading=!0),e.logsError=null;try{const s=await e.client.request("logs.tail",{cursor:t?.reset?void 0:e.logsCursor??void 0,limit:e.logsLimit,maxBytes:e.logsMaxBytes}),a=(Array.isArray(s.lines)?s.lines.filter(c=>typeof c=="string"):[]).map(pc),o=!!(t?.reset||s.reset||e.logsCursor==null);e.logsEntries=o?a:[...e.logsEntries,...a].slice(-lc),typeof s.cursor=="number"&&(e.logsCursor=s.cursor),typeof s.file=="string"&&(e.logsFile=s.file),e.logsTruncated=!!s.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t?.quiet||(e.logsLoading=!1)}}}const fo={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:V,n:Vt,Gx:Ji,Gy:Xi,a:Kn,d:Hn,h:fc}=fo,Be=32,Ds=64,hc=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},H=(e="")=>{const t=new Error(e);throw hc(t,H),t},gc=e=>typeof e=="bigint",vc=e=>typeof e=="string",mc=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",_e=(e,t,n="")=>{const s=mc(e),i=e?.length,a=t!==void 0;if(!s||a&&i!==t){const o=n&&`"${n}" `,c=a?` of length ${t}`:"",l=s?`length=${i}`:`type=${typeof e}`;H(o+"expected Uint8Array"+c+", got "+l)}return e},un=e=>new Uint8Array(e),ho=e=>Uint8Array.from(e),go=(e,t)=>e.toString(16).padStart(t,"0"),vo=e=>Array.from(_e(e)).map(t=>go(t,2)).join(""),ve={_0:48,_9:57,A:65,F:70,a:97,f:102},ea=e=>{if(e>=ve._0&&e<=ve._9)return e-ve._0;if(e>=ve.A&&e<=ve.F)return e-(ve.A-10);if(e>=ve.a&&e<=ve.f)return e-(ve.a-10)},mo=e=>{const t="hex invalid";if(!vc(e))return H(t);const n=e.length,s=n/2;if(n%2)return H(t);const i=un(s);for(let a=0,o=0;a<s;a++,o+=2){const c=ea(e.charCodeAt(o)),l=ea(e.charCodeAt(o+1));if(c===void 0||l===void 0)return H(t);i[a]=c*16+l}return i},bo=()=>globalThis?.crypto,bc=()=>bo()?.subtle??H("crypto.subtle must be defined, consider polyfill"),St=(...e)=>{const t=un(e.reduce((s,i)=>s+_e(i).length,0));let n=0;return e.forEach(s=>{t.set(s,n),n+=s.length}),t},yc=(e=Be)=>bo().getRandomValues(un(e)),Zt=BigInt,Re=(e,t,n,s="bad number: out of range")=>gc(e)&&t<=e&&e<n?e:H(s),A=(e,t=V)=>{const n=e%t;return n>=0n?n:t+n},yo=e=>A(e,Vt),wc=(e,t)=>{(e===0n||t<=0n)&&H("no inverse n="+e+" mod="+t);let n=A(e,t),s=t,i=0n,a=1n;for(;n!==0n;){const o=s/n,c=s%n,l=i-a*o;s=n,n=c,i=a,a=l}return s===1n?A(i,t):H("no inverse")},$c=e=>{const t=ko[e];return typeof t!="function"&&H("hashes."+e+" not set"),t},zn=e=>e instanceof ee?e:H("Point expected"),cs=2n**256n;class ee{static BASE;static ZERO;X;Y;Z;T;constructor(t,n,s,i){const a=cs;this.X=Re(t,0n,a),this.Y=Re(n,0n,a),this.Z=Re(s,1n,a),this.T=Re(i,0n,a),Object.freeze(this)}static CURVE(){return fo}static fromAffine(t){return new ee(t.x,t.y,1n,A(t.x*t.y))}static fromBytes(t,n=!1){const s=Hn,i=ho(_e(t,Be)),a=t[31];i[31]=a&-129;const o=$o(i);Re(o,0n,n?cs:V);const l=A(o*o),p=A(l-1n),d=A(s*l+1n);let{isValid:u,value:h}=kc(p,d);u||H("bad point: y not sqrt");const v=(h&1n)===1n,w=(a&128)!==0;return!n&&h===0n&&w&&H("bad point: x==0, isLastByteOdd"),w!==v&&(h=A(-h)),new ee(h,o,1n,A(h*o))}static fromHex(t,n){return ee.fromBytes(mo(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=Kn,n=Hn,s=this;if(s.is0())return H("bad point: ZERO");const{X:i,Y:a,Z:o,T:c}=s,l=A(i*i),p=A(a*a),d=A(o*o),u=A(d*d),h=A(l*t),v=A(d*A(h+p)),w=A(u+A(n*A(l*p)));if(v!==w)return H("bad point: equation left != right (1)");const $=A(i*a),k=A(o*c);return $!==k?H("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:s,Z:i}=this,{X:a,Y:o,Z:c}=zn(t),l=A(n*c),p=A(a*i),d=A(s*c),u=A(o*i);return l===p&&d===u}is0(){return this.equals(Qe)}negate(){return new ee(A(-this.X),this.Y,this.Z,A(-this.T))}double(){const{X:t,Y:n,Z:s}=this,i=Kn,a=A(t*t),o=A(n*n),c=A(2n*A(s*s)),l=A(i*a),p=t+n,d=A(A(p*p)-a-o),u=l+o,h=u-c,v=l-o,w=A(d*h),$=A(u*v),k=A(d*v),T=A(h*u);return new ee(w,$,T,k)}add(t){const{X:n,Y:s,Z:i,T:a}=this,{X:o,Y:c,Z:l,T:p}=zn(t),d=Kn,u=Hn,h=A(n*o),v=A(s*c),w=A(a*u*p),$=A(i*l),k=A((n+s)*(o+c)-h-v),T=A($-w),M=A($+w),P=A(v-d*h),L=A(k*T),C=A(M*P),E=A(k*P),pe=A(T*M);return new ee(L,C,pe,E)}subtract(t){return this.add(zn(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return Qe;if(Re(t,1n,Vt),t===1n)return this;if(this.equals(Fe))return Pc(t).p;let s=Qe,i=Fe;for(let a=this;t>0n;a=a.double(),t>>=1n)t&1n?s=s.add(a):n&&(i=i.add(a));return s}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:n,Z:s}=this;if(this.equals(Qe))return{x:0n,y:1n};const i=wc(s,V);A(s*i)!==1n&&H("invalid inverse");const a=A(t*i),o=A(n*i);return{x:a,y:o}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),s=wo(n);return s[31]|=t&1n?128:0,s}toHex(){return vo(this.toBytes())}clearCofactor(){return this.multiply(Zt(fc),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(Vt/2n,!1).double();return Vt%2n&&(t=t.add(this)),t.is0()}}const Fe=new ee(Ji,Xi,1n,A(Ji*Xi)),Qe=new ee(0n,1n,1n,0n);ee.BASE=Fe;ee.ZERO=Qe;const wo=e=>mo(go(Re(e,0n,cs),Ds)).reverse(),$o=e=>Zt("0x"+vo(ho(_e(e)).reverse())),ce=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=V;return n},xc=e=>{const n=e*e%V*e%V,s=ce(n,2n)*n%V,i=ce(s,1n)*e%V,a=ce(i,5n)*i%V,o=ce(a,10n)*a%V,c=ce(o,20n)*o%V,l=ce(c,40n)*c%V,p=ce(l,80n)*l%V,d=ce(p,80n)*l%V,u=ce(d,10n)*a%V;return{pow_p_5_8:ce(u,2n)*e%V,b2:n}},ta=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,kc=(e,t)=>{const n=A(t*t*t),s=A(n*n*t),i=xc(e*s).pow_p_5_8;let a=A(e*n*i);const o=A(t*a*a),c=a,l=A(a*ta),p=o===e,d=o===A(-e),u=o===A(-e*ta);return p&&(a=c),(d||u)&&(a=l),(A(a)&1n)===1n&&(a=A(-a)),{isValid:p||d,value:a}},ds=e=>yo($o(e)),Bs=(...e)=>ko.sha512Async(St(...e)),Ac=(...e)=>$c("sha512")(St(...e)),xo=e=>{const t=e.slice(0,Be);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(Be,Ds),s=ds(t),i=Fe.multiply(s),a=i.toBytes();return{head:t,prefix:n,scalar:s,point:i,pointBytes:a}},Fs=e=>Bs(_e(e,Be)).then(xo),Sc=e=>xo(Ac(_e(e,Be))),_c=e=>Fs(e).then(t=>t.pointBytes),Tc=e=>Bs(e.hashable).then(e.finish),Cc=(e,t,n)=>{const{pointBytes:s,scalar:i}=e,a=ds(t),o=Fe.multiply(a).toBytes();return{hashable:St(o,s,n),finish:p=>{const d=yo(a+ds(p)*i);return _e(St(o,wo(d)),Ds)}}},Ec=async(e,t)=>{const n=_e(e),s=await Fs(t),i=await Bs(s.prefix,n);return Tc(Cc(s,i,n))},ko={sha512Async:async e=>{const t=bc(),n=St(e);return un(await t.digest("SHA-512",n.buffer))},sha512:void 0},Lc=(e=yc(Be))=>e,Mc={getExtendedPublicKeyAsync:Fs,getExtendedPublicKey:Sc,randomSecretKey:Lc},Jt=8,Ic=256,Ao=Math.ceil(Ic/Jt)+1,us=2**(Jt-1),Rc=()=>{const e=[];let t=Fe,n=t;for(let s=0;s<Ao;s++){n=t,e.push(n);for(let i=1;i<us;i++)n=n.add(t),e.push(n);t=n.double()}return e};let na;const sa=(e,t)=>{const n=t.negate();return e?n:t},Pc=e=>{const t=na||(na=Rc());let n=Qe,s=Fe;const i=2**Jt,a=i,o=Zt(i-1),c=Zt(Jt);for(let l=0;l<Ao;l++){let p=Number(e&o);e>>=c,p>us&&(p-=a,e+=1n);const d=l*us,u=d,h=d+Math.abs(p)-1,v=l%2!==0,w=p<0;p===0?s=s.add(sa(v,t[u])):n=n.add(sa(w,t[h]))}return e!==0n&&H("invalid wnaf"),{p:n,f:s}},jn="clawdbot-device-identity-v1";function ps(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replaceAll("+","-").replaceAll("/","_").replace(/=+$/g,"")}function So(e){const t=e.replaceAll("-","+").replaceAll("_","/"),n=t+"=".repeat((4-t.length%4)%4),s=atob(n),i=new Uint8Array(s.length);for(let a=0;a<s.length;a+=1)i[a]=s.charCodeAt(a);return i}function Nc(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function _o(e){const t=await crypto.subtle.digest("SHA-256",e);return Nc(new Uint8Array(t))}async function Oc(){const e=Mc.randomSecretKey(),t=await _c(e);return{deviceId:await _o(t),publicKey:ps(t),privateKey:ps(e)}}async function Us(){try{const n=localStorage.getItem(jn);if(n){const s=JSON.parse(n);if(s?.version===1&&typeof s.deviceId=="string"&&typeof s.publicKey=="string"&&typeof s.privateKey=="string"){const i=await _o(So(s.publicKey));if(i!==s.deviceId){const a={...s,deviceId:i};return localStorage.setItem(jn,JSON.stringify(a)),{deviceId:i,publicKey:s.publicKey,privateKey:s.privateKey}}return{deviceId:s.deviceId,publicKey:s.publicKey,privateKey:s.privateKey}}}}catch{}const e=await Oc(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(jn,JSON.stringify(t)),e}async function Dc(e,t){const n=So(e),s=new TextEncoder().encode(t),i=await Ec(s,n);return ps(i)}const To="clawdbot.device.auth.v1";function Ks(e){return e.trim()}function Bc(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e){const s=n.trim();s&&t.add(s)}return[...t].sort()}function Hs(){try{const e=window.localStorage.getItem(To);if(!e)return null;const t=JSON.parse(e);return!t||t.version!==1||!t.deviceId||typeof t.deviceId!="string"||!t.tokens||typeof t.tokens!="object"?null:t}catch{return null}}function Co(e){try{window.localStorage.setItem(To,JSON.stringify(e))}catch{}}function Fc(e){const t=Hs();if(!t||t.deviceId!==e.deviceId)return null;const n=Ks(e.role),s=t.tokens[n];return!s||typeof s.token!="string"?null:s}function Eo(e){const t=Ks(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},s=Hs();s&&s.deviceId===e.deviceId&&(n.tokens={...s.tokens});const i={token:e.token,role:t,scopes:Bc(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=i,Co(n),i}function Lo(e){const t=Hs();if(!t||t.deviceId!==e.deviceId)return;const n=Ks(e.role);if(!t.tokens[n])return;const s={...t,tokens:{...t.tokens}};delete s.tokens[n],Co(s)}async function Te(e,t){if(!(!e.client||!e.connected)&&!e.devicesLoading){e.devicesLoading=!0,t?.quiet||(e.devicesError=null);try{const n=await e.client.request("device.pair.list",{});e.devicesList={pending:Array.isArray(n?.pending)?n.pending:[],paired:Array.isArray(n?.paired)?n.paired:[]}}catch(n){t?.quiet||(e.devicesError=String(n))}finally{e.devicesLoading=!1}}}async function Uc(e,t){if(!(!e.client||!e.connected))try{await e.client.request("device.pair.approve",{requestId:t}),await Te(e)}catch(n){e.devicesError=String(n)}}async function Kc(e,t){if(!(!e.client||!e.connected||!window.confirm("Reject this device pairing request?")))try{await e.client.request("device.pair.reject",{requestId:t}),await Te(e)}catch(s){e.devicesError=String(s)}}async function Hc(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("device.token.rotate",t);if(n?.token){const s=await Us(),i=n.role??t.role;(n.deviceId===s.deviceId||t.deviceId===s.deviceId)&&Eo({deviceId:s.deviceId,role:i,token:n.token,scopes:n.scopes??t.scopes??[]}),window.prompt("New device token (copy and store securely):",n.token)}await Te(e)}catch(n){e.devicesError=String(n)}}async function zc(e,t){if(!(!e.client||!e.connected||!window.confirm(`Revoke token for ${t.deviceId} (${t.role})?`)))try{await e.client.request("device.token.revoke",t);const s=await Us();t.deviceId===s.deviceId&&Lo({deviceId:s.deviceId,role:t.role}),await Te(e)}catch(s){e.devicesError=String(s)}}async function pn(e,t){if(!(!e.client||!e.connected)&&!e.nodesLoading){e.nodesLoading=!0,t?.quiet||(e.lastError=null);try{const n=await e.client.request("node.list",{});e.nodes=Array.isArray(n.nodes)?n.nodes:[]}catch(n){t?.quiet||(e.lastError=String(n))}finally{e.nodesLoading=!1}}}function jc(e){if(!e||e.kind==="gateway")return{method:"exec.approvals.get",params:{}};const t=e.nodeId.trim();return t?{method:"exec.approvals.node.get",params:{nodeId:t}}:null}function qc(e,t){if(!e||e.kind==="gateway")return{method:"exec.approvals.set",params:t};const n=e.nodeId.trim();return n?{method:"exec.approvals.node.set",params:{...t,nodeId:n}}:null}async function zs(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=jc(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const s=await e.client.request(n.method,n.params);Vc(e,s)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function Vc(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=De(t.file??{}))}async function Wc(e,t){if(!(!e.client||!e.connected)){e.execApprovalsSaving=!0,e.lastError=null;try{const n=e.execApprovalsSnapshot?.hash;if(!n){e.lastError="Exec approvals hash missing; reload and retry.";return}const s=e.execApprovalsForm??e.execApprovalsSnapshot?.file??{},i=qc(t,{file:s,baseHash:n});if(!i){e.lastError="Select a node before saving exec approvals.";return}await e.client.request(i.method,i.params),e.execApprovalsDirty=!1,await zs(e,t)}catch(n){e.lastError=String(n)}finally{e.execApprovalsSaving=!1}}}function Gc(e,t,n){const s=De(e.execApprovalsForm??e.execApprovalsSnapshot?.file??{});lo(s,t,n),e.execApprovalsForm=s,e.execApprovalsDirty=!0}function Yc(e,t){const n=De(e.execApprovalsForm??e.execApprovalsSnapshot?.file??{});co(n,t),e.execApprovalsForm=n,e.execApprovalsDirty=!0}async function js(e){if(!(!e.client||!e.connected)&&!e.presenceLoading){e.presenceLoading=!0,e.presenceError=null,e.presenceStatus=null;try{const t=await e.client.request("system-presence",{});Array.isArray(t)?(e.presenceEntries=t,e.presenceStatus=t.length===0?"No instances yet.":null):(e.presenceEntries=[],e.presenceStatus="No presence payload.")}catch(t){e.presenceError=String(t)}finally{e.presenceLoading=!1}}}function tt(e,t,n){if(!t.trim())return;const s={...e.skillMessages};n?s[t]=n:delete s[t],e.skillMessages=s}function fn(e){return e instanceof Error?e.message:String(e)}async function Ct(e,t){if(t?.clearMessages&&Object.keys(e.skillMessages).length>0&&(e.skillMessages={}),!(!e.client||!e.connected)&&!e.skillsLoading){e.skillsLoading=!0,e.skillsError=null;try{const n=await e.client.request("skills.status",{});n&&(e.skillsReport=n)}catch(n){e.skillsError=fn(n)}finally{e.skillsLoading=!1}}}function Qc(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function Zc(e,t,n){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.update",{skillKey:t,enabled:n}),await Ct(e),tt(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(s){const i=fn(s);e.skillsError=i,tt(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function Jc(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const n=e.skillEdits[t]??"";await e.client.request("skills.update",{skillKey:t,apiKey:n}),await Ct(e),tt(e,t,{kind:"success",message:"API key saved"})}catch(n){const s=fn(n);e.skillsError=s,tt(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function Xc(e,t,n,s){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const i=await e.client.request("skills.install",{name:n,installId:s,timeoutMs:12e4});await Ct(e),tt(e,t,{kind:"success",message:i?.message??"Installed"})}catch(i){const a=fn(i);e.skillsError=a,tt(e,t,{kind:"error",message:a})}finally{e.skillsBusyKey=null}}}function ed(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function qs(e){return e==="system"?ed():e}const Ft=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,td=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,Ut=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},nd=({nextTheme:e,applyTheme:t,context:n,currentTheme:s})=>{if(s===e)return;const i=globalThis.document??null;if(!i){t();return}const a=i.documentElement,o=i,c=td();if(!!o.startViewTransition&&!c){let p=.5,d=.5;if(n?.pointerClientX!==void 0&&n?.pointerClientY!==void 0&&typeof window<"u")p=Ft(n.pointerClientX/window.innerWidth),d=Ft(n.pointerClientY/window.innerHeight);else if(n?.element){const u=n.element.getBoundingClientRect();u.width>0&&u.height>0&&typeof window<"u"&&(p=Ft((u.left+u.width/2)/window.innerWidth),d=Ft((u.top+u.height/2)/window.innerHeight))}a.style.setProperty("--theme-switch-x",`${p*100}%`),a.style.setProperty("--theme-switch-y",`${d*100}%`),a.classList.add("theme-transition");try{const u=o.startViewTransition?.(()=>{t()});u?.finished?u.finished.finally(()=>Ut(a)):Ut(a)}catch{Ut(a),t()}return}t(),Ut(a)};function sd(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{pn(e,{quiet:!0})},5e3))}function id(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function Vs(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&Os(e,{quiet:!0})},2e3))}function Ws(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function Gs(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&dn(e)},3e3))}function Ys(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function ke(e,t){const n={...t,lastActiveSessionKey:t.lastActiveSessionKey?.trim()||t.sessionKey.trim()||"main"};e.settings=n,fl(n),t.theme!==e.theme&&(e.theme=t.theme,hn(e,qs(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function Mo(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&ke(e,{...e.settings,lastActiveSessionKey:n})}function ad(e){if(!window.location.search)return;const t=new URLSearchParams(window.location.search),n=t.get("token"),s=t.get("password"),i=t.get("session"),a=t.get("gatewayUrl");let o=!1;if(n!=null){const l=n.trim();l&&l!==e.settings.token&&ke(e,{...e.settings,token:l}),t.delete("token"),o=!0}if(s!=null){const l=s.trim();l&&(e.password=l),t.delete("password"),o=!0}if(i!=null){const l=i.trim();l&&(e.sessionKey=l,ke(e,{...e.settings,sessionKey:l,lastActiveSessionKey:l}))}if(a!=null){const l=a.trim();l&&l!==e.settings.gatewayUrl&&ke(e,{...e.settings,gatewayUrl:l}),t.delete("gatewayUrl"),o=!0}if(!o)return;const c=new URL(window.location.href);c.search=t.toString(),window.history.replaceState({},"",c.toString())}function od(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?Vs(e):Ws(e),t==="debug"?Gs(e):Ys(e),Qs(e),Ro(e,t,!1)}function rd(e,t,n){nd({nextTheme:t,applyTheme:()=>{e.theme=t,ke(e,{...e.settings,theme:t}),hn(e,qs(t))},context:n,currentTheme:e.theme})}async function Qs(e){e.tab==="overview"&&await Po(e),e.tab==="channels"&&await gd(e),e.tab==="instances"&&await js(e),e.tab==="sessions"&&await st(e),e.tab==="cron"&&await Zs(e),e.tab==="skills"&&await Ct(e),e.tab==="nodes"&&(await pn(e),await Te(e),await be(e),await zs(e)),e.tab==="chat"&&(await wd(e),ln(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await uo(e),await be(e)),e.tab==="debug"&&(await dn(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"&&(e.logsAtBottom=!0,await Os(e,{reset:!0}),ro(e,!0))}function ld(){if(typeof window>"u")return"";const e=window.__CLAWDBOT_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?rn(e):gl(window.location.pathname)}function cd(e){e.theme=e.settings.theme??"system",hn(e,qs(e.theme))}function hn(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function dd(e){if(typeof window>"u"||typeof window.matchMedia!="function")return;if(e.themeMedia=window.matchMedia("(prefers-color-scheme: dark)"),e.themeMediaHandler=n=>{e.theme==="system"&&hn(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function ud(e){if(!e.themeMedia||!e.themeMediaHandler)return;if(typeof e.themeMedia.removeEventListener=="function"){e.themeMedia.removeEventListener("change",e.themeMediaHandler);return}e.themeMedia.removeListener(e.themeMediaHandler),e.themeMedia=null,e.themeMediaHandler=null}function pd(e,t){if(typeof window>"u")return;const n=so(window.location.pathname,e.basePath)??"chat";Io(e,n),Ro(e,n,t)}function fd(e){if(typeof window>"u")return;const t=so(window.location.pathname,e.basePath);if(!t)return;const s=new URL(window.location.href).searchParams.get("session")?.trim();s&&(e.sessionKey=s,ke(e,{...e.settings,sessionKey:s,lastActiveSessionKey:s})),Io(e,t)}function Io(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?Vs(e):Ws(e),t==="debug"?Gs(e):Ys(e),e.connected&&Qs(e)}function Ro(e,t,n){if(typeof window>"u")return;const s=kt(Rs(t,e.basePath)),i=kt(window.location.pathname),a=new URL(window.location.href);t==="chat"&&e.sessionKey?a.searchParams.set("session",e.sessionKey):a.searchParams.delete("session"),i!==s&&(a.pathname=s),n?window.history.replaceState({},"",a.toString()):window.history.pushState({},"",a.toString())}function hd(e,t,n){if(typeof window>"u")return;const s=new URL(window.location.href);s.searchParams.set("session",t),window.history.replaceState({},"",s.toString())}async function Po(e){await Promise.all([oe(e,!1),js(e),st(e),Tt(e),dn(e)])}async function gd(e){await Promise.all([oe(e,!0),uo(e),be(e)])}async function Zs(e){await Promise.all([oe(e,!1),Tt(e),cn(e)])}function No(e){return e.chatSending||!!e.chatRunId}function vd(e){const t=e.trim();if(!t)return!1;const n=t.toLowerCase();return n==="/stop"?!0:n==="stop"||n==="esc"||n==="abort"||n==="wait"||n==="exit"}async function Oo(e){e.connected&&(e.chatMessage="",await El(e))}function md(e,t){const n=t.trim();n&&(e.chatQueue=[...e.chatQueue,{id:Ps(),text:n,createdAt:Date.now()}])}async function Do(e,t,n){Ns(e);const s=await Cl(e,t);return!s&&n?.previousDraft!=null&&(e.chatMessage=n.previousDraft),s&&Mo(e,e.sessionKey),s&&n?.restoreDraft&&n.previousDraft?.trim()&&(e.chatMessage=n.previousDraft),ln(e),s&&!e.chatRunId&&Bo(e),s}async function Bo(e){if(!e.connected||No(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await Do(e,t.text)||(e.chatQueue=[t,...e.chatQueue])}function bd(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function yd(e,t,n){if(!e.connected)return;const s=e.chatMessage,i=(t??e.chatMessage).trim();if(i){if(vd(i)){await Oo(e);return}if(t==null&&(e.chatMessage=""),No(e)){md(e,i);return}await Do(e,i,{previousDraft:t==null?s:void 0,restoreDraft:!!(t&&n?.restoreDraft)})}}async function wd(e){await Promise.all([Xe(e),st(e),fs(e)]),ln(e,!0)}const $d=Bo;function xd(e){const t=eo(e.sessionKey);return t?.agentId?t.agentId:e.hello?.snapshot?.sessionDefaults?.defaultAgentId?.trim()||"main"}function kd(e,t){const n=rn(e),s=encodeURIComponent(t);return n?`${n}/avatar/${s}?meta=1`:`/avatar/${s}?meta=1`}async function fs(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=xd(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=kd(e.basePath,t);try{const s=await fetch(n,{method:"GET"});if(!s.ok){e.chatAvatarUrl=null;return}const i=await s.json(),a=typeof i.avatarUrl=="string"?i.avatarUrl.trim():"";e.chatAvatarUrl=a||null}catch{e.chatAvatarUrl=null}}const Fo={CHILD:2},Uo=e=>(...t)=>({_$litDirective$:e,values:t});let Ko=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,n,s){this._$Ct=t,this._$AM=n,this._$Ci=s}_$AS(t,n){return this.update(t,n)}update(t,n){return this.render(...n)}};const{I:Ad}=nl,ia=e=>e,aa=()=>document.createComment(""),lt=(e,t,n)=>{const s=e._$AA.parentNode,i=t===void 0?e._$AB:t._$AA;if(n===void 0){const a=s.insertBefore(aa(),i),o=s.insertBefore(aa(),i);n=new Ad(a,o,e,e.options)}else{const a=n._$AB.nextSibling,o=n._$AM,c=o!==e;if(c){let l;n._$AQ?.(e),n._$AM=e,n._$AP!==void 0&&(l=e._$AU)!==o._$AU&&n._$AP(l)}if(a!==i||c){let l=n._$AA;for(;l!==a;){const p=ia(l).nextSibling;ia(s).insertBefore(l,i),l=p}}}return n},Me=(e,t,n=e)=>(e._$AI(t,n),e),Sd={},_d=(e,t=Sd)=>e._$AH=t,Td=e=>e._$AH,qn=e=>{e._$AR(),e._$AA.remove()};const oa=(e,t,n)=>{const s=new Map;for(let i=t;i<=n;i++)s.set(e[i],i);return s},Ho=Uo(class extends Ko{constructor(e){if(super(e),e.type!==Fo.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,n){let s;n===void 0?n=t:t!==void 0&&(s=t);const i=[],a=[];let o=0;for(const c of e)i[o]=s?s(c,o):o,a[o]=n(c,o),o++;return{values:a,keys:i}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,s]){const i=Td(e),{values:a,keys:o}=this.dt(t,n,s);if(!Array.isArray(i))return this.ut=o,a;const c=this.ut??=[],l=[];let p,d,u=0,h=i.length-1,v=0,w=a.length-1;for(;u<=h&&v<=w;)if(i[u]===null)u++;else if(i[h]===null)h--;else if(c[u]===o[v])l[v]=Me(i[u],a[v]),u++,v++;else if(c[h]===o[w])l[w]=Me(i[h],a[w]),h--,w--;else if(c[u]===o[w])l[w]=Me(i[u],a[w]),lt(e,l[w+1],i[u]),u++,w--;else if(c[h]===o[v])l[v]=Me(i[h],a[v]),lt(e,i[u],i[h]),h--,v++;else if(p===void 0&&(p=oa(o,v,w),d=oa(c,u,h)),p.has(c[u]))if(p.has(c[h])){const $=d.get(o[v]),k=$!==void 0?i[$]:null;if(k===null){const T=lt(e,i[u]);Me(T,a[v]),l[v]=T}else l[v]=Me(k,a[v]),lt(e,i[u],k),i[$]=null;v++}else qn(i[h]),h--;else qn(i[u]),u++;for(;v<=w;){const $=lt(e,l[w+1]);Me($,a[v]),l[v++]=$}for(;u<=h;){const $=i[u++];$!==null&&qn($)}return this.ut=o,_d(e,l),Se}});function zo(e){const t=e;let n=typeof t.role=="string"?t.role:"unknown";const s=typeof t.toolCallId=="string"||typeof t.tool_call_id=="string",i=t.content,a=Array.isArray(i)?i:null,o=Array.isArray(a)&&a.some(u=>{const v=String(u.type??"").toLowerCase();return v==="toolresult"||v==="tool_result"}),c=typeof t.toolName=="string"||typeof t.tool_name=="string";(s||o||c)&&(n="toolResult");let l=[];typeof t.content=="string"?l=[{type:"text",text:t.content}]:Array.isArray(t.content)?l=t.content.map(u=>({type:u.type||"text",text:u.text,name:u.name,args:u.args||u.arguments})):typeof t.text=="string"&&(l=[{type:"text",text:t.text}]);const p=typeof t.timestamp=="number"?t.timestamp:Date.now(),d=typeof t.id=="string"?t.id:void 0;return{role:n,content:l,timestamp:p,id:d}}function Js(e){const t=e.toLowerCase();return e==="user"||e==="User"?e:e==="assistant"?"assistant":e==="system"?"system":t==="toolresult"||t==="tool_result"||t==="tool"||t==="function"?"tool":e}function jo(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}class hs extends Ko{constructor(t){if(super(t),this.it=g,t.type!==Fo.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===g||t==null)return this._t=void 0,this.it=t;if(t===Se)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const n=[t];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}}hs.directiveName="unsafeHTML",hs.resultType=1;const gs=Uo(hs);const{entries:qo,setPrototypeOf:ra,isFrozen:Cd,getPrototypeOf:Ed,getOwnPropertyDescriptor:Ld}=Object;let{freeze:Z,seal:ne,create:vs}=Object,{apply:ms,construct:bs}=typeof Reflect<"u"&&Reflect;Z||(Z=function(t){return t});ne||(ne=function(t){return t});ms||(ms=function(t,n){for(var s=arguments.length,i=new Array(s>2?s-2:0),a=2;a<s;a++)i[a-2]=arguments[a];return t.apply(n,i)});bs||(bs=function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];return new t(...s)});const Kt=J(Array.prototype.forEach),Md=J(Array.prototype.lastIndexOf),la=J(Array.prototype.pop),ct=J(Array.prototype.push),Id=J(Array.prototype.splice),Wt=J(String.prototype.toLowerCase),Vn=J(String.prototype.toString),Wn=J(String.prototype.match),dt=J(String.prototype.replace),Rd=J(String.prototype.indexOf),Pd=J(String.prototype.trim),se=J(Object.prototype.hasOwnProperty),G=J(RegExp.prototype.test),ut=Nd(TypeError);function J(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];return ms(e,t,s)}}function Nd(e){return function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return bs(e,n)}}function I(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Wt;ra&&ra(e,null);let s=t.length;for(;s--;){let i=t[s];if(typeof i=="string"){const a=n(i);a!==i&&(Cd(t)||(t[s]=a),i=a)}e[i]=!0}return e}function Od(e){for(let t=0;t<e.length;t++)se(e,t)||(e[t]=null);return e}function de(e){const t=vs(null);for(const[n,s]of qo(e))se(e,n)&&(Array.isArray(s)?t[n]=Od(s):s&&typeof s=="object"&&s.constructor===Object?t[n]=de(s):t[n]=s);return t}function pt(e,t){for(;e!==null;){const s=Ld(e,t);if(s){if(s.get)return J(s.get);if(typeof s.value=="function")return J(s.value)}e=Ed(e)}function n(){return null}return n}const ca=Z(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Gn=Z(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Yn=Z(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Dd=Z(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Qn=Z(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Bd=Z(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),da=Z(["#text"]),ua=Z(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Zn=Z(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),pa=Z(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Ht=Z(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Fd=ne(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Ud=ne(/<%[\w\W]*|[\w\W]*%>/gm),Kd=ne(/\$\{[\w\W]*/gm),Hd=ne(/^data-[\-\w.\u00B7-\uFFFF]+$/),zd=ne(/^aria-[\-\w]+$/),Vo=ne(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),jd=ne(/^(?:\w+script|data):/i),qd=ne(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Wo=ne(/^html$/i),Vd=ne(/^[a-z][.\w]*(-[.\w]+)+$/i);var fa=Object.freeze({__proto__:null,ARIA_ATTR:zd,ATTR_WHITESPACE:qd,CUSTOM_ELEMENT:Vd,DATA_ATTR:Hd,DOCTYPE_NAME:Wo,ERB_EXPR:Ud,IS_ALLOWED_URI:Vo,IS_SCRIPT_OR_DATA:jd,MUSTACHE_EXPR:Fd,TMPLIT_EXPR:Kd});const ft={element:1,text:3,progressingInstruction:7,comment:8,document:9},Wd=function(){return typeof window>"u"?null:window},Gd=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let s=null;const i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(s=n.getAttribute(i));const a="dompurify"+(s?"#"+s:"");try{return t.createPolicy(a,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},ha=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Go(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Wd();const t=_=>Go(_);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==ft.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const s=n,i=s.currentScript,{DocumentFragment:a,HTMLTemplateElement:o,Node:c,Element:l,NodeFilter:p,NamedNodeMap:d=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:u,DOMParser:h,trustedTypes:v}=e,w=l.prototype,$=pt(w,"cloneNode"),k=pt(w,"remove"),T=pt(w,"nextSibling"),M=pt(w,"childNodes"),P=pt(w,"parentNode");if(typeof o=="function"){const _=n.createElement("template");_.content&&_.content.ownerDocument&&(n=_.content.ownerDocument)}let L,C="";const{implementation:E,createNodeIterator:pe,createDocumentFragment:yn,getElementsByTagName:wn}=n,{importNode:kr}=s;let W=ha();t.isSupported=typeof qo=="function"&&typeof P=="function"&&E&&E.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:$n,ERB_EXPR:xn,TMPLIT_EXPR:kn,DATA_ATTR:Ar,ARIA_ATTR:Sr,IS_SCRIPT_OR_DATA:_r,ATTR_WHITESPACE:di,CUSTOM_ELEMENT:Tr}=fa;let{IS_ALLOWED_URI:ui}=fa,K=null;const pi=I({},[...ca,...Gn,...Yn,...Qn,...da]);let z=null;const fi=I({},[...ua,...Zn,...pa,...Ht]);let B=Object.seal(vs(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),it=null,An=null;const He=Object.seal(vs(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let hi=!0,Sn=!0,gi=!1,vi=!0,ze=!1,Lt=!0,Ce=!1,_n=!1,Tn=!1,je=!1,Mt=!1,It=!1,mi=!0,bi=!1;const Cr="user-content-";let Cn=!0,at=!1,qe={},re=null;const En=I({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let yi=null;const wi=I({},["audio","video","img","source","image","track"]);let Ln=null;const $i=I({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Rt="http://www.w3.org/1998/Math/MathML",Pt="http://www.w3.org/2000/svg",fe="http://www.w3.org/1999/xhtml";let Ve=fe,Mn=!1,In=null;const Er=I({},[Rt,Pt,fe],Vn);let Nt=I({},["mi","mo","mn","ms","mtext"]),Ot=I({},["annotation-xml"]);const Lr=I({},["title","style","font","a","script"]);let ot=null;const Mr=["application/xhtml+xml","text/html"],Ir="text/html";let U=null,We=null;const Rr=n.createElement("form"),xi=function(f){return f instanceof RegExp||f instanceof Function},Rn=function(){let f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(We&&We===f)){if((!f||typeof f!="object")&&(f={}),f=de(f),ot=Mr.indexOf(f.PARSER_MEDIA_TYPE)===-1?Ir:f.PARSER_MEDIA_TYPE,U=ot==="application/xhtml+xml"?Vn:Wt,K=se(f,"ALLOWED_TAGS")?I({},f.ALLOWED_TAGS,U):pi,z=se(f,"ALLOWED_ATTR")?I({},f.ALLOWED_ATTR,U):fi,In=se(f,"ALLOWED_NAMESPACES")?I({},f.ALLOWED_NAMESPACES,Vn):Er,Ln=se(f,"ADD_URI_SAFE_ATTR")?I(de($i),f.ADD_URI_SAFE_ATTR,U):$i,yi=se(f,"ADD_DATA_URI_TAGS")?I(de(wi),f.ADD_DATA_URI_TAGS,U):wi,re=se(f,"FORBID_CONTENTS")?I({},f.FORBID_CONTENTS,U):En,it=se(f,"FORBID_TAGS")?I({},f.FORBID_TAGS,U):de({}),An=se(f,"FORBID_ATTR")?I({},f.FORBID_ATTR,U):de({}),qe=se(f,"USE_PROFILES")?f.USE_PROFILES:!1,hi=f.ALLOW_ARIA_ATTR!==!1,Sn=f.ALLOW_DATA_ATTR!==!1,gi=f.ALLOW_UNKNOWN_PROTOCOLS||!1,vi=f.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ze=f.SAFE_FOR_TEMPLATES||!1,Lt=f.SAFE_FOR_XML!==!1,Ce=f.WHOLE_DOCUMENT||!1,je=f.RETURN_DOM||!1,Mt=f.RETURN_DOM_FRAGMENT||!1,It=f.RETURN_TRUSTED_TYPE||!1,Tn=f.FORCE_BODY||!1,mi=f.SANITIZE_DOM!==!1,bi=f.SANITIZE_NAMED_PROPS||!1,Cn=f.KEEP_CONTENT!==!1,at=f.IN_PLACE||!1,ui=f.ALLOWED_URI_REGEXP||Vo,Ve=f.NAMESPACE||fe,Nt=f.MATHML_TEXT_INTEGRATION_POINTS||Nt,Ot=f.HTML_INTEGRATION_POINTS||Ot,B=f.CUSTOM_ELEMENT_HANDLING||{},f.CUSTOM_ELEMENT_HANDLING&&xi(f.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(B.tagNameCheck=f.CUSTOM_ELEMENT_HANDLING.tagNameCheck),f.CUSTOM_ELEMENT_HANDLING&&xi(f.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(B.attributeNameCheck=f.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),f.CUSTOM_ELEMENT_HANDLING&&typeof f.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(B.allowCustomizedBuiltInElements=f.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),ze&&(Sn=!1),Mt&&(je=!0),qe&&(K=I({},da),z=[],qe.html===!0&&(I(K,ca),I(z,ua)),qe.svg===!0&&(I(K,Gn),I(z,Zn),I(z,Ht)),qe.svgFilters===!0&&(I(K,Yn),I(z,Zn),I(z,Ht)),qe.mathMl===!0&&(I(K,Qn),I(z,pa),I(z,Ht))),f.ADD_TAGS&&(typeof f.ADD_TAGS=="function"?He.tagCheck=f.ADD_TAGS:(K===pi&&(K=de(K)),I(K,f.ADD_TAGS,U))),f.ADD_ATTR&&(typeof f.ADD_ATTR=="function"?He.attributeCheck=f.ADD_ATTR:(z===fi&&(z=de(z)),I(z,f.ADD_ATTR,U))),f.ADD_URI_SAFE_ATTR&&I(Ln,f.ADD_URI_SAFE_ATTR,U),f.FORBID_CONTENTS&&(re===En&&(re=de(re)),I(re,f.FORBID_CONTENTS,U)),f.ADD_FORBID_CONTENTS&&(re===En&&(re=de(re)),I(re,f.ADD_FORBID_CONTENTS,U)),Cn&&(K["#text"]=!0),Ce&&I(K,["html","head","body"]),K.table&&(I(K,["tbody"]),delete it.tbody),f.TRUSTED_TYPES_POLICY){if(typeof f.TRUSTED_TYPES_POLICY.createHTML!="function")throw ut('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof f.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ut('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');L=f.TRUSTED_TYPES_POLICY,C=L.createHTML("")}else L===void 0&&(L=Gd(v,i)),L!==null&&typeof C=="string"&&(C=L.createHTML(""));Z&&Z(f),We=f}},ki=I({},[...Gn,...Yn,...Dd]),Ai=I({},[...Qn,...Bd]),Pr=function(f){let x=P(f);(!x||!x.tagName)&&(x={namespaceURI:Ve,tagName:"template"});const S=Wt(f.tagName),D=Wt(x.tagName);return In[f.namespaceURI]?f.namespaceURI===Pt?x.namespaceURI===fe?S==="svg":x.namespaceURI===Rt?S==="svg"&&(D==="annotation-xml"||Nt[D]):!!ki[S]:f.namespaceURI===Rt?x.namespaceURI===fe?S==="math":x.namespaceURI===Pt?S==="math"&&Ot[D]:!!Ai[S]:f.namespaceURI===fe?x.namespaceURI===Pt&&!Ot[D]||x.namespaceURI===Rt&&!Nt[D]?!1:!Ai[S]&&(Lr[S]||!ki[S]):!!(ot==="application/xhtml+xml"&&In[f.namespaceURI]):!1},le=function(f){ct(t.removed,{element:f});try{P(f).removeChild(f)}catch{k(f)}},Ee=function(f,x){try{ct(t.removed,{attribute:x.getAttributeNode(f),from:x})}catch{ct(t.removed,{attribute:null,from:x})}if(x.removeAttribute(f),f==="is")if(je||Mt)try{le(x)}catch{}else try{x.setAttribute(f,"")}catch{}},Si=function(f){let x=null,S=null;if(Tn)f="<remove></remove>"+f;else{const F=Wn(f,/^[\r\n\t ]+/);S=F&&F[0]}ot==="application/xhtml+xml"&&Ve===fe&&(f='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+f+"</body></html>");const D=L?L.createHTML(f):f;if(Ve===fe)try{x=new h().parseFromString(D,ot)}catch{}if(!x||!x.documentElement){x=E.createDocument(Ve,"template",null);try{x.documentElement.innerHTML=Mn?C:D}catch{}}const q=x.body||x.documentElement;return f&&S&&q.insertBefore(n.createTextNode(S),q.childNodes[0]||null),Ve===fe?wn.call(x,Ce?"html":"body")[0]:Ce?x.documentElement:q},_i=function(f){return pe.call(f.ownerDocument||f,f,p.SHOW_ELEMENT|p.SHOW_COMMENT|p.SHOW_TEXT|p.SHOW_PROCESSING_INSTRUCTION|p.SHOW_CDATA_SECTION,null)},Pn=function(f){return f instanceof u&&(typeof f.nodeName!="string"||typeof f.textContent!="string"||typeof f.removeChild!="function"||!(f.attributes instanceof d)||typeof f.removeAttribute!="function"||typeof f.setAttribute!="function"||typeof f.namespaceURI!="string"||typeof f.insertBefore!="function"||typeof f.hasChildNodes!="function")},Ti=function(f){return typeof c=="function"&&f instanceof c};function he(_,f,x){Kt(_,S=>{S.call(t,f,x,We)})}const Ci=function(f){let x=null;if(he(W.beforeSanitizeElements,f,null),Pn(f))return le(f),!0;const S=U(f.nodeName);if(he(W.uponSanitizeElement,f,{tagName:S,allowedTags:K}),Lt&&f.hasChildNodes()&&!Ti(f.firstElementChild)&&G(/<[/\w!]/g,f.innerHTML)&&G(/<[/\w!]/g,f.textContent)||f.nodeType===ft.progressingInstruction||Lt&&f.nodeType===ft.comment&&G(/<[/\w]/g,f.data))return le(f),!0;if(!(He.tagCheck instanceof Function&&He.tagCheck(S))&&(!K[S]||it[S])){if(!it[S]&&Li(S)&&(B.tagNameCheck instanceof RegExp&&G(B.tagNameCheck,S)||B.tagNameCheck instanceof Function&&B.tagNameCheck(S)))return!1;if(Cn&&!re[S]){const D=P(f)||f.parentNode,q=M(f)||f.childNodes;if(q&&D){const F=q.length;for(let X=F-1;X>=0;--X){const ge=$(q[X],!0);ge.__removalCount=(f.__removalCount||0)+1,D.insertBefore(ge,T(f))}}}return le(f),!0}return f instanceof l&&!Pr(f)||(S==="noscript"||S==="noembed"||S==="noframes")&&G(/<\/no(script|embed|frames)/i,f.innerHTML)?(le(f),!0):(ze&&f.nodeType===ft.text&&(x=f.textContent,Kt([$n,xn,kn],D=>{x=dt(x,D," ")}),f.textContent!==x&&(ct(t.removed,{element:f.cloneNode()}),f.textContent=x)),he(W.afterSanitizeElements,f,null),!1)},Ei=function(f,x,S){if(mi&&(x==="id"||x==="name")&&(S in n||S in Rr))return!1;if(!(Sn&&!An[x]&&G(Ar,x))){if(!(hi&&G(Sr,x))){if(!(He.attributeCheck instanceof Function&&He.attributeCheck(x,f))){if(!z[x]||An[x]){if(!(Li(f)&&(B.tagNameCheck instanceof RegExp&&G(B.tagNameCheck,f)||B.tagNameCheck instanceof Function&&B.tagNameCheck(f))&&(B.attributeNameCheck instanceof RegExp&&G(B.attributeNameCheck,x)||B.attributeNameCheck instanceof Function&&B.attributeNameCheck(x,f))||x==="is"&&B.allowCustomizedBuiltInElements&&(B.tagNameCheck instanceof RegExp&&G(B.tagNameCheck,S)||B.tagNameCheck instanceof Function&&B.tagNameCheck(S))))return!1}else if(!Ln[x]){if(!G(ui,dt(S,di,""))){if(!((x==="src"||x==="xlink:href"||x==="href")&&f!=="script"&&Rd(S,"data:")===0&&yi[f])){if(!(gi&&!G(_r,dt(S,di,"")))){if(S)return!1}}}}}}}return!0},Li=function(f){return f!=="annotation-xml"&&Wn(f,Tr)},Mi=function(f){he(W.beforeSanitizeAttributes,f,null);const{attributes:x}=f;if(!x||Pn(f))return;const S={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:z,forceKeepAttr:void 0};let D=x.length;for(;D--;){const q=x[D],{name:F,namespaceURI:X,value:ge}=q,Ge=U(F),Nn=ge;let j=F==="value"?Nn:Pd(Nn);if(S.attrName=Ge,S.attrValue=j,S.keepAttr=!0,S.forceKeepAttr=void 0,he(W.uponSanitizeAttribute,f,S),j=S.attrValue,bi&&(Ge==="id"||Ge==="name")&&(Ee(F,f),j=Cr+j),Lt&&G(/((--!?|])>)|<\/(style|title|textarea)/i,j)){Ee(F,f);continue}if(Ge==="attributename"&&Wn(j,"href")){Ee(F,f);continue}if(S.forceKeepAttr)continue;if(!S.keepAttr){Ee(F,f);continue}if(!vi&&G(/\/>/i,j)){Ee(F,f);continue}ze&&Kt([$n,xn,kn],Ri=>{j=dt(j,Ri," ")});const Ii=U(f.nodeName);if(!Ei(Ii,Ge,j)){Ee(F,f);continue}if(L&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!X)switch(v.getAttributeType(Ii,Ge)){case"TrustedHTML":{j=L.createHTML(j);break}case"TrustedScriptURL":{j=L.createScriptURL(j);break}}if(j!==Nn)try{X?f.setAttributeNS(X,F,j):f.setAttribute(F,j),Pn(f)?le(f):la(t.removed)}catch{Ee(F,f)}}he(W.afterSanitizeAttributes,f,null)},Nr=function _(f){let x=null;const S=_i(f);for(he(W.beforeSanitizeShadowDOM,f,null);x=S.nextNode();)he(W.uponSanitizeShadowNode,x,null),Ci(x),Mi(x),x.content instanceof a&&_(x.content);he(W.afterSanitizeShadowDOM,f,null)};return t.sanitize=function(_){let f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},x=null,S=null,D=null,q=null;if(Mn=!_,Mn&&(_="<!-->"),typeof _!="string"&&!Ti(_))if(typeof _.toString=="function"){if(_=_.toString(),typeof _!="string")throw ut("dirty is not a string, aborting")}else throw ut("toString is not a function");if(!t.isSupported)return _;if(_n||Rn(f),t.removed=[],typeof _=="string"&&(at=!1),at){if(_.nodeName){const ge=U(_.nodeName);if(!K[ge]||it[ge])throw ut("root node is forbidden and cannot be sanitized in-place")}}else if(_ instanceof c)x=Si("<!---->"),S=x.ownerDocument.importNode(_,!0),S.nodeType===ft.element&&S.nodeName==="BODY"||S.nodeName==="HTML"?x=S:x.appendChild(S);else{if(!je&&!ze&&!Ce&&_.indexOf("<")===-1)return L&&It?L.createHTML(_):_;if(x=Si(_),!x)return je?null:It?C:""}x&&Tn&&le(x.firstChild);const F=_i(at?_:x);for(;D=F.nextNode();)Ci(D),Mi(D),D.content instanceof a&&Nr(D.content);if(at)return _;if(je){if(Mt)for(q=yn.call(x.ownerDocument);x.firstChild;)q.appendChild(x.firstChild);else q=x;return(z.shadowroot||z.shadowrootmode)&&(q=kr.call(s,q,!0)),q}let X=Ce?x.outerHTML:x.innerHTML;return Ce&&K["!doctype"]&&x.ownerDocument&&x.ownerDocument.doctype&&x.ownerDocument.doctype.name&&G(Wo,x.ownerDocument.doctype.name)&&(X="<!DOCTYPE "+x.ownerDocument.doctype.name+`>
17
- `+X),ze&&Kt([$n,xn,kn],ge=>{X=dt(X,ge," ")}),L&&It?L.createHTML(X):X},t.setConfig=function(){let _=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Rn(_),_n=!0},t.clearConfig=function(){We=null,_n=!1},t.isValidAttribute=function(_,f,x){We||Rn({});const S=U(_),D=U(f);return Ei(S,D,x)},t.addHook=function(_,f){typeof f=="function"&&ct(W[_],f)},t.removeHook=function(_,f){if(f!==void 0){const x=Md(W[_],f);return x===-1?void 0:Id(W[_],x,1)[0]}return la(W[_])},t.removeHooks=function(_){W[_]=[]},t.removeAllHooks=function(){W=ha()},t}var ys=Go();function Xs(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ke=Xs();function Yo(e){Ke=e}var yt={exec:()=>null};function R(e,t=""){let n=typeof e=="string"?e:e.source,s={replace:(i,a)=>{let o=typeof a=="string"?a:a.source;return o=o.replace(Y.caret,"$1"),n=n.replace(i,o),s},getRegex:()=>new RegExp(n,t)};return s}var Yd=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Y={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},Qd=/^(?:[ \t]*(?:\n|$))+/,Zd=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Jd=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Et=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Xd=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ei=/(?:[*+-]|\d{1,9}[.)])/,Qo=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Zo=R(Qo).replace(/bull/g,ei).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),eu=R(Qo).replace(/bull/g,ei).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),ti=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,tu=/^[^\n]+/,ni=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,nu=R(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ni).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),su=R(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ei).getRegex(),gn="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",si=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,iu=R("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",si).replace("tag",gn).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Jo=R(ti).replace("hr",Et).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",gn).getRegex(),au=R(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Jo).getRegex(),ii={blockquote:au,code:Zd,def:nu,fences:Jd,heading:Xd,hr:Et,html:iu,lheading:Zo,list:su,newline:Qd,paragraph:Jo,table:yt,text:tu},ga=R("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Et).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",gn).getRegex(),ou={...ii,lheading:eu,table:ga,paragraph:R(ti).replace("hr",Et).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ga).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",gn).getRegex()},ru={...ii,html:R(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",si).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:yt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:R(ti).replace("hr",Et).replace("heading",` *#{1,6} *[^
18
- ]`).replace("lheading",Zo).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},lu=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,cu=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Xo=/^( {2,}|\\)\n(?!\s*$)/,du=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,vn=/[\p{P}\p{S}]/u,ai=/[\s\p{P}\p{S}]/u,er=/[^\s\p{P}\p{S}]/u,uu=R(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ai).getRegex(),tr=/(?!~)[\p{P}\p{S}]/u,pu=/(?!~)[\s\p{P}\p{S}]/u,fu=/(?:[^\s\p{P}\p{S}]|~)/u,hu=R(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Yd?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),nr=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,gu=R(nr,"u").replace(/punct/g,vn).getRegex(),vu=R(nr,"u").replace(/punct/g,tr).getRegex(),sr="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",mu=R(sr,"gu").replace(/notPunctSpace/g,er).replace(/punctSpace/g,ai).replace(/punct/g,vn).getRegex(),bu=R(sr,"gu").replace(/notPunctSpace/g,fu).replace(/punctSpace/g,pu).replace(/punct/g,tr).getRegex(),yu=R("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,er).replace(/punctSpace/g,ai).replace(/punct/g,vn).getRegex(),wu=R(/\\(punct)/,"gu").replace(/punct/g,vn).getRegex(),$u=R(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),xu=R(si).replace("(?:-->|$)","-->").getRegex(),ku=R("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",xu).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Xt=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Au=R(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Xt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ir=R(/^!?\[(label)\]\[(ref)\]/).replace("label",Xt).replace("ref",ni).getRegex(),ar=R(/^!?\[(ref)\](?:\[\])?/).replace("ref",ni).getRegex(),Su=R("reflink|nolink(?!\\()","g").replace("reflink",ir).replace("nolink",ar).getRegex(),va=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,oi={_backpedal:yt,anyPunctuation:wu,autolink:$u,blockSkip:hu,br:Xo,code:cu,del:yt,emStrongLDelim:gu,emStrongRDelimAst:mu,emStrongRDelimUnd:yu,escape:lu,link:Au,nolink:ar,punctuation:uu,reflink:ir,reflinkSearch:Su,tag:ku,text:du,url:yt},_u={...oi,link:R(/^!?\[(label)\]\((.*?)\)/).replace("label",Xt).getRegex(),reflink:R(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Xt).getRegex()},ws={...oi,emStrongRDelimAst:bu,emStrongLDelim:vu,url:R(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",va).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:R(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",va).getRegex()},Tu={...ws,br:R(Xo).replace("{2,}","*").getRegex(),text:R(ws.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},zt={normal:ii,gfm:ou,pedantic:ru},ht={normal:oi,gfm:ws,breaks:Tu,pedantic:_u},Cu={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ma=e=>Cu[e];function me(e,t){if(t){if(Y.escapeTest.test(e))return e.replace(Y.escapeReplace,ma)}else if(Y.escapeTestNoEncode.test(e))return e.replace(Y.escapeReplaceNoEncode,ma);return e}function ba(e){try{e=encodeURI(e).replace(Y.percentDecode,"%")}catch{return null}return e}function ya(e,t){let n=e.replace(Y.findPipe,(a,o,c)=>{let l=!1,p=o;for(;--p>=0&&c[p]==="\\";)l=!l;return l?"|":" |"}),s=n.split(Y.splitPipe),i=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),t)if(s.length>t)s.splice(t);else for(;s.length<t;)s.push("");for(;i<s.length;i++)s[i]=s[i].trim().replace(Y.slashPipe,"|");return s}function gt(e,t,n){let s=e.length;if(s===0)return"";let i=0;for(;i<s&&e.charAt(s-i-1)===t;)i++;return e.slice(0,s-i)}function Eu(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let s=0;s<e.length;s++)if(e[s]==="\\")s++;else if(e[s]===t[0])n++;else if(e[s]===t[1]&&(n--,n<0))return s;return n>0?-2:-1}function wa(e,t,n,s,i){let a=t.href,o=t.title||null,c=e[1].replace(i.other.outputLinkReplace,"$1");s.state.inLink=!0;let l={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:a,title:o,text:c,tokens:s.inlineTokens(c)};return s.state.inLink=!1,l}function Lu(e,t,n){let s=e.match(n.other.indentCodeCompensation);if(s===null)return t;let i=s[1];return t.split(`
19
- `).map(a=>{let o=a.match(n.other.beginningSpace);if(o===null)return a;let[c]=o;return c.length>=i.length?a.slice(i.length):a}).join(`
15
+ `],{type:"text/plain"}),s=URL.createObjectURL(n),i=document.createElement("a"),a=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");i.href=s,i.download=`moltbot-logs-${t}-${a}.log`,i.click(),URL.revokeObjectURL(s)}function Ql(e){if(typeof ResizeObserver>"u")return;const t=e.querySelector(".topbar");if(!t)return;const n=()=>{const{height:s}=t.getBoundingClientRect();e.style.setProperty("--topbar-height",`${s}px`)};n(),e.topbarObserver=new ResizeObserver(()=>n()),e.topbarObserver.observe(t)}function De(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function et(e){return`${JSON.stringify(e,null,2).trimEnd()}
16
+ `}function co(e,t,n){if(t.length===0)return;let s=e;for(let a=0;a<t.length-1;a+=1){const o=t[a],l=t[a+1];if(typeof o=="number"){if(!Array.isArray(s))return;s[o]==null&&(s[o]=typeof l=="number"?[]:{}),s=s[o]}else{if(typeof s!="object"||s==null)return;const r=s;r[o]==null&&(r[o]=typeof l=="number"?[]:{}),s=r[o]}}const i=t[t.length-1];if(typeof i=="number"){Array.isArray(s)&&(s[i]=n);return}typeof s=="object"&&s!=null&&(s[i]=n)}function uo(e,t){if(t.length===0)return;let n=e;for(let i=0;i<t.length-1;i+=1){const a=t[i];if(typeof a=="number"){if(!Array.isArray(n))return;n=n[a]}else{if(typeof n!="object"||n==null)return;n=n[a]}if(n==null)return}const s=t[t.length-1];if(typeof s=="number"){Array.isArray(n)&&n.splice(s,1);return}typeof n=="object"&&n!=null&&delete n[s]}async function ye(e){if(!(!e.client||!e.connected)){e.configLoading=!0,e.lastError=null;try{const t=await e.client.request("config.get",{});Jl(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function po(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});Zl(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function Zl(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function Jl(e,t){e.configSnapshot=t;const n=typeof t.raw=="string"?t.raw:t.config&&typeof t.config=="object"?et(t.config):e.configRaw;!e.configFormDirty||e.configFormMode==="raw"?e.configRaw=n:e.configForm?e.configRaw=et(e.configForm):e.configRaw=n,e.configValid=typeof t.valid=="boolean"?t.valid:null,e.configIssues=Array.isArray(t.issues)?t.issues:[],e.configFormDirty||(e.configForm=De(t.config??{}),e.configFormOriginal=De(t.config??{}),e.configRawOriginal=n)}async function cs(e){if(!(!e.client||!e.connected)){e.configSaving=!0,e.lastError=null;try{const t=e.configFormMode==="form"&&e.configForm?et(e.configForm):e.configRaw,n=e.configSnapshot?.hash;if(!n){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.set",{raw:t,baseHash:n}),e.configFormDirty=!1,await ye(e)}catch(t){e.lastError=String(t)}finally{e.configSaving=!1}}}async function Xl(e){if(!(!e.client||!e.connected)){e.configApplying=!0,e.lastError=null;try{const t=e.configFormMode==="form"&&e.configForm?et(e.configForm):e.configRaw,n=e.configSnapshot?.hash;if(!n){e.lastError="Config hash missing; reload and retry.";return}await e.client.request("config.apply",{raw:t,baseHash:n,sessionKey:e.applySessionKey}),e.configFormDirty=!1,await ye(e)}catch(t){e.lastError=String(t)}finally{e.configApplying=!1}}}async function ec(e){if(!(!e.client||!e.connected)){e.updateRunning=!0,e.lastError=null;try{await e.client.request("update.run",{sessionKey:e.applySessionKey})}catch(t){e.lastError=String(t)}finally{e.updateRunning=!1}}}function Bt(e,t,n){const s=De(e.configForm??e.configSnapshot?.config??{});co(s,t,n),e.configForm=s,e.configFormDirty=!0,e.configFormMode==="form"&&(e.configRaw=et(s))}function Ji(e,t){const n=De(e.configForm??e.configSnapshot?.config??{});uo(n,t),e.configForm=n,e.configFormDirty=!0,e.configFormMode==="form"&&(e.configRaw=et(n))}async function Tt(e){if(!(!e.client||!e.connected))try{const t=await e.client.request("cron.status",{});e.cronStatus=t}catch(t){e.cronError=String(t)}}async function dn(e){if(!(!e.client||!e.connected)&&!e.cronLoading){e.cronLoading=!0,e.cronError=null;try{const t=await e.client.request("cron.list",{includeDisabled:!0});e.cronJobs=Array.isArray(t.jobs)?t.jobs:[]}catch(t){e.cronError=String(t)}finally{e.cronLoading=!1}}}function tc(e){if(e.scheduleKind==="at"){const n=Date.parse(e.scheduleAt);if(!Number.isFinite(n))throw new Error("Invalid run time.");return{kind:"at",atMs:n}}if(e.scheduleKind==="every"){const n=Qt(e.everyAmount,0);if(n<=0)throw new Error("Invalid interval amount.");const s=e.everyUnit;return{kind:"every",everyMs:n*(s==="minutes"?6e4:s==="hours"?36e5:864e5)}}const t=e.cronExpr.trim();if(!t)throw new Error("Cron expression required.");return{kind:"cron",expr:t,tz:e.cronTz.trim()||void 0}}function nc(e){if(e.payloadKind==="systemEvent"){const i=e.payloadText.trim();if(!i)throw new Error("System event text required.");return{kind:"systemEvent",text:i}}const t=e.payloadText.trim();if(!t)throw new Error("Agent message required.");const n={kind:"agentTurn",message:t};e.deliver&&(n.deliver=!0),e.channel&&(n.channel=e.channel),e.to.trim()&&(n.to=e.to.trim());const s=Qt(e.timeoutSeconds,0);return s>0&&(n.timeoutSeconds=s),n}async function sc(e){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const t=tc(e.cronForm),n=nc(e.cronForm),s=e.cronForm.agentId.trim(),i={name:e.cronForm.name.trim(),description:e.cronForm.description.trim()||void 0,agentId:s||void 0,enabled:e.cronForm.enabled,schedule:t,sessionTarget:e.cronForm.sessionTarget,wakeMode:e.cronForm.wakeMode,payload:n,isolation:e.cronForm.postToMainPrefix.trim()&&e.cronForm.sessionTarget==="isolated"?{postToMainPrefix:e.cronForm.postToMainPrefix.trim()}:void 0};if(!i.name)throw new Error("Name required.");await e.client.request("cron.add",i),e.cronForm={...e.cronForm,name:"",description:"",payloadText:""},await dn(e),await Tt(e)}catch(t){e.cronError=String(t)}finally{e.cronBusy=!1}}}async function ic(e,t,n){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.update",{id:t.id,patch:{enabled:n}}),await dn(e),await Tt(e)}catch(s){e.cronError=String(s)}finally{e.cronBusy=!1}}}async function ac(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.run",{id:t.id,mode:"force"}),await fo(e,t.id)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function oc(e,t){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{await e.client.request("cron.remove",{id:t.id}),e.cronRunsJobId===t.id&&(e.cronRunsJobId=null,e.cronRuns=[]),await dn(e),await Tt(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function fo(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("cron.runs",{id:t,limit:50});e.cronRunsJobId=t,e.cronRuns=Array.isArray(n.entries)?n.entries:[]}catch(n){e.cronError=String(n)}}async function oe(e,t){if(!(!e.client||!e.connected)&&!e.channelsLoading){e.channelsLoading=!0,e.channelsError=null;try{const n=await e.client.request("channels.status",{probe:t,timeoutMs:8e3});e.channelsSnapshot=n,e.channelsLastSuccess=Date.now()}catch(n){e.channelsError=String(n)}finally{e.channelsLoading=!1}}}async function rc(e,t){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{const n=await e.client.request("web.login.start",{force:t,timeoutMs:3e4});e.whatsappLoginMessage=n.message??null,e.whatsappLoginQrDataUrl=n.qrDataUrl??null,e.whatsappLoginConnected=null}catch(n){e.whatsappLoginMessage=String(n),e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function lc(e){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{const t=await e.client.request("web.login.wait",{timeoutMs:12e4});e.whatsappLoginMessage=t.message??null,e.whatsappLoginConnected=t.connected??null,t.connected&&(e.whatsappLoginQrDataUrl=null)}catch(t){e.whatsappLoginMessage=String(t),e.whatsappLoginConnected=null}finally{e.whatsappBusy=!1}}}async function cc(e){if(!(!e.client||!e.connected||e.whatsappBusy)){e.whatsappBusy=!0;try{await e.client.request("channels.logout",{channel:"whatsapp"}),e.whatsappLoginMessage="Logged out.",e.whatsappLoginQrDataUrl=null,e.whatsappLoginConnected=null}catch(t){e.whatsappLoginMessage=String(t)}finally{e.whatsappBusy=!1}}}async function un(e){if(!(!e.client||!e.connected)&&!e.debugLoading){e.debugLoading=!0;try{const[t,n,s,i]=await Promise.all([e.client.request("status",{}),e.client.request("health",{}),e.client.request("models.list",{}),e.client.request("last-heartbeat",{})]);e.debugStatus=t,e.debugHealth=n;const a=s;e.debugModels=Array.isArray(a?.models)?a?.models:[],e.debugHeartbeat=i}catch(t){e.debugCallError=String(t)}finally{e.debugLoading=!1}}}async function dc(e){if(!(!e.client||!e.connected)){e.debugCallError=null,e.debugCallResult=null;try{const t=e.debugCallParams.trim()?JSON.parse(e.debugCallParams):{},n=await e.client.request(e.debugCallMethod.trim(),t);e.debugCallResult=JSON.stringify(n,null,2)}catch(t){e.debugCallError=String(t)}}}const uc=2e3,pc=new Set(["trace","debug","info","warn","error","fatal"]);function fc(e){if(typeof e!="string")return null;const t=e.trim();if(!t.startsWith("{")||!t.endsWith("}"))return null;try{const n=JSON.parse(t);return!n||typeof n!="object"?null:n}catch{return null}}function hc(e){if(typeof e!="string")return null;const t=e.toLowerCase();return pc.has(t)?t:null}function gc(e){if(!e.trim())return{raw:e,message:e};try{const t=JSON.parse(e),n=t&&typeof t._meta=="object"&&t._meta!==null?t._meta:null,s=typeof t.time=="string"?t.time:typeof n?.date=="string"?n?.date:null,i=hc(n?.logLevelName??n?.level),a=typeof t[0]=="string"?t[0]:typeof n?.name=="string"?n?.name:null,o=fc(a);let l=null;o&&(typeof o.subsystem=="string"?l=o.subsystem:typeof o.module=="string"&&(l=o.module)),!l&&a&&a.length<120&&(l=a);let r=null;return typeof t[1]=="string"?r=t[1]:!o&&typeof t[0]=="string"?r=t[0]:typeof t.message=="string"&&(r=t.message),{raw:e,time:s,level:i,subsystem:l,message:r??e,meta:n??void 0}}catch{return{raw:e,message:e}}}async function Os(e,t){if(!(!e.client||!e.connected)&&!(e.logsLoading&&!t?.quiet)){t?.quiet||(e.logsLoading=!0),e.logsError=null;try{const s=await e.client.request("logs.tail",{cursor:t?.reset?void 0:e.logsCursor??void 0,limit:e.logsLimit,maxBytes:e.logsMaxBytes}),a=(Array.isArray(s.lines)?s.lines.filter(l=>typeof l=="string"):[]).map(gc),o=!!(t?.reset||s.reset||e.logsCursor==null);e.logsEntries=o?a:[...e.logsEntries,...a].slice(-uc),typeof s.cursor=="number"&&(e.logsCursor=s.cursor),typeof s.file=="string"&&(e.logsFile=s.file),e.logsTruncated=!!s.truncated,e.logsLastFetchAt=Date.now()}catch(n){e.logsError=String(n)}finally{t?.quiet||(e.logsLoading=!1)}}}const ho={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:W,n:Wt,Gx:Xi,Gy:ea,a:Hn,d:zn,h:vc}=ho,Be=32,Ds=64,mc=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},H=(e="")=>{const t=new Error(e);throw mc(t,H),t},yc=e=>typeof e=="bigint",bc=e=>typeof e=="string",wc=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",_e=(e,t,n="")=>{const s=wc(e),i=e?.length,a=t!==void 0;if(!s||a&&i!==t){const o=n&&`"${n}" `,l=a?` of length ${t}`:"",r=s?`length=${i}`:`type=${typeof e}`;H(o+"expected Uint8Array"+l+", got "+r)}return e},pn=e=>new Uint8Array(e),go=e=>Uint8Array.from(e),vo=(e,t)=>e.toString(16).padStart(t,"0"),mo=e=>Array.from(_e(e)).map(t=>vo(t,2)).join(""),ve={_0:48,_9:57,A:65,F:70,a:97,f:102},ta=e=>{if(e>=ve._0&&e<=ve._9)return e-ve._0;if(e>=ve.A&&e<=ve.F)return e-(ve.A-10);if(e>=ve.a&&e<=ve.f)return e-(ve.a-10)},yo=e=>{const t="hex invalid";if(!bc(e))return H(t);const n=e.length,s=n/2;if(n%2)return H(t);const i=pn(s);for(let a=0,o=0;a<s;a++,o+=2){const l=ta(e.charCodeAt(o)),r=ta(e.charCodeAt(o+1));if(l===void 0||r===void 0)return H(t);i[a]=l*16+r}return i},bo=()=>globalThis?.crypto,$c=()=>bo()?.subtle??H("crypto.subtle must be defined, consider polyfill"),St=(...e)=>{const t=pn(e.reduce((s,i)=>s+_e(i).length,0));let n=0;return e.forEach(s=>{t.set(s,n),n+=s.length}),t},xc=(e=Be)=>bo().getRandomValues(pn(e)),Zt=BigInt,Re=(e,t,n,s="bad number: out of range")=>yc(e)&&t<=e&&e<n?e:H(s),A=(e,t=W)=>{const n=e%t;return n>=0n?n:t+n},wo=e=>A(e,Wt),kc=(e,t)=>{(e===0n||t<=0n)&&H("no inverse n="+e+" mod="+t);let n=A(e,t),s=t,i=0n,a=1n;for(;n!==0n;){const o=s/n,l=s%n,r=i-a*o;s=n,n=l,i=a,a=r}return s===1n?A(i,t):H("no inverse")},Ac=e=>{const t=Ao[e];return typeof t!="function"&&H("hashes."+e+" not set"),t},jn=e=>e instanceof ee?e:H("Point expected"),ds=2n**256n;class ee{static BASE;static ZERO;X;Y;Z;T;constructor(t,n,s,i){const a=ds;this.X=Re(t,0n,a),this.Y=Re(n,0n,a),this.Z=Re(s,1n,a),this.T=Re(i,0n,a),Object.freeze(this)}static CURVE(){return ho}static fromAffine(t){return new ee(t.x,t.y,1n,A(t.x*t.y))}static fromBytes(t,n=!1){const s=zn,i=go(_e(t,Be)),a=t[31];i[31]=a&-129;const o=xo(i);Re(o,0n,n?ds:W);const r=A(o*o),p=A(r-1n),d=A(s*r+1n);let{isValid:u,value:g}=_c(p,d);u||H("bad point: y not sqrt");const v=(g&1n)===1n,w=(a&128)!==0;return!n&&g===0n&&w&&H("bad point: x==0, isLastByteOdd"),w!==v&&(g=A(-g)),new ee(g,o,1n,A(g*o))}static fromHex(t,n){return ee.fromBytes(yo(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=Hn,n=zn,s=this;if(s.is0())return H("bad point: ZERO");const{X:i,Y:a,Z:o,T:l}=s,r=A(i*i),p=A(a*a),d=A(o*o),u=A(d*d),g=A(r*t),v=A(d*A(g+p)),w=A(u+A(n*A(r*p)));if(v!==w)return H("bad point: equation left != right (1)");const $=A(i*a),k=A(o*l);return $!==k?H("bad point: equation left != right (2)"):this}equals(t){const{X:n,Y:s,Z:i}=this,{X:a,Y:o,Z:l}=jn(t),r=A(n*l),p=A(a*i),d=A(s*l),u=A(o*i);return r===p&&d===u}is0(){return this.equals(Qe)}negate(){return new ee(A(-this.X),this.Y,this.Z,A(-this.T))}double(){const{X:t,Y:n,Z:s}=this,i=Hn,a=A(t*t),o=A(n*n),l=A(2n*A(s*s)),r=A(i*a),p=t+n,d=A(A(p*p)-a-o),u=r+o,g=u-l,v=r-o,w=A(d*g),$=A(u*v),k=A(d*v),_=A(g*u);return new ee(w,$,_,k)}add(t){const{X:n,Y:s,Z:i,T:a}=this,{X:o,Y:l,Z:r,T:p}=jn(t),d=Hn,u=zn,g=A(n*o),v=A(s*l),w=A(a*u*p),$=A(i*r),k=A((n+s)*(o+l)-g-v),_=A($-w),I=A($+w),P=A(v-d*g),L=A(k*_),C=A(I*P),E=A(k*P),pe=A(_*I);return new ee(L,C,pe,E)}subtract(t){return this.add(jn(t).negate())}multiply(t,n=!0){if(!n&&(t===0n||this.is0()))return Qe;if(Re(t,1n,Wt),t===1n)return this;if(this.equals(Fe))return Dc(t).p;let s=Qe,i=Fe;for(let a=this;t>0n;a=a.double(),t>>=1n)t&1n?s=s.add(a):n&&(i=i.add(a));return s}multiplyUnsafe(t){return this.multiply(t,!1)}toAffine(){const{X:t,Y:n,Z:s}=this;if(this.equals(Qe))return{x:0n,y:1n};const i=kc(s,W);A(s*i)!==1n&&H("invalid inverse");const a=A(t*i),o=A(n*i);return{x:a,y:o}}toBytes(){const{x:t,y:n}=this.assertValidity().toAffine(),s=$o(n);return s[31]|=t&1n?128:0,s}toHex(){return mo(this.toBytes())}clearCofactor(){return this.multiply(Zt(vc),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let t=this.multiply(Wt/2n,!1).double();return Wt%2n&&(t=t.add(this)),t.is0()}}const Fe=new ee(Xi,ea,1n,A(Xi*ea)),Qe=new ee(0n,1n,1n,0n);ee.BASE=Fe;ee.ZERO=Qe;const $o=e=>yo(vo(Re(e,0n,ds),Ds)).reverse(),xo=e=>Zt("0x"+mo(go(_e(e)).reverse())),ce=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=W;return n},Sc=e=>{const n=e*e%W*e%W,s=ce(n,2n)*n%W,i=ce(s,1n)*e%W,a=ce(i,5n)*i%W,o=ce(a,10n)*a%W,l=ce(o,20n)*o%W,r=ce(l,40n)*l%W,p=ce(r,80n)*r%W,d=ce(p,80n)*r%W,u=ce(d,10n)*a%W;return{pow_p_5_8:ce(u,2n)*e%W,b2:n}},na=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,_c=(e,t)=>{const n=A(t*t*t),s=A(n*n*t),i=Sc(e*s).pow_p_5_8;let a=A(e*n*i);const o=A(t*a*a),l=a,r=A(a*na),p=o===e,d=o===A(-e),u=o===A(-e*na);return p&&(a=l),(d||u)&&(a=r),(A(a)&1n)===1n&&(a=A(-a)),{isValid:p||d,value:a}},us=e=>wo(xo(e)),Bs=(...e)=>Ao.sha512Async(St(...e)),Tc=(...e)=>Ac("sha512")(St(...e)),ko=e=>{const t=e.slice(0,Be);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(Be,Ds),s=us(t),i=Fe.multiply(s),a=i.toBytes();return{head:t,prefix:n,scalar:s,point:i,pointBytes:a}},Fs=e=>Bs(_e(e,Be)).then(ko),Cc=e=>ko(Tc(_e(e,Be))),Ec=e=>Fs(e).then(t=>t.pointBytes),Lc=e=>Bs(e.hashable).then(e.finish),Ic=(e,t,n)=>{const{pointBytes:s,scalar:i}=e,a=us(t),o=Fe.multiply(a).toBytes();return{hashable:St(o,s,n),finish:p=>{const d=wo(a+us(p)*i);return _e(St(o,$o(d)),Ds)}}},Mc=async(e,t)=>{const n=_e(e),s=await Fs(t),i=await Bs(s.prefix,n);return Lc(Ic(s,i,n))},Ao={sha512Async:async e=>{const t=$c(),n=St(e);return pn(await t.digest("SHA-512",n.buffer))},sha512:void 0},Rc=(e=xc(Be))=>e,Pc={getExtendedPublicKeyAsync:Fs,getExtendedPublicKey:Cc,randomSecretKey:Rc},Jt=8,Nc=256,So=Math.ceil(Nc/Jt)+1,ps=2**(Jt-1),Oc=()=>{const e=[];let t=Fe,n=t;for(let s=0;s<So;s++){n=t,e.push(n);for(let i=1;i<ps;i++)n=n.add(t),e.push(n);t=n.double()}return e};let sa;const ia=(e,t)=>{const n=t.negate();return e?n:t},Dc=e=>{const t=sa||(sa=Oc());let n=Qe,s=Fe;const i=2**Jt,a=i,o=Zt(i-1),l=Zt(Jt);for(let r=0;r<So;r++){let p=Number(e&o);e>>=l,p>ps&&(p-=a,e+=1n);const d=r*ps,u=d,g=d+Math.abs(p)-1,v=r%2!==0,w=p<0;p===0?s=s.add(ia(v,t[u])):n=n.add(ia(w,t[g]))}return e!==0n&&H("invalid wnaf"),{p:n,f:s}},qn="moltbot-device-identity-v1";function fs(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replaceAll("+","-").replaceAll("/","_").replace(/=+$/g,"")}function _o(e){const t=e.replaceAll("-","+").replaceAll("_","/"),n=t+"=".repeat((4-t.length%4)%4),s=atob(n),i=new Uint8Array(s.length);for(let a=0;a<s.length;a+=1)i[a]=s.charCodeAt(a);return i}function Bc(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function To(e){const t=await crypto.subtle.digest("SHA-256",e);return Bc(new Uint8Array(t))}async function Fc(){const e=Pc.randomSecretKey(),t=await Ec(e);return{deviceId:await To(t),publicKey:fs(t),privateKey:fs(e)}}async function Us(){try{const n=localStorage.getItem(qn);if(n){const s=JSON.parse(n);if(s?.version===1&&typeof s.deviceId=="string"&&typeof s.publicKey=="string"&&typeof s.privateKey=="string"){const i=await To(_o(s.publicKey));if(i!==s.deviceId){const a={...s,deviceId:i};return localStorage.setItem(qn,JSON.stringify(a)),{deviceId:i,publicKey:s.publicKey,privateKey:s.privateKey}}return{deviceId:s.deviceId,publicKey:s.publicKey,privateKey:s.privateKey}}}}catch{}const e=await Fc(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(qn,JSON.stringify(t)),e}async function Uc(e,t){const n=_o(e),s=new TextEncoder().encode(t),i=await Mc(s,n);return fs(i)}const Co="poolbot.device.auth.v1";function Ks(e){return e.trim()}function Kc(e){if(!Array.isArray(e))return[];const t=new Set;for(const n of e){const s=n.trim();s&&t.add(s)}return[...t].sort()}function Hs(){try{const e=window.localStorage.getItem(Co);if(!e)return null;const t=JSON.parse(e);return!t||t.version!==1||!t.deviceId||typeof t.deviceId!="string"||!t.tokens||typeof t.tokens!="object"?null:t}catch{return null}}function Eo(e){try{window.localStorage.setItem(Co,JSON.stringify(e))}catch{}}function Hc(e){const t=Hs();if(!t||t.deviceId!==e.deviceId)return null;const n=Ks(e.role),s=t.tokens[n];return!s||typeof s.token!="string"?null:s}function Lo(e){const t=Ks(e.role),n={version:1,deviceId:e.deviceId,tokens:{}},s=Hs();s&&s.deviceId===e.deviceId&&(n.tokens={...s.tokens});const i={token:e.token,role:t,scopes:Kc(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=i,Eo(n),i}function Io(e){const t=Hs();if(!t||t.deviceId!==e.deviceId)return;const n=Ks(e.role);if(!t.tokens[n])return;const s={...t,tokens:{...t.tokens}};delete s.tokens[n],Eo(s)}async function Te(e,t){if(!(!e.client||!e.connected)&&!e.devicesLoading){e.devicesLoading=!0,t?.quiet||(e.devicesError=null);try{const n=await e.client.request("device.pair.list",{});e.devicesList={pending:Array.isArray(n?.pending)?n.pending:[],paired:Array.isArray(n?.paired)?n.paired:[]}}catch(n){t?.quiet||(e.devicesError=String(n))}finally{e.devicesLoading=!1}}}async function zc(e,t){if(!(!e.client||!e.connected))try{await e.client.request("device.pair.approve",{requestId:t}),await Te(e)}catch(n){e.devicesError=String(n)}}async function jc(e,t){if(!(!e.client||!e.connected||!window.confirm("Reject this device pairing request?")))try{await e.client.request("device.pair.reject",{requestId:t}),await Te(e)}catch(s){e.devicesError=String(s)}}async function qc(e,t){if(!(!e.client||!e.connected))try{const n=await e.client.request("device.token.rotate",t);if(n?.token){const s=await Us(),i=n.role??t.role;(n.deviceId===s.deviceId||t.deviceId===s.deviceId)&&Lo({deviceId:s.deviceId,role:i,token:n.token,scopes:n.scopes??t.scopes??[]}),window.prompt("New device token (copy and store securely):",n.token)}await Te(e)}catch(n){e.devicesError=String(n)}}async function Wc(e,t){if(!(!e.client||!e.connected||!window.confirm(`Revoke token for ${t.deviceId} (${t.role})?`)))try{await e.client.request("device.token.revoke",t);const s=await Us();t.deviceId===s.deviceId&&Io({deviceId:s.deviceId,role:t.role}),await Te(e)}catch(s){e.devicesError=String(s)}}async function fn(e,t){if(!(!e.client||!e.connected)&&!e.nodesLoading){e.nodesLoading=!0,t?.quiet||(e.lastError=null);try{const n=await e.client.request("node.list",{});e.nodes=Array.isArray(n.nodes)?n.nodes:[]}catch(n){t?.quiet||(e.lastError=String(n))}finally{e.nodesLoading=!1}}}function Vc(e){if(!e||e.kind==="gateway")return{method:"exec.approvals.get",params:{}};const t=e.nodeId.trim();return t?{method:"exec.approvals.node.get",params:{nodeId:t}}:null}function Gc(e,t){if(!e||e.kind==="gateway")return{method:"exec.approvals.set",params:t};const n=e.nodeId.trim();return n?{method:"exec.approvals.node.set",params:{...t,nodeId:n}}:null}async function zs(e,t){if(!(!e.client||!e.connected)&&!e.execApprovalsLoading){e.execApprovalsLoading=!0,e.lastError=null;try{const n=Vc(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const s=await e.client.request(n.method,n.params);Yc(e,s)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function Yc(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=De(t.file??{}))}async function Qc(e,t){if(!(!e.client||!e.connected)){e.execApprovalsSaving=!0,e.lastError=null;try{const n=e.execApprovalsSnapshot?.hash;if(!n){e.lastError="Exec approvals hash missing; reload and retry.";return}const s=e.execApprovalsForm??e.execApprovalsSnapshot?.file??{},i=Gc(t,{file:s,baseHash:n});if(!i){e.lastError="Select a node before saving exec approvals.";return}await e.client.request(i.method,i.params),e.execApprovalsDirty=!1,await zs(e,t)}catch(n){e.lastError=String(n)}finally{e.execApprovalsSaving=!1}}}function Zc(e,t,n){const s=De(e.execApprovalsForm??e.execApprovalsSnapshot?.file??{});co(s,t,n),e.execApprovalsForm=s,e.execApprovalsDirty=!0}function Jc(e,t){const n=De(e.execApprovalsForm??e.execApprovalsSnapshot?.file??{});uo(n,t),e.execApprovalsForm=n,e.execApprovalsDirty=!0}async function js(e){if(!(!e.client||!e.connected)&&!e.presenceLoading){e.presenceLoading=!0,e.presenceError=null,e.presenceStatus=null;try{const t=await e.client.request("system-presence",{});Array.isArray(t)?(e.presenceEntries=t,e.presenceStatus=t.length===0?"No instances yet.":null):(e.presenceEntries=[],e.presenceStatus="No presence payload.")}catch(t){e.presenceError=String(t)}finally{e.presenceLoading=!1}}}function tt(e,t,n){if(!t.trim())return;const s={...e.skillMessages};n?s[t]=n:delete s[t],e.skillMessages=s}function hn(e){return e instanceof Error?e.message:String(e)}async function Ct(e,t){if(t?.clearMessages&&Object.keys(e.skillMessages).length>0&&(e.skillMessages={}),!(!e.client||!e.connected)&&!e.skillsLoading){e.skillsLoading=!0,e.skillsError=null;try{const n=await e.client.request("skills.status",{});n&&(e.skillsReport=n)}catch(n){e.skillsError=hn(n)}finally{e.skillsLoading=!1}}}function Xc(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function ed(e,t,n){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{await e.client.request("skills.update",{skillKey:t,enabled:n}),await Ct(e),tt(e,t,{kind:"success",message:n?"Skill enabled":"Skill disabled"})}catch(s){const i=hn(s);e.skillsError=i,tt(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function td(e,t){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const n=e.skillEdits[t]??"";await e.client.request("skills.update",{skillKey:t,apiKey:n}),await Ct(e),tt(e,t,{kind:"success",message:"API key saved"})}catch(n){const s=hn(n);e.skillsError=s,tt(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function nd(e,t,n,s){if(!(!e.client||!e.connected)){e.skillsBusyKey=t,e.skillsError=null;try{const i=await e.client.request("skills.install",{name:n,installId:s,timeoutMs:12e4});await Ct(e),tt(e,t,{kind:"success",message:i?.message??"Installed"})}catch(i){const a=hn(i);e.skillsError=a,tt(e,t,{kind:"error",message:a})}finally{e.skillsBusyKey=null}}}function sd(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function qs(e){return e==="system"?sd():e}const Ft=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,id=()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches??!1,Ut=e=>{e.classList.remove("theme-transition"),e.style.removeProperty("--theme-switch-x"),e.style.removeProperty("--theme-switch-y")},ad=({nextTheme:e,applyTheme:t,context:n,currentTheme:s})=>{if(s===e)return;const i=globalThis.document??null;if(!i){t();return}const a=i.documentElement,o=i,l=id();if(!!o.startViewTransition&&!l){let p=.5,d=.5;if(n?.pointerClientX!==void 0&&n?.pointerClientY!==void 0&&typeof window<"u")p=Ft(n.pointerClientX/window.innerWidth),d=Ft(n.pointerClientY/window.innerHeight);else if(n?.element){const u=n.element.getBoundingClientRect();u.width>0&&u.height>0&&typeof window<"u"&&(p=Ft((u.left+u.width/2)/window.innerWidth),d=Ft((u.top+u.height/2)/window.innerHeight))}a.style.setProperty("--theme-switch-x",`${p*100}%`),a.style.setProperty("--theme-switch-y",`${d*100}%`),a.classList.add("theme-transition");try{const u=o.startViewTransition?.(()=>{t()});u?.finished?u.finished.finally(()=>Ut(a)):Ut(a)}catch{Ut(a),t()}return}t(),Ut(a)};function od(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{fn(e,{quiet:!0})},5e3))}function rd(e){e.nodesPollInterval!=null&&(clearInterval(e.nodesPollInterval),e.nodesPollInterval=null)}function Ws(e){e.logsPollInterval==null&&(e.logsPollInterval=window.setInterval(()=>{e.tab==="logs"&&Os(e,{quiet:!0})},2e3))}function Vs(e){e.logsPollInterval!=null&&(clearInterval(e.logsPollInterval),e.logsPollInterval=null)}function Gs(e){e.debugPollInterval==null&&(e.debugPollInterval=window.setInterval(()=>{e.tab==="debug"&&un(e)},3e3))}function Ys(e){e.debugPollInterval!=null&&(clearInterval(e.debugPollInterval),e.debugPollInterval=null)}function ke(e,t){const n={...t,lastActiveSessionKey:t.lastActiveSessionKey?.trim()||t.sessionKey.trim()||"main"};e.settings=n,hl(n),t.theme!==e.theme&&(e.theme=t.theme,gn(e,qs(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function Mo(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&ke(e,{...e.settings,lastActiveSessionKey:n})}function ld(e){if(!window.location.search)return;const t=new URLSearchParams(window.location.search),n=t.get("token"),s=t.get("password"),i=t.get("session"),a=t.get("gatewayUrl");let o=!1;if(n!=null){const r=n.trim();r&&r!==e.settings.token&&ke(e,{...e.settings,token:r}),t.delete("token"),o=!0}if(s!=null){const r=s.trim();r&&(e.password=r),t.delete("password"),o=!0}if(i!=null){const r=i.trim();r&&(e.sessionKey=r,ke(e,{...e.settings,sessionKey:r,lastActiveSessionKey:r}))}if(a!=null){const r=a.trim();r&&r!==e.settings.gatewayUrl&&ke(e,{...e.settings,gatewayUrl:r}),t.delete("gatewayUrl"),o=!0}if(!o)return;const l=new URL(window.location.href);l.search=t.toString(),window.history.replaceState({},"",l.toString())}function cd(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?Ws(e):Vs(e),t==="debug"?Gs(e):Ys(e),Qs(e),Po(e,t,!1)}function dd(e,t,n){ad({nextTheme:t,applyTheme:()=>{e.theme=t,ke(e,{...e.settings,theme:t}),gn(e,qs(t))},context:n,currentTheme:e.theme})}async function Qs(e){e.tab==="overview"&&await No(e),e.tab==="channels"&&await yd(e),e.tab==="instances"&&await js(e),e.tab==="sessions"&&await st(e),e.tab==="cron"&&await Zs(e),e.tab==="skills"&&await Ct(e),e.tab==="nodes"&&(await fn(e),await Te(e),await ye(e),await zs(e)),e.tab==="chat"&&(await kd(e),cn(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await po(e),await ye(e)),e.tab==="debug"&&(await un(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"&&(e.logsAtBottom=!0,await Os(e,{reset:!0}),lo(e,!0))}function ud(){if(typeof window>"u")return"";const e=window.__CLAWDBOT_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?rn(e):vl(window.location.pathname)}function pd(e){e.theme=e.settings.theme??"system",gn(e,qs(e.theme))}function gn(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function fd(e){if(typeof window>"u"||typeof window.matchMedia!="function")return;if(e.themeMedia=window.matchMedia("(prefers-color-scheme: dark)"),e.themeMediaHandler=n=>{e.theme==="system"&&gn(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function hd(e){if(!e.themeMedia||!e.themeMediaHandler)return;if(typeof e.themeMedia.removeEventListener=="function"){e.themeMedia.removeEventListener("change",e.themeMediaHandler);return}e.themeMedia.removeListener(e.themeMediaHandler),e.themeMedia=null,e.themeMediaHandler=null}function gd(e,t){if(typeof window>"u")return;const n=io(window.location.pathname,e.basePath)??"chat";Ro(e,n),Po(e,n,t)}function vd(e){if(typeof window>"u")return;const t=io(window.location.pathname,e.basePath);if(!t)return;const s=new URL(window.location.href).searchParams.get("session")?.trim();s&&(e.sessionKey=s,ke(e,{...e.settings,sessionKey:s,lastActiveSessionKey:s})),Ro(e,t)}function Ro(e,t){e.tab!==t&&(e.tab=t),t==="chat"&&(e.chatHasAutoScrolled=!1),t==="logs"?Ws(e):Vs(e),t==="debug"?Gs(e):Ys(e),e.connected&&Qs(e)}function Po(e,t,n){if(typeof window>"u")return;const s=kt(Ps(t,e.basePath)),i=kt(window.location.pathname),a=new URL(window.location.href);t==="chat"&&e.sessionKey?a.searchParams.set("session",e.sessionKey):a.searchParams.delete("session"),i!==s&&(a.pathname=s),n?window.history.replaceState({},"",a.toString()):window.history.pushState({},"",a.toString())}function md(e,t,n){if(typeof window>"u")return;const s=new URL(window.location.href);s.searchParams.set("session",t),window.history.replaceState({},"",s.toString())}async function No(e){await Promise.all([oe(e,!1),js(e),st(e),Tt(e),un(e)])}async function yd(e){await Promise.all([oe(e,!0),po(e),ye(e)])}async function Zs(e){await Promise.all([oe(e,!1),Tt(e),dn(e)])}function Oo(e){return e.chatSending||!!e.chatRunId}function bd(e){const t=e.trim();if(!t)return!1;const n=t.toLowerCase();return n==="/stop"?!0:n==="stop"||n==="esc"||n==="abort"||n==="wait"||n==="exit"}async function Do(e){e.connected&&(e.chatMessage="",await Ml(e))}function wd(e,t,n){const s=t.trim(),i=!!(n&&n.length>0);!s&&!i||(e.chatQueue=[...e.chatQueue,{id:Ns(),text:s,createdAt:Date.now(),attachments:i?n?.map(a=>({...a})):void 0}])}async function Bo(e,t,n){ln(e);const s=await Il(e,t,n?.attachments);return!s&&n?.previousDraft!=null&&(e.chatMessage=n.previousDraft),!s&&n?.previousAttachments&&(e.chatAttachments=n.previousAttachments),s&&Mo(e,e.sessionKey),s&&n?.restoreDraft&&n.previousDraft?.trim()&&(e.chatMessage=n.previousDraft),s&&n?.restoreAttachments&&n.previousAttachments?.length&&(e.chatAttachments=n.previousAttachments),cn(e),s&&!e.chatRunId&&Fo(e),s}async function Fo(e){if(!e.connected||Oo(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await Bo(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function $d(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function xd(e,t,n){if(!e.connected)return;const s=e.chatMessage,i=(t??e.chatMessage).trim(),a=e.chatAttachments??[],o=t==null?a:[],l=o.length>0;if(!(!i&&!l)){if(bd(i)){await Do(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[]),Oo(e)){wd(e,i,o);return}await Bo(e,i,{previousDraft:t==null?s:void 0,restoreDraft:!!(t&&n?.restoreDraft),attachments:l?o:void 0,previousAttachments:t==null?a:void 0,restoreAttachments:!!(t&&n?.restoreDraft)})}}async function kd(e){await Promise.all([Xe(e),st(e),hs(e)]),cn(e,!0)}const Ad=Fo;function Sd(e){const t=to(e.sessionKey);return t?.agentId?t.agentId:e.hello?.snapshot?.sessionDefaults?.defaultAgentId?.trim()||"main"}function _d(e,t){const n=rn(e),s=encodeURIComponent(t);return n?`${n}/avatar/${s}?meta=1`:`/avatar/${s}?meta=1`}async function hs(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=Sd(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=_d(e.basePath,t);try{const s=await fetch(n,{method:"GET"});if(!s.ok){e.chatAvatarUrl=null;return}const i=await s.json(),a=typeof i.avatarUrl=="string"?i.avatarUrl.trim():"";e.chatAvatarUrl=a||null}catch{e.chatAvatarUrl=null}}const Uo={CHILD:2},Ko=e=>(...t)=>({_$litDirective$:e,values:t});let Ho=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,n,s){this._$Ct=t,this._$AM=n,this._$Ci=s}_$AS(t,n){return this.update(t,n)}update(t,n){return this.render(...n)}};const{I:Td}=sl,aa=e=>e,oa=()=>document.createComment(""),lt=(e,t,n)=>{const s=e._$AA.parentNode,i=t===void 0?e._$AB:t._$AA;if(n===void 0){const a=s.insertBefore(oa(),i),o=s.insertBefore(oa(),i);n=new Td(a,o,e,e.options)}else{const a=n._$AB.nextSibling,o=n._$AM,l=o!==e;if(l){let r;n._$AQ?.(e),n._$AM=e,n._$AP!==void 0&&(r=e._$AU)!==o._$AU&&n._$AP(r)}if(a!==i||l){let r=n._$AA;for(;r!==a;){const p=aa(r).nextSibling;aa(s).insertBefore(r,i),r=p}}}return n},Ie=(e,t,n=e)=>(e._$AI(t,n),e),Cd={},Ed=(e,t=Cd)=>e._$AH=t,Ld=e=>e._$AH,Wn=e=>{e._$AR(),e._$AA.remove()};const ra=(e,t,n)=>{const s=new Map;for(let i=t;i<=n;i++)s.set(e[i],i);return s},zo=Ko(class extends Ho{constructor(e){if(super(e),e.type!==Uo.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,n){let s;n===void 0?n=t:t!==void 0&&(s=t);const i=[],a=[];let o=0;for(const l of e)i[o]=s?s(l,o):o,a[o]=n(l,o),o++;return{values:a,keys:i}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,s]){const i=Ld(e),{values:a,keys:o}=this.dt(t,n,s);if(!Array.isArray(i))return this.ut=o,a;const l=this.ut??=[],r=[];let p,d,u=0,g=i.length-1,v=0,w=a.length-1;for(;u<=g&&v<=w;)if(i[u]===null)u++;else if(i[g]===null)g--;else if(l[u]===o[v])r[v]=Ie(i[u],a[v]),u++,v++;else if(l[g]===o[w])r[w]=Ie(i[g],a[w]),g--,w--;else if(l[u]===o[w])r[w]=Ie(i[u],a[w]),lt(e,r[w+1],i[u]),u++,w--;else if(l[g]===o[v])r[v]=Ie(i[g],a[v]),lt(e,i[u],i[g]),g--,v++;else if(p===void 0&&(p=ra(o,v,w),d=ra(l,u,g)),p.has(l[u]))if(p.has(l[g])){const $=d.get(o[v]),k=$!==void 0?i[$]:null;if(k===null){const _=lt(e,i[u]);Ie(_,a[v]),r[v]=_}else r[v]=Ie(k,a[v]),lt(e,i[u],k),i[$]=null;v++}else Wn(i[g]),g--;else Wn(i[u]),u++;for(;v<=w;){const $=lt(e,r[w+1]);Ie($,a[v]),r[v++]=$}for(;u<=g;){const $=i[u++];$!==null&&Wn($)}return this.ut=o,Ed(e,r),Se}});function jo(e){const t=e;let n=typeof t.role=="string"?t.role:"unknown";const s=typeof t.toolCallId=="string"||typeof t.tool_call_id=="string",i=t.content,a=Array.isArray(i)?i:null,o=Array.isArray(a)&&a.some(u=>{const v=String(u.type??"").toLowerCase();return v==="toolresult"||v==="tool_result"}),l=typeof t.toolName=="string"||typeof t.tool_name=="string";(s||o||l)&&(n="toolResult");let r=[];typeof t.content=="string"?r=[{type:"text",text:t.content}]:Array.isArray(t.content)?r=t.content.map(u=>({type:u.type||"text",text:u.text,name:u.name,args:u.args||u.arguments})):typeof t.text=="string"&&(r=[{type:"text",text:t.text}]);const p=typeof t.timestamp=="number"?t.timestamp:Date.now(),d=typeof t.id=="string"?t.id:void 0;return{role:n,content:r,timestamp:p,id:d}}function Js(e){const t=e.toLowerCase();return e==="user"||e==="User"?e:e==="assistant"?"assistant":e==="system"?"system":t==="toolresult"||t==="tool_result"||t==="tool"||t==="function"?"tool":e}function qo(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}class gs extends Ho{constructor(t){if(super(t),this.it=h,t.type!==Uo.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===h||t==null)return this._t=void 0,this.it=t;if(t===Se)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const n=[t];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}}gs.directiveName="unsafeHTML",gs.resultType=1;const vs=Ko(gs);const{entries:Wo,setPrototypeOf:la,isFrozen:Id,getPrototypeOf:Md,getOwnPropertyDescriptor:Rd}=Object;let{freeze:Z,seal:ne,create:ms}=Object,{apply:ys,construct:bs}=typeof Reflect<"u"&&Reflect;Z||(Z=function(t){return t});ne||(ne=function(t){return t});ys||(ys=function(t,n){for(var s=arguments.length,i=new Array(s>2?s-2:0),a=2;a<s;a++)i[a-2]=arguments[a];return t.apply(n,i)});bs||(bs=function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];return new t(...s)});const Kt=J(Array.prototype.forEach),Pd=J(Array.prototype.lastIndexOf),ca=J(Array.prototype.pop),ct=J(Array.prototype.push),Nd=J(Array.prototype.splice),Vt=J(String.prototype.toLowerCase),Vn=J(String.prototype.toString),Gn=J(String.prototype.match),dt=J(String.prototype.replace),Od=J(String.prototype.indexOf),Dd=J(String.prototype.trim),se=J(Object.prototype.hasOwnProperty),Y=J(RegExp.prototype.test),ut=Bd(TypeError);function J(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];return ys(e,t,s)}}function Bd(e){return function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return bs(e,n)}}function M(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Vt;la&&la(e,null);let s=t.length;for(;s--;){let i=t[s];if(typeof i=="string"){const a=n(i);a!==i&&(Id(t)||(t[s]=a),i=a)}e[i]=!0}return e}function Fd(e){for(let t=0;t<e.length;t++)se(e,t)||(e[t]=null);return e}function de(e){const t=ms(null);for(const[n,s]of Wo(e))se(e,n)&&(Array.isArray(s)?t[n]=Fd(s):s&&typeof s=="object"&&s.constructor===Object?t[n]=de(s):t[n]=s);return t}function pt(e,t){for(;e!==null;){const s=Rd(e,t);if(s){if(s.get)return J(s.get);if(typeof s.value=="function")return J(s.value)}e=Md(e)}function n(){return null}return n}const da=Z(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Yn=Z(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Qn=Z(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Ud=Z(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Zn=Z(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Kd=Z(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ua=Z(["#text"]),pa=Z(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Jn=Z(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),fa=Z(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Ht=Z(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Hd=ne(/\{\{[\w\W]*|[\w\W]*\}\}/gm),zd=ne(/<%[\w\W]*|[\w\W]*%>/gm),jd=ne(/\$\{[\w\W]*/gm),qd=ne(/^data-[\-\w.\u00B7-\uFFFF]+$/),Wd=ne(/^aria-[\-\w]+$/),Vo=ne(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Vd=ne(/^(?:\w+script|data):/i),Gd=ne(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Go=ne(/^html$/i),Yd=ne(/^[a-z][.\w]*(-[.\w]+)+$/i);var ha=Object.freeze({__proto__:null,ARIA_ATTR:Wd,ATTR_WHITESPACE:Gd,CUSTOM_ELEMENT:Yd,DATA_ATTR:qd,DOCTYPE_NAME:Go,ERB_EXPR:zd,IS_ALLOWED_URI:Vo,IS_SCRIPT_OR_DATA:Vd,MUSTACHE_EXPR:Hd,TMPLIT_EXPR:jd});const ft={element:1,text:3,progressingInstruction:7,comment:8,document:9},Qd=function(){return typeof window>"u"?null:window},Zd=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let s=null;const i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(s=n.getAttribute(i));const a="dompurify"+(s?"#"+s:"");try{return t.createPolicy(a,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},ga=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Yo(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Qd();const t=T=>Yo(T);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==ft.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const s=n,i=s.currentScript,{DocumentFragment:a,HTMLTemplateElement:o,Node:l,Element:r,NodeFilter:p,NamedNodeMap:d=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:u,DOMParser:g,trustedTypes:v}=e,w=r.prototype,$=pt(w,"cloneNode"),k=pt(w,"remove"),_=pt(w,"nextSibling"),I=pt(w,"childNodes"),P=pt(w,"parentNode");if(typeof o=="function"){const T=n.createElement("template");T.content&&T.content.ownerDocument&&(n=T.content.ownerDocument)}let L,C="";const{implementation:E,createNodeIterator:pe,createDocumentFragment:wn,getElementsByTagName:$n}=n,{importNode:Ar}=s;let G=ga();t.isSupported=typeof Wo=="function"&&typeof P=="function"&&E&&E.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:xn,ERB_EXPR:kn,TMPLIT_EXPR:An,DATA_ATTR:Sr,ARIA_ATTR:_r,IS_SCRIPT_OR_DATA:Tr,ATTR_WHITESPACE:di,CUSTOM_ELEMENT:Cr}=ha;let{IS_ALLOWED_URI:ui}=ha,K=null;const pi=M({},[...da,...Yn,...Qn,...Zn,...ua]);let z=null;const fi=M({},[...pa,...Jn,...fa,...Ht]);let B=Object.seal(ms(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),it=null,Sn=null;const He=Object.seal(ms(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let hi=!0,_n=!0,gi=!1,vi=!0,ze=!1,Lt=!0,Ce=!1,Tn=!1,Cn=!1,je=!1,It=!1,Mt=!1,mi=!0,yi=!1;const Er="user-content-";let En=!0,at=!1,qe={},re=null;const Ln=M({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let bi=null;const wi=M({},["audio","video","img","source","image","track"]);let In=null;const $i=M({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Rt="http://www.w3.org/1998/Math/MathML",Pt="http://www.w3.org/2000/svg",fe="http://www.w3.org/1999/xhtml";let We=fe,Mn=!1,Rn=null;const Lr=M({},[Rt,Pt,fe],Vn);let Nt=M({},["mi","mo","mn","ms","mtext"]),Ot=M({},["annotation-xml"]);const Ir=M({},["title","style","font","a","script"]);let ot=null;const Mr=["application/xhtml+xml","text/html"],Rr="text/html";let U=null,Ve=null;const Pr=n.createElement("form"),xi=function(f){return f instanceof RegExp||f instanceof Function},Pn=function(){let f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ve&&Ve===f)){if((!f||typeof f!="object")&&(f={}),f=de(f),ot=Mr.indexOf(f.PARSER_MEDIA_TYPE)===-1?Rr:f.PARSER_MEDIA_TYPE,U=ot==="application/xhtml+xml"?Vn:Vt,K=se(f,"ALLOWED_TAGS")?M({},f.ALLOWED_TAGS,U):pi,z=se(f,"ALLOWED_ATTR")?M({},f.ALLOWED_ATTR,U):fi,Rn=se(f,"ALLOWED_NAMESPACES")?M({},f.ALLOWED_NAMESPACES,Vn):Lr,In=se(f,"ADD_URI_SAFE_ATTR")?M(de($i),f.ADD_URI_SAFE_ATTR,U):$i,bi=se(f,"ADD_DATA_URI_TAGS")?M(de(wi),f.ADD_DATA_URI_TAGS,U):wi,re=se(f,"FORBID_CONTENTS")?M({},f.FORBID_CONTENTS,U):Ln,it=se(f,"FORBID_TAGS")?M({},f.FORBID_TAGS,U):de({}),Sn=se(f,"FORBID_ATTR")?M({},f.FORBID_ATTR,U):de({}),qe=se(f,"USE_PROFILES")?f.USE_PROFILES:!1,hi=f.ALLOW_ARIA_ATTR!==!1,_n=f.ALLOW_DATA_ATTR!==!1,gi=f.ALLOW_UNKNOWN_PROTOCOLS||!1,vi=f.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ze=f.SAFE_FOR_TEMPLATES||!1,Lt=f.SAFE_FOR_XML!==!1,Ce=f.WHOLE_DOCUMENT||!1,je=f.RETURN_DOM||!1,It=f.RETURN_DOM_FRAGMENT||!1,Mt=f.RETURN_TRUSTED_TYPE||!1,Cn=f.FORCE_BODY||!1,mi=f.SANITIZE_DOM!==!1,yi=f.SANITIZE_NAMED_PROPS||!1,En=f.KEEP_CONTENT!==!1,at=f.IN_PLACE||!1,ui=f.ALLOWED_URI_REGEXP||Vo,We=f.NAMESPACE||fe,Nt=f.MATHML_TEXT_INTEGRATION_POINTS||Nt,Ot=f.HTML_INTEGRATION_POINTS||Ot,B=f.CUSTOM_ELEMENT_HANDLING||{},f.CUSTOM_ELEMENT_HANDLING&&xi(f.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(B.tagNameCheck=f.CUSTOM_ELEMENT_HANDLING.tagNameCheck),f.CUSTOM_ELEMENT_HANDLING&&xi(f.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(B.attributeNameCheck=f.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),f.CUSTOM_ELEMENT_HANDLING&&typeof f.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(B.allowCustomizedBuiltInElements=f.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),ze&&(_n=!1),It&&(je=!0),qe&&(K=M({},ua),z=[],qe.html===!0&&(M(K,da),M(z,pa)),qe.svg===!0&&(M(K,Yn),M(z,Jn),M(z,Ht)),qe.svgFilters===!0&&(M(K,Qn),M(z,Jn),M(z,Ht)),qe.mathMl===!0&&(M(K,Zn),M(z,fa),M(z,Ht))),f.ADD_TAGS&&(typeof f.ADD_TAGS=="function"?He.tagCheck=f.ADD_TAGS:(K===pi&&(K=de(K)),M(K,f.ADD_TAGS,U))),f.ADD_ATTR&&(typeof f.ADD_ATTR=="function"?He.attributeCheck=f.ADD_ATTR:(z===fi&&(z=de(z)),M(z,f.ADD_ATTR,U))),f.ADD_URI_SAFE_ATTR&&M(In,f.ADD_URI_SAFE_ATTR,U),f.FORBID_CONTENTS&&(re===Ln&&(re=de(re)),M(re,f.FORBID_CONTENTS,U)),f.ADD_FORBID_CONTENTS&&(re===Ln&&(re=de(re)),M(re,f.ADD_FORBID_CONTENTS,U)),En&&(K["#text"]=!0),Ce&&M(K,["html","head","body"]),K.table&&(M(K,["tbody"]),delete it.tbody),f.TRUSTED_TYPES_POLICY){if(typeof f.TRUSTED_TYPES_POLICY.createHTML!="function")throw ut('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof f.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ut('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');L=f.TRUSTED_TYPES_POLICY,C=L.createHTML("")}else L===void 0&&(L=Zd(v,i)),L!==null&&typeof C=="string"&&(C=L.createHTML(""));Z&&Z(f),Ve=f}},ki=M({},[...Yn,...Qn,...Ud]),Ai=M({},[...Zn,...Kd]),Nr=function(f){let x=P(f);(!x||!x.tagName)&&(x={namespaceURI:We,tagName:"template"});const S=Vt(f.tagName),D=Vt(x.tagName);return Rn[f.namespaceURI]?f.namespaceURI===Pt?x.namespaceURI===fe?S==="svg":x.namespaceURI===Rt?S==="svg"&&(D==="annotation-xml"||Nt[D]):!!ki[S]:f.namespaceURI===Rt?x.namespaceURI===fe?S==="math":x.namespaceURI===Pt?S==="math"&&Ot[D]:!!Ai[S]:f.namespaceURI===fe?x.namespaceURI===Pt&&!Ot[D]||x.namespaceURI===Rt&&!Nt[D]?!1:!Ai[S]&&(Ir[S]||!ki[S]):!!(ot==="application/xhtml+xml"&&Rn[f.namespaceURI]):!1},le=function(f){ct(t.removed,{element:f});try{P(f).removeChild(f)}catch{k(f)}},Ee=function(f,x){try{ct(t.removed,{attribute:x.getAttributeNode(f),from:x})}catch{ct(t.removed,{attribute:null,from:x})}if(x.removeAttribute(f),f==="is")if(je||It)try{le(x)}catch{}else try{x.setAttribute(f,"")}catch{}},Si=function(f){let x=null,S=null;if(Cn)f="<remove></remove>"+f;else{const F=Gn(f,/^[\r\n\t ]+/);S=F&&F[0]}ot==="application/xhtml+xml"&&We===fe&&(f='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+f+"</body></html>");const D=L?L.createHTML(f):f;if(We===fe)try{x=new g().parseFromString(D,ot)}catch{}if(!x||!x.documentElement){x=E.createDocument(We,"template",null);try{x.documentElement.innerHTML=Mn?C:D}catch{}}const q=x.body||x.documentElement;return f&&S&&q.insertBefore(n.createTextNode(S),q.childNodes[0]||null),We===fe?$n.call(x,Ce?"html":"body")[0]:Ce?x.documentElement:q},_i=function(f){return pe.call(f.ownerDocument||f,f,p.SHOW_ELEMENT|p.SHOW_COMMENT|p.SHOW_TEXT|p.SHOW_PROCESSING_INSTRUCTION|p.SHOW_CDATA_SECTION,null)},Nn=function(f){return f instanceof u&&(typeof f.nodeName!="string"||typeof f.textContent!="string"||typeof f.removeChild!="function"||!(f.attributes instanceof d)||typeof f.removeAttribute!="function"||typeof f.setAttribute!="function"||typeof f.namespaceURI!="string"||typeof f.insertBefore!="function"||typeof f.hasChildNodes!="function")},Ti=function(f){return typeof l=="function"&&f instanceof l};function he(T,f,x){Kt(T,S=>{S.call(t,f,x,Ve)})}const Ci=function(f){let x=null;if(he(G.beforeSanitizeElements,f,null),Nn(f))return le(f),!0;const S=U(f.nodeName);if(he(G.uponSanitizeElement,f,{tagName:S,allowedTags:K}),Lt&&f.hasChildNodes()&&!Ti(f.firstElementChild)&&Y(/<[/\w!]/g,f.innerHTML)&&Y(/<[/\w!]/g,f.textContent)||f.nodeType===ft.progressingInstruction||Lt&&f.nodeType===ft.comment&&Y(/<[/\w]/g,f.data))return le(f),!0;if(!(He.tagCheck instanceof Function&&He.tagCheck(S))&&(!K[S]||it[S])){if(!it[S]&&Li(S)&&(B.tagNameCheck instanceof RegExp&&Y(B.tagNameCheck,S)||B.tagNameCheck instanceof Function&&B.tagNameCheck(S)))return!1;if(En&&!re[S]){const D=P(f)||f.parentNode,q=I(f)||f.childNodes;if(q&&D){const F=q.length;for(let X=F-1;X>=0;--X){const ge=$(q[X],!0);ge.__removalCount=(f.__removalCount||0)+1,D.insertBefore(ge,_(f))}}}return le(f),!0}return f instanceof r&&!Nr(f)||(S==="noscript"||S==="noembed"||S==="noframes")&&Y(/<\/no(script|embed|frames)/i,f.innerHTML)?(le(f),!0):(ze&&f.nodeType===ft.text&&(x=f.textContent,Kt([xn,kn,An],D=>{x=dt(x,D," ")}),f.textContent!==x&&(ct(t.removed,{element:f.cloneNode()}),f.textContent=x)),he(G.afterSanitizeElements,f,null),!1)},Ei=function(f,x,S){if(mi&&(x==="id"||x==="name")&&(S in n||S in Pr))return!1;if(!(_n&&!Sn[x]&&Y(Sr,x))){if(!(hi&&Y(_r,x))){if(!(He.attributeCheck instanceof Function&&He.attributeCheck(x,f))){if(!z[x]||Sn[x]){if(!(Li(f)&&(B.tagNameCheck instanceof RegExp&&Y(B.tagNameCheck,f)||B.tagNameCheck instanceof Function&&B.tagNameCheck(f))&&(B.attributeNameCheck instanceof RegExp&&Y(B.attributeNameCheck,x)||B.attributeNameCheck instanceof Function&&B.attributeNameCheck(x,f))||x==="is"&&B.allowCustomizedBuiltInElements&&(B.tagNameCheck instanceof RegExp&&Y(B.tagNameCheck,S)||B.tagNameCheck instanceof Function&&B.tagNameCheck(S))))return!1}else if(!In[x]){if(!Y(ui,dt(S,di,""))){if(!((x==="src"||x==="xlink:href"||x==="href")&&f!=="script"&&Od(S,"data:")===0&&bi[f])){if(!(gi&&!Y(Tr,dt(S,di,"")))){if(S)return!1}}}}}}}return!0},Li=function(f){return f!=="annotation-xml"&&Gn(f,Cr)},Ii=function(f){he(G.beforeSanitizeAttributes,f,null);const{attributes:x}=f;if(!x||Nn(f))return;const S={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:z,forceKeepAttr:void 0};let D=x.length;for(;D--;){const q=x[D],{name:F,namespaceURI:X,value:ge}=q,Ge=U(F),On=ge;let j=F==="value"?On:Dd(On);if(S.attrName=Ge,S.attrValue=j,S.keepAttr=!0,S.forceKeepAttr=void 0,he(G.uponSanitizeAttribute,f,S),j=S.attrValue,yi&&(Ge==="id"||Ge==="name")&&(Ee(F,f),j=Er+j),Lt&&Y(/((--!?|])>)|<\/(style|title|textarea)/i,j)){Ee(F,f);continue}if(Ge==="attributename"&&Gn(j,"href")){Ee(F,f);continue}if(S.forceKeepAttr)continue;if(!S.keepAttr){Ee(F,f);continue}if(!vi&&Y(/\/>/i,j)){Ee(F,f);continue}ze&&Kt([xn,kn,An],Ri=>{j=dt(j,Ri," ")});const Mi=U(f.nodeName);if(!Ei(Mi,Ge,j)){Ee(F,f);continue}if(L&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!X)switch(v.getAttributeType(Mi,Ge)){case"TrustedHTML":{j=L.createHTML(j);break}case"TrustedScriptURL":{j=L.createScriptURL(j);break}}if(j!==On)try{X?f.setAttributeNS(X,F,j):f.setAttribute(F,j),Nn(f)?le(f):ca(t.removed)}catch{Ee(F,f)}}he(G.afterSanitizeAttributes,f,null)},Or=function T(f){let x=null;const S=_i(f);for(he(G.beforeSanitizeShadowDOM,f,null);x=S.nextNode();)he(G.uponSanitizeShadowNode,x,null),Ci(x),Ii(x),x.content instanceof a&&T(x.content);he(G.afterSanitizeShadowDOM,f,null)};return t.sanitize=function(T){let f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},x=null,S=null,D=null,q=null;if(Mn=!T,Mn&&(T="<!-->"),typeof T!="string"&&!Ti(T))if(typeof T.toString=="function"){if(T=T.toString(),typeof T!="string")throw ut("dirty is not a string, aborting")}else throw ut("toString is not a function");if(!t.isSupported)return T;if(Tn||Pn(f),t.removed=[],typeof T=="string"&&(at=!1),at){if(T.nodeName){const ge=U(T.nodeName);if(!K[ge]||it[ge])throw ut("root node is forbidden and cannot be sanitized in-place")}}else if(T instanceof l)x=Si("<!---->"),S=x.ownerDocument.importNode(T,!0),S.nodeType===ft.element&&S.nodeName==="BODY"||S.nodeName==="HTML"?x=S:x.appendChild(S);else{if(!je&&!ze&&!Ce&&T.indexOf("<")===-1)return L&&Mt?L.createHTML(T):T;if(x=Si(T),!x)return je?null:Mt?C:""}x&&Cn&&le(x.firstChild);const F=_i(at?T:x);for(;D=F.nextNode();)Ci(D),Ii(D),D.content instanceof a&&Or(D.content);if(at)return T;if(je){if(It)for(q=wn.call(x.ownerDocument);x.firstChild;)q.appendChild(x.firstChild);else q=x;return(z.shadowroot||z.shadowrootmode)&&(q=Ar.call(s,q,!0)),q}let X=Ce?x.outerHTML:x.innerHTML;return Ce&&K["!doctype"]&&x.ownerDocument&&x.ownerDocument.doctype&&x.ownerDocument.doctype.name&&Y(Go,x.ownerDocument.doctype.name)&&(X="<!DOCTYPE "+x.ownerDocument.doctype.name+`>
17
+ `+X),ze&&Kt([xn,kn,An],ge=>{X=dt(X,ge," ")}),L&&Mt?L.createHTML(X):X},t.setConfig=function(){let T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Pn(T),Tn=!0},t.clearConfig=function(){Ve=null,Tn=!1},t.isValidAttribute=function(T,f,x){Ve||Pn({});const S=U(T),D=U(f);return Ei(S,D,x)},t.addHook=function(T,f){typeof f=="function"&&ct(G[T],f)},t.removeHook=function(T,f){if(f!==void 0){const x=Pd(G[T],f);return x===-1?void 0:Nd(G[T],x,1)[0]}return ca(G[T])},t.removeHooks=function(T){G[T]=[]},t.removeAllHooks=function(){G=ga()},t}var ws=Yo();function Xs(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ke=Xs();function Qo(e){Ke=e}var bt={exec:()=>null};function R(e,t=""){let n=typeof e=="string"?e:e.source,s={replace:(i,a)=>{let o=typeof a=="string"?a:a.source;return o=o.replace(Q.caret,"$1"),n=n.replace(i,o),s},getRegex:()=>new RegExp(n,t)};return s}var Jd=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Q={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},Xd=/^(?:[ \t]*(?:\n|$))+/,eu=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,tu=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Et=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,nu=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ei=/(?:[*+-]|\d{1,9}[.)])/,Zo=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Jo=R(Zo).replace(/bull/g,ei).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),su=R(Zo).replace(/bull/g,ei).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),ti=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,iu=/^[^\n]+/,ni=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,au=R(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ni).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ou=R(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ei).getRegex(),vn="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",si=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ru=R("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",si).replace("tag",vn).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Xo=R(ti).replace("hr",Et).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",vn).getRegex(),lu=R(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Xo).getRegex(),ii={blockquote:lu,code:eu,def:au,fences:tu,heading:nu,hr:Et,html:ru,lheading:Jo,list:ou,newline:Xd,paragraph:Xo,table:bt,text:iu},va=R("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Et).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",vn).getRegex(),cu={...ii,lheading:su,table:va,paragraph:R(ti).replace("hr",Et).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",va).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",vn).getRegex()},du={...ii,html:R(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",si).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:bt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:R(ti).replace("hr",Et).replace("heading",` *#{1,6} *[^
18
+ ]`).replace("lheading",Jo).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},uu=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,pu=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,er=/^( {2,}|\\)\n(?!\s*$)/,fu=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,mn=/[\p{P}\p{S}]/u,ai=/[\s\p{P}\p{S}]/u,tr=/[^\s\p{P}\p{S}]/u,hu=R(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ai).getRegex(),nr=/(?!~)[\p{P}\p{S}]/u,gu=/(?!~)[\s\p{P}\p{S}]/u,vu=/(?:[^\s\p{P}\p{S}]|~)/u,mu=R(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Jd?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),sr=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,yu=R(sr,"u").replace(/punct/g,mn).getRegex(),bu=R(sr,"u").replace(/punct/g,nr).getRegex(),ir="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",wu=R(ir,"gu").replace(/notPunctSpace/g,tr).replace(/punctSpace/g,ai).replace(/punct/g,mn).getRegex(),$u=R(ir,"gu").replace(/notPunctSpace/g,vu).replace(/punctSpace/g,gu).replace(/punct/g,nr).getRegex(),xu=R("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,tr).replace(/punctSpace/g,ai).replace(/punct/g,mn).getRegex(),ku=R(/\\(punct)/,"gu").replace(/punct/g,mn).getRegex(),Au=R(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Su=R(si).replace("(?:-->|$)","-->").getRegex(),_u=R("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Su).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Xt=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Tu=R(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Xt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ar=R(/^!?\[(label)\]\[(ref)\]/).replace("label",Xt).replace("ref",ni).getRegex(),or=R(/^!?\[(ref)\](?:\[\])?/).replace("ref",ni).getRegex(),Cu=R("reflink|nolink(?!\\()","g").replace("reflink",ar).replace("nolink",or).getRegex(),ma=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,oi={_backpedal:bt,anyPunctuation:ku,autolink:Au,blockSkip:mu,br:er,code:pu,del:bt,emStrongLDelim:yu,emStrongRDelimAst:wu,emStrongRDelimUnd:xu,escape:uu,link:Tu,nolink:or,punctuation:hu,reflink:ar,reflinkSearch:Cu,tag:_u,text:fu,url:bt},Eu={...oi,link:R(/^!?\[(label)\]\((.*?)\)/).replace("label",Xt).getRegex(),reflink:R(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Xt).getRegex()},$s={...oi,emStrongRDelimAst:$u,emStrongLDelim:bu,url:R(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",ma).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:R(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",ma).getRegex()},Lu={...$s,br:R(er).replace("{2,}","*").getRegex(),text:R($s.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},zt={normal:ii,gfm:cu,pedantic:du},ht={normal:oi,gfm:$s,breaks:Lu,pedantic:Eu},Iu={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ya=e=>Iu[e];function me(e,t){if(t){if(Q.escapeTest.test(e))return e.replace(Q.escapeReplace,ya)}else if(Q.escapeTestNoEncode.test(e))return e.replace(Q.escapeReplaceNoEncode,ya);return e}function ba(e){try{e=encodeURI(e).replace(Q.percentDecode,"%")}catch{return null}return e}function wa(e,t){let n=e.replace(Q.findPipe,(a,o,l)=>{let r=!1,p=o;for(;--p>=0&&l[p]==="\\";)r=!r;return r?"|":" |"}),s=n.split(Q.splitPipe),i=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),t)if(s.length>t)s.splice(t);else for(;s.length<t;)s.push("");for(;i<s.length;i++)s[i]=s[i].trim().replace(Q.slashPipe,"|");return s}function gt(e,t,n){let s=e.length;if(s===0)return"";let i=0;for(;i<s&&e.charAt(s-i-1)===t;)i++;return e.slice(0,s-i)}function Mu(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let s=0;s<e.length;s++)if(e[s]==="\\")s++;else if(e[s]===t[0])n++;else if(e[s]===t[1]&&(n--,n<0))return s;return n>0?-2:-1}function $a(e,t,n,s,i){let a=t.href,o=t.title||null,l=e[1].replace(i.other.outputLinkReplace,"$1");s.state.inLink=!0;let r={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:a,title:o,text:l,tokens:s.inlineTokens(l)};return s.state.inLink=!1,r}function Ru(e,t,n){let s=e.match(n.other.indentCodeCompensation);if(s===null)return t;let i=s[1];return t.split(`
19
+ `).map(a=>{let o=a.match(n.other.beginningSpace);if(o===null)return a;let[l]=o;return l.length>=i.length?a.slice(i.length):a}).join(`
20
20
  `)}var en=class{options;rules;lexer;constructor(e){this.options=e||Ke}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:gt(n,`
21
- `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],s=Lu(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:s}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let s=gt(n,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(n=s.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:gt(t[0],`
21
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],s=Ru(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:s}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let s=gt(n,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(n=s.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:gt(t[0],`
22
22
  `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=gt(t[0],`
23
23
  `).split(`
24
- `),s="",i="",a=[];for(;n.length>0;){let o=!1,c=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))c.push(n[l]),o=!0;else if(!o)c.push(n[l]);else break;n=n.slice(l);let p=c.join(`
24
+ `),s="",i="",a=[];for(;n.length>0;){let o=!1,l=[],r;for(r=0;r<n.length;r++)if(this.rules.other.blockquoteStart.test(n[r]))l.push(n[r]),o=!0;else if(!o)l.push(n[r]);else break;n=n.slice(r);let p=l.join(`
25
25
  `),d=p.replace(this.rules.other.blockquoteSetextReplace,`
26
26
  $1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
27
27
  ${p}`:p,i=i?`${i}
28
- ${d}`:d;let u=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,a,!0),this.lexer.state.top=u,n.length===0)break;let h=a.at(-1);if(h?.type==="code")break;if(h?.type==="blockquote"){let v=h,w=v.raw+`
28
+ ${d}`:d;let u=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,a,!0),this.lexer.state.top=u,n.length===0)break;let g=a.at(-1);if(g?.type==="code")break;if(g?.type==="blockquote"){let v=g,w=v.raw+`
29
29
  `+n.join(`
30
- `),$=this.blockquote(w);a[a.length-1]=$,s=s.substring(0,s.length-v.raw.length)+$.raw,i=i.substring(0,i.length-v.text.length)+$.text;break}else if(h?.type==="list"){let v=h,w=v.raw+`
30
+ `),$=this.blockquote(w);a[a.length-1]=$,s=s.substring(0,s.length-v.raw.length)+$.raw,i=i.substring(0,i.length-v.text.length)+$.text;break}else if(g?.type==="list"){let v=g,w=v.raw+`
31
31
  `+n.join(`
32
- `),$=this.list(w);a[a.length-1]=$,s=s.substring(0,s.length-h.raw.length)+$.raw,i=i.substring(0,i.length-v.raw.length)+$.raw,n=w.substring(a.at(-1).raw.length).split(`
33
- `);continue}}return{type:"blockquote",raw:s,tokens:a,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),s=n.length>1,i={type:"list",raw:"",ordered:s,start:s?+n.slice(0,-1):"",loose:!1,items:[]};n=s?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=s?n:"[*+-]");let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let l=!1,p="",d="";if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;p=t[0],e=e.substring(p.length);let u=t[2].split(`
34
- `,1)[0].replace(this.rules.other.listReplaceTabs,$=>" ".repeat(3*$.length)),h=e.split(`
35
- `,1)[0],v=!u.trim(),w=0;if(this.options.pedantic?(w=2,d=u.trimStart()):v?w=t[1].length+1:(w=t[2].search(this.rules.other.nonSpaceChar),w=w>4?1:w,d=u.slice(w),w+=t[1].length),v&&this.rules.other.blankLine.test(h)&&(p+=h+`
36
- `,e=e.substring(h.length+1),l=!0),!l){let $=this.rules.other.nextBulletRegex(w),k=this.rules.other.hrRegex(w),T=this.rules.other.fencesBeginRegex(w),M=this.rules.other.headingBeginRegex(w),P=this.rules.other.htmlBeginRegex(w);for(;e;){let L=e.split(`
37
- `,1)[0],C;if(h=L,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),C=h):C=h.replace(this.rules.other.tabCharGlobal," "),T.test(h)||M.test(h)||P.test(h)||$.test(h)||k.test(h))break;if(C.search(this.rules.other.nonSpaceChar)>=w||!h.trim())d+=`
38
- `+C.slice(w);else{if(v||u.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||T.test(u)||M.test(u)||k.test(u))break;d+=`
39
- `+h}!v&&!h.trim()&&(v=!0),p+=L+`
40
- `,e=e.substring(L.length+1),u=C.slice(w)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(o=!0)),i.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(d),loose:!1,text:d,tokens:[]}),i.raw+=p}let c=i.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let l of i.items){if(this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]),l.task){if(l.text=l.text.replace(this.rules.other.listReplaceTask,""),l.tokens[0]?.type==="text"||l.tokens[0]?.type==="paragraph"){l.tokens[0].raw=l.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),l.tokens[0].text=l.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let d=this.lexer.inlineQueue.length-1;d>=0;d--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[d].src)){this.lexer.inlineQueue[d].src=this.lexer.inlineQueue[d].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(l.raw);if(p){let d={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};l.checked=d.checked,i.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=d.raw+l.tokens[0].raw,l.tokens[0].text=d.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(d)):l.tokens.unshift({type:"paragraph",raw:d.raw,text:d.raw,tokens:[d]}):l.tokens.unshift(d)}}if(!i.loose){let p=l.tokens.filter(u=>u.type==="space"),d=p.length>0&&p.some(u=>this.rules.other.anyLine.test(u.raw));i.loose=d}}if(i.loose)for(let l of i.items){l.loose=!0;for(let p of l.tokens)p.type==="text"&&(p.type="paragraph")}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:s,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=ya(t[1]),s=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
41
- `):[],a={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===s.length){for(let o of s)this.rules.other.tableAlignRight.test(o)?a.align.push("right"):this.rules.other.tableAlignCenter.test(o)?a.align.push("center"):this.rules.other.tableAlignLeft.test(o)?a.align.push("left"):a.align.push(null);for(let o=0;o<n.length;o++)a.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:!0,align:a.align[o]});for(let o of i)a.rows.push(ya(o,a.header.length).map((c,l)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:a.align[l]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
42
- `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let a=gt(n.slice(0,-1),"\\");if((n.length-a.length)%2===0)return}else{let a=Eu(t[2],"()");if(a===-2)return;if(a>-1){let o=(t[0].indexOf("!")===0?5:4)+t[1].length+a;t[2]=t[2].substring(0,a),t[0]=t[0].substring(0,o).trim(),t[3]=""}}let s=t[2],i="";if(this.options.pedantic){let a=this.rules.other.pedanticHrefTitle.exec(s);a&&(s=a[1],i=a[3])}else i=t[3]?t[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?s=s.slice(1):s=s.slice(1,-1)),wa(t,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let s=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[s.toLowerCase()];if(!i){let a=n[0].charAt(0);return{type:"text",raw:a,text:a}}return wa(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!(!s||s[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[2])||!n||this.rules.inline.punctuation.exec(n))){let i=[...s[0]].length-1,a,o,c=i,l=0,p=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(p.lastIndex=0,t=t.slice(-1*e.length+i);(s=p.exec(t))!=null;){if(a=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!a)continue;if(o=[...a].length,s[3]||s[4]){c+=o;continue}else if((s[5]||s[6])&&i%3&&!((i+o)%3)){l+=o;continue}if(c-=o,c>0)continue;o=Math.min(o,o+c+l);let d=[...s[0]][0].length,u=e.slice(0,i+s.index+d+o);if(Math.min(i,o)%2){let v=u.slice(1,-1);return{type:"em",raw:u,text:v,tokens:this.lexer.inlineTokens(v)}}let h=u.slice(2,-2);return{type:"strong",raw:u,text:h,tokens:this.lexer.inlineTokens(h)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return s&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,s;return t[2]==="@"?(n=t[1],s="mailto:"+n):(n=t[1],s=n),{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,s;if(t[2]==="@")n=t[0],s="mailto:"+n;else{let i;do i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(i!==t[0]);n=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},ie=class $s{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Ke,this.options.tokenizer=this.options.tokenizer||new en,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:Y,block:zt.normal,inline:ht.normal};this.options.pedantic?(n.block=zt.pedantic,n.inline=ht.pedantic):this.options.gfm&&(n.block=zt.gfm,this.options.breaks?n.inline=ht.breaks:n.inline=ht.gfm),this.tokenizer.rules=n}static get rules(){return{block:zt,inline:ht}}static lex(t,n){return new $s(n).lex(t)}static lexInline(t,n){return new $s(n).inlineTokens(t)}lex(t){t=t.replace(Y.carriageReturn,`
43
- `),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let s=this.inlineQueue[n];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],s=!1){for(this.options.pedantic&&(t=t.replace(Y.tabCharGlobal," ").replace(Y.spaceLine,""));t;){let i;if(this.options.extensions?.block?.some(o=>(i=o.call({lexer:this},t,n))?(t=t.substring(i.raw.length),n.push(i),!0):!1))continue;if(i=this.tokenizer.space(t)){t=t.substring(i.raw.length);let o=n.at(-1);i.raw.length===1&&o!==void 0?o.raw+=`
32
+ `),$=this.list(w);a[a.length-1]=$,s=s.substring(0,s.length-g.raw.length)+$.raw,i=i.substring(0,i.length-v.raw.length)+$.raw,n=w.substring(a.at(-1).raw.length).split(`
33
+ `);continue}}return{type:"blockquote",raw:s,tokens:a,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),s=n.length>1,i={type:"list",raw:"",ordered:s,start:s?+n.slice(0,-1):"",loose:!1,items:[]};n=s?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=s?n:"[*+-]");let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let r=!1,p="",d="";if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;p=t[0],e=e.substring(p.length);let u=t[2].split(`
34
+ `,1)[0].replace(this.rules.other.listReplaceTabs,$=>" ".repeat(3*$.length)),g=e.split(`
35
+ `,1)[0],v=!u.trim(),w=0;if(this.options.pedantic?(w=2,d=u.trimStart()):v?w=t[1].length+1:(w=t[2].search(this.rules.other.nonSpaceChar),w=w>4?1:w,d=u.slice(w),w+=t[1].length),v&&this.rules.other.blankLine.test(g)&&(p+=g+`
36
+ `,e=e.substring(g.length+1),r=!0),!r){let $=this.rules.other.nextBulletRegex(w),k=this.rules.other.hrRegex(w),_=this.rules.other.fencesBeginRegex(w),I=this.rules.other.headingBeginRegex(w),P=this.rules.other.htmlBeginRegex(w);for(;e;){let L=e.split(`
37
+ `,1)[0],C;if(g=L,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),C=g):C=g.replace(this.rules.other.tabCharGlobal," "),_.test(g)||I.test(g)||P.test(g)||$.test(g)||k.test(g))break;if(C.search(this.rules.other.nonSpaceChar)>=w||!g.trim())d+=`
38
+ `+C.slice(w);else{if(v||u.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||_.test(u)||I.test(u)||k.test(u))break;d+=`
39
+ `+g}!v&&!g.trim()&&(v=!0),p+=L+`
40
+ `,e=e.substring(L.length+1),u=C.slice(w)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(o=!0)),i.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(d),loose:!1,text:d,tokens:[]}),i.raw+=p}let l=i.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let r of i.items){if(this.lexer.state.top=!1,r.tokens=this.lexer.blockTokens(r.text,[]),r.task){if(r.text=r.text.replace(this.rules.other.listReplaceTask,""),r.tokens[0]?.type==="text"||r.tokens[0]?.type==="paragraph"){r.tokens[0].raw=r.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),r.tokens[0].text=r.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let d=this.lexer.inlineQueue.length-1;d>=0;d--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[d].src)){this.lexer.inlineQueue[d].src=this.lexer.inlineQueue[d].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(r.raw);if(p){let d={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};r.checked=d.checked,i.loose?r.tokens[0]&&["paragraph","text"].includes(r.tokens[0].type)&&"tokens"in r.tokens[0]&&r.tokens[0].tokens?(r.tokens[0].raw=d.raw+r.tokens[0].raw,r.tokens[0].text=d.raw+r.tokens[0].text,r.tokens[0].tokens.unshift(d)):r.tokens.unshift({type:"paragraph",raw:d.raw,text:d.raw,tokens:[d]}):r.tokens.unshift(d)}}if(!i.loose){let p=r.tokens.filter(u=>u.type==="space"),d=p.length>0&&p.some(u=>this.rules.other.anyLine.test(u.raw));i.loose=d}}if(i.loose)for(let r of i.items){r.loose=!0;for(let p of r.tokens)p.type==="text"&&(p.type="paragraph")}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:s,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=wa(t[1]),s=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
41
+ `):[],a={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===s.length){for(let o of s)this.rules.other.tableAlignRight.test(o)?a.align.push("right"):this.rules.other.tableAlignCenter.test(o)?a.align.push("center"):this.rules.other.tableAlignLeft.test(o)?a.align.push("left"):a.align.push(null);for(let o=0;o<n.length;o++)a.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:!0,align:a.align[o]});for(let o of i)a.rows.push(wa(o,a.header.length).map((l,r)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:a.align[r]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
42
+ `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let a=gt(n.slice(0,-1),"\\");if((n.length-a.length)%2===0)return}else{let a=Mu(t[2],"()");if(a===-2)return;if(a>-1){let o=(t[0].indexOf("!")===0?5:4)+t[1].length+a;t[2]=t[2].substring(0,a),t[0]=t[0].substring(0,o).trim(),t[3]=""}}let s=t[2],i="";if(this.options.pedantic){let a=this.rules.other.pedanticHrefTitle.exec(s);a&&(s=a[1],i=a[3])}else i=t[3]?t[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?s=s.slice(1):s=s.slice(1,-1)),$a(t,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let s=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[s.toLowerCase()];if(!i){let a=n[0].charAt(0);return{type:"text",raw:a,text:a}}return $a(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!(!s||s[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[2])||!n||this.rules.inline.punctuation.exec(n))){let i=[...s[0]].length-1,a,o,l=i,r=0,p=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(p.lastIndex=0,t=t.slice(-1*e.length+i);(s=p.exec(t))!=null;){if(a=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!a)continue;if(o=[...a].length,s[3]||s[4]){l+=o;continue}else if((s[5]||s[6])&&i%3&&!((i+o)%3)){r+=o;continue}if(l-=o,l>0)continue;o=Math.min(o,o+l+r);let d=[...s[0]][0].length,u=e.slice(0,i+s.index+d+o);if(Math.min(i,o)%2){let v=u.slice(1,-1);return{type:"em",raw:u,text:v,tokens:this.lexer.inlineTokens(v)}}let g=u.slice(2,-2);return{type:"strong",raw:u,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return s&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,s;return t[2]==="@"?(n=t[1],s="mailto:"+n):(n=t[1],s=n),{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,s;if(t[2]==="@")n=t[0],s="mailto:"+n;else{let i;do i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(i!==t[0]);n=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},ie=class xs{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Ke,this.options.tokenizer=this.options.tokenizer||new en,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:Q,block:zt.normal,inline:ht.normal};this.options.pedantic?(n.block=zt.pedantic,n.inline=ht.pedantic):this.options.gfm&&(n.block=zt.gfm,this.options.breaks?n.inline=ht.breaks:n.inline=ht.gfm),this.tokenizer.rules=n}static get rules(){return{block:zt,inline:ht}}static lex(t,n){return new xs(n).lex(t)}static lexInline(t,n){return new xs(n).inlineTokens(t)}lex(t){t=t.replace(Q.carriageReturn,`
43
+ `),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let s=this.inlineQueue[n];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],s=!1){for(this.options.pedantic&&(t=t.replace(Q.tabCharGlobal," ").replace(Q.spaceLine,""));t;){let i;if(this.options.extensions?.block?.some(o=>(i=o.call({lexer:this},t,n))?(t=t.substring(i.raw.length),n.push(i),!0):!1))continue;if(i=this.tokenizer.space(t)){t=t.substring(i.raw.length);let o=n.at(-1);i.raw.length===1&&o!==void 0?o.raw+=`
44
44
  `:n.push(i);continue}if(i=this.tokenizer.code(t)){t=t.substring(i.raw.length);let o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=(o.raw.endsWith(`
45
45
  `)?"":`
46
46
  `)+i.raw,o.text+=`
47
47
  `+i.text,this.inlineQueue.at(-1).src=o.text):n.push(i);continue}if(i=this.tokenizer.fences(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.heading(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.hr(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.blockquote(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.list(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.html(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.def(t)){t=t.substring(i.raw.length);let o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=(o.raw.endsWith(`
48
48
  `)?"":`
49
49
  `)+i.raw,o.text+=`
50
- `+i.raw,this.inlineQueue.at(-1).src=o.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},n.push(i));continue}if(i=this.tokenizer.table(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.lheading(t)){t=t.substring(i.raw.length),n.push(i);continue}let a=t;if(this.options.extensions?.startBlock){let o=1/0,c=t.slice(1),l;this.options.extensions.startBlock.forEach(p=>{l=p.call({lexer:this},c),typeof l=="number"&&l>=0&&(o=Math.min(o,l))}),o<1/0&&o>=0&&(a=t.substring(0,o+1))}if(this.state.top&&(i=this.tokenizer.paragraph(a))){let o=n.at(-1);s&&o?.type==="paragraph"?(o.raw+=(o.raw.endsWith(`
50
+ `+i.raw,this.inlineQueue.at(-1).src=o.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},n.push(i));continue}if(i=this.tokenizer.table(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.lheading(t)){t=t.substring(i.raw.length),n.push(i);continue}let a=t;if(this.options.extensions?.startBlock){let o=1/0,l=t.slice(1),r;this.options.extensions.startBlock.forEach(p=>{r=p.call({lexer:this},l),typeof r=="number"&&r>=0&&(o=Math.min(o,r))}),o<1/0&&o>=0&&(a=t.substring(0,o+1))}if(this.state.top&&(i=this.tokenizer.paragraph(a))){let o=n.at(-1);s&&o?.type==="paragraph"?(o.raw+=(o.raw.endsWith(`
51
51
  `)?"":`
52
52
  `)+i.raw,o.text+=`
53
53
  `+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(i),s=a.length!==t.length,t=t.substring(i.raw.length);continue}if(i=this.tokenizer.text(t)){t=t.substring(i.raw.length);let o=n.at(-1);o?.type==="text"?(o.raw+=(o.raw.endsWith(`
54
54
  `)?"":`
55
55
  `)+i.raw,o.text+=`
56
- `+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(i);continue}if(t){let o="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(o);break}else throw new Error(o)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let s=t,i=null;if(this.tokens.links){let l=Object.keys(this.tokens.links);if(l.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)l.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,i.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let a;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)a=i[2]?i[2].length:0,s=s.slice(0,i.index+a)+"["+"a".repeat(i[0].length-a-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);s=this.options.hooks?.emStrongMask?.call({lexer:this},s)??s;let o=!1,c="";for(;t;){o||(c=""),o=!1;let l;if(this.options.extensions?.inline?.some(d=>(l=d.call({lexer:this},t,n))?(t=t.substring(l.raw.length),n.push(l),!0):!1))continue;if(l=this.tokenizer.escape(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.tag(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.link(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(l.raw.length);let d=n.at(-1);l.type==="text"&&d?.type==="text"?(d.raw+=l.raw,d.text+=l.text):n.push(l);continue}if(l=this.tokenizer.emStrong(t,s,c)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.codespan(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.br(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.del(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.autolink(t)){t=t.substring(l.raw.length),n.push(l);continue}if(!this.state.inLink&&(l=this.tokenizer.url(t))){t=t.substring(l.raw.length),n.push(l);continue}let p=t;if(this.options.extensions?.startInline){let d=1/0,u=t.slice(1),h;this.options.extensions.startInline.forEach(v=>{h=v.call({lexer:this},u),typeof h=="number"&&h>=0&&(d=Math.min(d,h))}),d<1/0&&d>=0&&(p=t.substring(0,d+1))}if(l=this.tokenizer.inlineText(p)){t=t.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(c=l.raw.slice(-1)),o=!0;let d=n.at(-1);d?.type==="text"?(d.raw+=l.raw,d.text+=l.text):n.push(l);continue}if(t){let d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return n}},tn=class{options;parser;constructor(e){this.options=e||Ke}space(e){return""}code({text:e,lang:t,escaped:n}){let s=(t||"").match(Y.notSpaceStart)?.[0],i=e.replace(Y.endingNewline,"")+`
56
+ `+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(i);continue}if(t){let o="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(o);break}else throw new Error(o)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let s=t,i=null;if(this.tokens.links){let r=Object.keys(this.tokens.links);if(r.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)r.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,i.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let a;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)a=i[2]?i[2].length:0,s=s.slice(0,i.index+a)+"["+"a".repeat(i[0].length-a-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);s=this.options.hooks?.emStrongMask?.call({lexer:this},s)??s;let o=!1,l="";for(;t;){o||(l=""),o=!1;let r;if(this.options.extensions?.inline?.some(d=>(r=d.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))continue;if(r=this.tokenizer.escape(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.link(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(r.raw.length);let d=n.at(-1);r.type==="text"&&d?.type==="text"?(d.raw+=r.raw,d.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(t,s,l)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(t)){t=t.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(t))){t=t.substring(r.raw.length),n.push(r);continue}let p=t;if(this.options.extensions?.startInline){let d=1/0,u=t.slice(1),g;this.options.extensions.startInline.forEach(v=>{g=v.call({lexer:this},u),typeof g=="number"&&g>=0&&(d=Math.min(d,g))}),d<1/0&&d>=0&&(p=t.substring(0,d+1))}if(r=this.tokenizer.inlineText(p)){t=t.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(l=r.raw.slice(-1)),o=!0;let d=n.at(-1);d?.type==="text"?(d.raw+=r.raw,d.text+=r.text):n.push(r);continue}if(t){let d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return n}},tn=class{options;parser;constructor(e){this.options=e||Ke}space(e){return""}code({text:e,lang:t,escaped:n}){let s=(t||"").match(Q.notSpaceStart)?.[0],i=e.replace(Q.endingNewline,"")+`
57
57
  `;return s?'<pre><code class="language-'+me(s)+'">'+(n?i:me(i,!0))+`</code></pre>
58
58
  `:"<pre><code>"+(n?i:me(i,!0))+`</code></pre>
59
59
  `}blockquote({tokens:e}){return`<blockquote>
60
60
  ${this.parser.parse(e)}</blockquote>
61
61
  `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
62
62
  `}hr(e){return`<hr>
63
- `}list(e){let t=e.ordered,n=e.start,s="";for(let o=0;o<e.items.length;o++){let c=e.items[o];s+=this.listitem(c)}let i=t?"ol":"ul",a=t&&n!==1?' start="'+n+'"':"";return"<"+i+a+`>
63
+ `}list(e){let t=e.ordered,n=e.start,s="";for(let o=0;o<e.items.length;o++){let l=e.items[o];s+=this.listitem(l)}let i=t?"ol":"ul",a=t&&n!==1?' start="'+n+'"':"";return"<"+i+a+`>
64
64
  `+s+"</"+i+`>
65
65
  `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
66
66
  `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
@@ -71,50 +71,50 @@ ${this.parser.parse(e)}</blockquote>
71
71
  `}tablerow({text:e}){return`<tr>
72
72
  ${e}</tr>
73
73
  `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
74
- `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${me(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let s=this.parser.parseInline(n),i=ba(e);if(i===null)return s;e=i;let a='<a href="'+e+'"';return t&&(a+=' title="'+me(t)+'"'),a+=">"+s+"</a>",a}image({href:e,title:t,text:n,tokens:s}){s&&(n=this.parser.parseInline(s,this.parser.textRenderer));let i=ba(e);if(i===null)return me(n);e=i;let a=`<img src="${e}" alt="${n}"`;return t&&(a+=` title="${me(t)}"`),a+=">",a}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:me(e.text)}},ri=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},ae=class xs{options;renderer;textRenderer;constructor(t){this.options=t||Ke,this.options.renderer=this.options.renderer||new tn,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ri}static parse(t,n){return new xs(n).parse(t)}static parseInline(t,n){return new xs(n).parseInline(t)}parse(t){let n="";for(let s=0;s<t.length;s++){let i=t[s];if(this.options.extensions?.renderers?.[i.type]){let o=i,c=this.options.extensions.renderers[o.type].call({parser:this},o);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(o.type)){n+=c||"";continue}}let a=i;switch(a.type){case"space":{n+=this.renderer.space(a);break}case"hr":{n+=this.renderer.hr(a);break}case"heading":{n+=this.renderer.heading(a);break}case"code":{n+=this.renderer.code(a);break}case"table":{n+=this.renderer.table(a);break}case"blockquote":{n+=this.renderer.blockquote(a);break}case"list":{n+=this.renderer.list(a);break}case"checkbox":{n+=this.renderer.checkbox(a);break}case"html":{n+=this.renderer.html(a);break}case"def":{n+=this.renderer.def(a);break}case"paragraph":{n+=this.renderer.paragraph(a);break}case"text":{n+=this.renderer.text(a);break}default:{let o='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(t,n=this.renderer){let s="";for(let i=0;i<t.length;i++){let a=t[i];if(this.options.extensions?.renderers?.[a.type]){let c=this.options.extensions.renderers[a.type].call({parser:this},a);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){s+=c||"";continue}}let o=a;switch(o.type){case"escape":{s+=n.text(o);break}case"html":{s+=n.html(o);break}case"link":{s+=n.link(o);break}case"image":{s+=n.image(o);break}case"checkbox":{s+=n.checkbox(o);break}case"strong":{s+=n.strong(o);break}case"em":{s+=n.em(o);break}case"codespan":{s+=n.codespan(o);break}case"br":{s+=n.br(o);break}case"del":{s+=n.del(o);break}case"text":{s+=n.text(o);break}default:{let c='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return s}},vt=class{options;block;constructor(e){this.options=e||Ke}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?ie.lex:ie.lexInline}provideParser(){return this.block?ae.parse:ae.parseInline}},Mu=class{defaults=Xs();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ae;Renderer=tn;TextRenderer=ri;Lexer=ie;Tokenizer=en;Hooks=vt;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let s of e)switch(n=n.concat(t.call(this,s)),s.type){case"table":{let i=s;for(let a of i.header)n=n.concat(this.walkTokens(a.tokens,t));for(let a of i.rows)for(let o of a)n=n.concat(this.walkTokens(o.tokens,t));break}case"list":{let i=s;n=n.concat(this.walkTokens(i.items,t));break}default:{let i=s;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(a=>{let o=i[a].flat(1/0);n=n.concat(this.walkTokens(o,t))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let a=t.renderers[i.name];a?t.renderers[i.name]=function(...o){let c=i.renderer.apply(this,o);return c===!1&&(c=a.apply(this,o)),c}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let a=t[i.level];a?a.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),s.extensions=t),n.renderer){let i=this.defaults.renderer||new tn(this.defaults);for(let a in n.renderer){if(!(a in i))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;let o=a,c=n.renderer[o],l=i[o];i[o]=(...p)=>{let d=c.apply(i,p);return d===!1&&(d=l.apply(i,p)),d||""}}s.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new en(this.defaults);for(let a in n.tokenizer){if(!(a in i))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;let o=a,c=n.tokenizer[o],l=i[o];i[o]=(...p)=>{let d=c.apply(i,p);return d===!1&&(d=l.apply(i,p)),d}}s.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new vt;for(let a in n.hooks){if(!(a in i))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;let o=a,c=n.hooks[o],l=i[o];vt.passThroughHooks.has(a)?i[o]=p=>{if(this.defaults.async&&vt.passThroughHooksRespectAsync.has(a))return(async()=>{let u=await c.call(i,p);return l.call(i,u)})();let d=c.call(i,p);return l.call(i,d)}:i[o]=(...p)=>{if(this.defaults.async)return(async()=>{let u=await c.apply(i,p);return u===!1&&(u=await l.apply(i,p)),u})();let d=c.apply(i,p);return d===!1&&(d=l.apply(i,p)),d}}s.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,a=n.walkTokens;s.walkTokens=function(o){let c=[];return c.push(a.call(this,o)),i&&(c=c.concat(i.call(this,o))),c}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ie.lex(e,t??this.defaults)}parser(e,t){return ae.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let s={...n},i={...this.defaults,...s},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&s.async===!1)return a(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(t):t,c=await(i.hooks?await i.hooks.provideLexer():e?ie.lex:ie.lexInline)(o,i),l=i.hooks?await i.hooks.processAllTokens(c):c;i.walkTokens&&await Promise.all(this.walkTokens(l,i.walkTokens));let p=await(i.hooks?await i.hooks.provideParser():e?ae.parse:ae.parseInline)(l,i);return i.hooks?await i.hooks.postprocess(p):p})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let o=(i.hooks?i.hooks.provideLexer():e?ie.lex:ie.lexInline)(t,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let c=(i.hooks?i.hooks.provideParser():e?ae.parse:ae.parseInline)(o,i);return i.hooks&&(c=i.hooks.postprocess(c)),c}catch(o){return a(o)}}}onError(e,t){return n=>{if(n.message+=`
75
- Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error occurred:</p><pre>"+me(n.message+"",!0)+"</pre>";return t?Promise.resolve(s):s}if(t)return Promise.reject(n);throw n}}},Ue=new Mu;function N(e,t){return Ue.parse(e,t)}N.options=N.setOptions=function(e){return Ue.setOptions(e),N.defaults=Ue.defaults,Yo(N.defaults),N};N.getDefaults=Xs;N.defaults=Ke;N.use=function(...e){return Ue.use(...e),N.defaults=Ue.defaults,Yo(N.defaults),N};N.walkTokens=function(e,t){return Ue.walkTokens(e,t)};N.parseInline=Ue.parseInline;N.Parser=ae;N.parser=ae.parse;N.Renderer=tn;N.TextRenderer=ri;N.Lexer=ie;N.lexer=ie.lex;N.Tokenizer=en;N.Hooks=vt;N.parse=N;N.options;N.setOptions;N.use;N.walkTokens;N.parseInline;ae.parse;ie.lex;N.setOptions({gfm:!0,breaks:!0,mangle:!1});const $a=["a","b","blockquote","br","code","del","em","h1","h2","h3","h4","hr","i","li","ol","p","pre","strong","table","tbody","td","th","thead","tr","ul"],xa=["class","href","rel","target","title","start"];let ka=!1;const Iu=14e4,Ru=4e4,Pu=200,Jn=5e4,Ne=new Map;function Nu(e){const t=Ne.get(e);return t===void 0?null:(Ne.delete(e),Ne.set(e,t),t)}function Aa(e,t){if(Ne.set(e,t),Ne.size<=Pu)return;const n=Ne.keys().next().value;n&&Ne.delete(n)}function Ou(){ka||(ka=!0,ys.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function ks(e){const t=e.trim();if(!t)return"";if(Ou(),t.length<=Jn){const o=Nu(t);if(o!==null)return o}const n=ao(t,Iu),s=n.truncated?`
74
+ `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${me(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let s=this.parser.parseInline(n),i=ba(e);if(i===null)return s;e=i;let a='<a href="'+e+'"';return t&&(a+=' title="'+me(t)+'"'),a+=">"+s+"</a>",a}image({href:e,title:t,text:n,tokens:s}){s&&(n=this.parser.parseInline(s,this.parser.textRenderer));let i=ba(e);if(i===null)return me(n);e=i;let a=`<img src="${e}" alt="${n}"`;return t&&(a+=` title="${me(t)}"`),a+=">",a}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:me(e.text)}},ri=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},ae=class ks{options;renderer;textRenderer;constructor(t){this.options=t||Ke,this.options.renderer=this.options.renderer||new tn,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ri}static parse(t,n){return new ks(n).parse(t)}static parseInline(t,n){return new ks(n).parseInline(t)}parse(t){let n="";for(let s=0;s<t.length;s++){let i=t[s];if(this.options.extensions?.renderers?.[i.type]){let o=i,l=this.options.extensions.renderers[o.type].call({parser:this},o);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(o.type)){n+=l||"";continue}}let a=i;switch(a.type){case"space":{n+=this.renderer.space(a);break}case"hr":{n+=this.renderer.hr(a);break}case"heading":{n+=this.renderer.heading(a);break}case"code":{n+=this.renderer.code(a);break}case"table":{n+=this.renderer.table(a);break}case"blockquote":{n+=this.renderer.blockquote(a);break}case"list":{n+=this.renderer.list(a);break}case"checkbox":{n+=this.renderer.checkbox(a);break}case"html":{n+=this.renderer.html(a);break}case"def":{n+=this.renderer.def(a);break}case"paragraph":{n+=this.renderer.paragraph(a);break}case"text":{n+=this.renderer.text(a);break}default:{let o='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(t,n=this.renderer){let s="";for(let i=0;i<t.length;i++){let a=t[i];if(this.options.extensions?.renderers?.[a.type]){let l=this.options.extensions.renderers[a.type].call({parser:this},a);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){s+=l||"";continue}}let o=a;switch(o.type){case"escape":{s+=n.text(o);break}case"html":{s+=n.html(o);break}case"link":{s+=n.link(o);break}case"image":{s+=n.image(o);break}case"checkbox":{s+=n.checkbox(o);break}case"strong":{s+=n.strong(o);break}case"em":{s+=n.em(o);break}case"codespan":{s+=n.codespan(o);break}case"br":{s+=n.br(o);break}case"del":{s+=n.del(o);break}case"text":{s+=n.text(o);break}default:{let l='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return s}},vt=class{options;block;constructor(e){this.options=e||Ke}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?ie.lex:ie.lexInline}provideParser(){return this.block?ae.parse:ae.parseInline}},Pu=class{defaults=Xs();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ae;Renderer=tn;TextRenderer=ri;Lexer=ie;Tokenizer=en;Hooks=vt;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let s of e)switch(n=n.concat(t.call(this,s)),s.type){case"table":{let i=s;for(let a of i.header)n=n.concat(this.walkTokens(a.tokens,t));for(let a of i.rows)for(let o of a)n=n.concat(this.walkTokens(o.tokens,t));break}case"list":{let i=s;n=n.concat(this.walkTokens(i.items,t));break}default:{let i=s;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(a=>{let o=i[a].flat(1/0);n=n.concat(this.walkTokens(o,t))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let a=t.renderers[i.name];a?t.renderers[i.name]=function(...o){let l=i.renderer.apply(this,o);return l===!1&&(l=a.apply(this,o)),l}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let a=t[i.level];a?a.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),s.extensions=t),n.renderer){let i=this.defaults.renderer||new tn(this.defaults);for(let a in n.renderer){if(!(a in i))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;let o=a,l=n.renderer[o],r=i[o];i[o]=(...p)=>{let d=l.apply(i,p);return d===!1&&(d=r.apply(i,p)),d||""}}s.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new en(this.defaults);for(let a in n.tokenizer){if(!(a in i))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;let o=a,l=n.tokenizer[o],r=i[o];i[o]=(...p)=>{let d=l.apply(i,p);return d===!1&&(d=r.apply(i,p)),d}}s.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new vt;for(let a in n.hooks){if(!(a in i))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;let o=a,l=n.hooks[o],r=i[o];vt.passThroughHooks.has(a)?i[o]=p=>{if(this.defaults.async&&vt.passThroughHooksRespectAsync.has(a))return(async()=>{let u=await l.call(i,p);return r.call(i,u)})();let d=l.call(i,p);return r.call(i,d)}:i[o]=(...p)=>{if(this.defaults.async)return(async()=>{let u=await l.apply(i,p);return u===!1&&(u=await r.apply(i,p)),u})();let d=l.apply(i,p);return d===!1&&(d=r.apply(i,p)),d}}s.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,a=n.walkTokens;s.walkTokens=function(o){let l=[];return l.push(a.call(this,o)),i&&(l=l.concat(i.call(this,o))),l}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ie.lex(e,t??this.defaults)}parser(e,t){return ae.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let s={...n},i={...this.defaults,...s},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&s.async===!1)return a(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(t):t,l=await(i.hooks?await i.hooks.provideLexer():e?ie.lex:ie.lexInline)(o,i),r=i.hooks?await i.hooks.processAllTokens(l):l;i.walkTokens&&await Promise.all(this.walkTokens(r,i.walkTokens));let p=await(i.hooks?await i.hooks.provideParser():e?ae.parse:ae.parseInline)(r,i);return i.hooks?await i.hooks.postprocess(p):p})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let o=(i.hooks?i.hooks.provideLexer():e?ie.lex:ie.lexInline)(t,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let l=(i.hooks?i.hooks.provideParser():e?ae.parse:ae.parseInline)(o,i);return i.hooks&&(l=i.hooks.postprocess(l)),l}catch(o){return a(o)}}}onError(e,t){return n=>{if(n.message+=`
75
+ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error occurred:</p><pre>"+me(n.message+"",!0)+"</pre>";return t?Promise.resolve(s):s}if(t)return Promise.reject(n);throw n}}},Ue=new Pu;function N(e,t){return Ue.parse(e,t)}N.options=N.setOptions=function(e){return Ue.setOptions(e),N.defaults=Ue.defaults,Qo(N.defaults),N};N.getDefaults=Xs;N.defaults=Ke;N.use=function(...e){return Ue.use(...e),N.defaults=Ue.defaults,Qo(N.defaults),N};N.walkTokens=function(e,t){return Ue.walkTokens(e,t)};N.parseInline=Ue.parseInline;N.Parser=ae;N.parser=ae.parse;N.Renderer=tn;N.TextRenderer=ri;N.Lexer=ie;N.lexer=ie.lex;N.Tokenizer=en;N.Hooks=vt;N.parse=N;N.options;N.setOptions;N.use;N.walkTokens;N.parseInline;ae.parse;ie.lex;N.setOptions({gfm:!0,breaks:!0,mangle:!1});const xa=["a","b","blockquote","br","code","del","em","h1","h2","h3","h4","hr","i","li","ol","p","pre","strong","table","tbody","td","th","thead","tr","ul"],ka=["class","href","rel","target","title","start"];let Aa=!1;const Nu=14e4,Ou=4e4,Du=200,Xn=5e4,Ne=new Map;function Bu(e){const t=Ne.get(e);return t===void 0?null:(Ne.delete(e),Ne.set(e,t),t)}function Sa(e,t){if(Ne.set(e,t),Ne.size<=Du)return;const n=Ne.keys().next().value;n&&Ne.delete(n)}function Fu(){Aa||(Aa=!0,ws.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function As(e){const t=e.trim();if(!t)return"";if(Fu(),t.length<=Xn){const o=Bu(t);if(o!==null)return o}const n=oo(t,Nu),s=n.truncated?`
76
76
 
77
- … truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>Ru){const c=`<pre class="code-block">${Du(`${n.text}${s}`)}</pre>`,l=ys.sanitize(c,{ALLOWED_TAGS:$a,ALLOWED_ATTR:xa});return t.length<=Jn&&Aa(t,l),l}const i=N.parse(`${n.text}${s}`),a=ys.sanitize(i,{ALLOWED_TAGS:$a,ALLOWED_ATTR:xa});return t.length<=Jn&&Aa(t,a),a}function Du(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const Bu=1500,Fu=2e3,or="Copy as markdown",Uu="Copied",Ku="Copy failed";async function Hu(e){if(!e)return!1;try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}function jt(e,t){e.title=t,e.setAttribute("aria-label",t)}function zu(e){const t=e.label??or;return r`
77
+ … truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>Ou){const l=`<pre class="code-block">${Uu(`${n.text}${s}`)}</pre>`,r=ws.sanitize(l,{ALLOWED_TAGS:xa,ALLOWED_ATTR:ka});return t.length<=Xn&&Sa(t,r),r}const i=N.parse(`${n.text}${s}`),a=ws.sanitize(i,{ALLOWED_TAGS:xa,ALLOWED_ATTR:ka});return t.length<=Xn&&Sa(t,a),a}function Uu(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const Ku=1500,Hu=2e3,rr="Copy as markdown",zu="Copied",ju="Copy failed";async function qu(e){if(!e)return!1;try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}function jt(e,t){e.title=t,e.setAttribute("aria-label",t)}function Wu(e){const t=e.label??rr;return c`
78
78
  <button
79
79
  class="chat-copy-btn"
80
80
  type="button"
81
81
  title=${t}
82
82
  aria-label=${t}
83
- @click=${async n=>{const s=n.currentTarget;if(s?.querySelector(".chat-copy-btn__icon"),!s||s.dataset.copying==="1")return;s.dataset.copying="1",s.setAttribute("aria-busy","true"),s.disabled=!0;const i=await Hu(e.text());if(s.isConnected){if(delete s.dataset.copying,s.removeAttribute("aria-busy"),s.disabled=!1,!i){s.dataset.error="1",jt(s,Ku),window.setTimeout(()=>{s.isConnected&&(delete s.dataset.error,jt(s,t))},Fu);return}s.dataset.copied="1",jt(s,Uu),window.setTimeout(()=>{s.isConnected&&(delete s.dataset.copied,jt(s,t))},Bu)}}}
83
+ @click=${async n=>{const s=n.currentTarget;if(s?.querySelector(".chat-copy-btn__icon"),!s||s.dataset.copying==="1")return;s.dataset.copying="1",s.setAttribute("aria-busy","true"),s.disabled=!0;const i=await qu(e.text());if(s.isConnected){if(delete s.dataset.copying,s.removeAttribute("aria-busy"),s.disabled=!1,!i){s.dataset.error="1",jt(s,ju),window.setTimeout(()=>{s.isConnected&&(delete s.dataset.error,jt(s,t))},Hu);return}s.dataset.copied="1",jt(s,zu),window.setTimeout(()=>{s.isConnected&&(delete s.dataset.copied,jt(s,t))},Ku)}}}
84
84
  >
85
85
  <span class="chat-copy-btn__icon" aria-hidden="true">
86
- <span class="chat-copy-btn__icon-copy">${Q.copy}</span>
87
- <span class="chat-copy-btn__icon-check">${Q.check}</span>
86
+ <span class="chat-copy-btn__icon-copy">${V.copy}</span>
87
+ <span class="chat-copy-btn__icon-check">${V.check}</span>
88
88
  </span>
89
89
  </button>
90
- `}function ju(e){return zu({text:()=>e,label:or})}const qu={icon:"puzzle",detailKeys:["command","path","url","targetUrl","targetId","ref","element","node","nodeId","id","requestId","to","channelId","guildId","userId","name","query","pattern","messageId"]},Vu={bash:{icon:"wrench",title:"Bash",detailKeys:["command"]},process:{icon:"wrench",title:"Process",detailKeys:["sessionId"]},read:{icon:"fileText",title:"Read",detailKeys:["path"]},write:{icon:"edit",title:"Write",detailKeys:["path"]},edit:{icon:"penLine",title:"Edit",detailKeys:["path"]},attach:{icon:"paperclip",title:"Attach",detailKeys:["path","url","fileName"]},browser:{icon:"globe",title:"Browser",actions:{status:{label:"status"},start:{label:"start"},stop:{label:"stop"},tabs:{label:"tabs"},open:{label:"open",detailKeys:["targetUrl"]},focus:{label:"focus",detailKeys:["targetId"]},close:{label:"close",detailKeys:["targetId"]},snapshot:{label:"snapshot",detailKeys:["targetUrl","targetId","ref","element","format"]},screenshot:{label:"screenshot",detailKeys:["targetUrl","targetId","ref","element"]},navigate:{label:"navigate",detailKeys:["targetUrl","targetId"]},console:{label:"console",detailKeys:["level","targetId"]},pdf:{label:"pdf",detailKeys:["targetId"]},upload:{label:"upload",detailKeys:["paths","ref","inputRef","element","targetId"]},dialog:{label:"dialog",detailKeys:["accept","promptText","targetId"]},act:{label:"act",detailKeys:["request.kind","request.ref","request.selector","request.text","request.value"]}}},canvas:{icon:"image",title:"Canvas",actions:{present:{label:"present",detailKeys:["target","node","nodeId"]},hide:{label:"hide",detailKeys:["node","nodeId"]},navigate:{label:"navigate",detailKeys:["url","node","nodeId"]},eval:{label:"eval",detailKeys:["javaScript","node","nodeId"]},snapshot:{label:"snapshot",detailKeys:["format","node","nodeId"]},a2ui_push:{label:"A2UI push",detailKeys:["jsonlPath","node","nodeId"]},a2ui_reset:{label:"A2UI reset",detailKeys:["node","nodeId"]}}},nodes:{icon:"smartphone",title:"Nodes",actions:{status:{label:"status"},describe:{label:"describe",detailKeys:["node","nodeId"]},pending:{label:"pending"},approve:{label:"approve",detailKeys:["requestId"]},reject:{label:"reject",detailKeys:["requestId"]},notify:{label:"notify",detailKeys:["node","nodeId","title","body"]},camera_snap:{label:"camera snap",detailKeys:["node","nodeId","facing","deviceId"]},camera_list:{label:"camera list",detailKeys:["node","nodeId"]},camera_clip:{label:"camera clip",detailKeys:["node","nodeId","facing","duration","durationMs"]},screen_record:{label:"screen record",detailKeys:["node","nodeId","duration","durationMs","fps","screenIndex"]}}},cron:{icon:"loader",title:"Cron",actions:{status:{label:"status"},list:{label:"list"},add:{label:"add",detailKeys:["job.name","job.id","job.schedule","job.cron"]},update:{label:"update",detailKeys:["id"]},remove:{label:"remove",detailKeys:["id"]},run:{label:"run",detailKeys:["id"]},runs:{label:"runs",detailKeys:["id"]},wake:{label:"wake",detailKeys:["text","mode"]}}},gateway:{icon:"plug",title:"Gateway",actions:{restart:{label:"restart",detailKeys:["reason","delayMs"]},"config.get":{label:"config get"},"config.schema":{label:"config schema"},"config.apply":{label:"config apply",detailKeys:["restartDelayMs"]},"update.run":{label:"update run",detailKeys:["restartDelayMs"]}}},whatsapp_login:{icon:"circle",title:"WhatsApp Login",actions:{start:{label:"start"},wait:{label:"wait"}}},discord:{icon:"messageSquare",title:"Discord",actions:{react:{label:"react",detailKeys:["channelId","messageId","emoji"]},reactions:{label:"reactions",detailKeys:["channelId","messageId"]},sticker:{label:"sticker",detailKeys:["to","stickerIds"]},poll:{label:"poll",detailKeys:["question","to"]},permissions:{label:"permissions",detailKeys:["channelId"]},readMessages:{label:"read messages",detailKeys:["channelId","limit"]},sendMessage:{label:"send",detailKeys:["to","content"]},editMessage:{label:"edit",detailKeys:["channelId","messageId"]},deleteMessage:{label:"delete",detailKeys:["channelId","messageId"]},threadCreate:{label:"thread create",detailKeys:["channelId","name"]},threadList:{label:"thread list",detailKeys:["guildId","channelId"]},threadReply:{label:"thread reply",detailKeys:["channelId","content"]},pinMessage:{label:"pin",detailKeys:["channelId","messageId"]},unpinMessage:{label:"unpin",detailKeys:["channelId","messageId"]},listPins:{label:"list pins",detailKeys:["channelId"]},searchMessages:{label:"search",detailKeys:["guildId","content"]},memberInfo:{label:"member",detailKeys:["guildId","userId"]},roleInfo:{label:"roles",detailKeys:["guildId"]},emojiList:{label:"emoji list",detailKeys:["guildId"]},roleAdd:{label:"role add",detailKeys:["guildId","userId","roleId"]},roleRemove:{label:"role remove",detailKeys:["guildId","userId","roleId"]},channelInfo:{label:"channel",detailKeys:["channelId"]},channelList:{label:"channels",detailKeys:["guildId"]},voiceStatus:{label:"voice",detailKeys:["guildId","userId"]},eventList:{label:"events",detailKeys:["guildId"]},eventCreate:{label:"event create",detailKeys:["guildId","name"]},timeout:{label:"timeout",detailKeys:["guildId","userId"]},kick:{label:"kick",detailKeys:["guildId","userId"]},ban:{label:"ban",detailKeys:["guildId","userId"]}}},slack:{icon:"messageSquare",title:"Slack",actions:{react:{label:"react",detailKeys:["channelId","messageId","emoji"]},reactions:{label:"reactions",detailKeys:["channelId","messageId"]},sendMessage:{label:"send",detailKeys:["to","content"]},editMessage:{label:"edit",detailKeys:["channelId","messageId"]},deleteMessage:{label:"delete",detailKeys:["channelId","messageId"]},readMessages:{label:"read messages",detailKeys:["channelId","limit"]},pinMessage:{label:"pin",detailKeys:["channelId","messageId"]},unpinMessage:{label:"unpin",detailKeys:["channelId","messageId"]},listPins:{label:"list pins",detailKeys:["channelId"]},memberInfo:{label:"member",detailKeys:["userId"]},emojiList:{label:"emoji list"}}}},Wu={fallback:qu,tools:Vu},rr=Wu,Sa=rr.fallback??{icon:"puzzle"},Gu=rr.tools??{};function Yu(e){return(e??"tool").trim()}function Qu(e){const t=e.replace(/_/g," ").trim();return t?t.split(/\s+/).map(n=>n.length<=2&&n.toUpperCase()===n?n:`${n.at(0)?.toUpperCase()??""}${n.slice(1)}`).join(" "):"Tool"}function Zu(e){const t=e?.trim();if(t)return t.replace(/_/g," ")}function lr(e){if(e!=null){if(typeof e=="string"){const t=e.trim();if(!t)return;const n=t.split(/\r?\n/)[0]?.trim()??"";return n?n.length>160?`${n.slice(0,157)}…`:n:void 0}if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e)){const t=e.map(s=>lr(s)).filter(s=>!!s);if(t.length===0)return;const n=t.slice(0,3).join(", ");return t.length>3?`${n}…`:n}}}function Ju(e,t){if(!e||typeof e!="object")return;let n=e;for(const s of t.split(".")){if(!s||!n||typeof n!="object")return;n=n[s]}return n}function Xu(e,t){for(const n of t){const s=Ju(e,n),i=lr(s);if(i)return i}}function ep(e){if(!e||typeof e!="object")return;const t=e,n=typeof t.path=="string"?t.path:void 0;if(!n)return;const s=typeof t.offset=="number"?t.offset:void 0,i=typeof t.limit=="number"?t.limit:void 0;return s!==void 0&&i!==void 0?`${n}:${s}-${s+i}`:n}function tp(e){if(!e||typeof e!="object")return;const t=e;return typeof t.path=="string"?t.path:void 0}function np(e,t){if(!(!e||!t))return e.actions?.[t]??void 0}function sp(e){const t=Yu(e.name),n=t.toLowerCase(),s=Gu[n],i=s?.icon??Sa.icon??"puzzle",a=s?.title??Qu(t),o=s?.label??t,c=e.args&&typeof e.args=="object"?e.args.action:void 0,l=typeof c=="string"?c.trim():void 0,p=np(s,l),d=Zu(p?.label??l);let u;n==="read"&&(u=ep(e.args)),!u&&(n==="write"||n==="edit"||n==="attach")&&(u=tp(e.args));const h=p?.detailKeys??s?.detailKeys??Sa.detailKeys??[];return!u&&h.length>0&&(u=Xu(e.args,h)),!u&&e.meta&&(u=e.meta),u&&(u=ap(u)),{name:t,icon:i,title:a,label:o,verb:d,detail:u}}function ip(e){const t=[];if(e.verb&&t.push(e.verb),e.detail&&t.push(e.detail),t.length!==0)return t.join(" · ")}function ap(e){return e&&e.replace(/\/Users\/[^/]+/g,"~").replace(/\/home\/[^/]+/g,"~")}const op=80,rp=2,_a=100;function lp(e){const t=e.trim();if(t.startsWith("{")||t.startsWith("["))try{const n=JSON.parse(t);return"```json\n"+JSON.stringify(n,null,2)+"\n```"}catch{}return e}function cp(e){const t=e.split(`
91
- `),n=t.slice(0,rp),s=n.join(`
92
- `);return s.length>_a?s.slice(0,_a)+"…":n.length<t.length?s+"…":s}function dp(e){const t=e,n=up(t.content),s=[];for(const i of n){const a=String(i.type??"").toLowerCase();(["toolcall","tool_call","tooluse","tool_use"].includes(a)||typeof i.name=="string"&&i.arguments!=null)&&s.push({kind:"call",name:i.name??"tool",args:pp(i.arguments??i.args)})}for(const i of n){const a=String(i.type??"").toLowerCase();if(a!=="toolresult"&&a!=="tool_result")continue;const o=fp(i),c=typeof i.name=="string"?i.name:"tool";s.push({kind:"result",name:c,text:o})}if(jo(e)&&!s.some(i=>i.kind==="result")){const i=typeof t.toolName=="string"&&t.toolName||typeof t.tool_name=="string"&&t.tool_name||"tool",a=oo(e)??void 0;s.push({kind:"result",name:i,text:a})}return s}function Ta(e,t){const n=sp({name:e.name,args:e.args}),s=ip(n),i=!!e.text?.trim(),a=!!t,o=a?()=>{if(i){t(lp(e.text));return}const u=`## ${n.label}
90
+ `}function Vu(e){return Wu({text:()=>e,label:rr})}const Gu={icon:"puzzle",detailKeys:["command","path","url","targetUrl","targetId","ref","element","node","nodeId","id","requestId","to","channelId","guildId","userId","name","query","pattern","messageId"]},Yu={bash:{icon:"wrench",title:"Bash",detailKeys:["command"]},process:{icon:"wrench",title:"Process",detailKeys:["sessionId"]},read:{icon:"fileText",title:"Read",detailKeys:["path"]},write:{icon:"edit",title:"Write",detailKeys:["path"]},edit:{icon:"penLine",title:"Edit",detailKeys:["path"]},attach:{icon:"paperclip",title:"Attach",detailKeys:["path","url","fileName"]},browser:{icon:"globe",title:"Browser",actions:{status:{label:"status"},start:{label:"start"},stop:{label:"stop"},tabs:{label:"tabs"},open:{label:"open",detailKeys:["targetUrl"]},focus:{label:"focus",detailKeys:["targetId"]},close:{label:"close",detailKeys:["targetId"]},snapshot:{label:"snapshot",detailKeys:["targetUrl","targetId","ref","element","format"]},screenshot:{label:"screenshot",detailKeys:["targetUrl","targetId","ref","element"]},navigate:{label:"navigate",detailKeys:["targetUrl","targetId"]},console:{label:"console",detailKeys:["level","targetId"]},pdf:{label:"pdf",detailKeys:["targetId"]},upload:{label:"upload",detailKeys:["paths","ref","inputRef","element","targetId"]},dialog:{label:"dialog",detailKeys:["accept","promptText","targetId"]},act:{label:"act",detailKeys:["request.kind","request.ref","request.selector","request.text","request.value"]}}},canvas:{icon:"image",title:"Canvas",actions:{present:{label:"present",detailKeys:["target","node","nodeId"]},hide:{label:"hide",detailKeys:["node","nodeId"]},navigate:{label:"navigate",detailKeys:["url","node","nodeId"]},eval:{label:"eval",detailKeys:["javaScript","node","nodeId"]},snapshot:{label:"snapshot",detailKeys:["format","node","nodeId"]},a2ui_push:{label:"A2UI push",detailKeys:["jsonlPath","node","nodeId"]},a2ui_reset:{label:"A2UI reset",detailKeys:["node","nodeId"]}}},nodes:{icon:"smartphone",title:"Nodes",actions:{status:{label:"status"},describe:{label:"describe",detailKeys:["node","nodeId"]},pending:{label:"pending"},approve:{label:"approve",detailKeys:["requestId"]},reject:{label:"reject",detailKeys:["requestId"]},notify:{label:"notify",detailKeys:["node","nodeId","title","body"]},camera_snap:{label:"camera snap",detailKeys:["node","nodeId","facing","deviceId"]},camera_list:{label:"camera list",detailKeys:["node","nodeId"]},camera_clip:{label:"camera clip",detailKeys:["node","nodeId","facing","duration","durationMs"]},screen_record:{label:"screen record",detailKeys:["node","nodeId","duration","durationMs","fps","screenIndex"]}}},cron:{icon:"loader",title:"Cron",actions:{status:{label:"status"},list:{label:"list"},add:{label:"add",detailKeys:["job.name","job.id","job.schedule","job.cron"]},update:{label:"update",detailKeys:["id"]},remove:{label:"remove",detailKeys:["id"]},run:{label:"run",detailKeys:["id"]},runs:{label:"runs",detailKeys:["id"]},wake:{label:"wake",detailKeys:["text","mode"]}}},gateway:{icon:"plug",title:"Gateway",actions:{restart:{label:"restart",detailKeys:["reason","delayMs"]},"config.get":{label:"config get"},"config.schema":{label:"config schema"},"config.apply":{label:"config apply",detailKeys:["restartDelayMs"]},"update.run":{label:"update run",detailKeys:["restartDelayMs"]}}},whatsapp_login:{icon:"circle",title:"WhatsApp Login",actions:{start:{label:"start"},wait:{label:"wait"}}},discord:{icon:"messageSquare",title:"Discord",actions:{react:{label:"react",detailKeys:["channelId","messageId","emoji"]},reactions:{label:"reactions",detailKeys:["channelId","messageId"]},sticker:{label:"sticker",detailKeys:["to","stickerIds"]},poll:{label:"poll",detailKeys:["question","to"]},permissions:{label:"permissions",detailKeys:["channelId"]},readMessages:{label:"read messages",detailKeys:["channelId","limit"]},sendMessage:{label:"send",detailKeys:["to","content"]},editMessage:{label:"edit",detailKeys:["channelId","messageId"]},deleteMessage:{label:"delete",detailKeys:["channelId","messageId"]},threadCreate:{label:"thread create",detailKeys:["channelId","name"]},threadList:{label:"thread list",detailKeys:["guildId","channelId"]},threadReply:{label:"thread reply",detailKeys:["channelId","content"]},pinMessage:{label:"pin",detailKeys:["channelId","messageId"]},unpinMessage:{label:"unpin",detailKeys:["channelId","messageId"]},listPins:{label:"list pins",detailKeys:["channelId"]},searchMessages:{label:"search",detailKeys:["guildId","content"]},memberInfo:{label:"member",detailKeys:["guildId","userId"]},roleInfo:{label:"roles",detailKeys:["guildId"]},emojiList:{label:"emoji list",detailKeys:["guildId"]},roleAdd:{label:"role add",detailKeys:["guildId","userId","roleId"]},roleRemove:{label:"role remove",detailKeys:["guildId","userId","roleId"]},channelInfo:{label:"channel",detailKeys:["channelId"]},channelList:{label:"channels",detailKeys:["guildId"]},voiceStatus:{label:"voice",detailKeys:["guildId","userId"]},eventList:{label:"events",detailKeys:["guildId"]},eventCreate:{label:"event create",detailKeys:["guildId","name"]},timeout:{label:"timeout",detailKeys:["guildId","userId"]},kick:{label:"kick",detailKeys:["guildId","userId"]},ban:{label:"ban",detailKeys:["guildId","userId"]}}},slack:{icon:"messageSquare",title:"Slack",actions:{react:{label:"react",detailKeys:["channelId","messageId","emoji"]},reactions:{label:"reactions",detailKeys:["channelId","messageId"]},sendMessage:{label:"send",detailKeys:["to","content"]},editMessage:{label:"edit",detailKeys:["channelId","messageId"]},deleteMessage:{label:"delete",detailKeys:["channelId","messageId"]},readMessages:{label:"read messages",detailKeys:["channelId","limit"]},pinMessage:{label:"pin",detailKeys:["channelId","messageId"]},unpinMessage:{label:"unpin",detailKeys:["channelId","messageId"]},listPins:{label:"list pins",detailKeys:["channelId"]},memberInfo:{label:"member",detailKeys:["userId"]},emojiList:{label:"emoji list"}}}},Qu={fallback:Gu,tools:Yu},lr=Qu,_a=lr.fallback??{icon:"puzzle"},Zu=lr.tools??{};function Ju(e){return(e??"tool").trim()}function Xu(e){const t=e.replace(/_/g," ").trim();return t?t.split(/\s+/).map(n=>n.length<=2&&n.toUpperCase()===n?n:`${n.at(0)?.toUpperCase()??""}${n.slice(1)}`).join(" "):"Tool"}function ep(e){const t=e?.trim();if(t)return t.replace(/_/g," ")}function cr(e){if(e!=null){if(typeof e=="string"){const t=e.trim();if(!t)return;const n=t.split(/\r?\n/)[0]?.trim()??"";return n?n.length>160?`${n.slice(0,157)}…`:n:void 0}if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e)){const t=e.map(s=>cr(s)).filter(s=>!!s);if(t.length===0)return;const n=t.slice(0,3).join(", ");return t.length>3?`${n}…`:n}}}function tp(e,t){if(!e||typeof e!="object")return;let n=e;for(const s of t.split(".")){if(!s||!n||typeof n!="object")return;n=n[s]}return n}function np(e,t){for(const n of t){const s=tp(e,n),i=cr(s);if(i)return i}}function sp(e){if(!e||typeof e!="object")return;const t=e,n=typeof t.path=="string"?t.path:void 0;if(!n)return;const s=typeof t.offset=="number"?t.offset:void 0,i=typeof t.limit=="number"?t.limit:void 0;return s!==void 0&&i!==void 0?`${n}:${s}-${s+i}`:n}function ip(e){if(!e||typeof e!="object")return;const t=e;return typeof t.path=="string"?t.path:void 0}function ap(e,t){if(!(!e||!t))return e.actions?.[t]??void 0}function op(e){const t=Ju(e.name),n=t.toLowerCase(),s=Zu[n],i=s?.icon??_a.icon??"puzzle",a=s?.title??Xu(t),o=s?.label??t,l=e.args&&typeof e.args=="object"?e.args.action:void 0,r=typeof l=="string"?l.trim():void 0,p=ap(s,r),d=ep(p?.label??r);let u;n==="read"&&(u=sp(e.args)),!u&&(n==="write"||n==="edit"||n==="attach")&&(u=ip(e.args));const g=p?.detailKeys??s?.detailKeys??_a.detailKeys??[];return!u&&g.length>0&&(u=np(e.args,g)),!u&&e.meta&&(u=e.meta),u&&(u=lp(u)),{name:t,icon:i,title:a,label:o,verb:d,detail:u}}function rp(e){const t=[];if(e.verb&&t.push(e.verb),e.detail&&t.push(e.detail),t.length!==0)return t.join(" · ")}function lp(e){return e&&e.replace(/\/Users\/[^/]+/g,"~").replace(/\/home\/[^/]+/g,"~")}const cp=80,dp=2,Ta=100;function up(e){const t=e.trim();if(t.startsWith("{")||t.startsWith("["))try{const n=JSON.parse(t);return"```json\n"+JSON.stringify(n,null,2)+"\n```"}catch{}return e}function pp(e){const t=e.split(`
91
+ `),n=t.slice(0,dp),s=n.join(`
92
+ `);return s.length>Ta?s.slice(0,Ta)+"…":n.length<t.length?s+"…":s}function fp(e){const t=e,n=hp(t.content),s=[];for(const i of n){const a=String(i.type??"").toLowerCase();(["toolcall","tool_call","tooluse","tool_use"].includes(a)||typeof i.name=="string"&&i.arguments!=null)&&s.push({kind:"call",name:i.name??"tool",args:gp(i.arguments??i.args)})}for(const i of n){const a=String(i.type??"").toLowerCase();if(a!=="toolresult"&&a!=="tool_result")continue;const o=vp(i),l=typeof i.name=="string"?i.name:"tool";s.push({kind:"result",name:l,text:o})}if(qo(e)&&!s.some(i=>i.kind==="result")){const i=typeof t.toolName=="string"&&t.toolName||typeof t.tool_name=="string"&&t.tool_name||"tool",a=ro(e)??void 0;s.push({kind:"result",name:i,text:a})}return s}function Ca(e,t){const n=op({name:e.name,args:e.args}),s=rp(n),i=!!e.text?.trim(),a=!!t,o=a?()=>{if(i){t(up(e.text));return}const u=`## ${n.label}
93
93
 
94
94
  ${s?`**Command:** \`${s}\`
95
95
 
96
- `:""}*No output — tool completed successfully.*`;t(u)}:void 0,c=i&&(e.text?.length??0)<=op,l=i&&!c,p=i&&c,d=!i;return r`
96
+ `:""}*No output — tool completed successfully.*`;t(u)}:void 0,l=i&&(e.text?.length??0)<=cp,r=i&&!l,p=i&&l,d=!i;return c`
97
97
  <div
98
98
  class="chat-tool-card ${a?"chat-tool-card--clickable":""}"
99
99
  @click=${o}
100
- role=${a?"button":g}
101
- tabindex=${a?"0":g}
102
- @keydown=${a?u=>{u.key!=="Enter"&&u.key!==" "||(u.preventDefault(),o?.())}:g}
100
+ role=${a?"button":h}
101
+ tabindex=${a?"0":h}
102
+ @keydown=${a?u=>{u.key!=="Enter"&&u.key!==" "||(u.preventDefault(),o?.())}:h}
103
103
  >
104
104
  <div class="chat-tool-card__header">
105
105
  <div class="chat-tool-card__title">
106
- <span class="chat-tool-card__icon">${Q[n.icon]}</span>
106
+ <span class="chat-tool-card__icon">${V[n.icon]}</span>
107
107
  <span>${n.label}</span>
108
108
  </div>
109
- ${a?r`<span class="chat-tool-card__action">${i?"View":""} ${Q.check}</span>`:g}
110
- ${d&&!a?r`<span class="chat-tool-card__status">${Q.check}</span>`:g}
109
+ ${a?c`<span class="chat-tool-card__action">${i?"View":""} ${V.check}</span>`:h}
110
+ ${d&&!a?c`<span class="chat-tool-card__status">${V.check}</span>`:h}
111
111
  </div>
112
- ${s?r`<div class="chat-tool-card__detail">${s}</div>`:g}
113
- ${d?r`<div class="chat-tool-card__status-text muted">Completed</div>`:g}
114
- ${l?r`<div class="chat-tool-card__preview mono">${cp(e.text)}</div>`:g}
115
- ${p?r`<div class="chat-tool-card__inline mono">${e.text}</div>`:g}
112
+ ${s?c`<div class="chat-tool-card__detail">${s}</div>`:h}
113
+ ${d?c`<div class="chat-tool-card__status-text muted">Completed</div>`:h}
114
+ ${r?c`<div class="chat-tool-card__preview mono">${pp(e.text)}</div>`:h}
115
+ ${p?c`<div class="chat-tool-card__inline mono">${e.text}</div>`:h}
116
116
  </div>
117
- `}function up(e){return Array.isArray(e)?e.filter(Boolean):[]}function pp(e){if(typeof e!="string")return e;const t=e.trim();if(!t||!t.startsWith("{")&&!t.startsWith("["))return e;try{return JSON.parse(t)}catch{return e}}function fp(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}function hp(e){return r`
117
+ `}function hp(e){return Array.isArray(e)?e.filter(Boolean):[]}function gp(e){if(typeof e!="string")return e;const t=e.trim();if(!t||!t.startsWith("{")&&!t.startsWith("["))return e;try{return JSON.parse(t)}catch{return e}}function vp(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}function mp(e){const n=e.content,s=[];if(Array.isArray(n))for(const i of n){if(typeof i!="object"||i===null)continue;const a=i;if(a.type==="image"){const o=a.source;if(o?.type==="base64"&&typeof o.data=="string"){const l=o.data,r=o.media_type||"image/png",p=l.startsWith("data:")?l:`data:${r};base64,${l}`;s.push({url:p})}else typeof a.url=="string"&&s.push({url:a.url})}else if(a.type==="image_url"){const o=a.image_url;typeof o?.url=="string"&&s.push({url:o.url})}}return s}function yp(e){return c`
118
118
  <div class="chat-group assistant">
119
119
  ${li("assistant",e)}
120
120
  <div class="chat-group-messages">
@@ -125,57 +125,69 @@ ${s?`**Command:** \`${s}\`
125
125
  </div>
126
126
  </div>
127
127
  </div>
128
- `}function gp(e,t,n,s){const i=new Date(t).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),a=s?.name??"Assistant";return r`
128
+ `}function bp(e,t,n,s){const i=new Date(t).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),a=s?.name??"Assistant";return c`
129
129
  <div class="chat-group assistant">
130
130
  ${li("assistant",s)}
131
131
  <div class="chat-group-messages">
132
- ${cr({role:"assistant",content:[{type:"text",text:e}],timestamp:t},{isStreaming:!0,showReasoning:!1},n)}
132
+ ${dr({role:"assistant",content:[{type:"text",text:e}],timestamp:t},{isStreaming:!0,showReasoning:!1},n)}
133
133
  <div class="chat-group-footer">
134
134
  <span class="chat-sender-name">${a}</span>
135
135
  <span class="chat-group-timestamp">${i}</span>
136
136
  </div>
137
137
  </div>
138
138
  </div>
139
- `}function vp(e,t){const n=Js(e.role),s=t.assistantName??"Assistant",i=n==="user"?"You":n==="assistant"?s:n,a=n==="user"?"user":n==="assistant"?"assistant":"other",o=new Date(e.timestamp).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});return r`
139
+ `}function wp(e,t){const n=Js(e.role),s=t.assistantName??"Assistant",i=n==="user"?"You":n==="assistant"?s:n,a=n==="user"?"user":n==="assistant"?"assistant":"other",o=new Date(e.timestamp).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});return c`
140
140
  <div class="chat-group ${a}">
141
141
  ${li(e.role,{name:s,avatar:t.assistantAvatar??null})}
142
142
  <div class="chat-group-messages">
143
- ${e.messages.map((c,l)=>cr(c.message,{isStreaming:e.isStreaming&&l===e.messages.length-1,showReasoning:t.showReasoning},t.onOpenSidebar))}
143
+ ${e.messages.map((l,r)=>dr(l.message,{isStreaming:e.isStreaming&&r===e.messages.length-1,showReasoning:t.showReasoning},t.onOpenSidebar))}
144
144
  <div class="chat-group-footer">
145
145
  <span class="chat-sender-name">${i}</span>
146
146
  <span class="chat-group-timestamp">${o}</span>
147
147
  </div>
148
148
  </div>
149
149
  </div>
150
- `}function li(e,t){const n=Js(e),s=t?.name?.trim()||"Assistant",i=t?.avatar?.trim()||"",a=n==="user"?"U":n==="assistant"?s.charAt(0).toUpperCase()||"A":n==="tool"?"⚙":"?",o=n==="user"?"user":n==="assistant"?"assistant":n==="tool"?"tool":"other";return i&&n==="assistant"?mp(i)?r`<img
150
+ `}function li(e,t){const n=Js(e),s=t?.name?.trim()||"Assistant",i=t?.avatar?.trim()||"",a=n==="user"?"U":n==="assistant"?s.charAt(0).toUpperCase()||"A":n==="tool"?"⚙":"?",o=n==="user"?"user":n==="assistant"?"assistant":n==="tool"?"tool":"other";return i&&n==="assistant"?$p(i)?c`<img
151
151
  class="chat-avatar ${o}"
152
152
  src="${i}"
153
153
  alt="${s}"
154
- />`:r`<div class="chat-avatar ${o}">${i}</div>`:r`<div class="chat-avatar ${o}">${a}</div>`}function mp(e){return/^https?:\/\//i.test(e)||/^data:image\//i.test(e)||/^\//.test(e)}function cr(e,t,n){const s=e,i=typeof s.role=="string"?s.role:"unknown",a=jo(e)||i.toLowerCase()==="toolresult"||i.toLowerCase()==="tool_result"||typeof s.toolCallId=="string"||typeof s.tool_call_id=="string",o=dp(e),c=o.length>0,l=oo(e),p=t.showReasoning&&i==="assistant"?Al(e):null,d=l?.trim()?l:null,u=p?_l(p):null,h=d,v=i==="assistant"&&!!h?.trim(),w=["chat-bubble",v?"has-copy":"",t.isStreaming?"streaming":"","fade-in"].filter(Boolean).join(" ");return!h&&c&&a?r`${o.map($=>Ta($,n))}`:!h&&!c?g:r`
155
- <div class="${w}">
156
- ${v?ju(h):g}
157
- ${u?r`<div class="chat-thinking">${gs(ks(u))}</div>`:g}
158
- ${h?r`<div class="chat-text">${gs(ks(h))}</div>`:g}
159
- ${o.map($=>Ta($,n))}
154
+ />`:c`<div class="chat-avatar ${o}">${i}</div>`:c`<div class="chat-avatar ${o}">${a}</div>`}function $p(e){return/^https?:\/\//i.test(e)||/^data:image\//i.test(e)||/^\//.test(e)}function xp(e){return e.length===0?h:c`
155
+ <div class="chat-message-images">
156
+ ${e.map(t=>c`
157
+ <img
158
+ src=${t.url}
159
+ alt=${t.alt??"Attached image"}
160
+ class="chat-message-image"
161
+ @click=${()=>window.open(t.url,"_blank")}
162
+ />
163
+ `)}
164
+ </div>
165
+ `}function dr(e,t,n){const s=e,i=typeof s.role=="string"?s.role:"unknown",a=qo(e)||i.toLowerCase()==="toolresult"||i.toLowerCase()==="tool_result"||typeof s.toolCallId=="string"||typeof s.tool_call_id=="string",o=fp(e),l=o.length>0,r=mp(e),p=r.length>0,d=ro(e),u=t.showReasoning&&i==="assistant"?Sl(e):null,g=d?.trim()?d:null,v=u?Tl(u):null,w=g,$=i==="assistant"&&!!w?.trim(),k=["chat-bubble",$?"has-copy":"",t.isStreaming?"streaming":"","fade-in"].filter(Boolean).join(" ");return!w&&l&&a?c`${o.map(_=>Ca(_,n))}`:!w&&!l&&!p?h:c`
166
+ <div class="${k}">
167
+ ${$?Vu(w):h}
168
+ ${xp(r)}
169
+ ${v?c`<div class="chat-thinking">${vs(As(v))}</div>`:h}
170
+ ${w?c`<div class="chat-text">${vs(As(w))}</div>`:h}
171
+ ${o.map(_=>Ca(_,n))}
160
172
  </div>
161
- `}function bp(e){return r`
173
+ `}function kp(e){return c`
162
174
  <div class="sidebar-panel">
163
175
  <div class="sidebar-header">
164
176
  <div class="sidebar-title">Tool Output</div>
165
177
  <button @click=${e.onClose} class="btn" title="Close sidebar">
166
- ${Q.x}
178
+ ${V.x}
167
179
  </button>
168
180
  </div>
169
181
  <div class="sidebar-content">
170
- ${e.error?r`
182
+ ${e.error?c`
171
183
  <div class="callout danger">${e.error}</div>
172
184
  <button @click=${e.onViewRawText} class="btn" style="margin-top: 12px;">
173
185
  View Raw Text
174
186
  </button>
175
- `:e.content?r`<div class="sidebar-markdown">${gs(ks(e.content))}</div>`:r`<div class="muted">No content available</div>`}
187
+ `:e.content?c`<div class="sidebar-markdown">${vs(As(e.content))}</div>`:c`<div class="muted">No content available</div>`}
176
188
  </div>
177
189
  </div>
178
- `}var yp=Object.defineProperty,wp=Object.getOwnPropertyDescriptor,mn=(e,t,n,s)=>{for(var i=s>1?void 0:s?wp(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(s?o(t,n,i):o(i))||i);return s&&i&&yp(t,n,i),i};let nt=class extends Ze{constructor(){super(...arguments),this.splitRatio=.6,this.minRatio=.4,this.maxRatio=.7,this.isDragging=!1,this.startX=0,this.startRatio=0,this.handleMouseDown=e=>{this.isDragging=!0,this.startX=e.clientX,this.startRatio=this.splitRatio,this.classList.add("dragging"),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),e.preventDefault()},this.handleMouseMove=e=>{if(!this.isDragging)return;const t=this.parentElement;if(!t)return;const n=t.getBoundingClientRect().width,i=(e.clientX-this.startX)/n;let a=this.startRatio+i;a=Math.max(this.minRatio,Math.min(this.maxRatio,a)),this.dispatchEvent(new CustomEvent("resize",{detail:{splitRatio:a},bubbles:!0,composed:!0}))},this.handleMouseUp=()=>{this.isDragging=!1,this.classList.remove("dragging"),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}}render(){return r``}connectedCallback(){super.connectedCallback(),this.addEventListener("mousedown",this.handleMouseDown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}};nt.styles=Dr`
190
+ `}var Ap=Object.defineProperty,Sp=Object.getOwnPropertyDescriptor,yn=(e,t,n,s)=>{for(var i=s>1?void 0:s?Sp(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(s?o(t,n,i):o(i))||i);return s&&i&&Ap(t,n,i),i};let nt=class extends Ze{constructor(){super(...arguments),this.splitRatio=.6,this.minRatio=.4,this.maxRatio=.7,this.isDragging=!1,this.startX=0,this.startRatio=0,this.handleMouseDown=e=>{this.isDragging=!0,this.startX=e.clientX,this.startRatio=this.splitRatio,this.classList.add("dragging"),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),e.preventDefault()},this.handleMouseMove=e=>{if(!this.isDragging)return;const t=this.parentElement;if(!t)return;const n=t.getBoundingClientRect().width,i=(e.clientX-this.startX)/n;let a=this.startRatio+i;a=Math.max(this.minRatio,Math.min(this.maxRatio,a)),this.dispatchEvent(new CustomEvent("resize",{detail:{splitRatio:a},bubbles:!0,composed:!0}))},this.handleMouseUp=()=>{this.isDragging=!1,this.classList.remove("dragging"),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}}render(){return c``}connectedCallback(){super.connectedCallback(),this.addEventListener("mousedown",this.handleMouseDown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}};nt.styles=Br`
179
191
  :host {
180
192
  width: 4px;
181
193
  cursor: col-resize;
@@ -201,33 +213,53 @@ ${s?`**Command:** \`${s}\`
201
213
  :host(.dragging) {
202
214
  background: var(--accent, #007bff);
203
215
  }
204
- `;mn([on({type:Number})],nt.prototype,"splitRatio",2);mn([on({type:Number})],nt.prototype,"minRatio",2);mn([on({type:Number})],nt.prototype,"maxRatio",2);nt=mn([Ja("resizable-divider")],nt);const $p=5e3;function xp(e){return e?e.active?r`
216
+ `;yn([on({type:Number})],nt.prototype,"splitRatio",2);yn([on({type:Number})],nt.prototype,"minRatio",2);yn([on({type:Number})],nt.prototype,"maxRatio",2);nt=yn([Xa("resizable-divider")],nt);const _p=5e3;function Tp(e){return e?e.active?c`
205
217
  <div class="callout info compaction-indicator compaction-indicator--active">
206
- ${Q.loader} Compacting context...
218
+ ${V.loader} Compacting context...
207
219
  </div>
208
- `:e.completedAt&&Date.now()-e.completedAt<$p?r`
220
+ `:e.completedAt&&Date.now()-e.completedAt<_p?c`
209
221
  <div class="callout success compaction-indicator compaction-indicator--complete">
210
- ${Q.check} Context compacted
211
- </div>
212
- `:g:g}function kp(e){const t=e.connected,n=e.sending||e.stream!==null,s=!!(e.canAbort&&e.onAbort),a=e.sessions?.sessions?.find(h=>h.key===e.sessionKey)?.reasoningLevel??"off",o=e.showThinking&&a!=="off",c={name:e.assistantName,avatar:e.assistantAvatar??e.assistantAvatarUrl??null},l=e.connected?"Message (↩ to send, Shift+↩ for line breaks)":"Connect to the gateway to start chatting…",p=e.splitRatio??.6,d=!!(e.sidebarOpen&&e.onCloseSidebar),u=r`
222
+ ${V.check} Context compacted
223
+ </div>
224
+ `:h:h}function Cp(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function Ep(e,t){const n=e.clipboardData?.items;if(!n||!t.onAttachmentsChange)return;const s=[];for(let i=0;i<n.length;i++){const a=n[i];a.type.startsWith("image/")&&s.push(a)}if(s.length!==0){e.preventDefault();for(const i of s){const a=i.getAsFile();if(!a)continue;const o=new FileReader;o.onload=()=>{const l=o.result,r={id:Cp(),dataUrl:l,mimeType:a.type},p=t.attachments??[];t.onAttachmentsChange?.([...p,r])},o.readAsDataURL(a)}}}function Lp(e){const t=e.attachments??[];return t.length===0?h:c`
225
+ <div class="chat-attachments">
226
+ ${t.map(n=>c`
227
+ <div class="chat-attachment">
228
+ <img
229
+ src=${n.dataUrl}
230
+ alt="Attachment preview"
231
+ class="chat-attachment__img"
232
+ />
233
+ <button
234
+ class="chat-attachment__remove"
235
+ type="button"
236
+ aria-label="Remove attachment"
237
+ @click=${()=>{const s=(e.attachments??[]).filter(i=>i.id!==n.id);e.onAttachmentsChange?.(s)}}
238
+ >
239
+ ${V.x}
240
+ </button>
241
+ </div>
242
+ `)}
243
+ </div>
244
+ `}function Ip(e){const t=e.connected,n=e.sending||e.stream!==null,s=!!(e.canAbort&&e.onAbort),a=e.sessions?.sessions?.find(v=>v.key===e.sessionKey)?.reasoningLevel??"off",o=e.showThinking&&a!=="off",l={name:e.assistantName,avatar:e.assistantAvatar??e.assistantAvatarUrl??null},r=(e.attachments?.length??0)>0,p=e.connected?r?"Add a message or paste more images...":"Message (↩ to send, Shift+↩ for line breaks, paste images)":"Connect to the gateway to start chatting…",d=e.splitRatio??.6,u=!!(e.sidebarOpen&&e.onCloseSidebar),g=c`
213
245
  <div
214
246
  class="chat-thread"
215
247
  role="log"
216
248
  aria-live="polite"
217
249
  @scroll=${e.onChatScroll}
218
250
  >
219
- ${e.loading?r`<div class="muted">Loading chat…</div>`:g}
220
- ${Ho(Sp(e),h=>h.key,h=>h.kind==="reading-indicator"?hp(c):h.kind==="stream"?gp(h.text,h.startedAt,e.onOpenSidebar,c):h.kind==="group"?vp(h,{onOpenSidebar:e.onOpenSidebar,showReasoning:o,assistantName:e.assistantName,assistantAvatar:c.avatar}):g)}
251
+ ${e.loading?c`<div class="muted">Loading chat…</div>`:h}
252
+ ${zo(Rp(e),v=>v.key,v=>v.kind==="reading-indicator"?yp(l):v.kind==="stream"?bp(v.text,v.startedAt,e.onOpenSidebar,l):v.kind==="group"?wp(v,{onOpenSidebar:e.onOpenSidebar,showReasoning:o,assistantName:e.assistantName,assistantAvatar:l.avatar}):h)}
221
253
  </div>
222
- `;return r`
254
+ `;return c`
223
255
  <section class="card chat">
224
- ${e.disabledReason?r`<div class="callout">${e.disabledReason}</div>`:g}
256
+ ${e.disabledReason?c`<div class="callout">${e.disabledReason}</div>`:h}
225
257
 
226
- ${e.error?r`<div class="callout danger">${e.error}</div>`:g}
258
+ ${e.error?c`<div class="callout danger">${e.error}</div>`:h}
227
259
 
228
- ${xp(e.compactionStatus)}
260
+ ${Tp(e.compactionStatus)}
229
261
 
230
- ${e.focusMode?r`
262
+ ${e.focusMode?c`
231
263
  <button
232
264
  class="chat-focus-exit"
233
265
  type="button"
@@ -235,155 +267,161 @@ ${s?`**Command:** \`${s}\`
235
267
  aria-label="Exit focus mode"
236
268
  title="Exit focus mode"
237
269
  >
238
- ${Q.x}
270
+ ${V.x}
239
271
  </button>
240
- `:g}
272
+ `:h}
241
273
 
242
274
  <div
243
- class="chat-split-container ${d?"chat-split-container--open":""}"
275
+ class="chat-split-container ${u?"chat-split-container--open":""}"
244
276
  >
245
277
  <div
246
278
  class="chat-main"
247
- style="flex: ${d?`0 0 ${p*100}%`:"1 1 100%"}"
279
+ style="flex: ${u?`0 0 ${d*100}%`:"1 1 100%"}"
248
280
  >
249
- ${u}
281
+ ${g}
250
282
  </div>
251
283
 
252
- ${d?r`
284
+ ${u?c`
253
285
  <resizable-divider
254
- .splitRatio=${p}
255
- @resize=${h=>e.onSplitRatioChange?.(h.detail.splitRatio)}
286
+ .splitRatio=${d}
287
+ @resize=${v=>e.onSplitRatioChange?.(v.detail.splitRatio)}
256
288
  ></resizable-divider>
257
289
  <div class="chat-sidebar">
258
- ${bp({content:e.sidebarContent??null,error:e.sidebarError??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(`\`\`\`
290
+ ${kp({content:e.sidebarContent??null,error:e.sidebarError??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(`\`\`\`
259
291
  ${e.sidebarContent}
260
292
  \`\`\``)}})}
261
293
  </div>
262
- `:g}
294
+ `:h}
263
295
  </div>
264
296
 
265
- ${e.queue.length?r`
297
+ ${e.queue.length?c`
266
298
  <div class="chat-queue" role="status" aria-live="polite">
267
299
  <div class="chat-queue__title">Queued (${e.queue.length})</div>
268
300
  <div class="chat-queue__list">
269
- ${e.queue.map(h=>r`
301
+ ${e.queue.map(v=>c`
270
302
  <div class="chat-queue__item">
271
- <div class="chat-queue__text">${h.text}</div>
303
+ <div class="chat-queue__text">
304
+ ${v.text||(v.attachments?.length?`Image (${v.attachments.length})`:"")}
305
+ </div>
272
306
  <button
273
307
  class="btn chat-queue__remove"
274
308
  type="button"
275
309
  aria-label="Remove queued message"
276
- @click=${()=>e.onQueueRemove(h.id)}
310
+ @click=${()=>e.onQueueRemove(v.id)}
277
311
  >
278
- ${Q.x}
312
+ ${V.x}
279
313
  </button>
280
314
  </div>
281
315
  `)}
282
316
  </div>
283
317
  </div>
284
- `:g}
318
+ `:h}
285
319
 
286
320
  <div class="chat-compose">
287
- <label class="field chat-compose__field">
288
- <span>Message</span>
289
- <textarea
290
- .value=${e.draft}
291
- ?disabled=${!e.connected}
292
- @keydown=${h=>{h.key==="Enter"&&(h.isComposing||h.keyCode===229||h.shiftKey||e.connected&&(h.preventDefault(),t&&e.onSend()))}}
293
- @input=${h=>e.onDraftChange(h.target.value)}
294
- placeholder=${l}
295
- ></textarea>
296
- </label>
297
- <div class="chat-compose__actions">
298
- <button
299
- class="btn"
300
- ?disabled=${!e.connected||!s&&e.sending}
301
- @click=${s?e.onAbort:e.onNewSession}
302
- >
303
- ${s?"Stop":"New session"}
304
- </button>
305
- <button
306
- class="btn primary"
307
- ?disabled=${!e.connected}
308
- @click=${e.onSend}
309
- >
310
- ${n?"Queue":"Send"}<kbd class="btn-kbd">↵</kbd>
311
- </button>
321
+ ${Lp(e)}
322
+ <div class="chat-compose__row">
323
+ <label class="field chat-compose__field">
324
+ <span>Message</span>
325
+ <textarea
326
+ .value=${e.draft}
327
+ ?disabled=${!e.connected}
328
+ @keydown=${v=>{v.key==="Enter"&&(v.isComposing||v.keyCode===229||v.shiftKey||e.connected&&(v.preventDefault(),t&&e.onSend()))}}
329
+ @input=${v=>e.onDraftChange(v.target.value)}
330
+ @paste=${v=>Ep(v,e)}
331
+ placeholder=${p}
332
+ ></textarea>
333
+ </label>
334
+ <div class="chat-compose__actions">
335
+ <button
336
+ class="btn"
337
+ ?disabled=${!e.connected||!s&&e.sending}
338
+ @click=${s?e.onAbort:e.onNewSession}
339
+ >
340
+ ${s?"Stop":"New session"}
341
+ </button>
342
+ <button
343
+ class="btn primary"
344
+ ?disabled=${!e.connected}
345
+ @click=${e.onSend}
346
+ >
347
+ ${n?"Queue":"Send"}<kbd class="btn-kbd">↵</kbd>
348
+ </button>
349
+ </div>
312
350
  </div>
313
351
  </div>
314
352
  </section>
315
- `}const Ca=200;function Ap(e){const t=[];let n=null;for(const s of e){if(s.kind!=="message"){n&&(t.push(n),n=null),t.push(s);continue}const i=zo(s.message),a=Js(i.role),o=i.timestamp||Date.now();!n||n.role!==a?(n&&t.push(n),n={kind:"group",key:`group:${a}:${s.key}`,role:a,messages:[{message:s.message,key:s.key}],timestamp:o,isStreaming:!1}):n.messages.push({message:s.message,key:s.key})}return n&&t.push(n),t}function Sp(e){const t=[],n=Array.isArray(e.messages)?e.messages:[],s=Array.isArray(e.toolMessages)?e.toolMessages:[],i=Math.max(0,n.length-Ca);i>0&&t.push({kind:"message",key:"chat:history:notice",message:{role:"system",content:`Showing last ${Ca} messages (${i} hidden).`,timestamp:Date.now()}});for(let a=i;a<n.length;a++){const o=n[a],c=zo(o);!e.showThinking&&c.role.toLowerCase()==="toolresult"||t.push({kind:"message",key:Ea(o,a),message:o})}if(e.showThinking)for(let a=0;a<s.length;a++)t.push({kind:"message",key:Ea(s[a],a+n.length),message:s[a]});if(e.stream!==null){const a=`stream:${e.sessionKey}:${e.streamStartedAt??"live"}`;e.stream.trim().length>0?t.push({kind:"stream",key:a,text:e.stream,startedAt:e.streamStartedAt??Date.now()}):t.push({kind:"reading-indicator",key:a})}return Ap(t)}function Ea(e,t){const n=e,s=typeof n.toolCallId=="string"?n.toolCallId:"";if(s)return`tool:${s}`;const i=typeof n.id=="string"?n.id:"";if(i)return`msg:${i}`;const a=typeof n.messageId=="string"?n.messageId:"";if(a)return`msg:${a}`;const o=typeof n.timestamp=="number"?n.timestamp:null,c=typeof n.role=="string"?n.role:"unknown";return o!=null?`msg:${c}:${o}:${t}`:`msg:${c}:${t}`}function ue(e){if(e)return Array.isArray(e.type)?e.type.filter(n=>n!=="null")[0]??e.type[0]:e.type}function dr(e){if(!e)return"";if(e.default!==void 0)return e.default;switch(ue(e)){case"object":return{};case"array":return[];case"boolean":return!1;case"number":case"integer":return 0;case"string":return"";default:return""}}function bn(e){return e.filter(t=>typeof t=="string").join(".")}function te(e,t){const n=bn(e),s=t[n];if(s)return s;const i=n.split(".");for(const[a,o]of Object.entries(t)){if(!a.includes("*"))continue;const c=a.split(".");if(c.length!==i.length)continue;let l=!0;for(let p=0;p<i.length;p+=1)if(c[p]!=="*"&&c[p]!==i[p]){l=!1;break}if(l)return o}}function we(e){return e.replace(/_/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/\s+/g," ").replace(/^./,t=>t.toUpperCase())}function _p(e){const t=bn(e).toLowerCase();return t.includes("token")||t.includes("password")||t.includes("secret")||t.includes("apikey")||t.endsWith("key")}const Tp=new Set(["title","description","default","nullable"]);function Cp(e){return Object.keys(e??{}).filter(n=>!Tp.has(n)).length===0}function Ep(e){if(e===void 0)return"";try{return JSON.stringify(e,null,2)??""}catch{return""}}const _t={chevronDown:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>`,plus:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>`,minus:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"></line></svg>`,trash:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path></svg>`,edit:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path></svg>`};function ye(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,onPatch:c}=e,l=e.showLabel??!0,p=ue(t),d=te(s,i),u=d?.label??t.title??we(String(s.at(-1))),h=d?.help??t.description,v=bn(s);if(a.has(v))return r`<div class="cfg-field cfg-field--error">
353
+ `}const Ea=200;function Mp(e){const t=[];let n=null;for(const s of e){if(s.kind!=="message"){n&&(t.push(n),n=null),t.push(s);continue}const i=jo(s.message),a=Js(i.role),o=i.timestamp||Date.now();!n||n.role!==a?(n&&t.push(n),n={kind:"group",key:`group:${a}:${s.key}`,role:a,messages:[{message:s.message,key:s.key}],timestamp:o,isStreaming:!1}):n.messages.push({message:s.message,key:s.key})}return n&&t.push(n),t}function Rp(e){const t=[],n=Array.isArray(e.messages)?e.messages:[],s=Array.isArray(e.toolMessages)?e.toolMessages:[],i=Math.max(0,n.length-Ea);i>0&&t.push({kind:"message",key:"chat:history:notice",message:{role:"system",content:`Showing last ${Ea} messages (${i} hidden).`,timestamp:Date.now()}});for(let a=i;a<n.length;a++){const o=n[a],l=jo(o);!e.showThinking&&l.role.toLowerCase()==="toolresult"||t.push({kind:"message",key:La(o,a),message:o})}if(e.showThinking)for(let a=0;a<s.length;a++)t.push({kind:"message",key:La(s[a],a+n.length),message:s[a]});if(e.stream!==null){const a=`stream:${e.sessionKey}:${e.streamStartedAt??"live"}`;e.stream.trim().length>0?t.push({kind:"stream",key:a,text:e.stream,startedAt:e.streamStartedAt??Date.now()}):t.push({kind:"reading-indicator",key:a})}return Mp(t)}function La(e,t){const n=e,s=typeof n.toolCallId=="string"?n.toolCallId:"";if(s)return`tool:${s}`;const i=typeof n.id=="string"?n.id:"";if(i)return`msg:${i}`;const a=typeof n.messageId=="string"?n.messageId:"";if(a)return`msg:${a}`;const o=typeof n.timestamp=="number"?n.timestamp:null,l=typeof n.role=="string"?n.role:"unknown";return o!=null?`msg:${l}:${o}:${t}`:`msg:${l}:${t}`}function ue(e){if(e)return Array.isArray(e.type)?e.type.filter(n=>n!=="null")[0]??e.type[0]:e.type}function ur(e){if(!e)return"";if(e.default!==void 0)return e.default;switch(ue(e)){case"object":return{};case"array":return[];case"boolean":return!1;case"number":case"integer":return 0;case"string":return"";default:return""}}function bn(e){return e.filter(t=>typeof t=="string").join(".")}function te(e,t){const n=bn(e),s=t[n];if(s)return s;const i=n.split(".");for(const[a,o]of Object.entries(t)){if(!a.includes("*"))continue;const l=a.split(".");if(l.length!==i.length)continue;let r=!0;for(let p=0;p<i.length;p+=1)if(l[p]!=="*"&&l[p]!==i[p]){r=!1;break}if(r)return o}}function we(e){return e.replace(/_/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/\s+/g," ").replace(/^./,t=>t.toUpperCase())}function Pp(e){const t=bn(e).toLowerCase();return t.includes("token")||t.includes("password")||t.includes("secret")||t.includes("apikey")||t.endsWith("key")}const Np=new Set(["title","description","default","nullable"]);function Op(e){return Object.keys(e??{}).filter(n=>!Np.has(n)).length===0}function Dp(e){if(e===void 0)return"";try{return JSON.stringify(e,null,2)??""}catch{return""}}const _t={chevronDown:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>`,plus:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>`,minus:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"></line></svg>`,trash:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path></svg>`,edit:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"></path></svg>`};function be(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,onPatch:l}=e,r=e.showLabel??!0,p=ue(t),d=te(s,i),u=d?.label??t.title??we(String(s.at(-1))),g=d?.help??t.description,v=bn(s);if(a.has(v))return c`<div class="cfg-field cfg-field--error">
316
354
  <div class="cfg-field__label">${u}</div>
317
355
  <div class="cfg-field__error">Unsupported schema node. Use Raw mode.</div>
318
- </div>`;if(t.anyOf||t.oneOf){const $=(t.anyOf??t.oneOf??[]).filter(C=>!(C.type==="null"||Array.isArray(C.type)&&C.type.includes("null")));if($.length===1)return ye({...e,schema:$[0]});const k=C=>{if(C.const!==void 0)return C.const;if(C.enum&&C.enum.length===1)return C.enum[0]},T=$.map(k),M=T.every(C=>C!==void 0);if(M&&T.length>0&&T.length<=5){const C=n??t.default;return r`
356
+ </div>`;if(t.anyOf||t.oneOf){const $=(t.anyOf??t.oneOf??[]).filter(C=>!(C.type==="null"||Array.isArray(C.type)&&C.type.includes("null")));if($.length===1)return be({...e,schema:$[0]});const k=C=>{if(C.const!==void 0)return C.const;if(C.enum&&C.enum.length===1)return C.enum[0]},_=$.map(k),I=_.every(C=>C!==void 0);if(I&&_.length>0&&_.length<=5){const C=n??t.default;return c`
319
357
  <div class="cfg-field">
320
- ${l?r`<label class="cfg-field__label">${u}</label>`:g}
321
- ${h?r`<div class="cfg-field__help">${h}</div>`:g}
358
+ ${r?c`<label class="cfg-field__label">${u}</label>`:h}
359
+ ${g?c`<div class="cfg-field__help">${g}</div>`:h}
322
360
  <div class="cfg-segmented">
323
- ${T.map((E,pe)=>r`
361
+ ${_.map((E,pe)=>c`
324
362
  <button
325
363
  type="button"
326
364
  class="cfg-segmented__btn ${E===C||String(E)===String(C)?"active":""}"
327
365
  ?disabled=${o}
328
- @click=${()=>c(s,E)}
366
+ @click=${()=>l(s,E)}
329
367
  >
330
368
  ${String(E)}
331
369
  </button>
332
370
  `)}
333
371
  </div>
334
372
  </div>
335
- `}if(M&&T.length>5)return Ma({...e,options:T,value:n??t.default});const P=new Set($.map(C=>ue(C)).filter(Boolean)),L=new Set([...P].map(C=>C==="integer"?"number":C));if([...L].every(C=>["string","number","boolean"].includes(C))){const C=L.has("string"),E=L.has("number");if(L.has("boolean")&&L.size===1)return ye({...e,schema:{...t,type:"boolean",anyOf:void 0,oneOf:void 0}});if(C||E)return La({...e,inputType:E&&!C?"number":"text"})}}if(t.enum){const w=t.enum;if(w.length<=5){const $=n??t.default;return r`
373
+ `}if(I&&_.length>5)return Ma({...e,options:_,value:n??t.default});const P=new Set($.map(C=>ue(C)).filter(Boolean)),L=new Set([...P].map(C=>C==="integer"?"number":C));if([...L].every(C=>["string","number","boolean"].includes(C))){const C=L.has("string"),E=L.has("number");if(L.has("boolean")&&L.size===1)return be({...e,schema:{...t,type:"boolean",anyOf:void 0,oneOf:void 0}});if(C||E)return Ia({...e,inputType:E&&!C?"number":"text"})}}if(t.enum){const w=t.enum;if(w.length<=5){const $=n??t.default;return c`
336
374
  <div class="cfg-field">
337
- ${l?r`<label class="cfg-field__label">${u}</label>`:g}
338
- ${h?r`<div class="cfg-field__help">${h}</div>`:g}
375
+ ${r?c`<label class="cfg-field__label">${u}</label>`:h}
376
+ ${g?c`<div class="cfg-field__help">${g}</div>`:h}
339
377
  <div class="cfg-segmented">
340
- ${w.map(k=>r`
378
+ ${w.map(k=>c`
341
379
  <button
342
380
  type="button"
343
381
  class="cfg-segmented__btn ${k===$||String(k)===String($)?"active":""}"
344
382
  ?disabled=${o}
345
- @click=${()=>c(s,k)}
383
+ @click=${()=>l(s,k)}
346
384
  >
347
385
  ${String(k)}
348
386
  </button>
349
387
  `)}
350
388
  </div>
351
389
  </div>
352
- `}return Ma({...e,options:w,value:n??t.default})}if(p==="object")return Mp(e);if(p==="array")return Ip(e);if(p==="boolean"){const w=typeof n=="boolean"?n:typeof t.default=="boolean"?t.default:!1;return r`
390
+ `}return Ma({...e,options:w,value:n??t.default})}if(p==="object")return Fp(e);if(p==="array")return Up(e);if(p==="boolean"){const w=typeof n=="boolean"?n:typeof t.default=="boolean"?t.default:!1;return c`
353
391
  <label class="cfg-toggle-row ${o?"disabled":""}">
354
392
  <div class="cfg-toggle-row__content">
355
393
  <span class="cfg-toggle-row__label">${u}</span>
356
- ${h?r`<span class="cfg-toggle-row__help">${h}</span>`:g}
394
+ ${g?c`<span class="cfg-toggle-row__help">${g}</span>`:h}
357
395
  </div>
358
396
  <div class="cfg-toggle">
359
397
  <input
360
398
  type="checkbox"
361
399
  .checked=${w}
362
400
  ?disabled=${o}
363
- @change=${$=>c(s,$.target.checked)}
401
+ @change=${$=>l(s,$.target.checked)}
364
402
  />
365
403
  <span class="cfg-toggle__track"></span>
366
404
  </div>
367
405
  </label>
368
- `}return p==="number"||p==="integer"?Lp(e):p==="string"?La({...e,inputType:"text"}):r`
406
+ `}return p==="number"||p==="integer"?Bp(e):p==="string"?Ia({...e,inputType:"text"}):c`
369
407
  <div class="cfg-field cfg-field--error">
370
408
  <div class="cfg-field__label">${u}</div>
371
409
  <div class="cfg-field__error">Unsupported type: ${p}. Use Raw mode.</div>
372
410
  </div>
373
- `}function La(e){const{schema:t,value:n,path:s,hints:i,disabled:a,onPatch:o,inputType:c}=e,l=e.showLabel??!0,p=te(s,i),d=p?.label??t.title??we(String(s.at(-1))),u=p?.help??t.description,h=p?.sensitive??_p(s),v=p?.placeholder??(h?"••••":t.default!==void 0?`Default: ${t.default}`:""),w=n??"";return r`
411
+ `}function Ia(e){const{schema:t,value:n,path:s,hints:i,disabled:a,onPatch:o,inputType:l}=e,r=e.showLabel??!0,p=te(s,i),d=p?.label??t.title??we(String(s.at(-1))),u=p?.help??t.description,g=p?.sensitive??Pp(s),v=p?.placeholder??(g?"••••":t.default!==void 0?`Default: ${t.default}`:""),w=n??"";return c`
374
412
  <div class="cfg-field">
375
- ${l?r`<label class="cfg-field__label">${d}</label>`:g}
376
- ${u?r`<div class="cfg-field__help">${u}</div>`:g}
413
+ ${r?c`<label class="cfg-field__label">${d}</label>`:h}
414
+ ${u?c`<div class="cfg-field__help">${u}</div>`:h}
377
415
  <div class="cfg-input-wrap">
378
416
  <input
379
- type=${h?"password":c}
417
+ type=${g?"password":l}
380
418
  class="cfg-input"
381
419
  placeholder=${v}
382
420
  .value=${w==null?"":String(w)}
383
421
  ?disabled=${a}
384
- @input=${$=>{const k=$.target.value;if(c==="number"){if(k.trim()===""){o(s,void 0);return}const T=Number(k);o(s,Number.isNaN(T)?k:T);return}o(s,k)}}
422
+ @input=${$=>{const k=$.target.value;if(l==="number"){if(k.trim()===""){o(s,void 0);return}const _=Number(k);o(s,Number.isNaN(_)?k:_);return}o(s,k)}}
385
423
  />
386
- ${t.default!==void 0?r`
424
+ ${t.default!==void 0?c`
387
425
  <button
388
426
  type="button"
389
427
  class="cfg-input__reset"
@@ -391,19 +429,19 @@ ${e.sidebarContent}
391
429
  ?disabled=${a}
392
430
  @click=${()=>o(s,t.default)}
393
431
  >↺</button>
394
- `:g}
432
+ `:h}
395
433
  </div>
396
434
  </div>
397
- `}function Lp(e){const{schema:t,value:n,path:s,hints:i,disabled:a,onPatch:o}=e,c=e.showLabel??!0,l=te(s,i),p=l?.label??t.title??we(String(s.at(-1))),d=l?.help??t.description,u=n??t.default??"",h=typeof u=="number"?u:0;return r`
435
+ `}function Bp(e){const{schema:t,value:n,path:s,hints:i,disabled:a,onPatch:o}=e,l=e.showLabel??!0,r=te(s,i),p=r?.label??t.title??we(String(s.at(-1))),d=r?.help??t.description,u=n??t.default??"",g=typeof u=="number"?u:0;return c`
398
436
  <div class="cfg-field">
399
- ${c?r`<label class="cfg-field__label">${p}</label>`:g}
400
- ${d?r`<div class="cfg-field__help">${d}</div>`:g}
437
+ ${l?c`<label class="cfg-field__label">${p}</label>`:h}
438
+ ${d?c`<div class="cfg-field__help">${d}</div>`:h}
401
439
  <div class="cfg-number">
402
440
  <button
403
441
  type="button"
404
442
  class="cfg-number__btn"
405
443
  ?disabled=${a}
406
- @click=${()=>o(s,h-1)}
444
+ @click=${()=>o(s,g-1)}
407
445
  >−</button>
408
446
  <input
409
447
  type="number"
@@ -416,72 +454,72 @@ ${e.sidebarContent}
416
454
  type="button"
417
455
  class="cfg-number__btn"
418
456
  ?disabled=${a}
419
- @click=${()=>o(s,h+1)}
457
+ @click=${()=>o(s,g+1)}
420
458
  >+</button>
421
459
  </div>
422
460
  </div>
423
- `}function Ma(e){const{schema:t,value:n,path:s,hints:i,disabled:a,options:o,onPatch:c}=e,l=e.showLabel??!0,p=te(s,i),d=p?.label??t.title??we(String(s.at(-1))),u=p?.help??t.description,h=n??t.default,v=o.findIndex($=>$===h||String($)===String(h)),w="__unset__";return r`
461
+ `}function Ma(e){const{schema:t,value:n,path:s,hints:i,disabled:a,options:o,onPatch:l}=e,r=e.showLabel??!0,p=te(s,i),d=p?.label??t.title??we(String(s.at(-1))),u=p?.help??t.description,g=n??t.default,v=o.findIndex($=>$===g||String($)===String(g)),w="__unset__";return c`
424
462
  <div class="cfg-field">
425
- ${l?r`<label class="cfg-field__label">${d}</label>`:g}
426
- ${u?r`<div class="cfg-field__help">${u}</div>`:g}
463
+ ${r?c`<label class="cfg-field__label">${d}</label>`:h}
464
+ ${u?c`<div class="cfg-field__help">${u}</div>`:h}
427
465
  <select
428
466
  class="cfg-select"
429
467
  ?disabled=${a}
430
468
  .value=${v>=0?String(v):w}
431
- @change=${$=>{const k=$.target.value;c(s,k===w?void 0:o[Number(k)])}}
469
+ @change=${$=>{const k=$.target.value;l(s,k===w?void 0:o[Number(k)])}}
432
470
  >
433
471
  <option value=${w}>Select...</option>
434
- ${o.map(($,k)=>r`
472
+ ${o.map(($,k)=>c`
435
473
  <option value=${String(k)}>${String($)}</option>
436
474
  `)}
437
475
  </select>
438
476
  </div>
439
- `}function Mp(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,onPatch:c}=e;e.showLabel;const l=te(s,i),p=l?.label??t.title??we(String(s.at(-1))),d=l?.help??t.description,u=n??t.default,h=u&&typeof u=="object"&&!Array.isArray(u)?u:{},v=t.properties??{},$=Object.entries(v).sort((P,L)=>{const C=te([...s,P[0]],i)?.order??0,E=te([...s,L[0]],i)?.order??0;return C!==E?C-E:P[0].localeCompare(L[0])}),k=new Set(Object.keys(v)),T=t.additionalProperties,M=!!T&&typeof T=="object";return s.length===1?r`
477
+ `}function Fp(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,onPatch:l}=e;e.showLabel;const r=te(s,i),p=r?.label??t.title??we(String(s.at(-1))),d=r?.help??t.description,u=n??t.default,g=u&&typeof u=="object"&&!Array.isArray(u)?u:{},v=t.properties??{},$=Object.entries(v).sort((P,L)=>{const C=te([...s,P[0]],i)?.order??0,E=te([...s,L[0]],i)?.order??0;return C!==E?C-E:P[0].localeCompare(L[0])}),k=new Set(Object.keys(v)),_=t.additionalProperties,I=!!_&&typeof _=="object";return s.length===1?c`
440
478
  <div class="cfg-fields">
441
- ${$.map(([P,L])=>ye({schema:L,value:h[P],path:[...s,P],hints:i,unsupported:a,disabled:o,onPatch:c}))}
442
- ${M?Ia({schema:T,value:h,path:s,hints:i,unsupported:a,disabled:o,reservedKeys:k,onPatch:c}):g}
479
+ ${$.map(([P,L])=>be({schema:L,value:g[P],path:[...s,P],hints:i,unsupported:a,disabled:o,onPatch:l}))}
480
+ ${I?Ra({schema:_,value:g,path:s,hints:i,unsupported:a,disabled:o,reservedKeys:k,onPatch:l}):h}
443
481
  </div>
444
- `:r`
482
+ `:c`
445
483
  <details class="cfg-object" open>
446
484
  <summary class="cfg-object__header">
447
485
  <span class="cfg-object__title">${p}</span>
448
486
  <span class="cfg-object__chevron">${_t.chevronDown}</span>
449
487
  </summary>
450
- ${d?r`<div class="cfg-object__help">${d}</div>`:g}
488
+ ${d?c`<div class="cfg-object__help">${d}</div>`:h}
451
489
  <div class="cfg-object__content">
452
- ${$.map(([P,L])=>ye({schema:L,value:h[P],path:[...s,P],hints:i,unsupported:a,disabled:o,onPatch:c}))}
453
- ${M?Ia({schema:T,value:h,path:s,hints:i,unsupported:a,disabled:o,reservedKeys:k,onPatch:c}):g}
490
+ ${$.map(([P,L])=>be({schema:L,value:g[P],path:[...s,P],hints:i,unsupported:a,disabled:o,onPatch:l}))}
491
+ ${I?Ra({schema:_,value:g,path:s,hints:i,unsupported:a,disabled:o,reservedKeys:k,onPatch:l}):h}
454
492
  </div>
455
493
  </details>
456
- `}function Ip(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,onPatch:c}=e,l=e.showLabel??!0,p=te(s,i),d=p?.label??t.title??we(String(s.at(-1))),u=p?.help??t.description,h=Array.isArray(t.items)?t.items[0]:t.items;if(!h)return r`
494
+ `}function Up(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,onPatch:l}=e,r=e.showLabel??!0,p=te(s,i),d=p?.label??t.title??we(String(s.at(-1))),u=p?.help??t.description,g=Array.isArray(t.items)?t.items[0]:t.items;if(!g)return c`
457
495
  <div class="cfg-field cfg-field--error">
458
496
  <div class="cfg-field__label">${d}</div>
459
497
  <div class="cfg-field__error">Unsupported array schema. Use Raw mode.</div>
460
498
  </div>
461
- `;const v=Array.isArray(n)?n:Array.isArray(t.default)?t.default:[];return r`
499
+ `;const v=Array.isArray(n)?n:Array.isArray(t.default)?t.default:[];return c`
462
500
  <div class="cfg-array">
463
501
  <div class="cfg-array__header">
464
- ${l?r`<span class="cfg-array__label">${d}</span>`:g}
502
+ ${r?c`<span class="cfg-array__label">${d}</span>`:h}
465
503
  <span class="cfg-array__count">${v.length} item${v.length!==1?"s":""}</span>
466
504
  <button
467
505
  type="button"
468
506
  class="cfg-array__add"
469
507
  ?disabled=${o}
470
- @click=${()=>{const w=[...v,dr(h)];c(s,w)}}
508
+ @click=${()=>{const w=[...v,ur(g)];l(s,w)}}
471
509
  >
472
510
  <span class="cfg-array__add-icon">${_t.plus}</span>
473
511
  Add
474
512
  </button>
475
513
  </div>
476
- ${u?r`<div class="cfg-array__help">${u}</div>`:g}
514
+ ${u?c`<div class="cfg-array__help">${u}</div>`:h}
477
515
 
478
- ${v.length===0?r`
516
+ ${v.length===0?c`
479
517
  <div class="cfg-array__empty">
480
518
  No items yet. Click "Add" to create one.
481
519
  </div>
482
- `:r`
520
+ `:c`
483
521
  <div class="cfg-array__items">
484
- ${v.map((w,$)=>r`
522
+ ${v.map((w,$)=>c`
485
523
  <div class="cfg-array__item">
486
524
  <div class="cfg-array__item-header">
487
525
  <span class="cfg-array__item-index">#${$+1}</span>
@@ -490,20 +528,20 @@ ${e.sidebarContent}
490
528
  class="cfg-array__item-remove"
491
529
  title="Remove item"
492
530
  ?disabled=${o}
493
- @click=${()=>{const k=[...v];k.splice($,1),c(s,k)}}
531
+ @click=${()=>{const k=[...v];k.splice($,1),l(s,k)}}
494
532
  >
495
533
  ${_t.trash}
496
534
  </button>
497
535
  </div>
498
536
  <div class="cfg-array__item-content">
499
- ${ye({schema:h,value:w,path:[...s,$],hints:i,unsupported:a,disabled:o,showLabel:!1,onPatch:c})}
537
+ ${be({schema:g,value:w,path:[...s,$],hints:i,unsupported:a,disabled:o,showLabel:!1,onPatch:l})}
500
538
  </div>
501
539
  </div>
502
540
  `)}
503
541
  </div>
504
542
  `}
505
543
  </div>
506
- `}function Ia(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,reservedKeys:c,onPatch:l}=e,p=Cp(t),d=Object.entries(n??{}).filter(([u])=>!c.has(u));return r`
544
+ `}function Ra(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,reservedKeys:l,onPatch:r}=e,p=Op(t),d=Object.entries(n??{}).filter(([u])=>!l.has(u));return c`
507
545
  <div class="cfg-map">
508
546
  <div class="cfg-map__header">
509
547
  <span class="cfg-map__label">Custom entries</span>
@@ -511,18 +549,18 @@ ${e.sidebarContent}
511
549
  type="button"
512
550
  class="cfg-map__add"
513
551
  ?disabled=${o}
514
- @click=${()=>{const u={...n??{}};let h=1,v=`custom-${h}`;for(;v in u;)h+=1,v=`custom-${h}`;u[v]=p?{}:dr(t),l(s,u)}}
552
+ @click=${()=>{const u={...n??{}};let g=1,v=`custom-${g}`;for(;v in u;)g+=1,v=`custom-${g}`;u[v]=p?{}:ur(t),r(s,u)}}
515
553
  >
516
554
  <span class="cfg-map__add-icon">${_t.plus}</span>
517
555
  Add Entry
518
556
  </button>
519
557
  </div>
520
558
 
521
- ${d.length===0?r`
559
+ ${d.length===0?c`
522
560
  <div class="cfg-map__empty">No custom entries.</div>
523
- `:r`
561
+ `:c`
524
562
  <div class="cfg-map__items">
525
- ${d.map(([u,h])=>{const v=[...s,u],w=Ep(h);return r`
563
+ ${d.map(([u,g])=>{const v=[...s,u],w=Dp(g);return c`
526
564
  <div class="cfg-map__item">
527
565
  <div class="cfg-map__item-key">
528
566
  <input
@@ -531,27 +569,27 @@ ${e.sidebarContent}
531
569
  placeholder="Key"
532
570
  .value=${u}
533
571
  ?disabled=${o}
534
- @change=${$=>{const k=$.target.value.trim();if(!k||k===u)return;const T={...n??{}};k in T||(T[k]=T[u],delete T[u],l(s,T))}}
572
+ @change=${$=>{const k=$.target.value.trim();if(!k||k===u)return;const _={...n??{}};k in _||(_[k]=_[u],delete _[u],r(s,_))}}
535
573
  />
536
574
  </div>
537
575
  <div class="cfg-map__item-value">
538
- ${p?r`
576
+ ${p?c`
539
577
  <textarea
540
578
  class="cfg-textarea cfg-textarea--sm"
541
579
  placeholder="JSON value"
542
580
  rows="2"
543
581
  .value=${w}
544
582
  ?disabled=${o}
545
- @change=${$=>{const k=$.target,T=k.value.trim();if(!T){l(v,void 0);return}try{l(v,JSON.parse(T))}catch{k.value=w}}}
583
+ @change=${$=>{const k=$.target,_=k.value.trim();if(!_){r(v,void 0);return}try{r(v,JSON.parse(_))}catch{k.value=w}}}
546
584
  ></textarea>
547
- `:ye({schema:t,value:h,path:v,hints:i,unsupported:a,disabled:o,showLabel:!1,onPatch:l})}
585
+ `:be({schema:t,value:g,path:v,hints:i,unsupported:a,disabled:o,showLabel:!1,onPatch:r})}
548
586
  </div>
549
587
  <button
550
588
  type="button"
551
589
  class="cfg-map__item-remove"
552
590
  title="Remove entry"
553
591
  ?disabled=${o}
554
- @click=${()=>{const $={...n??{}};delete $[u],l(s,$)}}
592
+ @click=${()=>{const $={...n??{}};delete $[u],r(s,$)}}
555
593
  >
556
594
  ${_t.trash}
557
595
  </button>
@@ -560,44 +598,44 @@ ${e.sidebarContent}
560
598
  </div>
561
599
  `}
562
600
  </div>
563
- `}const Ra={env:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg>`,update:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>`,agents:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7h1a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-1v1a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-1H2a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h1a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-.99-1-1.73a2 2 0 0 1 2-2z"></path><circle cx="8" cy="14" r="1"></circle><circle cx="16" cy="14" r="1"></circle></svg>`,auth:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>`,channels:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg>`,messages:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg>`,commands:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><polyline points="4 17 10 11 4 5"></polyline><line x1="12" y1="19" x2="20" y2="19"></line></svg>`,hooks:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>`,skills:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon></svg>`,tools:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"></path></svg>`,gateway:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg>`,wizard:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M15 4V2"></path><path d="M15 16v-2"></path><path d="M8 9h2"></path><path d="M20 9h2"></path><path d="M17.8 11.8 19 13"></path><path d="M15 9h0"></path><path d="M17.8 6.2 19 5"></path><path d="m3 21 9-9"></path><path d="M12.2 6.2 11 5"></path></svg>`,meta:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 20h9"></path><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"></path></svg>`,logging:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>`,browser:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"></circle><circle cx="12" cy="12" r="4"></circle><line x1="21.17" y1="8" x2="12" y2="8"></line><line x1="3.95" y1="6.06" x2="8.54" y2="14"></line><line x1="10.88" y1="21.94" x2="15.46" y2="14"></line></svg>`,ui:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="3" y1="9" x2="21" y2="9"></line><line x1="9" y1="21" x2="9" y2="9"></line></svg>`,models:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path><polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline><line x1="12" y1="22.08" x2="12" y2="12"></line></svg>`,bindings:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect><rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect><line x1="6" y1="6" x2="6.01" y2="6"></line><line x1="6" y1="18" x2="6.01" y2="18"></line></svg>`,broadcast:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M4.9 19.1C1 15.2 1 8.8 4.9 4.9"></path><path d="M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5"></path><circle cx="12" cy="12" r="2"></circle><path d="M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5"></path><path d="M19.1 4.9C23 8.8 23 15.1 19.1 19"></path></svg>`,audio:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M9 18V5l12-2v13"></path><circle cx="6" cy="18" r="3"></circle><circle cx="18" cy="16" r="3"></circle></svg>`,session:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>`,cron:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg>`,web:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg>`,discovery:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>`,canvasHost:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg>`,talk:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"></path><path d="M19 10v2a7 7 0 0 1-14 0v-2"></path><line x1="12" y1="19" x2="12" y2="23"></line><line x1="8" y1="23" x2="16" y2="23"></line></svg>`,plugins:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 2v6"></path><path d="m4.93 10.93 4.24 4.24"></path><path d="M2 12h6"></path><path d="m4.93 13.07 4.24-4.24"></path><path d="M12 22v-6"></path><path d="m19.07 13.07-4.24-4.24"></path><path d="M22 12h-6"></path><path d="m19.07 10.93-4.24 4.24"></path></svg>`,default:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline></svg>`},ci={env:{label:"Environment Variables",description:"Environment variables passed to the gateway process"},update:{label:"Updates",description:"Auto-update settings and release channel"},agents:{label:"Agents",description:"Agent configurations, models, and identities"},auth:{label:"Authentication",description:"API keys and authentication profiles"},channels:{label:"Channels",description:"Messaging channels (Telegram, Discord, Slack, etc.)"},messages:{label:"Messages",description:"Message handling and routing settings"},commands:{label:"Commands",description:"Custom slash commands"},hooks:{label:"Hooks",description:"Webhooks and event hooks"},skills:{label:"Skills",description:"Skill packs and capabilities"},tools:{label:"Tools",description:"Tool configurations (browser, search, etc.)"},gateway:{label:"Gateway",description:"Gateway server settings (port, auth, binding)"},wizard:{label:"Setup Wizard",description:"Setup wizard state and history"},meta:{label:"Metadata",description:"Gateway metadata and version information"},logging:{label:"Logging",description:"Log levels and output configuration"},browser:{label:"Browser",description:"Browser automation settings"},ui:{label:"UI",description:"User interface preferences"},models:{label:"Models",description:"AI model configurations and providers"},bindings:{label:"Bindings",description:"Key bindings and shortcuts"},broadcast:{label:"Broadcast",description:"Broadcast and notification settings"},audio:{label:"Audio",description:"Audio input/output settings"},session:{label:"Session",description:"Session management and persistence"},cron:{label:"Cron",description:"Scheduled tasks and automation"},web:{label:"Web",description:"Web server and API settings"},discovery:{label:"Discovery",description:"Service discovery and networking"},canvasHost:{label:"Canvas Host",description:"Canvas rendering and display"},talk:{label:"Talk",description:"Voice and speech settings"},plugins:{label:"Plugins",description:"Plugin management and extensions"}};function Pa(e){return Ra[e]??Ra.default}function Rp(e,t,n){if(!n)return!0;const s=n.toLowerCase(),i=ci[e];return e.toLowerCase().includes(s)||i&&(i.label.toLowerCase().includes(s)||i.description.toLowerCase().includes(s))?!0:mt(t,s)}function mt(e,t){if(e.title?.toLowerCase().includes(t)||e.description?.toLowerCase().includes(t)||e.enum?.some(s=>String(s).toLowerCase().includes(t)))return!0;if(e.properties){for(const[s,i]of Object.entries(e.properties))if(s.toLowerCase().includes(t)||mt(i,t))return!0}if(e.items){const s=Array.isArray(e.items)?e.items:[e.items];for(const i of s)if(i&&mt(i,t))return!0}if(e.additionalProperties&&typeof e.additionalProperties=="object"&&mt(e.additionalProperties,t))return!0;const n=e.anyOf??e.oneOf??e.allOf;if(n){for(const s of n)if(s&&mt(s,t))return!0}return!1}function Pp(e){if(!e.schema)return r`<div class="muted">Schema unavailable.</div>`;const t=e.schema,n=e.value??{};if(ue(t)!=="object"||!t.properties)return r`<div class="callout danger">Unsupported schema. Use Raw.</div>`;const s=new Set(e.unsupportedPaths??[]),i=t.properties,a=e.searchQuery??"",o=e.activeSection,c=e.activeSubsection??null,p=Object.entries(i).sort((u,h)=>{const v=te([u[0]],e.uiHints)?.order??50,w=te([h[0]],e.uiHints)?.order??50;return v!==w?v-w:u[0].localeCompare(h[0])}).filter(([u,h])=>!(o&&u!==o||a&&!Rp(u,h,a)));let d=null;if(o&&c&&p.length===1){const u=p[0]?.[1];u&&ue(u)==="object"&&u.properties&&u.properties[c]&&(d={sectionKey:o,subsectionKey:c,schema:u.properties[c]})}return p.length===0?r`
601
+ `}const Pa={env:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg>`,update:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>`,agents:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7h1a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-1v1a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-1H2a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h1a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-.99-1-1.73a2 2 0 0 1 2-2z"></path><circle cx="8" cy="14" r="1"></circle><circle cx="16" cy="14" r="1"></circle></svg>`,auth:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>`,channels:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg>`,messages:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg>`,commands:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><polyline points="4 17 10 11 4 5"></polyline><line x1="12" y1="19" x2="20" y2="19"></line></svg>`,hooks:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>`,skills:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon></svg>`,tools:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"></path></svg>`,gateway:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg>`,wizard:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M15 4V2"></path><path d="M15 16v-2"></path><path d="M8 9h2"></path><path d="M20 9h2"></path><path d="M17.8 11.8 19 13"></path><path d="M15 9h0"></path><path d="M17.8 6.2 19 5"></path><path d="m3 21 9-9"></path><path d="M12.2 6.2 11 5"></path></svg>`,meta:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 20h9"></path><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"></path></svg>`,logging:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>`,browser:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"></circle><circle cx="12" cy="12" r="4"></circle><line x1="21.17" y1="8" x2="12" y2="8"></line><line x1="3.95" y1="6.06" x2="8.54" y2="14"></line><line x1="10.88" y1="21.94" x2="15.46" y2="14"></line></svg>`,ui:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="3" y1="9" x2="21" y2="9"></line><line x1="9" y1="21" x2="9" y2="9"></line></svg>`,models:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path><polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline><line x1="12" y1="22.08" x2="12" y2="12"></line></svg>`,bindings:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect><rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect><line x1="6" y1="6" x2="6.01" y2="6"></line><line x1="6" y1="18" x2="6.01" y2="18"></line></svg>`,broadcast:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M4.9 19.1C1 15.2 1 8.8 4.9 4.9"></path><path d="M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5"></path><circle cx="12" cy="12" r="2"></circle><path d="M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5"></path><path d="M19.1 4.9C23 8.8 23 15.1 19.1 19"></path></svg>`,audio:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M9 18V5l12-2v13"></path><circle cx="6" cy="18" r="3"></circle><circle cx="18" cy="16" r="3"></circle></svg>`,session:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>`,cron:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg>`,web:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg>`,discovery:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>`,canvasHost:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg>`,talk:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"></path><path d="M19 10v2a7 7 0 0 1-14 0v-2"></path><line x1="12" y1="19" x2="12" y2="23"></line><line x1="8" y1="23" x2="16" y2="23"></line></svg>`,plugins:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M12 2v6"></path><path d="m4.93 10.93 4.24 4.24"></path><path d="M2 12h6"></path><path d="m4.93 13.07 4.24-4.24"></path><path d="M12 22v-6"></path><path d="m19.07 13.07-4.24-4.24"></path><path d="M22 12h-6"></path><path d="m19.07 10.93-4.24 4.24"></path></svg>`,default:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline></svg>`},ci={env:{label:"Environment Variables",description:"Environment variables passed to the gateway process"},update:{label:"Updates",description:"Auto-update settings and release channel"},agents:{label:"Agents",description:"Agent configurations, models, and identities"},auth:{label:"Authentication",description:"API keys and authentication profiles"},channels:{label:"Channels",description:"Messaging channels (Telegram, Discord, Slack, etc.)"},messages:{label:"Messages",description:"Message handling and routing settings"},commands:{label:"Commands",description:"Custom slash commands"},hooks:{label:"Hooks",description:"Webhooks and event hooks"},skills:{label:"Skills",description:"Skill packs and capabilities"},tools:{label:"Tools",description:"Tool configurations (browser, search, etc.)"},gateway:{label:"Gateway",description:"Gateway server settings (port, auth, binding)"},wizard:{label:"Setup Wizard",description:"Setup wizard state and history"},meta:{label:"Metadata",description:"Gateway metadata and version information"},logging:{label:"Logging",description:"Log levels and output configuration"},browser:{label:"Browser",description:"Browser automation settings"},ui:{label:"UI",description:"User interface preferences"},models:{label:"Models",description:"AI model configurations and providers"},bindings:{label:"Bindings",description:"Key bindings and shortcuts"},broadcast:{label:"Broadcast",description:"Broadcast and notification settings"},audio:{label:"Audio",description:"Audio input/output settings"},session:{label:"Session",description:"Session management and persistence"},cron:{label:"Cron",description:"Scheduled tasks and automation"},web:{label:"Web",description:"Web server and API settings"},discovery:{label:"Discovery",description:"Service discovery and networking"},canvasHost:{label:"Canvas Host",description:"Canvas rendering and display"},talk:{label:"Talk",description:"Voice and speech settings"},plugins:{label:"Plugins",description:"Plugin management and extensions"}};function Na(e){return Pa[e]??Pa.default}function Kp(e,t,n){if(!n)return!0;const s=n.toLowerCase(),i=ci[e];return e.toLowerCase().includes(s)||i&&(i.label.toLowerCase().includes(s)||i.description.toLowerCase().includes(s))?!0:mt(t,s)}function mt(e,t){if(e.title?.toLowerCase().includes(t)||e.description?.toLowerCase().includes(t)||e.enum?.some(s=>String(s).toLowerCase().includes(t)))return!0;if(e.properties){for(const[s,i]of Object.entries(e.properties))if(s.toLowerCase().includes(t)||mt(i,t))return!0}if(e.items){const s=Array.isArray(e.items)?e.items:[e.items];for(const i of s)if(i&&mt(i,t))return!0}if(e.additionalProperties&&typeof e.additionalProperties=="object"&&mt(e.additionalProperties,t))return!0;const n=e.anyOf??e.oneOf??e.allOf;if(n){for(const s of n)if(s&&mt(s,t))return!0}return!1}function Hp(e){if(!e.schema)return c`<div class="muted">Schema unavailable.</div>`;const t=e.schema,n=e.value??{};if(ue(t)!=="object"||!t.properties)return c`<div class="callout danger">Unsupported schema. Use Raw.</div>`;const s=new Set(e.unsupportedPaths??[]),i=t.properties,a=e.searchQuery??"",o=e.activeSection,l=e.activeSubsection??null,p=Object.entries(i).sort((u,g)=>{const v=te([u[0]],e.uiHints)?.order??50,w=te([g[0]],e.uiHints)?.order??50;return v!==w?v-w:u[0].localeCompare(g[0])}).filter(([u,g])=>!(o&&u!==o||a&&!Kp(u,g,a)));let d=null;if(o&&l&&p.length===1){const u=p[0]?.[1];u&&ue(u)==="object"&&u.properties&&u.properties[l]&&(d={sectionKey:o,subsectionKey:l,schema:u.properties[l]})}return p.length===0?c`
564
602
  <div class="config-empty">
565
- <div class="config-empty__icon">${Q.search}</div>
603
+ <div class="config-empty__icon">${V.search}</div>
566
604
  <div class="config-empty__text">
567
605
  ${a?`No settings match "${a}"`:"No settings in this section"}
568
606
  </div>
569
607
  </div>
570
- `:r`
608
+ `:c`
571
609
  <div class="config-form config-form--modern">
572
- ${d?(()=>{const{sectionKey:u,subsectionKey:h,schema:v}=d,w=te([u,h],e.uiHints),$=w?.label??v.title??we(h),k=w?.help??v.description??"",T=n[u],M=T&&typeof T=="object"?T[h]:void 0,P=`config-section-${u}-${h}`;return r`
610
+ ${d?(()=>{const{sectionKey:u,subsectionKey:g,schema:v}=d,w=te([u,g],e.uiHints),$=w?.label??v.title??we(g),k=w?.help??v.description??"",_=n[u],I=_&&typeof _=="object"?_[g]:void 0,P=`config-section-${u}-${g}`;return c`
573
611
  <section class="config-section-card" id=${P}>
574
612
  <div class="config-section-card__header">
575
- <span class="config-section-card__icon">${Pa(u)}</span>
613
+ <span class="config-section-card__icon">${Na(u)}</span>
576
614
  <div class="config-section-card__titles">
577
615
  <h3 class="config-section-card__title">${$}</h3>
578
- ${k?r`<p class="config-section-card__desc">${k}</p>`:g}
616
+ ${k?c`<p class="config-section-card__desc">${k}</p>`:h}
579
617
  </div>
580
618
  </div>
581
619
  <div class="config-section-card__content">
582
- ${ye({schema:v,value:M,path:[u,h],hints:e.uiHints,unsupported:s,disabled:e.disabled??!1,showLabel:!1,onPatch:e.onPatch})}
620
+ ${be({schema:v,value:I,path:[u,g],hints:e.uiHints,unsupported:s,disabled:e.disabled??!1,showLabel:!1,onPatch:e.onPatch})}
583
621
  </div>
584
622
  </section>
585
- `})():p.map(([u,h])=>{const v=ci[u]??{label:u.charAt(0).toUpperCase()+u.slice(1),description:h.description??""};return r`
623
+ `})():p.map(([u,g])=>{const v=ci[u]??{label:u.charAt(0).toUpperCase()+u.slice(1),description:g.description??""};return c`
586
624
  <section class="config-section-card" id="config-section-${u}">
587
625
  <div class="config-section-card__header">
588
- <span class="config-section-card__icon">${Pa(u)}</span>
626
+ <span class="config-section-card__icon">${Na(u)}</span>
589
627
  <div class="config-section-card__titles">
590
628
  <h3 class="config-section-card__title">${v.label}</h3>
591
- ${v.description?r`<p class="config-section-card__desc">${v.description}</p>`:g}
629
+ ${v.description?c`<p class="config-section-card__desc">${v.description}</p>`:h}
592
630
  </div>
593
631
  </div>
594
632
  <div class="config-section-card__content">
595
- ${ye({schema:h,value:n[u],path:[u],hints:e.uiHints,unsupported:s,disabled:e.disabled??!1,showLabel:!1,onPatch:e.onPatch})}
633
+ ${be({schema:g,value:n[u],path:[u],hints:e.uiHints,unsupported:s,disabled:e.disabled??!1,showLabel:!1,onPatch:e.onPatch})}
596
634
  </div>
597
635
  </section>
598
636
  `})}
599
637
  </div>
600
- `}const Np=new Set(["title","description","default","nullable"]);function Op(e){return Object.keys(e??{}).filter(n=>!Np.has(n)).length===0}function ur(e){const t=e.filter(i=>i!=null),n=t.length!==e.length,s=[];for(const i of t)s.some(a=>Object.is(a,i))||s.push(i);return{enumValues:s,nullable:n}}function pr(e){return!e||typeof e!="object"?{schema:null,unsupportedPaths:["<root>"]}:wt(e,[])}function wt(e,t){const n=new Set,s={...e},i=bn(t)||"<root>";if(e.anyOf||e.oneOf||e.allOf){const c=Dp(e,t);return c||{schema:e,unsupportedPaths:[i]}}const a=Array.isArray(e.type)&&e.type.includes("null"),o=ue(e)??(e.properties||e.additionalProperties?"object":void 0);if(s.type=o??e.type,s.nullable=a||e.nullable,s.enum){const{enumValues:c,nullable:l}=ur(s.enum);s.enum=c,l&&(s.nullable=!0),c.length===0&&n.add(i)}if(o==="object"){const c=e.properties??{},l={};for(const[p,d]of Object.entries(c)){const u=wt(d,[...t,p]);u.schema&&(l[p]=u.schema);for(const h of u.unsupportedPaths)n.add(h)}if(s.properties=l,e.additionalProperties===!0)n.add(i);else if(e.additionalProperties===!1)s.additionalProperties=!1;else if(e.additionalProperties&&typeof e.additionalProperties=="object"&&!Op(e.additionalProperties)){const p=wt(e.additionalProperties,[...t,"*"]);s.additionalProperties=p.schema??e.additionalProperties,p.unsupportedPaths.length>0&&n.add(i)}}else if(o==="array"){const c=Array.isArray(e.items)?e.items[0]:e.items;if(!c)n.add(i);else{const l=wt(c,[...t,"*"]);s.items=l.schema??c,l.unsupportedPaths.length>0&&n.add(i)}}else o!=="string"&&o!=="number"&&o!=="integer"&&o!=="boolean"&&!s.enum&&n.add(i);return{schema:s,unsupportedPaths:Array.from(n)}}function Dp(e,t){if(e.allOf)return null;const n=e.anyOf??e.oneOf;if(!n)return null;const s=[],i=[];let a=!1;for(const c of n){if(!c||typeof c!="object")return null;if(Array.isArray(c.enum)){const{enumValues:l,nullable:p}=ur(c.enum);s.push(...l),p&&(a=!0);continue}if("const"in c){if(c.const==null){a=!0;continue}s.push(c.const);continue}if(ue(c)==="null"){a=!0;continue}i.push(c)}if(s.length>0&&i.length===0){const c=[];for(const l of s)c.some(p=>Object.is(p,l))||c.push(l);return{schema:{...e,enum:c,nullable:a,anyOf:void 0,oneOf:void 0,allOf:void 0},unsupportedPaths:[]}}if(i.length===1){const c=wt(i[0],t);return c.schema&&(c.schema.nullable=a||c.schema.nullable),c}const o=["string","number","integer","boolean"];return i.length>0&&s.length===0&&i.every(c=>c.type&&o.includes(String(c.type)))?{schema:{...e,nullable:a},unsupportedPaths:[]}:null}const As={all:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="7" height="7"></rect><rect x="14" y="3" width="7" height="7"></rect><rect x="14" y="14" width="7" height="7"></rect><rect x="3" y="14" width="7" height="7"></rect></svg>`,env:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg>`,update:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>`,agents:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7h1a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-1v1a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-1H2a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h1a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-.99-1-1.73a2 2 0 0 1 2-2z"></path><circle cx="8" cy="14" r="1"></circle><circle cx="16" cy="14" r="1"></circle></svg>`,auth:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>`,channels:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg>`,messages:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg>`,commands:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="4 17 10 11 4 5"></polyline><line x1="12" y1="19" x2="20" y2="19"></line></svg>`,hooks:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>`,skills:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon></svg>`,tools:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"></path></svg>`,gateway:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg>`,wizard:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 4V2"></path><path d="M15 16v-2"></path><path d="M8 9h2"></path><path d="M20 9h2"></path><path d="M17.8 11.8 19 13"></path><path d="M15 9h0"></path><path d="M17.8 6.2 19 5"></path><path d="m3 21 9-9"></path><path d="M12.2 6.2 11 5"></path></svg>`,meta:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 20h9"></path><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"></path></svg>`,logging:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>`,browser:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><circle cx="12" cy="12" r="4"></circle><line x1="21.17" y1="8" x2="12" y2="8"></line><line x1="3.95" y1="6.06" x2="8.54" y2="14"></line><line x1="10.88" y1="21.94" x2="15.46" y2="14"></line></svg>`,ui:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="3" y1="9" x2="21" y2="9"></line><line x1="9" y1="21" x2="9" y2="9"></line></svg>`,models:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path><polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline><line x1="12" y1="22.08" x2="12" y2="12"></line></svg>`,bindings:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect><rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect><line x1="6" y1="6" x2="6.01" y2="6"></line><line x1="6" y1="18" x2="6.01" y2="18"></line></svg>`,broadcast:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4.9 19.1C1 15.2 1 8.8 4.9 4.9"></path><path d="M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5"></path><circle cx="12" cy="12" r="2"></circle><path d="M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5"></path><path d="M19.1 4.9C23 8.8 23 15.1 19.1 19"></path></svg>`,audio:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18V5l12-2v13"></path><circle cx="6" cy="18" r="3"></circle><circle cx="18" cy="16" r="3"></circle></svg>`,session:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>`,cron:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg>`,web:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg>`,discovery:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>`,canvasHost:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg>`,talk:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"></path><path d="M19 10v2a7 7 0 0 1-14 0v-2"></path><line x1="12" y1="19" x2="12" y2="23"></line><line x1="8" y1="23" x2="16" y2="23"></line></svg>`,plugins:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2v6"></path><path d="m4.93 10.93 4.24 4.24"></path><path d="M2 12h6"></path><path d="m4.93 13.07 4.24-4.24"></path><path d="M12 22v-6"></path><path d="m19.07 13.07-4.24-4.24"></path><path d="M22 12h-6"></path><path d="m19.07 10.93-4.24 4.24"></path></svg>`,default:r`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline></svg>`},Na=[{key:"env",label:"Environment"},{key:"update",label:"Updates"},{key:"agents",label:"Agents"},{key:"auth",label:"Authentication"},{key:"channels",label:"Channels"},{key:"messages",label:"Messages"},{key:"commands",label:"Commands"},{key:"hooks",label:"Hooks"},{key:"skills",label:"Skills"},{key:"tools",label:"Tools"},{key:"gateway",label:"Gateway"},{key:"wizard",label:"Setup Wizard"}],Oa="__all__";function Da(e){return As[e]??As.default}function Bp(e,t){const n=ci[e];return n||{label:t?.title??we(e),description:t?.description??""}}function Fp(e){const{key:t,schema:n,uiHints:s}=e;if(!n||ue(n)!=="object"||!n.properties)return[];const i=Object.entries(n.properties).map(([a,o])=>{const c=te([t,a],s),l=c?.label??o.title??we(a),p=c?.help??o.description??"",d=c?.order??50;return{key:a,label:l,description:p,order:d}});return i.sort((a,o)=>a.order!==o.order?a.order-o.order:a.key.localeCompare(o.key)),i}function Up(e,t){if(!e||!t)return[];const n=[];function s(i,a,o){if(i===a)return;if(typeof i!=typeof a){n.push({path:o,from:i,to:a});return}if(typeof i!="object"||i===null||a===null){i!==a&&n.push({path:o,from:i,to:a});return}if(Array.isArray(i)&&Array.isArray(a)){JSON.stringify(i)!==JSON.stringify(a)&&n.push({path:o,from:i,to:a});return}const c=i,l=a,p=new Set([...Object.keys(c),...Object.keys(l)]);for(const d of p)s(c[d],l[d],o?`${o}.${d}`:d)}return s(e,t,""),n}function Ba(e,t=40){let n;try{n=JSON.stringify(e)??String(e)}catch{n=String(e)}return n.length<=t?n:n.slice(0,t-3)+"..."}function Kp(e){const t=e.valid==null?"unknown":e.valid?"valid":"invalid",n=pr(e.schema),s=n.schema?n.unsupportedPaths.length>0:!1,i=n.schema?.properties??{},a=Na.filter(E=>E.key in i),o=new Set(Na.map(E=>E.key)),c=Object.keys(i).filter(E=>!o.has(E)).map(E=>({key:E,label:E.charAt(0).toUpperCase()+E.slice(1)})),l=[...a,...c],p=e.activeSection&&n.schema&&ue(n.schema)==="object"?n.schema.properties?.[e.activeSection]:void 0,d=e.activeSection?Bp(e.activeSection,p):null,u=e.activeSection?Fp({key:e.activeSection,schema:p,uiHints:e.uiHints}):[],h=e.formMode==="form"&&!!e.activeSection&&u.length>0,v=e.activeSubsection===Oa,w=e.searchQuery||v?null:e.activeSubsection??u[0]?.key??null,$=e.formMode==="form"?Up(e.originalValue,e.formValue):[],k=e.formMode==="raw"&&e.raw!==e.originalRaw,T=e.formMode==="form"?$.length>0:k,M=!!e.formValue&&!e.loading&&!!n.schema,P=e.connected&&!e.saving&&T&&(e.formMode==="raw"?!0:M),L=e.connected&&!e.applying&&!e.updating&&T&&(e.formMode==="raw"?!0:M),C=e.connected&&!e.applying&&!e.updating;return r`
638
+ `}const zp=new Set(["title","description","default","nullable"]);function jp(e){return Object.keys(e??{}).filter(n=>!zp.has(n)).length===0}function pr(e){const t=e.filter(i=>i!=null),n=t.length!==e.length,s=[];for(const i of t)s.some(a=>Object.is(a,i))||s.push(i);return{enumValues:s,nullable:n}}function fr(e){return!e||typeof e!="object"?{schema:null,unsupportedPaths:["<root>"]}:wt(e,[])}function wt(e,t){const n=new Set,s={...e},i=bn(t)||"<root>";if(e.anyOf||e.oneOf||e.allOf){const l=qp(e,t);return l||{schema:e,unsupportedPaths:[i]}}const a=Array.isArray(e.type)&&e.type.includes("null"),o=ue(e)??(e.properties||e.additionalProperties?"object":void 0);if(s.type=o??e.type,s.nullable=a||e.nullable,s.enum){const{enumValues:l,nullable:r}=pr(s.enum);s.enum=l,r&&(s.nullable=!0),l.length===0&&n.add(i)}if(o==="object"){const l=e.properties??{},r={};for(const[p,d]of Object.entries(l)){const u=wt(d,[...t,p]);u.schema&&(r[p]=u.schema);for(const g of u.unsupportedPaths)n.add(g)}if(s.properties=r,e.additionalProperties===!0)n.add(i);else if(e.additionalProperties===!1)s.additionalProperties=!1;else if(e.additionalProperties&&typeof e.additionalProperties=="object"&&!jp(e.additionalProperties)){const p=wt(e.additionalProperties,[...t,"*"]);s.additionalProperties=p.schema??e.additionalProperties,p.unsupportedPaths.length>0&&n.add(i)}}else if(o==="array"){const l=Array.isArray(e.items)?e.items[0]:e.items;if(!l)n.add(i);else{const r=wt(l,[...t,"*"]);s.items=r.schema??l,r.unsupportedPaths.length>0&&n.add(i)}}else o!=="string"&&o!=="number"&&o!=="integer"&&o!=="boolean"&&!s.enum&&n.add(i);return{schema:s,unsupportedPaths:Array.from(n)}}function qp(e,t){if(e.allOf)return null;const n=e.anyOf??e.oneOf;if(!n)return null;const s=[],i=[];let a=!1;for(const l of n){if(!l||typeof l!="object")return null;if(Array.isArray(l.enum)){const{enumValues:r,nullable:p}=pr(l.enum);s.push(...r),p&&(a=!0);continue}if("const"in l){if(l.const==null){a=!0;continue}s.push(l.const);continue}if(ue(l)==="null"){a=!0;continue}i.push(l)}if(s.length>0&&i.length===0){const l=[];for(const r of s)l.some(p=>Object.is(p,r))||l.push(r);return{schema:{...e,enum:l,nullable:a,anyOf:void 0,oneOf:void 0,allOf:void 0},unsupportedPaths:[]}}if(i.length===1){const l=wt(i[0],t);return l.schema&&(l.schema.nullable=a||l.schema.nullable),l}const o=["string","number","integer","boolean"];return i.length>0&&s.length===0&&i.every(l=>l.type&&o.includes(String(l.type)))?{schema:{...e,nullable:a},unsupportedPaths:[]}:null}const Ss={all:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="7" height="7"></rect><rect x="14" y="3" width="7" height="7"></rect><rect x="14" y="14" width="7" height="7"></rect><rect x="3" y="14" width="7" height="7"></rect></svg>`,env:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg>`,update:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>`,agents:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2a2 2 0 0 1 2 2c0 .74-.4 1.39-1 1.73V7h1a7 7 0 0 1 7 7h1a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-1v1a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-1H2a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h1a7 7 0 0 1 7-7h1V5.73c-.6-.34-1-.99-1-1.73a2 2 0 0 1 2-2z"></path><circle cx="8" cy="14" r="1"></circle><circle cx="16" cy="14" r="1"></circle></svg>`,auth:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>`,channels:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg>`,messages:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path><polyline points="22,6 12,13 2,6"></polyline></svg>`,commands:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="4 17 10 11 4 5"></polyline><line x1="12" y1="19" x2="20" y2="19"></line></svg>`,hooks:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>`,skills:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon></svg>`,tools:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"></path></svg>`,gateway:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg>`,wizard:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 4V2"></path><path d="M15 16v-2"></path><path d="M8 9h2"></path><path d="M20 9h2"></path><path d="M17.8 11.8 19 13"></path><path d="M15 9h0"></path><path d="M17.8 6.2 19 5"></path><path d="m3 21 9-9"></path><path d="M12.2 6.2 11 5"></path></svg>`,meta:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 20h9"></path><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"></path></svg>`,logging:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>`,browser:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><circle cx="12" cy="12" r="4"></circle><line x1="21.17" y1="8" x2="12" y2="8"></line><line x1="3.95" y1="6.06" x2="8.54" y2="14"></line><line x1="10.88" y1="21.94" x2="15.46" y2="14"></line></svg>`,ui:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="3" y1="9" x2="21" y2="9"></line><line x1="9" y1="21" x2="9" y2="9"></line></svg>`,models:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path><polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline><line x1="12" y1="22.08" x2="12" y2="12"></line></svg>`,bindings:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect><rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect><line x1="6" y1="6" x2="6.01" y2="6"></line><line x1="6" y1="18" x2="6.01" y2="18"></line></svg>`,broadcast:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4.9 19.1C1 15.2 1 8.8 4.9 4.9"></path><path d="M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5"></path><circle cx="12" cy="12" r="2"></circle><path d="M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5"></path><path d="M19.1 4.9C23 8.8 23 15.1 19.1 19"></path></svg>`,audio:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18V5l12-2v13"></path><circle cx="6" cy="18" r="3"></circle><circle cx="18" cy="16" r="3"></circle></svg>`,session:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></svg>`,cron:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg>`,web:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg>`,discovery:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>`,canvasHost:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg>`,talk:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"></path><path d="M19 10v2a7 7 0 0 1-14 0v-2"></path><line x1="12" y1="19" x2="12" y2="23"></line><line x1="8" y1="23" x2="16" y2="23"></line></svg>`,plugins:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2v6"></path><path d="m4.93 10.93 4.24 4.24"></path><path d="M2 12h6"></path><path d="m4.93 13.07 4.24-4.24"></path><path d="M12 22v-6"></path><path d="m19.07 13.07-4.24-4.24"></path><path d="M22 12h-6"></path><path d="m19.07 10.93-4.24 4.24"></path></svg>`,default:c`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline></svg>`},Oa=[{key:"env",label:"Environment"},{key:"update",label:"Updates"},{key:"agents",label:"Agents"},{key:"auth",label:"Authentication"},{key:"channels",label:"Channels"},{key:"messages",label:"Messages"},{key:"commands",label:"Commands"},{key:"hooks",label:"Hooks"},{key:"skills",label:"Skills"},{key:"tools",label:"Tools"},{key:"gateway",label:"Gateway"},{key:"wizard",label:"Setup Wizard"}],Da="__all__";function Ba(e){return Ss[e]??Ss.default}function Wp(e,t){const n=ci[e];return n||{label:t?.title??we(e),description:t?.description??""}}function Vp(e){const{key:t,schema:n,uiHints:s}=e;if(!n||ue(n)!=="object"||!n.properties)return[];const i=Object.entries(n.properties).map(([a,o])=>{const l=te([t,a],s),r=l?.label??o.title??we(a),p=l?.help??o.description??"",d=l?.order??50;return{key:a,label:r,description:p,order:d}});return i.sort((a,o)=>a.order!==o.order?a.order-o.order:a.key.localeCompare(o.key)),i}function Gp(e,t){if(!e||!t)return[];const n=[];function s(i,a,o){if(i===a)return;if(typeof i!=typeof a){n.push({path:o,from:i,to:a});return}if(typeof i!="object"||i===null||a===null){i!==a&&n.push({path:o,from:i,to:a});return}if(Array.isArray(i)&&Array.isArray(a)){JSON.stringify(i)!==JSON.stringify(a)&&n.push({path:o,from:i,to:a});return}const l=i,r=a,p=new Set([...Object.keys(l),...Object.keys(r)]);for(const d of p)s(l[d],r[d],o?`${o}.${d}`:d)}return s(e,t,""),n}function Fa(e,t=40){let n;try{n=JSON.stringify(e)??String(e)}catch{n=String(e)}return n.length<=t?n:n.slice(0,t-3)+"..."}function Yp(e){const t=e.valid==null?"unknown":e.valid?"valid":"invalid",n=fr(e.schema),s=n.schema?n.unsupportedPaths.length>0:!1,i=n.schema?.properties??{},a=Oa.filter(E=>E.key in i),o=new Set(Oa.map(E=>E.key)),l=Object.keys(i).filter(E=>!o.has(E)).map(E=>({key:E,label:E.charAt(0).toUpperCase()+E.slice(1)})),r=[...a,...l],p=e.activeSection&&n.schema&&ue(n.schema)==="object"?n.schema.properties?.[e.activeSection]:void 0,d=e.activeSection?Wp(e.activeSection,p):null,u=e.activeSection?Vp({key:e.activeSection,schema:p,uiHints:e.uiHints}):[],g=e.formMode==="form"&&!!e.activeSection&&u.length>0,v=e.activeSubsection===Da,w=e.searchQuery||v?null:e.activeSubsection??u[0]?.key??null,$=e.formMode==="form"?Gp(e.originalValue,e.formValue):[],k=e.formMode==="raw"&&e.raw!==e.originalRaw,_=e.formMode==="form"?$.length>0:k,I=!!e.formValue&&!e.loading&&!!n.schema,P=e.connected&&!e.saving&&_&&(e.formMode==="raw"?!0:I),L=e.connected&&!e.applying&&!e.updating&&_&&(e.formMode==="raw"?!0:I),C=e.connected&&!e.applying&&!e.updating;return c`
601
639
  <div class="config-layout">
602
640
  <!-- Sidebar -->
603
641
  <aside class="config-sidebar">
@@ -619,12 +657,12 @@ ${e.sidebarContent}
619
657
  .value=${e.searchQuery}
620
658
  @input=${E=>e.onSearchChange(E.target.value)}
621
659
  />
622
- ${e.searchQuery?r`
660
+ ${e.searchQuery?c`
623
661
  <button
624
662
  class="config-search__clear"
625
663
  @click=${()=>e.onSearchChange("")}
626
664
  >×</button>
627
- `:g}
665
+ `:h}
628
666
  </div>
629
667
 
630
668
  <!-- Section nav -->
@@ -633,15 +671,15 @@ ${e.sidebarContent}
633
671
  class="config-nav__item ${e.activeSection===null?"active":""}"
634
672
  @click=${()=>e.onSectionChange(null)}
635
673
  >
636
- <span class="config-nav__icon">${As.all}</span>
674
+ <span class="config-nav__icon">${Ss.all}</span>
637
675
  <span class="config-nav__label">All Settings</span>
638
676
  </button>
639
- ${l.map(E=>r`
677
+ ${r.map(E=>c`
640
678
  <button
641
679
  class="config-nav__item ${e.activeSection===E.key?"active":""}"
642
680
  @click=${()=>e.onSectionChange(E.key)}
643
681
  >
644
- <span class="config-nav__icon">${Da(E.key)}</span>
682
+ <span class="config-nav__icon">${Ba(E.key)}</span>
645
683
  <span class="config-nav__label">${E.label}</span>
646
684
  </button>
647
685
  `)}
@@ -672,9 +710,9 @@ ${e.sidebarContent}
672
710
  <!-- Action bar -->
673
711
  <div class="config-actions">
674
712
  <div class="config-actions__left">
675
- ${T?r`
713
+ ${_?c`
676
714
  <span class="config-changes-badge">${e.formMode==="raw"?"Unsaved changes":`${$.length} unsaved change${$.length!==1?"s":""}`}</span>
677
- `:r`
715
+ `:c`
678
716
  <span class="config-status muted">No changes</span>
679
717
  `}
680
718
  </div>
@@ -707,7 +745,7 @@ ${e.sidebarContent}
707
745
  </div>
708
746
 
709
747
  <!-- Diff panel (form mode only - raw mode doesn't have granular diff) -->
710
- ${T&&e.formMode==="form"?r`
748
+ ${_&&e.formMode==="form"?c`
711
749
  <details class="config-diff">
712
750
  <summary class="config-diff__summary">
713
751
  <span>View ${$.length} pending change${$.length!==1?"s":""}</span>
@@ -716,39 +754,39 @@ ${e.sidebarContent}
716
754
  </svg>
717
755
  </summary>
718
756
  <div class="config-diff__content">
719
- ${$.map(E=>r`
757
+ ${$.map(E=>c`
720
758
  <div class="config-diff__item">
721
759
  <div class="config-diff__path">${E.path}</div>
722
760
  <div class="config-diff__values">
723
- <span class="config-diff__from">${Ba(E.from)}</span>
761
+ <span class="config-diff__from">${Fa(E.from)}</span>
724
762
  <span class="config-diff__arrow">→</span>
725
- <span class="config-diff__to">${Ba(E.to)}</span>
763
+ <span class="config-diff__to">${Fa(E.to)}</span>
726
764
  </div>
727
765
  </div>
728
766
  `)}
729
767
  </div>
730
768
  </details>
731
- `:g}
769
+ `:h}
732
770
 
733
- ${d&&e.formMode==="form"?r`
771
+ ${d&&e.formMode==="form"?c`
734
772
  <div class="config-section-hero">
735
- <div class="config-section-hero__icon">${Da(e.activeSection??"")}</div>
773
+ <div class="config-section-hero__icon">${Ba(e.activeSection??"")}</div>
736
774
  <div class="config-section-hero__text">
737
775
  <div class="config-section-hero__title">${d.label}</div>
738
- ${d.description?r`<div class="config-section-hero__desc">${d.description}</div>`:g}
776
+ ${d.description?c`<div class="config-section-hero__desc">${d.description}</div>`:h}
739
777
  </div>
740
778
  </div>
741
- `:g}
779
+ `:h}
742
780
 
743
- ${h?r`
781
+ ${g?c`
744
782
  <div class="config-subnav">
745
783
  <button
746
784
  class="config-subnav__item ${w===null?"active":""}"
747
- @click=${()=>e.onSubsectionChange(Oa)}
785
+ @click=${()=>e.onSubsectionChange(Da)}
748
786
  >
749
787
  All
750
788
  </button>
751
- ${u.map(E=>r`
789
+ ${u.map(E=>c`
752
790
  <button
753
791
  class="config-subnav__item ${w===E.key?"active":""}"
754
792
  title=${E.description||E.label}
@@ -758,20 +796,20 @@ ${e.sidebarContent}
758
796
  </button>
759
797
  `)}
760
798
  </div>
761
- `:g}
799
+ `:h}
762
800
 
763
801
  <!-- Form content -->
764
802
  <div class="config-content">
765
- ${e.formMode==="form"?r`
766
- ${e.schemaLoading?r`<div class="config-loading">
803
+ ${e.formMode==="form"?c`
804
+ ${e.schemaLoading?c`<div class="config-loading">
767
805
  <div class="config-loading__spinner"></div>
768
806
  <span>Loading schema…</span>
769
- </div>`:Pp({schema:n.schema,uiHints:e.uiHints,value:e.formValue,disabled:e.loading||!e.formValue,unsupportedPaths:n.unsupportedPaths,onPatch:e.onFormPatch,searchQuery:e.searchQuery,activeSection:e.activeSection,activeSubsection:w})}
770
- ${s?r`<div class="callout danger" style="margin-top: 12px;">
807
+ </div>`:Hp({schema:n.schema,uiHints:e.uiHints,value:e.formValue,disabled:e.loading||!e.formValue,unsupportedPaths:n.unsupportedPaths,onPatch:e.onFormPatch,searchQuery:e.searchQuery,activeSection:e.activeSection,activeSubsection:w})}
808
+ ${s?c`<div class="callout danger" style="margin-top: 12px;">
771
809
  Form view can't safely edit some fields.
772
810
  Use Raw to avoid losing config entries.
773
- </div>`:g}
774
- `:r`
811
+ </div>`:h}
812
+ `:c`
775
813
  <label class="field config-raw-field">
776
814
  <span>Raw JSON5</span>
777
815
  <textarea
@@ -782,18 +820,18 @@ ${e.sidebarContent}
782
820
  `}
783
821
  </div>
784
822
 
785
- ${e.issues.length>0?r`<div class="callout danger" style="margin-top: 12px;">
823
+ ${e.issues.length>0?c`<div class="callout danger" style="margin-top: 12px;">
786
824
  <pre class="code-block">${JSON.stringify(e.issues,null,2)}</pre>
787
- </div>`:g}
825
+ </div>`:h}
788
826
  </main>
789
827
  </div>
790
- `}function Hp(e){if(!e&&e!==0)return"n/a";const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.round(t/60);return n<60?`${n}m`:`${Math.round(n/60)}h`}function zp(e,t){const n=t.snapshot,s=n?.channels;if(!n||!s)return!1;const i=s[e],a=typeof i?.configured=="boolean"&&i.configured,o=typeof i?.running=="boolean"&&i.running,c=typeof i?.connected=="boolean"&&i.connected,p=(n.channelAccounts?.[e]??[]).some(d=>d.configured||d.running||d.connected);return a||o||c||p}function jp(e,t){return t?.[e]?.length??0}function fr(e,t){const n=jp(e,t);return n<2?g:r`<div class="account-count">Accounts (${n})</div>`}function qp(e,t){let n=e;for(const s of t){if(!n)return null;const i=ue(n);if(i==="object"){const a=n.properties??{};if(typeof s=="string"&&a[s]){n=a[s];continue}const o=n.additionalProperties;if(typeof s=="string"&&o&&typeof o=="object"){n=o;continue}return null}if(i==="array"){if(typeof s!="number")return null;n=(Array.isArray(n.items)?n.items[0]:n.items)??null;continue}return null}return n}function Vp(e,t){const s=(e.channels??{})[t],i=e[t];return(s&&typeof s=="object"?s:null)??(i&&typeof i=="object"?i:null)??{}}function Wp(e){const t=pr(e.schema),n=t.schema;if(!n)return r`<div class="callout danger">Schema unavailable. Use Raw.</div>`;const s=qp(n,["channels",e.channelId]);if(!s)return r`<div class="callout danger">Channel config schema unavailable.</div>`;const i=e.configValue??{},a=Vp(i,e.channelId);return r`
828
+ `}function Qp(e){if(!e&&e!==0)return"n/a";const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.round(t/60);return n<60?`${n}m`:`${Math.round(n/60)}h`}function Zp(e,t){const n=t.snapshot,s=n?.channels;if(!n||!s)return!1;const i=s[e],a=typeof i?.configured=="boolean"&&i.configured,o=typeof i?.running=="boolean"&&i.running,l=typeof i?.connected=="boolean"&&i.connected,p=(n.channelAccounts?.[e]??[]).some(d=>d.configured||d.running||d.connected);return a||o||l||p}function Jp(e,t){return t?.[e]?.length??0}function hr(e,t){const n=Jp(e,t);return n<2?h:c`<div class="account-count">Accounts (${n})</div>`}function Xp(e,t){let n=e;for(const s of t){if(!n)return null;const i=ue(n);if(i==="object"){const a=n.properties??{};if(typeof s=="string"&&a[s]){n=a[s];continue}const o=n.additionalProperties;if(typeof s=="string"&&o&&typeof o=="object"){n=o;continue}return null}if(i==="array"){if(typeof s!="number")return null;n=(Array.isArray(n.items)?n.items[0]:n.items)??null;continue}return null}return n}function ef(e,t){const s=(e.channels??{})[t],i=e[t];return(s&&typeof s=="object"?s:null)??(i&&typeof i=="object"?i:null)??{}}function tf(e){const t=fr(e.schema),n=t.schema;if(!n)return c`<div class="callout danger">Schema unavailable. Use Raw.</div>`;const s=Xp(n,["channels",e.channelId]);if(!s)return c`<div class="callout danger">Channel config schema unavailable.</div>`;const i=e.configValue??{},a=ef(i,e.channelId);return c`
791
829
  <div class="config-form">
792
- ${ye({schema:s,value:a,path:["channels",e.channelId],hints:e.uiHints,unsupported:new Set(t.unsupportedPaths),disabled:e.disabled,showLabel:!1,onPatch:e.onPatch})}
830
+ ${be({schema:s,value:a,path:["channels",e.channelId],hints:e.uiHints,unsupported:new Set(t.unsupportedPaths),disabled:e.disabled,showLabel:!1,onPatch:e.onPatch})}
793
831
  </div>
794
- `}function $e(e){const{channelId:t,props:n}=e,s=n.configSaving||n.configSchemaLoading;return r`
832
+ `}function $e(e){const{channelId:t,props:n}=e,s=n.configSaving||n.configSchemaLoading;return c`
795
833
  <div style="margin-top: 16px;">
796
- ${n.configSchemaLoading?r`<div class="muted">Loading config schema…</div>`:Wp({channelId:t,configValue:n.configForm,schema:n.configSchema,uiHints:n.configUiHints,disabled:s,onPatch:n.onConfigPatch})}
834
+ ${n.configSchemaLoading?c`<div class="muted">Loading config schema…</div>`:tf({channelId:t,configValue:n.configForm,schema:n.configSchema,uiHints:n.configUiHints,disabled:s,onPatch:n.onConfigPatch})}
797
835
  <div class="row" style="margin-top: 12px;">
798
836
  <button
799
837
  class="btn primary"
@@ -811,7 +849,7 @@ ${e.sidebarContent}
811
849
  </button>
812
850
  </div>
813
851
  </div>
814
- `}function Gp(e){const{props:t,discord:n,accountCountLabel:s}=e;return r`
852
+ `}function nf(e){const{props:t,discord:n,accountCountLabel:s}=e;return c`
815
853
  <div class="card">
816
854
  <div class="card-title">Discord</div>
817
855
  <div class="card-sub">Bot status and channel configuration.</div>
@@ -836,14 +874,14 @@ ${e.sidebarContent}
836
874
  </div>
837
875
  </div>
838
876
 
839
- ${n?.lastError?r`<div class="callout danger" style="margin-top: 12px;">
877
+ ${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
840
878
  ${n.lastError}
841
- </div>`:g}
879
+ </div>`:h}
842
880
 
843
- ${n?.probe?r`<div class="callout" style="margin-top: 12px;">
881
+ ${n?.probe?c`<div class="callout" style="margin-top: 12px;">
844
882
  Probe ${n.probe.ok?"ok":"failed"} ·
845
883
  ${n.probe.status??""} ${n.probe.error??""}
846
- </div>`:g}
884
+ </div>`:h}
847
885
 
848
886
  ${$e({channelId:"discord",props:t})}
849
887
 
@@ -853,7 +891,7 @@ ${e.sidebarContent}
853
891
  </button>
854
892
  </div>
855
893
  </div>
856
- `}function Yp(e){const{props:t,googleChat:n,accountCountLabel:s}=e;return r`
894
+ `}function sf(e){const{props:t,googleChat:n,accountCountLabel:s}=e;return c`
857
895
  <div class="card">
858
896
  <div class="card-title">Google Chat</div>
859
897
  <div class="card-sub">Chat API webhook status and channel configuration.</div>
@@ -888,14 +926,14 @@ ${e.sidebarContent}
888
926
  </div>
889
927
  </div>
890
928
 
891
- ${n?.lastError?r`<div class="callout danger" style="margin-top: 12px;">
929
+ ${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
892
930
  ${n.lastError}
893
- </div>`:g}
931
+ </div>`:h}
894
932
 
895
- ${n?.probe?r`<div class="callout" style="margin-top: 12px;">
933
+ ${n?.probe?c`<div class="callout" style="margin-top: 12px;">
896
934
  Probe ${n.probe.ok?"ok":"failed"} ·
897
935
  ${n.probe.status??""} ${n.probe.error??""}
898
- </div>`:g}
936
+ </div>`:h}
899
937
 
900
938
  ${$e({channelId:"googlechat",props:t})}
901
939
 
@@ -905,7 +943,7 @@ ${e.sidebarContent}
905
943
  </button>
906
944
  </div>
907
945
  </div>
908
- `}function Qp(e){const{props:t,imessage:n,accountCountLabel:s}=e;return r`
946
+ `}function af(e){const{props:t,imessage:n,accountCountLabel:s}=e;return c`
909
947
  <div class="card">
910
948
  <div class="card-title">iMessage</div>
911
949
  <div class="card-sub">macOS bridge status and channel configuration.</div>
@@ -930,14 +968,14 @@ ${e.sidebarContent}
930
968
  </div>
931
969
  </div>
932
970
 
933
- ${n?.lastError?r`<div class="callout danger" style="margin-top: 12px;">
971
+ ${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
934
972
  ${n.lastError}
935
- </div>`:g}
973
+ </div>`:h}
936
974
 
937
- ${n?.probe?r`<div class="callout" style="margin-top: 12px;">
975
+ ${n?.probe?c`<div class="callout" style="margin-top: 12px;">
938
976
  Probe ${n.probe.ok?"ok":"failed"} ·
939
977
  ${n.probe.error??""}
940
- </div>`:g}
978
+ </div>`:h}
941
979
 
942
980
  ${$e({channelId:"imessage",props:t})}
943
981
 
@@ -947,62 +985,62 @@ ${e.sidebarContent}
947
985
  </button>
948
986
  </div>
949
987
  </div>
950
- `}function Zp(e){const{values:t,original:n}=e;return t.name!==n.name||t.displayName!==n.displayName||t.about!==n.about||t.picture!==n.picture||t.banner!==n.banner||t.website!==n.website||t.nip05!==n.nip05||t.lud16!==n.lud16}function Jp(e){const{state:t,callbacks:n,accountId:s}=e,i=Zp(t),a=(c,l,p={})=>{const{type:d="text",placeholder:u,maxLength:h,help:v}=p,w=t.values[c]??"",$=t.fieldErrors[c],k=`nostr-profile-${c}`;return d==="textarea"?r`
988
+ `}function of(e){const{values:t,original:n}=e;return t.name!==n.name||t.displayName!==n.displayName||t.about!==n.about||t.picture!==n.picture||t.banner!==n.banner||t.website!==n.website||t.nip05!==n.nip05||t.lud16!==n.lud16}function rf(e){const{state:t,callbacks:n,accountId:s}=e,i=of(t),a=(l,r,p={})=>{const{type:d="text",placeholder:u,maxLength:g,help:v}=p,w=t.values[l]??"",$=t.fieldErrors[l],k=`nostr-profile-${l}`;return d==="textarea"?c`
951
989
  <div class="form-field" style="margin-bottom: 12px;">
952
990
  <label for="${k}" style="display: block; margin-bottom: 4px; font-weight: 500;">
953
- ${l}
991
+ ${r}
954
992
  </label>
955
993
  <textarea
956
994
  id="${k}"
957
995
  .value=${w}
958
996
  placeholder=${u??""}
959
- maxlength=${h??2e3}
997
+ maxlength=${g??2e3}
960
998
  rows="3"
961
999
  style="width: 100%; padding: 8px; border: 1px solid var(--border-color); border-radius: 4px; resize: vertical; font-family: inherit;"
962
- @input=${T=>{const M=T.target;n.onFieldChange(c,M.value)}}
1000
+ @input=${_=>{const I=_.target;n.onFieldChange(l,I.value)}}
963
1001
  ?disabled=${t.saving}
964
1002
  ></textarea>
965
- ${v?r`<div style="font-size: 12px; color: var(--text-muted); margin-top: 2px;">${v}</div>`:g}
966
- ${$?r`<div style="font-size: 12px; color: var(--danger-color); margin-top: 2px;">${$}</div>`:g}
1003
+ ${v?c`<div style="font-size: 12px; color: var(--text-muted); margin-top: 2px;">${v}</div>`:h}
1004
+ ${$?c`<div style="font-size: 12px; color: var(--danger-color); margin-top: 2px;">${$}</div>`:h}
967
1005
  </div>
968
- `:r`
1006
+ `:c`
969
1007
  <div class="form-field" style="margin-bottom: 12px;">
970
1008
  <label for="${k}" style="display: block; margin-bottom: 4px; font-weight: 500;">
971
- ${l}
1009
+ ${r}
972
1010
  </label>
973
1011
  <input
974
1012
  id="${k}"
975
1013
  type=${d}
976
1014
  .value=${w}
977
1015
  placeholder=${u??""}
978
- maxlength=${h??256}
1016
+ maxlength=${g??256}
979
1017
  style="width: 100%; padding: 8px; border: 1px solid var(--border-color); border-radius: 4px;"
980
- @input=${T=>{const M=T.target;n.onFieldChange(c,M.value)}}
1018
+ @input=${_=>{const I=_.target;n.onFieldChange(l,I.value)}}
981
1019
  ?disabled=${t.saving}
982
1020
  />
983
- ${v?r`<div style="font-size: 12px; color: var(--text-muted); margin-top: 2px;">${v}</div>`:g}
984
- ${$?r`<div style="font-size: 12px; color: var(--danger-color); margin-top: 2px;">${$}</div>`:g}
1021
+ ${v?c`<div style="font-size: 12px; color: var(--text-muted); margin-top: 2px;">${v}</div>`:h}
1022
+ ${$?c`<div style="font-size: 12px; color: var(--danger-color); margin-top: 2px;">${$}</div>`:h}
985
1023
  </div>
986
- `},o=()=>{const c=t.values.picture;return c?r`
1024
+ `},o=()=>{const l=t.values.picture;return l?c`
987
1025
  <div style="margin-bottom: 12px;">
988
1026
  <img
989
- src=${c}
1027
+ src=${l}
990
1028
  alt="Profile picture preview"
991
1029
  style="max-width: 80px; max-height: 80px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border-color);"
992
- @error=${l=>{const p=l.target;p.style.display="none"}}
993
- @load=${l=>{const p=l.target;p.style.display="block"}}
1030
+ @error=${r=>{const p=r.target;p.style.display="none"}}
1031
+ @load=${r=>{const p=r.target;p.style.display="block"}}
994
1032
  />
995
1033
  </div>
996
- `:g};return r`
1034
+ `:h};return c`
997
1035
  <div class="nostr-profile-form" style="padding: 16px; background: var(--bg-secondary); border-radius: 8px; margin-top: 12px;">
998
1036
  <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px;">
999
1037
  <div style="font-weight: 600; font-size: 16px;">Edit Profile</div>
1000
1038
  <div style="font-size: 12px; color: var(--text-muted);">Account: ${s}</div>
1001
1039
  </div>
1002
1040
 
1003
- ${t.error?r`<div class="callout danger" style="margin-bottom: 12px;">${t.error}</div>`:g}
1041
+ ${t.error?c`<div class="callout danger" style="margin-bottom: 12px;">${t.error}</div>`:h}
1004
1042
 
1005
- ${t.success?r`<div class="callout success" style="margin-bottom: 12px;">${t.success}</div>`:g}
1043
+ ${t.success?c`<div class="callout success" style="margin-bottom: 12px;">${t.success}</div>`:h}
1006
1044
 
1007
1045
  ${o()}
1008
1046
 
@@ -1014,7 +1052,7 @@ ${e.sidebarContent}
1014
1052
 
1015
1053
  ${a("picture","Avatar URL",{type:"url",placeholder:"https://example.com/avatar.jpg",help:"HTTPS URL to your profile picture"})}
1016
1054
 
1017
- ${t.showAdvanced?r`
1055
+ ${t.showAdvanced?c`
1018
1056
  <div style="border-top: 1px solid var(--border-color); padding-top: 12px; margin-top: 12px;">
1019
1057
  <div style="font-weight: 500; margin-bottom: 12px; color: var(--text-muted);">Advanced</div>
1020
1058
 
@@ -1026,7 +1064,7 @@ ${e.sidebarContent}
1026
1064
 
1027
1065
  ${a("lud16","Lightning Address",{placeholder:"you@getalby.com",help:"Lightning address for tips (LUD-16)"})}
1028
1066
  </div>
1029
- `:g}
1067
+ `:h}
1030
1068
 
1031
1069
  <div style="display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap;">
1032
1070
  <button
@@ -1061,86 +1099,86 @@ ${e.sidebarContent}
1061
1099
  </button>
1062
1100
  </div>
1063
1101
 
1064
- ${i?r`<div style="font-size: 12px; color: var(--warning-color); margin-top: 8px;">
1102
+ ${i?c`<div style="font-size: 12px; color: var(--warning-color); margin-top: 8px;">
1065
1103
  You have unsaved changes
1066
- </div>`:g}
1104
+ </div>`:h}
1067
1105
  </div>
1068
- `}function Xp(e){const t={name:e?.name??"",displayName:e?.displayName??"",about:e?.about??"",picture:e?.picture??"",banner:e?.banner??"",website:e?.website??"",nip05:e?.nip05??"",lud16:e?.lud16??""};return{values:t,original:{...t},saving:!1,importing:!1,error:null,success:null,fieldErrors:{},showAdvanced:!!(e?.banner||e?.website||e?.nip05||e?.lud16)}}function Fa(e){return e?e.length<=20?e:`${e.slice(0,8)}...${e.slice(-8)}`:"n/a"}function ef(e){const{props:t,nostr:n,nostrAccounts:s,accountCountLabel:i,profileFormState:a,profileFormCallbacks:o,onEditProfile:c}=e,l=s[0],p=n?.configured??l?.configured??!1,d=n?.running??l?.running??!1,u=n?.publicKey??l?.publicKey,h=n?.lastStartAt??l?.lastStartAt??null,v=n?.lastError??l?.lastError??null,w=s.length>1,$=a!=null,k=M=>{const P=M.publicKey,L=M.profile,C=L?.displayName??L?.name??M.name??M.accountId;return r`
1106
+ `}function lf(e){const t={name:e?.name??"",displayName:e?.displayName??"",about:e?.about??"",picture:e?.picture??"",banner:e?.banner??"",website:e?.website??"",nip05:e?.nip05??"",lud16:e?.lud16??""};return{values:t,original:{...t},saving:!1,importing:!1,error:null,success:null,fieldErrors:{},showAdvanced:!!(e?.banner||e?.website||e?.nip05||e?.lud16)}}function Ua(e){return e?e.length<=20?e:`${e.slice(0,8)}...${e.slice(-8)}`:"n/a"}function cf(e){const{props:t,nostr:n,nostrAccounts:s,accountCountLabel:i,profileFormState:a,profileFormCallbacks:o,onEditProfile:l}=e,r=s[0],p=n?.configured??r?.configured??!1,d=n?.running??r?.running??!1,u=n?.publicKey??r?.publicKey,g=n?.lastStartAt??r?.lastStartAt??null,v=n?.lastError??r?.lastError??null,w=s.length>1,$=a!=null,k=I=>{const P=I.publicKey,L=I.profile,C=L?.displayName??L?.name??I.name??I.accountId;return c`
1069
1107
  <div class="account-card">
1070
1108
  <div class="account-card-header">
1071
1109
  <div class="account-card-title">${C}</div>
1072
- <div class="account-card-id">${M.accountId}</div>
1110
+ <div class="account-card-id">${I.accountId}</div>
1073
1111
  </div>
1074
1112
  <div class="status-list account-card-status">
1075
1113
  <div>
1076
1114
  <span class="label">Running</span>
1077
- <span>${M.running?"Yes":"No"}</span>
1115
+ <span>${I.running?"Yes":"No"}</span>
1078
1116
  </div>
1079
1117
  <div>
1080
1118
  <span class="label">Configured</span>
1081
- <span>${M.configured?"Yes":"No"}</span>
1119
+ <span>${I.configured?"Yes":"No"}</span>
1082
1120
  </div>
1083
1121
  <div>
1084
1122
  <span class="label">Public Key</span>
1085
- <span class="monospace" title="${P??""}">${Fa(P)}</span>
1123
+ <span class="monospace" title="${P??""}">${Ua(P)}</span>
1086
1124
  </div>
1087
1125
  <div>
1088
1126
  <span class="label">Last inbound</span>
1089
- <span>${M.lastInboundAt?O(M.lastInboundAt):"n/a"}</span>
1127
+ <span>${I.lastInboundAt?O(I.lastInboundAt):"n/a"}</span>
1090
1128
  </div>
1091
- ${M.lastError?r`
1092
- <div class="account-card-error">${M.lastError}</div>
1093
- `:g}
1129
+ ${I.lastError?c`
1130
+ <div class="account-card-error">${I.lastError}</div>
1131
+ `:h}
1094
1132
  </div>
1095
1133
  </div>
1096
- `},T=()=>{if($&&o)return Jp({state:a,callbacks:o,accountId:s[0]?.accountId??"default"});const M=l?.profile??n?.profile,{name:P,displayName:L,about:C,picture:E,nip05:pe}=M??{},yn=P||L||C||E||pe;return r`
1134
+ `},_=()=>{if($&&o)return rf({state:a,callbacks:o,accountId:s[0]?.accountId??"default"});const I=r?.profile??n?.profile,{name:P,displayName:L,about:C,picture:E,nip05:pe}=I??{},wn=P||L||C||E||pe;return c`
1097
1135
  <div style="margin-top: 16px; padding: 12px; background: var(--bg-secondary); border-radius: 8px;">
1098
1136
  <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;">
1099
1137
  <div style="font-weight: 500;">Profile</div>
1100
- ${p?r`
1138
+ ${p?c`
1101
1139
  <button
1102
1140
  class="btn btn-sm"
1103
- @click=${c}
1141
+ @click=${l}
1104
1142
  style="font-size: 12px; padding: 4px 8px;"
1105
1143
  >
1106
1144
  Edit Profile
1107
1145
  </button>
1108
- `:g}
1146
+ `:h}
1109
1147
  </div>
1110
- ${yn?r`
1148
+ ${wn?c`
1111
1149
  <div class="status-list">
1112
- ${E?r`
1150
+ ${E?c`
1113
1151
  <div style="margin-bottom: 8px;">
1114
1152
  <img
1115
1153
  src=${E}
1116
1154
  alt="Profile picture"
1117
1155
  style="width: 48px; height: 48px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border-color);"
1118
- @error=${wn=>{wn.target.style.display="none"}}
1156
+ @error=${$n=>{$n.target.style.display="none"}}
1119
1157
  />
1120
1158
  </div>
1121
- `:g}
1122
- ${P?r`<div><span class="label">Name</span><span>${P}</span></div>`:g}
1123
- ${L?r`<div><span class="label">Display Name</span><span>${L}</span></div>`:g}
1124
- ${C?r`<div><span class="label">About</span><span style="max-width: 300px; overflow: hidden; text-overflow: ellipsis;">${C}</span></div>`:g}
1125
- ${pe?r`<div><span class="label">NIP-05</span><span>${pe}</span></div>`:g}
1159
+ `:h}
1160
+ ${P?c`<div><span class="label">Name</span><span>${P}</span></div>`:h}
1161
+ ${L?c`<div><span class="label">Display Name</span><span>${L}</span></div>`:h}
1162
+ ${C?c`<div><span class="label">About</span><span style="max-width: 300px; overflow: hidden; text-overflow: ellipsis;">${C}</span></div>`:h}
1163
+ ${pe?c`<div><span class="label">NIP-05</span><span>${pe}</span></div>`:h}
1126
1164
  </div>
1127
- `:r`
1165
+ `:c`
1128
1166
  <div style="color: var(--text-muted); font-size: 13px;">
1129
1167
  No profile set. Click "Edit Profile" to add your name, bio, and avatar.
1130
1168
  </div>
1131
1169
  `}
1132
1170
  </div>
1133
- `};return r`
1171
+ `};return c`
1134
1172
  <div class="card">
1135
1173
  <div class="card-title">Nostr</div>
1136
1174
  <div class="card-sub">Decentralized DMs via Nostr relays (NIP-04).</div>
1137
1175
  ${i}
1138
1176
 
1139
- ${w?r`
1177
+ ${w?c`
1140
1178
  <div class="account-card-list">
1141
- ${s.map(M=>k(M))}
1179
+ ${s.map(I=>k(I))}
1142
1180
  </div>
1143
- `:r`
1181
+ `:c`
1144
1182
  <div class="status-list" style="margin-top: 16px;">
1145
1183
  <div>
1146
1184
  <span class="label">Configured</span>
@@ -1153,19 +1191,19 @@ ${e.sidebarContent}
1153
1191
  <div>
1154
1192
  <span class="label">Public Key</span>
1155
1193
  <span class="monospace" title="${u??""}"
1156
- >${Fa(u)}</span
1194
+ >${Ua(u)}</span
1157
1195
  >
1158
1196
  </div>
1159
1197
  <div>
1160
1198
  <span class="label">Last start</span>
1161
- <span>${h?O(h):"n/a"}</span>
1199
+ <span>${g?O(g):"n/a"}</span>
1162
1200
  </div>
1163
1201
  </div>
1164
1202
  `}
1165
1203
 
1166
- ${v?r`<div class="callout danger" style="margin-top: 12px;">${v}</div>`:g}
1204
+ ${v?c`<div class="callout danger" style="margin-top: 12px;">${v}</div>`:h}
1167
1205
 
1168
- ${T()}
1206
+ ${_()}
1169
1207
 
1170
1208
  ${$e({channelId:"nostr",props:t})}
1171
1209
 
@@ -1173,7 +1211,7 @@ ${e.sidebarContent}
1173
1211
  <button class="btn" @click=${()=>t.onRefresh(!1)}>Refresh</button>
1174
1212
  </div>
1175
1213
  </div>
1176
- `}function tf(e){const{props:t,signal:n,accountCountLabel:s}=e;return r`
1214
+ `}function df(e){const{props:t,signal:n,accountCountLabel:s}=e;return c`
1177
1215
  <div class="card">
1178
1216
  <div class="card-title">Signal</div>
1179
1217
  <div class="card-sub">signal-cli status and channel configuration.</div>
@@ -1202,14 +1240,14 @@ ${e.sidebarContent}
1202
1240
  </div>
1203
1241
  </div>
1204
1242
 
1205
- ${n?.lastError?r`<div class="callout danger" style="margin-top: 12px;">
1243
+ ${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
1206
1244
  ${n.lastError}
1207
- </div>`:g}
1245
+ </div>`:h}
1208
1246
 
1209
- ${n?.probe?r`<div class="callout" style="margin-top: 12px;">
1247
+ ${n?.probe?c`<div class="callout" style="margin-top: 12px;">
1210
1248
  Probe ${n.probe.ok?"ok":"failed"} ·
1211
1249
  ${n.probe.status??""} ${n.probe.error??""}
1212
- </div>`:g}
1250
+ </div>`:h}
1213
1251
 
1214
1252
  ${$e({channelId:"signal",props:t})}
1215
1253
 
@@ -1219,7 +1257,7 @@ ${e.sidebarContent}
1219
1257
  </button>
1220
1258
  </div>
1221
1259
  </div>
1222
- `}function nf(e){const{props:t,slack:n,accountCountLabel:s}=e;return r`
1260
+ `}function uf(e){const{props:t,slack:n,accountCountLabel:s}=e;return c`
1223
1261
  <div class="card">
1224
1262
  <div class="card-title">Slack</div>
1225
1263
  <div class="card-sub">Socket mode status and channel configuration.</div>
@@ -1244,14 +1282,14 @@ ${e.sidebarContent}
1244
1282
  </div>
1245
1283
  </div>
1246
1284
 
1247
- ${n?.lastError?r`<div class="callout danger" style="margin-top: 12px;">
1285
+ ${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
1248
1286
  ${n.lastError}
1249
- </div>`:g}
1287
+ </div>`:h}
1250
1288
 
1251
- ${n?.probe?r`<div class="callout" style="margin-top: 12px;">
1289
+ ${n?.probe?c`<div class="callout" style="margin-top: 12px;">
1252
1290
  Probe ${n.probe.ok?"ok":"failed"} ·
1253
1291
  ${n.probe.status??""} ${n.probe.error??""}
1254
- </div>`:g}
1292
+ </div>`:h}
1255
1293
 
1256
1294
  ${$e({channelId:"slack",props:t})}
1257
1295
 
@@ -1261,45 +1299,45 @@ ${e.sidebarContent}
1261
1299
  </button>
1262
1300
  </div>
1263
1301
  </div>
1264
- `}function sf(e){const{props:t,telegram:n,telegramAccounts:s,accountCountLabel:i}=e,a=s.length>1,o=c=>{const p=c.probe?.bot?.username,d=c.name||c.accountId;return r`
1302
+ `}function pf(e){const{props:t,telegram:n,telegramAccounts:s,accountCountLabel:i}=e,a=s.length>1,o=l=>{const p=l.probe?.bot?.username,d=l.name||l.accountId;return c`
1265
1303
  <div class="account-card">
1266
1304
  <div class="account-card-header">
1267
1305
  <div class="account-card-title">
1268
1306
  ${p?`@${p}`:d}
1269
1307
  </div>
1270
- <div class="account-card-id">${c.accountId}</div>
1308
+ <div class="account-card-id">${l.accountId}</div>
1271
1309
  </div>
1272
1310
  <div class="status-list account-card-status">
1273
1311
  <div>
1274
1312
  <span class="label">Running</span>
1275
- <span>${c.running?"Yes":"No"}</span>
1313
+ <span>${l.running?"Yes":"No"}</span>
1276
1314
  </div>
1277
1315
  <div>
1278
1316
  <span class="label">Configured</span>
1279
- <span>${c.configured?"Yes":"No"}</span>
1317
+ <span>${l.configured?"Yes":"No"}</span>
1280
1318
  </div>
1281
1319
  <div>
1282
1320
  <span class="label">Last inbound</span>
1283
- <span>${c.lastInboundAt?O(c.lastInboundAt):"n/a"}</span>
1321
+ <span>${l.lastInboundAt?O(l.lastInboundAt):"n/a"}</span>
1284
1322
  </div>
1285
- ${c.lastError?r`
1323
+ ${l.lastError?c`
1286
1324
  <div class="account-card-error">
1287
- ${c.lastError}
1325
+ ${l.lastError}
1288
1326
  </div>
1289
- `:g}
1327
+ `:h}
1290
1328
  </div>
1291
1329
  </div>
1292
- `};return r`
1330
+ `};return c`
1293
1331
  <div class="card">
1294
1332
  <div class="card-title">Telegram</div>
1295
1333
  <div class="card-sub">Bot status and channel configuration.</div>
1296
1334
  ${i}
1297
1335
 
1298
- ${a?r`
1336
+ ${a?c`
1299
1337
  <div class="account-card-list">
1300
- ${s.map(c=>o(c))}
1338
+ ${s.map(l=>o(l))}
1301
1339
  </div>
1302
- `:r`
1340
+ `:c`
1303
1341
  <div class="status-list" style="margin-top: 16px;">
1304
1342
  <div>
1305
1343
  <span class="label">Configured</span>
@@ -1324,14 +1362,14 @@ ${e.sidebarContent}
1324
1362
  </div>
1325
1363
  `}
1326
1364
 
1327
- ${n?.lastError?r`<div class="callout danger" style="margin-top: 12px;">
1365
+ ${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
1328
1366
  ${n.lastError}
1329
- </div>`:g}
1367
+ </div>`:h}
1330
1368
 
1331
- ${n?.probe?r`<div class="callout" style="margin-top: 12px;">
1369
+ ${n?.probe?c`<div class="callout" style="margin-top: 12px;">
1332
1370
  Probe ${n.probe.ok?"ok":"failed"} ·
1333
1371
  ${n.probe.status??""} ${n.probe.error??""}
1334
- </div>`:g}
1372
+ </div>`:h}
1335
1373
 
1336
1374
  ${$e({channelId:"telegram",props:t})}
1337
1375
 
@@ -1341,7 +1379,7 @@ ${e.sidebarContent}
1341
1379
  </button>
1342
1380
  </div>
1343
1381
  </div>
1344
- `}function af(e){const{props:t,whatsapp:n,accountCountLabel:s}=e;return r`
1382
+ `}function ff(e){const{props:t,whatsapp:n,accountCountLabel:s}=e;return c`
1345
1383
  <div class="card">
1346
1384
  <div class="card-title">WhatsApp</div>
1347
1385
  <div class="card-sub">Link WhatsApp Web and monitor connection health.</div>
@@ -1379,22 +1417,22 @@ ${e.sidebarContent}
1379
1417
  <div>
1380
1418
  <span class="label">Auth age</span>
1381
1419
  <span>
1382
- ${n?.authAgeMs!=null?Hp(n.authAgeMs):"n/a"}
1420
+ ${n?.authAgeMs!=null?Qp(n.authAgeMs):"n/a"}
1383
1421
  </span>
1384
1422
  </div>
1385
1423
  </div>
1386
1424
 
1387
- ${n?.lastError?r`<div class="callout danger" style="margin-top: 12px;">
1425
+ ${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
1388
1426
  ${n.lastError}
1389
- </div>`:g}
1427
+ </div>`:h}
1390
1428
 
1391
- ${t.whatsappMessage?r`<div class="callout" style="margin-top: 12px;">
1429
+ ${t.whatsappMessage?c`<div class="callout" style="margin-top: 12px;">
1392
1430
  ${t.whatsappMessage}
1393
- </div>`:g}
1431
+ </div>`:h}
1394
1432
 
1395
- ${t.whatsappQrDataUrl?r`<div class="qr-wrap">
1433
+ ${t.whatsappQrDataUrl?c`<div class="qr-wrap">
1396
1434
  <img src=${t.whatsappQrDataUrl} alt="WhatsApp QR" />
1397
- </div>`:g}
1435
+ </div>`:h}
1398
1436
 
1399
1437
  <div class="row" style="margin-top: 14px; flex-wrap: wrap;">
1400
1438
  <button
@@ -1432,9 +1470,9 @@ ${e.sidebarContent}
1432
1470
 
1433
1471
  ${$e({channelId:"whatsapp",props:t})}
1434
1472
  </div>
1435
- `}function of(e){const t=e.snapshot?.channels,n=t?.whatsapp??void 0,s=t?.telegram??void 0,i=t?.discord??null;t?.googlechat;const a=t?.slack??null,o=t?.signal??null,c=t?.imessage??null,l=t?.nostr??null,d=rf(e.snapshot).map((u,h)=>({key:u,enabled:zp(u,e),order:h})).sort((u,h)=>u.enabled!==h.enabled?u.enabled?-1:1:u.order-h.order);return r`
1473
+ `}function hf(e){const t=e.snapshot?.channels,n=t?.whatsapp??void 0,s=t?.telegram??void 0,i=t?.discord??null;t?.googlechat;const a=t?.slack??null,o=t?.signal??null,l=t?.imessage??null,r=t?.nostr??null,d=gf(e.snapshot).map((u,g)=>({key:u,enabled:Zp(u,e),order:g})).sort((u,g)=>u.enabled!==g.enabled?u.enabled?-1:1:u.order-g.order);return c`
1436
1474
  <section class="grid grid-cols-2">
1437
- ${d.map(u=>lf(u.key,e,{whatsapp:n,telegram:s,discord:i,slack:a,signal:o,imessage:c,nostr:l,channelAccounts:e.snapshot?.channelAccounts??null}))}
1475
+ ${d.map(u=>vf(u.key,e,{whatsapp:n,telegram:s,discord:i,slack:a,signal:o,imessage:l,nostr:r,channelAccounts:e.snapshot?.channelAccounts??null}))}
1438
1476
  </section>
1439
1477
 
1440
1478
  <section class="card" style="margin-top: 18px;">
@@ -1445,24 +1483,24 @@ ${e.sidebarContent}
1445
1483
  </div>
1446
1484
  <div class="muted">${e.lastSuccessAt?O(e.lastSuccessAt):"n/a"}</div>
1447
1485
  </div>
1448
- ${e.lastError?r`<div class="callout danger" style="margin-top: 12px;">
1486
+ ${e.lastError?c`<div class="callout danger" style="margin-top: 12px;">
1449
1487
  ${e.lastError}
1450
- </div>`:g}
1488
+ </div>`:h}
1451
1489
  <pre class="code-block" style="margin-top: 12px;">
1452
1490
  ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1453
1491
  </pre>
1454
1492
  </section>
1455
- `}function rf(e){return e?.channelMeta?.length?e.channelMeta.map(t=>t.id):e?.channelOrder?.length?e.channelOrder:["whatsapp","telegram","discord","googlechat","slack","signal","imessage","nostr"]}function lf(e,t,n){const s=fr(e,n.channelAccounts);switch(e){case"whatsapp":return af({props:t,whatsapp:n.whatsapp,accountCountLabel:s});case"telegram":return sf({props:t,telegram:n.telegram,telegramAccounts:n.channelAccounts?.telegram??[],accountCountLabel:s});case"discord":return Gp({props:t,discord:n.discord,accountCountLabel:s});case"googlechat":return Yp({props:t,accountCountLabel:s});case"slack":return nf({props:t,slack:n.slack,accountCountLabel:s});case"signal":return tf({props:t,signal:n.signal,accountCountLabel:s});case"imessage":return Qp({props:t,imessage:n.imessage,accountCountLabel:s});case"nostr":{const i=n.channelAccounts?.nostr??[],a=i[0],o=a?.accountId??"default",c=a?.profile??null,l=t.nostrProfileAccountId===o?t.nostrProfileFormState:null,p=l?{onFieldChange:t.onNostrProfileFieldChange,onSave:t.onNostrProfileSave,onImport:t.onNostrProfileImport,onCancel:t.onNostrProfileCancel,onToggleAdvanced:t.onNostrProfileToggleAdvanced}:null;return ef({props:t,nostr:n.nostr,nostrAccounts:i,accountCountLabel:s,profileFormState:l,profileFormCallbacks:p,onEditProfile:()=>t.onNostrProfileEdit(o,c)})}default:return cf(e,t,n.channelAccounts??{})}}function cf(e,t,n){const s=uf(t.snapshot,e),i=t.snapshot?.channels?.[e],a=typeof i?.configured=="boolean"?i.configured:void 0,o=typeof i?.running=="boolean"?i.running:void 0,c=typeof i?.connected=="boolean"?i.connected:void 0,l=typeof i?.lastError=="string"?i.lastError:void 0,p=n[e]??[],d=fr(e,n);return r`
1493
+ `}function gf(e){return e?.channelMeta?.length?e.channelMeta.map(t=>t.id):e?.channelOrder?.length?e.channelOrder:["whatsapp","telegram","discord","googlechat","slack","signal","imessage","nostr"]}function vf(e,t,n){const s=hr(e,n.channelAccounts);switch(e){case"whatsapp":return ff({props:t,whatsapp:n.whatsapp,accountCountLabel:s});case"telegram":return pf({props:t,telegram:n.telegram,telegramAccounts:n.channelAccounts?.telegram??[],accountCountLabel:s});case"discord":return nf({props:t,discord:n.discord,accountCountLabel:s});case"googlechat":return sf({props:t,accountCountLabel:s});case"slack":return uf({props:t,slack:n.slack,accountCountLabel:s});case"signal":return df({props:t,signal:n.signal,accountCountLabel:s});case"imessage":return af({props:t,imessage:n.imessage,accountCountLabel:s});case"nostr":{const i=n.channelAccounts?.nostr??[],a=i[0],o=a?.accountId??"default",l=a?.profile??null,r=t.nostrProfileAccountId===o?t.nostrProfileFormState:null,p=r?{onFieldChange:t.onNostrProfileFieldChange,onSave:t.onNostrProfileSave,onImport:t.onNostrProfileImport,onCancel:t.onNostrProfileCancel,onToggleAdvanced:t.onNostrProfileToggleAdvanced}:null;return cf({props:t,nostr:n.nostr,nostrAccounts:i,accountCountLabel:s,profileFormState:r,profileFormCallbacks:p,onEditProfile:()=>t.onNostrProfileEdit(o,l)})}default:return mf(e,t,n.channelAccounts??{})}}function mf(e,t,n){const s=bf(t.snapshot,e),i=t.snapshot?.channels?.[e],a=typeof i?.configured=="boolean"?i.configured:void 0,o=typeof i?.running=="boolean"?i.running:void 0,l=typeof i?.connected=="boolean"?i.connected:void 0,r=typeof i?.lastError=="string"?i.lastError:void 0,p=n[e]??[],d=hr(e,n);return c`
1456
1494
  <div class="card">
1457
1495
  <div class="card-title">${s}</div>
1458
1496
  <div class="card-sub">Channel status and configuration.</div>
1459
1497
  ${d}
1460
1498
 
1461
- ${p.length>0?r`
1499
+ ${p.length>0?c`
1462
1500
  <div class="account-card-list">
1463
- ${p.map(u=>gf(u))}
1501
+ ${p.map(u=>kf(u))}
1464
1502
  </div>
1465
- `:r`
1503
+ `:c`
1466
1504
  <div class="status-list" style="margin-top: 16px;">
1467
1505
  <div>
1468
1506
  <span class="label">Configured</span>
@@ -1474,18 +1512,18 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1474
1512
  </div>
1475
1513
  <div>
1476
1514
  <span class="label">Connected</span>
1477
- <span>${c==null?"n/a":c?"Yes":"No"}</span>
1515
+ <span>${l==null?"n/a":l?"Yes":"No"}</span>
1478
1516
  </div>
1479
1517
  </div>
1480
1518
  `}
1481
1519
 
1482
- ${l?r`<div class="callout danger" style="margin-top: 12px;">
1483
- ${l}
1484
- </div>`:g}
1520
+ ${r?c`<div class="callout danger" style="margin-top: 12px;">
1521
+ ${r}
1522
+ </div>`:h}
1485
1523
 
1486
1524
  ${$e({channelId:e,props:t})}
1487
1525
  </div>
1488
- `}function df(e){return e?.channelMeta?.length?Object.fromEntries(e.channelMeta.map(t=>[t.id,t])):{}}function uf(e,t){return df(e)[t]?.label??e?.channelLabels?.[t]??t}const pf=600*1e3;function hr(e){return e.lastInboundAt?Date.now()-e.lastInboundAt<pf:!1}function ff(e){return e.running?"Yes":hr(e)?"Active":"No"}function hf(e){return e.connected===!0?"Yes":e.connected===!1?"No":hr(e)?"Active":"n/a"}function gf(e){const t=ff(e),n=hf(e);return r`
1526
+ `}function yf(e){return e?.channelMeta?.length?Object.fromEntries(e.channelMeta.map(t=>[t.id,t])):{}}function bf(e,t){return yf(e)[t]?.label??e?.channelLabels?.[t]??t}const wf=600*1e3;function gr(e){return e.lastInboundAt?Date.now()-e.lastInboundAt<wf:!1}function $f(e){return e.running?"Yes":gr(e)?"Active":"No"}function xf(e){return e.connected===!0?"Yes":e.connected===!1?"No":gr(e)?"Active":"n/a"}function kf(e){const t=$f(e),n=xf(e);return c`
1489
1527
  <div class="account-card">
1490
1528
  <div class="account-card-header">
1491
1529
  <div class="account-card-title">${e.name||e.accountId}</div>
@@ -1508,14 +1546,14 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1508
1546
  <span class="label">Last inbound</span>
1509
1547
  <span>${e.lastInboundAt?O(e.lastInboundAt):"n/a"}</span>
1510
1548
  </div>
1511
- ${e.lastError?r`
1549
+ ${e.lastError?c`
1512
1550
  <div class="account-card-error">
1513
1551
  ${e.lastError}
1514
1552
  </div>
1515
- `:g}
1553
+ `:h}
1516
1554
  </div>
1517
1555
  </div>
1518
- `}function vf(e){const t=e.host??"unknown",n=e.ip?`(${e.ip})`:"",s=e.mode??"",i=e.version??"";return`${t} ${n} ${s} ${i}`.trim()}function mf(e){const t=e.ts??null;return t?O(t):"n/a"}function gr(e){return e?`${At(e)} (${O(e)})`:"n/a"}function bf(e){if(e.totalTokens==null)return"n/a";const t=e.totalTokens??0,n=e.contextTokens??0;return n?`${t} / ${n}`:String(t)}function yf(e){if(e==null)return"";try{return JSON.stringify(e,null,2)}catch{return String(e)}}function wf(e){const t=e.state??{},n=t.nextRunAtMs?At(t.nextRunAtMs):"n/a",s=t.lastRunAtMs?At(t.lastRunAtMs):"n/a";return`${t.lastStatus??"n/a"} · next ${n} · last ${s}`}function $f(e){const t=e.schedule;return t.kind==="at"?`At ${At(t.atMs)}`:t.kind==="every"?`Every ${io(t.everyMs)}`:`Cron ${t.expr}${t.tz?` (${t.tz})`:""}`}function xf(e){const t=e.payload;return t.kind==="systemEvent"?`System: ${t.text}`:`Agent: ${t.message}`}function kf(e){const t=["last",...e.channels.filter(Boolean)],n=e.form.channel?.trim();n&&!t.includes(n)&&t.push(n);const s=new Set;return t.filter(i=>s.has(i)?!1:(s.add(i),!0))}function Af(e,t){if(t==="last")return"last";const n=e.channelMeta?.find(s=>s.id===t);return n?.label?n.label:e.channelLabels?.[t]??t}function Sf(e){const t=kf(e);return r`
1556
+ `}function Af(e){const t=e.host??"unknown",n=e.ip?`(${e.ip})`:"",s=e.mode??"",i=e.version??"";return`${t} ${n} ${s} ${i}`.trim()}function Sf(e){const t=e.ts??null;return t?O(t):"n/a"}function vr(e){return e?`${At(e)} (${O(e)})`:"n/a"}function _f(e){if(e.totalTokens==null)return"n/a";const t=e.totalTokens??0,n=e.contextTokens??0;return n?`${t} / ${n}`:String(t)}function Tf(e){if(e==null)return"";try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Cf(e){const t=e.state??{},n=t.nextRunAtMs?At(t.nextRunAtMs):"n/a",s=t.lastRunAtMs?At(t.lastRunAtMs):"n/a";return`${t.lastStatus??"n/a"} · next ${n} · last ${s}`}function Ef(e){const t=e.schedule;return t.kind==="at"?`At ${At(t.atMs)}`:t.kind==="every"?`Every ${ao(t.everyMs)}`:`Cron ${t.expr}${t.tz?` (${t.tz})`:""}`}function Lf(e){const t=e.payload;return t.kind==="systemEvent"?`System: ${t.text}`:`Agent: ${t.message}`}function If(e){const t=["last",...e.channels.filter(Boolean)],n=e.form.channel?.trim();n&&!t.includes(n)&&t.push(n);const s=new Set;return t.filter(i=>s.has(i)?!1:(s.add(i),!0))}function Mf(e,t){if(t==="last")return"last";const n=e.channelMeta?.find(s=>s.id===t);return n?.label?n.label:e.channelLabels?.[t]??t}function Rf(e){const t=If(e);return c`
1519
1557
  <section class="grid grid-cols-2">
1520
1558
  <div class="card">
1521
1559
  <div class="card-title">Scheduler</div>
@@ -1533,14 +1571,14 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1533
1571
  </div>
1534
1572
  <div class="stat">
1535
1573
  <div class="stat-label">Next wake</div>
1536
- <div class="stat-value">${gr(e.status?.nextWakeAtMs??null)}</div>
1574
+ <div class="stat-value">${vr(e.status?.nextWakeAtMs??null)}</div>
1537
1575
  </div>
1538
1576
  </div>
1539
1577
  <div class="row" style="margin-top: 12px;">
1540
1578
  <button class="btn" ?disabled=${e.loading} @click=${e.onRefresh}>
1541
1579
  ${e.loading?"Refreshing…":"Refresh"}
1542
1580
  </button>
1543
- ${e.error?r`<span class="muted">${e.error}</span>`:g}
1581
+ ${e.error?c`<span class="muted">${e.error}</span>`:h}
1544
1582
  </div>
1545
1583
  </div>
1546
1584
 
@@ -1590,7 +1628,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1590
1628
  </select>
1591
1629
  </label>
1592
1630
  </div>
1593
- ${_f(e)}
1631
+ ${Pf(e)}
1594
1632
  <div class="form-grid" style="margin-top: 12px;">
1595
1633
  <label class="field">
1596
1634
  <span>Session</span>
@@ -1631,7 +1669,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1631
1669
  rows="4"
1632
1670
  ></textarea>
1633
1671
  </label>
1634
- ${e.form.payloadKind==="agentTurn"?r`
1672
+ ${e.form.payloadKind==="agentTurn"?c`
1635
1673
  <div class="form-grid" style="margin-top: 12px;">
1636
1674
  <label class="field checkbox">
1637
1675
  <span>Deliver</span>
@@ -1647,8 +1685,8 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1647
1685
  .value=${e.form.channel||"last"}
1648
1686
  @change=${n=>e.onFormChange({channel:n.target.value})}
1649
1687
  >
1650
- ${t.map(n=>r`<option value=${n}>
1651
- ${Af(e,n)}
1688
+ ${t.map(n=>c`<option value=${n}>
1689
+ ${Mf(e,n)}
1652
1690
  </option>`)}
1653
1691
  </select>
1654
1692
  </label>
@@ -1667,7 +1705,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1667
1705
  @input=${n=>e.onFormChange({timeoutSeconds:n.target.value})}
1668
1706
  />
1669
1707
  </label>
1670
- ${e.form.sessionTarget==="isolated"?r`
1708
+ ${e.form.sessionTarget==="isolated"?c`
1671
1709
  <label class="field">
1672
1710
  <span>Post to main prefix</span>
1673
1711
  <input
@@ -1675,9 +1713,9 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1675
1713
  @input=${n=>e.onFormChange({postToMainPrefix:n.target.value})}
1676
1714
  />
1677
1715
  </label>
1678
- `:g}
1716
+ `:h}
1679
1717
  </div>
1680
- `:g}
1718
+ `:h}
1681
1719
  <div class="row" style="margin-top: 14px;">
1682
1720
  <button class="btn primary" ?disabled=${e.busy} @click=${e.onAdd}>
1683
1721
  ${e.busy?"Saving…":"Add job"}
@@ -1689,9 +1727,9 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1689
1727
  <section class="card" style="margin-top: 18px;">
1690
1728
  <div class="card-title">Jobs</div>
1691
1729
  <div class="card-sub">All scheduled jobs stored in the gateway.</div>
1692
- ${e.jobs.length===0?r`<div class="muted" style="margin-top: 12px;">No jobs yet.</div>`:r`
1730
+ ${e.jobs.length===0?c`<div class="muted" style="margin-top: 12px;">No jobs yet.</div>`:c`
1693
1731
  <div class="list" style="margin-top: 12px;">
1694
- ${e.jobs.map(n=>Tf(n,e))}
1732
+ ${e.jobs.map(n=>Nf(n,e))}
1695
1733
  </div>
1696
1734
  `}
1697
1735
  </section>
@@ -1699,17 +1737,17 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1699
1737
  <section class="card" style="margin-top: 18px;">
1700
1738
  <div class="card-title">Run history</div>
1701
1739
  <div class="card-sub">Latest runs for ${e.runsJobId??"(select a job)"}.</div>
1702
- ${e.runsJobId==null?r`
1740
+ ${e.runsJobId==null?c`
1703
1741
  <div class="muted" style="margin-top: 12px;">
1704
1742
  Select a job to inspect run history.
1705
1743
  </div>
1706
- `:e.runs.length===0?r`<div class="muted" style="margin-top: 12px;">No runs yet.</div>`:r`
1744
+ `:e.runs.length===0?c`<div class="muted" style="margin-top: 12px;">No runs yet.</div>`:c`
1707
1745
  <div class="list" style="margin-top: 12px;">
1708
- ${e.runs.map(n=>Cf(n))}
1746
+ ${e.runs.map(n=>Of(n))}
1709
1747
  </div>
1710
1748
  `}
1711
1749
  </section>
1712
- `}function _f(e){const t=e.form;return t.scheduleKind==="at"?r`
1750
+ `}function Pf(e){const t=e.form;return t.scheduleKind==="at"?c`
1713
1751
  <label class="field" style="margin-top: 12px;">
1714
1752
  <span>Run at</span>
1715
1753
  <input
@@ -1718,7 +1756,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1718
1756
  @input=${n=>e.onFormChange({scheduleAt:n.target.value})}
1719
1757
  />
1720
1758
  </label>
1721
- `:t.scheduleKind==="every"?r`
1759
+ `:t.scheduleKind==="every"?c`
1722
1760
  <div class="form-grid" style="margin-top: 12px;">
1723
1761
  <label class="field">
1724
1762
  <span>Every</span>
@@ -1739,7 +1777,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1739
1777
  </select>
1740
1778
  </label>
1741
1779
  </div>
1742
- `:r`
1780
+ `:c`
1743
1781
  <div class="form-grid" style="margin-top: 12px;">
1744
1782
  <label class="field">
1745
1783
  <span>Expression</span>
@@ -1756,13 +1794,13 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1756
1794
  />
1757
1795
  </label>
1758
1796
  </div>
1759
- `}function Tf(e,t){const s=`list-item list-item-clickable${t.runsJobId===e.id?" list-item-selected":""}`;return r`
1797
+ `}function Nf(e,t){const s=`list-item list-item-clickable${t.runsJobId===e.id?" list-item-selected":""}`;return c`
1760
1798
  <div class=${s} @click=${()=>t.onLoadRuns(e.id)}>
1761
1799
  <div class="list-main">
1762
1800
  <div class="list-title">${e.name}</div>
1763
- <div class="list-sub">${$f(e)}</div>
1764
- <div class="muted">${xf(e)}</div>
1765
- ${e.agentId?r`<div class="muted">Agent: ${e.agentId}</div>`:g}
1801
+ <div class="list-sub">${Ef(e)}</div>
1802
+ <div class="muted">${Lf(e)}</div>
1803
+ ${e.agentId?c`<div class="muted">Agent: ${e.agentId}</div>`:h}
1766
1804
  <div class="chip-row" style="margin-top: 6px;">
1767
1805
  <span class="chip">${e.enabled?"enabled":"disabled"}</span>
1768
1806
  <span class="chip">${e.sessionTarget}</span>
@@ -1770,7 +1808,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1770
1808
  </div>
1771
1809
  </div>
1772
1810
  <div class="list-meta">
1773
- <div>${wf(e)}</div>
1811
+ <div>${Cf(e)}</div>
1774
1812
  <div class="row" style="justify-content: flex-end; margin-top: 8px;">
1775
1813
  <button
1776
1814
  class="btn"
@@ -1803,7 +1841,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1803
1841
  </div>
1804
1842
  </div>
1805
1843
  </div>
1806
- `}function Cf(e){return r`
1844
+ `}function Of(e){return c`
1807
1845
  <div class="list-item">
1808
1846
  <div class="list-main">
1809
1847
  <div class="list-title">${e.status}</div>
@@ -1812,10 +1850,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1812
1850
  <div class="list-meta">
1813
1851
  <div>${At(e.ts)}</div>
1814
1852
  <div class="muted">${e.durationMs??0}ms</div>
1815
- ${e.error?r`<div class="muted">${e.error}</div>`:g}
1853
+ ${e.error?c`<div class="muted">${e.error}</div>`:h}
1816
1854
  </div>
1817
1855
  </div>
1818
- `}function Ef(e){return r`
1856
+ `}function Df(e){const n=(e.status&&typeof e.status=="object"?e.status.securityAudit:null)?.summary??null,s=n?.critical??0,i=n?.warn??0,a=n?.info??0,o=s>0?"danger":i>0?"warn":"success",l=s>0?`${s} critical`:i>0?`${i} warnings`:"No critical issues";return c`
1819
1857
  <section class="grid grid-cols-2">
1820
1858
  <div class="card">
1821
1859
  <div class="row" style="justify-content: space-between;">
@@ -1830,6 +1868,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1830
1868
  <div class="stack" style="margin-top: 12px;">
1831
1869
  <div>
1832
1870
  <div class="muted">Status</div>
1871
+ ${n?c`<div class="callout ${o}" style="margin-top: 8px;">
1872
+ Security audit: ${l}${a>0?` · ${a} info`:""}. Run
1873
+ <span class="mono">moltbot security audit --deep</span> for details.
1874
+ </div>`:h}
1833
1875
  <pre class="code-block">${JSON.stringify(e.status??{},null,2)}</pre>
1834
1876
  </div>
1835
1877
  <div>
@@ -1851,7 +1893,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1851
1893
  <span>Method</span>
1852
1894
  <input
1853
1895
  .value=${e.callMethod}
1854
- @input=${t=>e.onCallMethodChange(t.target.value)}
1896
+ @input=${r=>e.onCallMethodChange(r.target.value)}
1855
1897
  placeholder="system-presence"
1856
1898
  />
1857
1899
  </label>
@@ -1859,7 +1901,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1859
1901
  <span>Params (JSON)</span>
1860
1902
  <textarea
1861
1903
  .value=${e.callParams}
1862
- @input=${t=>e.onCallParamsChange(t.target.value)}
1904
+ @input=${r=>e.onCallParamsChange(r.target.value)}
1863
1905
  rows="6"
1864
1906
  ></textarea>
1865
1907
  </label>
@@ -1867,10 +1909,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1867
1909
  <div class="row" style="margin-top: 12px;">
1868
1910
  <button class="btn primary" @click=${e.onCall}>Call</button>
1869
1911
  </div>
1870
- ${e.callError?r`<div class="callout danger" style="margin-top: 12px;">
1912
+ ${e.callError?c`<div class="callout danger" style="margin-top: 12px;">
1871
1913
  ${e.callError}
1872
- </div>`:g}
1873
- ${e.callResult?r`<pre class="code-block" style="margin-top: 12px;">${e.callResult}</pre>`:g}
1914
+ </div>`:h}
1915
+ ${e.callResult?c`<pre class="code-block" style="margin-top: 12px;">${e.callResult}</pre>`:h}
1874
1916
  </div>
1875
1917
  </section>
1876
1918
 
@@ -1883,23 +1925,23 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1883
1925
  <section class="card" style="margin-top: 18px;">
1884
1926
  <div class="card-title">Event Log</div>
1885
1927
  <div class="card-sub">Latest gateway events.</div>
1886
- ${e.eventLog.length===0?r`<div class="muted" style="margin-top: 12px;">No events yet.</div>`:r`
1928
+ ${e.eventLog.length===0?c`<div class="muted" style="margin-top: 12px;">No events yet.</div>`:c`
1887
1929
  <div class="list" style="margin-top: 12px;">
1888
- ${e.eventLog.map(t=>r`
1930
+ ${e.eventLog.map(r=>c`
1889
1931
  <div class="list-item">
1890
1932
  <div class="list-main">
1891
- <div class="list-title">${t.event}</div>
1892
- <div class="list-sub">${new Date(t.ts).toLocaleTimeString()}</div>
1933
+ <div class="list-title">${r.event}</div>
1934
+ <div class="list-sub">${new Date(r.ts).toLocaleTimeString()}</div>
1893
1935
  </div>
1894
1936
  <div class="list-meta">
1895
- <pre class="code-block">${yf(t.payload)}</pre>
1937
+ <pre class="code-block">${Tf(r.payload)}</pre>
1896
1938
  </div>
1897
1939
  </div>
1898
1940
  `)}
1899
1941
  </div>
1900
1942
  `}
1901
1943
  </section>
1902
- `}function Lf(e){return r`
1944
+ `}function Bf(e){return c`
1903
1945
  <section class="card">
1904
1946
  <div class="row" style="justify-content: space-between;">
1905
1947
  <div>
@@ -1910,38 +1952,38 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1910
1952
  ${e.loading?"Loading…":"Refresh"}
1911
1953
  </button>
1912
1954
  </div>
1913
- ${e.lastError?r`<div class="callout danger" style="margin-top: 12px;">
1955
+ ${e.lastError?c`<div class="callout danger" style="margin-top: 12px;">
1914
1956
  ${e.lastError}
1915
- </div>`:g}
1916
- ${e.statusMessage?r`<div class="callout" style="margin-top: 12px;">
1957
+ </div>`:h}
1958
+ ${e.statusMessage?c`<div class="callout" style="margin-top: 12px;">
1917
1959
  ${e.statusMessage}
1918
- </div>`:g}
1960
+ </div>`:h}
1919
1961
  <div class="list" style="margin-top: 16px;">
1920
- ${e.entries.length===0?r`<div class="muted">No instances reported yet.</div>`:e.entries.map(t=>Mf(t))}
1962
+ ${e.entries.length===0?c`<div class="muted">No instances reported yet.</div>`:e.entries.map(t=>Ff(t))}
1921
1963
  </div>
1922
1964
  </section>
1923
- `}function Mf(e){const t=e.lastInputSeconds!=null?`${e.lastInputSeconds}s ago`:"n/a",n=e.mode??"unknown",s=Array.isArray(e.roles)?e.roles.filter(Boolean):[],i=Array.isArray(e.scopes)?e.scopes.filter(Boolean):[],a=i.length>0?i.length>3?`${i.length} scopes`:`scopes: ${i.join(", ")}`:null;return r`
1965
+ `}function Ff(e){const t=e.lastInputSeconds!=null?`${e.lastInputSeconds}s ago`:"n/a",n=e.mode??"unknown",s=Array.isArray(e.roles)?e.roles.filter(Boolean):[],i=Array.isArray(e.scopes)?e.scopes.filter(Boolean):[],a=i.length>0?i.length>3?`${i.length} scopes`:`scopes: ${i.join(", ")}`:null;return c`
1924
1966
  <div class="list-item">
1925
1967
  <div class="list-main">
1926
1968
  <div class="list-title">${e.host??"unknown host"}</div>
1927
- <div class="list-sub">${vf(e)}</div>
1969
+ <div class="list-sub">${Af(e)}</div>
1928
1970
  <div class="chip-row">
1929
1971
  <span class="chip">${n}</span>
1930
- ${s.map(o=>r`<span class="chip">${o}</span>`)}
1931
- ${a?r`<span class="chip">${a}</span>`:g}
1932
- ${e.platform?r`<span class="chip">${e.platform}</span>`:g}
1933
- ${e.deviceFamily?r`<span class="chip">${e.deviceFamily}</span>`:g}
1934
- ${e.modelIdentifier?r`<span class="chip">${e.modelIdentifier}</span>`:g}
1935
- ${e.version?r`<span class="chip">${e.version}</span>`:g}
1972
+ ${s.map(o=>c`<span class="chip">${o}</span>`)}
1973
+ ${a?c`<span class="chip">${a}</span>`:h}
1974
+ ${e.platform?c`<span class="chip">${e.platform}</span>`:h}
1975
+ ${e.deviceFamily?c`<span class="chip">${e.deviceFamily}</span>`:h}
1976
+ ${e.modelIdentifier?c`<span class="chip">${e.modelIdentifier}</span>`:h}
1977
+ ${e.version?c`<span class="chip">${e.version}</span>`:h}
1936
1978
  </div>
1937
1979
  </div>
1938
1980
  <div class="list-meta">
1939
- <div>${mf(e)}</div>
1981
+ <div>${Sf(e)}</div>
1940
1982
  <div class="muted">Last input ${t}</div>
1941
1983
  <div class="muted">Reason ${e.reason??""}</div>
1942
1984
  </div>
1943
1985
  </div>
1944
- `}const Ua=["trace","debug","info","warn","error","fatal"];function If(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function Rf(e,t){return t?[e.message,e.subsystem,e.raw].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Pf(e){const t=e.filterText.trim().toLowerCase(),n=Ua.some(a=>!e.levelFilters[a]),s=e.entries.filter(a=>a.level&&!e.levelFilters[a.level]?!1:Rf(a,t)),i=t||n?"filtered":"visible";return r`
1986
+ `}const Ka=["trace","debug","info","warn","error","fatal"];function Uf(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function Kf(e,t){return t?[e.message,e.subsystem,e.raw].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function Hf(e){const t=e.filterText.trim().toLowerCase(),n=Ka.some(a=>!e.levelFilters[a]),s=e.entries.filter(a=>a.level&&!e.levelFilters[a.level]?!1:Kf(a,t)),i=t||n?"filtered":"visible";return c`
1945
1987
  <section class="card">
1946
1988
  <div class="row" style="justify-content: space-between;">
1947
1989
  <div>
@@ -1982,7 +2024,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1982
2024
  </div>
1983
2025
 
1984
2026
  <div class="chip-row" style="margin-top: 12px;">
1985
- ${Ua.map(a=>r`
2027
+ ${Ka.map(a=>c`
1986
2028
  <label class="chip log-chip ${a}">
1987
2029
  <input
1988
2030
  type="checkbox"
@@ -1994,16 +2036,16 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1994
2036
  `)}
1995
2037
  </div>
1996
2038
 
1997
- ${e.file?r`<div class="muted" style="margin-top: 10px;">File: ${e.file}</div>`:g}
1998
- ${e.truncated?r`<div class="callout" style="margin-top: 10px;">
2039
+ ${e.file?c`<div class="muted" style="margin-top: 10px;">File: ${e.file}</div>`:h}
2040
+ ${e.truncated?c`<div class="callout" style="margin-top: 10px;">
1999
2041
  Log output truncated; showing latest chunk.
2000
- </div>`:g}
2001
- ${e.error?r`<div class="callout danger" style="margin-top: 10px;">${e.error}</div>`:g}
2042
+ </div>`:h}
2043
+ ${e.error?c`<div class="callout danger" style="margin-top: 10px;">${e.error}</div>`:h}
2002
2044
 
2003
2045
  <div class="log-stream" style="margin-top: 12px;" @scroll=${e.onScroll}>
2004
- ${s.length===0?r`<div class="muted" style="padding: 12px;">No log entries.</div>`:s.map(a=>r`
2046
+ ${s.length===0?c`<div class="muted" style="padding: 12px;">No log entries.</div>`:s.map(a=>c`
2005
2047
  <div class="log-row">
2006
- <div class="log-time mono">${If(a.time)}</div>
2048
+ <div class="log-time mono">${Uf(a.time)}</div>
2007
2049
  <div class="log-level ${a.level??""}">${a.level??""}</div>
2008
2050
  <div class="log-subsystem mono">${a.subsystem??""}</div>
2009
2051
  <div class="log-message mono">${a.message??a.raw}</div>
@@ -2011,10 +2053,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2011
2053
  `)}
2012
2054
  </div>
2013
2055
  </section>
2014
- `}function Nf(e){const t=Kf(e),n=Wf(e);return r`
2015
- ${Yf(n)}
2016
- ${Gf(t)}
2017
- ${Of(e)}
2056
+ `}function zf(e){const t=Yf(e),n=th(e);return c`
2057
+ ${sh(n)}
2058
+ ${nh(t)}
2059
+ ${jf(e)}
2018
2060
  <section class="card">
2019
2061
  <div class="row" style="justify-content: space-between;">
2020
2062
  <div>
@@ -2026,10 +2068,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2026
2068
  </button>
2027
2069
  </div>
2028
2070
  <div class="list" style="margin-top: 16px;">
2029
- ${e.nodes.length===0?r`<div class="muted">No nodes found.</div>`:e.nodes.map(s=>ah(s))}
2071
+ ${e.nodes.length===0?c`<div class="muted">No nodes found.</div>`:e.nodes.map(s=>fh(s))}
2030
2072
  </div>
2031
2073
  </section>
2032
- `}function Of(e){const t=e.devicesList??{pending:[],paired:[]},n=Array.isArray(t.pending)?t.pending:[],s=Array.isArray(t.paired)?t.paired:[];return r`
2074
+ `}function jf(e){const t=e.devicesList??{pending:[],paired:[]},n=Array.isArray(t.pending)?t.pending:[],s=Array.isArray(t.paired)?t.paired:[];return c`
2033
2075
  <section class="card">
2034
2076
  <div class="row" style="justify-content: space-between;">
2035
2077
  <div>
@@ -2040,20 +2082,20 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2040
2082
  ${e.devicesLoading?"Loading…":"Refresh"}
2041
2083
  </button>
2042
2084
  </div>
2043
- ${e.devicesError?r`<div class="callout danger" style="margin-top: 12px;">${e.devicesError}</div>`:g}
2085
+ ${e.devicesError?c`<div class="callout danger" style="margin-top: 12px;">${e.devicesError}</div>`:h}
2044
2086
  <div class="list" style="margin-top: 16px;">
2045
- ${n.length>0?r`
2087
+ ${n.length>0?c`
2046
2088
  <div class="muted" style="margin-bottom: 8px;">Pending</div>
2047
- ${n.map(i=>Df(i,e))}
2048
- `:g}
2049
- ${s.length>0?r`
2089
+ ${n.map(i=>qf(i,e))}
2090
+ `:h}
2091
+ ${s.length>0?c`
2050
2092
  <div class="muted" style="margin-top: 12px; margin-bottom: 8px;">Paired</div>
2051
- ${s.map(i=>Bf(i,e))}
2052
- `:g}
2053
- ${n.length===0&&s.length===0?r`<div class="muted">No paired devices.</div>`:g}
2093
+ ${s.map(i=>Wf(i,e))}
2094
+ `:h}
2095
+ ${n.length===0&&s.length===0?c`<div class="muted">No paired devices.</div>`:h}
2054
2096
  </div>
2055
2097
  </section>
2056
- `}function Df(e,t){const n=e.displayName?.trim()||e.deviceId,s=typeof e.ts=="number"?O(e.ts):"n/a",i=e.role?.trim()?`role: ${e.role}`:"role: -",a=e.isRepair?" · repair":"",o=e.remoteIp?` · ${e.remoteIp}`:"";return r`
2098
+ `}function qf(e,t){const n=e.displayName?.trim()||e.deviceId,s=typeof e.ts=="number"?O(e.ts):"n/a",i=e.role?.trim()?`role: ${e.role}`:"role: -",a=e.isRepair?" · repair":"",o=e.remoteIp?` · ${e.remoteIp}`:"";return c`
2057
2099
  <div class="list-item">
2058
2100
  <div class="list-main">
2059
2101
  <div class="list-title">${n}</div>
@@ -2073,21 +2115,21 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2073
2115
  </div>
2074
2116
  </div>
2075
2117
  </div>
2076
- `}function Bf(e,t){const n=e.displayName?.trim()||e.deviceId,s=e.remoteIp?` · ${e.remoteIp}`:"",i=`roles: ${is(e.roles)}`,a=`scopes: ${is(e.scopes)}`,o=Array.isArray(e.tokens)?e.tokens:[];return r`
2118
+ `}function Wf(e,t){const n=e.displayName?.trim()||e.deviceId,s=e.remoteIp?` · ${e.remoteIp}`:"",i=`roles: ${as(e.roles)}`,a=`scopes: ${as(e.scopes)}`,o=Array.isArray(e.tokens)?e.tokens:[];return c`
2077
2119
  <div class="list-item">
2078
2120
  <div class="list-main">
2079
2121
  <div class="list-title">${n}</div>
2080
2122
  <div class="list-sub">${e.deviceId}${s}</div>
2081
2123
  <div class="muted" style="margin-top: 6px;">${i} · ${a}</div>
2082
- ${o.length===0?r`<div class="muted" style="margin-top: 6px;">Tokens: none</div>`:r`
2124
+ ${o.length===0?c`<div class="muted" style="margin-top: 6px;">Tokens: none</div>`:c`
2083
2125
  <div class="muted" style="margin-top: 10px;">Tokens</div>
2084
2126
  <div style="display: flex; flex-direction: column; gap: 8px; margin-top: 6px;">
2085
- ${o.map(c=>Ff(e.deviceId,c,t))}
2127
+ ${o.map(l=>Vf(e.deviceId,l,t))}
2086
2128
  </div>
2087
2129
  `}
2088
2130
  </div>
2089
2131
  </div>
2090
- `}function Ff(e,t,n){const s=t.revokedAtMs?"revoked":"active",i=`scopes: ${is(t.scopes)}`,a=O(t.rotatedAtMs??t.createdAtMs??t.lastUsedAtMs??null);return r`
2132
+ `}function Vf(e,t,n){const s=t.revokedAtMs?"revoked":"active",i=`scopes: ${as(t.scopes)}`,a=O(t.rotatedAtMs??t.createdAtMs??t.lastUsedAtMs??null);return c`
2091
2133
  <div class="row" style="justify-content: space-between; gap: 8px;">
2092
2134
  <div class="list-sub">${t.role} · ${s} · ${i} · ${a}</div>
2093
2135
  <div class="row" style="justify-content: flex-end; gap: 6px; flex-wrap: wrap;">
@@ -2097,7 +2139,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2097
2139
  >
2098
2140
  Rotate
2099
2141
  </button>
2100
- ${t.revokedAtMs?g:r`
2142
+ ${t.revokedAtMs?h:c`
2101
2143
  <button
2102
2144
  class="btn btn--sm danger"
2103
2145
  @click=${()=>n.onDeviceRevoke(e,t.role)}
@@ -2107,7 +2149,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2107
2149
  `}
2108
2150
  </div>
2109
2151
  </div>
2110
- `}const Ae="__defaults__",Ka=[{value:"deny",label:"Deny"},{value:"allowlist",label:"Allowlist"},{value:"full",label:"Full"}],Uf=[{value:"off",label:"Off"},{value:"on-miss",label:"On miss"},{value:"always",label:"Always"}];function Kf(e){const t=e.configForm,n=nh(e.nodes),{defaultBinding:s,agents:i}=ih(t),a=!!t,o=e.configSaving||e.configFormMode==="raw";return{ready:a,disabled:o,configDirty:e.configDirty,configLoading:e.configLoading,configSaving:e.configSaving,defaultBinding:s,agents:i,nodes:n,onBindDefault:e.onBindDefault,onBindAgent:e.onBindAgent,onSave:e.onSaveBindings,onLoadConfig:e.onLoadConfig,formMode:e.configFormMode}}function Ha(e){return e==="allowlist"||e==="full"||e==="deny"?e:"deny"}function Hf(e){return e==="always"||e==="off"||e==="on-miss"?e:"on-miss"}function zf(e){const t=e?.defaults??{};return{security:Ha(t.security),ask:Hf(t.ask),askFallback:Ha(t.askFallback??"deny"),autoAllowSkills:!!(t.autoAllowSkills??!1)}}function jf(e){const t=e?.agents??{},n=Array.isArray(t.list)?t.list:[],s=[];return n.forEach(i=>{if(!i||typeof i!="object")return;const a=i,o=typeof a.id=="string"?a.id.trim():"";if(!o)return;const c=typeof a.name=="string"?a.name.trim():void 0,l=a.default===!0;s.push({id:o,name:c||void 0,isDefault:l})}),s}function qf(e,t){const n=jf(e),s=Object.keys(t?.agents??{}),i=new Map;n.forEach(o=>i.set(o.id,o)),s.forEach(o=>{i.has(o)||i.set(o,{id:o})});const a=Array.from(i.values());return a.length===0&&a.push({id:"main",isDefault:!0}),a.sort((o,c)=>{if(o.isDefault&&!c.isDefault)return-1;if(!o.isDefault&&c.isDefault)return 1;const l=o.name?.trim()?o.name:o.id,p=c.name?.trim()?c.name:c.id;return l.localeCompare(p)}),a}function Vf(e,t){return e===Ae?Ae:e&&t.some(n=>n.id===e)?e:Ae}function Wf(e){const t=e.execApprovalsForm??e.execApprovalsSnapshot?.file??null,n=!!t,s=zf(t),i=qf(e.configForm,t),a=sh(e.nodes),o=e.execApprovalsTarget;let c=o==="node"&&e.execApprovalsTargetNodeId?e.execApprovalsTargetNodeId:null;o==="node"&&c&&!a.some(u=>u.id===c)&&(c=null);const l=Vf(e.execApprovalsSelectedAgent,i),p=l!==Ae?(t?.agents??{})[l]??null:null,d=Array.isArray(p?.allowlist)?p.allowlist??[]:[];return{ready:n,disabled:e.execApprovalsSaving||e.execApprovalsLoading,dirty:e.execApprovalsDirty,loading:e.execApprovalsLoading,saving:e.execApprovalsSaving,form:t,defaults:s,selectedScope:l,selectedAgent:p,agents:i,allowlist:d,target:o,targetNodeId:c,targetNodes:a,onSelectScope:e.onExecApprovalsSelectAgent,onSelectTarget:e.onExecApprovalsTargetChange,onPatch:e.onExecApprovalsPatch,onRemove:e.onExecApprovalsRemove,onLoad:e.onLoadExecApprovals,onSave:e.onSaveExecApprovals}}function Gf(e){const t=e.nodes.length>0,n=e.defaultBinding??"";return r`
2152
+ `}const Ae="__defaults__",Ha=[{value:"deny",label:"Deny"},{value:"allowlist",label:"Allowlist"},{value:"full",label:"Full"}],Gf=[{value:"off",label:"Off"},{value:"on-miss",label:"On miss"},{value:"always",label:"Always"}];function Yf(e){const t=e.configForm,n=dh(e.nodes),{defaultBinding:s,agents:i}=ph(t),a=!!t,o=e.configSaving||e.configFormMode==="raw";return{ready:a,disabled:o,configDirty:e.configDirty,configLoading:e.configLoading,configSaving:e.configSaving,defaultBinding:s,agents:i,nodes:n,onBindDefault:e.onBindDefault,onBindAgent:e.onBindAgent,onSave:e.onSaveBindings,onLoadConfig:e.onLoadConfig,formMode:e.configFormMode}}function za(e){return e==="allowlist"||e==="full"||e==="deny"?e:"deny"}function Qf(e){return e==="always"||e==="off"||e==="on-miss"?e:"on-miss"}function Zf(e){const t=e?.defaults??{};return{security:za(t.security),ask:Qf(t.ask),askFallback:za(t.askFallback??"deny"),autoAllowSkills:!!(t.autoAllowSkills??!1)}}function Jf(e){const t=e?.agents??{},n=Array.isArray(t.list)?t.list:[],s=[];return n.forEach(i=>{if(!i||typeof i!="object")return;const a=i,o=typeof a.id=="string"?a.id.trim():"";if(!o)return;const l=typeof a.name=="string"?a.name.trim():void 0,r=a.default===!0;s.push({id:o,name:l||void 0,isDefault:r})}),s}function Xf(e,t){const n=Jf(e),s=Object.keys(t?.agents??{}),i=new Map;n.forEach(o=>i.set(o.id,o)),s.forEach(o=>{i.has(o)||i.set(o,{id:o})});const a=Array.from(i.values());return a.length===0&&a.push({id:"main",isDefault:!0}),a.sort((o,l)=>{if(o.isDefault&&!l.isDefault)return-1;if(!o.isDefault&&l.isDefault)return 1;const r=o.name?.trim()?o.name:o.id,p=l.name?.trim()?l.name:l.id;return r.localeCompare(p)}),a}function eh(e,t){return e===Ae?Ae:e&&t.some(n=>n.id===e)?e:Ae}function th(e){const t=e.execApprovalsForm??e.execApprovalsSnapshot?.file??null,n=!!t,s=Zf(t),i=Xf(e.configForm,t),a=uh(e.nodes),o=e.execApprovalsTarget;let l=o==="node"&&e.execApprovalsTargetNodeId?e.execApprovalsTargetNodeId:null;o==="node"&&l&&!a.some(u=>u.id===l)&&(l=null);const r=eh(e.execApprovalsSelectedAgent,i),p=r!==Ae?(t?.agents??{})[r]??null:null,d=Array.isArray(p?.allowlist)?p.allowlist??[]:[];return{ready:n,disabled:e.execApprovalsSaving||e.execApprovalsLoading,dirty:e.execApprovalsDirty,loading:e.execApprovalsLoading,saving:e.execApprovalsSaving,form:t,defaults:s,selectedScope:r,selectedAgent:p,agents:i,allowlist:d,target:o,targetNodeId:l,targetNodes:a,onSelectScope:e.onExecApprovalsSelectAgent,onSelectTarget:e.onExecApprovalsTargetChange,onPatch:e.onExecApprovalsPatch,onRemove:e.onExecApprovalsRemove,onLoad:e.onLoadExecApprovals,onSave:e.onSaveExecApprovals}}function nh(e){const t=e.nodes.length>0,n=e.defaultBinding??"";return c`
2111
2153
  <section class="card">
2112
2154
  <div class="row" style="justify-content: space-between; align-items: center;">
2113
2155
  <div>
@@ -2125,11 +2167,11 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2125
2167
  </button>
2126
2168
  </div>
2127
2169
 
2128
- ${e.formMode==="raw"?r`<div class="callout warn" style="margin-top: 12px;">
2170
+ ${e.formMode==="raw"?c`<div class="callout warn" style="margin-top: 12px;">
2129
2171
  Switch the Config tab to <strong>Form</strong> mode to edit bindings here.
2130
- </div>`:g}
2172
+ </div>`:h}
2131
2173
 
2132
- ${e.ready?r`
2174
+ ${e.ready?c`
2133
2175
  <div class="list" style="margin-top: 16px;">
2134
2176
  <div class="list-item">
2135
2177
  <div class="list-main">
@@ -2144,7 +2186,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2144
2186
  @change=${s=>{const a=s.target.value.trim();e.onBindDefault(a||null)}}
2145
2187
  >
2146
2188
  <option value="" ?selected=${n===""}>Any node</option>
2147
- ${e.nodes.map(s=>r`<option
2189
+ ${e.nodes.map(s=>c`<option
2148
2190
  value=${s.id}
2149
2191
  ?selected=${n===s.id}
2150
2192
  >
@@ -2152,20 +2194,20 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2152
2194
  </option>`)}
2153
2195
  </select>
2154
2196
  </label>
2155
- ${t?g:r`<div class="muted">No nodes with system.run available.</div>`}
2197
+ ${t?h:c`<div class="muted">No nodes with system.run available.</div>`}
2156
2198
  </div>
2157
2199
  </div>
2158
2200
 
2159
- ${e.agents.length===0?r`<div class="muted">No agents found.</div>`:e.agents.map(s=>th(s,e))}
2201
+ ${e.agents.length===0?c`<div class="muted">No agents found.</div>`:e.agents.map(s=>ch(s,e))}
2160
2202
  </div>
2161
- `:r`<div class="row" style="margin-top: 12px; gap: 12px;">
2203
+ `:c`<div class="row" style="margin-top: 12px; gap: 12px;">
2162
2204
  <div class="muted">Load config to edit bindings.</div>
2163
2205
  <button class="btn" ?disabled=${e.configLoading} @click=${e.onLoadConfig}>
2164
2206
  ${e.configLoading?"Loading…":"Load config"}
2165
2207
  </button>
2166
2208
  </div>`}
2167
2209
  </section>
2168
- `}function Yf(e){const t=e.ready,n=e.target!=="node"||!!e.targetNodeId;return r`
2210
+ `}function sh(e){const t=e.ready,n=e.target!=="node"||!!e.targetNodeId;return c`
2169
2211
  <section class="card">
2170
2212
  <div class="row" style="justify-content: space-between; align-items: center;">
2171
2213
  <div>
@@ -2183,20 +2225,20 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2183
2225
  </button>
2184
2226
  </div>
2185
2227
 
2186
- ${Qf(e)}
2228
+ ${ih(e)}
2187
2229
 
2188
- ${t?r`
2189
- ${Zf(e)}
2190
- ${Jf(e)}
2191
- ${e.selectedScope===Ae?g:Xf(e)}
2192
- `:r`<div class="row" style="margin-top: 12px; gap: 12px;">
2230
+ ${t?c`
2231
+ ${ah(e)}
2232
+ ${oh(e)}
2233
+ ${e.selectedScope===Ae?h:rh(e)}
2234
+ `:c`<div class="row" style="margin-top: 12px; gap: 12px;">
2193
2235
  <div class="muted">Load exec approvals to edit allowlists.</div>
2194
2236
  <button class="btn" ?disabled=${e.loading||!n} @click=${e.onLoad}>
2195
2237
  ${e.loading?"Loading…":"Load approvals"}
2196
2238
  </button>
2197
2239
  </div>`}
2198
2240
  </section>
2199
- `}function Qf(e){const t=e.targetNodes.length>0,n=e.targetNodeId??"";return r`
2241
+ `}function ih(e){const t=e.targetNodes.length>0,n=e.targetNodeId??"";return c`
2200
2242
  <div class="list" style="margin-top: 12px;">
2201
2243
  <div class="list-item">
2202
2244
  <div class="list-main">
@@ -2216,7 +2258,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2216
2258
  <option value="node" ?selected=${e.target==="node"}>Node</option>
2217
2259
  </select>
2218
2260
  </label>
2219
- ${e.target==="node"?r`
2261
+ ${e.target==="node"?c`
2220
2262
  <label class="field">
2221
2263
  <span>Node</span>
2222
2264
  <select
@@ -2224,7 +2266,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2224
2266
  @change=${s=>{const a=s.target.value.trim();e.onSelectTarget("node",a||null)}}
2225
2267
  >
2226
2268
  <option value="" ?selected=${n===""}>Select node</option>
2227
- ${e.targetNodes.map(s=>r`<option
2269
+ ${e.targetNodes.map(s=>c`<option
2228
2270
  value=${s.id}
2229
2271
  ?selected=${n===s.id}
2230
2272
  >
@@ -2232,12 +2274,12 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2232
2274
  </option>`)}
2233
2275
  </select>
2234
2276
  </label>
2235
- `:g}
2277
+ `:h}
2236
2278
  </div>
2237
2279
  </div>
2238
- ${e.target==="node"&&!t?r`<div class="muted">No nodes advertise exec approvals yet.</div>`:g}
2280
+ ${e.target==="node"&&!t?c`<div class="muted">No nodes advertise exec approvals yet.</div>`:h}
2239
2281
  </div>
2240
- `}function Zf(e){return r`
2282
+ `}function ah(e){return c`
2241
2283
  <div class="row" style="margin-top: 12px; gap: 8px; flex-wrap: wrap;">
2242
2284
  <span class="label">Scope</span>
2243
2285
  <div class="row" style="gap: 8px; flex-wrap: wrap;">
@@ -2247,7 +2289,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2247
2289
  >
2248
2290
  Defaults
2249
2291
  </button>
2250
- ${e.agents.map(t=>{const n=t.name?.trim()?`${t.name} (${t.id})`:t.id;return r`
2292
+ ${e.agents.map(t=>{const n=t.name?.trim()?`${t.name} (${t.id})`:t.id;return c`
2251
2293
  <button
2252
2294
  class="btn btn--sm ${e.selectedScope===t.id?"active":""}"
2253
2295
  @click=${()=>e.onSelectScope(t.id)}
@@ -2257,7 +2299,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2257
2299
  `})}
2258
2300
  </div>
2259
2301
  </div>
2260
- `}function Jf(e){const t=e.selectedScope===Ae,n=e.defaults,s=e.selectedAgent??{},i=t?["defaults"]:["agents",e.selectedScope],a=typeof s.security=="string"?s.security:void 0,o=typeof s.ask=="string"?s.ask:void 0,c=typeof s.askFallback=="string"?s.askFallback:void 0,l=t?n.security:a??"__default__",p=t?n.ask:o??"__default__",d=t?n.askFallback:c??"__default__",u=typeof s.autoAllowSkills=="boolean"?s.autoAllowSkills:void 0,h=u??n.autoAllowSkills,v=u==null;return r`
2302
+ `}function oh(e){const t=e.selectedScope===Ae,n=e.defaults,s=e.selectedAgent??{},i=t?["defaults"]:["agents",e.selectedScope],a=typeof s.security=="string"?s.security:void 0,o=typeof s.ask=="string"?s.ask:void 0,l=typeof s.askFallback=="string"?s.askFallback:void 0,r=t?n.security:a??"__default__",p=t?n.ask:o??"__default__",d=t?n.askFallback:l??"__default__",u=typeof s.autoAllowSkills=="boolean"?s.autoAllowSkills:void 0,g=u??n.autoAllowSkills,v=u==null;return c`
2261
2303
  <div class="list" style="margin-top: 16px;">
2262
2304
  <div class="list-item">
2263
2305
  <div class="list-main">
@@ -2273,12 +2315,12 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2273
2315
  ?disabled=${e.disabled}
2274
2316
  @change=${w=>{const k=w.target.value;!t&&k==="__default__"?e.onRemove([...i,"security"]):e.onPatch([...i,"security"],k)}}
2275
2317
  >
2276
- ${t?g:r`<option value="__default__" ?selected=${l==="__default__"}>
2318
+ ${t?h:c`<option value="__default__" ?selected=${r==="__default__"}>
2277
2319
  Use default (${n.security})
2278
2320
  </option>`}
2279
- ${Ka.map(w=>r`<option
2321
+ ${Ha.map(w=>c`<option
2280
2322
  value=${w.value}
2281
- ?selected=${l===w.value}
2323
+ ?selected=${r===w.value}
2282
2324
  >
2283
2325
  ${w.label}
2284
2326
  </option>`)}
@@ -2301,10 +2343,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2301
2343
  ?disabled=${e.disabled}
2302
2344
  @change=${w=>{const k=w.target.value;!t&&k==="__default__"?e.onRemove([...i,"ask"]):e.onPatch([...i,"ask"],k)}}
2303
2345
  >
2304
- ${t?g:r`<option value="__default__" ?selected=${p==="__default__"}>
2346
+ ${t?h:c`<option value="__default__" ?selected=${p==="__default__"}>
2305
2347
  Use default (${n.ask})
2306
2348
  </option>`}
2307
- ${Uf.map(w=>r`<option
2349
+ ${Gf.map(w=>c`<option
2308
2350
  value=${w.value}
2309
2351
  ?selected=${p===w.value}
2310
2352
  >
@@ -2329,10 +2371,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2329
2371
  ?disabled=${e.disabled}
2330
2372
  @change=${w=>{const k=w.target.value;!t&&k==="__default__"?e.onRemove([...i,"askFallback"]):e.onPatch([...i,"askFallback"],k)}}
2331
2373
  >
2332
- ${t?g:r`<option value="__default__" ?selected=${d==="__default__"}>
2374
+ ${t?h:c`<option value="__default__" ?selected=${d==="__default__"}>
2333
2375
  Use default (${n.askFallback})
2334
2376
  </option>`}
2335
- ${Ka.map(w=>r`<option
2377
+ ${Ha.map(w=>c`<option
2336
2378
  value=${w.value}
2337
2379
  ?selected=${d===w.value}
2338
2380
  >
@@ -2347,7 +2389,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2347
2389
  <div class="list-main">
2348
2390
  <div class="list-title">Auto-allow skill CLIs</div>
2349
2391
  <div class="list-sub">
2350
- ${t?"Allow skill executables listed by the Gateway.":v?`Using default (${n.autoAllowSkills?"on":"off"}).`:`Override (${h?"on":"off"}).`}
2392
+ ${t?"Allow skill executables listed by the Gateway.":v?`Using default (${n.autoAllowSkills?"on":"off"}).`:`Override (${g?"on":"off"}).`}
2351
2393
  </div>
2352
2394
  </div>
2353
2395
  <div class="list-meta">
@@ -2356,21 +2398,21 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2356
2398
  <input
2357
2399
  type="checkbox"
2358
2400
  ?disabled=${e.disabled}
2359
- .checked=${h}
2401
+ .checked=${g}
2360
2402
  @change=${w=>{const $=w.target;e.onPatch([...i,"autoAllowSkills"],$.checked)}}
2361
2403
  />
2362
2404
  </label>
2363
- ${!t&&!v?r`<button
2405
+ ${!t&&!v?c`<button
2364
2406
  class="btn btn--sm"
2365
2407
  ?disabled=${e.disabled}
2366
2408
  @click=${()=>e.onRemove([...i,"autoAllowSkills"])}
2367
2409
  >
2368
2410
  Use default
2369
- </button>`:g}
2411
+ </button>`:h}
2370
2412
  </div>
2371
2413
  </div>
2372
2414
  </div>
2373
- `}function Xf(e){const t=["agents",e.selectedScope,"allowlist"],n=e.allowlist;return r`
2415
+ `}function rh(e){const t=["agents",e.selectedScope,"allowlist"],n=e.allowlist;return c`
2374
2416
  <div class="row" style="margin-top: 18px; justify-content: space-between;">
2375
2417
  <div>
2376
2418
  <div class="card-title">Allowlist</div>
@@ -2385,15 +2427,15 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2385
2427
  </button>
2386
2428
  </div>
2387
2429
  <div class="list" style="margin-top: 12px;">
2388
- ${n.length===0?r`<div class="muted">No allowlist entries yet.</div>`:n.map((s,i)=>eh(e,s,i))}
2430
+ ${n.length===0?c`<div class="muted">No allowlist entries yet.</div>`:n.map((s,i)=>lh(e,s,i))}
2389
2431
  </div>
2390
- `}function eh(e,t,n){const s=t.lastUsedAt?O(t.lastUsedAt):"never",i=t.lastUsedCommand?as(t.lastUsedCommand,120):null,a=t.lastResolvedPath?as(t.lastResolvedPath,120):null;return r`
2432
+ `}function lh(e,t,n){const s=t.lastUsedAt?O(t.lastUsedAt):"never",i=t.lastUsedCommand?os(t.lastUsedCommand,120):null,a=t.lastResolvedPath?os(t.lastResolvedPath,120):null;return c`
2391
2433
  <div class="list-item">
2392
2434
  <div class="list-main">
2393
2435
  <div class="list-title">${t.pattern?.trim()?t.pattern:"New pattern"}</div>
2394
2436
  <div class="list-sub">Last used: ${s}</div>
2395
- ${i?r`<div class="list-sub mono">${i}</div>`:g}
2396
- ${a?r`<div class="list-sub mono">${a}</div>`:g}
2437
+ ${i?c`<div class="list-sub mono">${i}</div>`:h}
2438
+ ${a?c`<div class="list-sub mono">${a}</div>`:h}
2397
2439
  </div>
2398
2440
  <div class="list-meta">
2399
2441
  <label class="field">
@@ -2402,7 +2444,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2402
2444
  type="text"
2403
2445
  .value=${t.pattern??""}
2404
2446
  ?disabled=${e.disabled}
2405
- @input=${o=>{const c=o.target;e.onPatch(["agents",e.selectedScope,"allowlist",n,"pattern"],c.value)}}
2447
+ @input=${o=>{const l=o.target;e.onPatch(["agents",e.selectedScope,"allowlist",n,"pattern"],l.value)}}
2406
2448
  />
2407
2449
  </label>
2408
2450
  <button
@@ -2414,7 +2456,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2414
2456
  </button>
2415
2457
  </div>
2416
2458
  </div>
2417
- `}function th(e,t){const n=e.binding??"__default__",s=e.name?.trim()?`${e.name} (${e.id})`:e.id,i=t.nodes.length>0;return r`
2459
+ `}function ch(e,t){const n=e.binding??"__default__",s=e.name?.trim()?`${e.name} (${e.id})`:e.id,i=t.nodes.length>0;return c`
2418
2460
  <div class="list-item">
2419
2461
  <div class="list-main">
2420
2462
  <div class="list-title">${s}</div>
@@ -2428,12 +2470,12 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2428
2470
  <span>Binding</span>
2429
2471
  <select
2430
2472
  ?disabled=${t.disabled||!i}
2431
- @change=${a=>{const c=a.target.value.trim();t.onBindAgent(e.index,c==="__default__"?null:c)}}
2473
+ @change=${a=>{const l=a.target.value.trim();t.onBindAgent(e.index,l==="__default__"?null:l)}}
2432
2474
  >
2433
2475
  <option value="__default__" ?selected=${n==="__default__"}>
2434
2476
  Use default
2435
2477
  </option>
2436
- ${t.nodes.map(a=>r`<option
2478
+ ${t.nodes.map(a=>c`<option
2437
2479
  value=${a.id}
2438
2480
  ?selected=${n===a.id}
2439
2481
  >
@@ -2443,7 +2485,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2443
2485
  </label>
2444
2486
  </div>
2445
2487
  </div>
2446
- `}function nh(e){const t=[];for(const n of e){if(!(Array.isArray(n.commands)?n.commands:[]).some(c=>String(c)==="system.run"))continue;const a=typeof n.nodeId=="string"?n.nodeId.trim():"";if(!a)continue;const o=typeof n.displayName=="string"&&n.displayName.trim()?n.displayName.trim():a;t.push({id:a,label:o===a?a:`${o} · ${a}`})}return t.sort((n,s)=>n.label.localeCompare(s.label)),t}function sh(e){const t=[];for(const n of e){if(!(Array.isArray(n.commands)?n.commands:[]).some(c=>String(c)==="system.execApprovals.get"||String(c)==="system.execApprovals.set"))continue;const a=typeof n.nodeId=="string"?n.nodeId.trim():"";if(!a)continue;const o=typeof n.displayName=="string"&&n.displayName.trim()?n.displayName.trim():a;t.push({id:a,label:o===a?a:`${o} · ${a}`})}return t.sort((n,s)=>n.label.localeCompare(s.label)),t}function ih(e){const t={id:"main",name:void 0,index:0,isDefault:!0,binding:null};if(!e||typeof e!="object")return{defaultBinding:null,agents:[t]};const s=(e.tools??{}).exec??{},i=typeof s.node=="string"&&s.node.trim()?s.node.trim():null,a=e.agents??{},o=Array.isArray(a.list)?a.list:[];if(o.length===0)return{defaultBinding:i,agents:[t]};const c=[];return o.forEach((l,p)=>{if(!l||typeof l!="object")return;const d=l,u=typeof d.id=="string"?d.id.trim():"";if(!u)return;const h=typeof d.name=="string"?d.name.trim():void 0,v=d.default===!0,$=(d.tools??{}).exec??{},k=typeof $.node=="string"&&$.node.trim()?$.node.trim():null;c.push({id:u,name:h||void 0,index:p,isDefault:v,binding:k})}),c.length===0&&c.push(t),{defaultBinding:i,agents:c}}function ah(e){const t=!!e.connected,n=!!e.paired,s=typeof e.displayName=="string"&&e.displayName.trim()||(typeof e.nodeId=="string"?e.nodeId:"unknown"),i=Array.isArray(e.caps)?e.caps:[],a=Array.isArray(e.commands)?e.commands:[];return r`
2488
+ `}function dh(e){const t=[];for(const n of e){if(!(Array.isArray(n.commands)?n.commands:[]).some(l=>String(l)==="system.run"))continue;const a=typeof n.nodeId=="string"?n.nodeId.trim():"";if(!a)continue;const o=typeof n.displayName=="string"&&n.displayName.trim()?n.displayName.trim():a;t.push({id:a,label:o===a?a:`${o} · ${a}`})}return t.sort((n,s)=>n.label.localeCompare(s.label)),t}function uh(e){const t=[];for(const n of e){if(!(Array.isArray(n.commands)?n.commands:[]).some(l=>String(l)==="system.execApprovals.get"||String(l)==="system.execApprovals.set"))continue;const a=typeof n.nodeId=="string"?n.nodeId.trim():"";if(!a)continue;const o=typeof n.displayName=="string"&&n.displayName.trim()?n.displayName.trim():a;t.push({id:a,label:o===a?a:`${o} · ${a}`})}return t.sort((n,s)=>n.label.localeCompare(s.label)),t}function ph(e){const t={id:"main",name:void 0,index:0,isDefault:!0,binding:null};if(!e||typeof e!="object")return{defaultBinding:null,agents:[t]};const s=(e.tools??{}).exec??{},i=typeof s.node=="string"&&s.node.trim()?s.node.trim():null,a=e.agents??{},o=Array.isArray(a.list)?a.list:[];if(o.length===0)return{defaultBinding:i,agents:[t]};const l=[];return o.forEach((r,p)=>{if(!r||typeof r!="object")return;const d=r,u=typeof d.id=="string"?d.id.trim():"";if(!u)return;const g=typeof d.name=="string"?d.name.trim():void 0,v=d.default===!0,$=(d.tools??{}).exec??{},k=typeof $.node=="string"&&$.node.trim()?$.node.trim():null;l.push({id:u,name:g||void 0,index:p,isDefault:v,binding:k})}),l.length===0&&l.push(t),{defaultBinding:i,agents:l}}function fh(e){const t=!!e.connected,n=!!e.paired,s=typeof e.displayName=="string"&&e.displayName.trim()||(typeof e.nodeId=="string"?e.nodeId:"unknown"),i=Array.isArray(e.caps)?e.caps:[],a=Array.isArray(e.commands)?e.commands:[];return c`
2447
2489
  <div class="list-item">
2448
2490
  <div class="list-main">
2449
2491
  <div class="list-title">${s}</div>
@@ -2457,22 +2499,22 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2457
2499
  <span class="chip ${t?"chip-ok":"chip-warn"}">
2458
2500
  ${t?"connected":"offline"}
2459
2501
  </span>
2460
- ${i.slice(0,12).map(o=>r`<span class="chip">${String(o)}</span>`)}
2461
- ${a.slice(0,8).map(o=>r`<span class="chip">${String(o)}</span>`)}
2502
+ ${i.slice(0,12).map(o=>c`<span class="chip">${String(o)}</span>`)}
2503
+ ${a.slice(0,8).map(o=>c`<span class="chip">${String(o)}</span>`)}
2462
2504
  </div>
2463
2505
  </div>
2464
2506
  </div>
2465
- `}function oh(e){const t=e.hello?.snapshot,n=t?.uptimeMs?io(t.uptimeMs):"n/a",s=t?.policy?.tickIntervalMs?`${t.policy.tickIntervalMs}ms`:"n/a",i=(()=>{if(e.connected||!e.lastError)return null;const o=e.lastError.toLowerCase();if(!(o.includes("unauthorized")||o.includes("connect failed")))return null;const l=!!e.settings.token.trim(),p=!!e.password.trim();return!l&&!p?r`
2507
+ `}function hh(e){const t=e.hello?.snapshot,n=t?.uptimeMs?ao(t.uptimeMs):"n/a",s=t?.policy?.tickIntervalMs?`${t.policy.tickIntervalMs}ms`:"n/a",i=(()=>{if(e.connected||!e.lastError)return null;const o=e.lastError.toLowerCase();if(!(o.includes("unauthorized")||o.includes("connect failed")))return null;const r=!!e.settings.token.trim(),p=!!e.password.trim();return!r&&!p?c`
2466
2508
  <div class="muted" style="margin-top: 8px;">
2467
2509
  This gateway requires auth. Add a token or password, then click Connect.
2468
2510
  <div style="margin-top: 6px;">
2469
- <span class="mono">clawdbot dashboard --no-open</span> → tokenized URL<br />
2470
- <span class="mono">clawdbot doctor --generate-gateway-token</span> → set token
2511
+ <span class="mono">moltbot dashboard --no-open</span> → tokenized URL<br />
2512
+ <span class="mono">moltbot doctor --generate-gateway-token</span> → set token
2471
2513
  </div>
2472
2514
  <div style="margin-top: 6px;">
2473
2515
  <a
2474
2516
  class="session-link"
2475
- href="https://docs.clawd.bot/web/dashboard"
2517
+ href="https://docs.molt.bot/web/dashboard"
2476
2518
  target="_blank"
2477
2519
  rel="noreferrer"
2478
2520
  title="Control UI auth docs (opens in new tab)"
@@ -2480,15 +2522,15 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2480
2522
  >
2481
2523
  </div>
2482
2524
  </div>
2483
- `:r`
2525
+ `:c`
2484
2526
  <div class="muted" style="margin-top: 8px;">
2485
2527
  Auth failed. Re-copy a tokenized URL with
2486
- <span class="mono">clawdbot dashboard --no-open</span>, or update the token,
2528
+ <span class="mono">moltbot dashboard --no-open</span>, or update the token,
2487
2529
  then click Connect.
2488
2530
  <div style="margin-top: 6px;">
2489
2531
  <a
2490
2532
  class="session-link"
2491
- href="https://docs.clawd.bot/web/dashboard"
2533
+ href="https://docs.molt.bot/web/dashboard"
2492
2534
  target="_blank"
2493
2535
  rel="noreferrer"
2494
2536
  title="Control UI auth docs (opens in new tab)"
@@ -2496,7 +2538,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2496
2538
  >
2497
2539
  </div>
2498
2540
  </div>
2499
- `})(),a=(()=>{if(e.connected||!e.lastError||(typeof window<"u"?window.isSecureContext:!0)!==!1)return null;const c=e.lastError.toLowerCase();return!c.includes("secure context")&&!c.includes("device identity required")?null:r`
2541
+ `})(),a=(()=>{if(e.connected||!e.lastError||(typeof window<"u"?window.isSecureContext:!0)!==!1)return null;const l=e.lastError.toLowerCase();return!l.includes("secure context")&&!l.includes("device identity required")?null:c`
2500
2542
  <div class="muted" style="margin-top: 8px;">
2501
2543
  This page is HTTP, so the browser blocks device identity. Use HTTPS (Tailscale Serve) or
2502
2544
  open <span class="mono">http://127.0.0.1:18789</span> on the gateway host.
@@ -2507,7 +2549,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2507
2549
  <div style="margin-top: 6px;">
2508
2550
  <a
2509
2551
  class="session-link"
2510
- href="https://docs.clawd.bot/gateway/tailscale"
2552
+ href="https://docs.molt.bot/gateway/tailscale"
2511
2553
  target="_blank"
2512
2554
  rel="noreferrer"
2513
2555
  title="Tailscale Serve docs (opens in new tab)"
@@ -2516,7 +2558,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2516
2558
  <span class="muted"> · </span>
2517
2559
  <a
2518
2560
  class="session-link"
2519
- href="https://docs.clawd.bot/web/control-ui#insecure-http"
2561
+ href="https://docs.molt.bot/web/control-ui#insecure-http"
2520
2562
  target="_blank"
2521
2563
  rel="noreferrer"
2522
2564
  title="Insecure HTTP docs (opens in new tab)"
@@ -2524,7 +2566,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2524
2566
  >
2525
2567
  </div>
2526
2568
  </div>
2527
- `})();return r`
2569
+ `})();return c`
2528
2570
  <section class="grid grid-cols-2">
2529
2571
  <div class="card">
2530
2572
  <div class="card-title">Gateway Access</div>
@@ -2534,7 +2576,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2534
2576
  <span>WebSocket URL</span>
2535
2577
  <input
2536
2578
  .value=${e.settings.gatewayUrl}
2537
- @input=${o=>{const c=o.target.value;e.onSettingsChange({...e.settings,gatewayUrl:c})}}
2579
+ @input=${o=>{const l=o.target.value;e.onSettingsChange({...e.settings,gatewayUrl:l})}}
2538
2580
  placeholder="ws://100.x.y.z:18789"
2539
2581
  />
2540
2582
  </label>
@@ -2542,7 +2584,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2542
2584
  <span>Gateway Token</span>
2543
2585
  <input
2544
2586
  .value=${e.settings.token}
2545
- @input=${o=>{const c=o.target.value;e.onSettingsChange({...e.settings,token:c})}}
2587
+ @input=${o=>{const l=o.target.value;e.onSettingsChange({...e.settings,token:l})}}
2546
2588
  placeholder="CLAWDBOT_GATEWAY_TOKEN"
2547
2589
  />
2548
2590
  </label>
@@ -2551,7 +2593,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2551
2593
  <input
2552
2594
  type="password"
2553
2595
  .value=${e.password}
2554
- @input=${o=>{const c=o.target.value;e.onPasswordChange(c)}}
2596
+ @input=${o=>{const l=o.target.value;e.onPasswordChange(l)}}
2555
2597
  placeholder="system or shared password"
2556
2598
  />
2557
2599
  </label>
@@ -2559,7 +2601,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2559
2601
  <span>Default Session Key</span>
2560
2602
  <input
2561
2603
  .value=${e.settings.sessionKey}
2562
- @input=${o=>{const c=o.target.value;e.onSessionKeyChange(c)}}
2604
+ @input=${o=>{const l=o.target.value;e.onSessionKeyChange(l)}}
2563
2605
  />
2564
2606
  </label>
2565
2607
  </div>
@@ -2595,11 +2637,11 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2595
2637
  </div>
2596
2638
  </div>
2597
2639
  </div>
2598
- ${e.lastError?r`<div class="callout danger" style="margin-top: 14px;">
2640
+ ${e.lastError?c`<div class="callout danger" style="margin-top: 14px;">
2599
2641
  <div>${e.lastError}</div>
2600
2642
  ${i??""}
2601
2643
  ${a??""}
2602
- </div>`:r`<div class="callout" style="margin-top: 14px;">
2644
+ </div>`:c`<div class="callout" style="margin-top: 14px;">
2603
2645
  Use Channels to link WhatsApp, Telegram, Discord, Signal, or iMessage.
2604
2646
  </div>`}
2605
2647
  </div>
@@ -2621,7 +2663,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2621
2663
  <div class="stat-value">
2622
2664
  ${e.cronEnabled==null?"n/a":e.cronEnabled?"Enabled":"Disabled"}
2623
2665
  </div>
2624
- <div class="muted">Next wake ${gr(e.cronNext)}</div>
2666
+ <div class="muted">Next wake ${vr(e.cronNext)}</div>
2625
2667
  </div>
2626
2668
  </section>
2627
2669
 
@@ -2645,7 +2687,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2645
2687
  </div>
2646
2688
  </div>
2647
2689
  </section>
2648
- `}const rh=["","off","minimal","low","medium","high"],lh=["","off","on"],ch=[{value:"",label:"inherit"},{value:"off",label:"off (explicit)"},{value:"on",label:"on"}],dh=["","off","on","stream"];function uh(e){if(!e)return"";const t=e.trim().toLowerCase();return t==="z.ai"||t==="z-ai"?"zai":t}function vr(e){return uh(e)==="zai"}function ph(e){return vr(e)?lh:rh}function fh(e,t){return!t||!e||e==="off"?e:"on"}function hh(e,t){return e?t&&e==="on"?"low":e:null}function gh(e){const t=e.result?.sessions??[];return r`
2690
+ `}const gh=["","off","minimal","low","medium","high"],vh=["","off","on"],mh=[{value:"",label:"inherit"},{value:"off",label:"off (explicit)"},{value:"on",label:"on"}],yh=["","off","on","stream"];function bh(e){if(!e)return"";const t=e.trim().toLowerCase();return t==="z.ai"||t==="z-ai"?"zai":t}function mr(e){return bh(e)==="zai"}function wh(e){return mr(e)?vh:gh}function $h(e,t){return!t||!e||e==="off"?e:"on"}function xh(e,t){return e?t&&e==="on"?"low":e:null}function kh(e){const t=e.result?.sessions??[];return c`
2649
2691
  <section class="card">
2650
2692
  <div class="row" style="justify-content: space-between;">
2651
2693
  <div>
@@ -2690,7 +2732,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2690
2732
  </label>
2691
2733
  </div>
2692
2734
 
2693
- ${e.error?r`<div class="callout danger" style="margin-top: 12px;">${e.error}</div>`:g}
2735
+ ${e.error?c`<div class="callout danger" style="margin-top: 12px;">${e.error}</div>`:h}
2694
2736
 
2695
2737
  <div class="muted" style="margin-top: 12px;">
2696
2738
  ${e.result?`Store: ${e.result.path}`:""}
@@ -2708,12 +2750,12 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2708
2750
  <div>Reasoning</div>
2709
2751
  <div>Actions</div>
2710
2752
  </div>
2711
- ${t.length===0?r`<div class="muted">No sessions found.</div>`:t.map(n=>vh(n,e.basePath,e.onPatch,e.onDelete,e.loading))}
2753
+ ${t.length===0?c`<div class="muted">No sessions found.</div>`:t.map(n=>Ah(n,e.basePath,e.onPatch,e.onDelete,e.loading))}
2712
2754
  </div>
2713
2755
  </section>
2714
- `}function vh(e,t,n,s,i){const a=e.updatedAt?O(e.updatedAt):"n/a",o=e.thinkingLevel??"",c=vr(e.modelProvider),l=fh(o,c),p=ph(e.modelProvider),d=e.verboseLevel??"",u=e.reasoningLevel??"",h=e.displayName??e.key,v=e.kind!=="global",w=v?`${Rs("chat",t)}?session=${encodeURIComponent(e.key)}`:null;return r`
2756
+ `}function Ah(e,t,n,s,i){const a=e.updatedAt?O(e.updatedAt):"n/a",o=e.thinkingLevel??"",l=mr(e.modelProvider),r=$h(o,l),p=wh(e.modelProvider),d=e.verboseLevel??"",u=e.reasoningLevel??"",g=e.displayName??e.key,v=e.kind!=="global",w=v?`${Ps("chat",t)}?session=${encodeURIComponent(e.key)}`:null;return c`
2715
2757
  <div class="table-row">
2716
- <div class="mono">${v?r`<a href=${w} class="session-link">${h}</a>`:h}</div>
2758
+ <div class="mono">${v?c`<a href=${w} class="session-link">${g}</a>`:g}</div>
2717
2759
  <div>
2718
2760
  <input
2719
2761
  .value=${e.label??""}
@@ -2724,14 +2766,14 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2724
2766
  </div>
2725
2767
  <div>${e.kind}</div>
2726
2768
  <div>${a}</div>
2727
- <div>${bf(e)}</div>
2769
+ <div>${_f(e)}</div>
2728
2770
  <div>
2729
2771
  <select
2730
- .value=${l}
2772
+ .value=${r}
2731
2773
  ?disabled=${i}
2732
- @change=${$=>{const k=$.target.value;n(e.key,{thinkingLevel:hh(k,c)})}}
2774
+ @change=${$=>{const k=$.target.value;n(e.key,{thinkingLevel:xh(k,l)})}}
2733
2775
  >
2734
- ${p.map($=>r`<option value=${$}>${$||"inherit"}</option>`)}
2776
+ ${p.map($=>c`<option value=${$}>${$||"inherit"}</option>`)}
2735
2777
  </select>
2736
2778
  </div>
2737
2779
  <div>
@@ -2740,7 +2782,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2740
2782
  ?disabled=${i}
2741
2783
  @change=${$=>{const k=$.target.value;n(e.key,{verboseLevel:k||null})}}
2742
2784
  >
2743
- ${ch.map($=>r`<option value=${$.value}>${$.label}</option>`)}
2785
+ ${mh.map($=>c`<option value=${$.value}>${$.label}</option>`)}
2744
2786
  </select>
2745
2787
  </div>
2746
2788
  <div>
@@ -2749,7 +2791,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2749
2791
  ?disabled=${i}
2750
2792
  @change=${$=>{const k=$.target.value;n(e.key,{reasoningLevel:k||null})}}
2751
2793
  >
2752
- ${dh.map($=>r`<option value=${$}>${$||"inherit"}</option>`)}
2794
+ ${yh.map($=>c`<option value=${$}>${$||"inherit"}</option>`)}
2753
2795
  </select>
2754
2796
  </div>
2755
2797
  <div>
@@ -2758,7 +2800,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2758
2800
  </button>
2759
2801
  </div>
2760
2802
  </div>
2761
- `}function mh(e){const t=Math.max(0,e),n=Math.floor(t/1e3);if(n<60)return`${n}s`;const s=Math.floor(n/60);return s<60?`${s}m`:`${Math.floor(s/60)}h`}function Ie(e,t){return t?r`<div class="exec-approval-meta-row"><span>${e}</span><span>${t}</span></div>`:g}function bh(e){const t=e.execApprovalQueue[0];if(!t)return g;const n=t.request,s=t.expiresAtMs-Date.now(),i=s>0?`expires in ${mh(s)}`:"expired",a=e.execApprovalQueue.length;return r`
2803
+ `}function Sh(e){const t=Math.max(0,e),n=Math.floor(t/1e3);if(n<60)return`${n}s`;const s=Math.floor(n/60);return s<60?`${s}m`:`${Math.floor(s/60)}h`}function Me(e,t){return t?c`<div class="exec-approval-meta-row"><span>${e}</span><span>${t}</span></div>`:h}function _h(e){const t=e.execApprovalQueue[0];if(!t)return h;const n=t.request,s=t.expiresAtMs-Date.now(),i=s>0?`expires in ${Sh(s)}`:"expired",a=e.execApprovalQueue.length;return c`
2762
2804
  <div class="exec-approval-overlay" role="dialog" aria-live="polite">
2763
2805
  <div class="exec-approval-card">
2764
2806
  <div class="exec-approval-header">
@@ -2766,19 +2808,19 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2766
2808
  <div class="exec-approval-title">Exec approval needed</div>
2767
2809
  <div class="exec-approval-sub">${i}</div>
2768
2810
  </div>
2769
- ${a>1?r`<div class="exec-approval-queue">${a} pending</div>`:g}
2811
+ ${a>1?c`<div class="exec-approval-queue">${a} pending</div>`:h}
2770
2812
  </div>
2771
2813
  <div class="exec-approval-command mono">${n.command}</div>
2772
2814
  <div class="exec-approval-meta">
2773
- ${Ie("Host",n.host)}
2774
- ${Ie("Agent",n.agentId)}
2775
- ${Ie("Session",n.sessionKey)}
2776
- ${Ie("CWD",n.cwd)}
2777
- ${Ie("Resolved",n.resolvedPath)}
2778
- ${Ie("Security",n.security)}
2779
- ${Ie("Ask",n.ask)}
2780
- </div>
2781
- ${e.execApprovalError?r`<div class="exec-approval-error">${e.execApprovalError}</div>`:g}
2815
+ ${Me("Host",n.host)}
2816
+ ${Me("Agent",n.agentId)}
2817
+ ${Me("Session",n.sessionKey)}
2818
+ ${Me("CWD",n.cwd)}
2819
+ ${Me("Resolved",n.resolvedPath)}
2820
+ ${Me("Security",n.security)}
2821
+ ${Me("Ask",n.ask)}
2822
+ </div>
2823
+ ${e.execApprovalError?c`<div class="exec-approval-error">${e.execApprovalError}</div>`:h}
2782
2824
  <div class="exec-approval-actions">
2783
2825
  <button
2784
2826
  class="btn primary"
@@ -2804,7 +2846,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2804
2846
  </div>
2805
2847
  </div>
2806
2848
  </div>
2807
- `}function yh(e){const t=e.report?.skills??[],n=e.filter.trim().toLowerCase(),s=n?t.filter(i=>[i.name,i.description,i.source].join(" ").toLowerCase().includes(n)):t;return r`
2849
+ `}function Th(e){const t=e.report?.skills??[],n=e.filter.trim().toLowerCase(),s=n?t.filter(i=>[i.name,i.description,i.source].join(" ").toLowerCase().includes(n)):t;return c`
2808
2850
  <section class="card">
2809
2851
  <div class="row" style="justify-content: space-between;">
2810
2852
  <div>
@@ -2828,38 +2870,38 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2828
2870
  <div class="muted">${s.length} shown</div>
2829
2871
  </div>
2830
2872
 
2831
- ${e.error?r`<div class="callout danger" style="margin-top: 12px;">${e.error}</div>`:g}
2873
+ ${e.error?c`<div class="callout danger" style="margin-top: 12px;">${e.error}</div>`:h}
2832
2874
 
2833
- ${s.length===0?r`<div class="muted" style="margin-top: 16px;">No skills found.</div>`:r`
2875
+ ${s.length===0?c`<div class="muted" style="margin-top: 16px;">No skills found.</div>`:c`
2834
2876
  <div class="list" style="margin-top: 16px;">
2835
- ${s.map(i=>wh(i,e))}
2877
+ ${s.map(i=>Ch(i,e))}
2836
2878
  </div>
2837
2879
  `}
2838
2880
  </section>
2839
- `}function wh(e,t){const n=t.busyKey===e.skillKey,s=t.edits[e.skillKey]??"",i=t.messages[e.skillKey]??null,a=e.install.length>0&&e.missing.bins.length>0,o=[...e.missing.bins.map(l=>`bin:${l}`),...e.missing.env.map(l=>`env:${l}`),...e.missing.config.map(l=>`config:${l}`),...e.missing.os.map(l=>`os:${l}`)],c=[];return e.disabled&&c.push("disabled"),e.blockedByAllowlist&&c.push("blocked by allowlist"),r`
2881
+ `}function Ch(e,t){const n=t.busyKey===e.skillKey,s=t.edits[e.skillKey]??"",i=t.messages[e.skillKey]??null,a=e.install.length>0&&e.missing.bins.length>0,o=[...e.missing.bins.map(r=>`bin:${r}`),...e.missing.env.map(r=>`env:${r}`),...e.missing.config.map(r=>`config:${r}`),...e.missing.os.map(r=>`os:${r}`)],l=[];return e.disabled&&l.push("disabled"),e.blockedByAllowlist&&l.push("blocked by allowlist"),c`
2840
2882
  <div class="list-item">
2841
2883
  <div class="list-main">
2842
2884
  <div class="list-title">
2843
2885
  ${e.emoji?`${e.emoji} `:""}${e.name}
2844
2886
  </div>
2845
- <div class="list-sub">${as(e.description,140)}</div>
2887
+ <div class="list-sub">${os(e.description,140)}</div>
2846
2888
  <div class="chip-row" style="margin-top: 6px;">
2847
2889
  <span class="chip">${e.source}</span>
2848
2890
  <span class="chip ${e.eligible?"chip-ok":"chip-warn"}">
2849
2891
  ${e.eligible?"eligible":"blocked"}
2850
2892
  </span>
2851
- ${e.disabled?r`<span class="chip chip-warn">disabled</span>`:g}
2893
+ ${e.disabled?c`<span class="chip chip-warn">disabled</span>`:h}
2852
2894
  </div>
2853
- ${o.length>0?r`
2895
+ ${o.length>0?c`
2854
2896
  <div class="muted" style="margin-top: 6px;">
2855
2897
  Missing: ${o.join(", ")}
2856
2898
  </div>
2857
- `:g}
2858
- ${c.length>0?r`
2899
+ `:h}
2900
+ ${l.length>0?c`
2859
2901
  <div class="muted" style="margin-top: 6px;">
2860
- Reason: ${c.join(", ")}
2902
+ Reason: ${l.join(", ")}
2861
2903
  </div>
2862
- `:g}
2904
+ `:h}
2863
2905
  </div>
2864
2906
  <div class="list-meta">
2865
2907
  <div class="row" style="justify-content: flex-end; flex-wrap: wrap;">
@@ -2870,27 +2912,27 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2870
2912
  >
2871
2913
  ${e.disabled?"Enable":"Disable"}
2872
2914
  </button>
2873
- ${a?r`<button
2915
+ ${a?c`<button
2874
2916
  class="btn"
2875
2917
  ?disabled=${n}
2876
2918
  @click=${()=>t.onInstall(e.skillKey,e.name,e.install[0].id)}
2877
2919
  >
2878
2920
  ${n?"Installing…":e.install[0].label}
2879
- </button>`:g}
2921
+ </button>`:h}
2880
2922
  </div>
2881
- ${i?r`<div
2923
+ ${i?c`<div
2882
2924
  class="muted"
2883
2925
  style="margin-top: 8px; color: ${i.kind==="error"?"var(--danger-color, #d14343)":"var(--success-color, #0a7f5a)"};"
2884
2926
  >
2885
2927
  ${i.message}
2886
- </div>`:g}
2887
- ${e.primaryEnv?r`
2928
+ </div>`:h}
2929
+ ${e.primaryEnv?c`
2888
2930
  <div class="field" style="margin-top: 10px;">
2889
2931
  <span>API key</span>
2890
2932
  <input
2891
2933
  type="password"
2892
2934
  .value=${s}
2893
- @input=${l=>t.onEdit(e.skillKey,l.target.value)}
2935
+ @input=${r=>t.onEdit(e.skillKey,r.target.value)}
2894
2936
  />
2895
2937
  </div>
2896
2938
  <button
@@ -2901,29 +2943,29 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2901
2943
  >
2902
2944
  Save key
2903
2945
  </button>
2904
- `:g}
2946
+ `:h}
2905
2947
  </div>
2906
2948
  </div>
2907
- `}function $h(e,t){const n=Rs(t,e.basePath);return r`
2949
+ `}function Eh(e,t){const n=Ps(t,e.basePath);return c`
2908
2950
  <a
2909
2951
  href=${n}
2910
2952
  class="nav-item ${e.tab===t?"active":""}"
2911
2953
  @click=${s=>{s.defaultPrevented||s.button!==0||s.metaKey||s.ctrlKey||s.shiftKey||s.altKey||(s.preventDefault(),e.setTab(t))}}
2912
- title=${ss(t)}
2954
+ title=${is(t)}
2913
2955
  >
2914
- <span class="nav-item__icon" aria-hidden="true">${Q[vl(t)]}</span>
2915
- <span class="nav-item__text">${ss(t)}</span>
2956
+ <span class="nav-item__icon" aria-hidden="true">${V[ml(t)]}</span>
2957
+ <span class="nav-item__text">${is(t)}</span>
2916
2958
  </a>
2917
- `}function xh(e){const t=kh(e.sessionKey,e.sessionsResult),n=e.onboarding,s=e.onboarding,i=e.onboarding?!1:e.settings.chatShowThinking,a=e.onboarding?!0:e.settings.chatFocusMode,o=r`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"></path><path d="M21 3v5h-5"></path></svg>`,c=r`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 7V4h3"></path><path d="M20 7V4h-3"></path><path d="M4 17v3h3"></path><path d="M20 17v3h-3"></path><circle cx="12" cy="12" r="3"></circle></svg>`;return r`
2959
+ `}function Lh(e){const t=Ih(e.sessionKey,e.sessionsResult),n=e.onboarding,s=e.onboarding,i=e.onboarding?!1:e.settings.chatShowThinking,a=e.onboarding?!0:e.settings.chatFocusMode,o=c`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"></path><path d="M21 3v5h-5"></path></svg>`,l=c`<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 7V4h3"></path><path d="M20 7V4h-3"></path><path d="M4 17v3h3"></path><path d="M20 17v3h-3"></path><circle cx="12" cy="12" r="3"></circle></svg>`;return c`
2918
2960
  <div class="chat-controls">
2919
2961
  <label class="field chat-controls__session">
2920
2962
  <select
2921
2963
  .value=${e.sessionKey}
2922
2964
  ?disabled=${!e.connected}
2923
- @change=${l=>{const p=l.target.value;e.sessionKey=p,e.chatMessage="",e.chatStream=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:p,lastActiveSessionKey:p}),e.loadAssistantIdentity(),hd(e,p),Xe(e)}}
2965
+ @change=${r=>{const p=r.target.value;e.sessionKey=p,e.chatMessage="",e.chatStream=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:p,lastActiveSessionKey:p}),e.loadAssistantIdentity(),md(e,p),Xe(e)}}
2924
2966
  >
2925
- ${Ho(t,l=>l.key,l=>r`<option value=${l.key}>
2926
- ${l.displayName??l.key}
2967
+ ${zo(t,r=>r.key,r=>c`<option value=${r.key}>
2968
+ ${r.displayName??r.key}
2927
2969
  </option>`)}
2928
2970
  </select>
2929
2971
  </label>
@@ -2943,7 +2985,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2943
2985
  aria-pressed=${i}
2944
2986
  title=${n?"Disabled during onboarding":"Toggle assistant thinking/working output"}
2945
2987
  >
2946
- ${Q.brain}
2988
+ ${V.brain}
2947
2989
  </button>
2948
2990
  <button
2949
2991
  class="btn btn--sm btn--icon ${a?"active":""}"
@@ -2952,10 +2994,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2952
2994
  aria-pressed=${a}
2953
2995
  title=${s?"Disabled during onboarding":"Toggle focus mode (hide sidebar + page header)"}
2954
2996
  >
2955
- ${c}
2997
+ ${l}
2956
2998
  </button>
2957
2999
  </div>
2958
- `}function kh(e,t){const n=new Set,s=[],i=t?.sessions?.find(a=>a.key===e);if(n.add(e),s.push({key:e,displayName:i?.displayName}),t?.sessions)for(const a of t.sessions)n.has(a.key)||(n.add(a.key),s.push({key:a.key,displayName:a.displayName}));return s}const Ah=["system","light","dark"];function Sh(e){const t=Math.max(0,Ah.indexOf(e.theme)),n=s=>i=>{const o={element:i.currentTarget};(i.clientX||i.clientY)&&(o.pointerClientX=i.clientX,o.pointerClientY=i.clientY),e.setTheme(s,o)};return r`
3000
+ `}function Ih(e,t){const n=new Set,s=[],i=t?.sessions?.find(a=>a.key===e);if(n.add(e),s.push({key:e,displayName:i?.displayName}),t?.sessions)for(const a of t.sessions)n.has(a.key)||(n.add(a.key),s.push({key:a.key,displayName:a.displayName}));return s}const Mh=["system","light","dark"];function Rh(e){const t=Math.max(0,Mh.indexOf(e.theme)),n=s=>i=>{const o={element:i.currentTarget};(i.clientX||i.clientY)&&(o.pointerClientX=i.clientX,o.pointerClientY=i.clientY),e.setTheme(s,o)};return c`
2959
3001
  <div class="theme-toggle" style="--theme-index: ${t};">
2960
3002
  <div class="theme-toggle__track" role="group" aria-label="Theme">
2961
3003
  <span class="theme-toggle__indicator"></span>
@@ -2966,7 +3008,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2966
3008
  aria-label="System theme"
2967
3009
  title="System"
2968
3010
  >
2969
- ${Ch()}
3011
+ ${Oh()}
2970
3012
  </button>
2971
3013
  <button
2972
3014
  class="theme-toggle__button ${e.theme==="light"?"active":""}"
@@ -2975,7 +3017,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2975
3017
  aria-label="Light theme"
2976
3018
  title="Light"
2977
3019
  >
2978
- ${_h()}
3020
+ ${Ph()}
2979
3021
  </button>
2980
3022
  <button
2981
3023
  class="theme-toggle__button ${e.theme==="dark"?"active":""}"
@@ -2984,11 +3026,11 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2984
3026
  aria-label="Dark theme"
2985
3027
  title="Dark"
2986
3028
  >
2987
- ${Th()}
3029
+ ${Nh()}
2988
3030
  </button>
2989
3031
  </div>
2990
3032
  </div>
2991
- `}function _h(){return r`
3033
+ `}function Ph(){return c`
2992
3034
  <svg class="theme-icon" viewBox="0 0 24 24" aria-hidden="true">
2993
3035
  <circle cx="12" cy="12" r="4"></circle>
2994
3036
  <path d="M12 2v2"></path>
@@ -3000,19 +3042,19 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
3000
3042
  <path d="m6.34 17.66-1.41 1.41"></path>
3001
3043
  <path d="m19.07 4.93-1.41 1.41"></path>
3002
3044
  </svg>
3003
- `}function Th(){return r`
3045
+ `}function Nh(){return c`
3004
3046
  <svg class="theme-icon" viewBox="0 0 24 24" aria-hidden="true">
3005
3047
  <path
3006
3048
  d="M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"
3007
3049
  ></path>
3008
3050
  </svg>
3009
- `}function Ch(){return r`
3051
+ `}function Oh(){return c`
3010
3052
  <svg class="theme-icon" viewBox="0 0 24 24" aria-hidden="true">
3011
3053
  <rect width="20" height="14" x="2" y="3" rx="2"></rect>
3012
3054
  <line x1="8" x2="16" y1="21" y2="21"></line>
3013
3055
  <line x1="12" x2="12" y1="17" y2="21"></line>
3014
3056
  </svg>
3015
- `}const Eh=/^data:/i,Lh=/^https?:\/\//i;function Mh(e){const t=e.agentsList?.agents??[],s=eo(e.sessionKey)?.agentId??e.agentsList?.defaultId??"main",a=t.find(c=>c.id===s)?.identity,o=a?.avatarUrl??a?.avatar;if(o)return Eh.test(o)||Lh.test(o)?o:a?.avatarUrl}function Ih(e){const t=e.presenceEntries.length,n=e.sessionsResult?.count??null,s=e.cronStatus?.nextWakeAtMs??null,i=e.connected?null:"Disconnected from gateway.",a=e.tab==="chat",o=a&&(e.settings.chatFocusMode||e.onboarding),c=e.onboarding?!1:e.settings.chatShowThinking,l=Mh(e),p=e.chatAvatarUrl??l??null;return r`
3057
+ `}const Dh=/^data:/i,Bh=/^https?:\/\//i;function Fh(e){const t=e.agentsList?.agents??[],s=to(e.sessionKey)?.agentId??e.agentsList?.defaultId??"main",a=t.find(l=>l.id===s)?.identity,o=a?.avatarUrl??a?.avatar;if(o)return Dh.test(o)||Bh.test(o)?o:a?.avatarUrl}function Uh(e){const t=e.presenceEntries.length,n=e.sessionsResult?.count??null,s=e.cronStatus?.nextWakeAtMs??null,i=e.connected?null:"Disconnected from gateway.",a=e.tab==="chat",o=a&&(e.settings.chatFocusMode||e.onboarding),l=e.onboarding?!1:e.settings.chatShowThinking,r=Fh(e),p=e.chatAvatarUrl??r??null;return c`
3016
3058
  <div class="shell ${a?"shell--chat":""} ${o?"shell--chat-focus":""} ${e.settings.navCollapsed?"shell--nav-collapsed":""} ${e.onboarding?"shell--onboarding":""}">
3017
3059
  <header class="topbar">
3018
3060
  <div class="topbar-left">
@@ -3022,14 +3064,14 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
3022
3064
  title="${e.settings.navCollapsed?"Expand sidebar":"Collapse sidebar"}"
3023
3065
  aria-label="${e.settings.navCollapsed?"Expand sidebar":"Collapse sidebar"}"
3024
3066
  >
3025
- <span class="nav-collapse-toggle__icon">${Q.menu}</span>
3067
+ <span class="nav-collapse-toggle__icon">${V.menu}</span>
3026
3068
  </button>
3027
3069
  <div class="brand">
3028
3070
  <div class="brand-logo">
3029
- <img src="https://mintcdn.com/clawdhub/4rYvG-uuZrMK_URE/assets/pixel-lobster.svg?fit=max&auto=format&n=4rYvG-uuZrMK_URE&q=85&s=da2032e9eac3b5d9bfe7eb96ca6a8a26" alt="Clawdbot" />
3071
+ <img src="https://mintcdn.com/clawdhub/4rYvG-uuZrMK_URE/assets/pixel-lobster.svg?fit=max&auto=format&n=4rYvG-uuZrMK_URE&q=85&s=da2032e9eac3b5d9bfe7eb96ca6a8a26" alt="Moltbot" />
3030
3072
  </div>
3031
3073
  <div class="brand-text">
3032
- <div class="brand-title">CLAWDBOT</div>
3074
+ <div class="brand-title">MOLTBOT</div>
3033
3075
  <div class="brand-sub">Gateway Dashboard</div>
3034
3076
  </div>
3035
3077
  </div>
@@ -3040,12 +3082,12 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
3040
3082
  <span>Health</span>
3041
3083
  <span class="mono">${e.connected?"OK":"Offline"}</span>
3042
3084
  </div>
3043
- ${Sh(e)}
3085
+ ${Rh(e)}
3044
3086
  </div>
3045
3087
  </header>
3046
3088
  <aside class="nav ${e.settings.navCollapsed?"nav--collapsed":""}">
3047
- ${hl.map(d=>{const u=e.settings.navGroupsCollapsed[d.label]??!1,h=d.tabs.some(v=>v===e.tab);return r`
3048
- <div class="nav-group ${u&&!h?"nav-group--collapsed":""}">
3089
+ ${gl.map(d=>{const u=e.settings.navGroupsCollapsed[d.label]??!1,g=d.tabs.some(v=>v===e.tab);return c`
3090
+ <div class="nav-group ${u&&!g?"nav-group--collapsed":""}">
3049
3091
  <button
3050
3092
  class="nav-label"
3051
3093
  @click=${()=>{const v={...e.settings.navGroupsCollapsed};v[d.label]=!u,e.applySettings({...e.settings,navGroupsCollapsed:v})}}
@@ -3055,7 +3097,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
3055
3097
  <span class="nav-label__chevron">${u?"+":"−"}</span>
3056
3098
  </button>
3057
3099
  <div class="nav-group__items">
3058
- ${d.tabs.map(v=>$h(e,v))}
3100
+ ${d.tabs.map(v=>Eh(e,v))}
3059
3101
  </div>
3060
3102
  </div>
3061
3103
  `})}
@@ -3066,12 +3108,12 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
3066
3108
  <div class="nav-group__items">
3067
3109
  <a
3068
3110
  class="nav-item nav-item--external"
3069
- href="https://docs.clawd.bot"
3111
+ href="https://docs.molt.bot"
3070
3112
  target="_blank"
3071
3113
  rel="noreferrer"
3072
3114
  title="Docs (opens in new tab)"
3073
3115
  >
3074
- <span class="nav-item__icon" aria-hidden="true">${Q.book}</span>
3116
+ <span class="nav-item__icon" aria-hidden="true">${V.book}</span>
3075
3117
  <span class="nav-item__text">Docs</span>
3076
3118
  </a>
3077
3119
  </div>
@@ -3080,40 +3122,40 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
3080
3122
  <main class="content ${a?"content--chat":""}">
3081
3123
  <section class="content-header">
3082
3124
  <div>
3083
- <div class="page-title">${ss(e.tab)}</div>
3084
- <div class="page-sub">${ml(e.tab)}</div>
3125
+ <div class="page-title">${is(e.tab)}</div>
3126
+ <div class="page-sub">${yl(e.tab)}</div>
3085
3127
  </div>
3086
3128
  <div class="page-meta">
3087
- ${e.lastError?r`<div class="pill danger">${e.lastError}</div>`:g}
3088
- ${a?xh(e):g}
3129
+ ${e.lastError?c`<div class="pill danger">${e.lastError}</div>`:h}
3130
+ ${a?Lh(e):h}
3089
3131
  </div>
3090
3132
  </section>
3091
3133
 
3092
- ${e.tab==="overview"?oh({connected:e.connected,hello:e.hello,settings:e.settings,password:e.password,lastError:e.lastError,presenceCount:t,sessionsCount:n,cronEnabled:e.cronStatus?.enabled??null,cronNext:s,lastChannelsRefresh:e.channelsLastSuccess,onSettingsChange:d=>e.applySettings(d),onPasswordChange:d=>e.password=d,onSessionKeyChange:d=>{e.sessionKey=d,e.chatMessage="",e.resetToolStream(),e.applySettings({...e.settings,sessionKey:d,lastActiveSessionKey:d}),e.loadAssistantIdentity()},onConnect:()=>e.connect(),onRefresh:()=>e.loadOverview()}):g}
3134
+ ${e.tab==="overview"?hh({connected:e.connected,hello:e.hello,settings:e.settings,password:e.password,lastError:e.lastError,presenceCount:t,sessionsCount:n,cronEnabled:e.cronStatus?.enabled??null,cronNext:s,lastChannelsRefresh:e.channelsLastSuccess,onSettingsChange:d=>e.applySettings(d),onPasswordChange:d=>e.password=d,onSessionKeyChange:d=>{e.sessionKey=d,e.chatMessage="",e.resetToolStream(),e.applySettings({...e.settings,sessionKey:d,lastActiveSessionKey:d}),e.loadAssistantIdentity()},onConnect:()=>e.connect(),onRefresh:()=>e.loadOverview()}):h}
3093
3135
 
3094
- ${e.tab==="channels"?of({connected:e.connected,loading:e.channelsLoading,snapshot:e.channelsSnapshot,lastError:e.channelsError,lastSuccessAt:e.channelsLastSuccess,whatsappMessage:e.whatsappLoginMessage,whatsappQrDataUrl:e.whatsappLoginQrDataUrl,whatsappConnected:e.whatsappLoginConnected,whatsappBusy:e.whatsappBusy,configSchema:e.configSchema,configSchemaLoading:e.configSchemaLoading,configForm:e.configForm,configUiHints:e.configUiHints,configSaving:e.configSaving,configFormDirty:e.configFormDirty,nostrProfileFormState:e.nostrProfileFormState,nostrProfileAccountId:e.nostrProfileAccountId,onRefresh:d=>oe(e,d),onWhatsAppStart:d=>e.handleWhatsAppStart(d),onWhatsAppWait:()=>e.handleWhatsAppWait(),onWhatsAppLogout:()=>e.handleWhatsAppLogout(),onConfigPatch:(d,u)=>Bt(e,d,u),onConfigSave:()=>e.handleChannelConfigSave(),onConfigReload:()=>e.handleChannelConfigReload(),onNostrProfileEdit:(d,u)=>e.handleNostrProfileEdit(d,u),onNostrProfileCancel:()=>e.handleNostrProfileCancel(),onNostrProfileFieldChange:(d,u)=>e.handleNostrProfileFieldChange(d,u),onNostrProfileSave:()=>e.handleNostrProfileSave(),onNostrProfileImport:()=>e.handleNostrProfileImport(),onNostrProfileToggleAdvanced:()=>e.handleNostrProfileToggleAdvanced()}):g}
3136
+ ${e.tab==="channels"?hf({connected:e.connected,loading:e.channelsLoading,snapshot:e.channelsSnapshot,lastError:e.channelsError,lastSuccessAt:e.channelsLastSuccess,whatsappMessage:e.whatsappLoginMessage,whatsappQrDataUrl:e.whatsappLoginQrDataUrl,whatsappConnected:e.whatsappLoginConnected,whatsappBusy:e.whatsappBusy,configSchema:e.configSchema,configSchemaLoading:e.configSchemaLoading,configForm:e.configForm,configUiHints:e.configUiHints,configSaving:e.configSaving,configFormDirty:e.configFormDirty,nostrProfileFormState:e.nostrProfileFormState,nostrProfileAccountId:e.nostrProfileAccountId,onRefresh:d=>oe(e,d),onWhatsAppStart:d=>e.handleWhatsAppStart(d),onWhatsAppWait:()=>e.handleWhatsAppWait(),onWhatsAppLogout:()=>e.handleWhatsAppLogout(),onConfigPatch:(d,u)=>Bt(e,d,u),onConfigSave:()=>e.handleChannelConfigSave(),onConfigReload:()=>e.handleChannelConfigReload(),onNostrProfileEdit:(d,u)=>e.handleNostrProfileEdit(d,u),onNostrProfileCancel:()=>e.handleNostrProfileCancel(),onNostrProfileFieldChange:(d,u)=>e.handleNostrProfileFieldChange(d,u),onNostrProfileSave:()=>e.handleNostrProfileSave(),onNostrProfileImport:()=>e.handleNostrProfileImport(),onNostrProfileToggleAdvanced:()=>e.handleNostrProfileToggleAdvanced()}):h}
3095
3137
 
3096
- ${e.tab==="instances"?Lf({loading:e.presenceLoading,entries:e.presenceEntries,lastError:e.presenceError,statusMessage:e.presenceStatus,onRefresh:()=>js(e)}):g}
3138
+ ${e.tab==="instances"?Bf({loading:e.presenceLoading,entries:e.presenceEntries,lastError:e.presenceError,statusMessage:e.presenceStatus,onRefresh:()=>js(e)}):h}
3097
3139
 
3098
- ${e.tab==="sessions"?gh({loading:e.sessionsLoading,result:e.sessionsResult,error:e.sessionsError,activeMinutes:e.sessionsFilterActive,limit:e.sessionsFilterLimit,includeGlobal:e.sessionsIncludeGlobal,includeUnknown:e.sessionsIncludeUnknown,basePath:e.basePath,onFiltersChange:d=>{e.sessionsFilterActive=d.activeMinutes,e.sessionsFilterLimit=d.limit,e.sessionsIncludeGlobal=d.includeGlobal,e.sessionsIncludeUnknown=d.includeUnknown},onRefresh:()=>st(e),onPatch:(d,u)=>Ml(e,d,u),onDelete:d=>Il(e,d)}):g}
3140
+ ${e.tab==="sessions"?kh({loading:e.sessionsLoading,result:e.sessionsResult,error:e.sessionsError,activeMinutes:e.sessionsFilterActive,limit:e.sessionsFilterLimit,includeGlobal:e.sessionsIncludeGlobal,includeUnknown:e.sessionsIncludeUnknown,basePath:e.basePath,onFiltersChange:d=>{e.sessionsFilterActive=d.activeMinutes,e.sessionsFilterLimit=d.limit,e.sessionsIncludeGlobal=d.includeGlobal,e.sessionsIncludeUnknown=d.includeUnknown},onRefresh:()=>st(e),onPatch:(d,u)=>Pl(e,d,u),onDelete:d=>Nl(e,d)}):h}
3099
3141
 
3100
- ${e.tab==="cron"?Sf({loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:e.channelsSnapshot?.channelMeta?.length?e.channelsSnapshot.channelMeta.map(d=>d.id):e.channelsSnapshot?.channelOrder??[],channelLabels:e.channelsSnapshot?.channelLabels??{},channelMeta:e.channelsSnapshot?.channelMeta??[],runsJobId:e.cronRunsJobId,runs:e.cronRuns,onFormChange:d=>e.cronForm={...e.cronForm,...d},onRefresh:()=>e.loadCron(),onAdd:()=>ec(e),onToggle:(d,u)=>tc(e,d,u),onRun:d=>nc(e,d),onRemove:d=>sc(e,d),onLoadRuns:d=>po(e,d)}):g}
3142
+ ${e.tab==="cron"?Rf({loading:e.cronLoading,status:e.cronStatus,jobs:e.cronJobs,error:e.cronError,busy:e.cronBusy,form:e.cronForm,channels:e.channelsSnapshot?.channelMeta?.length?e.channelsSnapshot.channelMeta.map(d=>d.id):e.channelsSnapshot?.channelOrder??[],channelLabels:e.channelsSnapshot?.channelLabels??{},channelMeta:e.channelsSnapshot?.channelMeta??[],runsJobId:e.cronRunsJobId,runs:e.cronRuns,onFormChange:d=>e.cronForm={...e.cronForm,...d},onRefresh:()=>e.loadCron(),onAdd:()=>sc(e),onToggle:(d,u)=>ic(e,d,u),onRun:d=>ac(e,d),onRemove:d=>oc(e,d),onLoadRuns:d=>fo(e,d)}):h}
3101
3143
 
3102
- ${e.tab==="skills"?yh({loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,onFilterChange:d=>e.skillsFilter=d,onRefresh:()=>Ct(e,{clearMessages:!0}),onToggle:(d,u)=>Zc(e,d,u),onEdit:(d,u)=>Qc(e,d,u),onSaveKey:d=>Jc(e,d),onInstall:(d,u,h)=>Xc(e,d,u,h)}):g}
3144
+ ${e.tab==="skills"?Th({loading:e.skillsLoading,report:e.skillsReport,error:e.skillsError,filter:e.skillsFilter,edits:e.skillEdits,messages:e.skillMessages,busyKey:e.skillsBusyKey,onFilterChange:d=>e.skillsFilter=d,onRefresh:()=>Ct(e,{clearMessages:!0}),onToggle:(d,u)=>ed(e,d,u),onEdit:(d,u)=>Xc(e,d,u),onSaveKey:d=>td(e,d),onInstall:(d,u,g)=>nd(e,d,u,g)}):h}
3103
3145
 
3104
- ${e.tab==="nodes"?Nf({loading:e.nodesLoading,nodes:e.nodes,devicesLoading:e.devicesLoading,devicesError:e.devicesError,devicesList:e.devicesList,configForm:e.configForm??e.configSnapshot?.config,configLoading:e.configLoading,configSaving:e.configSaving,configDirty:e.configFormDirty,configFormMode:e.configFormMode,execApprovalsLoading:e.execApprovalsLoading,execApprovalsSaving:e.execApprovalsSaving,execApprovalsDirty:e.execApprovalsDirty,execApprovalsSnapshot:e.execApprovalsSnapshot,execApprovalsForm:e.execApprovalsForm,execApprovalsSelectedAgent:e.execApprovalsSelectedAgent,execApprovalsTarget:e.execApprovalsTarget,execApprovalsTargetNodeId:e.execApprovalsTargetNodeId,onRefresh:()=>pn(e),onDevicesRefresh:()=>Te(e),onDeviceApprove:d=>Uc(e,d),onDeviceReject:d=>Kc(e,d),onDeviceRotate:(d,u,h)=>Hc(e,{deviceId:d,role:u,scopes:h}),onDeviceRevoke:(d,u)=>zc(e,{deviceId:d,role:u}),onLoadConfig:()=>be(e),onLoadExecApprovals:()=>{const d=e.execApprovalsTarget==="node"&&e.execApprovalsTargetNodeId?{kind:"node",nodeId:e.execApprovalsTargetNodeId}:{kind:"gateway"};return zs(e,d)},onBindDefault:d=>{d?Bt(e,["tools","exec","node"],d):Zi(e,["tools","exec","node"])},onBindAgent:(d,u)=>{const h=["agents","list",d,"tools","exec","node"];u?Bt(e,h,u):Zi(e,h)},onSaveBindings:()=>ls(e),onExecApprovalsTargetChange:(d,u)=>{e.execApprovalsTarget=d,e.execApprovalsTargetNodeId=u,e.execApprovalsSnapshot=null,e.execApprovalsForm=null,e.execApprovalsDirty=!1,e.execApprovalsSelectedAgent=null},onExecApprovalsSelectAgent:d=>{e.execApprovalsSelectedAgent=d},onExecApprovalsPatch:(d,u)=>Gc(e,d,u),onExecApprovalsRemove:d=>Yc(e,d),onSaveExecApprovals:()=>{const d=e.execApprovalsTarget==="node"&&e.execApprovalsTargetNodeId?{kind:"node",nodeId:e.execApprovalsTargetNodeId}:{kind:"gateway"};return Wc(e,d)}}):g}
3146
+ ${e.tab==="nodes"?zf({loading:e.nodesLoading,nodes:e.nodes,devicesLoading:e.devicesLoading,devicesError:e.devicesError,devicesList:e.devicesList,configForm:e.configForm??e.configSnapshot?.config,configLoading:e.configLoading,configSaving:e.configSaving,configDirty:e.configFormDirty,configFormMode:e.configFormMode,execApprovalsLoading:e.execApprovalsLoading,execApprovalsSaving:e.execApprovalsSaving,execApprovalsDirty:e.execApprovalsDirty,execApprovalsSnapshot:e.execApprovalsSnapshot,execApprovalsForm:e.execApprovalsForm,execApprovalsSelectedAgent:e.execApprovalsSelectedAgent,execApprovalsTarget:e.execApprovalsTarget,execApprovalsTargetNodeId:e.execApprovalsTargetNodeId,onRefresh:()=>fn(e),onDevicesRefresh:()=>Te(e),onDeviceApprove:d=>zc(e,d),onDeviceReject:d=>jc(e,d),onDeviceRotate:(d,u,g)=>qc(e,{deviceId:d,role:u,scopes:g}),onDeviceRevoke:(d,u)=>Wc(e,{deviceId:d,role:u}),onLoadConfig:()=>ye(e),onLoadExecApprovals:()=>{const d=e.execApprovalsTarget==="node"&&e.execApprovalsTargetNodeId?{kind:"node",nodeId:e.execApprovalsTargetNodeId}:{kind:"gateway"};return zs(e,d)},onBindDefault:d=>{d?Bt(e,["tools","exec","node"],d):Ji(e,["tools","exec","node"])},onBindAgent:(d,u)=>{const g=["agents","list",d,"tools","exec","node"];u?Bt(e,g,u):Ji(e,g)},onSaveBindings:()=>cs(e),onExecApprovalsTargetChange:(d,u)=>{e.execApprovalsTarget=d,e.execApprovalsTargetNodeId=u,e.execApprovalsSnapshot=null,e.execApprovalsForm=null,e.execApprovalsDirty=!1,e.execApprovalsSelectedAgent=null},onExecApprovalsSelectAgent:d=>{e.execApprovalsSelectedAgent=d},onExecApprovalsPatch:(d,u)=>Zc(e,d,u),onExecApprovalsRemove:d=>Jc(e,d),onSaveExecApprovals:()=>{const d=e.execApprovalsTarget==="node"&&e.execApprovalsTargetNodeId?{kind:"node",nodeId:e.execApprovalsTargetNodeId}:{kind:"gateway"};return Qc(e,d)}}):h}
3105
3147
 
3106
- ${e.tab==="chat"?kp({sessionKey:e.sessionKey,onSessionKeyChange:d=>{e.sessionKey=d,e.chatMessage="",e.chatStream=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:d,lastActiveSessionKey:d}),e.loadAssistantIdentity(),Xe(e),fs(e)},thinkingLevel:e.chatThinkingLevel,showThinking:c,loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:p,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,draft:e.chatMessage,queue:e.chatQueue,connected:e.connected,canSend:e.connected,disabledReason:i,error:e.lastError,sessions:e.sessionsResult,focusMode:o,onRefresh:()=>(e.resetToolStream(),Promise.all([Xe(e),fs(e)])),onToggleFocusMode:()=>{e.onboarding||e.applySettings({...e.settings,chatFocusMode:!e.settings.chatFocusMode})},onChatScroll:d=>e.handleChatScroll(d),onDraftChange:d=>e.chatMessage=d,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:d=>e.removeQueuedMessage(d),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:d=>e.handleOpenSidebar(d),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:d=>e.handleSplitRatioChange(d),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar}):g}
3148
+ ${e.tab==="chat"?Ip({sessionKey:e.sessionKey,onSessionKeyChange:d=>{e.sessionKey=d,e.chatMessage="",e.chatAttachments=[],e.chatStream=null,e.chatStreamStartedAt=null,e.chatRunId=null,e.chatQueue=[],e.resetToolStream(),e.resetChatScroll(),e.applySettings({...e.settings,sessionKey:d,lastActiveSessionKey:d}),e.loadAssistantIdentity(),Xe(e),hs(e)},thinkingLevel:e.chatThinkingLevel,showThinking:l,loading:e.chatLoading,sending:e.chatSending,compactionStatus:e.compactionStatus,assistantAvatarUrl:p,messages:e.chatMessages,toolMessages:e.chatToolMessages,stream:e.chatStream,streamStartedAt:e.chatStreamStartedAt,draft:e.chatMessage,queue:e.chatQueue,connected:e.connected,canSend:e.connected,disabledReason:i,error:e.lastError,sessions:e.sessionsResult,focusMode:o,onRefresh:()=>(e.resetToolStream(),Promise.all([Xe(e),hs(e)])),onToggleFocusMode:()=>{e.onboarding||e.applySettings({...e.settings,chatFocusMode:!e.settings.chatFocusMode})},onChatScroll:d=>e.handleChatScroll(d),onDraftChange:d=>e.chatMessage=d,attachments:e.chatAttachments,onAttachmentsChange:d=>e.chatAttachments=d,onSend:()=>e.handleSendChat(),canAbort:!!e.chatRunId,onAbort:()=>{e.handleAbortChat()},onQueueRemove:d=>e.removeQueuedMessage(d),onNewSession:()=>e.handleSendChat("/new",{restoreDraft:!0}),sidebarOpen:e.sidebarOpen,sidebarContent:e.sidebarContent,sidebarError:e.sidebarError,splitRatio:e.splitRatio,onOpenSidebar:d=>e.handleOpenSidebar(d),onCloseSidebar:()=>e.handleCloseSidebar(),onSplitRatioChange:d=>e.handleSplitRatioChange(d),assistantName:e.assistantName,assistantAvatar:e.assistantAvatar}):h}
3107
3149
 
3108
- ${e.tab==="config"?Kp({raw:e.configRaw,originalRaw:e.configRawOriginal,valid:e.configValid,issues:e.configIssues,loading:e.configLoading,saving:e.configSaving,applying:e.configApplying,updating:e.updateRunning,connected:e.connected,schema:e.configSchema,schemaLoading:e.configSchemaLoading,uiHints:e.configUiHints,formMode:e.configFormMode,formValue:e.configForm,originalValue:e.configFormOriginal,searchQuery:e.configSearchQuery,activeSection:e.configActiveSection,activeSubsection:e.configActiveSubsection,onRawChange:d=>{e.configRaw=d},onFormModeChange:d=>e.configFormMode=d,onFormPatch:(d,u)=>Bt(e,d,u),onSearchChange:d=>e.configSearchQuery=d,onSectionChange:d=>{e.configActiveSection=d,e.configActiveSubsection=null},onSubsectionChange:d=>e.configActiveSubsection=d,onReload:()=>be(e),onSave:()=>ls(e),onApply:()=>Ql(e),onUpdate:()=>Zl(e)}):g}
3150
+ ${e.tab==="config"?Yp({raw:e.configRaw,originalRaw:e.configRawOriginal,valid:e.configValid,issues:e.configIssues,loading:e.configLoading,saving:e.configSaving,applying:e.configApplying,updating:e.updateRunning,connected:e.connected,schema:e.configSchema,schemaLoading:e.configSchemaLoading,uiHints:e.configUiHints,formMode:e.configFormMode,formValue:e.configForm,originalValue:e.configFormOriginal,searchQuery:e.configSearchQuery,activeSection:e.configActiveSection,activeSubsection:e.configActiveSubsection,onRawChange:d=>{e.configRaw=d},onFormModeChange:d=>e.configFormMode=d,onFormPatch:(d,u)=>Bt(e,d,u),onSearchChange:d=>e.configSearchQuery=d,onSectionChange:d=>{e.configActiveSection=d,e.configActiveSubsection=null},onSubsectionChange:d=>e.configActiveSubsection=d,onReload:()=>ye(e),onSave:()=>cs(e),onApply:()=>Xl(e),onUpdate:()=>ec(e)}):h}
3109
3151
 
3110
- ${e.tab==="debug"?Ef({loading:e.debugLoading,status:e.debugStatus,health:e.debugHealth,models:e.debugModels,heartbeat:e.debugHeartbeat,eventLog:e.eventLog,callMethod:e.debugCallMethod,callParams:e.debugCallParams,callResult:e.debugCallResult,callError:e.debugCallError,onCallMethodChange:d=>e.debugCallMethod=d,onCallParamsChange:d=>e.debugCallParams=d,onRefresh:()=>dn(e),onCall:()=>rc(e)}):g}
3152
+ ${e.tab==="debug"?Df({loading:e.debugLoading,status:e.debugStatus,health:e.debugHealth,models:e.debugModels,heartbeat:e.debugHeartbeat,eventLog:e.eventLog,callMethod:e.debugCallMethod,callParams:e.debugCallParams,callResult:e.debugCallResult,callError:e.debugCallError,onCallMethodChange:d=>e.debugCallMethod=d,onCallParamsChange:d=>e.debugCallParams=d,onRefresh:()=>un(e),onCall:()=>dc(e)}):h}
3111
3153
 
3112
- ${e.tab==="logs"?Pf({loading:e.logsLoading,error:e.logsError,file:e.logsFile,entries:e.logsEntries,filterText:e.logsFilterText,levelFilters:e.logsLevelFilters,autoFollow:e.logsAutoFollow,truncated:e.logsTruncated,onFilterTextChange:d=>e.logsFilterText=d,onLevelToggle:(d,u)=>{e.logsLevelFilters={...e.logsLevelFilters,[d]:u}},onToggleAutoFollow:d=>e.logsAutoFollow=d,onRefresh:()=>Os(e,{reset:!0}),onExport:(d,u)=>e.exportLogs(d,u),onScroll:d=>e.handleLogsScroll(d)}):g}
3154
+ ${e.tab==="logs"?Hf({loading:e.logsLoading,error:e.logsError,file:e.logsFile,entries:e.logsEntries,filterText:e.logsFilterText,levelFilters:e.logsLevelFilters,autoFollow:e.logsAutoFollow,truncated:e.logsTruncated,onFilterTextChange:d=>e.logsFilterText=d,onLevelToggle:(d,u)=>{e.logsLevelFilters={...e.logsLevelFilters,[d]:u}},onToggleAutoFollow:d=>e.logsAutoFollow=d,onRefresh:()=>Os(e,{reset:!0}),onExport:(d,u)=>e.exportLogs(d,u),onScroll:d=>e.handleLogsScroll(d)}):h}
3113
3155
  </main>
3114
- ${bh(e)}
3156
+ ${_h(e)}
3115
3157
  </div>
3116
- `}const Rh={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},Ph={name:"",description:"",agentId:"",enabled:!0,scheduleKind:"every",scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"0 7 * * *",cronTz:"",sessionTarget:"main",wakeMode:"next-heartbeat",payloadKind:"systemEvent",payloadText:"",deliver:!1,channel:"last",to:"",timeoutSeconds:"",postToMainPrefix:""};async function Nh(e){if(!(!e.client||!e.connected)&&!e.agentsLoading){e.agentsLoading=!0,e.agentsError=null;try{const t=await e.client.request("agents.list",{});t&&(e.agentsList=t)}catch(t){e.agentsError=String(t)}finally{e.agentsLoading=!1}}}const mr={WEBCHAT_UI:"webchat-ui",CONTROL_UI:"clawdbot-control-ui",WEBCHAT:"webchat",CLI:"cli",GATEWAY_CLIENT:"gateway-client",MACOS_APP:"clawdbot-macos",IOS_APP:"clawdbot-ios",ANDROID_APP:"clawdbot-android",NODE_HOST:"node-host",TEST:"test",FINGERPRINT:"fingerprint",PROBE:"clawdbot-probe"},za=mr,Ss={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(mr));new Set(Object.values(Ss));function Oh(e){const t=e.version??(e.nonce?"v2":"v1"),n=e.scopes.join(","),s=e.token??"",i=[t,e.deviceId,e.clientId,e.clientMode,e.role,n,String(e.signedAtMs),s];return t==="v2"&&i.push(e.nonce??""),i.join("|")}const Dh=4008;class Bh{constructor(t){this.opts=t,this.ws=null,this.pending=new Map,this.closed=!1,this.lastSeq=null,this.connectNonce=null,this.connectSent=!1,this.connectTimer=null,this.backoffMs=800}start(){this.closed=!1,this.connect()}stop(){this.closed=!0,this.ws?.close(),this.ws=null,this.flushPending(new Error("gateway client stopped"))}get connected(){return this.ws?.readyState===WebSocket.OPEN}connect(){this.closed||(this.ws=new WebSocket(this.opts.url),this.ws.onopen=()=>this.queueConnect(),this.ws.onmessage=t=>this.handleMessage(String(t.data??"")),this.ws.onclose=t=>{const n=String(t.reason??"");this.ws=null,this.flushPending(new Error(`gateway closed (${t.code}): ${n}`)),this.opts.onClose?.({code:t.code,reason:n}),this.scheduleReconnect()},this.ws.onerror=()=>{})}scheduleReconnect(){if(this.closed)return;const t=this.backoffMs;this.backoffMs=Math.min(this.backoffMs*1.7,15e3),window.setTimeout(()=>this.connect(),t)}flushPending(t){for(const[,n]of this.pending)n.reject(t);this.pending.clear()}async sendConnect(){if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);const t=typeof crypto<"u"&&!!crypto.subtle,n=["operator.admin","operator.approvals","operator.pairing"],s="operator";let i=null,a=!1,o=this.opts.token;if(t){i=await Us();const d=Fc({deviceId:i.deviceId,role:s})?.token;o=d??this.opts.token,a=!!(d&&this.opts.token)}const c=o||this.opts.password?{token:o,password:this.opts.password}:void 0;let l;if(t&&i){const d=Date.now(),u=this.connectNonce??void 0,h=Oh({deviceId:i.deviceId,clientId:this.opts.clientName??za.CONTROL_UI,clientMode:this.opts.mode??Ss.WEBCHAT,role:s,scopes:n,signedAtMs:d,token:o??null,nonce:u}),v=await Dc(i.privateKey,h);l={id:i.deviceId,publicKey:i.publicKey,signature:v,signedAt:d,nonce:u}}const p={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??za.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??Ss.WEBCHAT,instanceId:this.opts.instanceId},role:s,scopes:n,device:l,caps:[],auth:c,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",p).then(d=>{d?.auth?.deviceToken&&i&&Eo({deviceId:i.deviceId,role:d.auth.role??s,token:d.auth.deviceToken,scopes:d.auth.scopes??[]}),this.backoffMs=800,this.opts.onHello?.(d)}).catch(()=>{a&&i&&Lo({deviceId:i.deviceId,role:s}),this.ws?.close(Dh,"connect failed")})}handleMessage(t){let n;try{n=JSON.parse(t)}catch{return}const s=n;if(s.type==="event"){const i=n;if(i.event==="connect.challenge"){const o=i.payload,c=o&&typeof o.nonce=="string"?o.nonce:null;c&&(this.connectNonce=c,this.sendConnect());return}const a=typeof i.seq=="number"?i.seq:null;a!==null&&(this.lastSeq!==null&&a>this.lastSeq+1&&this.opts.onGap?.({expected:this.lastSeq+1,received:a}),this.lastSeq=a);try{this.opts.onEvent?.(i)}catch(o){console.error("[gateway] event handler error:",o)}return}if(s.type==="res"){const i=n,a=this.pending.get(i.id);if(!a)return;this.pending.delete(i.id),i.ok?a.resolve(i.payload):a.reject(new Error(i.error?.message??"request failed"));return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const s=Ps(),i={type:"req",id:s,method:t,params:n},a=new Promise((o,c)=>{this.pending.set(s,{resolve:l=>o(l),reject:c})});return this.ws.send(JSON.stringify(i)),a}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}}function _s(e){return typeof e=="object"&&e!==null}function Fh(e){if(!_s(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!_s(n))return null;const s=typeof n.command=="string"?n.command.trim():"";if(!s)return null;const i=typeof e.createdAtMs=="number"?e.createdAtMs:0,a=typeof e.expiresAtMs=="number"?e.expiresAtMs:0;return!i||!a?null:{id:t,request:{command:s,cwd:typeof n.cwd=="string"?n.cwd:null,host:typeof n.host=="string"?n.host:null,security:typeof n.security=="string"?n.security:null,ask:typeof n.ask=="string"?n.ask:null,agentId:typeof n.agentId=="string"?n.agentId:null,resolvedPath:typeof n.resolvedPath=="string"?n.resolvedPath:null,sessionKey:typeof n.sessionKey=="string"?n.sessionKey:null},createdAtMs:i,expiresAtMs:a}}function Uh(e){if(!_s(e))return null;const t=typeof e.id=="string"?e.id.trim():"";return t?{id:t,decision:typeof e.decision=="string"?e.decision:null,resolvedBy:typeof e.resolvedBy=="string"?e.resolvedBy:null,ts:typeof e.ts=="number"?e.ts:null}:null}function br(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function Kh(e,t){const n=br(e).filter(s=>s.id!==t.id);return n.push(t),n}function ja(e,t){return br(e).filter(n=>n.id!==t)}async function yr(e,t){if(!e.client||!e.connected)return;const n=e.sessionKey.trim(),s=n?{sessionKey:n}:{};try{const i=await e.client.request("agent.identity.get",s);if(!i)return;const a=ns(i);e.assistantName=a.name,e.assistantAvatar=a.avatar,e.assistantAgentId=a.agentId??null}catch{}}function Xn(e,t){const n=(e??"").trim(),s=t.mainSessionKey?.trim();if(!s)return n;if(!n)return s;const i=t.mainKey?.trim()||"main",a=t.defaultAgentId?.trim();return n==="main"||n===i||a&&(n===`agent:${a}:main`||n===`agent:${a}:${i}`)?s:n}function Hh(e,t){if(!t?.mainSessionKey)return;const n=Xn(e.sessionKey,t),s=Xn(e.settings.sessionKey,t),i=Xn(e.settings.lastActiveSessionKey,t),a=n||s||e.sessionKey,o={...e.settings,sessionKey:s||a,lastActiveSessionKey:i||a},c=o.sessionKey!==e.settings.sessionKey||o.lastActiveSessionKey!==e.settings.lastActiveSessionKey;a!==e.sessionKey&&(e.sessionKey=a),c&&ke(e,o)}function wr(e){e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null,e.client?.stop(),e.client=new Bh({url:e.settings.gatewayUrl,token:e.settings.token.trim()?e.settings.token:void 0,password:e.password.trim()?e.password:void 0,clientName:"clawdbot-control-ui",mode:"webchat",onHello:t=>{e.connected=!0,e.lastError=null,e.hello=t,qh(e,t),yr(e),Nh(e),pn(e,{quiet:!0}),Te(e,{quiet:!0}),Qs(e)},onClose:({code:t,reason:n})=>{e.connected=!1,t!==1012&&(e.lastError=`disconnected (${t}): ${n||"no reason"}`)},onEvent:t=>zh(e,t),onGap:({expected:t,received:n})=>{e.lastError=`event gap detected (expected seq ${t}, got ${n}); refresh recommended`}}),e.client.start()}function zh(e,t){try{jh(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function jh(e,t){if(e.eventLogBuffer=[{ts:Date.now(),event:t.event,payload:t.payload},...e.eventLogBuffer].slice(0,250),e.tab==="debug"&&(e.eventLog=e.eventLogBuffer),t.event==="agent"){if(e.onboarding)return;Hl(e,t.payload);return}if(t.event==="chat"){const n=t.payload;n?.sessionKey&&Mo(e,n.sessionKey);const s=Ll(e,n);(s==="final"||s==="error"||s==="aborted")&&(Ns(e),$d(e)),s==="final"&&Xe(e);return}if(t.event==="presence"){const n=t.payload;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event==="cron"&&e.tab==="cron"&&Zs(e),(t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&Te(e,{quiet:!0}),t.event==="exec.approval.requested"){const n=Fh(t.payload);if(n){e.execApprovalQueue=Kh(e.execApprovalQueue,n),e.execApprovalError=null;const s=Math.max(0,n.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=ja(e.execApprovalQueue,n.id)},s)}return}if(t.event==="exec.approval.resolved"){const n=Uh(t.payload);n&&(e.execApprovalQueue=ja(e.execApprovalQueue,n.id))}}function qh(e,t){const n=t.snapshot;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence),n?.health&&(e.debugHealth=n.health),n?.sessionDefaults&&Hh(e,n.sessionDefaults)}function Vh(e){e.basePath=ld(),pd(e,!0),cd(e),dd(e),window.addEventListener("popstate",e.popStateHandler),ad(e),wr(e),sd(e),e.tab==="logs"&&Vs(e),e.tab==="debug"&&Gs(e)}function Wh(e){Wl(e)}function Gh(e){window.removeEventListener("popstate",e.popStateHandler),id(e),Ws(e),Ys(e),ud(e),e.topbarObserver?.disconnect(),e.topbarObserver=null}function Yh(e,t){if(e.tab==="chat"&&(t.has("chatMessages")||t.has("chatToolMessages")||t.has("chatStream")||t.has("chatLoading")||t.has("tab"))){const n=t.has("tab"),s=t.has("chatLoading")&&t.get("chatLoading")===!0&&e.chatLoading===!1;ln(e,n||s||!e.chatHasAutoScrolled)}e.tab==="logs"&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&ro(e,t.has("tab")||t.has("logsAutoFollow"))}async function Qh(e,t){await ic(e,t),await oe(e,!0)}async function Zh(e){await ac(e),await oe(e,!0)}async function Jh(e){await oc(e),await oe(e,!0)}async function Xh(e){await ls(e),await be(e),await oe(e,!0)}async function eg(e){await be(e),await oe(e,!0)}function tg(e){if(!Array.isArray(e))return{};const t={};for(const n of e){if(typeof n!="string")continue;const[s,...i]=n.split(":");if(!s||i.length===0)continue;const a=s.trim(),o=i.join(":").trim();a&&o&&(t[a]=o)}return t}function $r(e){return(e.channelsSnapshot?.channelAccounts?.nostr??[])[0]?.accountId??e.nostrProfileAccountId??"default"}function xr(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function ng(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=Xp(n??void 0)}function sg(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function ig(e,t,n){const s=e.nostrProfileFormState;s&&(e.nostrProfileFormState={...s,values:{...s.values,[t]:n},fieldErrors:{...s.fieldErrors,[t]:""}})}function ag(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function og(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=$r(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const s=await fetch(xr(n),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.values)}),i=await s.json().catch(()=>null);if(!s.ok||i?.ok===!1||!i){const a=i?.error??`Profile update failed (${s.status})`;e.nostrProfileFormState={...t,saving:!1,error:a,success:null,fieldErrors:tg(i?.details)};return}if(!i.persisted){e.nostrProfileFormState={...t,saving:!1,error:"Profile publish failed on all relays.",success:null};return}e.nostrProfileFormState={...t,saving:!1,error:null,success:"Profile published to relays.",fieldErrors:{},original:{...t.values}},await oe(e,!0)}catch(s){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(s)}`,success:null}}}async function rg(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=$r(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const s=await fetch(xr(n,"/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoMerge:!0})}),i=await s.json().catch(()=>null);if(!s.ok||i?.ok===!1||!i){const l=i?.error??`Profile import failed (${s.status})`;e.nostrProfileFormState={...t,importing:!1,error:l,success:null};return}const a=i.merged??i.imported??null,o=a?{...t.values,...a}:t.values,c=!!(o.banner||o.website||o.nip05||o.lud16);e.nostrProfileFormState={...t,importing:!1,values:o,error:null,success:i.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:c},i.saved&&await oe(e,!0)}catch(s){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(s)}`,success:null}}}var lg=Object.defineProperty,cg=Object.getOwnPropertyDescriptor,b=(e,t,n,s)=>{for(var i=s>1?void 0:s?cg(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(s?o(t,n,i):o(i))||i);return s&&i&&lg(t,n,i),i};const es=ul();function dg(){if(!window.location.search)return!1;const t=new URLSearchParams(window.location.search).get("onboarding");if(!t)return!1;const n=t.trim().toLowerCase();return n==="1"||n==="true"||n==="yes"||n==="on"}let m=class extends Ze{constructor(){super(...arguments),this.settings=pl(),this.password="",this.tab="chat",this.onboarding=dg(),this.connected=!1,this.theme=this.settings.theme??"system",this.themeResolved="dark",this.hello=null,this.lastError=null,this.eventLog=[],this.eventLogBuffer=[],this.toolStreamSyncTimer=null,this.sidebarCloseTimer=null,this.assistantName=es.name,this.assistantAvatar=es.avatar,this.assistantAgentId=es.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],this.chatToolMessages=[],this.chatStream=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.compactionStatus=null,this.chatAvatarUrl=null,this.chatThinkingLevel=null,this.chatQueue=[],this.sidebarOpen=!1,this.sidebarContent=null,this.sidebarError=null,this.splitRatio=this.settings.splitRatio,this.nodesLoading=!1,this.nodes=[],this.devicesLoading=!1,this.devicesError=null,this.devicesList=null,this.execApprovalsLoading=!1,this.execApprovalsSaving=!1,this.execApprovalsDirty=!1,this.execApprovalsSnapshot=null,this.execApprovalsForm=null,this.execApprovalsSelectedAgent=null,this.execApprovalsTarget="gateway",this.execApprovalsTargetNodeId=null,this.execApprovalQueue=[],this.execApprovalBusy=!1,this.execApprovalError=null,this.configLoading=!1,this.configRaw=`{
3158
+ `}const Kh={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},Hh={name:"",description:"",agentId:"",enabled:!0,scheduleKind:"every",scheduleAt:"",everyAmount:"30",everyUnit:"minutes",cronExpr:"0 7 * * *",cronTz:"",sessionTarget:"main",wakeMode:"next-heartbeat",payloadKind:"systemEvent",payloadText:"",deliver:!1,channel:"last",to:"",timeoutSeconds:"",postToMainPrefix:""};async function zh(e){if(!(!e.client||!e.connected)&&!e.agentsLoading){e.agentsLoading=!0,e.agentsError=null;try{const t=await e.client.request("agents.list",{});t&&(e.agentsList=t)}catch(t){e.agentsError=String(t)}finally{e.agentsLoading=!1}}}const yr={WEBCHAT_UI:"webchat-ui",CONTROL_UI:"poolbot-control-ui",WEBCHAT:"webchat",CLI:"cli",GATEWAY_CLIENT:"gateway-client",MACOS_APP:"poolbot-macos",IOS_APP:"poolbot-ios",ANDROID_APP:"poolbot-android",NODE_HOST:"node-host",TEST:"test",FINGERPRINT:"fingerprint",PROBE:"poolbot-probe"},ja=yr,_s={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values(yr));new Set(Object.values(_s));function jh(e){const t=e.version??(e.nonce?"v2":"v1"),n=e.scopes.join(","),s=e.token??"",i=[t,e.deviceId,e.clientId,e.clientMode,e.role,n,String(e.signedAtMs),s];return t==="v2"&&i.push(e.nonce??""),i.join("|")}const qh=4008;class Wh{constructor(t){this.opts=t,this.ws=null,this.pending=new Map,this.closed=!1,this.lastSeq=null,this.connectNonce=null,this.connectSent=!1,this.connectTimer=null,this.backoffMs=800}start(){this.closed=!1,this.connect()}stop(){this.closed=!0,this.ws?.close(),this.ws=null,this.flushPending(new Error("gateway client stopped"))}get connected(){return this.ws?.readyState===WebSocket.OPEN}connect(){this.closed||(this.ws=new WebSocket(this.opts.url),this.ws.onopen=()=>this.queueConnect(),this.ws.onmessage=t=>this.handleMessage(String(t.data??"")),this.ws.onclose=t=>{const n=String(t.reason??"");this.ws=null,this.flushPending(new Error(`gateway closed (${t.code}): ${n}`)),this.opts.onClose?.({code:t.code,reason:n}),this.scheduleReconnect()},this.ws.onerror=()=>{})}scheduleReconnect(){if(this.closed)return;const t=this.backoffMs;this.backoffMs=Math.min(this.backoffMs*1.7,15e3),window.setTimeout(()=>this.connect(),t)}flushPending(t){for(const[,n]of this.pending)n.reject(t);this.pending.clear()}async sendConnect(){if(this.connectSent)return;this.connectSent=!0,this.connectTimer!==null&&(window.clearTimeout(this.connectTimer),this.connectTimer=null);const t=typeof crypto<"u"&&!!crypto.subtle,n=["operator.admin","operator.approvals","operator.pairing"],s="operator";let i=null,a=!1,o=this.opts.token;if(t){i=await Us();const d=Hc({deviceId:i.deviceId,role:s})?.token;o=d??this.opts.token,a=!!(d&&this.opts.token)}const l=o||this.opts.password?{token:o,password:this.opts.password}:void 0;let r;if(t&&i){const d=Date.now(),u=this.connectNonce??void 0,g=jh({deviceId:i.deviceId,clientId:this.opts.clientName??ja.CONTROL_UI,clientMode:this.opts.mode??_s.WEBCHAT,role:s,scopes:n,signedAtMs:d,token:o??null,nonce:u}),v=await Uc(i.privateKey,g);r={id:i.deviceId,publicKey:i.publicKey,signature:v,signedAt:d,nonce:u}}const p={minProtocol:3,maxProtocol:3,client:{id:this.opts.clientName??ja.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??_s.WEBCHAT,instanceId:this.opts.instanceId},role:s,scopes:n,device:r,caps:[],auth:l,userAgent:navigator.userAgent,locale:navigator.language};this.request("connect",p).then(d=>{d?.auth?.deviceToken&&i&&Lo({deviceId:i.deviceId,role:d.auth.role??s,token:d.auth.deviceToken,scopes:d.auth.scopes??[]}),this.backoffMs=800,this.opts.onHello?.(d)}).catch(()=>{a&&i&&Io({deviceId:i.deviceId,role:s}),this.ws?.close(qh,"connect failed")})}handleMessage(t){let n;try{n=JSON.parse(t)}catch{return}const s=n;if(s.type==="event"){const i=n;if(i.event==="connect.challenge"){const o=i.payload,l=o&&typeof o.nonce=="string"?o.nonce:null;l&&(this.connectNonce=l,this.sendConnect());return}const a=typeof i.seq=="number"?i.seq:null;a!==null&&(this.lastSeq!==null&&a>this.lastSeq+1&&this.opts.onGap?.({expected:this.lastSeq+1,received:a}),this.lastSeq=a);try{this.opts.onEvent?.(i)}catch(o){console.error("[gateway] event handler error:",o)}return}if(s.type==="res"){const i=n,a=this.pending.get(i.id);if(!a)return;this.pending.delete(i.id),i.ok?a.resolve(i.payload):a.reject(new Error(i.error?.message??"request failed"));return}}request(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)return Promise.reject(new Error("gateway not connected"));const s=Ns(),i={type:"req",id:s,method:t,params:n},a=new Promise((o,l)=>{this.pending.set(s,{resolve:r=>o(r),reject:l})});return this.ws.send(JSON.stringify(i)),a}queueConnect(){this.connectNonce=null,this.connectSent=!1,this.connectTimer!==null&&window.clearTimeout(this.connectTimer),this.connectTimer=window.setTimeout(()=>{this.sendConnect()},750)}}function Ts(e){return typeof e=="object"&&e!==null}function Vh(e){if(!Ts(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!Ts(n))return null;const s=typeof n.command=="string"?n.command.trim():"";if(!s)return null;const i=typeof e.createdAtMs=="number"?e.createdAtMs:0,a=typeof e.expiresAtMs=="number"?e.expiresAtMs:0;return!i||!a?null:{id:t,request:{command:s,cwd:typeof n.cwd=="string"?n.cwd:null,host:typeof n.host=="string"?n.host:null,security:typeof n.security=="string"?n.security:null,ask:typeof n.ask=="string"?n.ask:null,agentId:typeof n.agentId=="string"?n.agentId:null,resolvedPath:typeof n.resolvedPath=="string"?n.resolvedPath:null,sessionKey:typeof n.sessionKey=="string"?n.sessionKey:null},createdAtMs:i,expiresAtMs:a}}function Gh(e){if(!Ts(e))return null;const t=typeof e.id=="string"?e.id.trim():"";return t?{id:t,decision:typeof e.decision=="string"?e.decision:null,resolvedBy:typeof e.resolvedBy=="string"?e.resolvedBy:null,ts:typeof e.ts=="number"?e.ts:null}:null}function br(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function Yh(e,t){const n=br(e).filter(s=>s.id!==t.id);return n.push(t),n}function qa(e,t){return br(e).filter(n=>n.id!==t)}async function wr(e,t){if(!e.client||!e.connected)return;const n=e.sessionKey.trim(),s=n?{sessionKey:n}:{};try{const i=await e.client.request("agent.identity.get",s);if(!i)return;const a=ss(i);e.assistantName=a.name,e.assistantAvatar=a.avatar,e.assistantAgentId=a.agentId??null}catch{}}function es(e,t){const n=(e??"").trim(),s=t.mainSessionKey?.trim();if(!s)return n;if(!n)return s;const i=t.mainKey?.trim()||"main",a=t.defaultAgentId?.trim();return n==="main"||n===i||a&&(n===`agent:${a}:main`||n===`agent:${a}:${i}`)?s:n}function Qh(e,t){if(!t?.mainSessionKey)return;const n=es(e.sessionKey,t),s=es(e.settings.sessionKey,t),i=es(e.settings.lastActiveSessionKey,t),a=n||s||e.sessionKey,o={...e.settings,sessionKey:s||a,lastActiveSessionKey:i||a},l=o.sessionKey!==e.settings.sessionKey||o.lastActiveSessionKey!==e.settings.lastActiveSessionKey;a!==e.sessionKey&&(e.sessionKey=a),l&&ke(e,o)}function $r(e){e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null,e.client?.stop(),e.client=new Wh({url:e.settings.gatewayUrl,token:e.settings.token.trim()?e.settings.token:void 0,password:e.password.trim()?e.password:void 0,clientName:"moltbot-control-ui",mode:"webchat",onHello:t=>{e.connected=!0,e.lastError=null,e.hello=t,Xh(e,t),e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,ln(e),wr(e),zh(e),fn(e,{quiet:!0}),Te(e,{quiet:!0}),Qs(e)},onClose:({code:t,reason:n})=>{e.connected=!1,t!==1012&&(e.lastError=`disconnected (${t}): ${n||"no reason"}`)},onEvent:t=>Zh(e,t),onGap:({expected:t,received:n})=>{e.lastError=`event gap detected (expected seq ${t}, got ${n}); refresh recommended`}}),e.client.start()}function Zh(e,t){try{Jh(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function Jh(e,t){if(e.eventLogBuffer=[{ts:Date.now(),event:t.event,payload:t.payload},...e.eventLogBuffer].slice(0,250),e.tab==="debug"&&(e.eventLog=e.eventLogBuffer),t.event==="agent"){if(e.onboarding)return;ql(e,t.payload);return}if(t.event==="chat"){const n=t.payload;n?.sessionKey&&Mo(e,n.sessionKey);const s=Rl(e,n);(s==="final"||s==="error"||s==="aborted")&&(ln(e),Ad(e)),s==="final"&&Xe(e);return}if(t.event==="presence"){const n=t.payload;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence,e.presenceError=null,e.presenceStatus=null);return}if(t.event==="cron"&&e.tab==="cron"&&Zs(e),(t.event==="device.pair.requested"||t.event==="device.pair.resolved")&&Te(e,{quiet:!0}),t.event==="exec.approval.requested"){const n=Vh(t.payload);if(n){e.execApprovalQueue=Yh(e.execApprovalQueue,n),e.execApprovalError=null;const s=Math.max(0,n.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=qa(e.execApprovalQueue,n.id)},s)}return}if(t.event==="exec.approval.resolved"){const n=Gh(t.payload);n&&(e.execApprovalQueue=qa(e.execApprovalQueue,n.id))}}function Xh(e,t){const n=t.snapshot;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence),n?.health&&(e.debugHealth=n.health),n?.sessionDefaults&&Qh(e,n.sessionDefaults)}function eg(e){e.basePath=ud(),gd(e,!0),pd(e),fd(e),window.addEventListener("popstate",e.popStateHandler),ld(e),$r(e),od(e),e.tab==="logs"&&Ws(e),e.tab==="debug"&&Gs(e)}function tg(e){Ql(e)}function ng(e){window.removeEventListener("popstate",e.popStateHandler),rd(e),Vs(e),Ys(e),hd(e),e.topbarObserver?.disconnect(),e.topbarObserver=null}function sg(e,t){if(e.tab==="chat"&&(t.has("chatMessages")||t.has("chatToolMessages")||t.has("chatStream")||t.has("chatLoading")||t.has("tab"))){const n=t.has("tab"),s=t.has("chatLoading")&&t.get("chatLoading")===!0&&e.chatLoading===!1;cn(e,n||s||!e.chatHasAutoScrolled)}e.tab==="logs"&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&lo(e,t.has("tab")||t.has("logsAutoFollow"))}async function ig(e,t){await rc(e,t),await oe(e,!0)}async function ag(e){await lc(e),await oe(e,!0)}async function og(e){await cc(e),await oe(e,!0)}async function rg(e){await cs(e),await ye(e),await oe(e,!0)}async function lg(e){await ye(e),await oe(e,!0)}function cg(e){if(!Array.isArray(e))return{};const t={};for(const n of e){if(typeof n!="string")continue;const[s,...i]=n.split(":");if(!s||i.length===0)continue;const a=s.trim(),o=i.join(":").trim();a&&o&&(t[a]=o)}return t}function xr(e){return(e.channelsSnapshot?.channelAccounts?.nostr??[])[0]?.accountId??e.nostrProfileAccountId??"default"}function kr(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function dg(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=lf(n??void 0)}function ug(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function pg(e,t,n){const s=e.nostrProfileFormState;s&&(e.nostrProfileFormState={...s,values:{...s.values,[t]:n},fieldErrors:{...s.fieldErrors,[t]:""}})}function fg(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function hg(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=xr(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const s=await fetch(kr(n),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.values)}),i=await s.json().catch(()=>null);if(!s.ok||i?.ok===!1||!i){const a=i?.error??`Profile update failed (${s.status})`;e.nostrProfileFormState={...t,saving:!1,error:a,success:null,fieldErrors:cg(i?.details)};return}if(!i.persisted){e.nostrProfileFormState={...t,saving:!1,error:"Profile publish failed on all relays.",success:null};return}e.nostrProfileFormState={...t,saving:!1,error:null,success:"Profile published to relays.",fieldErrors:{},original:{...t.values}},await oe(e,!0)}catch(s){e.nostrProfileFormState={...t,saving:!1,error:`Profile update failed: ${String(s)}`,success:null}}}async function gg(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=xr(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const s=await fetch(kr(n,"/import"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoMerge:!0})}),i=await s.json().catch(()=>null);if(!s.ok||i?.ok===!1||!i){const r=i?.error??`Profile import failed (${s.status})`;e.nostrProfileFormState={...t,importing:!1,error:r,success:null};return}const a=i.merged??i.imported??null,o=a?{...t.values,...a}:t.values,l=!!(o.banner||o.website||o.nip05||o.lud16);e.nostrProfileFormState={...t,importing:!1,values:o,error:null,success:i.saved?"Profile imported from relays. Review and publish.":"Profile imported. Review and publish.",showAdvanced:l},i.saved&&await oe(e,!0)}catch(s){e.nostrProfileFormState={...t,importing:!1,error:`Profile import failed: ${String(s)}`,success:null}}}var vg=Object.defineProperty,mg=Object.getOwnPropertyDescriptor,y=(e,t,n,s)=>{for(var i=s>1?void 0:s?mg(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(s?o(t,n,i):o(i))||i);return s&&i&&vg(t,n,i),i};const ts=pl();function yg(){if(!window.location.search)return!1;const t=new URLSearchParams(window.location.search).get("onboarding");if(!t)return!1;const n=t.trim().toLowerCase();return n==="1"||n==="true"||n==="yes"||n==="on"}let m=class extends Ze{constructor(){super(...arguments),this.settings=fl(),this.password="",this.tab="chat",this.onboarding=yg(),this.connected=!1,this.theme=this.settings.theme??"system",this.themeResolved="dark",this.hello=null,this.lastError=null,this.eventLog=[],this.eventLogBuffer=[],this.toolStreamSyncTimer=null,this.sidebarCloseTimer=null,this.assistantName=ts.name,this.assistantAvatar=ts.avatar,this.assistantAgentId=ts.agentId??null,this.sessionKey=this.settings.sessionKey,this.chatLoading=!1,this.chatSending=!1,this.chatMessage="",this.chatMessages=[],this.chatToolMessages=[],this.chatStream=null,this.chatStreamStartedAt=null,this.chatRunId=null,this.compactionStatus=null,this.chatAvatarUrl=null,this.chatThinkingLevel=null,this.chatQueue=[],this.chatAttachments=[],this.sidebarOpen=!1,this.sidebarContent=null,this.sidebarError=null,this.splitRatio=this.settings.splitRatio,this.nodesLoading=!1,this.nodes=[],this.devicesLoading=!1,this.devicesError=null,this.devicesList=null,this.execApprovalsLoading=!1,this.execApprovalsSaving=!1,this.execApprovalsDirty=!1,this.execApprovalsSnapshot=null,this.execApprovalsForm=null,this.execApprovalsSelectedAgent=null,this.execApprovalsTarget="gateway",this.execApprovalsTargetNodeId=null,this.execApprovalQueue=[],this.execApprovalBusy=!1,this.execApprovalError=null,this.configLoading=!1,this.configRaw=`{
3117
3159
  }
3118
- `,this.configRawOriginal="",this.configValid=null,this.configIssues=[],this.configSaving=!1,this.configApplying=!1,this.updateRunning=!1,this.applySessionKey=this.settings.lastActiveSessionKey,this.configSnapshot=null,this.configSchema=null,this.configSchemaVersion=null,this.configSchemaLoading=!1,this.configUiHints={},this.configForm=null,this.configFormOriginal=null,this.configFormDirty=!1,this.configFormMode="form",this.configSearchQuery="",this.configActiveSection=null,this.configActiveSubsection=null,this.channelsLoading=!1,this.channelsSnapshot=null,this.channelsError=null,this.channelsLastSuccess=null,this.whatsappLoginMessage=null,this.whatsappLoginQrDataUrl=null,this.whatsappLoginConnected=null,this.whatsappBusy=!1,this.nostrProfileFormState=null,this.nostrProfileAccountId=null,this.presenceLoading=!1,this.presenceEntries=[],this.presenceError=null,this.presenceStatus=null,this.agentsLoading=!1,this.agentsList=null,this.agentsError=null,this.sessionsLoading=!1,this.sessionsResult=null,this.sessionsError=null,this.sessionsFilterActive="",this.sessionsFilterLimit="120",this.sessionsIncludeGlobal=!0,this.sessionsIncludeUnknown=!1,this.cronLoading=!1,this.cronJobs=[],this.cronStatus=null,this.cronError=null,this.cronForm={...Ph},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.skillsLoading=!1,this.skillsReport=null,this.skillsError=null,this.skillsFilter="",this.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.debugLoading=!1,this.debugStatus=null,this.debugHealth=null,this.debugModels=[],this.debugHeartbeat=null,this.debugCallMethod="",this.debugCallParams="{}",this.debugCallResult=null,this.debugCallError=null,this.logsLoading=!1,this.logsError=null,this.logsFile=null,this.logsEntries=[],this.logsFilterText="",this.logsLevelFilters={...Rh},this.logsAutoFollow=!0,this.logsTruncated=!1,this.logsCursor=null,this.logsLastFetchAt=null,this.logsLimit=500,this.logsMaxBytes=25e4,this.logsAtBottom=!0,this.client=null,this.chatScrollFrame=null,this.chatScrollTimeout=null,this.chatHasAutoScrolled=!1,this.chatUserNearBottom=!0,this.nodesPollInterval=null,this.logsPollInterval=null,this.debugPollInterval=null,this.logsScrollFrame=null,this.toolStreamById=new Map,this.toolStreamOrder=[],this.basePath="",this.popStateHandler=()=>fd(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),Vh(this)}firstUpdated(){Wh(this)}disconnectedCallback(){Gh(this),super.disconnectedCallback()}updated(e){Yh(this,e)}connect(){wr(this)}handleChatScroll(e){zl(this,e)}handleLogsScroll(e){jl(this,e)}exportLogs(e,t){Vl(e,t)}resetToolStream(){Ns(this)}resetChatScroll(){ql(this)}async loadAssistantIdentity(){await yr(this)}applySettings(e){ke(this,e)}setTab(e){od(this,e)}setTheme(e,t){rd(this,e,t)}async loadOverview(){await Po(this)}async loadCron(){await Zs(this)}async handleAbortChat(){await Oo(this)}removeQueuedMessage(e){bd(this,e)}async handleSendChat(e,t){await yd(this,e,t)}async handleWhatsAppStart(e){await Qh(this,e)}async handleWhatsAppWait(){await Zh(this)}async handleWhatsAppLogout(){await Jh(this)}async handleChannelConfigSave(){await Xh(this)}async handleChannelConfigReload(){await eg(this)}handleNostrProfileEdit(e,t){ng(this,e,t)}handleNostrProfileCancel(){sg(this)}handleNostrProfileFieldChange(e,t){ig(this,e,t)}async handleNostrProfileSave(){await og(this)}async handleNostrProfileImport(){await rg(this)}handleNostrProfileToggleAdvanced(){ag(this)}async handleExecApprovalDecision(e){const t=this.execApprovalQueue[0];if(!(!t||!this.client||this.execApprovalBusy)){this.execApprovalBusy=!0,this.execApprovalError=null;try{await this.client.request("exec.approval.resolve",{id:t.id,decision:e}),this.execApprovalQueue=this.execApprovalQueue.filter(n=>n.id!==t.id)}catch(n){this.execApprovalError=`Exec approval failed: ${String(n)}`}finally{this.execApprovalBusy=!1}}}handleOpenSidebar(e){this.sidebarCloseTimer!=null&&(window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=null),this.sidebarContent=e,this.sidebarError=null,this.sidebarOpen=!0}handleCloseSidebar(){this.sidebarOpen=!1,this.sidebarCloseTimer!=null&&window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=window.setTimeout(()=>{this.sidebarOpen||(this.sidebarContent=null,this.sidebarError=null,this.sidebarCloseTimer=null)},200)}handleSplitRatioChange(e){const t=Math.max(.4,Math.min(.7,e));this.splitRatio=t,this.applySettings({...this.settings,splitRatio:t})}render(){return Ih(this)}};b([y()],m.prototype,"settings",2);b([y()],m.prototype,"password",2);b([y()],m.prototype,"tab",2);b([y()],m.prototype,"onboarding",2);b([y()],m.prototype,"connected",2);b([y()],m.prototype,"theme",2);b([y()],m.prototype,"themeResolved",2);b([y()],m.prototype,"hello",2);b([y()],m.prototype,"lastError",2);b([y()],m.prototype,"eventLog",2);b([y()],m.prototype,"assistantName",2);b([y()],m.prototype,"assistantAvatar",2);b([y()],m.prototype,"assistantAgentId",2);b([y()],m.prototype,"sessionKey",2);b([y()],m.prototype,"chatLoading",2);b([y()],m.prototype,"chatSending",2);b([y()],m.prototype,"chatMessage",2);b([y()],m.prototype,"chatMessages",2);b([y()],m.prototype,"chatToolMessages",2);b([y()],m.prototype,"chatStream",2);b([y()],m.prototype,"chatStreamStartedAt",2);b([y()],m.prototype,"chatRunId",2);b([y()],m.prototype,"compactionStatus",2);b([y()],m.prototype,"chatAvatarUrl",2);b([y()],m.prototype,"chatThinkingLevel",2);b([y()],m.prototype,"chatQueue",2);b([y()],m.prototype,"sidebarOpen",2);b([y()],m.prototype,"sidebarContent",2);b([y()],m.prototype,"sidebarError",2);b([y()],m.prototype,"splitRatio",2);b([y()],m.prototype,"nodesLoading",2);b([y()],m.prototype,"nodes",2);b([y()],m.prototype,"devicesLoading",2);b([y()],m.prototype,"devicesError",2);b([y()],m.prototype,"devicesList",2);b([y()],m.prototype,"execApprovalsLoading",2);b([y()],m.prototype,"execApprovalsSaving",2);b([y()],m.prototype,"execApprovalsDirty",2);b([y()],m.prototype,"execApprovalsSnapshot",2);b([y()],m.prototype,"execApprovalsForm",2);b([y()],m.prototype,"execApprovalsSelectedAgent",2);b([y()],m.prototype,"execApprovalsTarget",2);b([y()],m.prototype,"execApprovalsTargetNodeId",2);b([y()],m.prototype,"execApprovalQueue",2);b([y()],m.prototype,"execApprovalBusy",2);b([y()],m.prototype,"execApprovalError",2);b([y()],m.prototype,"configLoading",2);b([y()],m.prototype,"configRaw",2);b([y()],m.prototype,"configRawOriginal",2);b([y()],m.prototype,"configValid",2);b([y()],m.prototype,"configIssues",2);b([y()],m.prototype,"configSaving",2);b([y()],m.prototype,"configApplying",2);b([y()],m.prototype,"updateRunning",2);b([y()],m.prototype,"applySessionKey",2);b([y()],m.prototype,"configSnapshot",2);b([y()],m.prototype,"configSchema",2);b([y()],m.prototype,"configSchemaVersion",2);b([y()],m.prototype,"configSchemaLoading",2);b([y()],m.prototype,"configUiHints",2);b([y()],m.prototype,"configForm",2);b([y()],m.prototype,"configFormOriginal",2);b([y()],m.prototype,"configFormDirty",2);b([y()],m.prototype,"configFormMode",2);b([y()],m.prototype,"configSearchQuery",2);b([y()],m.prototype,"configActiveSection",2);b([y()],m.prototype,"configActiveSubsection",2);b([y()],m.prototype,"channelsLoading",2);b([y()],m.prototype,"channelsSnapshot",2);b([y()],m.prototype,"channelsError",2);b([y()],m.prototype,"channelsLastSuccess",2);b([y()],m.prototype,"whatsappLoginMessage",2);b([y()],m.prototype,"whatsappLoginQrDataUrl",2);b([y()],m.prototype,"whatsappLoginConnected",2);b([y()],m.prototype,"whatsappBusy",2);b([y()],m.prototype,"nostrProfileFormState",2);b([y()],m.prototype,"nostrProfileAccountId",2);b([y()],m.prototype,"presenceLoading",2);b([y()],m.prototype,"presenceEntries",2);b([y()],m.prototype,"presenceError",2);b([y()],m.prototype,"presenceStatus",2);b([y()],m.prototype,"agentsLoading",2);b([y()],m.prototype,"agentsList",2);b([y()],m.prototype,"agentsError",2);b([y()],m.prototype,"sessionsLoading",2);b([y()],m.prototype,"sessionsResult",2);b([y()],m.prototype,"sessionsError",2);b([y()],m.prototype,"sessionsFilterActive",2);b([y()],m.prototype,"sessionsFilterLimit",2);b([y()],m.prototype,"sessionsIncludeGlobal",2);b([y()],m.prototype,"sessionsIncludeUnknown",2);b([y()],m.prototype,"cronLoading",2);b([y()],m.prototype,"cronJobs",2);b([y()],m.prototype,"cronStatus",2);b([y()],m.prototype,"cronError",2);b([y()],m.prototype,"cronForm",2);b([y()],m.prototype,"cronRunsJobId",2);b([y()],m.prototype,"cronRuns",2);b([y()],m.prototype,"cronBusy",2);b([y()],m.prototype,"skillsLoading",2);b([y()],m.prototype,"skillsReport",2);b([y()],m.prototype,"skillsError",2);b([y()],m.prototype,"skillsFilter",2);b([y()],m.prototype,"skillEdits",2);b([y()],m.prototype,"skillsBusyKey",2);b([y()],m.prototype,"skillMessages",2);b([y()],m.prototype,"debugLoading",2);b([y()],m.prototype,"debugStatus",2);b([y()],m.prototype,"debugHealth",2);b([y()],m.prototype,"debugModels",2);b([y()],m.prototype,"debugHeartbeat",2);b([y()],m.prototype,"debugCallMethod",2);b([y()],m.prototype,"debugCallParams",2);b([y()],m.prototype,"debugCallResult",2);b([y()],m.prototype,"debugCallError",2);b([y()],m.prototype,"logsLoading",2);b([y()],m.prototype,"logsError",2);b([y()],m.prototype,"logsFile",2);b([y()],m.prototype,"logsEntries",2);b([y()],m.prototype,"logsFilterText",2);b([y()],m.prototype,"logsLevelFilters",2);b([y()],m.prototype,"logsAutoFollow",2);b([y()],m.prototype,"logsTruncated",2);b([y()],m.prototype,"logsCursor",2);b([y()],m.prototype,"logsLastFetchAt",2);b([y()],m.prototype,"logsLimit",2);b([y()],m.prototype,"logsMaxBytes",2);b([y()],m.prototype,"logsAtBottom",2);m=b([Ja("clawdbot-app")],m);
3119
- //# sourceMappingURL=index-Cl-Y9zqE.js.map
3160
+ `,this.configRawOriginal="",this.configValid=null,this.configIssues=[],this.configSaving=!1,this.configApplying=!1,this.updateRunning=!1,this.applySessionKey=this.settings.lastActiveSessionKey,this.configSnapshot=null,this.configSchema=null,this.configSchemaVersion=null,this.configSchemaLoading=!1,this.configUiHints={},this.configForm=null,this.configFormOriginal=null,this.configFormDirty=!1,this.configFormMode="form",this.configSearchQuery="",this.configActiveSection=null,this.configActiveSubsection=null,this.channelsLoading=!1,this.channelsSnapshot=null,this.channelsError=null,this.channelsLastSuccess=null,this.whatsappLoginMessage=null,this.whatsappLoginQrDataUrl=null,this.whatsappLoginConnected=null,this.whatsappBusy=!1,this.nostrProfileFormState=null,this.nostrProfileAccountId=null,this.presenceLoading=!1,this.presenceEntries=[],this.presenceError=null,this.presenceStatus=null,this.agentsLoading=!1,this.agentsList=null,this.agentsError=null,this.sessionsLoading=!1,this.sessionsResult=null,this.sessionsError=null,this.sessionsFilterActive="",this.sessionsFilterLimit="120",this.sessionsIncludeGlobal=!0,this.sessionsIncludeUnknown=!1,this.cronLoading=!1,this.cronJobs=[],this.cronStatus=null,this.cronError=null,this.cronForm={...Hh},this.cronRunsJobId=null,this.cronRuns=[],this.cronBusy=!1,this.skillsLoading=!1,this.skillsReport=null,this.skillsError=null,this.skillsFilter="",this.skillEdits={},this.skillsBusyKey=null,this.skillMessages={},this.debugLoading=!1,this.debugStatus=null,this.debugHealth=null,this.debugModels=[],this.debugHeartbeat=null,this.debugCallMethod="",this.debugCallParams="{}",this.debugCallResult=null,this.debugCallError=null,this.logsLoading=!1,this.logsError=null,this.logsFile=null,this.logsEntries=[],this.logsFilterText="",this.logsLevelFilters={...Kh},this.logsAutoFollow=!0,this.logsTruncated=!1,this.logsCursor=null,this.logsLastFetchAt=null,this.logsLimit=500,this.logsMaxBytes=25e4,this.logsAtBottom=!0,this.client=null,this.chatScrollFrame=null,this.chatScrollTimeout=null,this.chatHasAutoScrolled=!1,this.chatUserNearBottom=!0,this.nodesPollInterval=null,this.logsPollInterval=null,this.debugPollInterval=null,this.logsScrollFrame=null,this.toolStreamById=new Map,this.toolStreamOrder=[],this.basePath="",this.popStateHandler=()=>vd(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),eg(this)}firstUpdated(){tg(this)}disconnectedCallback(){ng(this),super.disconnectedCallback()}updated(e){sg(this,e)}connect(){$r(this)}handleChatScroll(e){Wl(this,e)}handleLogsScroll(e){Vl(this,e)}exportLogs(e,t){Yl(e,t)}resetToolStream(){ln(this)}resetChatScroll(){Gl(this)}async loadAssistantIdentity(){await wr(this)}applySettings(e){ke(this,e)}setTab(e){cd(this,e)}setTheme(e,t){dd(this,e,t)}async loadOverview(){await No(this)}async loadCron(){await Zs(this)}async handleAbortChat(){await Do(this)}removeQueuedMessage(e){$d(this,e)}async handleSendChat(e,t){await xd(this,e,t)}async handleWhatsAppStart(e){await ig(this,e)}async handleWhatsAppWait(){await ag(this)}async handleWhatsAppLogout(){await og(this)}async handleChannelConfigSave(){await rg(this)}async handleChannelConfigReload(){await lg(this)}handleNostrProfileEdit(e,t){dg(this,e,t)}handleNostrProfileCancel(){ug(this)}handleNostrProfileFieldChange(e,t){pg(this,e,t)}async handleNostrProfileSave(){await hg(this)}async handleNostrProfileImport(){await gg(this)}handleNostrProfileToggleAdvanced(){fg(this)}async handleExecApprovalDecision(e){const t=this.execApprovalQueue[0];if(!(!t||!this.client||this.execApprovalBusy)){this.execApprovalBusy=!0,this.execApprovalError=null;try{await this.client.request("exec.approval.resolve",{id:t.id,decision:e}),this.execApprovalQueue=this.execApprovalQueue.filter(n=>n.id!==t.id)}catch(n){this.execApprovalError=`Exec approval failed: ${String(n)}`}finally{this.execApprovalBusy=!1}}}handleOpenSidebar(e){this.sidebarCloseTimer!=null&&(window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=null),this.sidebarContent=e,this.sidebarError=null,this.sidebarOpen=!0}handleCloseSidebar(){this.sidebarOpen=!1,this.sidebarCloseTimer!=null&&window.clearTimeout(this.sidebarCloseTimer),this.sidebarCloseTimer=window.setTimeout(()=>{this.sidebarOpen||(this.sidebarContent=null,this.sidebarError=null,this.sidebarCloseTimer=null)},200)}handleSplitRatioChange(e){const t=Math.max(.4,Math.min(.7,e));this.splitRatio=t,this.applySettings({...this.settings,splitRatio:t})}render(){return Uh(this)}};y([b()],m.prototype,"settings",2);y([b()],m.prototype,"password",2);y([b()],m.prototype,"tab",2);y([b()],m.prototype,"onboarding",2);y([b()],m.prototype,"connected",2);y([b()],m.prototype,"theme",2);y([b()],m.prototype,"themeResolved",2);y([b()],m.prototype,"hello",2);y([b()],m.prototype,"lastError",2);y([b()],m.prototype,"eventLog",2);y([b()],m.prototype,"assistantName",2);y([b()],m.prototype,"assistantAvatar",2);y([b()],m.prototype,"assistantAgentId",2);y([b()],m.prototype,"sessionKey",2);y([b()],m.prototype,"chatLoading",2);y([b()],m.prototype,"chatSending",2);y([b()],m.prototype,"chatMessage",2);y([b()],m.prototype,"chatMessages",2);y([b()],m.prototype,"chatToolMessages",2);y([b()],m.prototype,"chatStream",2);y([b()],m.prototype,"chatStreamStartedAt",2);y([b()],m.prototype,"chatRunId",2);y([b()],m.prototype,"compactionStatus",2);y([b()],m.prototype,"chatAvatarUrl",2);y([b()],m.prototype,"chatThinkingLevel",2);y([b()],m.prototype,"chatQueue",2);y([b()],m.prototype,"chatAttachments",2);y([b()],m.prototype,"sidebarOpen",2);y([b()],m.prototype,"sidebarContent",2);y([b()],m.prototype,"sidebarError",2);y([b()],m.prototype,"splitRatio",2);y([b()],m.prototype,"nodesLoading",2);y([b()],m.prototype,"nodes",2);y([b()],m.prototype,"devicesLoading",2);y([b()],m.prototype,"devicesError",2);y([b()],m.prototype,"devicesList",2);y([b()],m.prototype,"execApprovalsLoading",2);y([b()],m.prototype,"execApprovalsSaving",2);y([b()],m.prototype,"execApprovalsDirty",2);y([b()],m.prototype,"execApprovalsSnapshot",2);y([b()],m.prototype,"execApprovalsForm",2);y([b()],m.prototype,"execApprovalsSelectedAgent",2);y([b()],m.prototype,"execApprovalsTarget",2);y([b()],m.prototype,"execApprovalsTargetNodeId",2);y([b()],m.prototype,"execApprovalQueue",2);y([b()],m.prototype,"execApprovalBusy",2);y([b()],m.prototype,"execApprovalError",2);y([b()],m.prototype,"configLoading",2);y([b()],m.prototype,"configRaw",2);y([b()],m.prototype,"configRawOriginal",2);y([b()],m.prototype,"configValid",2);y([b()],m.prototype,"configIssues",2);y([b()],m.prototype,"configSaving",2);y([b()],m.prototype,"configApplying",2);y([b()],m.prototype,"updateRunning",2);y([b()],m.prototype,"applySessionKey",2);y([b()],m.prototype,"configSnapshot",2);y([b()],m.prototype,"configSchema",2);y([b()],m.prototype,"configSchemaVersion",2);y([b()],m.prototype,"configSchemaLoading",2);y([b()],m.prototype,"configUiHints",2);y([b()],m.prototype,"configForm",2);y([b()],m.prototype,"configFormOriginal",2);y([b()],m.prototype,"configFormDirty",2);y([b()],m.prototype,"configFormMode",2);y([b()],m.prototype,"configSearchQuery",2);y([b()],m.prototype,"configActiveSection",2);y([b()],m.prototype,"configActiveSubsection",2);y([b()],m.prototype,"channelsLoading",2);y([b()],m.prototype,"channelsSnapshot",2);y([b()],m.prototype,"channelsError",2);y([b()],m.prototype,"channelsLastSuccess",2);y([b()],m.prototype,"whatsappLoginMessage",2);y([b()],m.prototype,"whatsappLoginQrDataUrl",2);y([b()],m.prototype,"whatsappLoginConnected",2);y([b()],m.prototype,"whatsappBusy",2);y([b()],m.prototype,"nostrProfileFormState",2);y([b()],m.prototype,"nostrProfileAccountId",2);y([b()],m.prototype,"presenceLoading",2);y([b()],m.prototype,"presenceEntries",2);y([b()],m.prototype,"presenceError",2);y([b()],m.prototype,"presenceStatus",2);y([b()],m.prototype,"agentsLoading",2);y([b()],m.prototype,"agentsList",2);y([b()],m.prototype,"agentsError",2);y([b()],m.prototype,"sessionsLoading",2);y([b()],m.prototype,"sessionsResult",2);y([b()],m.prototype,"sessionsError",2);y([b()],m.prototype,"sessionsFilterActive",2);y([b()],m.prototype,"sessionsFilterLimit",2);y([b()],m.prototype,"sessionsIncludeGlobal",2);y([b()],m.prototype,"sessionsIncludeUnknown",2);y([b()],m.prototype,"cronLoading",2);y([b()],m.prototype,"cronJobs",2);y([b()],m.prototype,"cronStatus",2);y([b()],m.prototype,"cronError",2);y([b()],m.prototype,"cronForm",2);y([b()],m.prototype,"cronRunsJobId",2);y([b()],m.prototype,"cronRuns",2);y([b()],m.prototype,"cronBusy",2);y([b()],m.prototype,"skillsLoading",2);y([b()],m.prototype,"skillsReport",2);y([b()],m.prototype,"skillsError",2);y([b()],m.prototype,"skillsFilter",2);y([b()],m.prototype,"skillEdits",2);y([b()],m.prototype,"skillsBusyKey",2);y([b()],m.prototype,"skillMessages",2);y([b()],m.prototype,"debugLoading",2);y([b()],m.prototype,"debugStatus",2);y([b()],m.prototype,"debugHealth",2);y([b()],m.prototype,"debugModels",2);y([b()],m.prototype,"debugHeartbeat",2);y([b()],m.prototype,"debugCallMethod",2);y([b()],m.prototype,"debugCallParams",2);y([b()],m.prototype,"debugCallResult",2);y([b()],m.prototype,"debugCallError",2);y([b()],m.prototype,"logsLoading",2);y([b()],m.prototype,"logsError",2);y([b()],m.prototype,"logsFile",2);y([b()],m.prototype,"logsEntries",2);y([b()],m.prototype,"logsFilterText",2);y([b()],m.prototype,"logsLevelFilters",2);y([b()],m.prototype,"logsAutoFollow",2);y([b()],m.prototype,"logsTruncated",2);y([b()],m.prototype,"logsCursor",2);y([b()],m.prototype,"logsLastFetchAt",2);y([b()],m.prototype,"logsLimit",2);y([b()],m.prototype,"logsMaxBytes",2);y([b()],m.prototype,"logsAtBottom",2);m=y([Xa("poolbot-app")],m);
3161
+ //# sourceMappingURL=index-CmNMuoem.js.map