@poolzin/pool-bot 2026.2.0 → 2026.2.2

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 (258) hide show
  1. package/CHANGELOG.md +118 -0
  2. package/README-header.png +0 -0
  3. package/dist/agents/bash-tools.exec.js +76 -25
  4. package/dist/agents/cli-runner/helpers.js +9 -11
  5. package/dist/agents/context.js +1 -1
  6. package/dist/agents/identity.js +47 -7
  7. package/dist/agents/memory-search.js +25 -8
  8. package/dist/agents/model-catalog.js +1 -1
  9. package/dist/agents/model-selection.js +21 -0
  10. package/dist/agents/pi-embedded-block-chunker.js +117 -42
  11. package/dist/agents/pi-embedded-helpers/errors.js +183 -78
  12. package/dist/agents/pi-embedded-helpers.js +1 -1
  13. package/dist/agents/pi-embedded-runner/compact.js +8 -10
  14. package/dist/agents/pi-embedded-runner/model.js +62 -3
  15. package/dist/agents/pi-embedded-runner/run/attempt.js +21 -11
  16. package/dist/agents/pi-embedded-runner/run.js +199 -46
  17. package/dist/agents/pi-embedded-runner/system-prompt.js +10 -2
  18. package/dist/agents/pi-embedded-subscribe.js +118 -29
  19. package/dist/agents/pi-tools.js +10 -5
  20. package/dist/agents/poolbot-tools.js +15 -10
  21. package/dist/agents/sandbox-paths.js +31 -0
  22. package/dist/agents/session-tool-result-guard.js +94 -15
  23. package/dist/agents/shell-utils.js +51 -0
  24. package/dist/agents/skills/bundled-context.js +23 -0
  25. package/dist/agents/skills/bundled-dir.js +41 -7
  26. package/dist/agents/skills-install.js +60 -23
  27. package/dist/agents/subagent-announce.js +79 -34
  28. package/dist/agents/tool-policy.conformance.js +14 -0
  29. package/dist/agents/tool-policy.js +24 -0
  30. package/dist/agents/tools/cron-tool.js +166 -19
  31. package/dist/agents/tools/discord-actions-presence.js +78 -0
  32. package/dist/agents/tools/image-tool.js +1 -1
  33. package/dist/agents/tools/message-tool.js +56 -2
  34. package/dist/agents/tools/sessions-history-tool.js +69 -1
  35. package/dist/agents/tools/web-search.js +211 -42
  36. package/dist/agents/usage.js +23 -1
  37. package/dist/agents/workspace-run.js +67 -0
  38. package/dist/agents/workspace-templates.js +44 -0
  39. package/dist/auto-reply/command-auth.js +121 -6
  40. package/dist/auto-reply/envelope.js +74 -82
  41. package/dist/auto-reply/reply/commands-compact.js +1 -0
  42. package/dist/auto-reply/reply/commands-context-report.js +1 -0
  43. package/dist/auto-reply/reply/commands-context.js +1 -0
  44. package/dist/auto-reply/reply/commands-models.js +107 -60
  45. package/dist/auto-reply/reply/commands-ptt.js +171 -0
  46. package/dist/auto-reply/reply/get-reply-run.js +2 -1
  47. package/dist/auto-reply/reply/inbound-context.js +5 -1
  48. package/dist/auto-reply/reply/mentions.js +1 -1
  49. package/dist/auto-reply/reply/model-selection.js +3 -3
  50. package/dist/auto-reply/thinking.js +88 -43
  51. package/dist/browser/bridge-server.js +13 -0
  52. package/dist/browser/cdp.helpers.js +38 -24
  53. package/dist/browser/client-fetch.js +50 -7
  54. package/dist/browser/config.js +1 -10
  55. package/dist/browser/extension-relay.js +101 -40
  56. package/dist/browser/pw-ai.js +1 -1
  57. package/dist/browser/pw-session.js +143 -8
  58. package/dist/browser/pw-tools-core.interactions.js +125 -27
  59. package/dist/browser/pw-tools-core.responses.js +1 -1
  60. package/dist/browser/pw-tools-core.state.js +1 -1
  61. package/dist/browser/routes/agent.act.js +86 -41
  62. package/dist/browser/routes/dispatcher.js +4 -4
  63. package/dist/browser/screenshot.js +1 -1
  64. package/dist/browser/server.js +13 -0
  65. package/dist/build-info.json +3 -3
  66. package/dist/canvas-host/a2ui/index.html +28 -28
  67. package/dist/channels/reply-prefix.js +8 -1
  68. package/dist/cli/cron-cli/register.cron-add.js +61 -40
  69. package/dist/cli/cron-cli/register.cron-edit.js +60 -34
  70. package/dist/cli/cron-cli/shared.js +56 -41
  71. package/dist/cli/dns-cli.js +26 -14
  72. package/dist/cli/gateway-cli/register.js +37 -19
  73. package/dist/cli/memory-cli.js +5 -5
  74. package/dist/cli/parse-bytes.js +37 -0
  75. package/dist/cli/update-cli.js +173 -52
  76. package/dist/commands/agent.js +1 -0
  77. package/dist/commands/auth-choice.apply.oauth.js +1 -1
  78. package/dist/commands/doctor-config-flow.js +61 -5
  79. package/dist/commands/doctor-state-migrations.js +1 -1
  80. package/dist/commands/health.js +1 -1
  81. package/dist/commands/model-allowlist.js +29 -0
  82. package/dist/commands/model-picker.js +2 -1
  83. package/dist/commands/models/list.registry.js +1 -1
  84. package/dist/commands/models/list.status-command.js +43 -23
  85. package/dist/commands/models/shared.js +15 -0
  86. package/dist/commands/onboard-custom.js +384 -0
  87. package/dist/commands/onboard-non-interactive/local/auth-choice-inference.js +35 -0
  88. package/dist/commands/onboard-non-interactive/local/auth-choice.js +6 -3
  89. package/dist/commands/onboard-skills.js +63 -38
  90. package/dist/commands/openai-model-default.js +41 -0
  91. package/dist/compat/legacy-names.js +2 -0
  92. package/dist/config/defaults.js +3 -2
  93. package/dist/config/paths.js +136 -35
  94. package/dist/config/plugin-auto-enable.js +21 -5
  95. package/dist/config/redact-snapshot.js +153 -0
  96. package/dist/config/schema.field-metadata.js +590 -0
  97. package/dist/config/schema.js +2 -2
  98. package/dist/config/sessions/store.js +291 -23
  99. package/dist/config/zod-schema.agent-defaults.js +3 -0
  100. package/dist/config/zod-schema.agent-runtime.js +13 -2
  101. package/dist/config/zod-schema.providers-core.js +142 -0
  102. package/dist/config/zod-schema.session.js +3 -0
  103. package/dist/control-ui/assets/{index-CIRDm-Lu.css → index-CSfXd2LO.css} +1 -1
  104. package/dist/control-ui/assets/{index-CmNMuoem.js → index-HRr1grwl.js} +446 -413
  105. package/dist/control-ui/assets/index-HRr1grwl.js.map +1 -0
  106. package/dist/control-ui/index.html +4 -4
  107. package/dist/cron/delivery.js +57 -0
  108. package/dist/cron/isolated-agent/delivery-target.js +18 -3
  109. package/dist/cron/isolated-agent/helpers.js +22 -5
  110. package/dist/cron/isolated-agent/run.js +172 -63
  111. package/dist/cron/isolated-agent/session.js +2 -0
  112. package/dist/cron/normalize.js +356 -28
  113. package/dist/cron/parse.js +10 -5
  114. package/dist/cron/run-log.js +35 -10
  115. package/dist/cron/schedule.js +41 -6
  116. package/dist/cron/service/jobs.js +208 -35
  117. package/dist/cron/service/ops.js +72 -16
  118. package/dist/cron/service/state.js +2 -0
  119. package/dist/cron/service/store.js +386 -14
  120. package/dist/cron/service/timer.js +390 -147
  121. package/dist/cron/session-reaper.js +86 -0
  122. package/dist/cron/store.js +23 -8
  123. package/dist/cron/validate-timestamp.js +43 -0
  124. package/dist/discord/monitor/agent-components.js +438 -0
  125. package/dist/discord/monitor/allow-list.js +28 -5
  126. package/dist/discord/monitor/gateway-registry.js +29 -0
  127. package/dist/discord/monitor/native-command.js +44 -23
  128. package/dist/discord/monitor/sender-identity.js +45 -0
  129. package/dist/discord/pluralkit.js +27 -0
  130. package/dist/discord/send.outbound.js +92 -5
  131. package/dist/discord/send.shared.js +60 -23
  132. package/dist/discord/targets.js +84 -1
  133. package/dist/entry.js +15 -9
  134. package/dist/extensionAPI.js +8 -0
  135. package/dist/gateway/control-ui.js +8 -1
  136. package/dist/gateway/hooks-mapping.js +3 -0
  137. package/dist/gateway/hooks.js +65 -0
  138. package/dist/gateway/net.js +96 -31
  139. package/dist/gateway/node-command-policy.js +50 -15
  140. package/dist/gateway/origin-check.js +56 -0
  141. package/dist/gateway/protocol/client-info.js +9 -0
  142. package/dist/gateway/protocol/index.js +9 -2
  143. package/dist/gateway/protocol/schema/agents-models-skills.js +71 -1
  144. package/dist/gateway/protocol/schema/cron.js +22 -10
  145. package/dist/gateway/protocol/schema/protocol-schemas.js +16 -2
  146. package/dist/gateway/protocol/schema/sessions.js +12 -0
  147. package/dist/gateway/server/hooks.js +1 -1
  148. package/dist/gateway/server-broadcast.js +26 -9
  149. package/dist/gateway/server-chat.js +112 -23
  150. package/dist/gateway/server-discovery-runtime.js +10 -2
  151. package/dist/gateway/server-http.js +109 -11
  152. package/dist/gateway/server-methods/agent-timestamp.js +60 -0
  153. package/dist/gateway/server-methods/agents.js +321 -2
  154. package/dist/gateway/server-methods/usage.js +559 -16
  155. package/dist/gateway/server-runtime-state.js +22 -8
  156. package/dist/gateway/server-startup-memory.js +16 -0
  157. package/dist/gateway/server.impl.js +5 -1
  158. package/dist/gateway/session-utils.fs.js +23 -25
  159. package/dist/gateway/session-utils.js +20 -10
  160. package/dist/gateway/sessions-patch.js +7 -22
  161. package/dist/gateway/test-helpers.mocks.js +11 -7
  162. package/dist/gateway/test-helpers.server.js +35 -2
  163. package/dist/imessage/constants.js +2 -0
  164. package/dist/imessage/monitor/deliver.js +4 -1
  165. package/dist/imessage/monitor/monitor-provider.js +51 -1
  166. package/dist/infra/bonjour-discovery.js +131 -70
  167. package/dist/infra/control-ui-assets.js +134 -12
  168. package/dist/infra/errors.js +12 -0
  169. package/dist/infra/exec-approvals.js +266 -57
  170. package/dist/infra/format-time/format-datetime.js +79 -0
  171. package/dist/infra/format-time/format-duration.js +81 -0
  172. package/dist/infra/format-time/format-relative.js +80 -0
  173. package/dist/infra/heartbeat-runner.js +140 -49
  174. package/dist/infra/home-dir.js +54 -0
  175. package/dist/infra/net/fetch-guard.js +122 -0
  176. package/dist/infra/net/ssrf.js +65 -29
  177. package/dist/infra/outbound/abort.js +14 -0
  178. package/dist/infra/outbound/message-action-runner.js +77 -13
  179. package/dist/infra/outbound/outbound-session.js +143 -37
  180. package/dist/infra/poolbot-root.js +43 -1
  181. package/dist/infra/session-cost-usage.js +631 -41
  182. package/dist/infra/state-migrations.js +317 -47
  183. package/dist/infra/update-global.js +35 -0
  184. package/dist/infra/update-runner.js +149 -43
  185. package/dist/infra/warning-filter.js +65 -0
  186. package/dist/infra/widearea-dns.js +30 -9
  187. package/dist/logging/redact-identifier.js +12 -0
  188. package/dist/media/fetch.js +81 -58
  189. package/dist/media/store.js +2 -0
  190. package/dist/media-understanding/apply.js +403 -3
  191. package/dist/media-understanding/attachments.js +38 -27
  192. package/dist/media-understanding/defaults.js +16 -0
  193. package/dist/media-understanding/providers/deepgram/audio.js +22 -14
  194. package/dist/media-understanding/providers/google/audio.js +24 -17
  195. package/dist/media-understanding/providers/google/video.js +24 -17
  196. package/dist/media-understanding/providers/image.js +3 -3
  197. package/dist/media-understanding/providers/index.js +4 -1
  198. package/dist/media-understanding/providers/openai/audio.js +22 -14
  199. package/dist/media-understanding/providers/shared.js +16 -11
  200. package/dist/media-understanding/providers/zai/index.js +6 -0
  201. package/dist/media-understanding/runner.js +158 -90
  202. package/dist/memory/batch-voyage.js +277 -0
  203. package/dist/memory/embeddings-voyage.js +75 -0
  204. package/dist/memory/embeddings.js +28 -16
  205. package/dist/memory/internal.js +101 -18
  206. package/dist/memory/manager.js +154 -48
  207. package/dist/memory/search-manager.js +173 -0
  208. package/dist/memory/session-files.js +9 -3
  209. package/dist/node-host/runner.js +34 -24
  210. package/dist/node-host/with-timeout.js +27 -0
  211. package/dist/plugins/commands.js +5 -1
  212. package/dist/plugins/config-state.js +86 -7
  213. package/dist/plugins/source-display.js +51 -0
  214. package/dist/process/exec.js +20 -2
  215. package/dist/routing/resolve-route.js +12 -0
  216. package/dist/routing/session-key.js +15 -0
  217. package/dist/runtime.js +2 -0
  218. package/dist/security/audit-extra.async.js +601 -0
  219. package/dist/security/audit-extra.js +2 -830
  220. package/dist/security/audit-extra.sync.js +505 -0
  221. package/dist/security/channel-metadata.js +34 -0
  222. package/dist/security/external-content.js +88 -6
  223. package/dist/security/skill-scanner.js +330 -0
  224. package/dist/sessions/session-key-utils.js +7 -0
  225. package/dist/signal/monitor/event-handler.js +80 -1
  226. package/dist/slack/monitor/media.js +85 -15
  227. package/dist/tailscale/detect.js +1 -2
  228. package/dist/telegram/bot/helpers.js +109 -28
  229. package/dist/telegram/bot-handlers.js +144 -3
  230. package/dist/telegram/bot-message-context.js +37 -10
  231. package/dist/telegram/bot-message-dispatch.js +54 -17
  232. package/dist/telegram/bot-native-commands.js +86 -29
  233. package/dist/telegram/bot.js +30 -29
  234. package/dist/telegram/model-buttons.js +163 -0
  235. package/dist/telegram/monitor.js +110 -85
  236. package/dist/telegram/send.js +129 -47
  237. package/dist/terminal/restore.js +45 -0
  238. package/dist/test-helpers/state-dir-env.js +16 -0
  239. package/dist/tts/tts.js +12 -6
  240. package/dist/tui/tui-session-actions.js +166 -54
  241. package/dist/utils/fetch-timeout.js +20 -0
  242. package/dist/utils/normalize-secret-input.js +19 -0
  243. package/dist/utils/transcript-tools.js +58 -0
  244. package/dist/utils.js +45 -14
  245. package/dist/version.js +42 -5
  246. package/dist/wizard/clack-prompter.js +9 -6
  247. package/extensions/googlechat/node_modules/.bin/poolbot +21 -0
  248. package/extensions/googlechat/package.json +2 -2
  249. package/extensions/line/node_modules/.bin/poolbot +21 -0
  250. package/extensions/line/package.json +1 -1
  251. package/extensions/matrix/node_modules/.bin/poolbot +21 -0
  252. package/extensions/matrix/package.json +1 -1
  253. package/extensions/memory-core/node_modules/.bin/poolbot +21 -0
  254. package/extensions/memory-core/package.json +4 -1
  255. package/extensions/twitch/node_modules/.bin/poolbot +21 -0
  256. package/extensions/twitch/package.json +1 -1
  257. package/package.json +183 -24
  258. package/dist/control-ui/assets/index-CmNMuoem.js.map +0 -1
@@ -1,24 +1,24 @@
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(`
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,Es=qt.ShadowRoot&&(qt.ShadyCSS===void 0||qt.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Is=Symbol(),Pi=new WeakMap;let Ya=class{constructor(t,n,s){if(this._$cssResult$=!0,s!==Is)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(Es&&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 Ur=e=>new Ya(typeof e=="string"?e:e+"",void 0,Is),Kr=(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 Ya(n,e,Is)},Hr=(e,t)=>{if(Es)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=Es?e=>e:e=>e instanceof CSSStyleSheet?(t=>{let n="";for(const s of t.cssRules)n+=s.cssText;return Ur(n)})(e):e;const{is:zr,defineProperty:jr,getOwnPropertyDescriptor:qr,getOwnPropertyNames:Wr,getOwnPropertySymbols:Vr,getPrototypeOf:Gr}=Object,nn=globalThis,Oi=nn.trustedTypes,Yr=Oi?Oi.emptyScript:"",Qr=nn.reactiveElementPolyfillSupport,yt=(e,t)=>e,Gt={toAttribute(e,t){switch(t){case Boolean:e=e?Yr: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)=>!zr(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&&jr(this.prototype,t,i)}}static getPropertyDescriptor(t,n,s){const{get:i,set:a}=qr(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=Gr(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=[...Wr(n),...Vr(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 Hr(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,Qr?.({ReactiveElement:Ye}),(nn.reactiveElementVersions??=[]).push("2.1.2");const Ms=globalThis,Bi=e=>e,Yt=Ms.trustedTypes,Fi=Yt?Yt.createPolicy("lit-html",{createHTML:e=>e}):void 0,Qa="$lit$",xe=`lit$${Math.random().toFixed(9).slice(2)}$`,Za="?"+xe,Zr=`<${Za}>`,Oe=document,$t=()=>Oe.createComment(""),xt=e=>e===null||typeof e!="object"&&typeof e!="function",Rs=Array.isArray,Jr=e=>Rs(e)||typeof e?.[Symbol.iterator]=="function",Bn=`[
2
+ \f\r]`,rt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ui=/-->/g,Ki=/>/g,Ie=RegExp(`>|${Bn}(?:([^\\s"'>=/]+)(${Bn}*=${Bn}*(?:[^
3
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Hi=/'/g,zi=/"/g,Ja=/^(?:script|style|textarea|title)$/i,Xr=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),c=Xr(1),Se=Symbol.for("lit-noChange"),f=Symbol.for("lit-nothing"),ji=new WeakMap,Pe=Oe.createTreeWalker(Oe,129);function Xa(e,t){if(!Rs(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return Fi!==void 0?Fi.createHTML(t):t}const el=(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?(Ja.test(d[2])&&(i=RegExp("</"+d[2],"g")),o=Ie):d[3]!==void 0&&(o=Ie):o===Ie?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?Ie:d[3]==='"'?zi:Hi):o===zi||o===Hi?o=Ie:o===Ui||o===Ki?o=rt:(o=Ie,i=void 0);const v=o===Ie&&e[l+1].startsWith("/>")?" ":"";a+=o===rt?r+Zr:u>=0?(s.push(p),r.slice(0,u)+Qa+r.slice(u)+xe+v):r+xe+(u===-2?l:v)}return[Xa(e,a+(e[n]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]};let ss=class eo{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]=el(t,n);if(this.el=eo.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(Qa)){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]==="."?nl:w[1]==="?"?sl:w[1]==="@"?il:an}),i.removeAttribute(u)}else u.startsWith(xe)&&(r.push({type:6,index:a}),i.removeAttribute(u));if(Ja.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===Za)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 tl{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 al(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 to{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,n,s,i){this.type=2,this._$AH=f,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===f||t==null||t===""?(this._$AH!==f&&this._$AR(),this._$AH=f):t!==this._$AH&&t!==Se&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Jr(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!==f&&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=ss.createElement(Xa(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(n);else{const a=new tl(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 ss(t)),n}k(t){Rs(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 to(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=f,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=f}_$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===f?t=f:t!==f&&(t+=(p??"")+a[r+1]),this._$AH[r]=p}o&&!i&&this.j(t)}j(t){t===f?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}let nl=class extends an{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===f?void 0:t}},sl=class extends an{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==f)}},il=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)??f)===Se)return;const s=this._$AH,i=t===f&&s!==f||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,a=t!==f&&(s===f||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)}},al=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 ol={I:sn},rl=Ms.litHtmlPolyfillSupport;rl?.(ss,sn),(Ms.litHtmlVersions??=[]).push("3.3.2");const ll=(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 Ps=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=ll(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,Ps.litElementHydrateSupport?.({LitElement:Ze});const cl=Ps.litElementPolyfillSupport;cl?.({LitElement:Ze});(Ps.litElementVersions??=[]).push("4.2.2");const no=e=>(t,n)=>{n!==void 0?n.addInitializer(()=>{customElements.define(e,t)}):customElements.define(e,t)};const dl={attribute:!0,type:String,converter:Gt,reflect:!1,hasChanged:Ls},ul=(e=dl,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"?ul(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 pl=50,hl=200,fl="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 is(e){const t=qi(e?.name,pl)??fl,n=qi(e?.avatar??void 0,hl)??null;return{agentId:typeof e?.agentId=="string"&&e.agentId.trim()?e.agentId.trim():null,name:t,avatar:n}}function gl(){return is(typeof window>"u"?{}:{name:window.__CLAWDBOT_ASSISTANT_NAME__,avatar:window.__CLAWDBOT_ASSISTANT_AVATAR__})}const so="poolbot.control.settings.v1";function vl(){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(so);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 ml(e){localStorage.setItem(so,JSON.stringify(e))}function io(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 yl=[{label:"Chat",tabs:["chat"]},{label:"Control",tabs:["overview","channels","instances","sessions","cron"]},{label:"Agent",tabs:["skills","nodes"]},{label:"Settings",tabs:["config","debug","logs"]}],ao={overview:"/overview",channels:"/channels",instances:"/instances",sessions:"/sessions",cron:"/cron",skills:"/skills",nodes:"/nodes",chat:"/chat",config:"/config",debug:"/debug",logs:"/logs"},oo=new Map(Object.entries(ao).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 ln(e,t=""){const n=rn(t),s=ao[e];return n?`${n}${s}`:s}function ro(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":oo.get(i)??null}function bl(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(oo.has(i)){const a=n.slice(0,s);return a.length?`/${a.join("/")}`:""}}return`/${n.join("/")}`}function wl(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 as(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 $l(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 ~/.poolbot/poolbot.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>`},xl=/<\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 Vi(e){const t=[],n=/(^|\n)(```|~~~)[^\n]*\n[\s\S]*?(?:\n\2(?:\n|$)|$)/g;for(const i of e.matchAll(n)){const a=(i.index??0)+i[1].length;t.push({start:a,end:a+i[0].length-i[1].length})}const s=/`+[^`]+`+/g;for(const i of e.matchAll(s)){const a=i.index??0,o=a+i[0].length;t.some(r=>a>=r.start&&o<=r.end)||t.push({start:a,end:o})}return t.sort((i,a)=>i.start-a.start),t}function Gi(e,t){return t.some(n=>e>=n.start&&e<n.end)}function kl(e,t){return e.trimStart()}function Al(e,t){if(!e||!xl.test(e))return e;let n=e;if(Dt.test(n)){Dt.lastIndex=0;const l=[],r=Vi(n);for(const p of n.matchAll(Dt)){const d=p.index??0;l.push({start:d,length:p[0].length,inCode:Gi(d,r)})}for(let p=l.length-1;p>=0;p--){const d=l[p];d.inCode||(n=n.slice(0,d.start)+n.slice(d.start+d.length))}}else Dt.lastIndex=0;const s=Vi(n);Wi.lastIndex=0;let i="",a=0,o=!1;for(const l of n.matchAll(Wi)){const r=l.index??0,p=l[1]==="/";Gi(r,s)||(o?p&&(o=!1):(i+=n.slice(a,r),p||(o=!0)),a=r+l[0].length)}return i+=n.slice(a),kl(i)}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`}const Sl=O;function lo(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 os(e){return!e||e.length===0?"none":e.filter(t=>!!(t&&t.trim())).join(", ")}function rs(e,t=120){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function co(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 Fn(e){return Al(e)}const _l=/^\[([^\]]+)\]\s*/,Tl=["WebChat","WhatsApp","Telegram","Signal","Slack","Discord","iMessage","Teams","Matrix","Zalo","Zalo Personal","BlueBubbles"],Un=new WeakMap,Kn=new WeakMap;function Cl(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:Tl.some(t=>e.startsWith(`${t} `))}function Hn(e){const t=e.match(_l);if(!t)return e;const n=t[1]??"";return Cl(n)?e.slice(t[0].length):e}function ls(e){const t=e,n=typeof t.role=="string"?t.role:"",s=t.content;if(typeof s=="string")return n==="assistant"?Fn(s):Hn(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"?Fn(a):Hn(a)}}return typeof t.text=="string"?n==="assistant"?Fn(t.text):Hn(t.text):null}function uo(e){if(!e||typeof e!="object")return ls(e);const t=e;if(Un.has(t))return Un.get(t)??null;const n=ls(e);return Un.set(t,n),n}function Yi(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=Il(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 El(e){if(!e||typeof e!="object")return Yi(e);const t=e;if(Kn.has(t))return Kn.get(t)??null;const n=Yi(e);return Kn.set(t,n),n}function Il(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 Ll(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 Qi=!1;function Zi(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 Ml(){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 Rl(){Qi||(Qi=!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),Zi(t)}return Rl(),Zi(Ml())}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 Pl(e){const t=/^data:([^;]+);base64,(.+)$/.exec(e);return t?{mimeType:t[1],content:t[2]}:null}async function Nl(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=Pl(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 Ol(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 Dl(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=ls(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 Bl(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 Fl(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 Ji=50,Ul=80,Kl=12e4;function Hl(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 Xi(e){if(e==null)return null;if(typeof e=="number"||typeof e=="boolean")return String(e);const t=Hl(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=co(n,Kl);return s.truncated?`${s.text}
12
+
13
+ … truncated (${s.total} chars, showing first ${s.text.length}).`:s.text}function zl(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 jl(e){if(e.toolStreamOrder.length<=Ji)return;const t=e.toolStreamOrder.length-Ji,n=e.toolStreamOrder.splice(0,t);for(const s of n)e.toolStreamById.delete(s)}function ql(e){e.chatToolMessages=e.toolStreamOrder.map(t=>e.toolStreamById.get(t)?.message).filter(t=>!!t)}function cs(e){e.toolStreamSyncTimer!=null&&(clearTimeout(e.toolStreamSyncTimer),e.toolStreamSyncTimer=null),ql(e)}function Wl(e,t=!1){if(t){cs(e);return}e.toolStreamSyncTimer==null&&(e.toolStreamSyncTimer=window.setTimeout(()=>cs(e),Ul))}function cn(e){e.toolStreamById.clear(),e.toolStreamOrder=[],e.chatToolMessages=[],cs(e)}const Vl=5e3;function Gl(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},Vl))}function Yl(e,t){if(!t)return;if(t.stream==="compaction"){Gl(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"?Xi(s.partialResult):o==="result"?Xi(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=zl(d),jl(e),Wl(e,o==="result")}function dn(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 po(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 Ql(e,t){const n=t.currentTarget;if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;e.chatUserNearBottom=s<200}function Zl(e,t){const n=t.currentTarget;if(!n)return;const s=n.scrollHeight-n.scrollTop-n.clientHeight;e.logsAtBottom=s<80}function Jl(e){e.chatHasAutoScrolled=!1,e.chatUserNearBottom=!0}function Xl(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=`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(`
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=`poolbot-logs-${t}-${a}.log`,i.click(),URL.revokeObjectURL(s)}function ec(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 ho(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 fo(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",{});nc(e,t)}catch(t){e.lastError=String(t)}finally{e.configLoading=!1}}}async function go(e){if(!(!e.client||!e.connected)&&!e.configSchemaLoading){e.configSchemaLoading=!0;try{const t=await e.client.request("config.schema",{});tc(e,t)}catch(t){e.lastError=String(t)}finally{e.configSchemaLoading=!1}}}function tc(e,t){e.configSchema=t.schema??null,e.configUiHints=t.uiHints??{},e.configSchemaVersion=t.version??null}function nc(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 ds(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 sc(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 ic(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??{});ho(s,t,n),e.configForm=s,e.configFormDirty=!0,e.configFormMode==="form"&&(e.configRaw=et(s))}function ea(e,t){const n=De(e.configForm??e.configSnapshot?.config??{});fo(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 un(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 ac(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 oc(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 rc(e){if(!(!e.client||!e.connected||e.cronBusy)){e.cronBusy=!0,e.cronError=null;try{const t=ac(e.cronForm),n=oc(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 un(e),await Tt(e)}catch(t){e.cronError=String(t)}finally{e.cronBusy=!1}}}async function lc(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 un(e),await Tt(e)}catch(s){e.cronError=String(s)}finally{e.cronBusy=!1}}}async function cc(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 vo(e,t.id)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function dc(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 un(e),await Tt(e)}catch(n){e.cronError=String(n)}finally{e.cronBusy=!1}}}async function vo(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 uc(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 pc(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 hc(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 pn(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 fc(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 gc=2e3,vc=new Set(["trace","debug","info","warn","error","fatal"]);function mc(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 yc(e){if(typeof e!="string")return null;const t=e.toLowerCase();return vc.has(t)?t:null}function bc(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=yc(n?.logLevelName??n?.level),a=typeof t[0]=="string"?t[0]:typeof n?.name=="string"?n?.name:null,o=mc(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(bc),o=!!(t?.reset||s.reset||e.logsCursor==null);e.logsEntries=o?a:[...e.logsEntries,...a].slice(-gc),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 mo={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:W,n:Wt,Gx:ta,Gy:na,a:zn,d:jn,h:wc}=mo,Be=32,Ds=64,$c=(...e)=>{"captureStackTrace"in Error&&typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(...e)},H=(e="")=>{const t=new Error(e);throw $c(t,H),t},xc=e=>typeof e=="bigint",kc=e=>typeof e=="string",Ac=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array",_e=(e,t,n="")=>{const s=Ac(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},hn=e=>new Uint8Array(e),yo=e=>Uint8Array.from(e),bo=(e,t)=>e.toString(16).padStart(t,"0"),wo=e=>Array.from(_e(e)).map(t=>bo(t,2)).join(""),ve={_0:48,_9:57,A:65,F:70,a:97,f:102},sa=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)},$o=e=>{const t="hex invalid";if(!kc(e))return H(t);const n=e.length,s=n/2;if(n%2)return H(t);const i=hn(s);for(let a=0,o=0;a<s;a++,o+=2){const l=sa(e.charCodeAt(o)),r=sa(e.charCodeAt(o+1));if(l===void 0||r===void 0)return H(t);i[a]=l*16+r}return i},xo=()=>globalThis?.crypto,Sc=()=>xo()?.subtle??H("crypto.subtle must be defined, consider polyfill"),St=(...e)=>{const t=hn(e.reduce((s,i)=>s+_e(i).length,0));let n=0;return e.forEach(s=>{t.set(s,n),n+=s.length}),t},_c=(e=Be)=>xo().getRandomValues(hn(e)),Zt=BigInt,Re=(e,t,n,s="bad number: out of range")=>xc(e)&&t<=e&&e<n?e:H(s),A=(e,t=W)=>{const n=e%t;return n>=0n?n:t+n},ko=e=>A(e,Wt),Tc=(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")},Cc=e=>{const t=To[e];return typeof t!="function"&&H("hashes."+e+" not set"),t},qn=e=>e instanceof ee?e:H("Point expected"),us=2n**256n;class ee{static BASE;static ZERO;X;Y;Z;T;constructor(t,n,s,i){const a=us;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 mo}static fromAffine(t){return new ee(t.x,t.y,1n,A(t.x*t.y))}static fromBytes(t,n=!1){const s=jn,i=yo(_e(t,Be)),a=t[31];i[31]=a&-129;const o=So(i);Re(o,0n,n?us:W);const r=A(o*o),p=A(r-1n),d=A(s*r+1n);let{isValid:u,value:g}=Ic(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($o(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){const t=zn,n=jn,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}=qn(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=zn,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}=qn(t),d=zn,u=jn,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),L=A($+w),P=A(v-d*g),I=A(k*_),C=A(L*P),E=A(k*P),pe=A(_*L);return new ee(I,C,pe,E)}subtract(t){return this.add(qn(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 Kc(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=Tc(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=Ao(n);return s[31]|=t&1n?128:0,s}toHex(){return wo(this.toBytes())}clearCofactor(){return this.multiply(Zt(wc),!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(ta,na,1n,A(ta*na)),Qe=new ee(0n,1n,1n,0n);ee.BASE=Fe;ee.ZERO=Qe;const Ao=e=>$o(bo(Re(e,0n,us),Ds)).reverse(),So=e=>Zt("0x"+wo(yo(_e(e)).reverse())),ce=(e,t)=>{let n=e;for(;t-- >0n;)n*=n,n%=W;return n},Ec=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}},ia=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,Ic=(e,t)=>{const n=A(t*t*t),s=A(n*n*t),i=Ec(e*s).pow_p_5_8;let a=A(e*n*i);const o=A(t*a*a),l=a,r=A(a*ia),p=o===e,d=o===A(-e),u=o===A(-e*ia);return p&&(a=l),(d||u)&&(a=r),(A(a)&1n)===1n&&(a=A(-a)),{isValid:p||d,value:a}},ps=e=>ko(So(e)),Bs=(...e)=>To.sha512Async(St(...e)),Lc=(...e)=>Cc("sha512")(St(...e)),_o=e=>{const t=e.slice(0,Be);t[0]&=248,t[31]&=127,t[31]|=64;const n=e.slice(Be,Ds),s=ps(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(_o),Mc=e=>_o(Lc(_e(e,Be))),Rc=e=>Fs(e).then(t=>t.pointBytes),Pc=e=>Bs(e.hashable).then(e.finish),Nc=(e,t,n)=>{const{pointBytes:s,scalar:i}=e,a=ps(t),o=Fe.multiply(a).toBytes();return{hashable:St(o,s,n),finish:p=>{const d=ko(a+ps(p)*i);return _e(St(o,Ao(d)),Ds)}}},Oc=async(e,t)=>{const n=_e(e),s=await Fs(t),i=await Bs(s.prefix,n);return Pc(Nc(s,i,n))},To={sha512Async:async e=>{const t=Sc(),n=St(e);return hn(await t.digest("SHA-512",n.buffer))},sha512:void 0},Dc=(e=_c(Be))=>e,Bc={getExtendedPublicKeyAsync:Fs,getExtendedPublicKey:Mc,randomSecretKey:Dc},Jt=8,Fc=256,Co=Math.ceil(Fc/Jt)+1,hs=2**(Jt-1),Uc=()=>{const e=[];let t=Fe,n=t;for(let s=0;s<Co;s++){n=t,e.push(n);for(let i=1;i<hs;i++)n=n.add(t),e.push(n);t=n.double()}return e};let aa;const oa=(e,t)=>{const n=t.negate();return e?n:t},Kc=e=>{const t=aa||(aa=Uc());let n=Qe,s=Fe;const i=2**Jt,a=i,o=Zt(i-1),l=Zt(Jt);for(let r=0;r<Co;r++){let p=Number(e&o);e>>=l,p>hs&&(p-=a,e+=1n);const d=r*hs,u=d,g=d+Math.abs(p)-1,v=r%2!==0,w=p<0;p===0?s=s.add(oa(v,t[u])):n=n.add(oa(w,t[g]))}return e!==0n&&H("invalid wnaf"),{p:n,f:s}},Wn="poolbot-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 Eo(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 Hc(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}async function Io(e){const t=await crypto.subtle.digest("SHA-256",e);return Hc(new Uint8Array(t))}async function zc(){const e=Bc.randomSecretKey(),t=await Rc(e);return{deviceId:await Io(t),publicKey:fs(t),privateKey:fs(e)}}async function Us(){try{const n=localStorage.getItem(Wn);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 Io(Eo(s.publicKey));if(i!==s.deviceId){const a={...s,deviceId:i};return localStorage.setItem(Wn,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 zc(),t={version:1,deviceId:e.deviceId,publicKey:e.publicKey,privateKey:e.privateKey,createdAtMs:Date.now()};return localStorage.setItem(Wn,JSON.stringify(t)),e}async function jc(e,t){const n=Eo(e),s=new TextEncoder().encode(t),i=await Oc(s,n);return fs(i)}const Lo="poolbot.device.auth.v1";function Ks(e){return e.trim()}function qc(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(Lo);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 Mo(e){try{window.localStorage.setItem(Lo,JSON.stringify(e))}catch{}}function Wc(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 Ro(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:qc(e.scopes),updatedAtMs:Date.now()};return n.tokens[t]=i,Mo(n),i}function Po(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],Mo(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 Vc(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 Gc(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 Yc(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)&&Ro({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 Qc(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&&Po({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 Zc(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 Jc(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=Zc(t);if(!n){e.lastError="Select a node before loading exec approvals.";return}const s=await e.client.request(n.method,n.params);Xc(e,s)}catch(n){e.lastError=String(n)}finally{e.execApprovalsLoading=!1}}}function Xc(e,t){e.execApprovalsSnapshot=t,e.execApprovalsDirty||(e.execApprovalsForm=De(t.file??{}))}async function ed(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=Jc(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 td(e,t,n){const s=De(e.execApprovalsForm??e.execApprovalsSnapshot?.file??{});ho(s,t,n),e.execApprovalsForm=s,e.execApprovalsDirty=!0}function nd(e,t){const n=De(e.execApprovalsForm??e.execApprovalsSnapshot?.file??{});fo(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 gn(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=gn(n)}finally{e.skillsLoading=!1}}}function sd(e,t,n){e.skillEdits={...e.skillEdits,[t]:n}}async function id(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=gn(s);e.skillsError=i,tt(e,t,{kind:"error",message:i})}finally{e.skillsBusyKey=null}}}async function ad(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=gn(n);e.skillsError=s,tt(e,t,{kind:"error",message:s})}finally{e.skillsBusyKey=null}}}async function od(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=gn(i);e.skillsError=a,tt(e,t,{kind:"error",message:a})}finally{e.skillsBusyKey=null}}}function rd(){return typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function qs(e){return e==="system"?rd():e}const Ft=e=>Number.isNaN(e)?.5:e<=0?0:e>=1?1:e,ld=()=>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")},cd=({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=ld();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 dd(e){e.nodesPollInterval==null&&(e.nodesPollInterval=window.setInterval(()=>{fn(e,{quiet:!0})},5e3))}function ud(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"&&pn(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,ml(n),t.theme!==e.theme&&(e.theme=t.theme,vn(e,qs(t.theme))),e.applySessionKey=e.settings.lastActiveSessionKey}function No(e,t){const n=t.trim();n&&e.settings.lastActiveSessionKey!==n&&ke(e,{...e.settings,lastActiveSessionKey:n})}function pd(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 hd(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),Do(e,t,!1)}function fd(e,t,n){cd({nextTheme:t,applyTheme:()=>{e.theme=t,ke(e,{...e.settings,theme:t}),vn(e,qs(t))},context:n,currentTheme:e.theme})}async function Qs(e){e.tab==="overview"&&await Bo(e),e.tab==="channels"&&await xd(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 Td(e),dn(e,!e.chatHasAutoScrolled)),e.tab==="config"&&(await go(e),await ye(e)),e.tab==="debug"&&(await pn(e),e.eventLog=e.eventLogBuffer),e.tab==="logs"&&(e.logsAtBottom=!0,await Os(e,{reset:!0}),po(e,!0))}function gd(){if(typeof window>"u")return"";const e=window.__CLAWDBOT_CONTROL_UI_BASE_PATH__;return typeof e=="string"&&e.trim()?rn(e):bl(window.location.pathname)}function vd(e){e.theme=e.settings.theme??"system",vn(e,qs(e.theme))}function vn(e,t){if(e.themeResolved=t,typeof document>"u")return;const n=document.documentElement;n.dataset.theme=t,n.style.colorScheme=t}function md(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"&&vn(e,n.matches?"dark":"light")},typeof e.themeMedia.addEventListener=="function"){e.themeMedia.addEventListener("change",e.themeMediaHandler);return}e.themeMedia.addListener(e.themeMediaHandler)}function yd(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 bd(e,t){if(typeof window>"u")return;const n=ro(window.location.pathname,e.basePath)??"chat";Oo(e,n),Do(e,n,t)}function wd(e){if(typeof window>"u")return;const t=ro(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})),Oo(e,t)}function Oo(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 Do(e,t,n){if(typeof window>"u")return;const s=kt(ln(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 $d(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 Bo(e){await Promise.all([oe(e,!1),js(e),st(e),Tt(e),pn(e)])}async function xd(e){await Promise.all([oe(e,!0),go(e),ye(e)])}async function Zs(e){await Promise.all([oe(e,!1),Tt(e),un(e)])}function Fo(e){return e.chatSending||!!e.chatRunId}function kd(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 Uo(e){e.connected&&(e.chatMessage="",await Ol(e))}function Ad(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 Ko(e,t,n){cn(e);const s=await Nl(e,t,n?.attachments);return!s&&n?.previousDraft!=null&&(e.chatMessage=n.previousDraft),!s&&n?.previousAttachments&&(e.chatAttachments=n.previousAttachments),s&&No(e,e.sessionKey),s&&n?.restoreDraft&&n.previousDraft?.trim()&&(e.chatMessage=n.previousDraft),s&&n?.restoreAttachments&&n.previousAttachments?.length&&(e.chatAttachments=n.previousAttachments),dn(e),s&&!e.chatRunId&&Ho(e),s}async function Ho(e){if(!e.connected||Fo(e))return;const[t,...n]=e.chatQueue;if(!t)return;e.chatQueue=n,await Ko(e,t.text,{attachments:t.attachments})||(e.chatQueue=[t,...e.chatQueue])}function Sd(e,t){e.chatQueue=e.chatQueue.filter(n=>n.id!==t)}async function _d(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(kd(i)){await Uo(e);return}if(t==null&&(e.chatMessage="",e.chatAttachments=[]),Fo(e)){Ad(e,i,o);return}await Ko(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 Td(e){await Promise.all([Xe(e),st(e),gs(e)]),dn(e,!0)}const Cd=Ho;function Ed(e){const t=io(e.sessionKey);return t?.agentId?t.agentId:e.hello?.snapshot?.sessionDefaults?.defaultAgentId?.trim()||"main"}function Id(e,t){const n=rn(e),s=encodeURIComponent(t);return n?`${n}/avatar/${s}?meta=1`:`/avatar/${s}?meta=1`}async function gs(e){if(!e.connected){e.chatAvatarUrl=null;return}const t=Ed(e);if(!t){e.chatAvatarUrl=null;return}e.chatAvatarUrl=null;const n=Id(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 zo={CHILD:2},jo=e=>(...t)=>({_$litDirective$:e,values:t});let qo=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:Ld}=ol,ra=e=>e,la=()=>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(la(),i),o=s.insertBefore(la(),i);n=new Ld(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=ra(r).nextSibling;ra(s).insertBefore(r,i),r=p}}}return n},Le=(e,t,n=e)=>(e._$AI(t,n),e),Md={},Rd=(e,t=Md)=>e._$AH=t,Pd=e=>e._$AH,Vn=e=>{e._$AR(),e._$AA.remove()};const ca=(e,t,n)=>{const s=new Map;for(let i=t;i<=n;i++)s.set(e[i],i);return s},Wo=jo(class extends qo{constructor(e){if(super(e),e.type!==zo.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=Pd(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]=Le(i[u],a[v]),u++,v++;else if(l[g]===o[w])r[w]=Le(i[g],a[w]),g--,w--;else if(l[u]===o[w])r[w]=Le(i[u],a[w]),lt(e,r[w+1],i[u]),u++,w--;else if(l[g]===o[v])r[v]=Le(i[g],a[v]),lt(e,i[u],i[g]),g--,v++;else if(p===void 0&&(p=ca(o,v,w),d=ca(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]);Le(_,a[v]),r[v]=_}else r[v]=Le(k,a[v]),lt(e,i[u],k),i[$]=null;v++}else Vn(i[g]),g--;else Vn(i[u]),u++;for(;v<=w;){const $=lt(e,r[w+1]);Le($,a[v]),r[v++]=$}for(;u<=g;){const $=i[u++];$!==null&&Vn($)}return this.ut=o,Rd(e,r),Se}});function Vo(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 Go(e){const t=e,n=typeof t.role=="string"?t.role.toLowerCase():"";return n==="toolresult"||n==="tool_result"}class vs extends qo{constructor(t){if(super(t),this.it=f,t.type!==zo.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===f||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:[]}}}vs.directiveName="unsafeHTML",vs.resultType=1;const ms=jo(vs);const{entries:Yo,setPrototypeOf:da,isFrozen:Nd,getPrototypeOf:Od,getOwnPropertyDescriptor:Dd}=Object;let{freeze:Z,seal:ne,create:ys}=Object,{apply:bs,construct:ws}=typeof Reflect<"u"&&Reflect;Z||(Z=function(t){return t});ne||(ne=function(t){return t});bs||(bs=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)});ws||(ws=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),Bd=J(Array.prototype.lastIndexOf),ua=J(Array.prototype.pop),ct=J(Array.prototype.push),Fd=J(Array.prototype.splice),Vt=J(String.prototype.toLowerCase),Gn=J(String.prototype.toString),Yn=J(String.prototype.match),dt=J(String.prototype.replace),Ud=J(String.prototype.indexOf),Kd=J(String.prototype.trim),se=J(Object.prototype.hasOwnProperty),Y=J(RegExp.prototype.test),ut=Hd(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 bs(e,t,s)}}function Hd(e){return function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return ws(e,n)}}function M(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Vt;da&&da(e,null);let s=t.length;for(;s--;){let i=t[s];if(typeof i=="string"){const a=n(i);a!==i&&(Nd(t)||(t[s]=a),i=a)}e[i]=!0}return e}function zd(e){for(let t=0;t<e.length;t++)se(e,t)||(e[t]=null);return e}function de(e){const t=ys(null);for(const[n,s]of Yo(e))se(e,n)&&(Array.isArray(s)?t[n]=zd(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=Dd(e,t);if(s){if(s.get)return J(s.get);if(typeof s.value=="function")return J(s.value)}e=Od(e)}function n(){return null}return n}const pa=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"]),Qn=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"]),Zn=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"]),jd=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"]),Jn=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"]),qd=Z(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ha=Z(["#text"]),fa=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"]),Xn=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"]),ga=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"]),Wd=ne(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Vd=ne(/<%[\w\W]*|[\w\W]*%>/gm),Gd=ne(/\$\{[\w\W]*/gm),Yd=ne(/^data-[\-\w.\u00B7-\uFFFF]+$/),Qd=ne(/^aria-[\-\w]+$/),Qo=ne(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Zd=ne(/^(?:\w+script|data):/i),Jd=ne(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Zo=ne(/^html$/i),Xd=ne(/^[a-z][.\w]*(-[.\w]+)+$/i);var va=Object.freeze({__proto__:null,ARIA_ATTR:Qd,ATTR_WHITESPACE:Jd,CUSTOM_ELEMENT:Xd,DATA_ATTR:Yd,DOCTYPE_NAME:Zo,ERB_EXPR:Vd,IS_ALLOWED_URI:Qo,IS_SCRIPT_OR_DATA:Zd,MUSTACHE_EXPR:Wd,TMPLIT_EXPR:Gd});const ht={element:1,text:3,progressingInstruction:7,comment:8,document:9},eu=function(){return typeof window>"u"?null:window},tu=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}},ma=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Jo(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:eu();const t=T=>Jo(T);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==ht.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"),L=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 I,C="";const{implementation:E,createNodeIterator:pe,createDocumentFragment:$n,getElementsByTagName:xn}=n,{importNode:Tr}=s;let G=ma();t.isSupported=typeof Yo=="function"&&typeof P=="function"&&E&&E.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:kn,ERB_EXPR:An,TMPLIT_EXPR:Sn,DATA_ATTR:Cr,ARIA_ATTR:Er,IS_SCRIPT_OR_DATA:Ir,ATTR_WHITESPACE:di,CUSTOM_ELEMENT:Lr}=va;let{IS_ALLOWED_URI:ui}=va,K=null;const pi=M({},[...pa,...Qn,...Zn,...Jn,...ha]);let z=null;const hi=M({},[...fa,...Xn,...ga,...Ht]);let B=Object.seal(ys(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,_n=null;const He=Object.seal(ys(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let fi=!0,Tn=!0,gi=!1,vi=!0,ze=!1,It=!0,Ce=!1,Cn=!1,En=!1,je=!1,Lt=!1,Mt=!1,mi=!0,yi=!1;const Mr="user-content-";let In=!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 Mn=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",he="http://www.w3.org/1999/xhtml";let We=he,Rn=!1,Pn=null;const Rr=M({},[Rt,Pt,he],Gn);let Nt=M({},["mi","mo","mn","ms","mtext"]),Ot=M({},["annotation-xml"]);const Pr=M({},["title","style","font","a","script"]);let ot=null;const Nr=["application/xhtml+xml","text/html"],Or="text/html";let U=null,Ve=null;const Dr=n.createElement("form"),xi=function(h){return h instanceof RegExp||h instanceof Function},Nn=function(){let h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ve&&Ve===h)){if((!h||typeof h!="object")&&(h={}),h=de(h),ot=Nr.indexOf(h.PARSER_MEDIA_TYPE)===-1?Or:h.PARSER_MEDIA_TYPE,U=ot==="application/xhtml+xml"?Gn:Vt,K=se(h,"ALLOWED_TAGS")?M({},h.ALLOWED_TAGS,U):pi,z=se(h,"ALLOWED_ATTR")?M({},h.ALLOWED_ATTR,U):hi,Pn=se(h,"ALLOWED_NAMESPACES")?M({},h.ALLOWED_NAMESPACES,Gn):Rr,Mn=se(h,"ADD_URI_SAFE_ATTR")?M(de($i),h.ADD_URI_SAFE_ATTR,U):$i,bi=se(h,"ADD_DATA_URI_TAGS")?M(de(wi),h.ADD_DATA_URI_TAGS,U):wi,re=se(h,"FORBID_CONTENTS")?M({},h.FORBID_CONTENTS,U):Ln,it=se(h,"FORBID_TAGS")?M({},h.FORBID_TAGS,U):de({}),_n=se(h,"FORBID_ATTR")?M({},h.FORBID_ATTR,U):de({}),qe=se(h,"USE_PROFILES")?h.USE_PROFILES:!1,fi=h.ALLOW_ARIA_ATTR!==!1,Tn=h.ALLOW_DATA_ATTR!==!1,gi=h.ALLOW_UNKNOWN_PROTOCOLS||!1,vi=h.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ze=h.SAFE_FOR_TEMPLATES||!1,It=h.SAFE_FOR_XML!==!1,Ce=h.WHOLE_DOCUMENT||!1,je=h.RETURN_DOM||!1,Lt=h.RETURN_DOM_FRAGMENT||!1,Mt=h.RETURN_TRUSTED_TYPE||!1,En=h.FORCE_BODY||!1,mi=h.SANITIZE_DOM!==!1,yi=h.SANITIZE_NAMED_PROPS||!1,In=h.KEEP_CONTENT!==!1,at=h.IN_PLACE||!1,ui=h.ALLOWED_URI_REGEXP||Qo,We=h.NAMESPACE||he,Nt=h.MATHML_TEXT_INTEGRATION_POINTS||Nt,Ot=h.HTML_INTEGRATION_POINTS||Ot,B=h.CUSTOM_ELEMENT_HANDLING||{},h.CUSTOM_ELEMENT_HANDLING&&xi(h.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(B.tagNameCheck=h.CUSTOM_ELEMENT_HANDLING.tagNameCheck),h.CUSTOM_ELEMENT_HANDLING&&xi(h.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(B.attributeNameCheck=h.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),h.CUSTOM_ELEMENT_HANDLING&&typeof h.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(B.allowCustomizedBuiltInElements=h.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),ze&&(Tn=!1),Lt&&(je=!0),qe&&(K=M({},ha),z=[],qe.html===!0&&(M(K,pa),M(z,fa)),qe.svg===!0&&(M(K,Qn),M(z,Xn),M(z,Ht)),qe.svgFilters===!0&&(M(K,Zn),M(z,Xn),M(z,Ht)),qe.mathMl===!0&&(M(K,Jn),M(z,ga),M(z,Ht))),h.ADD_TAGS&&(typeof h.ADD_TAGS=="function"?He.tagCheck=h.ADD_TAGS:(K===pi&&(K=de(K)),M(K,h.ADD_TAGS,U))),h.ADD_ATTR&&(typeof h.ADD_ATTR=="function"?He.attributeCheck=h.ADD_ATTR:(z===hi&&(z=de(z)),M(z,h.ADD_ATTR,U))),h.ADD_URI_SAFE_ATTR&&M(Mn,h.ADD_URI_SAFE_ATTR,U),h.FORBID_CONTENTS&&(re===Ln&&(re=de(re)),M(re,h.FORBID_CONTENTS,U)),h.ADD_FORBID_CONTENTS&&(re===Ln&&(re=de(re)),M(re,h.ADD_FORBID_CONTENTS,U)),In&&(K["#text"]=!0),Ce&&M(K,["html","head","body"]),K.table&&(M(K,["tbody"]),delete it.tbody),h.TRUSTED_TYPES_POLICY){if(typeof h.TRUSTED_TYPES_POLICY.createHTML!="function")throw ut('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof h.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ut('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');I=h.TRUSTED_TYPES_POLICY,C=I.createHTML("")}else I===void 0&&(I=tu(v,i)),I!==null&&typeof C=="string"&&(C=I.createHTML(""));Z&&Z(h),Ve=h}},ki=M({},[...Qn,...Zn,...jd]),Ai=M({},[...Jn,...qd]),Br=function(h){let x=P(h);(!x||!x.tagName)&&(x={namespaceURI:We,tagName:"template"});const S=Vt(h.tagName),D=Vt(x.tagName);return Pn[h.namespaceURI]?h.namespaceURI===Pt?x.namespaceURI===he?S==="svg":x.namespaceURI===Rt?S==="svg"&&(D==="annotation-xml"||Nt[D]):!!ki[S]:h.namespaceURI===Rt?x.namespaceURI===he?S==="math":x.namespaceURI===Pt?S==="math"&&Ot[D]:!!Ai[S]:h.namespaceURI===he?x.namespaceURI===Pt&&!Ot[D]||x.namespaceURI===Rt&&!Nt[D]?!1:!Ai[S]&&(Pr[S]||!ki[S]):!!(ot==="application/xhtml+xml"&&Pn[h.namespaceURI]):!1},le=function(h){ct(t.removed,{element:h});try{P(h).removeChild(h)}catch{k(h)}},Ee=function(h,x){try{ct(t.removed,{attribute:x.getAttributeNode(h),from:x})}catch{ct(t.removed,{attribute:null,from:x})}if(x.removeAttribute(h),h==="is")if(je||Lt)try{le(x)}catch{}else try{x.setAttribute(h,"")}catch{}},Si=function(h){let x=null,S=null;if(En)h="<remove></remove>"+h;else{const F=Yn(h,/^[\r\n\t ]+/);S=F&&F[0]}ot==="application/xhtml+xml"&&We===he&&(h='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+h+"</body></html>");const D=I?I.createHTML(h):h;if(We===he)try{x=new g().parseFromString(D,ot)}catch{}if(!x||!x.documentElement){x=E.createDocument(We,"template",null);try{x.documentElement.innerHTML=Rn?C:D}catch{}}const q=x.body||x.documentElement;return h&&S&&q.insertBefore(n.createTextNode(S),q.childNodes[0]||null),We===he?xn.call(x,Ce?"html":"body")[0]:Ce?x.documentElement:q},_i=function(h){return pe.call(h.ownerDocument||h,h,p.SHOW_ELEMENT|p.SHOW_COMMENT|p.SHOW_TEXT|p.SHOW_PROCESSING_INSTRUCTION|p.SHOW_CDATA_SECTION,null)},On=function(h){return h instanceof u&&(typeof h.nodeName!="string"||typeof h.textContent!="string"||typeof h.removeChild!="function"||!(h.attributes instanceof d)||typeof h.removeAttribute!="function"||typeof h.setAttribute!="function"||typeof h.namespaceURI!="string"||typeof h.insertBefore!="function"||typeof h.hasChildNodes!="function")},Ti=function(h){return typeof l=="function"&&h instanceof l};function fe(T,h,x){Kt(T,S=>{S.call(t,h,x,Ve)})}const Ci=function(h){let x=null;if(fe(G.beforeSanitizeElements,h,null),On(h))return le(h),!0;const S=U(h.nodeName);if(fe(G.uponSanitizeElement,h,{tagName:S,allowedTags:K}),It&&h.hasChildNodes()&&!Ti(h.firstElementChild)&&Y(/<[/\w!]/g,h.innerHTML)&&Y(/<[/\w!]/g,h.textContent)||h.nodeType===ht.progressingInstruction||It&&h.nodeType===ht.comment&&Y(/<[/\w]/g,h.data))return le(h),!0;if(!(He.tagCheck instanceof Function&&He.tagCheck(S))&&(!K[S]||it[S])){if(!it[S]&&Ii(S)&&(B.tagNameCheck instanceof RegExp&&Y(B.tagNameCheck,S)||B.tagNameCheck instanceof Function&&B.tagNameCheck(S)))return!1;if(In&&!re[S]){const D=P(h)||h.parentNode,q=L(h)||h.childNodes;if(q&&D){const F=q.length;for(let X=F-1;X>=0;--X){const ge=$(q[X],!0);ge.__removalCount=(h.__removalCount||0)+1,D.insertBefore(ge,_(h))}}}return le(h),!0}return h instanceof r&&!Br(h)||(S==="noscript"||S==="noembed"||S==="noframes")&&Y(/<\/no(script|embed|frames)/i,h.innerHTML)?(le(h),!0):(ze&&h.nodeType===ht.text&&(x=h.textContent,Kt([kn,An,Sn],D=>{x=dt(x,D," ")}),h.textContent!==x&&(ct(t.removed,{element:h.cloneNode()}),h.textContent=x)),fe(G.afterSanitizeElements,h,null),!1)},Ei=function(h,x,S){if(mi&&(x==="id"||x==="name")&&(S in n||S in Dr))return!1;if(!(Tn&&!_n[x]&&Y(Cr,x))){if(!(fi&&Y(Er,x))){if(!(He.attributeCheck instanceof Function&&He.attributeCheck(x,h))){if(!z[x]||_n[x]){if(!(Ii(h)&&(B.tagNameCheck instanceof RegExp&&Y(B.tagNameCheck,h)||B.tagNameCheck instanceof Function&&B.tagNameCheck(h))&&(B.attributeNameCheck instanceof RegExp&&Y(B.attributeNameCheck,x)||B.attributeNameCheck instanceof Function&&B.attributeNameCheck(x,h))||x==="is"&&B.allowCustomizedBuiltInElements&&(B.tagNameCheck instanceof RegExp&&Y(B.tagNameCheck,S)||B.tagNameCheck instanceof Function&&B.tagNameCheck(S))))return!1}else if(!Mn[x]){if(!Y(ui,dt(S,di,""))){if(!((x==="src"||x==="xlink:href"||x==="href")&&h!=="script"&&Ud(S,"data:")===0&&bi[h])){if(!(gi&&!Y(Ir,dt(S,di,"")))){if(S)return!1}}}}}}}return!0},Ii=function(h){return h!=="annotation-xml"&&Yn(h,Lr)},Li=function(h){fe(G.beforeSanitizeAttributes,h,null);const{attributes:x}=h;if(!x||On(h))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),Dn=ge;let j=F==="value"?Dn:Kd(Dn);if(S.attrName=Ge,S.attrValue=j,S.keepAttr=!0,S.forceKeepAttr=void 0,fe(G.uponSanitizeAttribute,h,S),j=S.attrValue,yi&&(Ge==="id"||Ge==="name")&&(Ee(F,h),j=Mr+j),It&&Y(/((--!?|])>)|<\/(style|title|textarea)/i,j)){Ee(F,h);continue}if(Ge==="attributename"&&Yn(j,"href")){Ee(F,h);continue}if(S.forceKeepAttr)continue;if(!S.keepAttr){Ee(F,h);continue}if(!vi&&Y(/\/>/i,j)){Ee(F,h);continue}ze&&Kt([kn,An,Sn],Ri=>{j=dt(j,Ri," ")});const Mi=U(h.nodeName);if(!Ei(Mi,Ge,j)){Ee(F,h);continue}if(I&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!X)switch(v.getAttributeType(Mi,Ge)){case"TrustedHTML":{j=I.createHTML(j);break}case"TrustedScriptURL":{j=I.createScriptURL(j);break}}if(j!==Dn)try{X?h.setAttributeNS(X,F,j):h.setAttribute(F,j),On(h)?le(h):ua(t.removed)}catch{Ee(F,h)}}fe(G.afterSanitizeAttributes,h,null)},Fr=function T(h){let x=null;const S=_i(h);for(fe(G.beforeSanitizeShadowDOM,h,null);x=S.nextNode();)fe(G.uponSanitizeShadowNode,x,null),Ci(x),Li(x),x.content instanceof a&&T(x.content);fe(G.afterSanitizeShadowDOM,h,null)};return t.sanitize=function(T){let h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},x=null,S=null,D=null,q=null;if(Rn=!T,Rn&&(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(Cn||Nn(h),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===ht.element&&S.nodeName==="BODY"||S.nodeName==="HTML"?x=S:x.appendChild(S);else{if(!je&&!ze&&!Ce&&T.indexOf("<")===-1)return I&&Mt?I.createHTML(T):T;if(x=Si(T),!x)return je?null:Mt?C:""}x&&En&&le(x.firstChild);const F=_i(at?T:x);for(;D=F.nextNode();)Ci(D),Li(D),D.content instanceof a&&Fr(D.content);if(at)return T;if(je){if(Lt)for(q=$n.call(x.ownerDocument);x.firstChild;)q.appendChild(x.firstChild);else q=x;return(z.shadowroot||z.shadowrootmode)&&(q=Tr.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(Zo,x.ownerDocument.doctype.name)&&(X="<!DOCTYPE "+x.ownerDocument.doctype.name+`>
17
+ `+X),ze&&Kt([kn,An,Sn],ge=>{X=dt(X,ge," ")}),I&&Mt?I.createHTML(X):X},t.setConfig=function(){let T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Nn(T),Cn=!0},t.clearConfig=function(){Ve=null,Cn=!1},t.isValidAttribute=function(T,h,x){Ve||Nn({});const S=U(T),D=U(h);return Ei(S,D,x)},t.addHook=function(T,h){typeof h=="function"&&ct(G[T],h)},t.removeHook=function(T,h){if(h!==void 0){const x=Bd(G[T],h);return x===-1?void 0:Fd(G[T],x,1)[0]}return ua(G[T])},t.removeHooks=function(T){G[T]=[]},t.removeAllHooks=function(){G=ma()},t}var $s=Jo();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 Xo(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 nu=(()=>{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")},su=/^(?:[ \t]*(?:\n|$))+/,iu=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,au=/^ {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+|$)/,ou=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ei=/(?:[*+-]|\d{1,9}[.)])/,er=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,tr=R(er).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(),ru=R(er).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]+)*)/,lu=/^[^\n]+/,ni=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,cu=R(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ni).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),du=R(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ei).getRegex(),mn="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]*?(?:-->|$))/,uu=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",mn).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),nr=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",mn).getRegex(),pu=R(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",nr).getRegex(),ii={blockquote:pu,code:iu,def:cu,fences:au,heading:ou,hr:Et,html:uu,lheading:tr,list:du,newline:su,paragraph:nr,table:bt,text:lu},ya=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",mn).getRegex(),hu={...ii,lheading:ru,table:ya,paragraph:R(ti).replace("hr",Et).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ya).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",mn).getRegex()},fu={...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",tr).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},gu=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,vu=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,sr=/^( {2,}|\\)\n(?!\s*$)/,mu=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,yn=/[\p{P}\p{S}]/u,ai=/[\s\p{P}\p{S}]/u,ir=/[^\s\p{P}\p{S}]/u,yu=R(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ai).getRegex(),ar=/(?!~)[\p{P}\p{S}]/u,bu=/(?!~)[\s\p{P}\p{S}]/u,wu=/(?:[^\s\p{P}\p{S}]|~)/u,$u=R(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",nu?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),or=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,xu=R(or,"u").replace(/punct/g,yn).getRegex(),ku=R(or,"u").replace(/punct/g,ar).getRegex(),rr="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Au=R(rr,"gu").replace(/notPunctSpace/g,ir).replace(/punctSpace/g,ai).replace(/punct/g,yn).getRegex(),Su=R(rr,"gu").replace(/notPunctSpace/g,wu).replace(/punctSpace/g,bu).replace(/punct/g,ar).getRegex(),_u=R("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ir).replace(/punctSpace/g,ai).replace(/punct/g,yn).getRegex(),Tu=R(/\\(punct)/,"gu").replace(/punct/g,yn).getRegex(),Cu=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(),Eu=R(si).replace("(?:-->|$)","-->").getRegex(),Iu=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",Eu).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Xt=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Lu=R(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Xt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),lr=R(/^!?\[(label)\]\[(ref)\]/).replace("label",Xt).replace("ref",ni).getRegex(),cr=R(/^!?\[(ref)\](?:\[\])?/).replace("ref",ni).getRegex(),Mu=R("reflink|nolink(?!\\()","g").replace("reflink",lr).replace("nolink",cr).getRegex(),ba=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,oi={_backpedal:bt,anyPunctuation:Tu,autolink:Cu,blockSkip:$u,br:sr,code:vu,del:bt,emStrongLDelim:xu,emStrongRDelimAst:Au,emStrongRDelimUnd:_u,escape:gu,link:Lu,nolink:cr,punctuation:yu,reflink:lr,reflinkSearch:Mu,tag:Iu,text:mu,url:bt},Ru={...oi,link:R(/^!?\[(label)\]\((.*?)\)/).replace("label",Xt).getRegex(),reflink:R(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Xt).getRegex()},xs={...oi,emStrongRDelimAst:Su,emStrongLDelim:ku,url:R(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",ba).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",ba).getRegex()},Pu={...xs,br:R(sr).replace("{2,}","*").getRegex(),text:R(xs.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},zt={normal:ii,gfm:hu,pedantic:fu},ft={normal:oi,gfm:xs,breaks:Pu,pedantic:Ru},Nu={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},wa=e=>Nu[e];function me(e,t){if(t){if(Q.escapeTest.test(e))return e.replace(Q.escapeReplace,wa)}else if(Q.escapeTestNoEncode.test(e))return e.replace(Q.escapeReplaceNoEncode,wa);return e}function $a(e){try{e=encodeURI(e).replace(Q.percentDecode,"%")}catch{return null}return e}function xa(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 Ou(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 ka(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 Du(e,t,n){let s=e.match(n.other.indentCodeCompensation);if(s===null)return t;let i=s[1];return t.split(`
19
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=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],`
21
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],s=Du(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
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(`
@@ -33,13 +33,13 @@ ${d}`:d;let u=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
33
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
34
  `,1)[0].replace(this.rules.other.listReplaceTabs,$=>" ".repeat(3*$.length)),g=e.split(`
35
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,`
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),L=this.rules.other.headingBeginRegex(w),P=this.rules.other.htmlBeginRegex(w);for(;e;){let I=e.split(`
37
+ `,1)[0],C;if(g=I,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),C=g):C=g.replace(this.rules.other.tabCharGlobal," "),_.test(g)||L.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)||L.test(u)||k.test(u))break;d+=`
39
+ `+g}!v&&!g.trim()&&(v=!0),p+=I+`
40
+ `,e=e.substring(I.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=xa(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(xa(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=Ou(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)),ka(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 ka(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 ks{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:ft.normal};this.options.pedantic?(n.block=zt.pedantic,n.inline=ft.pedantic):this.options.gfm&&(n.block=zt.gfm,this.options.breaks?n.inline=ft.breaks:n.inline=ft.gfm),this.tokenizer.rules=n}static get rules(){return{block:zt,inline:ft}}static lex(t,n){return new ks(n).lex(t)}static lexInline(t,n){return new ks(n).inlineTokens(t)}lex(t){t=t.replace(Q.carriageReturn,`
43
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
  `)?"":`
@@ -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 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?`
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=$a(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=$a(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 As{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 As(n).parse(t)}static parseInline(t,n){return new As(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}},Bu=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 Bu;function N(e,t){return Ue.parse(e,t)}N.options=N.setOptions=function(e){return Ue.setOptions(e),N.defaults=Ue.defaults,Xo(N.defaults),N};N.getDefaults=Xs;N.defaults=Ke;N.use=function(...e){return Ue.use(...e),N.defaults=Ue.defaults,Xo(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 Aa=["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"],Sa=["class","href","rel","target","title","start"];let _a=!1;const Fu=14e4,Uu=4e4,Ku=200,es=5e4,Ne=new Map;function Hu(e){const t=Ne.get(e);return t===void 0?null:(Ne.delete(e),Ne.set(e,t),t)}function Ta(e,t){if(Ne.set(e,t),Ne.size<=Ku)return;const n=Ne.keys().next().value;n&&Ne.delete(n)}function zu(){_a||(_a=!0,$s.addHook("afterSanitizeAttributes",e=>{!(e instanceof HTMLAnchorElement)||!e.getAttribute("href")||(e.setAttribute("rel","noreferrer noopener"),e.setAttribute("target","_blank"))}))}function Ss(e){const t=e.trim();if(!t)return"";if(zu(),t.length<=es){const o=Hu(t);if(o!==null)return o}const n=co(t,Fu),s=n.truncated?`
76
76
 
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`
77
+ … truncated (${n.total} chars, showing first ${n.text.length}).`:"";if(n.text.length>Uu){const l=`<pre class="code-block">${ju(`${n.text}${s}`)}</pre>`,r=$s.sanitize(l,{ALLOWED_TAGS:Aa,ALLOWED_ATTR:Sa});return t.length<=es&&Ta(t,r),r}const i=N.parse(`${n.text}${s}`),a=$s.sanitize(i,{ALLOWED_TAGS:Aa,ALLOWED_ATTR:Sa});return t.length<=es&&Ta(t,a),a}function ju(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}const qu=1500,Wu=2e3,dr="Copy as markdown",Vu="Copied",Gu="Copy failed";async function Yu(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 Qu(e){const t=e.label??dr;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 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)}}}
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 Yu(e.text());if(s.isConnected){if(delete s.dataset.copying,s.removeAttribute("aria-busy"),s.disabled=!1,!i){s.dataset.error="1",jt(s,Gu),window.setTimeout(()=>{s.isConnected&&(delete s.dataset.error,jt(s,t))},Wu);return}s.dataset.copied="1",jt(s,Vu),window.setTimeout(()=>{s.isConnected&&(delete s.dataset.copied,jt(s,t))},qu)}}}
84
84
  >
85
85
  <span class="chat-copy-btn__icon" aria-hidden="true">
86
86
  <span class="chat-copy-btn__icon-copy">${V.copy}</span>
87
87
  <span class="chat-copy-btn__icon-check">${V.check}</span>
88
88
  </span>
89
89
  </button>
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}
90
+ `}function Zu(e){return Qu({text:()=>e,label:dr})}const Ju={icon:"puzzle",detailKeys:["command","path","url","targetUrl","targetId","ref","element","node","nodeId","id","requestId","to","channelId","guildId","userId","name","query","pattern","messageId"]},Xu={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"}}}},ep={fallback:Ju,tools:Xu},ur=ep,Ca=ur.fallback??{icon:"puzzle"},tp=ur.tools??{};function np(e){return(e??"tool").trim()}function sp(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 ip(e){const t=e?.trim();if(t)return t.replace(/_/g," ")}function pr(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=>pr(s)).filter(s=>!!s);if(t.length===0)return;const n=t.slice(0,3).join(", ");return t.length>3?`${n}…`:n}}}function ap(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 op(e,t){for(const n of t){const s=ap(e,n),i=pr(s);if(i)return i}}function rp(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 lp(e){if(!e||typeof e!="object")return;const t=e;return typeof t.path=="string"?t.path:void 0}function cp(e,t){if(!(!e||!t))return e.actions?.[t]??void 0}function dp(e){const t=np(e.name),n=t.toLowerCase(),s=tp[n],i=s?.icon??Ca.icon??"puzzle",a=s?.title??sp(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=cp(s,r),d=ip(p?.label??r);let u;n==="read"&&(u=rp(e.args)),!u&&(n==="write"||n==="edit"||n==="attach")&&(u=lp(e.args));const g=p?.detailKeys??s?.detailKeys??Ca.detailKeys??[];return!u&&g.length>0&&(u=op(e.args,g)),!u&&e.meta&&(u=e.meta),u&&(u=pp(u)),{name:t,icon:i,title:a,label:o,verb:d,detail:u}}function up(e){const t=[];if(e.verb&&t.push(e.verb),e.detail&&t.push(e.detail),t.length!==0)return t.join(" · ")}function pp(e){return e&&e.replace(/\/Users\/[^/]+/g,"~").replace(/\/home\/[^/]+/g,"~")}const hp=80,fp=2,Ea=100;function gp(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 vp(e){const t=e.split(`
91
+ `),n=t.slice(0,fp),s=n.join(`
92
+ `);return s.length>Ea?s.slice(0,Ea)+"…":n.length<t.length?s+"…":s}function mp(e){const t=e,n=yp(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:bp(i.arguments??i.args)})}for(const i of n){const a=String(i.type??"").toLowerCase();if(a!=="toolresult"&&a!=="tool_result")continue;const o=wp(i),l=typeof i.name=="string"?i.name:"tool";s.push({kind:"result",name:l,text:o})}if(Go(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=uo(e)??void 0;s.push({kind:"result",name:i,text:a})}return s}function Ia(e,t){const n=dp({name:e.name,args:e.args}),s=up(n),i=!!e.text?.trim(),a=!!t,o=a?()=>{if(i){t(gp(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,l=i&&(e.text?.length??0)<=cp,r=i&&!l,p=i&&l,d=!i;return c`
96
+ `:""}*No output — tool completed successfully.*`;t(u)}:void 0,l=i&&(e.text?.length??0)<=hp,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":h}
101
- tabindex=${a?"0":h}
102
- @keydown=${a?u=>{u.key!=="Enter"&&u.key!==" "||(u.preventDefault(),o?.())}:h}
100
+ role=${a?"button":f}
101
+ tabindex=${a?"0":f}
102
+ @keydown=${a?u=>{u.key!=="Enter"&&u.key!==" "||(u.preventDefault(),o?.())}:f}
103
103
  >
104
104
  <div class="chat-tool-card__header">
105
105
  <div class="chat-tool-card__title">
106
106
  <span class="chat-tool-card__icon">${V[n.icon]}</span>
107
107
  <span>${n.label}</span>
108
108
  </div>
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}
109
+ ${a?c`<span class="chat-tool-card__action">${i?"View":""} ${V.check}</span>`:f}
110
+ ${d&&!a?c`<span class="chat-tool-card__status">${V.check}</span>`:f}
111
111
  </div>
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}
112
+ ${s?c`<div class="chat-tool-card__detail">${s}</div>`:f}
113
+ ${d?c`<div class="chat-tool-card__status-text muted">Completed</div>`:f}
114
+ ${r?c`<div class="chat-tool-card__preview mono">${vp(e.text)}</div>`:f}
115
+ ${p?c`<div class="chat-tool-card__inline mono">${e.text}</div>`:f}
116
116
  </div>
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`
117
+ `}function yp(e){return Array.isArray(e)?e.filter(Boolean):[]}function bp(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 wp(e){if(typeof e.text=="string")return e.text;if(typeof e.content=="string")return e.content}function $p(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 xp(e){return c`
118
118
  <div class="chat-group assistant">
119
119
  ${li("assistant",e)}
120
120
  <div class="chat-group-messages">
@@ -125,33 +125,33 @@ ${s?`**Command:** \`${s}\`
125
125
  </div>
126
126
  </div>
127
127
  </div>
128
- `}function bp(e,t,n,s){const i=new Date(t).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),a=s?.name??"Assistant";return c`
128
+ `}function kp(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
- ${dr({role:"assistant",content:[{type:"text",text:e}],timestamp:t},{isStreaming:!0,showReasoning:!1},n)}
132
+ ${hr({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 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`
139
+ `}function Ap(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((l,r)=>dr(l.message,{isStreaming:e.isStreaming&&r===e.messages.length-1,showReasoning:t.showReasoning},t.onOpenSidebar))}
143
+ ${e.messages.map((l,r)=>hr(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"?$p(i)?c`<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"?Sp(i)?c`<img
151
151
  class="chat-avatar ${o}"
152
152
  src="${i}"
153
153
  alt="${s}"
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`
154
+ />`:c`<div class="chat-avatar ${o}">${i}</div>`:c`<div class="chat-avatar ${o}">${a}</div>`}function Sp(e){return/^https?:\/\//i.test(e)||/^data:image\//i.test(e)||/^\//.test(e)}function _p(e){return e.length===0?f:c`
155
155
  <div class="chat-message-images">
156
156
  ${e.map(t=>c`
157
157
  <img
@@ -162,15 +162,15 @@ ${s?`**Command:** \`${s}\`
162
162
  />
163
163
  `)}
164
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`
165
+ `}function hr(e,t,n){const s=e,i=typeof s.role=="string"?s.role:"unknown",a=Go(e)||i.toLowerCase()==="toolresult"||i.toLowerCase()==="tool_result"||typeof s.toolCallId=="string"||typeof s.tool_call_id=="string",o=mp(e),l=o.length>0,r=$p(e),p=r.length>0,d=uo(e),u=t.showReasoning&&i==="assistant"?El(e):null,g=d?.trim()?d:null,v=u?Ll(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(_=>Ia(_,n))}`:!w&&!l&&!p?f:c`
166
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))}
167
+ ${$?Zu(w):f}
168
+ ${_p(r)}
169
+ ${v?c`<div class="chat-thinking">${ms(Ss(v))}</div>`:f}
170
+ ${w?c`<div class="chat-text">${ms(Ss(w))}</div>`:f}
171
+ ${o.map(_=>Ia(_,n))}
172
172
  </div>
173
- `}function kp(e){return c`
173
+ `}function Tp(e){return c`
174
174
  <div class="sidebar-panel">
175
175
  <div class="sidebar-header">
176
176
  <div class="sidebar-title">Tool Output</div>
@@ -184,10 +184,10 @@ ${s?`**Command:** \`${s}\`
184
184
  <button @click=${e.onViewRawText} class="btn" style="margin-top: 12px;">
185
185
  View Raw Text
186
186
  </button>
187
- `:e.content?c`<div class="sidebar-markdown">${vs(As(e.content))}</div>`:c`<div class="muted">No content available</div>`}
187
+ `:e.content?c`<div class="sidebar-markdown">${ms(Ss(e.content))}</div>`:c`<div class="muted">No content available</div>`}
188
188
  </div>
189
189
  </div>
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`
190
+ `}var Cp=Object.defineProperty,Ep=Object.getOwnPropertyDescriptor,bn=(e,t,n,s)=>{for(var i=s>1?void 0:s?Ep(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&&Cp(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=Kr`
191
191
  :host {
192
192
  width: 4px;
193
193
  cursor: col-resize;
@@ -213,15 +213,15 @@ ${s?`**Command:** \`${s}\`
213
213
  :host(.dragging) {
214
214
  background: var(--accent, #007bff);
215
215
  }
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`
216
+ `;bn([on({type:Number})],nt.prototype,"splitRatio",2);bn([on({type:Number})],nt.prototype,"minRatio",2);bn([on({type:Number})],nt.prototype,"maxRatio",2);nt=bn([no("resizable-divider")],nt);const Ip=5e3;function Lp(e){return e?e.active?c`
217
217
  <div class="callout info compaction-indicator compaction-indicator--active">
218
218
  ${V.loader} Compacting context...
219
219
  </div>
220
- `:e.completedAt&&Date.now()-e.completedAt<_p?c`
220
+ `:e.completedAt&&Date.now()-e.completedAt<Ip?c`
221
221
  <div class="callout success compaction-indicator compaction-indicator--complete">
222
222
  ${V.check} Context compacted
223
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`
224
+ `:f:f}function Mp(){return`att-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function Rp(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:Mp(),dataUrl:l,mimeType:a.type},p=t.attachments??[];t.onAttachmentsChange?.([...p,r])},o.readAsDataURL(a)}}}function Pp(e){const t=e.attachments??[];return t.length===0?f:c`
225
225
  <div class="chat-attachments">
226
226
  ${t.map(n=>c`
227
227
  <div class="chat-attachment">
@@ -241,23 +241,23 @@ ${s?`**Command:** \`${s}\`
241
241
  </div>
242
242
  `)}
243
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`
244
+ `}function Np(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`
245
245
  <div
246
246
  class="chat-thread"
247
247
  role="log"
248
248
  aria-live="polite"
249
249
  @scroll=${e.onChatScroll}
250
250
  >
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)}
251
+ ${e.loading?c`<div class="muted">Loading chat…</div>`:f}
252
+ ${Wo(Dp(e),v=>v.key,v=>v.kind==="reading-indicator"?xp(l):v.kind==="stream"?kp(v.text,v.startedAt,e.onOpenSidebar,l):v.kind==="group"?Ap(v,{onOpenSidebar:e.onOpenSidebar,showReasoning:o,assistantName:e.assistantName,assistantAvatar:l.avatar}):f)}
253
253
  </div>
254
254
  `;return c`
255
255
  <section class="card chat">
256
- ${e.disabledReason?c`<div class="callout">${e.disabledReason}</div>`:h}
256
+ ${e.disabledReason?c`<div class="callout">${e.disabledReason}</div>`:f}
257
257
 
258
- ${e.error?c`<div class="callout danger">${e.error}</div>`:h}
258
+ ${e.error?c`<div class="callout danger">${e.error}</div>`:f}
259
259
 
260
- ${Tp(e.compactionStatus)}
260
+ ${Lp(e.compactionStatus)}
261
261
 
262
262
  ${e.focusMode?c`
263
263
  <button
@@ -269,7 +269,7 @@ ${s?`**Command:** \`${s}\`
269
269
  >
270
270
  ${V.x}
271
271
  </button>
272
- `:h}
272
+ `:f}
273
273
 
274
274
  <div
275
275
  class="chat-split-container ${u?"chat-split-container--open":""}"
@@ -287,11 +287,11 @@ ${s?`**Command:** \`${s}\`
287
287
  @resize=${v=>e.onSplitRatioChange?.(v.detail.splitRatio)}
288
288
  ></resizable-divider>
289
289
  <div class="chat-sidebar">
290
- ${kp({content:e.sidebarContent??null,error:e.sidebarError??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(`\`\`\`
290
+ ${Tp({content:e.sidebarContent??null,error:e.sidebarError??null,onClose:e.onCloseSidebar,onViewRawText:()=>{!e.sidebarContent||!e.onOpenSidebar||e.onOpenSidebar(`\`\`\`
291
291
  ${e.sidebarContent}
292
292
  \`\`\``)}})}
293
293
  </div>
294
- `:h}
294
+ `:f}
295
295
  </div>
296
296
 
297
297
  ${e.queue.length?c`
@@ -315,10 +315,10 @@ ${e.sidebarContent}
315
315
  `)}
316
316
  </div>
317
317
  </div>
318
- `:h}
318
+ `:f}
319
319
 
320
320
  <div class="chat-compose">
321
- ${Lp(e)}
321
+ ${Pp(e)}
322
322
  <div class="chat-compose__row">
323
323
  <label class="field chat-compose__field">
324
324
  <span>Message</span>
@@ -327,7 +327,7 @@ ${e.sidebarContent}
327
327
  ?disabled=${!e.connected}
328
328
  @keydown=${v=>{v.key==="Enter"&&(v.isComposing||v.keyCode===229||v.shiftKey||e.connected&&(v.preventDefault(),t&&e.onSend()))}}
329
329
  @input=${v=>e.onDraftChange(v.target.value)}
330
- @paste=${v=>Ep(v,e)}
330
+ @paste=${v=>Rp(v,e)}
331
331
  placeholder=${p}
332
332
  ></textarea>
333
333
  </label>
@@ -350,13 +350,13 @@ ${e.sidebarContent}
350
350
  </div>
351
351
  </div>
352
352
  </section>
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">
353
+ `}const La=200;function Op(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=Vo(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 Dp(e){const t=[],n=Array.isArray(e.messages)?e.messages:[],s=Array.isArray(e.toolMessages)?e.toolMessages:[],i=Math.max(0,n.length-La);i>0&&t.push({kind:"message",key:"chat:history:notice",message:{role:"system",content:`Showing last ${La} messages (${i} hidden).`,timestamp:Date.now()}});for(let a=i;a<n.length;a++){const o=n[a],l=Vo(o);!e.showThinking&&l.role.toLowerCase()==="toolresult"||t.push({kind:"message",key:Ma(o,a),message:o})}if(e.showThinking)for(let a=0;a<s.length;a++)t.push({kind:"message",key:Ma(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 Op(t)}function Ma(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 fr(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 wn(e){return e.filter(t=>typeof t=="string").join(".")}function te(e,t){const n=wn(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 Bp(e){const t=wn(e).toLowerCase();return t.includes("token")||t.includes("password")||t.includes("secret")||t.includes("apikey")||t.endsWith("key")}const Fp=new Set(["title","description","default","nullable"]);function Up(e){return Object.keys(e??{}).filter(n=>!Fp.has(n)).length===0}function Kp(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=wn(s);if(a.has(v))return c`<div class="cfg-field cfg-field--error">
354
354
  <div class="cfg-field__label">${u}</div>
355
355
  <div class="cfg-field__error">Unsupported schema node. Use Raw mode.</div>
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`
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),L=_.every(C=>C!==void 0);if(L&&_.length>0&&_.length<=5){const C=n??t.default;return c`
357
357
  <div class="cfg-field">
358
- ${r?c`<label class="cfg-field__label">${u}</label>`:h}
359
- ${g?c`<div class="cfg-field__help">${g}</div>`:h}
358
+ ${r?c`<label class="cfg-field__label">${u}</label>`:f}
359
+ ${g?c`<div class="cfg-field__help">${g}</div>`:f}
360
360
  <div class="cfg-segmented">
361
361
  ${_.map((E,pe)=>c`
362
362
  <button
@@ -370,10 +370,10 @@ ${e.sidebarContent}
370
370
  `)}
371
371
  </div>
372
372
  </div>
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`
373
+ `}if(L&&_.length>5)return Pa({...e,options:_,value:n??t.default});const P=new Set($.map(C=>ue(C)).filter(Boolean)),I=new Set([...P].map(C=>C==="integer"?"number":C));if([...I].every(C=>["string","number","boolean"].includes(C))){const C=I.has("string"),E=I.has("number");if(I.has("boolean")&&I.size===1)return be({...e,schema:{...t,type:"boolean",anyOf:void 0,oneOf:void 0}});if(C||E)return Ra({...e,inputType:E&&!C?"number":"text"})}}if(t.enum){const w=t.enum;if(w.length<=5){const $=n??t.default;return c`
374
374
  <div class="cfg-field">
375
- ${r?c`<label class="cfg-field__label">${u}</label>`:h}
376
- ${g?c`<div class="cfg-field__help">${g}</div>`:h}
375
+ ${r?c`<label class="cfg-field__label">${u}</label>`:f}
376
+ ${g?c`<div class="cfg-field__help">${g}</div>`:f}
377
377
  <div class="cfg-segmented">
378
378
  ${w.map(k=>c`
379
379
  <button
@@ -387,11 +387,11 @@ ${e.sidebarContent}
387
387
  `)}
388
388
  </div>
389
389
  </div>
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`
390
+ `}return Pa({...e,options:w,value:n??t.default})}if(p==="object")return zp(e);if(p==="array")return jp(e);if(p==="boolean"){const w=typeof n=="boolean"?n:typeof t.default=="boolean"?t.default:!1;return c`
391
391
  <label class="cfg-toggle-row ${o?"disabled":""}">
392
392
  <div class="cfg-toggle-row__content">
393
393
  <span class="cfg-toggle-row__label">${u}</span>
394
- ${g?c`<span class="cfg-toggle-row__help">${g}</span>`:h}
394
+ ${g?c`<span class="cfg-toggle-row__help">${g}</span>`:f}
395
395
  </div>
396
396
  <div class="cfg-toggle">
397
397
  <input
@@ -403,15 +403,15 @@ ${e.sidebarContent}
403
403
  <span class="cfg-toggle__track"></span>
404
404
  </div>
405
405
  </label>
406
- `}return p==="number"||p==="integer"?Bp(e):p==="string"?Ia({...e,inputType:"text"}):c`
406
+ `}return p==="number"||p==="integer"?Hp(e):p==="string"?Ra({...e,inputType:"text"}):c`
407
407
  <div class="cfg-field cfg-field--error">
408
408
  <div class="cfg-field__label">${u}</div>
409
409
  <div class="cfg-field__error">Unsupported type: ${p}. Use Raw mode.</div>
410
410
  </div>
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`
411
+ `}function Ra(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??Bp(s),v=p?.placeholder??(g?"••••":t.default!==void 0?`Default: ${t.default}`:""),w=n??"";return c`
412
412
  <div class="cfg-field">
413
- ${r?c`<label class="cfg-field__label">${d}</label>`:h}
414
- ${u?c`<div class="cfg-field__help">${u}</div>`:h}
413
+ ${r?c`<label class="cfg-field__label">${d}</label>`:f}
414
+ ${u?c`<div class="cfg-field__help">${u}</div>`:f}
415
415
  <div class="cfg-input-wrap">
416
416
  <input
417
417
  type=${g?"password":l}
@@ -429,13 +429,13 @@ ${e.sidebarContent}
429
429
  ?disabled=${a}
430
430
  @click=${()=>o(s,t.default)}
431
431
  >↺</button>
432
- `:h}
432
+ `:f}
433
433
  </div>
434
434
  </div>
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`
435
+ `}function Hp(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`
436
436
  <div class="cfg-field">
437
- ${l?c`<label class="cfg-field__label">${p}</label>`:h}
438
- ${d?c`<div class="cfg-field__help">${d}</div>`:h}
437
+ ${l?c`<label class="cfg-field__label">${p}</label>`:f}
438
+ ${d?c`<div class="cfg-field__help">${d}</div>`:f}
439
439
  <div class="cfg-number">
440
440
  <button
441
441
  type="button"
@@ -458,10 +458,10 @@ ${e.sidebarContent}
458
458
  >+</button>
459
459
  </div>
460
460
  </div>
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`
461
+ `}function Pa(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`
462
462
  <div class="cfg-field">
463
- ${r?c`<label class="cfg-field__label">${d}</label>`:h}
464
- ${u?c`<div class="cfg-field__help">${u}</div>`:h}
463
+ ${r?c`<label class="cfg-field__label">${d}</label>`:f}
464
+ ${u?c`<div class="cfg-field__help">${u}</div>`:f}
465
465
  <select
466
466
  class="cfg-select"
467
467
  ?disabled=${a}
@@ -474,10 +474,10 @@ ${e.sidebarContent}
474
474
  `)}
475
475
  </select>
476
476
  </div>
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`
477
+ `}function zp(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,I)=>{const C=te([...s,P[0]],i)?.order??0,E=te([...s,I[0]],i)?.order??0;return C!==E?C-E:P[0].localeCompare(I[0])}),k=new Set(Object.keys(v)),_=t.additionalProperties,L=!!_&&typeof _=="object";return s.length===1?c`
478
478
  <div class="cfg-fields">
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}
479
+ ${$.map(([P,I])=>be({schema:I,value:g[P],path:[...s,P],hints:i,unsupported:a,disabled:o,onPatch:l}))}
480
+ ${L?Na({schema:_,value:g,path:s,hints:i,unsupported:a,disabled:o,reservedKeys:k,onPatch:l}):f}
481
481
  </div>
482
482
  `:c`
483
483
  <details class="cfg-object" open>
@@ -485,13 +485,13 @@ ${e.sidebarContent}
485
485
  <span class="cfg-object__title">${p}</span>
486
486
  <span class="cfg-object__chevron">${_t.chevronDown}</span>
487
487
  </summary>
488
- ${d?c`<div class="cfg-object__help">${d}</div>`:h}
488
+ ${d?c`<div class="cfg-object__help">${d}</div>`:f}
489
489
  <div class="cfg-object__content">
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}
490
+ ${$.map(([P,I])=>be({schema:I,value:g[P],path:[...s,P],hints:i,unsupported:a,disabled:o,onPatch:l}))}
491
+ ${L?Na({schema:_,value:g,path:s,hints:i,unsupported:a,disabled:o,reservedKeys:k,onPatch:l}):f}
492
492
  </div>
493
493
  </details>
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`
494
+ `}function jp(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`
495
495
  <div class="cfg-field cfg-field--error">
496
496
  <div class="cfg-field__label">${d}</div>
497
497
  <div class="cfg-field__error">Unsupported array schema. Use Raw mode.</div>
@@ -499,19 +499,19 @@ ${e.sidebarContent}
499
499
  `;const v=Array.isArray(n)?n:Array.isArray(t.default)?t.default:[];return c`
500
500
  <div class="cfg-array">
501
501
  <div class="cfg-array__header">
502
- ${r?c`<span class="cfg-array__label">${d}</span>`:h}
502
+ ${r?c`<span class="cfg-array__label">${d}</span>`:f}
503
503
  <span class="cfg-array__count">${v.length} item${v.length!==1?"s":""}</span>
504
504
  <button
505
505
  type="button"
506
506
  class="cfg-array__add"
507
507
  ?disabled=${o}
508
- @click=${()=>{const w=[...v,ur(g)];l(s,w)}}
508
+ @click=${()=>{const w=[...v,fr(g)];l(s,w)}}
509
509
  >
510
510
  <span class="cfg-array__add-icon">${_t.plus}</span>
511
511
  Add
512
512
  </button>
513
513
  </div>
514
- ${u?c`<div class="cfg-array__help">${u}</div>`:h}
514
+ ${u?c`<div class="cfg-array__help">${u}</div>`:f}
515
515
 
516
516
  ${v.length===0?c`
517
517
  <div class="cfg-array__empty">
@@ -541,7 +541,7 @@ ${e.sidebarContent}
541
541
  </div>
542
542
  `}
543
543
  </div>
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`
544
+ `}function Na(e){const{schema:t,value:n,path:s,hints:i,unsupported:a,disabled:o,reservedKeys:l,onPatch:r}=e,p=Up(t),d=Object.entries(n??{}).filter(([u])=>!l.has(u));return c`
545
545
  <div class="cfg-map">
546
546
  <div class="cfg-map__header">
547
547
  <span class="cfg-map__label">Custom entries</span>
@@ -549,7 +549,7 @@ ${e.sidebarContent}
549
549
  type="button"
550
550
  class="cfg-map__add"
551
551
  ?disabled=${o}
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)}}
552
+ @click=${()=>{const u={...n??{}};let g=1,v=`custom-${g}`;for(;v in u;)g+=1,v=`custom-${g}`;u[v]=p?{}:fr(t),r(s,u)}}
553
553
  >
554
554
  <span class="cfg-map__add-icon">${_t.plus}</span>
555
555
  Add Entry
@@ -560,7 +560,7 @@ ${e.sidebarContent}
560
560
  <div class="cfg-map__empty">No custom entries.</div>
561
561
  `:c`
562
562
  <div class="cfg-map__items">
563
- ${d.map(([u,g])=>{const v=[...s,u],w=Dp(g);return c`
563
+ ${d.map(([u,g])=>{const v=[...s,u],w=Kp(g);return c`
564
564
  <div class="cfg-map__item">
565
565
  <div class="cfg-map__item-key">
566
566
  <input
@@ -598,7 +598,7 @@ ${e.sidebarContent}
598
598
  </div>
599
599
  `}
600
600
  </div>
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`
601
+ `}const Oa={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 Da(e){return Oa[e]??Oa.default}function qp(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 Wp(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&&!qp(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`
602
602
  <div class="config-empty">
603
603
  <div class="config-empty__icon">${V.search}</div>
604
604
  <div class="config-empty__text">
@@ -607,26 +607,26 @@ ${e.sidebarContent}
607
607
  </div>
608
608
  `:c`
609
609
  <div class="config-form config-form--modern">
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`
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],L=_&&typeof _=="object"?_[g]:void 0,P=`config-section-${u}-${g}`;return c`
611
611
  <section class="config-section-card" id=${P}>
612
612
  <div class="config-section-card__header">
613
- <span class="config-section-card__icon">${Na(u)}</span>
613
+ <span class="config-section-card__icon">${Da(u)}</span>
614
614
  <div class="config-section-card__titles">
615
615
  <h3 class="config-section-card__title">${$}</h3>
616
- ${k?c`<p class="config-section-card__desc">${k}</p>`:h}
616
+ ${k?c`<p class="config-section-card__desc">${k}</p>`:f}
617
617
  </div>
618
618
  </div>
619
619
  <div class="config-section-card__content">
620
- ${be({schema:v,value:I,path:[u,g],hints:e.uiHints,unsupported:s,disabled:e.disabled??!1,showLabel:!1,onPatch:e.onPatch})}
620
+ ${be({schema:v,value:L,path:[u,g],hints:e.uiHints,unsupported:s,disabled:e.disabled??!1,showLabel:!1,onPatch:e.onPatch})}
621
621
  </div>
622
622
  </section>
623
623
  `})():p.map(([u,g])=>{const v=ci[u]??{label:u.charAt(0).toUpperCase()+u.slice(1),description:g.description??""};return c`
624
624
  <section class="config-section-card" id="config-section-${u}">
625
625
  <div class="config-section-card__header">
626
- <span class="config-section-card__icon">${Na(u)}</span>
626
+ <span class="config-section-card__icon">${Da(u)}</span>
627
627
  <div class="config-section-card__titles">
628
628
  <h3 class="config-section-card__title">${v.label}</h3>
629
- ${v.description?c`<p class="config-section-card__desc">${v.description}</p>`:h}
629
+ ${v.description?c`<p class="config-section-card__desc">${v.description}</p>`:f}
630
630
  </div>
631
631
  </div>
632
632
  <div class="config-section-card__content">
@@ -635,7 +635,7 @@ ${e.sidebarContent}
635
635
  </section>
636
636
  `})}
637
637
  </div>
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`
638
+ `}const Vp=new Set(["title","description","default","nullable"]);function Gp(e){return Object.keys(e??{}).filter(n=>!Vp.has(n)).length===0}function gr(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 vr(e){return!e||typeof e!="object"?{schema:null,unsupportedPaths:["<root>"]}:wt(e,[])}function wt(e,t){const n=new Set,s={...e},i=wn(t)||"<root>";if(e.anyOf||e.oneOf||e.allOf){const l=Yp(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}=gr(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"&&!Gp(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 Yp(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}=gr(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 _s={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>`},Ba=[{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"}],Fa="__all__";function Ua(e){return _s[e]??_s.default}function Qp(e,t){const n=ci[e];return n||{label:t?.title??we(e),description:t?.description??""}}function Zp(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 Jp(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 Ka(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 Xp(e){const t=e.valid==null?"unknown":e.valid?"valid":"invalid",n=vr(e.schema),s=n.schema?n.unsupportedPaths.length>0:!1,i=n.schema?.properties??{},a=Ba.filter(E=>E.key in i),o=new Set(Ba.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?Qp(e.activeSection,p):null,u=e.activeSection?Zp({key:e.activeSection,schema:p,uiHints:e.uiHints}):[],g=e.formMode==="form"&&!!e.activeSection&&u.length>0,v=e.activeSubsection===Fa,w=e.searchQuery||v?null:e.activeSubsection??u[0]?.key??null,$=e.formMode==="form"?Jp(e.originalValue,e.formValue):[],k=e.formMode==="raw"&&e.raw!==e.originalRaw,_=e.formMode==="form"?$.length>0:k,L=!!e.formValue&&!e.loading&&!!n.schema,P=e.connected&&!e.saving&&_&&(e.formMode==="raw"?!0:L),I=e.connected&&!e.applying&&!e.updating&&_&&(e.formMode==="raw"?!0:L),C=e.connected&&!e.applying&&!e.updating;return c`
639
639
  <div class="config-layout">
640
640
  <!-- Sidebar -->
641
641
  <aside class="config-sidebar">
@@ -662,7 +662,7 @@ ${e.sidebarContent}
662
662
  class="config-search__clear"
663
663
  @click=${()=>e.onSearchChange("")}
664
664
  >×</button>
665
- `:h}
665
+ `:f}
666
666
  </div>
667
667
 
668
668
  <!-- Section nav -->
@@ -671,7 +671,7 @@ ${e.sidebarContent}
671
671
  class="config-nav__item ${e.activeSection===null?"active":""}"
672
672
  @click=${()=>e.onSectionChange(null)}
673
673
  >
674
- <span class="config-nav__icon">${Ss.all}</span>
674
+ <span class="config-nav__icon">${_s.all}</span>
675
675
  <span class="config-nav__label">All Settings</span>
676
676
  </button>
677
677
  ${r.map(E=>c`
@@ -679,7 +679,7 @@ ${e.sidebarContent}
679
679
  class="config-nav__item ${e.activeSection===E.key?"active":""}"
680
680
  @click=${()=>e.onSectionChange(E.key)}
681
681
  >
682
- <span class="config-nav__icon">${Ba(E.key)}</span>
682
+ <span class="config-nav__icon">${Ua(E.key)}</span>
683
683
  <span class="config-nav__label">${E.label}</span>
684
684
  </button>
685
685
  `)}
@@ -729,7 +729,7 @@ ${e.sidebarContent}
729
729
  </button>
730
730
  <button
731
731
  class="btn btn--sm"
732
- ?disabled=${!L}
732
+ ?disabled=${!I}
733
733
  @click=${e.onApply}
734
734
  >
735
735
  ${e.applying?"Applying…":"Apply"}
@@ -758,31 +758,31 @@ ${e.sidebarContent}
758
758
  <div class="config-diff__item">
759
759
  <div class="config-diff__path">${E.path}</div>
760
760
  <div class="config-diff__values">
761
- <span class="config-diff__from">${Fa(E.from)}</span>
761
+ <span class="config-diff__from">${Ka(E.from)}</span>
762
762
  <span class="config-diff__arrow">→</span>
763
- <span class="config-diff__to">${Fa(E.to)}</span>
763
+ <span class="config-diff__to">${Ka(E.to)}</span>
764
764
  </div>
765
765
  </div>
766
766
  `)}
767
767
  </div>
768
768
  </details>
769
- `:h}
769
+ `:f}
770
770
 
771
771
  ${d&&e.formMode==="form"?c`
772
772
  <div class="config-section-hero">
773
- <div class="config-section-hero__icon">${Ba(e.activeSection??"")}</div>
773
+ <div class="config-section-hero__icon">${Ua(e.activeSection??"")}</div>
774
774
  <div class="config-section-hero__text">
775
775
  <div class="config-section-hero__title">${d.label}</div>
776
- ${d.description?c`<div class="config-section-hero__desc">${d.description}</div>`:h}
776
+ ${d.description?c`<div class="config-section-hero__desc">${d.description}</div>`:f}
777
777
  </div>
778
778
  </div>
779
- `:h}
779
+ `:f}
780
780
 
781
781
  ${g?c`
782
782
  <div class="config-subnav">
783
783
  <button
784
784
  class="config-subnav__item ${w===null?"active":""}"
785
- @click=${()=>e.onSubsectionChange(Da)}
785
+ @click=${()=>e.onSubsectionChange(Fa)}
786
786
  >
787
787
  All
788
788
  </button>
@@ -796,7 +796,7 @@ ${e.sidebarContent}
796
796
  </button>
797
797
  `)}
798
798
  </div>
799
- `:h}
799
+ `:f}
800
800
 
801
801
  <!-- Form content -->
802
802
  <div class="config-content">
@@ -804,11 +804,11 @@ ${e.sidebarContent}
804
804
  ${e.schemaLoading?c`<div class="config-loading">
805
805
  <div class="config-loading__spinner"></div>
806
806
  <span>Loading schema…</span>
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})}
807
+ </div>`:Wp({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
808
  ${s?c`<div class="callout danger" style="margin-top: 12px;">
809
809
  Form view can't safely edit some fields.
810
810
  Use Raw to avoid losing config entries.
811
- </div>`:h}
811
+ </div>`:f}
812
812
  `:c`
813
813
  <label class="field config-raw-field">
814
814
  <span>Raw JSON5</span>
@@ -822,16 +822,16 @@ ${e.sidebarContent}
822
822
 
823
823
  ${e.issues.length>0?c`<div class="callout danger" style="margin-top: 12px;">
824
824
  <pre class="code-block">${JSON.stringify(e.issues,null,2)}</pre>
825
- </div>`:h}
825
+ </div>`:f}
826
826
  </main>
827
827
  </div>
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`
828
+ `}function eh(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 th(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 nh(e,t){return t?.[e]?.length??0}function mr(e,t){const n=nh(e,t);return n<2?f:c`<div class="account-count">Accounts (${n})</div>`}function sh(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 ih(e,t){const s=(e.channels??{})[t],i=e[t];return(s&&typeof s=="object"?s:null)??(i&&typeof i=="object"?i:null)??{}}function ah(e){const t=vr(e.schema),n=t.schema;if(!n)return c`<div class="callout danger">Schema unavailable. Use Raw.</div>`;const s=sh(n,["channels",e.channelId]);if(!s)return c`<div class="callout danger">Channel config schema unavailable.</div>`;const i=e.configValue??{},a=ih(i,e.channelId);return c`
829
829
  <div class="config-form">
830
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})}
831
831
  </div>
832
832
  `}function $e(e){const{channelId:t,props:n}=e,s=n.configSaving||n.configSchemaLoading;return c`
833
833
  <div style="margin-top: 16px;">
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})}
834
+ ${n.configSchemaLoading?c`<div class="muted">Loading config schema…</div>`:ah({channelId:t,configValue:n.configForm,schema:n.configSchema,uiHints:n.configUiHints,disabled:s,onPatch:n.onConfigPatch})}
835
835
  <div class="row" style="margin-top: 12px;">
836
836
  <button
837
837
  class="btn primary"
@@ -849,7 +849,7 @@ ${e.sidebarContent}
849
849
  </button>
850
850
  </div>
851
851
  </div>
852
- `}function nf(e){const{props:t,discord:n,accountCountLabel:s}=e;return c`
852
+ `}function oh(e){const{props:t,discord:n,accountCountLabel:s}=e;return c`
853
853
  <div class="card">
854
854
  <div class="card-title">Discord</div>
855
855
  <div class="card-sub">Bot status and channel configuration.</div>
@@ -876,12 +876,12 @@ ${e.sidebarContent}
876
876
 
877
877
  ${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
878
878
  ${n.lastError}
879
- </div>`:h}
879
+ </div>`:f}
880
880
 
881
881
  ${n?.probe?c`<div class="callout" style="margin-top: 12px;">
882
882
  Probe ${n.probe.ok?"ok":"failed"} ·
883
883
  ${n.probe.status??""} ${n.probe.error??""}
884
- </div>`:h}
884
+ </div>`:f}
885
885
 
886
886
  ${$e({channelId:"discord",props:t})}
887
887
 
@@ -891,7 +891,7 @@ ${e.sidebarContent}
891
891
  </button>
892
892
  </div>
893
893
  </div>
894
- `}function sf(e){const{props:t,googleChat:n,accountCountLabel:s}=e;return c`
894
+ `}function rh(e){const{props:t,googleChat:n,accountCountLabel:s}=e;return c`
895
895
  <div class="card">
896
896
  <div class="card-title">Google Chat</div>
897
897
  <div class="card-sub">Chat API webhook status and channel configuration.</div>
@@ -928,12 +928,12 @@ ${e.sidebarContent}
928
928
 
929
929
  ${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
930
930
  ${n.lastError}
931
- </div>`:h}
931
+ </div>`:f}
932
932
 
933
933
  ${n?.probe?c`<div class="callout" style="margin-top: 12px;">
934
934
  Probe ${n.probe.ok?"ok":"failed"} ·
935
935
  ${n.probe.status??""} ${n.probe.error??""}
936
- </div>`:h}
936
+ </div>`:f}
937
937
 
938
938
  ${$e({channelId:"googlechat",props:t})}
939
939
 
@@ -943,7 +943,7 @@ ${e.sidebarContent}
943
943
  </button>
944
944
  </div>
945
945
  </div>
946
- `}function af(e){const{props:t,imessage:n,accountCountLabel:s}=e;return c`
946
+ `}function lh(e){const{props:t,imessage:n,accountCountLabel:s}=e;return c`
947
947
  <div class="card">
948
948
  <div class="card-title">iMessage</div>
949
949
  <div class="card-sub">macOS bridge status and channel configuration.</div>
@@ -970,12 +970,12 @@ ${e.sidebarContent}
970
970
 
971
971
  ${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
972
972
  ${n.lastError}
973
- </div>`:h}
973
+ </div>`:f}
974
974
 
975
975
  ${n?.probe?c`<div class="callout" style="margin-top: 12px;">
976
976
  Probe ${n.probe.ok?"ok":"failed"} ·
977
977
  ${n.probe.error??""}
978
- </div>`:h}
978
+ </div>`:f}
979
979
 
980
980
  ${$e({channelId:"imessage",props:t})}
981
981
 
@@ -985,7 +985,7 @@ ${e.sidebarContent}
985
985
  </button>
986
986
  </div>
987
987
  </div>
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`
988
+ `}function ch(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 dh(e){const{state:t,callbacks:n,accountId:s}=e,i=ch(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`
989
989
  <div class="form-field" style="margin-bottom: 12px;">
990
990
  <label for="${k}" style="display: block; margin-bottom: 4px; font-weight: 500;">
991
991
  ${r}
@@ -997,11 +997,11 @@ ${e.sidebarContent}
997
997
  maxlength=${g??2e3}
998
998
  rows="3"
999
999
  style="width: 100%; padding: 8px; border: 1px solid var(--border-color); border-radius: 4px; resize: vertical; font-family: inherit;"
1000
- @input=${_=>{const I=_.target;n.onFieldChange(l,I.value)}}
1000
+ @input=${_=>{const L=_.target;n.onFieldChange(l,L.value)}}
1001
1001
  ?disabled=${t.saving}
1002
1002
  ></textarea>
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}
1003
+ ${v?c`<div style="font-size: 12px; color: var(--text-muted); margin-top: 2px;">${v}</div>`:f}
1004
+ ${$?c`<div style="font-size: 12px; color: var(--danger-color); margin-top: 2px;">${$}</div>`:f}
1005
1005
  </div>
1006
1006
  `:c`
1007
1007
  <div class="form-field" style="margin-bottom: 12px;">
@@ -1015,11 +1015,11 @@ ${e.sidebarContent}
1015
1015
  placeholder=${u??""}
1016
1016
  maxlength=${g??256}
1017
1017
  style="width: 100%; padding: 8px; border: 1px solid var(--border-color); border-radius: 4px;"
1018
- @input=${_=>{const I=_.target;n.onFieldChange(l,I.value)}}
1018
+ @input=${_=>{const L=_.target;n.onFieldChange(l,L.value)}}
1019
1019
  ?disabled=${t.saving}
1020
1020
  />
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}
1021
+ ${v?c`<div style="font-size: 12px; color: var(--text-muted); margin-top: 2px;">${v}</div>`:f}
1022
+ ${$?c`<div style="font-size: 12px; color: var(--danger-color); margin-top: 2px;">${$}</div>`:f}
1023
1023
  </div>
1024
1024
  `},o=()=>{const l=t.values.picture;return l?c`
1025
1025
  <div style="margin-bottom: 12px;">
@@ -1031,16 +1031,16 @@ ${e.sidebarContent}
1031
1031
  @load=${r=>{const p=r.target;p.style.display="block"}}
1032
1032
  />
1033
1033
  </div>
1034
- `:h};return c`
1034
+ `:f};return c`
1035
1035
  <div class="nostr-profile-form" style="padding: 16px; background: var(--bg-secondary); border-radius: 8px; margin-top: 12px;">
1036
1036
  <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px;">
1037
1037
  <div style="font-weight: 600; font-size: 16px;">Edit Profile</div>
1038
1038
  <div style="font-size: 12px; color: var(--text-muted);">Account: ${s}</div>
1039
1039
  </div>
1040
1040
 
1041
- ${t.error?c`<div class="callout danger" style="margin-bottom: 12px;">${t.error}</div>`:h}
1041
+ ${t.error?c`<div class="callout danger" style="margin-bottom: 12px;">${t.error}</div>`:f}
1042
1042
 
1043
- ${t.success?c`<div class="callout success" style="margin-bottom: 12px;">${t.success}</div>`:h}
1043
+ ${t.success?c`<div class="callout success" style="margin-bottom: 12px;">${t.success}</div>`:f}
1044
1044
 
1045
1045
  ${o()}
1046
1046
 
@@ -1064,7 +1064,7 @@ ${e.sidebarContent}
1064
1064
 
1065
1065
  ${a("lud16","Lightning Address",{placeholder:"you@getalby.com",help:"Lightning address for tips (LUD-16)"})}
1066
1066
  </div>
1067
- `:h}
1067
+ `:f}
1068
1068
 
1069
1069
  <div style="display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap;">
1070
1070
  <button
@@ -1101,37 +1101,37 @@ ${e.sidebarContent}
1101
1101
 
1102
1102
  ${i?c`<div style="font-size: 12px; color: var(--warning-color); margin-top: 8px;">
1103
1103
  You have unsaved changes
1104
- </div>`:h}
1104
+ </div>`:f}
1105
1105
  </div>
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`
1106
+ `}function uh(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 Ha(e){return e?e.length<=20?e:`${e.slice(0,8)}...${e.slice(-8)}`:"n/a"}function ph(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=L=>{const P=L.publicKey,I=L.profile,C=I?.displayName??I?.name??L.name??L.accountId;return c`
1107
1107
  <div class="account-card">
1108
1108
  <div class="account-card-header">
1109
1109
  <div class="account-card-title">${C}</div>
1110
- <div class="account-card-id">${I.accountId}</div>
1110
+ <div class="account-card-id">${L.accountId}</div>
1111
1111
  </div>
1112
1112
  <div class="status-list account-card-status">
1113
1113
  <div>
1114
1114
  <span class="label">Running</span>
1115
- <span>${I.running?"Yes":"No"}</span>
1115
+ <span>${L.running?"Yes":"No"}</span>
1116
1116
  </div>
1117
1117
  <div>
1118
1118
  <span class="label">Configured</span>
1119
- <span>${I.configured?"Yes":"No"}</span>
1119
+ <span>${L.configured?"Yes":"No"}</span>
1120
1120
  </div>
1121
1121
  <div>
1122
1122
  <span class="label">Public Key</span>
1123
- <span class="monospace" title="${P??""}">${Ua(P)}</span>
1123
+ <span class="monospace" title="${P??""}">${Ha(P)}</span>
1124
1124
  </div>
1125
1125
  <div>
1126
1126
  <span class="label">Last inbound</span>
1127
- <span>${I.lastInboundAt?O(I.lastInboundAt):"n/a"}</span>
1127
+ <span>${L.lastInboundAt?O(L.lastInboundAt):"n/a"}</span>
1128
1128
  </div>
1129
- ${I.lastError?c`
1130
- <div class="account-card-error">${I.lastError}</div>
1131
- `:h}
1129
+ ${L.lastError?c`
1130
+ <div class="account-card-error">${L.lastError}</div>
1131
+ `:f}
1132
1132
  </div>
1133
1133
  </div>
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`
1134
+ `},_=()=>{if($&&o)return dh({state:a,callbacks:o,accountId:s[0]?.accountId??"default"});const L=r?.profile??n?.profile,{name:P,displayName:I,about:C,picture:E,nip05:pe}=L??{},$n=P||I||C||E||pe;return c`
1135
1135
  <div style="margin-top: 16px; padding: 12px; background: var(--bg-secondary); border-radius: 8px;">
1136
1136
  <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;">
1137
1137
  <div style="font-weight: 500;">Profile</div>
@@ -1143,9 +1143,9 @@ ${e.sidebarContent}
1143
1143
  >
1144
1144
  Edit Profile
1145
1145
  </button>
1146
- `:h}
1146
+ `:f}
1147
1147
  </div>
1148
- ${wn?c`
1148
+ ${$n?c`
1149
1149
  <div class="status-list">
1150
1150
  ${E?c`
1151
1151
  <div style="margin-bottom: 8px;">
@@ -1153,14 +1153,14 @@ ${e.sidebarContent}
1153
1153
  src=${E}
1154
1154
  alt="Profile picture"
1155
1155
  style="width: 48px; height: 48px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border-color);"
1156
- @error=${$n=>{$n.target.style.display="none"}}
1156
+ @error=${xn=>{xn.target.style.display="none"}}
1157
1157
  />
1158
1158
  </div>
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}
1159
+ `:f}
1160
+ ${P?c`<div><span class="label">Name</span><span>${P}</span></div>`:f}
1161
+ ${I?c`<div><span class="label">Display Name</span><span>${I}</span></div>`:f}
1162
+ ${C?c`<div><span class="label">About</span><span style="max-width: 300px; overflow: hidden; text-overflow: ellipsis;">${C}</span></div>`:f}
1163
+ ${pe?c`<div><span class="label">NIP-05</span><span>${pe}</span></div>`:f}
1164
1164
  </div>
1165
1165
  `:c`
1166
1166
  <div style="color: var(--text-muted); font-size: 13px;">
@@ -1176,7 +1176,7 @@ ${e.sidebarContent}
1176
1176
 
1177
1177
  ${w?c`
1178
1178
  <div class="account-card-list">
1179
- ${s.map(I=>k(I))}
1179
+ ${s.map(L=>k(L))}
1180
1180
  </div>
1181
1181
  `:c`
1182
1182
  <div class="status-list" style="margin-top: 16px;">
@@ -1191,7 +1191,7 @@ ${e.sidebarContent}
1191
1191
  <div>
1192
1192
  <span class="label">Public Key</span>
1193
1193
  <span class="monospace" title="${u??""}"
1194
- >${Ua(u)}</span
1194
+ >${Ha(u)}</span
1195
1195
  >
1196
1196
  </div>
1197
1197
  <div>
@@ -1201,7 +1201,7 @@ ${e.sidebarContent}
1201
1201
  </div>
1202
1202
  `}
1203
1203
 
1204
- ${v?c`<div class="callout danger" style="margin-top: 12px;">${v}</div>`:h}
1204
+ ${v?c`<div class="callout danger" style="margin-top: 12px;">${v}</div>`:f}
1205
1205
 
1206
1206
  ${_()}
1207
1207
 
@@ -1211,7 +1211,7 @@ ${e.sidebarContent}
1211
1211
  <button class="btn" @click=${()=>t.onRefresh(!1)}>Refresh</button>
1212
1212
  </div>
1213
1213
  </div>
1214
- `}function df(e){const{props:t,signal:n,accountCountLabel:s}=e;return c`
1214
+ `}function hh(e){const{props:t,signal:n,accountCountLabel:s}=e;return c`
1215
1215
  <div class="card">
1216
1216
  <div class="card-title">Signal</div>
1217
1217
  <div class="card-sub">signal-cli status and channel configuration.</div>
@@ -1242,12 +1242,12 @@ ${e.sidebarContent}
1242
1242
 
1243
1243
  ${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
1244
1244
  ${n.lastError}
1245
- </div>`:h}
1245
+ </div>`:f}
1246
1246
 
1247
1247
  ${n?.probe?c`<div class="callout" style="margin-top: 12px;">
1248
1248
  Probe ${n.probe.ok?"ok":"failed"} ·
1249
1249
  ${n.probe.status??""} ${n.probe.error??""}
1250
- </div>`:h}
1250
+ </div>`:f}
1251
1251
 
1252
1252
  ${$e({channelId:"signal",props:t})}
1253
1253
 
@@ -1257,7 +1257,7 @@ ${e.sidebarContent}
1257
1257
  </button>
1258
1258
  </div>
1259
1259
  </div>
1260
- `}function uf(e){const{props:t,slack:n,accountCountLabel:s}=e;return c`
1260
+ `}function fh(e){const{props:t,slack:n,accountCountLabel:s}=e;return c`
1261
1261
  <div class="card">
1262
1262
  <div class="card-title">Slack</div>
1263
1263
  <div class="card-sub">Socket mode status and channel configuration.</div>
@@ -1284,12 +1284,12 @@ ${e.sidebarContent}
1284
1284
 
1285
1285
  ${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
1286
1286
  ${n.lastError}
1287
- </div>`:h}
1287
+ </div>`:f}
1288
1288
 
1289
1289
  ${n?.probe?c`<div class="callout" style="margin-top: 12px;">
1290
1290
  Probe ${n.probe.ok?"ok":"failed"} ·
1291
1291
  ${n.probe.status??""} ${n.probe.error??""}
1292
- </div>`:h}
1292
+ </div>`:f}
1293
1293
 
1294
1294
  ${$e({channelId:"slack",props:t})}
1295
1295
 
@@ -1299,7 +1299,7 @@ ${e.sidebarContent}
1299
1299
  </button>
1300
1300
  </div>
1301
1301
  </div>
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`
1302
+ `}function gh(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`
1303
1303
  <div class="account-card">
1304
1304
  <div class="account-card-header">
1305
1305
  <div class="account-card-title">
@@ -1324,7 +1324,7 @@ ${e.sidebarContent}
1324
1324
  <div class="account-card-error">
1325
1325
  ${l.lastError}
1326
1326
  </div>
1327
- `:h}
1327
+ `:f}
1328
1328
  </div>
1329
1329
  </div>
1330
1330
  `};return c`
@@ -1364,12 +1364,12 @@ ${e.sidebarContent}
1364
1364
 
1365
1365
  ${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
1366
1366
  ${n.lastError}
1367
- </div>`:h}
1367
+ </div>`:f}
1368
1368
 
1369
1369
  ${n?.probe?c`<div class="callout" style="margin-top: 12px;">
1370
1370
  Probe ${n.probe.ok?"ok":"failed"} ·
1371
1371
  ${n.probe.status??""} ${n.probe.error??""}
1372
- </div>`:h}
1372
+ </div>`:f}
1373
1373
 
1374
1374
  ${$e({channelId:"telegram",props:t})}
1375
1375
 
@@ -1379,7 +1379,7 @@ ${e.sidebarContent}
1379
1379
  </button>
1380
1380
  </div>
1381
1381
  </div>
1382
- `}function ff(e){const{props:t,whatsapp:n,accountCountLabel:s}=e;return c`
1382
+ `}function vh(e){const{props:t,whatsapp:n,accountCountLabel:s}=e;return c`
1383
1383
  <div class="card">
1384
1384
  <div class="card-title">WhatsApp</div>
1385
1385
  <div class="card-sub">Link WhatsApp Web and monitor connection health.</div>
@@ -1417,22 +1417,22 @@ ${e.sidebarContent}
1417
1417
  <div>
1418
1418
  <span class="label">Auth age</span>
1419
1419
  <span>
1420
- ${n?.authAgeMs!=null?Qp(n.authAgeMs):"n/a"}
1420
+ ${n?.authAgeMs!=null?eh(n.authAgeMs):"n/a"}
1421
1421
  </span>
1422
1422
  </div>
1423
1423
  </div>
1424
1424
 
1425
1425
  ${n?.lastError?c`<div class="callout danger" style="margin-top: 12px;">
1426
1426
  ${n.lastError}
1427
- </div>`:h}
1427
+ </div>`:f}
1428
1428
 
1429
1429
  ${t.whatsappMessage?c`<div class="callout" style="margin-top: 12px;">
1430
1430
  ${t.whatsappMessage}
1431
- </div>`:h}
1431
+ </div>`:f}
1432
1432
 
1433
1433
  ${t.whatsappQrDataUrl?c`<div class="qr-wrap">
1434
1434
  <img src=${t.whatsappQrDataUrl} alt="WhatsApp QR" />
1435
- </div>`:h}
1435
+ </div>`:f}
1436
1436
 
1437
1437
  <div class="row" style="margin-top: 14px; flex-wrap: wrap;">
1438
1438
  <button
@@ -1470,9 +1470,9 @@ ${e.sidebarContent}
1470
1470
 
1471
1471
  ${$e({channelId:"whatsapp",props:t})}
1472
1472
  </div>
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`
1473
+ `}function mh(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=yh(e.snapshot).map((u,g)=>({key:u,enabled:th(u,e),order:g})).sort((u,g)=>u.enabled!==g.enabled?u.enabled?-1:1:u.order-g.order);return c`
1474
1474
  <section class="grid grid-cols-2">
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}))}
1475
+ ${d.map(u=>bh(u.key,e,{whatsapp:n,telegram:s,discord:i,slack:a,signal:o,imessage:l,nostr:r,channelAccounts:e.snapshot?.channelAccounts??null}))}
1476
1476
  </section>
1477
1477
 
1478
1478
  <section class="card" style="margin-top: 18px;">
@@ -1485,12 +1485,12 @@ ${e.sidebarContent}
1485
1485
  </div>
1486
1486
  ${e.lastError?c`<div class="callout danger" style="margin-top: 12px;">
1487
1487
  ${e.lastError}
1488
- </div>`:h}
1488
+ </div>`:f}
1489
1489
  <pre class="code-block" style="margin-top: 12px;">
1490
1490
  ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1491
1491
  </pre>
1492
1492
  </section>
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`
1493
+ `}function yh(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 bh(e,t,n){const s=mr(e,n.channelAccounts);switch(e){case"whatsapp":return vh({props:t,whatsapp:n.whatsapp,accountCountLabel:s});case"telegram":return gh({props:t,telegram:n.telegram,telegramAccounts:n.channelAccounts?.telegram??[],accountCountLabel:s});case"discord":return oh({props:t,discord:n.discord,accountCountLabel:s});case"googlechat":return rh({props:t,accountCountLabel:s});case"slack":return fh({props:t,slack:n.slack,accountCountLabel:s});case"signal":return hh({props:t,signal:n.signal,accountCountLabel:s});case"imessage":return lh({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 ph({props:t,nostr:n.nostr,nostrAccounts:i,accountCountLabel:s,profileFormState:r,profileFormCallbacks:p,onEditProfile:()=>t.onNostrProfileEdit(o,l)})}default:return wh(e,t,n.channelAccounts??{})}}function wh(e,t,n){const s=xh(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=mr(e,n);return c`
1494
1494
  <div class="card">
1495
1495
  <div class="card-title">${s}</div>
1496
1496
  <div class="card-sub">Channel status and configuration.</div>
@@ -1498,7 +1498,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1498
1498
 
1499
1499
  ${p.length>0?c`
1500
1500
  <div class="account-card-list">
1501
- ${p.map(u=>kf(u))}
1501
+ ${p.map(u=>_h(u))}
1502
1502
  </div>
1503
1503
  `:c`
1504
1504
  <div class="status-list" style="margin-top: 16px;">
@@ -1519,11 +1519,11 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1519
1519
 
1520
1520
  ${r?c`<div class="callout danger" style="margin-top: 12px;">
1521
1521
  ${r}
1522
- </div>`:h}
1522
+ </div>`:f}
1523
1523
 
1524
1524
  ${$e({channelId:e,props:t})}
1525
1525
  </div>
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`
1526
+ `}function $h(e){return e?.channelMeta?.length?Object.fromEntries(e.channelMeta.map(t=>[t.id,t])):{}}function xh(e,t){return $h(e)[t]?.label??e?.channelLabels?.[t]??t}const kh=600*1e3;function yr(e){return e.lastInboundAt?Date.now()-e.lastInboundAt<kh:!1}function Ah(e){return e.running?"Yes":yr(e)?"Active":"No"}function Sh(e){return e.connected===!0?"Yes":e.connected===!1?"No":yr(e)?"Active":"n/a"}function _h(e){const t=Ah(e),n=Sh(e);return c`
1527
1527
  <div class="account-card">
1528
1528
  <div class="account-card-header">
1529
1529
  <div class="account-card-title">${e.name||e.accountId}</div>
@@ -1550,10 +1550,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1550
1550
  <div class="account-card-error">
1551
1551
  ${e.lastError}
1552
1552
  </div>
1553
- `:h}
1553
+ `:f}
1554
1554
  </div>
1555
1555
  </div>
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`
1556
+ `}function Th(e){const t=e.host??"unknown",n=e.ip?`(${e.ip})`:"",s=e.mode??"",i=e.version??"";return`${t} ${n} ${s} ${i}`.trim()}function Ch(e){const t=e.ts??null;return t?O(t):"n/a"}function br(e){return e?`${At(e)} (${O(e)})`:"n/a"}function Eh(e){if(e.totalTokens==null)return"n/a";const t=e.totalTokens??0,n=e.contextTokens??0;return n?`${t} / ${n}`:String(t)}function Ih(e){if(e==null)return"";try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Lh(e){const t=e.schedule;return t.kind==="at"?`At ${At(t.atMs)}`:t.kind==="every"?`Every ${lo(t.everyMs)}`:`Cron ${t.expr}${t.tz?` (${t.tz})`:""}`}function Mh(e){const t=["last",...e.channels.filter(Boolean)],n=e.form.deliveryChannel?.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 Rh(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 Ph(e){const t=Mh(e),s=(e.runsJobId==null?void 0:e.jobs.find(a=>a.id===e.runsJobId))?.name??e.runsJobId??"(select a job)",i=e.runs.toSorted((a,o)=>o.ts-a.ts);return c`
1557
1557
  <section class="grid grid-cols-2">
1558
1558
  <div class="card">
1559
1559
  <div class="card-title">Scheduler</div>
@@ -1571,14 +1571,14 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1571
1571
  </div>
1572
1572
  <div class="stat">
1573
1573
  <div class="stat-label">Next wake</div>
1574
- <div class="stat-value">${vr(e.status?.nextWakeAtMs??null)}</div>
1574
+ <div class="stat-value">${br(e.status?.nextWakeAtMs??null)}</div>
1575
1575
  </div>
1576
1576
  </div>
1577
1577
  <div class="row" style="margin-top: 12px;">
1578
1578
  <button class="btn" ?disabled=${e.loading} @click=${e.onRefresh}>
1579
1579
  ${e.loading?"Refreshing…":"Refresh"}
1580
1580
  </button>
1581
- ${e.error?c`<span class="muted">${e.error}</span>`:h}
1581
+ ${e.error?c`<span class="muted">${e.error}</span>`:f}
1582
1582
  </div>
1583
1583
  </div>
1584
1584
 
@@ -1590,21 +1590,21 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1590
1590
  <span>Name</span>
1591
1591
  <input
1592
1592
  .value=${e.form.name}
1593
- @input=${n=>e.onFormChange({name:n.target.value})}
1593
+ @input=${a=>e.onFormChange({name:a.target.value})}
1594
1594
  />
1595
1595
  </label>
1596
1596
  <label class="field">
1597
1597
  <span>Description</span>
1598
1598
  <input
1599
1599
  .value=${e.form.description}
1600
- @input=${n=>e.onFormChange({description:n.target.value})}
1600
+ @input=${a=>e.onFormChange({description:a.target.value})}
1601
1601
  />
1602
1602
  </label>
1603
1603
  <label class="field">
1604
1604
  <span>Agent ID</span>
1605
1605
  <input
1606
1606
  .value=${e.form.agentId}
1607
- @input=${n=>e.onFormChange({agentId:n.target.value})}
1607
+ @input=${a=>e.onFormChange({agentId:a.target.value})}
1608
1608
  placeholder="default"
1609
1609
  />
1610
1610
  </label>
@@ -1613,14 +1613,14 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1613
1613
  <input
1614
1614
  type="checkbox"
1615
1615
  .checked=${e.form.enabled}
1616
- @change=${n=>e.onFormChange({enabled:n.target.checked})}
1616
+ @change=${a=>e.onFormChange({enabled:a.target.checked})}
1617
1617
  />
1618
1618
  </label>
1619
1619
  <label class="field">
1620
1620
  <span>Schedule</span>
1621
1621
  <select
1622
1622
  .value=${e.form.scheduleKind}
1623
- @change=${n=>e.onFormChange({scheduleKind:n.target.value})}
1623
+ @change=${a=>e.onFormChange({scheduleKind:a.target.value})}
1624
1624
  >
1625
1625
  <option value="every">Every</option>
1626
1626
  <option value="at">At</option>
@@ -1628,13 +1628,13 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1628
1628
  </select>
1629
1629
  </label>
1630
1630
  </div>
1631
- ${Pf(e)}
1631
+ ${Nh(e)}
1632
1632
  <div class="form-grid" style="margin-top: 12px;">
1633
1633
  <label class="field">
1634
1634
  <span>Session</span>
1635
1635
  <select
1636
1636
  .value=${e.form.sessionTarget}
1637
- @change=${n=>e.onFormChange({sessionTarget:n.target.value})}
1637
+ @change=${a=>e.onFormChange({sessionTarget:a.target.value})}
1638
1638
  >
1639
1639
  <option value="main">Main</option>
1640
1640
  <option value="isolated">Isolated</option>
@@ -1644,17 +1644,17 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1644
1644
  <span>Wake mode</span>
1645
1645
  <select
1646
1646
  .value=${e.form.wakeMode}
1647
- @change=${n=>e.onFormChange({wakeMode:n.target.value})}
1647
+ @change=${a=>e.onFormChange({wakeMode:a.target.value})}
1648
1648
  >
1649
- <option value="next-heartbeat">Next heartbeat</option>
1650
1649
  <option value="now">Now</option>
1650
+ <option value="next-heartbeat">Next heartbeat</option>
1651
1651
  </select>
1652
1652
  </label>
1653
1653
  <label class="field">
1654
1654
  <span>Payload</span>
1655
1655
  <select
1656
1656
  .value=${e.form.payloadKind}
1657
- @change=${n=>e.onFormChange({payloadKind:n.target.value})}
1657
+ @change=${a=>e.onFormChange({payloadKind:a.target.value})}
1658
1658
  >
1659
1659
  <option value="systemEvent">System event</option>
1660
1660
  <option value="agentTurn">Agent turn</option>
@@ -1665,57 +1665,52 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1665
1665
  <span>${e.form.payloadKind==="systemEvent"?"System text":"Agent message"}</span>
1666
1666
  <textarea
1667
1667
  .value=${e.form.payloadText}
1668
- @input=${n=>e.onFormChange({payloadText:n.target.value})}
1668
+ @input=${a=>e.onFormChange({payloadText:a.target.value})}
1669
1669
  rows="4"
1670
1670
  ></textarea>
1671
1671
  </label>
1672
- ${e.form.payloadKind==="agentTurn"?c`
1673
- <div class="form-grid" style="margin-top: 12px;">
1674
- <label class="field checkbox">
1675
- <span>Deliver</span>
1676
- <input
1677
- type="checkbox"
1678
- .checked=${e.form.deliver}
1679
- @change=${n=>e.onFormChange({deliver:n.target.checked})}
1680
- />
1681
- </label>
1682
- <label class="field">
1683
- <span>Channel</span>
1684
- <select
1685
- .value=${e.form.channel||"last"}
1686
- @change=${n=>e.onFormChange({channel:n.target.value})}
1687
- >
1688
- ${t.map(n=>c`<option value=${n}>
1689
- ${Mf(e,n)}
1690
- </option>`)}
1691
- </select>
1692
- </label>
1693
- <label class="field">
1694
- <span>To</span>
1695
- <input
1696
- .value=${e.form.to}
1697
- @input=${n=>e.onFormChange({to:n.target.value})}
1698
- placeholder="+1555… or chat id"
1699
- />
1700
- </label>
1701
- <label class="field">
1702
- <span>Timeout (seconds)</span>
1703
- <input
1704
- .value=${e.form.timeoutSeconds}
1705
- @input=${n=>e.onFormChange({timeoutSeconds:n.target.value})}
1706
- />
1707
- </label>
1708
- ${e.form.sessionTarget==="isolated"?c`
1709
- <label class="field">
1710
- <span>Post to main prefix</span>
1711
- <input
1712
- .value=${e.form.postToMainPrefix}
1713
- @input=${n=>e.onFormChange({postToMainPrefix:n.target.value})}
1714
- />
1715
- </label>
1716
- `:h}
1717
- </div>
1718
- `:h}
1672
+ ${e.form.payloadKind==="agentTurn"?c`
1673
+ <div class="form-grid" style="margin-top: 12px;">
1674
+ <label class="field">
1675
+ <span>Delivery</span>
1676
+ <select
1677
+ .value=${e.form.deliveryMode}
1678
+ @change=${a=>e.onFormChange({deliveryMode:a.target.value})}
1679
+ >
1680
+ <option value="announce">Announce summary (default)</option>
1681
+ <option value="none">None (internal)</option>
1682
+ </select>
1683
+ </label>
1684
+ <label class="field">
1685
+ <span>Timeout (seconds)</span>
1686
+ <input
1687
+ .value=${e.form.timeoutSeconds}
1688
+ @input=${a=>e.onFormChange({timeoutSeconds:a.target.value})}
1689
+ />
1690
+ </label>
1691
+ ${e.form.deliveryMode==="announce"?c`
1692
+ <label class="field">
1693
+ <span>Channel</span>
1694
+ <select
1695
+ .value=${e.form.deliveryChannel||"last"}
1696
+ @change=${a=>e.onFormChange({deliveryChannel:a.target.value})}
1697
+ >
1698
+ ${t.map(a=>c`<option value=${a}>
1699
+ ${Rh(e,a)}
1700
+ </option>`)}
1701
+ </select>
1702
+ </label>
1703
+ <label class="field">
1704
+ <span>To</span>
1705
+ <input
1706
+ .value=${e.form.deliveryTo}
1707
+ @input=${a=>e.onFormChange({deliveryTo:a.target.value})}
1708
+ placeholder="+1555… or chat id"
1709
+ />
1710
+ </label>
1711
+ `:f}
1712
+ </div>
1713
+ `:f}
1719
1714
  <div class="row" style="margin-top: 14px;">
1720
1715
  <button class="btn primary" ?disabled=${e.busy} @click=${e.onAdd}>
1721
1716
  ${e.busy?"Saving…":"Add job"}
@@ -1727,27 +1722,29 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1727
1722
  <section class="card" style="margin-top: 18px;">
1728
1723
  <div class="card-title">Jobs</div>
1729
1724
  <div class="card-sub">All scheduled jobs stored in the gateway.</div>
1730
- ${e.jobs.length===0?c`<div class="muted" style="margin-top: 12px;">No jobs yet.</div>`:c`
1725
+ ${e.jobs.length===0?c`
1726
+ <div class="muted" style="margin-top: 12px">No jobs yet.</div>
1727
+ `:c`
1731
1728
  <div class="list" style="margin-top: 12px;">
1732
- ${e.jobs.map(n=>Nf(n,e))}
1729
+ ${e.jobs.map(a=>Oh(a,e))}
1733
1730
  </div>
1734
1731
  `}
1735
1732
  </section>
1736
1733
 
1737
1734
  <section class="card" style="margin-top: 18px;">
1738
1735
  <div class="card-title">Run history</div>
1739
- <div class="card-sub">Latest runs for ${e.runsJobId??"(select a job)"}.</div>
1736
+ <div class="card-sub">Latest runs for ${s}.</div>
1740
1737
  ${e.runsJobId==null?c`
1741
- <div class="muted" style="margin-top: 12px;">
1742
- Select a job to inspect run history.
1743
- </div>
1744
- `:e.runs.length===0?c`<div class="muted" style="margin-top: 12px;">No runs yet.</div>`:c`
1738
+ <div class="muted" style="margin-top: 12px">Select a job to inspect run history.</div>
1739
+ `:i.length===0?c`
1740
+ <div class="muted" style="margin-top: 12px">No runs yet.</div>
1741
+ `:c`
1745
1742
  <div class="list" style="margin-top: 12px;">
1746
- ${e.runs.map(n=>Of(n))}
1743
+ ${i.map(a=>Fh(a,e.basePath))}
1747
1744
  </div>
1748
1745
  `}
1749
1746
  </section>
1750
- `}function Pf(e){const t=e.form;return t.scheduleKind==="at"?c`
1747
+ `}function Nh(e){const t=e.form;return t.scheduleKind==="at"?c`
1751
1748
  <label class="field" style="margin-top: 12px;">
1752
1749
  <span>Run at</span>
1753
1750
  <input
@@ -1794,22 +1791,26 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1794
1791
  />
1795
1792
  </label>
1796
1793
  </div>
1797
- `}function Nf(e,t){const s=`list-item list-item-clickable${t.runsJobId===e.id?" list-item-selected":""}`;return c`
1794
+ `}function Oh(e,t){const s=`list-item list-item-clickable cron-job${t.runsJobId===e.id?" list-item-selected":""}`;return c`
1798
1795
  <div class=${s} @click=${()=>t.onLoadRuns(e.id)}>
1799
1796
  <div class="list-main">
1800
1797
  <div class="list-title">${e.name}</div>
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}
1804
- <div class="chip-row" style="margin-top: 6px;">
1805
- <span class="chip">${e.enabled?"enabled":"disabled"}</span>
1798
+ <div class="list-sub">${Lh(e)}</div>
1799
+ ${Dh(e)}
1800
+ ${e.agentId?c`<div class="muted cron-job-agent">Agent: ${e.agentId}</div>`:f}
1801
+ </div>
1802
+ <div class="list-meta">
1803
+ ${Bh(e)}
1804
+ </div>
1805
+ <div class="cron-job-footer">
1806
+ <div class="chip-row cron-job-chips">
1807
+ <span class=${`chip ${e.enabled?"chip-ok":"chip-danger"}`}>
1808
+ ${e.enabled?"enabled":"disabled"}
1809
+ </span>
1806
1810
  <span class="chip">${e.sessionTarget}</span>
1807
1811
  <span class="chip">${e.wakeMode}</span>
1808
1812
  </div>
1809
- </div>
1810
- <div class="list-meta">
1811
- <div>${Cf(e)}</div>
1812
- <div class="row" style="justify-content: flex-end; margin-top: 8px;">
1813
+ <div class="row cron-job-actions">
1813
1814
  <button
1814
1815
  class="btn"
1815
1816
  ?disabled=${t.busy}
@@ -1829,7 +1830,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1829
1830
  ?disabled=${t.busy}
1830
1831
  @click=${i=>{i.stopPropagation(),t.onLoadRuns(e.id)}}
1831
1832
  >
1832
- Runs
1833
+ History
1833
1834
  </button>
1834
1835
  <button
1835
1836
  class="btn danger"
@@ -1841,7 +1842,38 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1841
1842
  </div>
1842
1843
  </div>
1843
1844
  </div>
1844
- `}function Of(e){return c`
1845
+ `}function Dh(e){if(e.payload.kind==="systemEvent")return c`<div class="cron-job-detail">
1846
+ <span class="cron-job-detail-label">System</span>
1847
+ <span class="muted cron-job-detail-value">${e.payload.text}</span>
1848
+ </div>`;const t=e.delivery,n=t?.channel||t?.to?` (${t.channel??"last"}${t.to?` -> ${t.to}`:""})`:"";return c`
1849
+ <div class="cron-job-detail">
1850
+ <span class="cron-job-detail-label">Prompt</span>
1851
+ <span class="muted cron-job-detail-value">${e.payload.message}</span>
1852
+ </div>
1853
+ ${t?c`<div class="cron-job-detail">
1854
+ <span class="cron-job-detail-label">Delivery</span>
1855
+ <span class="muted cron-job-detail-value">${t.mode}${n}</span>
1856
+ </div>`:f}
1857
+ `}function za(e){return typeof e!="number"||!Number.isFinite(e)?"n/a":Sl(e)}function Bh(e){const t=e.state?.lastStatus??"n/a",n=t==="ok"?"cron-job-status-ok":t==="error"?"cron-job-status-error":t==="skipped"?"cron-job-status-skipped":"cron-job-status-na",s=e.state?.nextRunAtMs,i=e.state?.lastRunAtMs;return c`
1858
+ <div class="cron-job-state">
1859
+ <div class="cron-job-state-row">
1860
+ <span class="cron-job-state-key">Status</span>
1861
+ <span class=${`cron-job-status-pill ${n}`}>${t}</span>
1862
+ </div>
1863
+ <div class="cron-job-state-row">
1864
+ <span class="cron-job-state-key">Next</span>
1865
+ <span class="cron-job-state-value" title=${At(s)}>
1866
+ ${za(s)}
1867
+ </span>
1868
+ </div>
1869
+ <div class="cron-job-state-row">
1870
+ <span class="cron-job-state-key">Last</span>
1871
+ <span class="cron-job-state-value" title=${At(i)}>
1872
+ ${za(i)}
1873
+ </span>
1874
+ </div>
1875
+ </div>
1876
+ `}function Fh(e,t){const n=typeof e.sessionKey=="string"&&e.sessionKey.trim().length>0?`${ln("chat",t)}?session=${encodeURIComponent(e.sessionKey)}`:null;return c`
1845
1877
  <div class="list-item">
1846
1878
  <div class="list-main">
1847
1879
  <div class="list-title">${e.status}</div>
@@ -1850,10 +1882,11 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1850
1882
  <div class="list-meta">
1851
1883
  <div>${At(e.ts)}</div>
1852
1884
  <div class="muted">${e.durationMs??0}ms</div>
1853
- ${e.error?c`<div class="muted">${e.error}</div>`:h}
1885
+ ${n?c`<div><a class="session-link" href=${n}>Open run chat</a></div>`:f}
1886
+ ${e.error?c`<div class="muted">${e.error}</div>`:f}
1854
1887
  </div>
1855
1888
  </div>
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`
1889
+ `}function Uh(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`
1857
1890
  <section class="grid grid-cols-2">
1858
1891
  <div class="card">
1859
1892
  <div class="row" style="justify-content: space-between;">
@@ -1870,8 +1903,8 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1870
1903
  <div class="muted">Status</div>
1871
1904
  ${n?c`<div class="callout ${o}" style="margin-top: 8px;">
1872
1905
  Security audit: ${l}${a>0?` · ${a} info`:""}. Run
1873
- <span class="mono">moltbot security audit --deep</span> for details.
1874
- </div>`:h}
1906
+ <span class="mono">poolbot security audit --deep</span> for details.
1907
+ </div>`:f}
1875
1908
  <pre class="code-block">${JSON.stringify(e.status??{},null,2)}</pre>
1876
1909
  </div>
1877
1910
  <div>
@@ -1911,8 +1944,8 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1911
1944
  </div>
1912
1945
  ${e.callError?c`<div class="callout danger" style="margin-top: 12px;">
1913
1946
  ${e.callError}
1914
- </div>`:h}
1915
- ${e.callResult?c`<pre class="code-block" style="margin-top: 12px;">${e.callResult}</pre>`:h}
1947
+ </div>`:f}
1948
+ ${e.callResult?c`<pre class="code-block" style="margin-top: 12px;">${e.callResult}</pre>`:f}
1916
1949
  </div>
1917
1950
  </section>
1918
1951
 
@@ -1934,14 +1967,14 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1934
1967
  <div class="list-sub">${new Date(r.ts).toLocaleTimeString()}</div>
1935
1968
  </div>
1936
1969
  <div class="list-meta">
1937
- <pre class="code-block">${Tf(r.payload)}</pre>
1970
+ <pre class="code-block">${Ih(r.payload)}</pre>
1938
1971
  </div>
1939
1972
  </div>
1940
1973
  `)}
1941
1974
  </div>
1942
1975
  `}
1943
1976
  </section>
1944
- `}function Bf(e){return c`
1977
+ `}function Kh(e){return c`
1945
1978
  <section class="card">
1946
1979
  <div class="row" style="justify-content: space-between;">
1947
1980
  <div>
@@ -1954,36 +1987,36 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
1954
1987
  </div>
1955
1988
  ${e.lastError?c`<div class="callout danger" style="margin-top: 12px;">
1956
1989
  ${e.lastError}
1957
- </div>`:h}
1990
+ </div>`:f}
1958
1991
  ${e.statusMessage?c`<div class="callout" style="margin-top: 12px;">
1959
1992
  ${e.statusMessage}
1960
- </div>`:h}
1993
+ </div>`:f}
1961
1994
  <div class="list" style="margin-top: 16px;">
1962
- ${e.entries.length===0?c`<div class="muted">No instances reported yet.</div>`:e.entries.map(t=>Ff(t))}
1995
+ ${e.entries.length===0?c`<div class="muted">No instances reported yet.</div>`:e.entries.map(t=>Hh(t))}
1963
1996
  </div>
1964
1997
  </section>
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`
1998
+ `}function Hh(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`
1966
1999
  <div class="list-item">
1967
2000
  <div class="list-main">
1968
2001
  <div class="list-title">${e.host??"unknown host"}</div>
1969
- <div class="list-sub">${Af(e)}</div>
2002
+ <div class="list-sub">${Th(e)}</div>
1970
2003
  <div class="chip-row">
1971
2004
  <span class="chip">${n}</span>
1972
2005
  ${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}
2006
+ ${a?c`<span class="chip">${a}</span>`:f}
2007
+ ${e.platform?c`<span class="chip">${e.platform}</span>`:f}
2008
+ ${e.deviceFamily?c`<span class="chip">${e.deviceFamily}</span>`:f}
2009
+ ${e.modelIdentifier?c`<span class="chip">${e.modelIdentifier}</span>`:f}
2010
+ ${e.version?c`<span class="chip">${e.version}</span>`:f}
1978
2011
  </div>
1979
2012
  </div>
1980
2013
  <div class="list-meta">
1981
- <div>${Sf(e)}</div>
2014
+ <div>${Ch(e)}</div>
1982
2015
  <div class="muted">Last input ${t}</div>
1983
2016
  <div class="muted">Reason ${e.reason??""}</div>
1984
2017
  </div>
1985
2018
  </div>
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`
2019
+ `}const ja=["trace","debug","info","warn","error","fatal"];function zh(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function jh(e,t){return t?[e.message,e.subsystem,e.raw].filter(Boolean).join(" ").toLowerCase().includes(t):!0}function qh(e){const t=e.filterText.trim().toLowerCase(),n=ja.some(a=>!e.levelFilters[a]),s=e.entries.filter(a=>a.level&&!e.levelFilters[a.level]?!1:jh(a,t)),i=t||n?"filtered":"visible";return c`
1987
2020
  <section class="card">
1988
2021
  <div class="row" style="justify-content: space-between;">
1989
2022
  <div>
@@ -2024,7 +2057,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2024
2057
  </div>
2025
2058
 
2026
2059
  <div class="chip-row" style="margin-top: 12px;">
2027
- ${Ka.map(a=>c`
2060
+ ${ja.map(a=>c`
2028
2061
  <label class="chip log-chip ${a}">
2029
2062
  <input
2030
2063
  type="checkbox"
@@ -2036,16 +2069,16 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2036
2069
  `)}
2037
2070
  </div>
2038
2071
 
2039
- ${e.file?c`<div class="muted" style="margin-top: 10px;">File: ${e.file}</div>`:h}
2072
+ ${e.file?c`<div class="muted" style="margin-top: 10px;">File: ${e.file}</div>`:f}
2040
2073
  ${e.truncated?c`<div class="callout" style="margin-top: 10px;">
2041
2074
  Log output truncated; showing latest chunk.
2042
- </div>`:h}
2043
- ${e.error?c`<div class="callout danger" style="margin-top: 10px;">${e.error}</div>`:h}
2075
+ </div>`:f}
2076
+ ${e.error?c`<div class="callout danger" style="margin-top: 10px;">${e.error}</div>`:f}
2044
2077
 
2045
2078
  <div class="log-stream" style="margin-top: 12px;" @scroll=${e.onScroll}>
2046
2079
  ${s.length===0?c`<div class="muted" style="padding: 12px;">No log entries.</div>`:s.map(a=>c`
2047
2080
  <div class="log-row">
2048
- <div class="log-time mono">${Uf(a.time)}</div>
2081
+ <div class="log-time mono">${zh(a.time)}</div>
2049
2082
  <div class="log-level ${a.level??""}">${a.level??""}</div>
2050
2083
  <div class="log-subsystem mono">${a.subsystem??""}</div>
2051
2084
  <div class="log-message mono">${a.message??a.raw}</div>
@@ -2053,10 +2086,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2053
2086
  `)}
2054
2087
  </div>
2055
2088
  </section>
2056
- `}function zf(e){const t=Yf(e),n=th(e);return c`
2057
- ${sh(n)}
2058
- ${nh(t)}
2059
- ${jf(e)}
2089
+ `}function Wh(e){const t=Jh(e),n=af(e);return c`
2090
+ ${rf(n)}
2091
+ ${of(t)}
2092
+ ${Vh(e)}
2060
2093
  <section class="card">
2061
2094
  <div class="row" style="justify-content: space-between;">
2062
2095
  <div>
@@ -2068,10 +2101,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2068
2101
  </button>
2069
2102
  </div>
2070
2103
  <div class="list" style="margin-top: 16px;">
2071
- ${e.nodes.length===0?c`<div class="muted">No nodes found.</div>`:e.nodes.map(s=>fh(s))}
2104
+ ${e.nodes.length===0?c`<div class="muted">No nodes found.</div>`:e.nodes.map(s=>mf(s))}
2072
2105
  </div>
2073
2106
  </section>
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`
2107
+ `}function Vh(e){const t=e.devicesList??{pending:[],paired:[]},n=Array.isArray(t.pending)?t.pending:[],s=Array.isArray(t.paired)?t.paired:[];return c`
2075
2108
  <section class="card">
2076
2109
  <div class="row" style="justify-content: space-between;">
2077
2110
  <div>
@@ -2082,20 +2115,20 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2082
2115
  ${e.devicesLoading?"Loading…":"Refresh"}
2083
2116
  </button>
2084
2117
  </div>
2085
- ${e.devicesError?c`<div class="callout danger" style="margin-top: 12px;">${e.devicesError}</div>`:h}
2118
+ ${e.devicesError?c`<div class="callout danger" style="margin-top: 12px;">${e.devicesError}</div>`:f}
2086
2119
  <div class="list" style="margin-top: 16px;">
2087
2120
  ${n.length>0?c`
2088
2121
  <div class="muted" style="margin-bottom: 8px;">Pending</div>
2089
- ${n.map(i=>qf(i,e))}
2090
- `:h}
2122
+ ${n.map(i=>Gh(i,e))}
2123
+ `:f}
2091
2124
  ${s.length>0?c`
2092
2125
  <div class="muted" style="margin-top: 12px; margin-bottom: 8px;">Paired</div>
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}
2126
+ ${s.map(i=>Yh(i,e))}
2127
+ `:f}
2128
+ ${n.length===0&&s.length===0?c`<div class="muted">No paired devices.</div>`:f}
2096
2129
  </div>
2097
2130
  </section>
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`
2131
+ `}function Gh(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`
2099
2132
  <div class="list-item">
2100
2133
  <div class="list-main">
2101
2134
  <div class="list-title">${n}</div>
@@ -2115,7 +2148,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2115
2148
  </div>
2116
2149
  </div>
2117
2150
  </div>
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`
2151
+ `}function Yh(e,t){const n=e.displayName?.trim()||e.deviceId,s=e.remoteIp?` · ${e.remoteIp}`:"",i=`roles: ${os(e.roles)}`,a=`scopes: ${os(e.scopes)}`,o=Array.isArray(e.tokens)?e.tokens:[];return c`
2119
2152
  <div class="list-item">
2120
2153
  <div class="list-main">
2121
2154
  <div class="list-title">${n}</div>
@@ -2124,12 +2157,12 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2124
2157
  ${o.length===0?c`<div class="muted" style="margin-top: 6px;">Tokens: none</div>`:c`
2125
2158
  <div class="muted" style="margin-top: 10px;">Tokens</div>
2126
2159
  <div style="display: flex; flex-direction: column; gap: 8px; margin-top: 6px;">
2127
- ${o.map(l=>Vf(e.deviceId,l,t))}
2160
+ ${o.map(l=>Qh(e.deviceId,l,t))}
2128
2161
  </div>
2129
2162
  `}
2130
2163
  </div>
2131
2164
  </div>
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`
2165
+ `}function Qh(e,t,n){const s=t.revokedAtMs?"revoked":"active",i=`scopes: ${os(t.scopes)}`,a=O(t.rotatedAtMs??t.createdAtMs??t.lastUsedAtMs??null);return c`
2133
2166
  <div class="row" style="justify-content: space-between; gap: 8px;">
2134
2167
  <div class="list-sub">${t.role} · ${s} · ${i} · ${a}</div>
2135
2168
  <div class="row" style="justify-content: flex-end; gap: 6px; flex-wrap: wrap;">
@@ -2139,7 +2172,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2139
2172
  >
2140
2173
  Rotate
2141
2174
  </button>
2142
- ${t.revokedAtMs?h:c`
2175
+ ${t.revokedAtMs?f:c`
2143
2176
  <button
2144
2177
  class="btn btn--sm danger"
2145
2178
  @click=${()=>n.onDeviceRevoke(e,t.role)}
@@ -2149,7 +2182,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2149
2182
  `}
2150
2183
  </div>
2151
2184
  </div>
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`
2185
+ `}const Ae="__defaults__",qa=[{value:"deny",label:"Deny"},{value:"allowlist",label:"Allowlist"},{value:"full",label:"Full"}],Zh=[{value:"off",label:"Off"},{value:"on-miss",label:"On miss"},{value:"always",label:"Always"}];function Jh(e){const t=e.configForm,n=ff(e.nodes),{defaultBinding:s,agents:i}=vf(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 Wa(e){return e==="allowlist"||e==="full"||e==="deny"?e:"deny"}function Xh(e){return e==="always"||e==="off"||e==="on-miss"?e:"on-miss"}function ef(e){const t=e?.defaults??{};return{security:Wa(t.security),ask:Xh(t.ask),askFallback:Wa(t.askFallback??"deny"),autoAllowSkills:!!(t.autoAllowSkills??!1)}}function tf(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 nf(e,t){const n=tf(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 sf(e,t){return e===Ae?Ae:e&&t.some(n=>n.id===e)?e:Ae}function af(e){const t=e.execApprovalsForm??e.execApprovalsSnapshot?.file??null,n=!!t,s=ef(t),i=nf(e.configForm,t),a=gf(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=sf(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 of(e){const t=e.nodes.length>0,n=e.defaultBinding??"";return c`
2153
2186
  <section class="card">
2154
2187
  <div class="row" style="justify-content: space-between; align-items: center;">
2155
2188
  <div>
@@ -2169,7 +2202,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2169
2202
 
2170
2203
  ${e.formMode==="raw"?c`<div class="callout warn" style="margin-top: 12px;">
2171
2204
  Switch the Config tab to <strong>Form</strong> mode to edit bindings here.
2172
- </div>`:h}
2205
+ </div>`:f}
2173
2206
 
2174
2207
  ${e.ready?c`
2175
2208
  <div class="list" style="margin-top: 16px;">
@@ -2194,11 +2227,11 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2194
2227
  </option>`)}
2195
2228
  </select>
2196
2229
  </label>
2197
- ${t?h:c`<div class="muted">No nodes with system.run available.</div>`}
2230
+ ${t?f:c`<div class="muted">No nodes with system.run available.</div>`}
2198
2231
  </div>
2199
2232
  </div>
2200
2233
 
2201
- ${e.agents.length===0?c`<div class="muted">No agents found.</div>`:e.agents.map(s=>ch(s,e))}
2234
+ ${e.agents.length===0?c`<div class="muted">No agents found.</div>`:e.agents.map(s=>hf(s,e))}
2202
2235
  </div>
2203
2236
  `:c`<div class="row" style="margin-top: 12px; gap: 12px;">
2204
2237
  <div class="muted">Load config to edit bindings.</div>
@@ -2207,7 +2240,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2207
2240
  </button>
2208
2241
  </div>`}
2209
2242
  </section>
2210
- `}function sh(e){const t=e.ready,n=e.target!=="node"||!!e.targetNodeId;return c`
2243
+ `}function rf(e){const t=e.ready,n=e.target!=="node"||!!e.targetNodeId;return c`
2211
2244
  <section class="card">
2212
2245
  <div class="row" style="justify-content: space-between; align-items: center;">
2213
2246
  <div>
@@ -2225,12 +2258,12 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2225
2258
  </button>
2226
2259
  </div>
2227
2260
 
2228
- ${ih(e)}
2261
+ ${lf(e)}
2229
2262
 
2230
2263
  ${t?c`
2231
- ${ah(e)}
2232
- ${oh(e)}
2233
- ${e.selectedScope===Ae?h:rh(e)}
2264
+ ${cf(e)}
2265
+ ${df(e)}
2266
+ ${e.selectedScope===Ae?f:uf(e)}
2234
2267
  `:c`<div class="row" style="margin-top: 12px; gap: 12px;">
2235
2268
  <div class="muted">Load exec approvals to edit allowlists.</div>
2236
2269
  <button class="btn" ?disabled=${e.loading||!n} @click=${e.onLoad}>
@@ -2238,7 +2271,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2238
2271
  </button>
2239
2272
  </div>`}
2240
2273
  </section>
2241
- `}function ih(e){const t=e.targetNodes.length>0,n=e.targetNodeId??"";return c`
2274
+ `}function lf(e){const t=e.targetNodes.length>0,n=e.targetNodeId??"";return c`
2242
2275
  <div class="list" style="margin-top: 12px;">
2243
2276
  <div class="list-item">
2244
2277
  <div class="list-main">
@@ -2274,12 +2307,12 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2274
2307
  </option>`)}
2275
2308
  </select>
2276
2309
  </label>
2277
- `:h}
2310
+ `:f}
2278
2311
  </div>
2279
2312
  </div>
2280
- ${e.target==="node"&&!t?c`<div class="muted">No nodes advertise exec approvals yet.</div>`:h}
2313
+ ${e.target==="node"&&!t?c`<div class="muted">No nodes advertise exec approvals yet.</div>`:f}
2281
2314
  </div>
2282
- `}function ah(e){return c`
2315
+ `}function cf(e){return c`
2283
2316
  <div class="row" style="margin-top: 12px; gap: 8px; flex-wrap: wrap;">
2284
2317
  <span class="label">Scope</span>
2285
2318
  <div class="row" style="gap: 8px; flex-wrap: wrap;">
@@ -2299,7 +2332,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2299
2332
  `})}
2300
2333
  </div>
2301
2334
  </div>
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`
2335
+ `}function df(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`
2303
2336
  <div class="list" style="margin-top: 16px;">
2304
2337
  <div class="list-item">
2305
2338
  <div class="list-main">
@@ -2315,10 +2348,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2315
2348
  ?disabled=${e.disabled}
2316
2349
  @change=${w=>{const k=w.target.value;!t&&k==="__default__"?e.onRemove([...i,"security"]):e.onPatch([...i,"security"],k)}}
2317
2350
  >
2318
- ${t?h:c`<option value="__default__" ?selected=${r==="__default__"}>
2351
+ ${t?f:c`<option value="__default__" ?selected=${r==="__default__"}>
2319
2352
  Use default (${n.security})
2320
2353
  </option>`}
2321
- ${Ha.map(w=>c`<option
2354
+ ${qa.map(w=>c`<option
2322
2355
  value=${w.value}
2323
2356
  ?selected=${r===w.value}
2324
2357
  >
@@ -2343,10 +2376,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2343
2376
  ?disabled=${e.disabled}
2344
2377
  @change=${w=>{const k=w.target.value;!t&&k==="__default__"?e.onRemove([...i,"ask"]):e.onPatch([...i,"ask"],k)}}
2345
2378
  >
2346
- ${t?h:c`<option value="__default__" ?selected=${p==="__default__"}>
2379
+ ${t?f:c`<option value="__default__" ?selected=${p==="__default__"}>
2347
2380
  Use default (${n.ask})
2348
2381
  </option>`}
2349
- ${Gf.map(w=>c`<option
2382
+ ${Zh.map(w=>c`<option
2350
2383
  value=${w.value}
2351
2384
  ?selected=${p===w.value}
2352
2385
  >
@@ -2371,10 +2404,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2371
2404
  ?disabled=${e.disabled}
2372
2405
  @change=${w=>{const k=w.target.value;!t&&k==="__default__"?e.onRemove([...i,"askFallback"]):e.onPatch([...i,"askFallback"],k)}}
2373
2406
  >
2374
- ${t?h:c`<option value="__default__" ?selected=${d==="__default__"}>
2407
+ ${t?f:c`<option value="__default__" ?selected=${d==="__default__"}>
2375
2408
  Use default (${n.askFallback})
2376
2409
  </option>`}
2377
- ${Ha.map(w=>c`<option
2410
+ ${qa.map(w=>c`<option
2378
2411
  value=${w.value}
2379
2412
  ?selected=${d===w.value}
2380
2413
  >
@@ -2408,11 +2441,11 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2408
2441
  @click=${()=>e.onRemove([...i,"autoAllowSkills"])}
2409
2442
  >
2410
2443
  Use default
2411
- </button>`:h}
2444
+ </button>`:f}
2412
2445
  </div>
2413
2446
  </div>
2414
2447
  </div>
2415
- `}function rh(e){const t=["agents",e.selectedScope,"allowlist"],n=e.allowlist;return c`
2448
+ `}function uf(e){const t=["agents",e.selectedScope,"allowlist"],n=e.allowlist;return c`
2416
2449
  <div class="row" style="margin-top: 18px; justify-content: space-between;">
2417
2450
  <div>
2418
2451
  <div class="card-title">Allowlist</div>
@@ -2427,15 +2460,15 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2427
2460
  </button>
2428
2461
  </div>
2429
2462
  <div class="list" style="margin-top: 12px;">
2430
- ${n.length===0?c`<div class="muted">No allowlist entries yet.</div>`:n.map((s,i)=>lh(e,s,i))}
2463
+ ${n.length===0?c`<div class="muted">No allowlist entries yet.</div>`:n.map((s,i)=>pf(e,s,i))}
2431
2464
  </div>
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`
2465
+ `}function pf(e,t,n){const s=t.lastUsedAt?O(t.lastUsedAt):"never",i=t.lastUsedCommand?rs(t.lastUsedCommand,120):null,a=t.lastResolvedPath?rs(t.lastResolvedPath,120):null;return c`
2433
2466
  <div class="list-item">
2434
2467
  <div class="list-main">
2435
2468
  <div class="list-title">${t.pattern?.trim()?t.pattern:"New pattern"}</div>
2436
2469
  <div class="list-sub">Last used: ${s}</div>
2437
- ${i?c`<div class="list-sub mono">${i}</div>`:h}
2438
- ${a?c`<div class="list-sub mono">${a}</div>`:h}
2470
+ ${i?c`<div class="list-sub mono">${i}</div>`:f}
2471
+ ${a?c`<div class="list-sub mono">${a}</div>`:f}
2439
2472
  </div>
2440
2473
  <div class="list-meta">
2441
2474
  <label class="field">
@@ -2456,7 +2489,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2456
2489
  </button>
2457
2490
  </div>
2458
2491
  </div>
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`
2492
+ `}function hf(e,t){const n=e.binding??"__default__",s=e.name?.trim()?`${e.name} (${e.id})`:e.id,i=t.nodes.length>0;return c`
2460
2493
  <div class="list-item">
2461
2494
  <div class="list-main">
2462
2495
  <div class="list-title">${s}</div>
@@ -2485,7 +2518,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2485
2518
  </label>
2486
2519
  </div>
2487
2520
  </div>
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`
2521
+ `}function ff(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 gf(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 vf(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 mf(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`
2489
2522
  <div class="list-item">
2490
2523
  <div class="list-main">
2491
2524
  <div class="list-title">${s}</div>
@@ -2504,12 +2537,12 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2504
2537
  </div>
2505
2538
  </div>
2506
2539
  </div>
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`
2540
+ `}function yf(e){const t=e.hello?.snapshot,n=t?.uptimeMs?lo(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`
2508
2541
  <div class="muted" style="margin-top: 8px;">
2509
2542
  This gateway requires auth. Add a token or password, then click Connect.
2510
2543
  <div style="margin-top: 6px;">
2511
- <span class="mono">moltbot dashboard --no-open</span> → tokenized URL<br />
2512
- <span class="mono">moltbot doctor --generate-gateway-token</span> → set token
2544
+ <span class="mono">poolbot dashboard --no-open</span> → tokenized URL<br />
2545
+ <span class="mono">poolbot doctor --generate-gateway-token</span> → set token
2513
2546
  </div>
2514
2547
  <div style="margin-top: 6px;">
2515
2548
  <a
@@ -2525,7 +2558,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2525
2558
  `:c`
2526
2559
  <div class="muted" style="margin-top: 8px;">
2527
2560
  Auth failed. Re-copy a tokenized URL with
2528
- <span class="mono">moltbot dashboard --no-open</span>, or update the token,
2561
+ <span class="mono">poolbot dashboard --no-open</span>, or update the token,
2529
2562
  then click Connect.
2530
2563
  <div style="margin-top: 6px;">
2531
2564
  <a
@@ -2663,7 +2696,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2663
2696
  <div class="stat-value">
2664
2697
  ${e.cronEnabled==null?"n/a":e.cronEnabled?"Enabled":"Disabled"}
2665
2698
  </div>
2666
- <div class="muted">Next wake ${vr(e.cronNext)}</div>
2699
+ <div class="muted">Next wake ${br(e.cronNext)}</div>
2667
2700
  </div>
2668
2701
  </section>
2669
2702
 
@@ -2687,7 +2720,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2687
2720
  </div>
2688
2721
  </div>
2689
2722
  </section>
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`
2723
+ `}const bf=["","off","minimal","low","medium","high"],wf=["","off","on"],$f=[{value:"",label:"inherit"},{value:"off",label:"off (explicit)"},{value:"on",label:"on"}],xf=["","off","on","stream"];function kf(e){if(!e)return"";const t=e.trim().toLowerCase();return t==="z.ai"||t==="z-ai"?"zai":t}function wr(e){return kf(e)==="zai"}function Af(e){return wr(e)?wf:bf}function Sf(e,t){return!t||!e||e==="off"?e:"on"}function _f(e,t){return e?t&&e==="on"?"low":e:null}function Tf(e){const t=e.result?.sessions??[];return c`
2691
2724
  <section class="card">
2692
2725
  <div class="row" style="justify-content: space-between;">
2693
2726
  <div>
@@ -2732,7 +2765,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2732
2765
  </label>
2733
2766
  </div>
2734
2767
 
2735
- ${e.error?c`<div class="callout danger" style="margin-top: 12px;">${e.error}</div>`:h}
2768
+ ${e.error?c`<div class="callout danger" style="margin-top: 12px;">${e.error}</div>`:f}
2736
2769
 
2737
2770
  <div class="muted" style="margin-top: 12px;">
2738
2771
  ${e.result?`Store: ${e.result.path}`:""}
@@ -2750,10 +2783,10 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2750
2783
  <div>Reasoning</div>
2751
2784
  <div>Actions</div>
2752
2785
  </div>
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))}
2786
+ ${t.length===0?c`<div class="muted">No sessions found.</div>`:t.map(n=>Cf(n,e.basePath,e.onPatch,e.onDelete,e.loading))}
2754
2787
  </div>
2755
2788
  </section>
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`
2789
+ `}function Cf(e,t,n,s,i){const a=e.updatedAt?O(e.updatedAt):"n/a",o=e.thinkingLevel??"",l=wr(e.modelProvider),r=Sf(o,l),p=Af(e.modelProvider),d=e.verboseLevel??"",u=e.reasoningLevel??"",g=e.displayName??e.key,v=e.kind!=="global",w=v?`${ln("chat",t)}?session=${encodeURIComponent(e.key)}`:null;return c`
2757
2790
  <div class="table-row">
2758
2791
  <div class="mono">${v?c`<a href=${w} class="session-link">${g}</a>`:g}</div>
2759
2792
  <div>
@@ -2766,12 +2799,12 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2766
2799
  </div>
2767
2800
  <div>${e.kind}</div>
2768
2801
  <div>${a}</div>
2769
- <div>${_f(e)}</div>
2802
+ <div>${Eh(e)}</div>
2770
2803
  <div>
2771
2804
  <select
2772
2805
  .value=${r}
2773
2806
  ?disabled=${i}
2774
- @change=${$=>{const k=$.target.value;n(e.key,{thinkingLevel:xh(k,l)})}}
2807
+ @change=${$=>{const k=$.target.value;n(e.key,{thinkingLevel:_f(k,l)})}}
2775
2808
  >
2776
2809
  ${p.map($=>c`<option value=${$}>${$||"inherit"}</option>`)}
2777
2810
  </select>
@@ -2782,7 +2815,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2782
2815
  ?disabled=${i}
2783
2816
  @change=${$=>{const k=$.target.value;n(e.key,{verboseLevel:k||null})}}
2784
2817
  >
2785
- ${mh.map($=>c`<option value=${$.value}>${$.label}</option>`)}
2818
+ ${$f.map($=>c`<option value=${$.value}>${$.label}</option>`)}
2786
2819
  </select>
2787
2820
  </div>
2788
2821
  <div>
@@ -2791,7 +2824,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2791
2824
  ?disabled=${i}
2792
2825
  @change=${$=>{const k=$.target.value;n(e.key,{reasoningLevel:k||null})}}
2793
2826
  >
2794
- ${yh.map($=>c`<option value=${$}>${$||"inherit"}</option>`)}
2827
+ ${xf.map($=>c`<option value=${$}>${$||"inherit"}</option>`)}
2795
2828
  </select>
2796
2829
  </div>
2797
2830
  <div>
@@ -2800,7 +2833,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2800
2833
  </button>
2801
2834
  </div>
2802
2835
  </div>
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`
2836
+ `}function Ef(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>`:f}function If(e){const t=e.execApprovalQueue[0];if(!t)return f;const n=t.request,s=t.expiresAtMs-Date.now(),i=s>0?`expires in ${Ef(s)}`:"expired",a=e.execApprovalQueue.length;return c`
2804
2837
  <div class="exec-approval-overlay" role="dialog" aria-live="polite">
2805
2838
  <div class="exec-approval-card">
2806
2839
  <div class="exec-approval-header">
@@ -2808,7 +2841,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2808
2841
  <div class="exec-approval-title">Exec approval needed</div>
2809
2842
  <div class="exec-approval-sub">${i}</div>
2810
2843
  </div>
2811
- ${a>1?c`<div class="exec-approval-queue">${a} pending</div>`:h}
2844
+ ${a>1?c`<div class="exec-approval-queue">${a} pending</div>`:f}
2812
2845
  </div>
2813
2846
  <div class="exec-approval-command mono">${n.command}</div>
2814
2847
  <div class="exec-approval-meta">
@@ -2820,7 +2853,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2820
2853
  ${Me("Security",n.security)}
2821
2854
  ${Me("Ask",n.ask)}
2822
2855
  </div>
2823
- ${e.execApprovalError?c`<div class="exec-approval-error">${e.execApprovalError}</div>`:h}
2856
+ ${e.execApprovalError?c`<div class="exec-approval-error">${e.execApprovalError}</div>`:f}
2824
2857
  <div class="exec-approval-actions">
2825
2858
  <button
2826
2859
  class="btn primary"
@@ -2846,7 +2879,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2846
2879
  </div>
2847
2880
  </div>
2848
2881
  </div>
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`
2882
+ `}function Lf(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`
2850
2883
  <section class="card">
2851
2884
  <div class="row" style="justify-content: space-between;">
2852
2885
  <div>
@@ -2870,38 +2903,38 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2870
2903
  <div class="muted">${s.length} shown</div>
2871
2904
  </div>
2872
2905
 
2873
- ${e.error?c`<div class="callout danger" style="margin-top: 12px;">${e.error}</div>`:h}
2906
+ ${e.error?c`<div class="callout danger" style="margin-top: 12px;">${e.error}</div>`:f}
2874
2907
 
2875
2908
  ${s.length===0?c`<div class="muted" style="margin-top: 16px;">No skills found.</div>`:c`
2876
2909
  <div class="list" style="margin-top: 16px;">
2877
- ${s.map(i=>Ch(i,e))}
2910
+ ${s.map(i=>Mf(i,e))}
2878
2911
  </div>
2879
2912
  `}
2880
2913
  </section>
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`
2914
+ `}function Mf(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`
2882
2915
  <div class="list-item">
2883
2916
  <div class="list-main">
2884
2917
  <div class="list-title">
2885
2918
  ${e.emoji?`${e.emoji} `:""}${e.name}
2886
2919
  </div>
2887
- <div class="list-sub">${os(e.description,140)}</div>
2920
+ <div class="list-sub">${rs(e.description,140)}</div>
2888
2921
  <div class="chip-row" style="margin-top: 6px;">
2889
2922
  <span class="chip">${e.source}</span>
2890
2923
  <span class="chip ${e.eligible?"chip-ok":"chip-warn"}">
2891
2924
  ${e.eligible?"eligible":"blocked"}
2892
2925
  </span>
2893
- ${e.disabled?c`<span class="chip chip-warn">disabled</span>`:h}
2926
+ ${e.disabled?c`<span class="chip chip-warn">disabled</span>`:f}
2894
2927
  </div>
2895
2928
  ${o.length>0?c`
2896
2929
  <div class="muted" style="margin-top: 6px;">
2897
2930
  Missing: ${o.join(", ")}
2898
2931
  </div>
2899
- `:h}
2932
+ `:f}
2900
2933
  ${l.length>0?c`
2901
2934
  <div class="muted" style="margin-top: 6px;">
2902
2935
  Reason: ${l.join(", ")}
2903
2936
  </div>
2904
- `:h}
2937
+ `:f}
2905
2938
  </div>
2906
2939
  <div class="list-meta">
2907
2940
  <div class="row" style="justify-content: flex-end; flex-wrap: wrap;">
@@ -2918,14 +2951,14 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2918
2951
  @click=${()=>t.onInstall(e.skillKey,e.name,e.install[0].id)}
2919
2952
  >
2920
2953
  ${n?"Installing…":e.install[0].label}
2921
- </button>`:h}
2954
+ </button>`:f}
2922
2955
  </div>
2923
2956
  ${i?c`<div
2924
2957
  class="muted"
2925
2958
  style="margin-top: 8px; color: ${i.kind==="error"?"var(--danger-color, #d14343)":"var(--success-color, #0a7f5a)"};"
2926
2959
  >
2927
2960
  ${i.message}
2928
- </div>`:h}
2961
+ </div>`:f}
2929
2962
  ${e.primaryEnv?c`
2930
2963
  <div class="field" style="margin-top: 10px;">
2931
2964
  <span>API key</span>
@@ -2943,28 +2976,28 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2943
2976
  >
2944
2977
  Save key
2945
2978
  </button>
2946
- `:h}
2979
+ `:f}
2947
2980
  </div>
2948
2981
  </div>
2949
- `}function Eh(e,t){const n=Ps(t,e.basePath);return c`
2982
+ `}function Rf(e,t){const n=ln(t,e.basePath);return c`
2950
2983
  <a
2951
2984
  href=${n}
2952
2985
  class="nav-item ${e.tab===t?"active":""}"
2953
2986
  @click=${s=>{s.defaultPrevented||s.button!==0||s.metaKey||s.ctrlKey||s.shiftKey||s.altKey||(s.preventDefault(),e.setTab(t))}}
2954
- title=${is(t)}
2987
+ title=${as(t)}
2955
2988
  >
2956
- <span class="nav-item__icon" aria-hidden="true">${V[ml(t)]}</span>
2957
- <span class="nav-item__text">${is(t)}</span>
2989
+ <span class="nav-item__icon" aria-hidden="true">${V[wl(t)]}</span>
2990
+ <span class="nav-item__text">${as(t)}</span>
2958
2991
  </a>
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`
2992
+ `}function Pf(e){const t=Nf(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`
2960
2993
  <div class="chat-controls">
2961
2994
  <label class="field chat-controls__session">
2962
2995
  <select
2963
2996
  .value=${e.sessionKey}
2964
2997
  ?disabled=${!e.connected}
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)}}
2998
+ @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(),$d(e,p),Xe(e)}}
2966
2999
  >
2967
- ${zo(t,r=>r.key,r=>c`<option value=${r.key}>
3000
+ ${Wo(t,r=>r.key,r=>c`<option value=${r.key}>
2968
3001
  ${r.displayName??r.key}
2969
3002
  </option>`)}
2970
3003
  </select>
@@ -2997,7 +3030,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
2997
3030
  ${l}
2998
3031
  </button>
2999
3032
  </div>
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`
3033
+ `}function Nf(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 Of=["system","light","dark"];function Df(e){const t=Math.max(0,Of.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`
3001
3034
  <div class="theme-toggle" style="--theme-index: ${t};">
3002
3035
  <div class="theme-toggle__track" role="group" aria-label="Theme">
3003
3036
  <span class="theme-toggle__indicator"></span>
@@ -3008,7 +3041,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
3008
3041
  aria-label="System theme"
3009
3042
  title="System"
3010
3043
  >
3011
- ${Oh()}
3044
+ ${Uf()}
3012
3045
  </button>
3013
3046
  <button
3014
3047
  class="theme-toggle__button ${e.theme==="light"?"active":""}"
@@ -3017,7 +3050,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
3017
3050
  aria-label="Light theme"
3018
3051
  title="Light"
3019
3052
  >
3020
- ${Ph()}
3053
+ ${Bf()}
3021
3054
  </button>
3022
3055
  <button
3023
3056
  class="theme-toggle__button ${e.theme==="dark"?"active":""}"
@@ -3026,11 +3059,11 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
3026
3059
  aria-label="Dark theme"
3027
3060
  title="Dark"
3028
3061
  >
3029
- ${Nh()}
3062
+ ${Ff()}
3030
3063
  </button>
3031
3064
  </div>
3032
3065
  </div>
3033
- `}function Ph(){return c`
3066
+ `}function Bf(){return c`
3034
3067
  <svg class="theme-icon" viewBox="0 0 24 24" aria-hidden="true">
3035
3068
  <circle cx="12" cy="12" r="4"></circle>
3036
3069
  <path d="M12 2v2"></path>
@@ -3042,19 +3075,19 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
3042
3075
  <path d="m6.34 17.66-1.41 1.41"></path>
3043
3076
  <path d="m19.07 4.93-1.41 1.41"></path>
3044
3077
  </svg>
3045
- `}function Nh(){return c`
3078
+ `}function Ff(){return c`
3046
3079
  <svg class="theme-icon" viewBox="0 0 24 24" aria-hidden="true">
3047
3080
  <path
3048
3081
  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"
3049
3082
  ></path>
3050
3083
  </svg>
3051
- `}function Oh(){return c`
3084
+ `}function Uf(){return c`
3052
3085
  <svg class="theme-icon" viewBox="0 0 24 24" aria-hidden="true">
3053
3086
  <rect width="20" height="14" x="2" y="3" rx="2"></rect>
3054
3087
  <line x1="8" x2="16" y1="21" y2="21"></line>
3055
3088
  <line x1="12" x2="12" y1="17" y2="21"></line>
3056
3089
  </svg>
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`
3090
+ `}const Kf=/^data:/i,Hf=/^https?:\/\//i;function zf(e){const t=e.agentsList?.agents??[],s=io(e.sessionKey)?.agentId??e.agentsList?.defaultId??"main",a=t.find(l=>l.id===s)?.identity,o=a?.avatarUrl??a?.avatar;if(o)return Kf.test(o)||Hf.test(o)?o:a?.avatarUrl}function jf(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=zf(e),p=e.chatAvatarUrl??r??null;return c`
3058
3091
  <div class="shell ${a?"shell--chat":""} ${o?"shell--chat-focus":""} ${e.settings.navCollapsed?"shell--nav-collapsed":""} ${e.onboarding?"shell--onboarding":""}">
3059
3092
  <header class="topbar">
3060
3093
  <div class="topbar-left">
@@ -3068,7 +3101,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
3068
3101
  </button>
3069
3102
  <div class="brand">
3070
3103
  <div class="brand-logo">
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" />
3104
+ <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="Poolbot" />
3072
3105
  </div>
3073
3106
  <div class="brand-text">
3074
3107
  <div class="brand-title">MOLTBOT</div>
@@ -3082,11 +3115,11 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
3082
3115
  <span>Health</span>
3083
3116
  <span class="mono">${e.connected?"OK":"Offline"}</span>
3084
3117
  </div>
3085
- ${Rh(e)}
3118
+ ${Df(e)}
3086
3119
  </div>
3087
3120
  </header>
3088
3121
  <aside class="nav ${e.settings.navCollapsed?"nav--collapsed":""}">
3089
- ${gl.map(d=>{const u=e.settings.navGroupsCollapsed[d.label]??!1,g=d.tabs.some(v=>v===e.tab);return c`
3122
+ ${yl.map(d=>{const u=e.settings.navGroupsCollapsed[d.label]??!1,g=d.tabs.some(v=>v===e.tab);return c`
3090
3123
  <div class="nav-group ${u&&!g?"nav-group--collapsed":""}">
3091
3124
  <button
3092
3125
  class="nav-label"
@@ -3097,7 +3130,7 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
3097
3130
  <span class="nav-label__chevron">${u?"+":"−"}</span>
3098
3131
  </button>
3099
3132
  <div class="nav-group__items">
3100
- ${d.tabs.map(v=>Eh(e,v))}
3133
+ ${d.tabs.map(v=>Rf(e,v))}
3101
3134
  </div>
3102
3135
  </div>
3103
3136
  `})}
@@ -3122,40 +3155,40 @@ ${e.snapshot?JSON.stringify(e.snapshot,null,2):"No snapshot yet."}
3122
3155
  <main class="content ${a?"content--chat":""}">
3123
3156
  <section class="content-header">
3124
3157
  <div>
3125
- <div class="page-title">${is(e.tab)}</div>
3126
- <div class="page-sub">${yl(e.tab)}</div>
3158
+ <div class="page-title">${as(e.tab)}</div>
3159
+ <div class="page-sub">${$l(e.tab)}</div>
3127
3160
  </div>
3128
3161
  <div class="page-meta">
3129
- ${e.lastError?c`<div class="pill danger">${e.lastError}</div>`:h}
3130
- ${a?Lh(e):h}
3162
+ ${e.lastError?c`<div class="pill danger">${e.lastError}</div>`:f}
3163
+ ${a?Pf(e):f}
3131
3164
  </div>
3132
3165
  </section>
3133
3166
 
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}
3167
+ ${e.tab==="overview"?yf({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()}):f}
3135
3168
 
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}
3169
+ ${e.tab==="channels"?mh({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()}):f}
3137
3170
 
3138
- ${e.tab==="instances"?Bf({loading:e.presenceLoading,entries:e.presenceEntries,lastError:e.presenceError,statusMessage:e.presenceStatus,onRefresh:()=>js(e)}):h}
3171
+ ${e.tab==="instances"?Kh({loading:e.presenceLoading,entries:e.presenceEntries,lastError:e.presenceError,statusMessage:e.presenceStatus,onRefresh:()=>js(e)}):f}
3139
3172
 
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}
3173
+ ${e.tab==="sessions"?Tf({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)=>Bl(e,d,u),onDelete:d=>Fl(e,d)}):f}
3141
3174
 
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}
3175
+ ${e.tab==="cron"?Ph({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:()=>rc(e),onToggle:(d,u)=>lc(e,d,u),onRun:d=>cc(e,d),onRemove:d=>dc(e,d),onLoadRuns:d=>vo(e,d)}):f}
3143
3176
 
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}
3177
+ ${e.tab==="skills"?Lf({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)=>id(e,d,u),onEdit:(d,u)=>sd(e,d,u),onSaveKey:d=>ad(e,d),onInstall:(d,u,g)=>od(e,d,u,g)}):f}
3145
3178
 
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}
3179
+ ${e.tab==="nodes"?Wh({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=>Vc(e,d),onDeviceReject:d=>Gc(e,d),onDeviceRotate:(d,u,g)=>Yc(e,{deviceId:d,role:u,scopes:g}),onDeviceRevoke:(d,u)=>Qc(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):ea(e,["tools","exec","node"])},onBindAgent:(d,u)=>{const g=["agents","list",d,"tools","exec","node"];u?Bt(e,g,u):ea(e,g)},onSaveBindings:()=>ds(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)=>td(e,d,u),onExecApprovalsRemove:d=>nd(e,d),onSaveExecApprovals:()=>{const d=e.execApprovalsTarget==="node"&&e.execApprovalsTargetNodeId?{kind:"node",nodeId:e.execApprovalsTargetNodeId}:{kind:"gateway"};return ed(e,d)}}):f}
3147
3180
 
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}
3181
+ ${e.tab==="chat"?Np({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),gs(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),gs(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}):f}
3149
3182
 
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}
3183
+ ${e.tab==="config"?Xp({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:()=>ds(e),onApply:()=>sc(e),onUpdate:()=>ic(e)}):f}
3151
3184
 
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}
3185
+ ${e.tab==="debug"?Uh({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:()=>pn(e),onCall:()=>fc(e)}):f}
3153
3186
 
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}
3187
+ ${e.tab==="logs"?qh({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)}):f}
3155
3188
  </main>
3156
- ${_h(e)}
3189
+ ${If(e)}
3157
3190
  </div>
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=`{
3191
+ `}const qf={trace:!0,debug:!0,info:!0,warn:!0,error:!0,fatal:!0},Wf={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 Vf(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 $r={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"},Va=$r,Ts={WEBCHAT:"webchat",CLI:"cli",UI:"ui",BACKEND:"backend",NODE:"node",PROBE:"probe",TEST:"test"};new Set(Object.values($r));new Set(Object.values(Ts));function Gf(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 Yf=4008;class Qf{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=Wc({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=Gf({deviceId:i.deviceId,clientId:this.opts.clientName??Va.CONTROL_UI,clientMode:this.opts.mode??Ts.WEBCHAT,role:s,scopes:n,signedAtMs:d,token:o??null,nonce:u}),v=await jc(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??Va.CONTROL_UI,version:this.opts.clientVersion??"dev",platform:this.opts.platform??navigator.platform??"web",mode:this.opts.mode??Ts.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&&Ro({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&&Po({deviceId:i.deviceId,role:s}),this.ws?.close(Yf,"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 Cs(e){return typeof e=="object"&&e!==null}function Zf(e){if(!Cs(e))return null;const t=typeof e.id=="string"?e.id.trim():"",n=e.request;if(!t||!Cs(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 Jf(e){if(!Cs(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 xr(e){const t=Date.now();return e.filter(n=>n.expiresAtMs>t)}function Xf(e,t){const n=xr(e).filter(s=>s.id!==t.id);return n.push(t),n}function Ga(e,t){return xr(e).filter(n=>n.id!==t)}async function kr(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=is(i);e.assistantName=a.name,e.assistantAvatar=a.avatar,e.assistantAgentId=a.agentId??null}catch{}}function ts(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 eg(e,t){if(!t?.mainSessionKey)return;const n=ts(e.sessionKey,t),s=ts(e.settings.sessionKey,t),i=ts(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 Ar(e){e.lastError=null,e.hello=null,e.connected=!1,e.execApprovalQueue=[],e.execApprovalError=null,e.client?.stop(),e.client=new Qf({url:e.settings.gatewayUrl,token:e.settings.token.trim()?e.settings.token:void 0,password:e.password.trim()?e.password:void 0,clientName:"poolbot-control-ui",mode:"webchat",onHello:t=>{e.connected=!0,e.lastError=null,e.hello=t,sg(e,t),e.chatRunId=null,e.chatStream=null,e.chatStreamStartedAt=null,cn(e),kr(e),Vf(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=>tg(e,t),onGap:({expected:t,received:n})=>{e.lastError=`event gap detected (expected seq ${t}, got ${n}); refresh recommended`}}),e.client.start()}function tg(e,t){try{ng(e,t)}catch(n){console.error("[gateway] handleGatewayEvent error:",t.event,n)}}function ng(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;Yl(e,t.payload);return}if(t.event==="chat"){const n=t.payload;n?.sessionKey&&No(e,n.sessionKey);const s=Dl(e,n);(s==="final"||s==="error"||s==="aborted")&&(cn(e),Cd(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=Zf(t.payload);if(n){e.execApprovalQueue=Xf(e.execApprovalQueue,n),e.execApprovalError=null;const s=Math.max(0,n.expiresAtMs-Date.now()+500);window.setTimeout(()=>{e.execApprovalQueue=Ga(e.execApprovalQueue,n.id)},s)}return}if(t.event==="exec.approval.resolved"){const n=Jf(t.payload);n&&(e.execApprovalQueue=Ga(e.execApprovalQueue,n.id))}}function sg(e,t){const n=t.snapshot;n?.presence&&Array.isArray(n.presence)&&(e.presenceEntries=n.presence),n?.health&&(e.debugHealth=n.health),n?.sessionDefaults&&eg(e,n.sessionDefaults)}function ig(e){e.basePath=gd(),bd(e,!0),vd(e),md(e),window.addEventListener("popstate",e.popStateHandler),pd(e),Ar(e),dd(e),e.tab==="logs"&&Ws(e),e.tab==="debug"&&Gs(e)}function ag(e){ec(e)}function og(e){window.removeEventListener("popstate",e.popStateHandler),ud(e),Vs(e),Ys(e),yd(e),e.topbarObserver?.disconnect(),e.topbarObserver=null}function rg(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;dn(e,n||s||!e.chatHasAutoScrolled)}e.tab==="logs"&&(t.has("logsEntries")||t.has("logsAutoFollow")||t.has("tab"))&&e.logsAutoFollow&&e.logsAtBottom&&po(e,t.has("tab")||t.has("logsAutoFollow"))}async function lg(e,t){await uc(e,t),await oe(e,!0)}async function cg(e){await pc(e),await oe(e,!0)}async function dg(e){await hc(e),await oe(e,!0)}async function ug(e){await ds(e),await ye(e),await oe(e,!0)}async function pg(e){await ye(e),await oe(e,!0)}function hg(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 Sr(e){return(e.channelsSnapshot?.channelAccounts?.nostr??[])[0]?.accountId??e.nostrProfileAccountId??"default"}function _r(e,t=""){return`/api/channels/nostr/${encodeURIComponent(e)}/profile${t}`}function fg(e,t,n){e.nostrProfileAccountId=t,e.nostrProfileFormState=uh(n??void 0)}function gg(e){e.nostrProfileFormState=null,e.nostrProfileAccountId=null}function vg(e,t,n){const s=e.nostrProfileFormState;s&&(e.nostrProfileFormState={...s,values:{...s.values,[t]:n},fieldErrors:{...s.fieldErrors,[t]:""}})}function mg(e){const t=e.nostrProfileFormState;t&&(e.nostrProfileFormState={...t,showAdvanced:!t.showAdvanced})}async function yg(e){const t=e.nostrProfileFormState;if(!t||t.saving)return;const n=Sr(e);e.nostrProfileFormState={...t,saving:!0,error:null,success:null,fieldErrors:{}};try{const s=await fetch(_r(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:hg(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 bg(e){const t=e.nostrProfileFormState;if(!t||t.importing)return;const n=Sr(e);e.nostrProfileFormState={...t,importing:!0,error:null,success:null};try{const s=await fetch(_r(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 wg=Object.defineProperty,$g=Object.getOwnPropertyDescriptor,y=(e,t,n,s)=>{for(var i=s>1?void 0:s?$g(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&&wg(t,n,i),i};const ns=gl();function xg(){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=vl(),this.password="",this.tab="chat",this.onboarding=xg(),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=ns.name,this.assistantAvatar=ns.avatar,this.assistantAgentId=ns.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=`{
3159
3192
  }
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
3193
+ `,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={...Wf},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={...qf},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=()=>wd(this),this.themeMedia=null,this.themeMediaHandler=null,this.topbarObserver=null}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),ig(this)}firstUpdated(){ag(this)}disconnectedCallback(){og(this),super.disconnectedCallback()}updated(e){rg(this,e)}connect(){Ar(this)}handleChatScroll(e){Ql(this,e)}handleLogsScroll(e){Zl(this,e)}exportLogs(e,t){Xl(e,t)}resetToolStream(){cn(this)}resetChatScroll(){Jl(this)}async loadAssistantIdentity(){await kr(this)}applySettings(e){ke(this,e)}setTab(e){hd(this,e)}setTheme(e,t){fd(this,e,t)}async loadOverview(){await Bo(this)}async loadCron(){await Zs(this)}async handleAbortChat(){await Uo(this)}removeQueuedMessage(e){Sd(this,e)}async handleSendChat(e,t){await _d(this,e,t)}async handleWhatsAppStart(e){await lg(this,e)}async handleWhatsAppWait(){await cg(this)}async handleWhatsAppLogout(){await dg(this)}async handleChannelConfigSave(){await ug(this)}async handleChannelConfigReload(){await pg(this)}handleNostrProfileEdit(e,t){fg(this,e,t)}handleNostrProfileCancel(){gg(this)}handleNostrProfileFieldChange(e,t){vg(this,e,t)}async handleNostrProfileSave(){await yg(this)}async handleNostrProfileImport(){await bg(this)}handleNostrProfileToggleAdvanced(){mg(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 jf(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([no("poolbot-app")],m);
3194
+ //# sourceMappingURL=index-HRr1grwl.js.map