skimpyclaw 0.3.14 → 0.4.0

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 (222) hide show
  1. package/README.md +47 -37
  2. package/dist/__tests__/adapter-types.test.d.ts +4 -0
  3. package/dist/__tests__/adapter-types.test.js +63 -0
  4. package/dist/__tests__/anthropic-adapter.test.d.ts +4 -0
  5. package/dist/__tests__/anthropic-adapter.test.js +264 -0
  6. package/dist/__tests__/api.test.js +0 -1
  7. package/dist/__tests__/cli.integration.test.js +2 -4
  8. package/dist/__tests__/cli.test.js +0 -1
  9. package/dist/__tests__/code-agents-notifications.test.js +137 -0
  10. package/dist/__tests__/code-agents-parser.test.js +19 -1
  11. package/dist/__tests__/code-agents-preflight.test.js +3 -28
  12. package/dist/__tests__/code-agents-utils.test.js +34 -9
  13. package/dist/__tests__/code-agents-worktrees.test.js +116 -0
  14. package/dist/__tests__/codex-adapter.test.js +184 -0
  15. package/dist/__tests__/codex-auth.test.js +66 -0
  16. package/dist/__tests__/codex-provider-gating.test.js +35 -0
  17. package/dist/__tests__/codex-unified-loop.test.js +111 -0
  18. package/dist/__tests__/config-security.test.js +127 -0
  19. package/dist/__tests__/config.test.js +23 -0
  20. package/dist/__tests__/context-manager.test.js +243 -164
  21. package/dist/__tests__/cron-run.test.js +250 -0
  22. package/dist/__tests__/cron.test.js +12 -38
  23. package/dist/__tests__/digests.test.js +67 -0
  24. package/dist/__tests__/discord-attachments.test.js +211 -0
  25. package/dist/__tests__/discord-docs.test.d.ts +1 -0
  26. package/dist/__tests__/discord-docs.test.js +27 -0
  27. package/dist/__tests__/discord-thread-agents.test.d.ts +1 -0
  28. package/dist/__tests__/discord-thread-agents.test.js +115 -0
  29. package/dist/__tests__/discord-thread-context.test.d.ts +1 -0
  30. package/dist/__tests__/discord-thread-context.test.js +42 -0
  31. package/dist/__tests__/doctor.formatters.test.js +4 -4
  32. package/dist/__tests__/doctor.index.test.js +1 -1
  33. package/dist/__tests__/doctor.runner.test.js +3 -15
  34. package/dist/__tests__/env-sanitizer.test.d.ts +1 -0
  35. package/dist/__tests__/env-sanitizer.test.js +45 -0
  36. package/dist/__tests__/exec-approval.test.js +61 -0
  37. package/dist/__tests__/fetch-tool.test.d.ts +1 -0
  38. package/dist/__tests__/fetch-tool.test.js +85 -0
  39. package/dist/__tests__/gateway-status-auth.test.d.ts +1 -0
  40. package/dist/__tests__/gateway-status-auth.test.js +72 -0
  41. package/dist/__tests__/heartbeat.test.js +3 -3
  42. package/dist/__tests__/interactive-sessions.test.d.ts +1 -0
  43. package/dist/__tests__/interactive-sessions.test.js +96 -0
  44. package/dist/__tests__/langfuse.test.js +6 -18
  45. package/dist/__tests__/model-selection.test.js +3 -4
  46. package/dist/__tests__/providers-init.test.js +2 -8
  47. package/dist/__tests__/providers-routing.test.js +1 -1
  48. package/dist/__tests__/providers-utils.test.js +13 -3
  49. package/dist/__tests__/sessions.test.js +14 -10
  50. package/dist/__tests__/setup.test.js +12 -29
  51. package/dist/__tests__/skills.test.js +10 -7
  52. package/dist/__tests__/stream-formatter.test.d.ts +1 -0
  53. package/dist/__tests__/stream-formatter.test.js +114 -0
  54. package/dist/__tests__/token-efficiency.test.js +131 -15
  55. package/dist/__tests__/tool-loop.test.d.ts +4 -0
  56. package/dist/__tests__/tool-loop.test.js +505 -0
  57. package/dist/__tests__/tools.test.js +101 -276
  58. package/dist/__tests__/utils.test.d.ts +1 -0
  59. package/dist/__tests__/utils.test.js +14 -0
  60. package/dist/__tests__/voice.test.js +21 -0
  61. package/dist/agent.js +35 -4
  62. package/dist/api.js +113 -37
  63. package/dist/channels/discord/attachments.d.ts +50 -0
  64. package/dist/channels/discord/attachments.js +137 -0
  65. package/dist/channels/discord/delegation.d.ts +5 -0
  66. package/dist/channels/discord/delegation.js +136 -0
  67. package/dist/channels/discord/handlers.js +694 -7
  68. package/dist/channels/discord/index.d.ts +16 -1
  69. package/dist/channels/discord/index.js +64 -1
  70. package/dist/channels/discord/thread-agents.d.ts +54 -0
  71. package/dist/channels/discord/thread-agents.js +323 -0
  72. package/dist/channels/discord/threads.d.ts +58 -0
  73. package/dist/channels/discord/threads.js +192 -0
  74. package/dist/channels/discord/types.js +4 -2
  75. package/dist/channels/discord/utils.d.ts +16 -0
  76. package/dist/channels/discord/utils.js +86 -6
  77. package/dist/channels/telegram/index.d.ts +1 -1
  78. package/dist/channels/telegram/types.js +1 -1
  79. package/dist/channels/telegram/utils.js +9 -3
  80. package/dist/channels.d.ts +1 -1
  81. package/dist/cli.js +20 -400
  82. package/dist/code-agents/executor.d.ts +1 -1
  83. package/dist/code-agents/executor.js +101 -45
  84. package/dist/code-agents/index.d.ts +2 -7
  85. package/dist/code-agents/index.js +111 -80
  86. package/dist/code-agents/interactive-resume.d.ts +6 -0
  87. package/dist/code-agents/interactive-resume.js +98 -0
  88. package/dist/code-agents/interactive-sessions.d.ts +20 -0
  89. package/dist/code-agents/interactive-sessions.js +132 -0
  90. package/dist/code-agents/parser.js +5 -1
  91. package/dist/code-agents/registry.d.ts +7 -1
  92. package/dist/code-agents/registry.js +11 -23
  93. package/dist/code-agents/stream-formatter.d.ts +8 -0
  94. package/dist/code-agents/stream-formatter.js +92 -0
  95. package/dist/code-agents/types.d.ts +16 -24
  96. package/dist/code-agents/utils.d.ts +35 -11
  97. package/dist/code-agents/utils.js +349 -95
  98. package/dist/code-agents/worktrees.d.ts +37 -0
  99. package/dist/code-agents/worktrees.js +116 -0
  100. package/dist/config.d.ts +2 -4
  101. package/dist/config.js +123 -23
  102. package/dist/cron.d.ts +1 -6
  103. package/dist/cron.js +175 -82
  104. package/dist/dashboard/assets/index-B345aOO-.js +65 -0
  105. package/dist/dashboard/assets/index-ZWK4dalJ.css +1 -0
  106. package/dist/dashboard/index.html +2 -2
  107. package/dist/digests.d.ts +1 -0
  108. package/dist/digests.js +132 -42
  109. package/dist/doctor/checks.d.ts +0 -3
  110. package/dist/doctor/checks.js +1 -108
  111. package/dist/doctor/runner.js +1 -4
  112. package/dist/env-sanitizer.d.ts +2 -0
  113. package/dist/env-sanitizer.js +61 -0
  114. package/dist/exec-approval.d.ts +11 -1
  115. package/dist/exec-approval.js +17 -4
  116. package/dist/gateway.d.ts +3 -1
  117. package/dist/gateway.js +17 -7
  118. package/dist/heartbeat.js +1 -6
  119. package/dist/langfuse.js +3 -29
  120. package/dist/model-selection.js +3 -1
  121. package/dist/providers/adapter.d.ts +118 -0
  122. package/dist/providers/adapter.js +6 -0
  123. package/dist/providers/adapters/anthropic-adapter.d.ts +22 -0
  124. package/dist/providers/adapters/anthropic-adapter.js +204 -0
  125. package/dist/providers/adapters/codex-adapter.d.ts +26 -0
  126. package/dist/providers/adapters/codex-adapter.js +203 -0
  127. package/dist/providers/anthropic.d.ts +1 -0
  128. package/dist/providers/anthropic.js +10 -272
  129. package/dist/providers/codex.d.ts +21 -0
  130. package/dist/providers/codex.js +149 -330
  131. package/dist/providers/content.d.ts +1 -1
  132. package/dist/providers/content.js +2 -2
  133. package/dist/providers/context-manager.d.ts +18 -6
  134. package/dist/providers/context-manager.js +199 -223
  135. package/dist/providers/index.d.ts +9 -1
  136. package/dist/providers/index.js +73 -64
  137. package/dist/providers/loop-utils.d.ts +20 -0
  138. package/dist/providers/loop-utils.js +30 -0
  139. package/dist/providers/tool-loop.d.ts +12 -0
  140. package/dist/providers/tool-loop.js +251 -0
  141. package/dist/providers/utils.d.ts +19 -3
  142. package/dist/providers/utils.js +100 -29
  143. package/dist/secure-store.d.ts +8 -0
  144. package/dist/secure-store.js +80 -0
  145. package/dist/service.js +3 -28
  146. package/dist/sessions.d.ts +3 -0
  147. package/dist/sessions.js +147 -18
  148. package/dist/setup-templates.js +13 -25
  149. package/dist/setup.d.ts +10 -6
  150. package/dist/setup.js +84 -292
  151. package/dist/skills.js +3 -11
  152. package/dist/tools/agent-delegation.d.ts +19 -0
  153. package/dist/tools/agent-delegation.js +49 -0
  154. package/dist/tools/bash-tool.js +89 -34
  155. package/dist/tools/definitions.d.ts +199 -302
  156. package/dist/tools/definitions.js +70 -123
  157. package/dist/tools/execute-context.d.ts +13 -4
  158. package/dist/tools/fetch-tool.js +109 -13
  159. package/dist/tools/file-tools.js +7 -1
  160. package/dist/tools.d.ts +7 -7
  161. package/dist/tools.js +133 -151
  162. package/dist/types.d.ts +37 -30
  163. package/dist/utils.js +4 -6
  164. package/dist/voice.d.ts +1 -1
  165. package/dist/voice.js +17 -4
  166. package/package.json +33 -23
  167. package/templates/TOOLS.md +0 -27
  168. package/dist/__tests__/audit.test.js +0 -122
  169. package/dist/__tests__/code-agents-orchestrator.test.js +0 -216
  170. package/dist/__tests__/code-agents-sandbox.test.js +0 -163
  171. package/dist/__tests__/orchestrator.test.js +0 -425
  172. package/dist/__tests__/sandbox-bridge.test.js +0 -116
  173. package/dist/__tests__/sandbox-manager.test.js +0 -144
  174. package/dist/__tests__/sandbox-mount-security.test.js +0 -139
  175. package/dist/__tests__/sandbox-runtime.test.js +0 -176
  176. package/dist/__tests__/subagent.test.js +0 -240
  177. package/dist/__tests__/telegram.test.js +0 -42
  178. package/dist/code-agents/orchestrator.d.ts +0 -29
  179. package/dist/code-agents/orchestrator.js +0 -694
  180. package/dist/code-agents/worktree.d.ts +0 -40
  181. package/dist/code-agents/worktree.js +0 -215
  182. package/dist/dashboard/assets/index-BoTHPby4.js +0 -65
  183. package/dist/dashboard/assets/index-D4mufvBg.css +0 -1
  184. package/dist/dashboard.d.ts +0 -8
  185. package/dist/dashboard.js +0 -4071
  186. package/dist/discord.d.ts +0 -8
  187. package/dist/discord.js +0 -792
  188. package/dist/mcp-context-a8c.d.ts +0 -13
  189. package/dist/mcp-context-a8c.js +0 -34
  190. package/dist/orchestrator.d.ts +0 -15
  191. package/dist/orchestrator.js +0 -676
  192. package/dist/providers/openai.d.ts +0 -10
  193. package/dist/providers/openai.js +0 -355
  194. package/dist/sandbox/bridge.d.ts +0 -5
  195. package/dist/sandbox/bridge.js +0 -63
  196. package/dist/sandbox/index.d.ts +0 -5
  197. package/dist/sandbox/index.js +0 -4
  198. package/dist/sandbox/manager.d.ts +0 -7
  199. package/dist/sandbox/manager.js +0 -100
  200. package/dist/sandbox/mount-security.d.ts +0 -12
  201. package/dist/sandbox/mount-security.js +0 -122
  202. package/dist/sandbox/runtime.d.ts +0 -39
  203. package/dist/sandbox/runtime.js +0 -192
  204. package/dist/sandbox-utils.d.ts +0 -6
  205. package/dist/sandbox-utils.js +0 -36
  206. package/dist/subagent.d.ts +0 -19
  207. package/dist/subagent.js +0 -407
  208. package/dist/telegram.d.ts +0 -2
  209. package/dist/telegram.js +0 -11
  210. package/dist/tools/browser-tool.d.ts +0 -3
  211. package/dist/tools/browser-tool.js +0 -266
  212. package/sandbox/Dockerfile +0 -40
  213. /package/dist/__tests__/{audit.test.d.ts → code-agents-notifications.test.d.ts} +0 -0
  214. /package/dist/__tests__/{code-agents-orchestrator.test.d.ts → code-agents-worktrees.test.d.ts} +0 -0
  215. /package/dist/__tests__/{code-agents-sandbox.test.d.ts → codex-adapter.test.d.ts} +0 -0
  216. /package/dist/__tests__/{orchestrator.test.d.ts → codex-auth.test.d.ts} +0 -0
  217. /package/dist/__tests__/{sandbox-bridge.test.d.ts → codex-provider-gating.test.d.ts} +0 -0
  218. /package/dist/__tests__/{sandbox-manager.test.d.ts → codex-unified-loop.test.d.ts} +0 -0
  219. /package/dist/__tests__/{sandbox-mount-security.test.d.ts → config-security.test.d.ts} +0 -0
  220. /package/dist/__tests__/{sandbox-runtime.test.d.ts → cron-run.test.d.ts} +0 -0
  221. /package/dist/__tests__/{subagent.test.d.ts → digests.test.d.ts} +0 -0
  222. /package/dist/__tests__/{telegram.test.d.ts → discord-attachments.test.d.ts} +0 -0
@@ -0,0 +1,65 @@
1
+ var Ga=Object.defineProperty;var Va=(e,t,r)=>t in e?Ga(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var q=(e,t,r)=>Va(e,typeof t!="symbol"?t+"":t,r);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const o of l.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function r(a){const l={};return a.integrity&&(l.integrity=a.integrity),a.referrerPolicy&&(l.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?l.credentials="include":a.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function i(a){if(a.ep)return;a.ep=!0;const l=r(a);fetch(a.href,l)}})();var wt,O,Ni,ze,Dr,Oi,zi,Ui,Vn,En,Ln,Bi,jt={},Wt=[],Za=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,St=Array.isArray;function xe(e,t){for(var r in t)e[r]=t[r];return e}function Zn(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Ee(e,t,r){var i,a,l,o={};for(l in t)l=="key"?i=t[l]:l=="ref"?a=t[l]:o[l]=t[l];if(arguments.length>2&&(o.children=arguments.length>3?wt.call(arguments,2):r),typeof e=="function"&&e.defaultProps!=null)for(l in e.defaultProps)o[l]===void 0&&(o[l]=e.defaultProps[l]);return xt(e,o,i,a,null)}function xt(e,t,r,i,a){var l={type:e,props:t,key:r,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:a??++Ni,__i:-1,__u:0};return a==null&&O.vnode!=null&&O.vnode(l),l}function Ka(){return{current:null}}function te(e){return e.children}function we(e,t){this.props=e,this.context=t}function et(e,t){if(t==null)return e.__?et(e.__,e.__i+1):null;for(var r;t<e.__k.length;t++)if((r=e.__k[t])!=null&&r.__e!=null)return r.__e;return typeof e.type=="function"?et(e):null}function Ja(e){if(e.__P&&e.__d){var t=e.__v,r=t.__e,i=[],a=[],l=xe({},t);l.__v=t.__v+1,O.vnode&&O.vnode(l),Kn(e.__P,l,t,e.__n,e.__P.namespaceURI,32&t.__u?[r]:null,i,r??et(t),!!(32&t.__u),a),l.__v=t.__v,l.__.__k[l.__i]=l,Wi(i,l,a),t.__e=t.__=null,l.__e!=r&&Fi(l)}}function Fi(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),Fi(e)}function $n(e){(!e.__d&&(e.__d=!0)&&ze.push(e)&&!qt.__r++||Dr!=O.debounceRendering)&&((Dr=O.debounceRendering)||Oi)(qt)}function qt(){for(var e,t=1;ze.length;)ze.length>t&&ze.sort(zi),e=ze.shift(),t=ze.length,Ja(e);qt.__r=0}function Hi(e,t,r,i,a,l,o,s,d,c,m){var p,v,g,u,b,S,k,h=i&&i.__k||Wt,_=t.length;for(d=Ya(r,t,h,d,_),p=0;p<_;p++)(g=r.__k[p])!=null&&(v=g.__i!=-1&&h[g.__i]||jt,g.__i=p,S=Kn(e,g,v,a,l,o,s,d,c,m),u=g.__e,g.ref&&v.ref!=g.ref&&(v.ref&&Jn(v.ref,null,g),m.push(g.ref,g.__c||u,g)),b==null&&u!=null&&(b=u),(k=!!(4&g.__u))||v.__k===g.__k?d=ji(g,d,e,k):typeof g.type=="function"&&S!==void 0?d=S:u&&(d=u.nextSibling),g.__u&=-7);return r.__e=b,d}function Ya(e,t,r,i,a){var l,o,s,d,c,m=r.length,p=m,v=0;for(e.__k=new Array(a),l=0;l<a;l++)(o=t[l])!=null&&typeof o!="boolean"&&typeof o!="function"?(typeof o=="string"||typeof o=="number"||typeof o=="bigint"||o.constructor==String?o=e.__k[l]=xt(null,o,null,null,null):St(o)?o=e.__k[l]=xt(te,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[l]=xt(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[l]=o,d=l+v,o.__=e,o.__b=e.__b+1,s=null,(c=o.__i=Xa(o,r,d,p))!=-1&&(p--,(s=r[c])&&(s.__u|=2)),s==null||s.__v==null?(c==-1&&(a>m?v--:a<m&&v++),typeof o.type!="function"&&(o.__u|=4)):c!=d&&(c==d-1?v--:c==d+1?v++:(c>d?v--:v++,o.__u|=4))):e.__k[l]=null;if(p)for(l=0;l<m;l++)(s=r[l])!=null&&!(2&s.__u)&&(s.__e==i&&(i=et(s)),Gi(s,s));return i}function ji(e,t,r,i){var a,l;if(typeof e.type=="function"){for(a=e.__k,l=0;a&&l<a.length;l++)a[l]&&(a[l].__=e,t=ji(a[l],t,r,i));return t}e.__e!=t&&(i&&(t&&e.type&&!t.parentNode&&(t=et(e)),r.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Ae(e,t){return t=t||[],e==null||typeof e=="boolean"||(St(e)?e.some(function(r){Ae(r,t)}):t.push(e)),t}function Xa(e,t,r,i){var a,l,o,s=e.key,d=e.type,c=t[r],m=c!=null&&(2&c.__u)==0;if(c===null&&s==null||m&&s==c.key&&d==c.type)return r;if(i>(m?1:0)){for(a=r-1,l=r+1;a>=0||l<t.length;)if((c=t[o=a>=0?a--:l++])!=null&&!(2&c.__u)&&s==c.key&&d==c.type)return o}return-1}function Pr(e,t,r){t[0]=="-"?e.setProperty(t,r??""):e[t]=r==null?"":typeof r!="number"||Za.test(t)?r:r+"px"}function Dt(e,t,r,i,a){var l,o;e:if(t=="style")if(typeof r=="string")e.style.cssText=r;else{if(typeof i=="string"&&(e.style.cssText=i=""),i)for(t in i)r&&t in r||Pr(e.style,t,"");if(r)for(t in r)i&&r[t]==i[t]||Pr(e.style,t,r[t])}else if(t[0]=="o"&&t[1]=="n")l=t!=(t=t.replace(Ui,"$1")),o=t.toLowerCase(),t=o in e||t=="onFocusOut"||t=="onFocusIn"?o.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+l]=r,r?i?r.u=i.u:(r.u=Vn,e.addEventListener(t,l?Ln:En,l)):e.removeEventListener(t,l?Ln:En,l);else{if(a=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=r??"";break e}catch{}typeof r=="function"||(r==null||r===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&r==1?"":r))}}function Nr(e){return function(t){if(this.l){var r=this.l[t.type+e];if(t.t==null)t.t=Vn++;else if(t.t<r.u)return;return r(O.event?O.event(t):t)}}}function Kn(e,t,r,i,a,l,o,s,d,c){var m,p,v,g,u,b,S,k,h,_,E,M,P,T,C,x=t.type;if(t.constructor!==void 0)return null;128&r.__u&&(d=!!(32&r.__u),l=[s=t.__e=r.__e]),(m=O.__b)&&m(t);e:if(typeof x=="function")try{if(k=t.props,h="prototype"in x&&x.prototype.render,_=(m=x.contextType)&&i[m.__c],E=m?_?_.props.value:m.__:i,r.__c?S=(p=t.__c=r.__c).__=p.__E:(h?t.__c=p=new x(k,E):(t.__c=p=new we(k,E),p.constructor=x,p.render=el),_&&_.sub(p),p.state||(p.state={}),p.__n=i,v=p.__d=!0,p.__h=[],p._sb=[]),h&&p.__s==null&&(p.__s=p.state),h&&x.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=xe({},p.__s)),xe(p.__s,x.getDerivedStateFromProps(k,p.__s))),g=p.props,u=p.state,p.__v=t,v)h&&x.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),h&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(h&&x.getDerivedStateFromProps==null&&k!==g&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(k,E),t.__v==r.__v||!p.__e&&p.shouldComponentUpdate!=null&&p.shouldComponentUpdate(k,p.__s,E)===!1){t.__v!=r.__v&&(p.props=k,p.state=p.__s,p.__d=!1),t.__e=r.__e,t.__k=r.__k,t.__k.some(function(y){y&&(y.__=t)}),Wt.push.apply(p.__h,p._sb),p._sb=[],p.__h.length&&o.push(p);break e}p.componentWillUpdate!=null&&p.componentWillUpdate(k,p.__s,E),h&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(g,u,b)})}if(p.context=E,p.props=k,p.__P=e,p.__e=!1,M=O.__r,P=0,h)p.state=p.__s,p.__d=!1,M&&M(t),m=p.render(p.props,p.state,p.context),Wt.push.apply(p.__h,p._sb),p._sb=[];else do p.__d=!1,M&&M(t),m=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++P<25);p.state=p.__s,p.getChildContext!=null&&(i=xe(xe({},i),p.getChildContext())),h&&!v&&p.getSnapshotBeforeUpdate!=null&&(b=p.getSnapshotBeforeUpdate(g,u)),T=m!=null&&m.type===te&&m.key==null?qi(m.props.children):m,s=Hi(e,St(T)?T:[T],t,r,i,a,l,o,s,d,c),p.base=t.__e,t.__u&=-161,p.__h.length&&o.push(p),S&&(p.__E=p.__=null)}catch(y){if(t.__v=null,d||l!=null)if(y.then){for(t.__u|=d?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;l[l.indexOf(s)]=null,t.__e=s}else{for(C=l.length;C--;)Zn(l[C]);Rn(t)}else t.__e=r.__e,t.__k=r.__k,y.then||Rn(t);O.__e(y,t,r)}else l==null&&t.__v==r.__v?(t.__k=r.__k,t.__e=r.__e):s=t.__e=Qa(r.__e,t,r,i,a,l,o,d,c);return(m=O.diffed)&&m(t),128&t.__u?void 0:s}function Rn(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(Rn))}function Wi(e,t,r){for(var i=0;i<r.length;i++)Jn(r[i],r[++i],r[++i]);O.__c&&O.__c(t,e),e.some(function(a){try{e=a.__h,a.__h=[],e.some(function(l){l.call(a)})}catch(l){O.__e(l,a.__v)}})}function qi(e){return typeof e!="object"||e==null||e.__b>0?e:St(e)?e.map(qi):xe({},e)}function Qa(e,t,r,i,a,l,o,s,d){var c,m,p,v,g,u,b,S=r.props||jt,k=t.props,h=t.type;if(h=="svg"?a="http://www.w3.org/2000/svg":h=="math"?a="http://www.w3.org/1998/Math/MathML":a||(a="http://www.w3.org/1999/xhtml"),l!=null){for(c=0;c<l.length;c++)if((g=l[c])&&"setAttribute"in g==!!h&&(h?g.localName==h:g.nodeType==3)){e=g,l[c]=null;break}}if(e==null){if(h==null)return document.createTextNode(k);e=document.createElementNS(a,h,k.is&&k),s&&(O.__m&&O.__m(t,l),s=!1),l=null}if(h==null)S===k||s&&e.data==k||(e.data=k);else{if(l=l&&wt.call(e.childNodes),!s&&l!=null)for(S={},c=0;c<e.attributes.length;c++)S[(g=e.attributes[c]).name]=g.value;for(c in S)g=S[c],c=="dangerouslySetInnerHTML"?p=g:c=="children"||c in k||c=="value"&&"defaultValue"in k||c=="checked"&&"defaultChecked"in k||Dt(e,c,null,g,a);for(c in k)g=k[c],c=="children"?v=g:c=="dangerouslySetInnerHTML"?m=g:c=="value"?u=g:c=="checked"?b=g:s&&typeof g!="function"||S[c]===g||Dt(e,c,g,S[c],a);if(m)s||p&&(m.__html==p.__html||m.__html==e.innerHTML)||(e.innerHTML=m.__html),t.__k=[];else if(p&&(e.innerHTML=""),Hi(t.type=="template"?e.content:e,St(v)?v:[v],t,r,i,h=="foreignObject"?"http://www.w3.org/1999/xhtml":a,l,o,l?l[0]:r.__k&&et(r,0),s,d),l!=null)for(c=l.length;c--;)Zn(l[c]);s||(c="value",h=="progress"&&u==null?e.removeAttribute("value"):u!=null&&(u!==e[c]||h=="progress"&&!u||h=="option"&&u!=S[c])&&Dt(e,c,u,S[c],a),c="checked",b!=null&&b!=e[c]&&Dt(e,c,b,S[c],a))}return e}function Jn(e,t,r){try{if(typeof e=="function"){var i=typeof e.__u=="function";i&&e.__u(),i&&t==null||(e.__u=e(t))}else e.current=t}catch(a){O.__e(a,r)}}function Gi(e,t,r){var i,a;if(O.unmount&&O.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||Jn(i,null,t)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(l){O.__e(l,t)}i.base=i.__P=null}if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&Gi(i[a],t,r||typeof e.type!="function");r||Zn(e.__e),e.__c=e.__=e.__e=void 0}function el(e,t,r){return this.constructor(e,r)}function tt(e,t,r){var i,a,l,o;t==document&&(t=document.documentElement),O.__&&O.__(e,t),a=(i=typeof r=="function")?null:r&&r.__k||t.__k,l=[],o=[],Kn(t,e=(!i&&r||t).__k=Ee(te,null,[e]),a||jt,jt,t.namespaceURI,!i&&r?[r]:a?null:t.firstChild?wt.call(t.childNodes):null,l,!i&&r?r:a?a.__e:t.firstChild,i,o),Wi(l,e,o)}function Vi(e,t){tt(e,t,Vi)}function tl(e,t,r){var i,a,l,o,s=xe({},e.props);for(l in e.type&&e.type.defaultProps&&(o=e.type.defaultProps),t)l=="key"?i=t[l]:l=="ref"?a=t[l]:s[l]=t[l]===void 0&&o!=null?o[l]:t[l];return arguments.length>2&&(s.children=arguments.length>3?wt.call(arguments,2):r),xt(e.type,s,i||e.key,a||e.ref,null)}function nl(e){function t(r){var i,a;return this.getChildContext||(i=new Set,(a={})[t.__c]=this,this.getChildContext=function(){return a},this.componentWillUnmount=function(){i=null},this.shouldComponentUpdate=function(l){this.props.value!=l.value&&i.forEach(function(o){o.__e=!0,$n(o)})},this.sub=function(l){i.add(l);var o=l.componentWillUnmount;l.componentWillUnmount=function(){i&&i.delete(l),o&&o.call(l)}}),r.children}return t.__c="__cC"+Bi++,t.__=e,t.Provider=t.__l=(t.Consumer=function(r,i){return r.children(i)}).contextType=t,t}wt=Wt.slice,O={__e:function(e,t,r,i){for(var a,l,o;t=t.__;)if((a=t.__c)&&!a.__)try{if((l=a.constructor)&&l.getDerivedStateFromError!=null&&(a.setState(l.getDerivedStateFromError(e)),o=a.__d),a.componentDidCatch!=null&&(a.componentDidCatch(e,i||{}),o=a.__d),o)return a.__E=a}catch(s){e=s}throw e}},Ni=0,we.prototype.setState=function(e,t){var r;r=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=xe({},this.state),typeof e=="function"&&(e=e(xe({},r),this.props)),e&&xe(r,e),e!=null&&this.__v&&(t&&this._sb.push(t),$n(this))},we.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),$n(this))},we.prototype.render=te,ze=[],Oi=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,zi=function(e,t){return e.__v.__b-t.__v.__b},qt.__r=0,Ui=/(PointerCapture)$|Capture$/i,Vn=0,En=Nr(!1),Ln=Nr(!0),Bi=0;var rl=0;function n(e,t,r,i,a,l){t||(t={});var o,s,d=t;if("ref"in d)for(s in d={},t)s=="ref"?o=t[s]:d[s]=t[s];var c={type:e,props:d,key:r,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--rl,__i:-1,__u:0,__source:a,__self:l};if(typeof e=="function"&&(o=e.defaultProps))for(s in o)d[s]===void 0&&(d[s]=o[s]);return O.vnode&&O.vnode(c),c}var Me,V,gn,Or,nt=0,Zi=[],Y=O,zr=Y.__b,Ur=Y.__r,Br=Y.diffed,Fr=Y.__c,Hr=Y.unmount,jr=Y.__;function at(e,t){Y.__h&&Y.__h(V,e,nt||t),nt=0;var r=V.__H||(V.__H={__:[],__h:[]});return e>=r.__.length&&r.__.push({}),r.__[e]}function w(e){return nt=1,Yn(Qi,e)}function Yn(e,t,r){var i=at(Me++,2);if(i.t=e,!i.__c&&(i.__=[r?r(t):Qi(void 0,t),function(s){var d=i.__N?i.__N[0]:i.__[0],c=i.t(d,s);d!==c&&(i.__N=[c,i.__[1]],i.__c.setState({}))}],i.__c=V,!V.__f)){var a=function(s,d,c){if(!i.__c.__H)return!0;var m=i.__c.__H.__.filter(function(v){return v.__c});if(m.every(function(v){return!v.__N}))return!l||l.call(this,s,d,c);var p=i.__c.props!==s;return m.some(function(v){if(v.__N){var g=v.__[0];v.__=v.__N,v.__N=void 0,g!==v.__[0]&&(p=!0)}}),l&&l.call(this,s,d,c)||p};V.__f=!0;var l=V.shouldComponentUpdate,o=V.componentWillUpdate;V.componentWillUpdate=function(s,d,c){if(this.__e){var m=l;l=void 0,a(s,d,c),l=m}o&&o.call(this,s,d,c)},V.shouldComponentUpdate=a}return i.__N||i.__}function j(e,t){var r=at(Me++,3);!Y.__s&&Qn(r.__H,t)&&(r.__=e,r.u=t,V.__H.__h.push(r))}function Tt(e,t){var r=at(Me++,4);!Y.__s&&Qn(r.__H,t)&&(r.__=e,r.u=t,V.__h.push(r))}function $e(e){return nt=5,ve(function(){return{current:e}},[])}function Ki(e,t,r){nt=6,Tt(function(){if(typeof e=="function"){var i=e(t());return function(){e(null),i&&typeof i=="function"&&i()}}if(e)return e.current=t(),function(){return e.current=null}},r==null?r:r.concat(e))}function ve(e,t){var r=at(Me++,7);return Qn(r.__H,t)&&(r.__=e(),r.__H=t,r.__h=e),r.__}function Xn(e,t){return nt=8,ve(function(){return e},t)}function Ji(e){var t=V.context[e.__c],r=at(Me++,9);return r.c=e,t?(r.__==null&&(r.__=!0,t.sub(V)),t.props.value):e.__}function Yi(e,t){Y.useDebugValue&&Y.useDebugValue(t?t(e):e)}function Xi(){var e=at(Me++,11);if(!e.__){for(var t=V.__v;t!==null&&!t.__m&&t.__!==null;)t=t.__;var r=t.__m||(t.__m=[0,0]);e.__="P"+r[0]+"-"+r[1]++}return e.__}function il(){for(var e;e=Zi.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Ut),t.__h.some(Mn),t.__h=[]}catch(r){t.__h=[],Y.__e(r,e.__v)}}}Y.__b=function(e){V=null,zr&&zr(e)},Y.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),jr&&jr(e,t)},Y.__r=function(e){Ur&&Ur(e),Me=0;var t=(V=e.__c).__H;t&&(gn===V?(t.__h=[],V.__h=[],t.__.some(function(r){r.__N&&(r.__=r.__N),r.u=r.__N=void 0})):(t.__h.some(Ut),t.__h.some(Mn),t.__h=[],Me=0)),gn=V},Y.diffed=function(e){Br&&Br(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Zi.push(t)!==1&&Or===Y.requestAnimationFrame||((Or=Y.requestAnimationFrame)||al)(il)),t.__H.__.some(function(r){r.u&&(r.__H=r.u),r.u=void 0})),gn=V=null},Y.__c=function(e,t){t.some(function(r){try{r.__h.some(Ut),r.__h=r.__h.filter(function(i){return!i.__||Mn(i)})}catch(i){t.some(function(a){a.__h&&(a.__h=[])}),t=[],Y.__e(i,r.__v)}}),Fr&&Fr(e,t)},Y.unmount=function(e){Hr&&Hr(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.some(function(i){try{Ut(i)}catch(a){t=a}}),r.__H=void 0,t&&Y.__e(t,r.__v))};var Wr=typeof requestAnimationFrame=="function";function al(e){var t,r=function(){clearTimeout(i),Wr&&cancelAnimationFrame(t),setTimeout(e)},i=setTimeout(r,35);Wr&&(t=requestAnimationFrame(r))}function Ut(e){var t=V,r=e.__c;typeof r=="function"&&(e.__c=void 0,r()),V=t}function Mn(e){var t=V;e.__c=e.__(),V=t}function Qn(e,t){return!e||e.length!==t.length||t.some(function(r,i){return r!==e[i]})}function Qi(e,t){return typeof t=="function"?t(e):t}function ea(e,t){for(var r in t)e[r]=t[r];return e}function In(e,t){for(var r in e)if(r!=="__source"&&!(r in t))return!0;for(var i in t)if(i!=="__source"&&e[i]!==t[i])return!0;return!1}function ta(e,t){var r=t(),i=w({t:{__:r,u:t}}),a=i[0].t,l=i[1];return Tt(function(){a.__=r,a.u=t,mn(a)&&l({t:a})},[e,r,t]),j(function(){return mn(a)&&l({t:a}),e(function(){mn(a)&&l({t:a})})},[e]),r}function mn(e){try{return!((t=e.__)===(r=e.u())&&(t!==0||1/t==1/r)||t!=t&&r!=r)}catch{return!0}var t,r}function na(e){e()}function ra(e){return e}function ia(){return[!1,na]}var aa=Tt;function Dn(e,t){this.props=e,this.context=t}function ll(e,t){function r(a){var l=this.props.ref,o=l==a.ref;return!o&&l&&(l.call?l(null):l.current=null),t?!t(this.props,a)||!o:In(this.props,a)}function i(a){return this.shouldComponentUpdate=r,Ee(e,a)}return i.displayName="Memo("+(e.displayName||e.name)+")",i.prototype.isReactComponent=!0,i.__f=!0,i.type=e,i}(Dn.prototype=new we).isPureReactComponent=!0,Dn.prototype.shouldComponentUpdate=function(e,t){return In(this.props,e)||In(this.state,t)};var qr=O.__b;O.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),qr&&qr(e)};var sl=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function ol(e){function t(r){var i=ea({},r);return delete i.ref,e(i,r.ref||null)}return t.$$typeof=sl,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(e.displayName||e.name)+")",t}var Gr=function(e,t){return e==null?null:Ae(Ae(e).map(t))},cl={map:Gr,forEach:Gr,count:function(e){return e?Ae(e).length:0},only:function(e){var t=Ae(e);if(t.length!==1)throw"Children.only";return t[0]},toArray:Ae},dl=O.__e;O.__e=function(e,t,r,i){if(e.then){for(var a,l=t;l=l.__;)if((a=l.__c)&&a.__c)return t.__e==null&&(t.__e=r.__e,t.__k=r.__k),a.__c(e,t)}dl(e,t,r,i)};var Vr=O.unmount;function la(e,t,r){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(i){typeof i.__c=="function"&&i.__c()}),e.__c.__H=null),(e=ea({},e)).__c!=null&&(e.__c.__P===r&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(i){return la(i,t,r)})),e}function sa(e,t,r){return e&&r&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(i){return sa(i,t,r)}),e.__c&&e.__c.__P===t&&(e.__e&&r.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=r)),e}function Bt(){this.__u=0,this.o=null,this.__b=null}function oa(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function ul(e){var t,r,i,a=null;function l(o){if(t||(t=e()).then(function(s){s&&(a=s.default||s),i=!0},function(s){r=s,i=!0}),r)throw r;if(!i)throw t;return a?Ee(a,o):null}return l.displayName="Lazy",l.__f=!0,l}function yt(){this.i=null,this.l=null}O.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Vr&&Vr(e)},(Bt.prototype=new we).__c=function(e,t){var r=t.__c,i=this;i.o==null&&(i.o=[]),i.o.push(r);var a=oa(i.__v),l=!1,o=function(){l||i.__z||(l=!0,r.__R=null,a?a(d):d())};r.__R=o;var s=r.__P;r.__P=null;var d=function(){if(!--i.__u){if(i.state.__a){var c=i.state.__a;i.__v.__k[0]=sa(c,c.__c.__P,c.__c.__O)}var m;for(i.setState({__a:i.__b=null});m=i.o.pop();)m.__P=s,m.forceUpdate()}};i.__u++||32&t.__u||i.setState({__a:i.__b=i.__v.__k[0]}),e.then(o,o)},Bt.prototype.componentWillUnmount=function(){this.o=[]},Bt.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var r=document.createElement("div"),i=this.__v.__k[0].__c;this.__v.__k[0]=la(this.__b,r,i.__O=i.__P)}this.__b=null}var a=t.__a&&Ee(te,null,e.fallback);return a&&(a.__u&=-33),[Ee(te,null,t.__a?null:e.children),a]};var Zr=function(e,t,r){if(++r[1]===r[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!=="t"||!e.l.size))for(r=e.i;r;){for(;r.length>3;)r.pop()();if(r[1]<r[0])break;e.i=r=r[2]}};function hl(e){return this.getChildContext=function(){return e.context},e.children}function pl(e){var t=this,r=e.h;if(t.componentWillUnmount=function(){tt(null,t.v),t.v=null,t.h=null},t.h&&t.h!==r&&t.componentWillUnmount(),!t.v){for(var i=t.__v;i!==null&&!i.__m&&i.__!==null;)i=i.__;t.h=r,t.v={nodeType:1,parentNode:r,childNodes:[],__k:{__m:i.__m},contains:function(){return!0},namespaceURI:r.namespaceURI,insertBefore:function(a,l){this.childNodes.push(a),t.h.insertBefore(a,l)},removeChild:function(a){this.childNodes.splice(this.childNodes.indexOf(a)>>>1,1),t.h.removeChild(a)}}}tt(Ee(hl,{context:t.context},e.__v),t.v)}function fl(e,t){var r=Ee(pl,{__v:e,h:t});return r.containerInfo=t,r}(yt.prototype=new we).__a=function(e){var t=this,r=oa(t.__v),i=t.l.get(e);return i[0]++,function(a){var l=function(){t.props.revealOrder?(i.push(a),Zr(t,e,i)):a()};r?r(l):l()}},yt.prototype.render=function(e){this.i=null,this.l=new Map;var t=Ae(e.children);e.revealOrder&&e.revealOrder[0]==="b"&&t.reverse();for(var r=t.length;r--;)this.l.set(t[r],this.i=[1,0,this.i]);return e.children},yt.prototype.componentDidUpdate=yt.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,r){Zr(e,r,t)})};var ca=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,gl=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,ml=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,vl=/[A-Z0-9]/g,_l=typeof document<"u",bl=function(e){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(e)};function yl(e,t,r){return t.__k==null&&(t.textContent=""),tt(e,t),typeof r=="function"&&r(),e?e.__c:null}function kl(e,t,r){return Vi(e,t),typeof r=="function"&&r(),e?e.__c:null}we.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(we.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var Kr=O.event;function xl(){}function wl(){return this.cancelBubble}function Sl(){return this.defaultPrevented}O.event=function(e){return Kr&&(e=Kr(e)),e.persist=xl,e.isPropagationStopped=wl,e.isDefaultPrevented=Sl,e.nativeEvent=e};var er,Tl={enumerable:!1,configurable:!0,get:function(){return this.class}},Jr=O.vnode;O.vnode=function(e){typeof e.type=="string"&&function(t){var r=t.props,i=t.type,a={},l=i.indexOf("-")===-1;for(var o in r){var s=r[o];if(!(o==="value"&&"defaultValue"in r&&s==null||_l&&o==="children"&&i==="noscript"||o==="class"||o==="className")){var d=o.toLowerCase();o==="defaultValue"&&"value"in r&&r.value==null?o="value":o==="download"&&s===!0?s="":d==="translate"&&s==="no"?s=!1:d[0]==="o"&&d[1]==="n"?d==="ondoubleclick"?o="ondblclick":d!=="onchange"||i!=="input"&&i!=="textarea"||bl(r.type)?d==="onfocus"?o="onfocusin":d==="onblur"?o="onfocusout":ml.test(o)&&(o=d):d=o="oninput":l&&gl.test(o)?o=o.replace(vl,"-$&").toLowerCase():s===null&&(s=void 0),d==="oninput"&&a[o=d]&&(o="oninputCapture"),a[o]=s}}i=="select"&&a.multiple&&Array.isArray(a.value)&&(a.value=Ae(r.children).forEach(function(c){c.props.selected=a.value.indexOf(c.props.value)!=-1})),i=="select"&&a.defaultValue!=null&&(a.value=Ae(r.children).forEach(function(c){c.props.selected=a.multiple?a.defaultValue.indexOf(c.props.value)!=-1:a.defaultValue==c.props.value})),r.class&&!r.className?(a.class=r.class,Object.defineProperty(a,"className",Tl)):r.className&&(a.class=a.className=r.className),t.props=a}(e),e.$$typeof=ca,Jr&&Jr(e)};var Yr=O.__r;O.__r=function(e){Yr&&Yr(e),er=e.__c};var Xr=O.diffed;O.diffed=function(e){Xr&&Xr(e);var t=e.props,r=e.__e;r!=null&&e.type==="textarea"&&"value"in t&&t.value!==r.value&&(r.value=t.value==null?"":t.value),er=null};var Cl={ReactCurrentDispatcher:{current:{readContext:function(e){return er.__n[e.__c].props.value},useCallback:Xn,useContext:Ji,useDebugValue:Yi,useDeferredValue:ra,useEffect:j,useId:Xi,useImperativeHandle:Ki,useInsertionEffect:aa,useLayoutEffect:Tt,useMemo:ve,useReducer:Yn,useRef:$e,useState:w,useSyncExternalStore:ta,useTransition:ia}}};function Al(e){return Ee.bind(null,e)}function Xt(e){return!!e&&e.$$typeof===ca}function El(e){return Xt(e)&&e.type===te}function Ll(e){return!!e&&typeof e.displayName=="string"&&e.displayName.startsWith("Memo(")}function $l(e){return Xt(e)?tl.apply(null,arguments):e}function Rl(e){return!!e.__k&&(tt(null,e),!0)}function Ml(e){return e&&(e.base||e.nodeType===1&&e)||null}var Il=function(e,t){return e(t)},Dl=function(e,t){return e(t)},Pl=te,Nl=Xt,Fe={useState:w,useId:Xi,useReducer:Yn,useEffect:j,useLayoutEffect:Tt,useInsertionEffect:aa,useTransition:ia,useDeferredValue:ra,useSyncExternalStore:ta,startTransition:na,useRef:$e,useImperativeHandle:Ki,useMemo:ve,useCallback:Xn,useContext:Ji,useDebugValue:Yi,version:"18.3.1",Children:cl,render:yl,hydrate:kl,unmountComponentAtNode:Rl,createPortal:fl,createElement:Ee,createContext:nl,createFactory:Al,cloneElement:$l,createRef:Ka,Fragment:te,isValidElement:Xt,isElement:Nl,isFragment:El,isMemo:Ll,findDOMNode:Ml,Component:we,PureComponent:Dn,memo:ll,forwardRef:ol,flushSync:Dl,unstable_batchedUpdates:Il,StrictMode:Pl,Suspense:Bt,SuspenseList:yt,lazy:ul,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:Cl},da={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Qr=Fe.createContext&&Fe.createContext(da),Ol=["attr","size","title"];function zl(e,t){if(e==null)return{};var r=Ul(e,t),i,a;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a<l.length;a++)i=l[a],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(r[i]=e[i])}return r}function Ul(e,t){if(e==null)return{};var r={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){if(t.indexOf(i)>=0)continue;r[i]=e[i]}return r}function Gt(){return Gt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},Gt.apply(this,arguments)}function ei(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,i)}return r}function Vt(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?ei(Object(r),!0).forEach(function(i){Bl(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ei(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function Bl(e,t,r){return t=Fl(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Fl(e){var t=Hl(e,"string");return typeof t=="symbol"?t:t+""}function Hl(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function ua(e){return e&&e.map((t,r)=>Fe.createElement(t.tag,Vt({key:r},t.attr),ua(t.child)))}function N(e){return t=>Fe.createElement(jl,Gt({attr:Vt({},e.attr)},t),ua(e.child))}function jl(e){var t=r=>{var{attr:i,size:a,title:l}=e,o=zl(e,Ol),s=a||r.size||"1em",d;return r.className&&(d=r.className),e.className&&(d=(d?d+" ":"")+e.className),Fe.createElement("svg",Gt({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},r.attr,i,o,{className:d,style:Vt(Vt({color:e.color||r.color},r.style),e.style),height:s,width:s,xmlns:"http://www.w3.org/2000/svg"}),l&&Fe.createElement("title",null,l),e.children)};return Qr!==void 0?Fe.createElement(Qr.Consumer,null,r=>t(r)):t(da)}function ti(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M5 12h14"},child:[]},{tag:"path",attr:{d:"m12 5 7 7-7 7"},child:[]}]})(e)}function Wl(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z"},child:[]},{tag:"path",attr:{d:"m9 12 2 2 4-4"},child:[]}]})(e)}function ql(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M12 7v14"},child:[]},{tag:"path",attr:{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z"},child:[]}]})(e)}function Gl(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M12 8V4H8"},child:[]},{tag:"rect",attr:{width:"16",height:"12",x:"4",y:"8",rx:"2"},child:[]},{tag:"path",attr:{d:"M2 14h2"},child:[]},{tag:"path",attr:{d:"M20 14h2"},child:[]},{tag:"path",attr:{d:"M15 13v2"},child:[]},{tag:"path",attr:{d:"M9 13v2"},child:[]}]})(e)}function Re(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M20 6 9 17l-5-5"},child:[]}]})(e)}function Ft(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"m6 9 6 6 6-6"},child:[]}]})(e)}function Vl(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"m15 18-6-6 6-6"},child:[]}]})(e)}function Zl(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"m9 18 6-6-6-6"},child:[]}]})(e)}function ha(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"path",attr:{d:"m9 12 2 2 4-4"},child:[]}]})(e)}function Kl(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"circle",attr:{cx:"12",cy:"12",r:"1"},child:[]}]})(e)}function Jl(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"path",attr:{d:"m15 9-6 6"},child:[]},{tag:"path",attr:{d:"m9 9 6 6"},child:[]}]})(e)}function He(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"polyline",attr:{points:"12 6 12 12 16.5 12"},child:[]}]})(e)}function Yl(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"polyline",attr:{points:"12 6 12 12 16 14"},child:[]}]})(e)}function ni(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"polyline",attr:{points:"12 6 12 12 16 14"},child:[]}]})(e)}function tr(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"16 18 22 12 16 6"},child:[]},{tag:"polyline",attr:{points:"8 6 2 12 8 18"},child:[]}]})(e)}function pa(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{width:"16",height:"16",x:"4",y:"4",rx:"2"},child:[]},{tag:"rect",attr:{width:"6",height:"6",x:"9",y:"9",rx:"1"},child:[]},{tag:"path",attr:{d:"M15 2v2"},child:[]},{tag:"path",attr:{d:"M15 20v2"},child:[]},{tag:"path",attr:{d:"M2 15h2"},child:[]},{tag:"path",attr:{d:"M2 9h2"},child:[]},{tag:"path",attr:{d:"M20 15h2"},child:[]},{tag:"path",attr:{d:"M20 9h2"},child:[]},{tag:"path",attr:{d:"M9 2v2"},child:[]},{tag:"path",attr:{d:"M9 20v2"},child:[]}]})(e)}function Pn(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"ellipse",attr:{cx:"12",cy:"5",rx:"9",ry:"3"},child:[]},{tag:"path",attr:{d:"M3 5V19A9 3 0 0 0 21 19V5"},child:[]},{tag:"path",attr:{d:"M3 12A9 3 0 0 0 21 12"},child:[]}]})(e)}function Be(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"12",x2:"12",y1:"2",y2:"22"},child:[]},{tag:"path",attr:{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"},child:[]}]})(e)}function Xl(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M15 3h6v6"},child:[]},{tag:"path",attr:{d:"M10 14 21 3"},child:[]},{tag:"path",attr:{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"},child:[]}]})(e)}function je(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"},child:[]},{tag:"path",attr:{d:"M14 2v4a2 2 0 0 0 2 2h4"},child:[]},{tag:"path",attr:{d:"M10 9H8"},child:[]},{tag:"path",attr:{d:"M16 13H8"},child:[]},{tag:"path",attr:{d:"M16 17H8"},child:[]}]})(e)}function Ql(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"4",x2:"20",y1:"9",y2:"9"},child:[]},{tag:"line",attr:{x1:"4",x2:"20",y1:"15",y2:"15"},child:[]},{tag:"line",attr:{x1:"10",x2:"8",y1:"3",y2:"21"},child:[]},{tag:"line",attr:{x1:"16",x2:"14",y1:"3",y2:"21"},child:[]}]})(e)}function fa(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z"},child:[]},{tag:"path",attr:{d:"M3.22 12H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27"},child:[]}]})(e)}function es(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"},child:[]},{tag:"path",attr:{d:"M3 3v5h5"},child:[]},{tag:"path",attr:{d:"M12 7v5l4 2"},child:[]}]})(e)}function ts(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{width:"7",height:"9",x:"3",y:"3",rx:"1"},child:[]},{tag:"rect",attr:{width:"7",height:"5",x:"14",y:"3",rx:"1"},child:[]},{tag:"rect",attr:{width:"7",height:"9",x:"14",y:"12",rx:"1"},child:[]},{tag:"rect",attr:{width:"7",height:"5",x:"3",y:"16",rx:"1"},child:[]}]})(e)}function ns(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M13 12h8"},child:[]},{tag:"path",attr:{d:"M13 18h8"},child:[]},{tag:"path",attr:{d:"M13 6h8"},child:[]},{tag:"path",attr:{d:"M3 12h1"},child:[]},{tag:"path",attr:{d:"M3 18h1"},child:[]},{tag:"path",attr:{d:"M3 6h1"},child:[]},{tag:"path",attr:{d:"M8 12h1"},child:[]},{tag:"path",attr:{d:"M8 18h1"},child:[]},{tag:"path",attr:{d:"M8 6h1"},child:[]}]})(e)}function rs(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"4",x2:"20",y1:"12",y2:"12"},child:[]},{tag:"line",attr:{x1:"4",x2:"20",y1:"6",y2:"6"},child:[]},{tag:"line",attr:{x1:"4",x2:"20",y1:"18",y2:"18"},child:[]}]})(e)}function rt(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"},child:[]}]})(e)}function is(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"},child:[]}]})(e)}function as(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M5 12h14"},child:[]},{tag:"path",attr:{d:"M12 5v14"},child:[]}]})(e)}function ue(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"},child:[]},{tag:"path",attr:{d:"M21 3v5h-5"},child:[]},{tag:"path",attr:{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"},child:[]},{tag:"path",attr:{d:"M8 16H3v5"},child:[]}]})(e)}function ls(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"},child:[]},{tag:"path",attr:{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"},child:[]},{tag:"path",attr:{d:"M7 3v4a1 1 0 0 0 1 1h7"},child:[]}]})(e)}function Nn(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"11",cy:"11",r:"8"},child:[]},{tag:"path",attr:{d:"m21 21-4.3-4.3"},child:[]}]})(e)}function ss(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z"},child:[]},{tag:"path",attr:{d:"m21.854 2.147-10.94 10.939"},child:[]}]})(e)}function os(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"},child:[]},{tag:"rect",attr:{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"},child:[]},{tag:"line",attr:{x1:"6",x2:"6.01",y1:"6",y2:"6"},child:[]},{tag:"line",attr:{x1:"6",x2:"6.01",y1:"18",y2:"18"},child:[]}]})(e)}function cs(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M20 7h-9"},child:[]},{tag:"path",attr:{d:"M14 17H5"},child:[]},{tag:"circle",attr:{cx:"17",cy:"17",r:"3"},child:[]},{tag:"circle",attr:{cx:"7",cy:"7",r:"3"},child:[]}]})(e)}function On(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"},child:[]},{tag:"path",attr:{d:"M12 8v4"},child:[]},{tag:"path",attr:{d:"M12 16h.01"},child:[]}]})(e)}function ds(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"4"},child:[]},{tag:"path",attr:{d:"M12 2v2"},child:[]},{tag:"path",attr:{d:"M12 20v2"},child:[]},{tag:"path",attr:{d:"m4.93 4.93 1.41 1.41"},child:[]},{tag:"path",attr:{d:"m17.66 17.66 1.41 1.41"},child:[]},{tag:"path",attr:{d:"M2 12h2"},child:[]},{tag:"path",attr:{d:"M20 12h2"},child:[]},{tag:"path",attr:{d:"m6.34 17.66-1.41 1.41"},child:[]},{tag:"path",attr:{d:"m19.07 4.93-1.41 1.41"},child:[]}]})(e)}function us(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M3 6h18"},child:[]},{tag:"path",attr:{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"},child:[]},{tag:"path",attr:{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"},child:[]},{tag:"line",attr:{x1:"10",x2:"10",y1:"11",y2:"17"},child:[]},{tag:"line",attr:{x1:"14",x2:"14",y1:"11",y2:"17"},child:[]}]})(e)}function ri(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"},child:[]}]})(e)}function hs(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"18",cy:"15",r:"3"},child:[]},{tag:"circle",attr:{cx:"9",cy:"7",r:"4"},child:[]},{tag:"path",attr:{d:"M10 15H6a4 4 0 0 0-4 4v2"},child:[]},{tag:"path",attr:{d:"m21.7 16.4-.9-.3"},child:[]},{tag:"path",attr:{d:"m15.2 13.9-.9-.3"},child:[]},{tag:"path",attr:{d:"m16.6 18.7.3-.9"},child:[]},{tag:"path",attr:{d:"m19.1 12.2.3-.9"},child:[]},{tag:"path",attr:{d:"m19.6 18.7-.4-1"},child:[]},{tag:"path",attr:{d:"m16.8 12.3-.4-1"},child:[]},{tag:"path",attr:{d:"m14.3 16.6 1-.4"},child:[]},{tag:"path",attr:{d:"m20.7 13.8 1-.4"},child:[]}]})(e)}function it(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M18 6 6 18"},child:[]},{tag:"path",attr:{d:"m6 6 12 12"},child:[]}]})(e)}function zn(e){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"},child:[]}]})(e)}function ii(e){return"href"in e}const ai=[{id:"overview",label:"Overview",icon:ts,section:"dashboard"},{id:"history",label:"Messages",icon:rt,section:"dashboard"},{id:"approvals",label:"Approvals",icon:Wl,section:"dashboard"},{id:"digests",label:"Digests",icon:je,section:"dashboard"},{id:"audit",label:"Audit",icon:Nn,section:"dashboard"},{id:"usage",label:"Usage",icon:Be,section:"dashboard"},{id:"coding",label:"Coding Agent",icon:tr,section:"dashboard"},{id:"memory",label:"Memory",icon:Pn,section:"settings"},{id:"templates",label:"Templates",icon:je,section:"settings"},{id:"model",label:"Model",icon:pa,section:"settings"},{id:"agents",label:"Agents",icon:hs,section:"settings"},{id:"skills",label:"Skills",icon:zn,section:"settings"},{id:"cron",label:"Scheduled Jobs",icon:He,section:"settings"},{id:"config",label:"Config",icon:cs,section:"settings"},{id:"logs",label:"Logs",icon:ns,section:"footer"},{id:"health",label:"Health",icon:fa,section:"footer"}],ps=[{id:"dashboard",label:"Dashboard"},{id:"settings",label:"Settings"}];function fs({currentPage:e,onNavigate:t,botName:r,botEmoji:i,pendingApprovals:a,isNarrow:l,onClose:o}){return n("nav",{class:"sidebar",children:[n("div",{class:"sidebar-header",children:[n("div",{class:"sidebar-logo",children:i}),n("div",{class:"sidebar-brand",children:[n("span",{class:"sidebar-brand-name",children:r}),n("span",{class:"sidebar-brand-status",children:"Online"})]}),l&&n("button",{class:"sidebar-close-btn",onClick:o,"aria-label":"Close sidebar",children:n(Vl,{size:16})})]}),ps.map(s=>{const d=ai.filter(c=>c.section===s.id);return n("div",{class:"sidebar-section",children:[n("div",{class:"sidebar-section-label",children:s.label}),d.map(c=>{const m=c.icon;if(ii(c))return n("a",{href:c.href,class:"sidebar-item",children:[n("span",{class:"sidebar-item-icon",children:n(m,{size:16})}),n("span",{class:"sidebar-item-label",children:c.label})]},c.id);const p=c.id==="approvals"&&a?a:void 0;return n("button",{"data-page":c.id,class:`sidebar-item${e===c.id?" active":""}`,onClick:()=>t(c.id),children:[n("span",{class:"sidebar-item-icon",children:n(m,{size:16})}),n("span",{class:"sidebar-item-label",children:c.label}),p?n("span",{class:"item-badge",children:p}):null]},c.id)})]},s.id)}),n("div",{class:"sidebar-spacer"}),n("div",{class:"sidebar-footer",children:[ai.filter(s=>s.section==="footer").map(s=>{const d=s.icon;return ii(s)?n("a",{href:s.href,class:"sidebar-footer-item",children:[n("span",{class:"sidebar-item-icon",children:n(d,{size:16})}),n("span",{class:"sidebar-item-label",children:s.label})]},s.id):n("button",{"data-page":s.id,class:`sidebar-footer-item${e===s.id?" active":""}`,onClick:()=>t(s.id),children:[n("span",{class:"sidebar-item-icon",children:n(d,{size:16})}),n("span",{class:"sidebar-item-label",children:s.label})]},s.id)}),n("a",{class:"sidebar-footer-item",href:"https://docs.skimpyclaw.xyz/guide/",target:"_blank",rel:"noreferrer",title:"Open SkimpyClaw documentation",children:[n("span",{class:"sidebar-item-icon",children:n(ql,{size:16})}),n("span",{class:"sidebar-item-label",children:"Help Docs"})]})]})]})}function gs({toasts:e}){return n("div",{class:"toast-container",children:e.map(t=>n("div",{class:`toast ${t.type}`,children:t.message},t.id))})}function ms(){const[e,t]=w([]),r=Xn((i,a="info",l=3e3)=>{const o=crypto.randomUUID();t(s=>[...s,{id:o,message:i,type:a}]),setTimeout(()=>{t(s=>s.filter(d=>d.id!==o))},l)},[]);return{toasts:e,showToast:r}}const nr="dashboard_token",Un="skimpy-dashboard-unauthorized";function ga(){return localStorage.getItem(nr)??""}function vs(e){localStorage.setItem(nr,e)}function _s(){localStorage.removeItem(nr)}function bs(e){const t=()=>e();return window.addEventListener(Un,t),()=>window.removeEventListener(Un,t)}class ys extends Error{constructor(t,r){super(r),this.status=t,this.name="ApiError"}}async function z(e,t={}){const r=ga(),i={...r?{Authorization:`Bearer ${r}`}:{},...t.headers??{}};t.body&&(i["Content-Type"]="application/json");const a=await fetch(`/api/dashboard/${e}`,{...t,headers:i});if(!a.ok){a.status===401&&(_s(),window.dispatchEvent(new Event(Un)));const l=await a.text().catch(()=>a.statusText);throw new ys(a.status,l)}return a.json()}const ks=()=>z("status"),li=()=>z("health"),si=()=>z("doctor");function ma(e={}){const t=new URLSearchParams;e.limit!==void 0&&t.set("limit",String(e.limit)),e.offset!==void 0&&t.set("offset",String(e.offset)),e.trigger&&t.set("trigger",e.trigger);const r=t.toString();return z(`audit${r?`?${r}`:""}`)}const va=()=>z("approvals"),_a=e=>z(`approvals/${encodeURIComponent(e)}/approve`,{method:"POST"}),ba=e=>z(`approvals/${encodeURIComponent(e)}/deny`,{method:"POST"}),xs=()=>z("cron"),ws=e=>z(`cron/${encodeURIComponent(e)}/run`,{method:"POST"}),Ss=e=>z(`cron/prompt-file?path=${encodeURIComponent(e)}`),Ts=()=>z("model"),Cs=e=>z("model",{method:"POST",body:JSON.stringify({model:e})}),As=()=>z("agent-profiles"),Es=(e,t)=>z("agent-profiles",{method:"POST",body:JSON.stringify({alias:e,agentId:t})}),Ls=(e,t)=>z(`agent-profiles/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)}),$s=e=>z(`agent-profiles/${encodeURIComponent(e)}`,{method:"DELETE"}),Rs=e=>z(`memory/${encodeURIComponent(e)}`),Ms=(e,t)=>z(`memory/${encodeURIComponent(e)}/${encodeURIComponent(t)}`),Is=e=>z(`templates/${encodeURIComponent(e)}`),Ds=(e,t)=>z(`templates/${encodeURIComponent(e)}/${encodeURIComponent(t)}`),Ps=(e,t,r)=>z(`templates/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({content:r})}),Ns=()=>z("logs"),Os=e=>z(e),zs=()=>z("code-agents"),Us=e=>z(`code-agents/${encodeURIComponent(e)}/cancel`,{method:"POST"}),Bs=(e,t)=>z("messages/agent",{method:"POST",body:JSON.stringify({message:e,model:t})}),Fs=e=>{const t=e?`?channel=${encodeURIComponent(e)}`:"";return z(`conversations${t}`)},Hs=(e,t)=>{const r=new URLSearchParams;(t==null?void 0:t.limit)!==void 0&&r.set("limit",String(t.limit)),(t==null?void 0:t.offset)!==void 0&&r.set("offset",String(t.offset));const i=r.toString();return z(`conversations/${encodeURIComponent(e)}${i?`?${i}`:""}`)},rr=()=>z("config"),ya=e=>z("config",{method:"PUT",body:JSON.stringify({config:e})}),js=()=>z("reload",{method:"POST"}),Ws=()=>z("digests"),qs=e=>z(`digests/${encodeURIComponent(e)}`),Gs=()=>z("skills"),Vs=e=>z(`skills/${encodeURIComponent(e)}`),Zs=(e,t)=>z("skills",{method:"POST",body:JSON.stringify({name:e,content:t})}),Ks=(e,t)=>z(`skills/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({enabled:t})}),Js=(e,t)=>z(`skills/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({content:t})}),Ys=e=>z(`skills/${encodeURIComponent(e)}`,{method:"DELETE"}),ir=()=>z("usage");function Xs(e){const t=new URLSearchParams;t.set("limit",String(e.limit)),(e==null?void 0:e.offset)!==void 0&&t.set("offset",String(e.offset)),e!=null&&e.model&&t.set("model",e.model);const r=t.toString();return z(`usage/records${r?`?${r}`:""}`)}function vn(e){const t=Math.floor(e);if(t<60)return`${t}s`;const r=Math.floor(t/60);if(r<60)return`${r}m`;const i=Math.floor(r/60);return i<24?`${i}h ${r%60}m`:`${Math.floor(i/24)}d ${i%24}h`}function Qs(){const e=new Date().getHours();return e<12?"Good morning":e<17?"Good afternoon":"Good evening"}function eo(e){const t=new Date(e),r=Date.now()-t.getTime(),i=Math.floor(r/1e3);if(i<60)return`${i}s ago`;const a=Math.floor(i/60);if(a<60)return`${a}m ago`;const l=Math.floor(a/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`}function to(e){const t=Date.now()-new Date(e).getTime(),r=Math.floor(t/6e4),i=Math.floor(t%6e4/1e3);return`${r}:${i.toString().padStart(2,"0")}`}function oi(e){if(!e)return"N/A";const r=new Date(e).getTime()-Date.now();if(r<0)return"overdue";const i=Math.floor(r/6e4);return i<60?`in ${i}m`:`in ${Math.floor(i/60)}h ${i%60}m`}function no(e){return e?e==="telegram"?"Telegram":e==="discord"?"Discord":e:"—"}function ro(e){const t=e.events.filter(r=>r.type==="tool_use").length;return t>0?`${t} tool call${t>1?"s":""}`:e.events.length>0?e.events[0].summary??"":""}function ci({onNavigate:e,showToast:t}){var h;const[r,i]=w(null),[a,l]=w([]),[o,s]=w([]),[d,c]=w(null),[m,p]=w(new Set),[v,g]=w(!0);j(()=>{u();const _=setInterval(u,1e4);return()=>clearInterval(_)},[]);async function u(){const[_,E,M,P]=await Promise.allSettled([ks(),ma({limit:8,offset:0}),va(),ir()]);_.status==="fulfilled"?i(_.value):console.error("[overview] status load failed",_.reason),E.status==="fulfilled"?l(E.value.traces??[]):console.error("[overview] audit load failed",E.reason),M.status==="fulfilled"?s(M.value.pending??[]):console.error("[overview] approvals load failed",M.reason),P.status==="fulfilled"&&c(P.value),g(!1)}async function b(_,E){p(M=>new Set([...M,_]));try{E?(await _a(_),t==null||t("Command approved","success")):(await ba(_),t==null||t("Command denied","warning")),await u()}catch{t==null||t("Action failed","error")}finally{p(M=>{const P=new Set(M);return P.delete(_),P})}}const S=_=>_==="telegram"?n(ss,{size:14}):_==="cron"?n(He,{size:14}):n(os,{size:14});if(v)return n("div",{style:{display:"flex",justifyContent:"center",padding:"48px"},children:n("div",{class:"spinner"})});const k=r==null?void 0:r.cronJobs.reduce((_,E)=>_!=null&&_.nextRun?E.nextRun?new Date(_.nextRun)<new Date(E.nextRun)?_:E:_:E,null);return n("div",{children:[n("div",{class:"page-header",children:[n("div",{class:"page-title",children:"Overview"}),n("div",{class:"header-actions",children:n("div",{class:"header-meta",children:[(r==null?void 0:r.model)??"—"," • up ",r?vn(r.uptime):"—"]})})]}),n("div",{class:"welcome-banner",children:[n("div",{class:"welcome-greeting",children:[Qs(),", Katrina"]}),n("div",{class:"welcome-sub",children:r?`Running for ${vn(r.uptime)} · ${r.model}`:"Loading…"})]}),o.length>0&&n("div",{style:{marginBottom:16},children:o.map(_=>n("div",{class:"approval-card",children:[n("div",{class:"approval-card-icon",children:n(On,{size:20})}),n("div",{class:"approval-card-content",children:[n("div",{class:"approval-card-title",children:[o.length," pending approval",o.length>1?"s":""]}),n("div",{class:"approval-card-detail",children:["Tier ",_.tier," — ",n("code",{class:"approval-cmd",children:_.command})]}),_.cwd&&n("div",{class:"approval-card-cwd",children:_.cwd})]}),n("div",{class:"approval-card-time",children:to(_.createdAt)}),n("div",{class:"approval-card-actions",children:[n("button",{class:"approval-btn-deny",disabled:m.has(_.id),onClick:()=>b(_.id,!1),children:"Deny"}),n("button",{class:"approval-btn-approve",disabled:m.has(_.id),onClick:()=>b(_.id,!0),children:[n(Re,{size:14})," Approve"]})]})]},_.id))}),n("div",{class:"stats-grid stats-grid-6",children:[n("div",{class:"stat-card",children:[n("div",{class:"stat-icon sage",children:n(He,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value",children:r?vn(r.uptime):"—"}),n("div",{class:"stat-subtitle",children:"Uptime"})]})]}),n("div",{class:"stat-card",children:[n("div",{class:"stat-icon amber",children:n(Yl,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value stat-value-md",children:oi(k==null?void 0:k.nextRun)}),n("div",{class:"stat-subtitle",children:["Next cron · ",(r==null?void 0:r.cronJobs.length)??0," jobs"]})]})]}),n("div",{class:"stat-card",children:[n("div",{class:"stat-icon green",children:n(pa,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value stat-value-md",children:(r==null?void 0:r.model)??"—"}),n("div",{class:"stat-subtitle",children:"Active model"})]})]}),n("div",{class:"stat-card",children:[n("div",{class:"stat-icon blue",children:n(rt,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value stat-value-md",children:no((r==null?void 0:r.activeChannel)??null)}),n("div",{class:"stat-subtitle",children:"Active channel"})]})]}),n("div",{class:"stat-card",children:[n("div",{class:"stat-icon rose",children:n(Be,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value stat-value-md",children:d?`$${d.today.totalCost.toFixed(2)}`:"—"}),n("div",{class:"stat-subtitle",children:"Cost today"})]})]})]}),n("div",{class:"section",children:[n("div",{class:"section-header",children:[n("div",{class:"section-title",children:"Audit Logs"}),n("a",{class:"section-link",href:"#audit",onClick:_=>{_.preventDefault(),e("audit")},children:n("span",{class:"section-link-content",children:["View all ",n(ti,{size:14})]})})]}),n("div",{class:"feed-card",children:n("div",{class:"feed",children:a.length===0?n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(es,{size:18})}),n("div",{class:"empty-state-text",children:"No recent audit logs"})]}):a.slice(0,6).map(_=>n("div",{class:"feed-item",children:[n("div",{class:`feed-icon ${_.trigger==="telegram"?"telegram":_.trigger==="cron"?"cron":"system"}`,children:S(_.trigger)}),n("div",{children:[n("div",{class:"feed-title",children:_.trigger}),n("div",{class:"feed-detail",children:ro(_)})]}),n("div",{class:"feed-time",children:eo(_.startedAt)})]},_.traceId))})})]}),(((h=r==null?void 0:r.cronJobs)==null?void 0:h.length)??0)>0&&n("div",{class:"section",children:[n("div",{class:"section-header",children:[n("div",{class:"section-title",children:"Scheduled Jobs"}),n("a",{class:"section-link",href:"#cron",onClick:_=>{_.preventDefault(),e("cron")},children:n("span",{class:"section-link-content",children:["Manage ",n(ti,{size:14})]})})]}),n("div",{class:"cron-grid",children:((r==null?void 0:r.cronJobs)??[]).slice(0,4).map(_=>n("div",{class:"cron-card",children:[n("div",{class:"cron-info",children:[n("div",{class:"cron-name",children:_.name}),n("div",{class:"cron-schedule",children:_.id})]}),n("div",{class:"cron-next",children:oi(_.nextRun)})]},_.id))})]})]})}function Bn(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function io(e){const t=e.trim();return/^(https?:|mailto:|\/|#)/i.test(t)?t:"#"}function ct(e){let t=Bn(e);return t=t.replace(/`([^`]+)`/g,"<code>$1</code>"),t=t.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),t=t.replace(/\*([^*]+)\*/g,"<em>$1</em>"),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(r,i,a)=>`<a href="${Bn(io(a))}" target="_blank" rel="noreferrer">${i}</a>`),t}function ao(e){const t=e.replace(/\r\n/g,`
2
+ `).split(`
3
+ `),r=[];let i=!1,a=[],l=null,o=[];function s(){l&&(r.push(`</${l}>`),l=null)}function d(){o.length!==0&&(r.push(`<p>${ct(o.join(" "))}</p>`),o=[])}function c(){i&&(r.push(`<pre><code>${Bn(a.join(`
4
+ `))}</code></pre>`),a=[],i=!1)}for(const m of t){if(m.trim().startsWith("```")){d(),s(),i?c():i=!0;continue}if(i){a.push(m);continue}const p=/^(#{1,6})\s+(.*)$/.exec(m);if(p){d(),s();const u=p[1].length;r.push(`<h${u}>${ct(p[2])}</h${u}>`);continue}const v=/^[-*]\s+(.*)$/.exec(m);if(v){d(),l!=="ul"&&(s(),l="ul",r.push("<ul>")),r.push(`<li>${ct(v[1])}</li>`);continue}const g=/^\d+\.\s+(.*)$/.exec(m);if(g){d(),l!=="ol"&&(s(),l="ol",r.push("<ol>")),r.push(`<li>${ct(g[1])}</li>`);continue}if(m.trim()===""){d(),s();continue}if(s(),m.startsWith("> ")){d(),r.push(`<blockquote>${ct(m.slice(2))}</blockquote>`);continue}o.push(m.trim())}return d(),s(),c(),r.join(`
5
+ `)}function Qt({content:e}){const t=ve(()=>ao(e||""),[e]);return n("div",{class:"markdown-view",dangerouslySetInnerHTML:{__html:t}})}const ka="dashboard_agent_messages_v1";function lo(e){if(!e||typeof e!="object")return!1;const t=e;return(t.role==="user"||t.role==="assistant")&&typeof t.content=="string"&&typeof t.ts=="string"&&t.conversationId==="dashboard-agent"&&(t.channel==="dashboard"||t.channel==="telegram"||t.channel==="discord")&&typeof t.chatId=="string"}function so(){try{const e=localStorage.getItem(ka);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(lo).slice(-300):[]}catch{return[]}}function oo(e){const t=Date.now()-new Date(e).getTime(),r=Math.floor(t/1e3);if(r<60)return`${r}s ago`;const i=Math.floor(r/60);if(i<60)return`${i}m ago`;const a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function co(){const[e,t]=w([]),[r,i]=w([]),[a,l]=w(()=>so()),[o,s]=w("all"),[d,c]=w(1),[m,p]=w(!1),[v,g]=w(!1),[u,b]=w(!0),[S,k]=w(""),[h,_]=w(!1),E=$e(null),M=$e(!0),P=$e(!1),T=$e(0),C=$e(0),x=(o==="all"?[...r,...a]:r).sort((A,U)=>new Date(A.ts).getTime()-new Date(U.ts).getTime()),y=()=>{const A=E.current;A&&(A.scrollTop=A.scrollHeight)};j(()=>{c(1),p(!1),g(!1),M.current=!0},[o]),j(()=>{R()},[o,d]),j(()=>{const A=setInterval(()=>{R()},5e3);return()=>clearInterval(A)},[o,d]),j(()=>{try{localStorage.setItem(ka,JSON.stringify(a.slice(-300)))}catch{}},[a]),j(()=>{const A=E.current;if(A){if(P.current){const U=A.scrollHeight;A.scrollTop=Math.max(0,U-T.current+C.current),P.current=!1,g(!1);return}if(M.current){requestAnimationFrame(y);const U=setTimeout(y,80);return()=>clearTimeout(U)}}},[x.length,u]);async function R(){b(!0);try{const U=(await Fs(o==="all"?void 0:o)).conversations??[];if(t(U),U.length===0){i([]);return}const ce=U.slice(0,12),pe=Math.max(20,d*30),Ie=await Promise.all(ce.map(async re=>{const G=await Hs(re.id,{limit:pe});return{hasMore:!!G.hasMore,messages:(G.messages??[]).map(Pe=>({...Pe,conversationId:re.id,channel:re.channel,chatId:re.chatId}))}})),De=Ie.some(re=>re.hasMore);p(De);const J=Ie.flatMap(re=>re.messages).sort((re,G)=>new Date(re.ts).getTime()-new Date(G.ts).getTime());i(J)}catch(A){console.error("[messages] load failed",A)}finally{b(!1)}}function $(A){const U=A.currentTarget,ce=U.scrollHeight-(U.scrollTop+U.clientHeight);M.current=ce<24,U.scrollTop<=40&&m&&!v&&!u&&(P.current=!0,T.current=U.scrollHeight,C.current=U.scrollTop,g(!0),c(pe=>pe+1))}async function H(){const A=S.trim();if(!(!A||h)){_(!0),M.current=!0;try{l(ce=>[...ce,{role:"user",content:A,ts:new Date().toISOString(),conversationId:"dashboard-agent",channel:"dashboard",chatId:"active"}]);const U=await Bs(A);l(ce=>[...ce,{role:"assistant",content:U.response,ts:U.timestamp||new Date().toISOString(),conversationId:"dashboard-agent",channel:"dashboard",chatId:"agent"}]),k("")}catch(U){console.error("[messages] send failed",U)}finally{_(!1)}}}function X(A){return A==="dashboard"?"Dashboard":A==="discord"?"Discord":"Telegram"}return n("div",{class:"messages-page",children:[n("div",{class:"page-header",children:[n("div",{class:"page-title",children:"Messages"}),n("div",{class:"header-actions",children:[n("select",{class:"btn btn-sm",value:o,onChange:A=>s(A.target.value),children:[n("option",{value:"all",children:"All channels"}),n("option",{value:"telegram",children:"Telegram"}),n("option",{value:"discord",children:"Discord"})]}),n("button",{class:"btn-refresh",onClick:()=>void R(),children:[n(ue,{size:14})," Refresh"]})]})]}),u&&e.length===0?n("div",{class:"messages-filler",children:n("div",{class:"spinner"})}):e.length===0?n("div",{class:"card messages-chat-card",children:n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(rt,{size:18})}),n("div",{class:"empty-state-text",children:"No messages yet"})]})}):n("div",{class:"card messages-chat-card",children:[x.length===0?n("div",{class:"empty-state",children:n("div",{class:"empty-state-text",children:"No conversation messages"})}):n("div",{ref:E,class:"chat-list messages-chat-list",onScroll:$,children:[v&&n("div",{style:{display:"flex",justifyContent:"center",padding:"6px 0"},children:n("div",{class:"spinner",style:{width:14,height:14}})}),x.map((A,U)=>n("div",{class:`chat-row ${A.role==="user"?"user":"assistant"}`,children:[n("div",{class:"chat-meta",children:[A.role==="user"?"You":"SkimpyClaw"," · ",X(A.channel)," · ",oo(A.ts)]}),n("div",{class:`chat-bubble ${A.role==="user"?"user":"assistant"}`,children:n(Qt,{content:A.content})})]},`${A.ts}-${U}`))]}),n("div",{class:"messages-composer-inline",children:n("div",{style:{display:"flex",gap:8},children:[n("input",{value:S,onInput:A=>k(A.target.value),onKeyDown:A=>{A.key==="Enter"&&(A.preventDefault(),H())},placeholder:"Send a message to the agent",style:{flex:1,padding:"10px 12px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border)",background:"var(--surface-alt)",color:"var(--text)"}}),n("button",{class:"btn btn-sm btn-primary",onClick:H,disabled:h||!S.trim(),children:h?"Sending…":"Send"})]})})]})]})}function uo(e){if(!e)return"N/A";const t=new Date(e).getTime()-Date.now();if(t<0)return"overdue";const r=Math.floor(t/6e4);return r<60?`in ${r}m`:`in ${Math.floor(r/60)}h ${r%60}m`}function ho({showToast:e}){const[t,r]=w([]),[i,a]=w(!0),[l,o]=w(new Set),[s,d]=w(null),[c,m]=w(null),[p,v]=w(!1),[g,u]=w(null),[b,S]=w(null),[k,h]=w({id:"",name:"",scheduleExpr:"",tz:"America/Chicago",model:"",payloadKind:"agentTurn",message:"",script:"",url:"",cwd:"",timeoutMs:"",sendAsVoice:!1,discordThreadId:""});j(()=>{_()},[]);async function _(){a(!0);try{const[x,y]=await Promise.all([xs(),rr()]);r(x.jobs??[]);const R=y.config??{};d(R)}catch{e("Failed to load cron jobs","error")}finally{a(!1)}}async function E(x){var A,U,ce,pe,Ie,De,J,re,G,Pe;const y=((A=x.payload)==null?void 0:A.kind)||"agentTurn",R=((U=x.payload)==null?void 0:U.message)||"";let $=R,H=null,X=null;if(y==="agentTurn"&&typeof R=="string"&&R.trim().endsWith(".md"))try{const Z=await Ss(R);$=Z.content,H=R,X=Z.content}catch{}u(H),S(X),h({id:x.id||"",name:x.name||"",scheduleExpr:((ce=x.schedule)==null?void 0:ce.expr)||"",tz:((pe=x.schedule)==null?void 0:pe.tz)||"America/Chicago",model:x.model||"",payloadKind:y,message:$,script:((Ie=x.payload)==null?void 0:Ie.script)||"",url:((De=x.payload)==null?void 0:De.url)||"",cwd:((J=x.payload)==null?void 0:J.cwd)||"",timeoutMs:(re=x.payload)!=null&&re.timeoutMs?String(x.payload.timeoutMs):"",sendAsVoice:!!((G=x.payload)!=null&&G.sendAsVoice),discordThreadId:((Pe=x.payload)==null?void 0:Pe.discordThreadId)||""})}function M(){m(null),u(null),S(null),h({id:"",name:"",scheduleExpr:"",tz:"America/Chicago",model:"",payloadKind:"agentTurn",message:"",script:"",url:"",cwd:"",timeoutMs:"",sendAsVoice:!1,discordThreadId:""})}function P(x){var R;m(x);const y=(((R=s==null?void 0:s.cron)==null?void 0:R.jobs)??[]).find($=>$.id===x);y&&E(y)}async function T(){if(!s)return;const x=k.id.trim(),y=k.name.trim(),R=k.scheduleExpr.trim();if(!x||!y||!R){e("ID, name, and schedule are required","error");return}const $=structuredClone(s);$.cron||($.cron={jobs:[]}),Array.isArray($.cron.jobs)||($.cron.jobs=[]);const H={kind:k.payloadKind};if(k.payloadKind==="agentTurn"){const U=g&&b!==null&&k.message===b;H.message=U?g:k.message}k.payloadKind==="script"&&(H.script=k.script,k.cwd.trim()&&(H.cwd=k.cwd.trim()),k.timeoutMs.trim()&&(H.timeoutMs=Number(k.timeoutMs))),k.payloadKind==="http"&&(H.url=k.url),k.sendAsVoice&&(H.sendAsVoice=!0),k.discordThreadId.trim()&&(H.discordThreadId=k.discordThreadId.trim());const X={id:x,name:y,schedule:{kind:"cron",expr:R,tz:k.tz.trim()||"America/Chicago"},payload:H,model:k.model.trim()||void 0},A=$.cron.jobs.findIndex(U=>U.id===x);A>=0?$.cron.jobs[A]=X:$.cron.jobs.push(X),v(!0);try{await ya($),e(A>=0?"Cron job updated":"Cron job created","success"),d($),m(x),await _()}catch{e("Failed to save cron job","error")}finally{v(!1)}}async function C(x){o(y=>new Set([...y,x]));try{await ws(x),e("Job triggered","success")}catch{e("Failed to trigger job","error")}finally{o(y=>{const R=new Set(y);return R.delete(x),R})}}return n("div",{children:[n("div",{class:"page-header",children:[n("div",{class:"page-title",children:"Scheduled Jobs"}),n("div",{class:"header-actions",children:[n("button",{class:"btn btn-sm",onClick:M,children:"New Job"}),n("button",{class:"btn-refresh",onClick:_,children:[n(ue,{size:14})," Refresh"]})]})]}),i?n("div",{style:{display:"flex",justifyContent:"center",padding:"48px"},children:n("div",{class:"spinner"})}):t.length===0?n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(He,{size:18})}),n("div",{class:"empty-state-text",children:"No scheduled jobs configured"})]}):n("div",{style:{display:"grid",gridTemplateColumns:"320px 1fr",gap:16},children:[n("div",{class:"card",style:{marginBottom:0,padding:0,overflow:"hidden"},children:n("div",{class:"templates-list",children:t.map(x=>n("button",{class:`templates-list-item${c===x.id?" active":""}`,onClick:()=>P(x.id),children:[n("div",{class:"templates-list-icon",children:n(He,{size:14})}),n("div",{class:"templates-list-content",children:[n("div",{class:"templates-list-title",children:x.name}),n("div",{class:"templates-list-meta",children:[x.id," · ",uo(x.nextRun)]})]})]},x.id))})}),n("div",{class:"card",style:{marginBottom:0},children:[n("div",{class:"card-title",style:{fontWeight:700,marginBottom:12},children:c?"Edit Cron Job":"Create Cron Job"}),n("div",{class:"form-grid two",children:[n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Job ID"}),n("input",{value:k.id,onInput:x=>h(y=>({...y,id:x.target.value})),placeholder:"morning_digest"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Job name"}),n("input",{value:k.name,onInput:x=>h(y=>({...y,name:x.target.value})),placeholder:"Morning Digest"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Cron expression"}),n("input",{value:k.scheduleExpr,onInput:x=>h(y=>({...y,scheduleExpr:x.target.value})),placeholder:"*/30 * * * *"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Timezone"}),n("input",{value:k.tz,onInput:x=>h(y=>({...y,tz:x.target.value})),placeholder:"America/Chicago"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Model override"}),n("input",{value:k.model,onInput:x=>h(y=>({...y,model:x.target.value})),placeholder:"optional"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Payload kind"}),n("select",{value:k.payloadKind,onChange:x=>h(y=>({...y,payloadKind:x.target.value})),children:[n("option",{value:"agentTurn",children:"agentTurn"}),n("option",{value:"script",children:"script"}),n("option",{value:"http",children:"http"})]})]})]}),k.payloadKind==="agentTurn"&&n("label",{class:"form-field",style:{marginTop:10},children:[n("span",{class:"form-label",children:"Agent prompt"}),g&&n("span",{class:"form-help",children:["Loaded from ",g]}),n("textarea",{value:k.message,onInput:x=>h(y=>({...y,message:x.target.value})),placeholder:"Message prompt",style:{minHeight:120}})]}),k.payloadKind==="script"&&n(te,{children:[n("label",{class:"form-field",style:{marginTop:10},children:[n("span",{class:"form-label",children:"Script"}),n("textarea",{value:k.script,onInput:x=>h(y=>({...y,script:x.target.value})),placeholder:"Shell script",style:{minHeight:120}})]}),n("div",{class:"form-grid two",style:{marginTop:10},children:[n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Working directory"}),n("input",{value:k.cwd,onInput:x=>h(y=>({...y,cwd:x.target.value})),placeholder:"optional"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Timeout ms"}),n("input",{value:k.timeoutMs,onInput:x=>h(y=>({...y,timeoutMs:x.target.value})),placeholder:"optional"})]})]})]}),k.payloadKind==="http"&&n("label",{class:"form-field",style:{marginTop:10},children:[n("span",{class:"form-label",children:"URL"}),n("input",{value:k.url,onInput:x=>h(y=>({...y,url:x.target.value})),placeholder:"https://..."})]}),n("label",{class:"form-field",style:{marginTop:10},children:[n("span",{class:"form-label",children:"Discord thread ID (optional)"}),n("input",{value:k.discordThreadId,onInput:x=>h(y=>({...y,discordThreadId:x.target.value})),placeholder:"123456789012345678"})]}),n("label",{class:"form-checkbox",style:{marginTop:10},children:[n("input",{type:"checkbox",checked:k.sendAsVoice,onChange:x=>h(y=>({...y,sendAsVoice:x.target.checked}))}),"Send output as voice"]}),n("div",{class:"form-actions",children:[c&&n("button",{class:"btn btn-sm",disabled:l.has(c),onClick:()=>C(c),children:l.has(c)?"Running…":"Run now"}),n("button",{class:"btn btn-sm btn-primary",onClick:T,disabled:p,children:p?"Saving…":"Save Job"})]})]})]})]})}function ar(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var qe=ar();function xa(e){qe=e}var Ue={exec:()=>null};function F(e,t=""){let r=typeof e=="string"?e:e.source,i={replace:(a,l)=>{let o=typeof l=="string"?l:l.source;return o=o.replace(le.caret,"$1"),r=r.replace(a,o),i},getRegex:()=>new RegExp(r,t)};return i}var po=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),le={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,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"),blockquoteBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}>`)},fo=/^(?:[ \t]*(?:\n|$))+/,go=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,mo=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Ct=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,vo=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,lr=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,wa=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Sa=F(wa).replace(/bull/g,lr).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(),_o=F(wa).replace(/bull/g,lr).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(),sr=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,bo=/^[^\n]+/,or=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,yo=F(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",or).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ko=F(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,lr).getRegex(),en="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",cr=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,xo=F("^ {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",cr).replace("tag",en).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ta=F(sr).replace("hr",Ct).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[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",en).getRegex(),wo=F(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ta).getRegex(),dr={blockquote:wo,code:go,def:yo,fences:mo,heading:vo,hr:Ct,html:xo,lheading:Sa,list:ko,newline:fo,paragraph:Ta,table:Ue,text:bo},di=F("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Ct).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[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",en).getRegex(),So={...dr,lheading:_o,table:di,paragraph:F(sr).replace("hr",Ct).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",di).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",en).getRegex()},To={...dr,html:F(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",cr).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:Ue,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:F(sr).replace("hr",Ct).replace("heading",` *#{1,6} *[^
6
+ ]`).replace("lheading",Sa).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Co=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ao=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ca=/^( {2,}|\\)\n(?!\s*$)/,Eo=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,tn=/[\p{P}\p{S}]/u,ur=/[\s\p{P}\p{S}]/u,Aa=/[^\s\p{P}\p{S}]/u,Lo=F(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ur).getRegex(),Ea=/(?!~)[\p{P}\p{S}]/u,$o=/(?!~)[\s\p{P}\p{S}]/u,Ro=/(?:[^\s\p{P}\p{S}]|~)/u,La=/(?![*_])[\p{P}\p{S}]/u,Mo=/(?![*_])[\s\p{P}\p{S}]/u,Io=/(?:[^\s\p{P}\p{S}]|[*_])/u,Do=F(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",po?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),$a=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Po=F($a,"u").replace(/punct/g,tn).getRegex(),No=F($a,"u").replace(/punct/g,Ea).getRegex(),Ra="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Oo=F(Ra,"gu").replace(/notPunctSpace/g,Aa).replace(/punctSpace/g,ur).replace(/punct/g,tn).getRegex(),zo=F(Ra,"gu").replace(/notPunctSpace/g,Ro).replace(/punctSpace/g,$o).replace(/punct/g,Ea).getRegex(),Uo=F("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Aa).replace(/punctSpace/g,ur).replace(/punct/g,tn).getRegex(),Bo=F(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,La).getRegex(),Fo="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Ho=F(Fo,"gu").replace(/notPunctSpace/g,Io).replace(/punctSpace/g,Mo).replace(/punct/g,La).getRegex(),jo=F(/\\(punct)/,"gu").replace(/punct/g,tn).getRegex(),Wo=F(/^<(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(),qo=F(cr).replace("(?:-->|$)","-->").getRegex(),Go=F("^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",qo).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Zt=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Vo=F(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Zt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ma=F(/^!?\[(label)\]\[(ref)\]/).replace("label",Zt).replace("ref",or).getRegex(),Ia=F(/^!?\[(ref)\](?:\[\])?/).replace("ref",or).getRegex(),Zo=F("reflink|nolink(?!\\()","g").replace("reflink",Ma).replace("nolink",Ia).getRegex(),ui=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,hr={_backpedal:Ue,anyPunctuation:jo,autolink:Wo,blockSkip:Do,br:Ca,code:Ao,del:Ue,delLDelim:Ue,delRDelim:Ue,emStrongLDelim:Po,emStrongRDelimAst:Oo,emStrongRDelimUnd:Uo,escape:Co,link:Vo,nolink:Ia,punctuation:Lo,reflink:Ma,reflinkSearch:Zo,tag:Go,text:Eo,url:Ue},Ko={...hr,link:F(/^!?\[(label)\]\((.*?)\)/).replace("label",Zt).getRegex(),reflink:F(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Zt).getRegex()},Fn={...hr,emStrongRDelimAst:zo,emStrongLDelim:No,delLDelim:Bo,delRDelim:Ho,url:F(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",ui).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:F(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",ui).getRegex()},Jo={...Fn,br:F(Ca).replace("{2,}","*").getRegex(),text:F(Fn.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Pt={normal:dr,gfm:So,pedantic:To},dt={normal:hr,gfm:Fn,breaks:Jo,pedantic:Ko},Yo={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},hi=e=>Yo[e];function ye(e,t){if(t){if(le.escapeTest.test(e))return e.replace(le.escapeReplace,hi)}else if(le.escapeTestNoEncode.test(e))return e.replace(le.escapeReplaceNoEncode,hi);return e}function pi(e){try{e=encodeURI(e).replace(le.percentDecode,"%")}catch{return null}return e}function fi(e,t){var l;let r=e.replace(le.findPipe,(o,s,d)=>{let c=!1,m=s;for(;--m>=0&&d[m]==="\\";)c=!c;return c?"|":" |"}),i=r.split(le.splitPipe),a=0;if(i[0].trim()||i.shift(),i.length>0&&!((l=i.at(-1))!=null&&l.trim())&&i.pop(),t)if(i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;a<i.length;a++)i[a]=i[a].trim().replace(le.slashPipe,"|");return i}function ut(e,t,r){let i=e.length;if(i===0)return"";let a=0;for(;a<i&&e.charAt(i-a-1)===t;)a++;return e.slice(0,i-a)}function Xo(e,t){if(e.indexOf(t[1])===-1)return-1;let r=0;for(let i=0;i<e.length;i++)if(e[i]==="\\")i++;else if(e[i]===t[0])r++;else if(e[i]===t[1]&&(r--,r<0))return i;return r>0?-2:-1}function Qo(e,t=0){let r=t,i="";for(let a of e)if(a===" "){let l=4-r%4;i+=" ".repeat(l),r+=l}else i+=a,r++;return i}function gi(e,t,r,i,a){let l=t.href,o=t.title||null,s=e[1].replace(a.other.outputLinkReplace,"$1");i.state.inLink=!0;let d={type:e[0].charAt(0)==="!"?"image":"link",raw:r,href:l,title:o,text:s,tokens:i.inlineTokens(s)};return i.state.inLink=!1,d}function ec(e,t,r){let i=e.match(r.other.indentCodeCompensation);if(i===null)return t;let a=i[1];return t.split(`
7
+ `).map(l=>{let o=l.match(r.other.beginningSpace);if(o===null)return l;let[s]=o;return s.length>=a.length?l.slice(a.length):l}).join(`
8
+ `)}var Kt=class{constructor(e){q(this,"options");q(this,"rules");q(this,"lexer");this.options=e||qe}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 r=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?r:ut(r,`
9
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let r=t[0],i=ec(r,t[3]||"",this.rules);return{type:"code",raw:r,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:i}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let r=t[2].trim();if(this.rules.other.endingHash.test(r)){let i=ut(r,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceChar.test(i))&&(r=i.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:ut(t[0],`
10
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let r=ut(t[0],`
11
+ `).split(`
12
+ `),i="",a="",l=[];for(;r.length>0;){let o=!1,s=[],d;for(d=0;d<r.length;d++)if(this.rules.other.blockquoteStart.test(r[d]))s.push(r[d]),o=!0;else if(!o)s.push(r[d]);else break;r=r.slice(d);let c=s.join(`
13
+ `),m=c.replace(this.rules.other.blockquoteSetextReplace,`
14
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");i=i?`${i}
15
+ ${c}`:c,a=a?`${a}
16
+ ${m}`:m;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(m,l,!0),this.lexer.state.top=p,r.length===0)break;let v=l.at(-1);if((v==null?void 0:v.type)==="code")break;if((v==null?void 0:v.type)==="blockquote"){let g=v,u=g.raw+`
17
+ `+r.join(`
18
+ `),b=this.blockquote(u);l[l.length-1]=b,i=i.substring(0,i.length-g.raw.length)+b.raw,a=a.substring(0,a.length-g.text.length)+b.text;break}else if((v==null?void 0:v.type)==="list"){let g=v,u=g.raw+`
19
+ `+r.join(`
20
+ `),b=this.list(u);l[l.length-1]=b,i=i.substring(0,i.length-v.raw.length)+b.raw,a=a.substring(0,a.length-g.raw.length)+b.raw,r=u.substring(l.at(-1).raw.length).split(`
21
+ `);continue}}return{type:"blockquote",raw:i,tokens:l,text:a}}}list(e){var r,i;let t=this.rules.block.list.exec(e);if(t){let a=t[1].trim(),l=a.length>1,o={type:"list",raw:"",ordered:l,start:l?+a.slice(0,-1):"",loose:!1,items:[]};a=l?`\\d{1,9}\\${a.slice(-1)}`:`\\${a}`,this.options.pedantic&&(a=l?a:"[*+-]");let s=this.rules.other.listItemRegex(a),d=!1;for(;e;){let m=!1,p="",v="";if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;p=t[0],e=e.substring(p.length);let g=Qo(t[2].split(`
22
+ `,1)[0],t[1].length),u=e.split(`
23
+ `,1)[0],b=!g.trim(),S=0;if(this.options.pedantic?(S=2,v=g.trimStart()):b?S=t[1].length+1:(S=g.search(this.rules.other.nonSpaceChar),S=S>4?1:S,v=g.slice(S),S+=t[1].length),b&&this.rules.other.blankLine.test(u)&&(p+=u+`
24
+ `,e=e.substring(u.length+1),m=!0),!m){let k=this.rules.other.nextBulletRegex(S),h=this.rules.other.hrRegex(S),_=this.rules.other.fencesBeginRegex(S),E=this.rules.other.headingBeginRegex(S),M=this.rules.other.htmlBeginRegex(S),P=this.rules.other.blockquoteBeginRegex(S);for(;e;){let T=e.split(`
25
+ `,1)[0],C;if(u=T,this.options.pedantic?(u=u.replace(this.rules.other.listReplaceNesting," "),C=u):C=u.replace(this.rules.other.tabCharGlobal," "),_.test(u)||E.test(u)||M.test(u)||P.test(u)||k.test(u)||h.test(u))break;if(C.search(this.rules.other.nonSpaceChar)>=S||!u.trim())v+=`
26
+ `+C.slice(S);else{if(b||g.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||_.test(g)||E.test(g)||h.test(g))break;v+=`
27
+ `+u}b=!u.trim(),p+=T+`
28
+ `,e=e.substring(T.length+1),g=C.slice(S)}}o.loose||(d?o.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(d=!0)),o.items.push({type:"list_item",raw:p,task:!!this.options.gfm&&this.rules.other.listIsTask.test(v),loose:!1,text:v,tokens:[]}),o.raw+=p}let c=o.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let m of o.items){if(this.lexer.state.top=!1,m.tokens=this.lexer.blockTokens(m.text,[]),m.task){if(m.text=m.text.replace(this.rules.other.listReplaceTask,""),((r=m.tokens[0])==null?void 0:r.type)==="text"||((i=m.tokens[0])==null?void 0:i.type)==="paragraph"){m.tokens[0].raw=m.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),m.tokens[0].text=m.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let v=this.lexer.inlineQueue.length-1;v>=0;v--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[v].src)){this.lexer.inlineQueue[v].src=this.lexer.inlineQueue[v].src.replace(this.rules.other.listReplaceTask,"");break}}let p=this.rules.other.listTaskCheckbox.exec(m.raw);if(p){let v={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};m.checked=v.checked,o.loose?m.tokens[0]&&["paragraph","text"].includes(m.tokens[0].type)&&"tokens"in m.tokens[0]&&m.tokens[0].tokens?(m.tokens[0].raw=v.raw+m.tokens[0].raw,m.tokens[0].text=v.raw+m.tokens[0].text,m.tokens[0].tokens.unshift(v)):m.tokens.unshift({type:"paragraph",raw:v.raw,text:v.raw,tokens:[v]}):m.tokens.unshift(v)}}if(!o.loose){let p=m.tokens.filter(g=>g.type==="space"),v=p.length>0&&p.some(g=>this.rules.other.anyLine.test(g.raw));o.loose=v}}if(o.loose)for(let m of o.items){m.loose=!0;for(let p of m.tokens)p.type==="text"&&(p.type="paragraph")}return o}}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 r=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),i=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",a=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:r,raw:t[0],href:i,title:a}}}table(e){var o;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let r=fi(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),a=(o=t[3])!=null&&o.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
29
+ `):[],l={type:"table",raw:t[0],header:[],align:[],rows:[]};if(r.length===i.length){for(let s of i)this.rules.other.tableAlignRight.test(s)?l.align.push("right"):this.rules.other.tableAlignCenter.test(s)?l.align.push("center"):this.rules.other.tableAlignLeft.test(s)?l.align.push("left"):l.align.push(null);for(let s=0;s<r.length;s++)l.header.push({text:r[s],tokens:this.lexer.inline(r[s]),header:!0,align:l.align[s]});for(let s of a)l.rows.push(fi(s,l.header.length).map((d,c)=>({text:d,tokens:this.lexer.inline(d),header:!1,align:l.align[c]})));return l}}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 r=t[1].charAt(t[1].length-1)===`
30
+ `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:r,tokens:this.lexer.inline(r)}}}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 r=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let l=ut(r.slice(0,-1),"\\");if((r.length-l.length)%2===0)return}else{let l=Xo(t[2],"()");if(l===-2)return;if(l>-1){let o=(t[0].indexOf("!")===0?5:4)+t[1].length+l;t[2]=t[2].substring(0,l),t[0]=t[0].substring(0,o).trim(),t[3]=""}}let i=t[2],a="";if(this.options.pedantic){let l=this.rules.other.pedanticHrefTitle.exec(i);l&&(i=l[1],a=l[3])}else a=t[3]?t[3].slice(1,-1):"";return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?i=i.slice(1):i=i.slice(1,-1)),gi(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:a&&a.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let r;if((r=this.rules.inline.reflink.exec(e))||(r=this.rules.inline.nolink.exec(e))){let i=(r[2]||r[1]).replace(this.rules.other.multipleSpaceGlobal," "),a=t[i.toLowerCase()];if(!a){let l=r[0].charAt(0);return{type:"text",raw:l,text:l}}return gi(r,a,r[0],this.lexer,this.rules)}}emStrong(e,t,r=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||i[3]&&r.match(this.rules.other.unicodeAlphaNumeric))&&(!(i[1]||i[2])||!r||this.rules.inline.punctuation.exec(r))){let a=[...i[0]].length-1,l,o,s=a,d=0,c=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+a);(i=c.exec(t))!=null;){if(l=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!l)continue;if(o=[...l].length,i[3]||i[4]){s+=o;continue}else if((i[5]||i[6])&&a%3&&!((a+o)%3)){d+=o;continue}if(s-=o,s>0)continue;o=Math.min(o,o+s+d);let m=[...i[0]][0].length,p=e.slice(0,a+i.index+m+o);if(Math.min(a,o)%2){let g=p.slice(1,-1);return{type:"em",raw:p,text:g,tokens:this.lexer.inlineTokens(g)}}let v=p.slice(2,-2);return{type:"strong",raw:p,text:v,tokens:this.lexer.inlineTokens(v)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let r=t[2].replace(this.rules.other.newLineCharGlobal," "),i=this.rules.other.nonSpaceChar.test(r),a=this.rules.other.startingSpaceChar.test(r)&&this.rules.other.endingSpaceChar.test(r);return i&&a&&(r=r.substring(1,r.length-1)),{type:"codespan",raw:t[0],text:r}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,r=""){let i=this.rules.inline.delLDelim.exec(e);if(i&&(!i[1]||!r||this.rules.inline.punctuation.exec(r))){let a=[...i[0]].length-1,l,o,s=a,d=this.rules.inline.delRDelim;for(d.lastIndex=0,t=t.slice(-1*e.length+a);(i=d.exec(t))!=null;){if(l=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!l||(o=[...l].length,o!==a))continue;if(i[3]||i[4]){s+=o;continue}if(s-=o,s>0)continue;o=Math.min(o,o+s);let c=[...i[0]][0].length,m=e.slice(0,a+i.index+c+o),p=m.slice(a,-a);return{type:"del",raw:m,text:p,tokens:this.lexer.inlineTokens(p)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let r,i;return t[2]==="@"?(r=t[1],i="mailto:"+r):(r=t[1],i=r),{type:"link",raw:t[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}url(e){var r;let t;if(t=this.rules.inline.url.exec(e)){let i,a;if(t[2]==="@")i=t[0],a="mailto:"+i;else{let l;do l=t[0],t[0]=((r=this.rules.inline._backpedal.exec(t[0]))==null?void 0:r[0])??"";while(l!==t[0]);i=t[0],t[1]==="www."?a="http://"+t[0]:a=t[0]}return{type:"link",raw:t[0],text:i,href:a,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let r=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:r}}}},ge=class Hn{constructor(t){q(this,"tokens");q(this,"options");q(this,"state");q(this,"inlineQueue");q(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||qe,this.options.tokenizer=this.options.tokenizer||new Kt,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 r={other:le,block:Pt.normal,inline:dt.normal};this.options.pedantic?(r.block=Pt.pedantic,r.inline=dt.pedantic):this.options.gfm&&(r.block=Pt.gfm,this.options.breaks?r.inline=dt.breaks:r.inline=dt.gfm),this.tokenizer.rules=r}static get rules(){return{block:Pt,inline:dt}}static lex(t,r){return new Hn(r).lex(t)}static lexInline(t,r){return new Hn(r).inlineTokens(t)}lex(t){t=t.replace(le.carriageReturn,`
31
+ `),this.blockTokens(t,this.tokens);for(let r=0;r<this.inlineQueue.length;r++){let i=this.inlineQueue[r];this.inlineTokens(i.src,i.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,r=[],i=!1){var a,l,o;for(this.options.pedantic&&(t=t.replace(le.tabCharGlobal," ").replace(le.spaceLine,""));t;){let s;if((l=(a=this.options.extensions)==null?void 0:a.block)!=null&&l.some(c=>(s=c.call({lexer:this},t,r))?(t=t.substring(s.raw.length),r.push(s),!0):!1))continue;if(s=this.tokenizer.space(t)){t=t.substring(s.raw.length);let c=r.at(-1);s.raw.length===1&&c!==void 0?c.raw+=`
32
+ `:r.push(s);continue}if(s=this.tokenizer.code(t)){t=t.substring(s.raw.length);let c=r.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
33
+ `)?"":`
34
+ `)+s.raw,c.text+=`
35
+ `+s.text,this.inlineQueue.at(-1).src=c.text):r.push(s);continue}if(s=this.tokenizer.fences(t)){t=t.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.heading(t)){t=t.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.hr(t)){t=t.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.blockquote(t)){t=t.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.list(t)){t=t.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.html(t)){t=t.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.def(t)){t=t.substring(s.raw.length);let c=r.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
36
+ `)?"":`
37
+ `)+s.raw,c.text+=`
38
+ `+s.raw,this.inlineQueue.at(-1).src=c.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title},r.push(s));continue}if(s=this.tokenizer.table(t)){t=t.substring(s.raw.length),r.push(s);continue}if(s=this.tokenizer.lheading(t)){t=t.substring(s.raw.length),r.push(s);continue}let d=t;if((o=this.options.extensions)!=null&&o.startBlock){let c=1/0,m=t.slice(1),p;this.options.extensions.startBlock.forEach(v=>{p=v.call({lexer:this},m),typeof p=="number"&&p>=0&&(c=Math.min(c,p))}),c<1/0&&c>=0&&(d=t.substring(0,c+1))}if(this.state.top&&(s=this.tokenizer.paragraph(d))){let c=r.at(-1);i&&(c==null?void 0:c.type)==="paragraph"?(c.raw+=(c.raw.endsWith(`
39
+ `)?"":`
40
+ `)+s.raw,c.text+=`
41
+ `+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):r.push(s),i=d.length!==t.length,t=t.substring(s.raw.length);continue}if(s=this.tokenizer.text(t)){t=t.substring(s.raw.length);let c=r.at(-1);(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
42
+ `)?"":`
43
+ `)+s.raw,c.text+=`
44
+ `+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):r.push(s);continue}if(t){let c="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return this.state.top=!0,r}inline(t,r=[]){return this.inlineQueue.push({src:t,tokens:r}),r}inlineTokens(t,r=[]){var d,c,m,p,v;let i=t,a=null;if(this.tokens.links){let g=Object.keys(this.tokens.links);if(g.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)g.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,a.index)+"["+"a".repeat(a[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.anyPunctuation.exec(i))!=null;)i=i.slice(0,a.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let l;for(;(a=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)l=a[2]?a[2].length:0,i=i.slice(0,a.index+l)+"["+"a".repeat(a[0].length-l-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);i=((c=(d=this.options.hooks)==null?void 0:d.emStrongMask)==null?void 0:c.call({lexer:this},i))??i;let o=!1,s="";for(;t;){o||(s=""),o=!1;let g;if((p=(m=this.options.extensions)==null?void 0:m.inline)!=null&&p.some(b=>(g=b.call({lexer:this},t,r))?(t=t.substring(g.raw.length),r.push(g),!0):!1))continue;if(g=this.tokenizer.escape(t)){t=t.substring(g.raw.length),r.push(g);continue}if(g=this.tokenizer.tag(t)){t=t.substring(g.raw.length),r.push(g);continue}if(g=this.tokenizer.link(t)){t=t.substring(g.raw.length),r.push(g);continue}if(g=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(g.raw.length);let b=r.at(-1);g.type==="text"&&(b==null?void 0:b.type)==="text"?(b.raw+=g.raw,b.text+=g.text):r.push(g);continue}if(g=this.tokenizer.emStrong(t,i,s)){t=t.substring(g.raw.length),r.push(g);continue}if(g=this.tokenizer.codespan(t)){t=t.substring(g.raw.length),r.push(g);continue}if(g=this.tokenizer.br(t)){t=t.substring(g.raw.length),r.push(g);continue}if(g=this.tokenizer.del(t,i,s)){t=t.substring(g.raw.length),r.push(g);continue}if(g=this.tokenizer.autolink(t)){t=t.substring(g.raw.length),r.push(g);continue}if(!this.state.inLink&&(g=this.tokenizer.url(t))){t=t.substring(g.raw.length),r.push(g);continue}let u=t;if((v=this.options.extensions)!=null&&v.startInline){let b=1/0,S=t.slice(1),k;this.options.extensions.startInline.forEach(h=>{k=h.call({lexer:this},S),typeof k=="number"&&k>=0&&(b=Math.min(b,k))}),b<1/0&&b>=0&&(u=t.substring(0,b+1))}if(g=this.tokenizer.inlineText(u)){t=t.substring(g.raw.length),g.raw.slice(-1)!=="_"&&(s=g.raw.slice(-1)),o=!0;let b=r.at(-1);(b==null?void 0:b.type)==="text"?(b.raw+=g.raw,b.text+=g.text):r.push(g);continue}if(t){let b="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(b);break}else throw new Error(b)}}return r}},Jt=class{constructor(e){q(this,"options");q(this,"parser");this.options=e||qe}space(e){return""}code({text:e,lang:t,escaped:r}){var l;let i=(l=(t||"").match(le.notSpaceStart))==null?void 0:l[0],a=e.replace(le.endingNewline,"")+`
45
+ `;return i?'<pre><code class="language-'+ye(i)+'">'+(r?a:ye(a,!0))+`</code></pre>
46
+ `:"<pre><code>"+(r?a:ye(a,!0))+`</code></pre>
47
+ `}blockquote({tokens:e}){return`<blockquote>
48
+ ${this.parser.parse(e)}</blockquote>
49
+ `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
50
+ `}hr(e){return`<hr>
51
+ `}list(e){let t=e.ordered,r=e.start,i="";for(let o=0;o<e.items.length;o++){let s=e.items[o];i+=this.listitem(s)}let a=t?"ol":"ul",l=t&&r!==1?' start="'+r+'"':"";return"<"+a+l+`>
52
+ `+i+"</"+a+`>
53
+ `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
54
+ `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
55
+ `}table(e){let t="",r="";for(let a=0;a<e.header.length;a++)r+=this.tablecell(e.header[a]);t+=this.tablerow({text:r});let i="";for(let a=0;a<e.rows.length;a++){let l=e.rows[a];r="";for(let o=0;o<l.length;o++)r+=this.tablecell(l[o]);i+=this.tablerow({text:r})}return i&&(i=`<tbody>${i}</tbody>`),`<table>
56
+ <thead>
57
+ `+t+`</thead>
58
+ `+i+`</table>
59
+ `}tablerow({text:e}){return`<tr>
60
+ ${e}</tr>
61
+ `}tablecell(e){let t=this.parser.parseInline(e.tokens),r=e.header?"th":"td";return(e.align?`<${r} align="${e.align}">`:`<${r}>`)+t+`</${r}>
62
+ `}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>${ye(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:r}){let i=this.parser.parseInline(r),a=pi(e);if(a===null)return i;e=a;let l='<a href="'+e+'"';return t&&(l+=' title="'+ye(t)+'"'),l+=">"+i+"</a>",l}image({href:e,title:t,text:r,tokens:i}){i&&(r=this.parser.parseInline(i,this.parser.textRenderer));let a=pi(e);if(a===null)return ye(r);e=a;let l=`<img src="${e}" alt="${ye(r)}"`;return t&&(l+=` title="${ye(t)}"`),l+=">",l}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:ye(e.text)}},pr=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}},me=class jn{constructor(t){q(this,"options");q(this,"renderer");q(this,"textRenderer");this.options=t||qe,this.options.renderer=this.options.renderer||new Jt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new pr}static parse(t,r){return new jn(r).parse(t)}static parseInline(t,r){return new jn(r).parseInline(t)}parse(t){var i,a;let r="";for(let l=0;l<t.length;l++){let o=t[l];if((a=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&a[o.type]){let d=o,c=this.options.extensions.renderers[d.type].call({parser:this},d);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(d.type)){r+=c||"";continue}}let s=o;switch(s.type){case"space":{r+=this.renderer.space(s);break}case"hr":{r+=this.renderer.hr(s);break}case"heading":{r+=this.renderer.heading(s);break}case"code":{r+=this.renderer.code(s);break}case"table":{r+=this.renderer.table(s);break}case"blockquote":{r+=this.renderer.blockquote(s);break}case"list":{r+=this.renderer.list(s);break}case"checkbox":{r+=this.renderer.checkbox(s);break}case"html":{r+=this.renderer.html(s);break}case"def":{r+=this.renderer.def(s);break}case"paragraph":{r+=this.renderer.paragraph(s);break}case"text":{r+=this.renderer.text(s);break}default:{let d='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(d),"";throw new Error(d)}}}return r}parseInline(t,r=this.renderer){var a,l;let i="";for(let o=0;o<t.length;o++){let s=t[o];if((l=(a=this.options.extensions)==null?void 0:a.renderers)!=null&&l[s.type]){let c=this.options.extensions.renderers[s.type].call({parser:this},s);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){i+=c||"";continue}}let d=s;switch(d.type){case"escape":{i+=r.text(d);break}case"html":{i+=r.html(d);break}case"link":{i+=r.link(d);break}case"image":{i+=r.image(d);break}case"checkbox":{i+=r.checkbox(d);break}case"strong":{i+=r.strong(d);break}case"em":{i+=r.em(d);break}case"codespan":{i+=r.codespan(d);break}case"br":{i+=r.br(d);break}case"del":{i+=r.del(d);break}case"text":{i+=r.text(d);break}default:{let c='Token with "'+d.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return i}},zt,kt=(zt=class{constructor(e){q(this,"options");q(this,"block");this.options=e||qe}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?ge.lex:ge.lexInline}provideParser(){return this.block?me.parse:me.parseInline}},q(zt,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),q(zt,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),zt),tc=class{constructor(...e){q(this,"defaults",ar());q(this,"options",this.setOptions);q(this,"parse",this.parseMarkdown(!0));q(this,"parseInline",this.parseMarkdown(!1));q(this,"Parser",me);q(this,"Renderer",Jt);q(this,"TextRenderer",pr);q(this,"Lexer",ge);q(this,"Tokenizer",Kt);q(this,"Hooks",kt);this.use(...e)}walkTokens(e,t){var i,a;let r=[];for(let l of e)switch(r=r.concat(t.call(this,l)),l.type){case"table":{let o=l;for(let s of o.header)r=r.concat(this.walkTokens(s.tokens,t));for(let s of o.rows)for(let d of s)r=r.concat(this.walkTokens(d.tokens,t));break}case"list":{let o=l;r=r.concat(this.walkTokens(o.items,t));break}default:{let o=l;(a=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&a[o.type]?this.defaults.extensions.childTokens[o.type].forEach(s=>{let d=o[s].flat(1/0);r=r.concat(this.walkTokens(d,t))}):o.tokens&&(r=r.concat(this.walkTokens(o.tokens,t)))}}return r}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(r=>{let i={...r};if(i.async=this.defaults.async||i.async||!1,r.extensions&&(r.extensions.forEach(a=>{if(!a.name)throw new Error("extension name required");if("renderer"in a){let l=t.renderers[a.name];l?t.renderers[a.name]=function(...o){let s=a.renderer.apply(this,o);return s===!1&&(s=l.apply(this,o)),s}:t.renderers[a.name]=a.renderer}if("tokenizer"in a){if(!a.level||a.level!=="block"&&a.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let l=t[a.level];l?l.unshift(a.tokenizer):t[a.level]=[a.tokenizer],a.start&&(a.level==="block"?t.startBlock?t.startBlock.push(a.start):t.startBlock=[a.start]:a.level==="inline"&&(t.startInline?t.startInline.push(a.start):t.startInline=[a.start]))}"childTokens"in a&&a.childTokens&&(t.childTokens[a.name]=a.childTokens)}),i.extensions=t),r.renderer){let a=this.defaults.renderer||new Jt(this.defaults);for(let l in r.renderer){if(!(l in a))throw new Error(`renderer '${l}' does not exist`);if(["options","parser"].includes(l))continue;let o=l,s=r.renderer[o],d=a[o];a[o]=(...c)=>{let m=s.apply(a,c);return m===!1&&(m=d.apply(a,c)),m||""}}i.renderer=a}if(r.tokenizer){let a=this.defaults.tokenizer||new Kt(this.defaults);for(let l in r.tokenizer){if(!(l in a))throw new Error(`tokenizer '${l}' does not exist`);if(["options","rules","lexer"].includes(l))continue;let o=l,s=r.tokenizer[o],d=a[o];a[o]=(...c)=>{let m=s.apply(a,c);return m===!1&&(m=d.apply(a,c)),m}}i.tokenizer=a}if(r.hooks){let a=this.defaults.hooks||new kt;for(let l in r.hooks){if(!(l in a))throw new Error(`hook '${l}' does not exist`);if(["options","block"].includes(l))continue;let o=l,s=r.hooks[o],d=a[o];kt.passThroughHooks.has(l)?a[o]=c=>{if(this.defaults.async&&kt.passThroughHooksRespectAsync.has(l))return(async()=>{let p=await s.call(a,c);return d.call(a,p)})();let m=s.call(a,c);return d.call(a,m)}:a[o]=(...c)=>{if(this.defaults.async)return(async()=>{let p=await s.apply(a,c);return p===!1&&(p=await d.apply(a,c)),p})();let m=s.apply(a,c);return m===!1&&(m=d.apply(a,c)),m}}i.hooks=a}if(r.walkTokens){let a=this.defaults.walkTokens,l=r.walkTokens;i.walkTokens=function(o){let s=[];return s.push(l.call(this,o)),a&&(s=s.concat(a.call(this,o))),s}}this.defaults={...this.defaults,...i}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ge.lex(e,t??this.defaults)}parser(e,t){return me.parse(e,t??this.defaults)}parseMarkdown(e){return(t,r)=>{let i={...r},a={...this.defaults,...i},l=this.onError(!!a.silent,!!a.async);if(this.defaults.async===!0&&i.async===!1)return l(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 l(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return l(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(a.hooks&&(a.hooks.options=a,a.hooks.block=e),a.async)return(async()=>{let o=a.hooks?await a.hooks.preprocess(t):t,s=await(a.hooks?await a.hooks.provideLexer():e?ge.lex:ge.lexInline)(o,a),d=a.hooks?await a.hooks.processAllTokens(s):s;a.walkTokens&&await Promise.all(this.walkTokens(d,a.walkTokens));let c=await(a.hooks?await a.hooks.provideParser():e?me.parse:me.parseInline)(d,a);return a.hooks?await a.hooks.postprocess(c):c})().catch(l);try{a.hooks&&(t=a.hooks.preprocess(t));let o=(a.hooks?a.hooks.provideLexer():e?ge.lex:ge.lexInline)(t,a);a.hooks&&(o=a.hooks.processAllTokens(o)),a.walkTokens&&this.walkTokens(o,a.walkTokens);let s=(a.hooks?a.hooks.provideParser():e?me.parse:me.parseInline)(o,a);return a.hooks&&(s=a.hooks.postprocess(s)),s}catch(o){return l(o)}}}onError(e,t){return r=>{if(r.message+=`
63
+ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+ye(r.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(r);throw r}}},We=new tc;function W(e,t){return We.parse(e,t)}W.options=W.setOptions=function(e){return We.setOptions(e),W.defaults=We.defaults,xa(W.defaults),W};W.getDefaults=ar;W.defaults=qe;W.use=function(...e){return We.use(...e),W.defaults=We.defaults,xa(W.defaults),W};W.walkTokens=function(e,t){return We.walkTokens(e,t)};W.parseInline=We.parseInline;W.Parser=me;W.parser=me.parse;W.Renderer=Jt;W.TextRenderer=pr;W.Lexer=ge;W.lexer=ge.lex;W.Tokenizer=Kt;W.Hooks=kt;W.parse=W;W.options;W.setOptions;W.use;W.walkTokens;W.parseInline;me.parse;ge.lex;/*! @license DOMPurify 3.3.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.1/LICENSE */const{entries:Da,setPrototypeOf:mi,isFrozen:nc,getPrototypeOf:rc,getOwnPropertyDescriptor:ic}=Object;let{freeze:se,seal:he,create:Wn}=Object,{apply:qn,construct:Gn}=typeof Reflect<"u"&&Reflect;se||(se=function(t){return t});he||(he=function(t){return t});qn||(qn=function(t,r){for(var i=arguments.length,a=new Array(i>2?i-2:0),l=2;l<i;l++)a[l-2]=arguments[l];return t.apply(r,a)});Gn||(Gn=function(t){for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];return new t(...i)});const Nt=oe(Array.prototype.forEach),ac=oe(Array.prototype.lastIndexOf),vi=oe(Array.prototype.pop),ht=oe(Array.prototype.push),lc=oe(Array.prototype.splice),Ht=oe(String.prototype.toLowerCase),_n=oe(String.prototype.toString),bn=oe(String.prototype.match),pt=oe(String.prototype.replace),sc=oe(String.prototype.indexOf),oc=oe(String.prototype.trim),fe=oe(Object.prototype.hasOwnProperty),ae=oe(RegExp.prototype.test),ft=cc(TypeError);function oe(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];return qn(e,t,i)}}function cc(e){return function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return Gn(e,r)}}function B(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ht;mi&&mi(e,null);let i=t.length;for(;i--;){let a=t[i];if(typeof a=="string"){const l=r(a);l!==a&&(nc(t)||(t[i]=l),a=l)}e[a]=!0}return e}function dc(e){for(let t=0;t<e.length;t++)fe(e,t)||(e[t]=null);return e}function ke(e){const t=Wn(null);for(const[r,i]of Da(e))fe(e,r)&&(Array.isArray(i)?t[r]=dc(i):i&&typeof i=="object"&&i.constructor===Object?t[r]=ke(i):t[r]=i);return t}function gt(e,t){for(;e!==null;){const i=ic(e,t);if(i){if(i.get)return oe(i.get);if(typeof i.value=="function")return oe(i.value)}e=rc(e)}function r(){return null}return r}const _i=se(["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=se(["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"]),kn=se(["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"]),uc=se(["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"]),xn=se(["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"]),hc=se(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),bi=se(["#text"]),yi=se(["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"]),wn=se(["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"]),ki=se(["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"]),Ot=se(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),pc=he(/\{\{[\w\W]*|[\w\W]*\}\}/gm),fc=he(/<%[\w\W]*|[\w\W]*%>/gm),gc=he(/\$\{[\w\W]*/gm),mc=he(/^data-[\-\w.\u00B7-\uFFFF]+$/),vc=he(/^aria-[\-\w]+$/),Pa=he(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),_c=he(/^(?:\w+script|data):/i),bc=he(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Na=he(/^html$/i),yc=he(/^[a-z][.\w]*(-[.\w]+)+$/i);var xi=Object.freeze({__proto__:null,ARIA_ATTR:vc,ATTR_WHITESPACE:bc,CUSTOM_ELEMENT:yc,DATA_ATTR:mc,DOCTYPE_NAME:Na,ERB_EXPR:fc,IS_ALLOWED_URI:Pa,IS_SCRIPT_OR_DATA:_c,MUSTACHE_EXPR:pc,TMPLIT_EXPR:gc});const mt={element:1,text:3,progressingInstruction:7,comment:8,document:9},kc=function(){return typeof window>"u"?null:window},xc=function(t,r){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let i=null;const a="data-tt-policy-suffix";r&&r.hasAttribute(a)&&(i=r.getAttribute(a));const l="dompurify"+(i?"#"+i:"");try{return t.createPolicy(l,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+l+" could not be created."),null}},wi=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Oa(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:kc();const t=D=>Oa(D);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==mt.document||!e.Element)return t.isSupported=!1,t;let{document:r}=e;const i=r,a=i.currentScript,{DocumentFragment:l,HTMLTemplateElement:o,Node:s,Element:d,NodeFilter:c,NamedNodeMap:m=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:p,DOMParser:v,trustedTypes:g}=e,u=d.prototype,b=gt(u,"cloneNode"),S=gt(u,"remove"),k=gt(u,"nextSibling"),h=gt(u,"childNodes"),_=gt(u,"parentNode");if(typeof o=="function"){const D=r.createElement("template");D.content&&D.content.ownerDocument&&(r=D.content.ownerDocument)}let E,M="";const{implementation:P,createNodeIterator:T,createDocumentFragment:C,getElementsByTagName:x}=r,{importNode:y}=i;let R=wi();t.isSupported=typeof Da=="function"&&typeof _=="function"&&P&&P.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:$,ERB_EXPR:H,TMPLIT_EXPR:X,DATA_ATTR:A,ARIA_ATTR:U,IS_SCRIPT_OR_DATA:ce,ATTR_WHITESPACE:pe,CUSTOM_ELEMENT:Ie}=xi;let{IS_ALLOWED_URI:De}=xi,J=null;const re=B({},[..._i,...yn,...kn,...xn,...bi]);let G=null;const Pe=B({},[...yi,...wn,...ki,...Ot]);let Z=Object.seal(Wn(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}})),lt=null,nn=null;const Ge=Object.seal(Wn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let fr=!0,rn=!0,gr=!1,mr=!0,Ve=!1,At=!0,Ne=!1,an=!1,ln=!1,Ze=!1,Et=!1,Lt=!1,vr=!0,_r=!1;const za="user-content-";let sn=!0,st=!1,Ke={},_e=null;const on=B({},["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 br=null;const yr=B({},["audio","video","img","source","image","track"]);let cn=null;const kr=B({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),$t="http://www.w3.org/1998/Math/MathML",Rt="http://www.w3.org/2000/svg",Se="http://www.w3.org/1999/xhtml";let Je=Se,dn=!1,un=null;const Ua=B({},[$t,Rt,Se],_n);let Mt=B({},["mi","mo","mn","ms","mtext"]),It=B({},["annotation-xml"]);const Ba=B({},["title","style","font","a","script"]);let ot=null;const Fa=["application/xhtml+xml","text/html"],Ha="text/html";let ee=null,Ye=null;const ja=r.createElement("form"),xr=function(f){return f instanceof RegExp||f instanceof Function},hn=function(){let f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ye&&Ye===f)){if((!f||typeof f!="object")&&(f={}),f=ke(f),ot=Fa.indexOf(f.PARSER_MEDIA_TYPE)===-1?Ha:f.PARSER_MEDIA_TYPE,ee=ot==="application/xhtml+xml"?_n:Ht,J=fe(f,"ALLOWED_TAGS")?B({},f.ALLOWED_TAGS,ee):re,G=fe(f,"ALLOWED_ATTR")?B({},f.ALLOWED_ATTR,ee):Pe,un=fe(f,"ALLOWED_NAMESPACES")?B({},f.ALLOWED_NAMESPACES,_n):Ua,cn=fe(f,"ADD_URI_SAFE_ATTR")?B(ke(kr),f.ADD_URI_SAFE_ATTR,ee):kr,br=fe(f,"ADD_DATA_URI_TAGS")?B(ke(yr),f.ADD_DATA_URI_TAGS,ee):yr,_e=fe(f,"FORBID_CONTENTS")?B({},f.FORBID_CONTENTS,ee):on,lt=fe(f,"FORBID_TAGS")?B({},f.FORBID_TAGS,ee):ke({}),nn=fe(f,"FORBID_ATTR")?B({},f.FORBID_ATTR,ee):ke({}),Ke=fe(f,"USE_PROFILES")?f.USE_PROFILES:!1,fr=f.ALLOW_ARIA_ATTR!==!1,rn=f.ALLOW_DATA_ATTR!==!1,gr=f.ALLOW_UNKNOWN_PROTOCOLS||!1,mr=f.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ve=f.SAFE_FOR_TEMPLATES||!1,At=f.SAFE_FOR_XML!==!1,Ne=f.WHOLE_DOCUMENT||!1,Ze=f.RETURN_DOM||!1,Et=f.RETURN_DOM_FRAGMENT||!1,Lt=f.RETURN_TRUSTED_TYPE||!1,ln=f.FORCE_BODY||!1,vr=f.SANITIZE_DOM!==!1,_r=f.SANITIZE_NAMED_PROPS||!1,sn=f.KEEP_CONTENT!==!1,st=f.IN_PLACE||!1,De=f.ALLOWED_URI_REGEXP||Pa,Je=f.NAMESPACE||Se,Mt=f.MATHML_TEXT_INTEGRATION_POINTS||Mt,It=f.HTML_INTEGRATION_POINTS||It,Z=f.CUSTOM_ELEMENT_HANDLING||{},f.CUSTOM_ELEMENT_HANDLING&&xr(f.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Z.tagNameCheck=f.CUSTOM_ELEMENT_HANDLING.tagNameCheck),f.CUSTOM_ELEMENT_HANDLING&&xr(f.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Z.attributeNameCheck=f.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),f.CUSTOM_ELEMENT_HANDLING&&typeof f.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Z.allowCustomizedBuiltInElements=f.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Ve&&(rn=!1),Et&&(Ze=!0),Ke&&(J=B({},bi),G=[],Ke.html===!0&&(B(J,_i),B(G,yi)),Ke.svg===!0&&(B(J,yn),B(G,wn),B(G,Ot)),Ke.svgFilters===!0&&(B(J,kn),B(G,wn),B(G,Ot)),Ke.mathMl===!0&&(B(J,xn),B(G,ki),B(G,Ot))),f.ADD_TAGS&&(typeof f.ADD_TAGS=="function"?Ge.tagCheck=f.ADD_TAGS:(J===re&&(J=ke(J)),B(J,f.ADD_TAGS,ee))),f.ADD_ATTR&&(typeof f.ADD_ATTR=="function"?Ge.attributeCheck=f.ADD_ATTR:(G===Pe&&(G=ke(G)),B(G,f.ADD_ATTR,ee))),f.ADD_URI_SAFE_ATTR&&B(cn,f.ADD_URI_SAFE_ATTR,ee),f.FORBID_CONTENTS&&(_e===on&&(_e=ke(_e)),B(_e,f.FORBID_CONTENTS,ee)),f.ADD_FORBID_CONTENTS&&(_e===on&&(_e=ke(_e)),B(_e,f.ADD_FORBID_CONTENTS,ee)),sn&&(J["#text"]=!0),Ne&&B(J,["html","head","body"]),J.table&&(B(J,["tbody"]),delete lt.tbody),f.TRUSTED_TYPES_POLICY){if(typeof f.TRUSTED_TYPES_POLICY.createHTML!="function")throw ft('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof f.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ft('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');E=f.TRUSTED_TYPES_POLICY,M=E.createHTML("")}else E===void 0&&(E=xc(g,a)),E!==null&&typeof M=="string"&&(M=E.createHTML(""));se&&se(f),Ye=f}},wr=B({},[...yn,...kn,...uc]),Sr=B({},[...xn,...hc]),Wa=function(f){let L=_(f);(!L||!L.tagName)&&(L={namespaceURI:Je,tagName:"template"});const I=Ht(f.tagName),K=Ht(L.tagName);return un[f.namespaceURI]?f.namespaceURI===Rt?L.namespaceURI===Se?I==="svg":L.namespaceURI===$t?I==="svg"&&(K==="annotation-xml"||Mt[K]):!!wr[I]:f.namespaceURI===$t?L.namespaceURI===Se?I==="math":L.namespaceURI===Rt?I==="math"&&It[K]:!!Sr[I]:f.namespaceURI===Se?L.namespaceURI===Rt&&!It[K]||L.namespaceURI===$t&&!Mt[K]?!1:!Sr[I]&&(Ba[I]||!wr[I]):!!(ot==="application/xhtml+xml"&&un[f.namespaceURI]):!1},be=function(f){ht(t.removed,{element:f});try{_(f).removeChild(f)}catch{S(f)}},Oe=function(f,L){try{ht(t.removed,{attribute:L.getAttributeNode(f),from:L})}catch{ht(t.removed,{attribute:null,from:L})}if(L.removeAttribute(f),f==="is")if(Ze||Et)try{be(L)}catch{}else try{L.setAttribute(f,"")}catch{}},Tr=function(f){let L=null,I=null;if(ln)f="<remove></remove>"+f;else{const Q=bn(f,/^[\r\n\t ]+/);I=Q&&Q[0]}ot==="application/xhtml+xml"&&Je===Se&&(f='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+f+"</body></html>");const K=E?E.createHTML(f):f;if(Je===Se)try{L=new v().parseFromString(K,ot)}catch{}if(!L||!L.documentElement){L=P.createDocument(Je,"template",null);try{L.documentElement.innerHTML=dn?M:K}catch{}}const ie=L.body||L.documentElement;return f&&I&&ie.insertBefore(r.createTextNode(I),ie.childNodes[0]||null),Je===Se?x.call(L,Ne?"html":"body")[0]:Ne?L.documentElement:ie},Cr=function(f){return T.call(f.ownerDocument||f,f,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},pn=function(f){return f instanceof p&&(typeof f.nodeName!="string"||typeof f.textContent!="string"||typeof f.removeChild!="function"||!(f.attributes instanceof m)||typeof f.removeAttribute!="function"||typeof f.setAttribute!="function"||typeof f.namespaceURI!="string"||typeof f.insertBefore!="function"||typeof f.hasChildNodes!="function")},Ar=function(f){return typeof s=="function"&&f instanceof s};function Te(D,f,L){Nt(D,I=>{I.call(t,f,L,Ye)})}const Er=function(f){let L=null;if(Te(R.beforeSanitizeElements,f,null),pn(f))return be(f),!0;const I=ee(f.nodeName);if(Te(R.uponSanitizeElement,f,{tagName:I,allowedTags:J}),At&&f.hasChildNodes()&&!Ar(f.firstElementChild)&&ae(/<[/\w!]/g,f.innerHTML)&&ae(/<[/\w!]/g,f.textContent)||f.nodeType===mt.progressingInstruction||At&&f.nodeType===mt.comment&&ae(/<[/\w]/g,f.data))return be(f),!0;if(!(Ge.tagCheck instanceof Function&&Ge.tagCheck(I))&&(!J[I]||lt[I])){if(!lt[I]&&$r(I)&&(Z.tagNameCheck instanceof RegExp&&ae(Z.tagNameCheck,I)||Z.tagNameCheck instanceof Function&&Z.tagNameCheck(I)))return!1;if(sn&&!_e[I]){const K=_(f)||f.parentNode,ie=h(f)||f.childNodes;if(ie&&K){const Q=ie.length;for(let de=Q-1;de>=0;--de){const Ce=b(ie[de],!0);Ce.__removalCount=(f.__removalCount||0)+1,K.insertBefore(Ce,k(f))}}}return be(f),!0}return f instanceof d&&!Wa(f)||(I==="noscript"||I==="noembed"||I==="noframes")&&ae(/<\/no(script|embed|frames)/i,f.innerHTML)?(be(f),!0):(Ve&&f.nodeType===mt.text&&(L=f.textContent,Nt([$,H,X],K=>{L=pt(L,K," ")}),f.textContent!==L&&(ht(t.removed,{element:f.cloneNode()}),f.textContent=L)),Te(R.afterSanitizeElements,f,null),!1)},Lr=function(f,L,I){if(vr&&(L==="id"||L==="name")&&(I in r||I in ja))return!1;if(!(rn&&!nn[L]&&ae(A,L))){if(!(fr&&ae(U,L))){if(!(Ge.attributeCheck instanceof Function&&Ge.attributeCheck(L,f))){if(!G[L]||nn[L]){if(!($r(f)&&(Z.tagNameCheck instanceof RegExp&&ae(Z.tagNameCheck,f)||Z.tagNameCheck instanceof Function&&Z.tagNameCheck(f))&&(Z.attributeNameCheck instanceof RegExp&&ae(Z.attributeNameCheck,L)||Z.attributeNameCheck instanceof Function&&Z.attributeNameCheck(L,f))||L==="is"&&Z.allowCustomizedBuiltInElements&&(Z.tagNameCheck instanceof RegExp&&ae(Z.tagNameCheck,I)||Z.tagNameCheck instanceof Function&&Z.tagNameCheck(I))))return!1}else if(!cn[L]){if(!ae(De,pt(I,pe,""))){if(!((L==="src"||L==="xlink:href"||L==="href")&&f!=="script"&&sc(I,"data:")===0&&br[f])){if(!(gr&&!ae(ce,pt(I,pe,"")))){if(I)return!1}}}}}}}return!0},$r=function(f){return f!=="annotation-xml"&&bn(f,Ie)},Rr=function(f){Te(R.beforeSanitizeAttributes,f,null);const{attributes:L}=f;if(!L||pn(f))return;const I={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:G,forceKeepAttr:void 0};let K=L.length;for(;K--;){const ie=L[K],{name:Q,namespaceURI:de,value:Ce}=ie,Xe=ee(Q),fn=Ce;let ne=Q==="value"?fn:oc(fn);if(I.attrName=Xe,I.attrValue=ne,I.keepAttr=!0,I.forceKeepAttr=void 0,Te(R.uponSanitizeAttribute,f,I),ne=I.attrValue,_r&&(Xe==="id"||Xe==="name")&&(Oe(Q,f),ne=za+ne),At&&ae(/((--!?|])>)|<\/(style|title|textarea)/i,ne)){Oe(Q,f);continue}if(Xe==="attributename"&&bn(ne,"href")){Oe(Q,f);continue}if(I.forceKeepAttr)continue;if(!I.keepAttr){Oe(Q,f);continue}if(!mr&&ae(/\/>/i,ne)){Oe(Q,f);continue}Ve&&Nt([$,H,X],Ir=>{ne=pt(ne,Ir," ")});const Mr=ee(f.nodeName);if(!Lr(Mr,Xe,ne)){Oe(Q,f);continue}if(E&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!de)switch(g.getAttributeType(Mr,Xe)){case"TrustedHTML":{ne=E.createHTML(ne);break}case"TrustedScriptURL":{ne=E.createScriptURL(ne);break}}if(ne!==fn)try{de?f.setAttributeNS(de,Q,ne):f.setAttribute(Q,ne),pn(f)?be(f):vi(t.removed)}catch{Oe(Q,f)}}Te(R.afterSanitizeAttributes,f,null)},qa=function D(f){let L=null;const I=Cr(f);for(Te(R.beforeSanitizeShadowDOM,f,null);L=I.nextNode();)Te(R.uponSanitizeShadowNode,L,null),Er(L),Rr(L),L.content instanceof l&&D(L.content);Te(R.afterSanitizeShadowDOM,f,null)};return t.sanitize=function(D){let f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},L=null,I=null,K=null,ie=null;if(dn=!D,dn&&(D="<!-->"),typeof D!="string"&&!Ar(D))if(typeof D.toString=="function"){if(D=D.toString(),typeof D!="string")throw ft("dirty is not a string, aborting")}else throw ft("toString is not a function");if(!t.isSupported)return D;if(an||hn(f),t.removed=[],typeof D=="string"&&(st=!1),st){if(D.nodeName){const Ce=ee(D.nodeName);if(!J[Ce]||lt[Ce])throw ft("root node is forbidden and cannot be sanitized in-place")}}else if(D instanceof s)L=Tr("<!---->"),I=L.ownerDocument.importNode(D,!0),I.nodeType===mt.element&&I.nodeName==="BODY"||I.nodeName==="HTML"?L=I:L.appendChild(I);else{if(!Ze&&!Ve&&!Ne&&D.indexOf("<")===-1)return E&&Lt?E.createHTML(D):D;if(L=Tr(D),!L)return Ze?null:Lt?M:""}L&&ln&&be(L.firstChild);const Q=Cr(st?D:L);for(;K=Q.nextNode();)Er(K),Rr(K),K.content instanceof l&&qa(K.content);if(st)return D;if(Ze){if(Et)for(ie=C.call(L.ownerDocument);L.firstChild;)ie.appendChild(L.firstChild);else ie=L;return(G.shadowroot||G.shadowrootmode)&&(ie=y.call(i,ie,!0)),ie}let de=Ne?L.outerHTML:L.innerHTML;return Ne&&J["!doctype"]&&L.ownerDocument&&L.ownerDocument.doctype&&L.ownerDocument.doctype.name&&ae(Na,L.ownerDocument.doctype.name)&&(de="<!DOCTYPE "+L.ownerDocument.doctype.name+`>
64
+ `+de),Ve&&Nt([$,H,X],Ce=>{de=pt(de,Ce," ")}),E&&Lt?E.createHTML(de):de},t.setConfig=function(){let D=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};hn(D),an=!0},t.clearConfig=function(){Ye=null,an=!1},t.isValidAttribute=function(D,f,L){Ye||hn({});const I=ee(D),K=ee(f);return Lr(I,K,L)},t.addHook=function(D,f){typeof f=="function"&&ht(R[D],f)},t.removeHook=function(D,f){if(f!==void 0){const L=ac(R[D],f);return L===-1?void 0:lc(R[D],L,1)[0]}return vi(R[D])},t.removeHooks=function(D){R[D]=[]},t.removeAllHooks=function(){R=wi()},t}var wc=Oa();function Le({content:e,className:t,style:r}){if(!e)return null;const i=W.parse(e,{breaks:!0,gfm:!0}),a=wc.sanitize(i,{ALLOWED_TAGS:["h1","h2","h3","h4","h5","h6","p","br","hr","strong","em","b","i","u","code","pre","ul","ol","li","blockquote","a","table","thead","tbody","tr","th","td","span","div"],ALLOWED_ATTR:["href","target","rel","class"]});return n("div",{className:t,style:r,dangerouslySetInnerHTML:{__html:a}})}const Yt=[{color:"#b48b7f",soft:"rgba(180, 139, 127, 0.12)"},{color:"#9d8792",soft:"rgba(157, 135, 146, 0.12)"},{color:"#7f9a9a",soft:"rgba(127, 154, 154, 0.12)"},{color:"#a9957a",soft:"rgba(169, 149, 122, 0.12)"},{color:"#8a859d",soft:"rgba(138, 133, 157, 0.12)"}];function Sc(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return Math.abs(t)}function Si(e){return Yt[Sc(e)%Yt.length]}function Tc(e){return typeof e.durationSeconds=="number"?e.durationSeconds:Math.max(0,Math.round((Date.now()-new Date(e.startedAt).getTime())/1e3))}function Ti(e){const t=Tc(e);if(t<60)return`${t}s`;const r=Math.floor(t/60),i=t%60;return`${r}m ${i}s`}function vt(e){return e==="completed"?"completed":e==="cancelled"||e==="failed"||e==="timeout"?"failed":e==="pending"?"pending":"running"}function Cc(e){return e?new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"--:--"}function Ci(e){return e==="completed"?n(Re,{size:20}):e==="cancelled"?n(it,{size:20}):e==="failed"||e==="timeout"?n(it,{size:20}):n(ue,{size:20})}function Sn(e){var t;return e.agent==="team-coordinator"?"TEAM":((t=e.agent)==null?void 0:t.toUpperCase())||"CLAUDE"}function Tn(e){return e.modelLabel?e.modelLabel:e.model?e.model.includes("/")?e.model.split("/").slice(1).join("/"):e.model:`${e.agent||"agent"} default`}function Cn(e){return e.effort||"effort default"}function Ac(){const[e,t]=w([]),[r,i]=w(0),[a,l]=w(!0),[o,s]=w(0),[d,c]=w(new Set),[m]=w(()=>Yt[Math.floor(Math.random()*Yt.length)]),p=10;j(()=>{v();const h=setInterval(v,3e3);return()=>clearInterval(h)},[]);async function v(){try{const[h,_]=await Promise.all([zs(),ir().catch(()=>null)]);t(h.agents??[]),_&&i(_.today.totalCost)}catch{}finally{l(!1)}}async function g(h){if(!d.has(h)){c(_=>new Set(_).add(h));try{await Us(h),await v()}catch{}finally{c(_=>{const E=new Set(_);return E.delete(h),E})}}}const u=ve(()=>{const h=new Map;for(const _ of e){if(!_.parentTaskId)continue;const E=h.get(_.parentTaskId)??[];E.push(_),h.set(_.parentTaskId,E)}return h},[e]),b=ve(()=>e.filter(h=>!h.parentTaskId),[e]),S=ve(()=>{const h=o*p;return b.slice(h,h+p)},[b,o]);j(()=>{const h=Math.max(0,Math.ceil(b.length/p)-1);o>h&&s(h)},[b.length,o]);const k=ve(()=>{const h=b.filter(M=>vt(M.status)==="running").length,_=b.filter(M=>vt(M.status)==="completed").length,E=b.filter(M=>vt(M.status)==="failed").length;return{running:h,completed:_,failed:E,cost:r}},[b,r]);return n("div",{class:"coding-page",style:{"--coding-accent":m.color,"--coding-accent-soft":m.soft},children:[n("div",{class:"page-header",children:[n("div",{class:"page-title",children:"Coding Agent"}),n("div",{class:"header-actions",children:[n("div",{class:"coding-refresh-pill",children:[n("span",{class:"dot"})," Auto-refresh 3s"]}),n("button",{class:"btn-refresh",onClick:v,children:[n(ue,{size:14})," Refresh"]})]})]}),a&&e.length===0?n("div",{style:{display:"flex",justifyContent:"center",padding:"48px"},children:n("div",{class:"spinner"})}):b.length===0?n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(tr,{size:18})}),n("div",{class:"empty-state-text",children:"No coding agent sessions"})]}):n("div",{class:"coding-body",children:[n("div",{class:"coding-stats-grid",children:[n("div",{class:"coding-stat-card",children:[n("div",{class:"coding-stat-icon running",children:n(ue,{size:14})}),n("div",{class:"coding-stat-content",children:[n("div",{class:"coding-stat-value",children:k.running}),n("div",{class:"coding-stat-label",children:"Running"})]})]}),n("div",{class:"coding-stat-card",children:[n("div",{class:"coding-stat-icon completed",children:n(Re,{size:14})}),n("div",{class:"coding-stat-content",children:[n("div",{class:"coding-stat-value",children:k.completed}),n("div",{class:"coding-stat-label",children:"Completed"})]})]}),n("div",{class:"coding-stat-card",children:[n("div",{class:"coding-stat-icon failed",children:n(it,{size:14})}),n("div",{class:"coding-stat-content",children:[n("div",{class:"coding-stat-value",children:k.failed}),n("div",{class:"coding-stat-label",children:"Failed"})]})]}),n("div",{class:"coding-stat-card",children:[n("div",{class:"coding-stat-icon cost",children:n(Be,{size:14})}),n("div",{class:"coding-stat-content",children:[n("div",{class:"coding-stat-value",children:["$",k.cost.toFixed(2)]}),n("div",{class:"coding-stat-label",children:"Cost today"})]})]})]}),S.map(h=>{const _=u.get(h.id)??[],E=h.liveOutput||h.outputPreview,M=vt(h.status),P=M==="running",T=Si(h.id);return n("div",{class:`coding-task-card ${M}`,style:{"--card-accent":T.color,"--card-accent-soft":T.soft},children:[n("div",{class:"coding-task-main",children:[n("div",{class:`coding-task-icon ${M}`,children:Ci(h.status)}),n("div",{class:"coding-task-content",children:[n("div",{class:"coding-task-pills",children:[n("span",{class:"coding-pill id",children:h.id}),n("span",{class:"coding-pill",children:h.agent==="team-coordinator"?`${Sn(h)} (${_.length})`:Sn(h)}),n("span",{class:"coding-pill model",title:h.modelLabel||h.model||"",children:Tn(h)}),n("span",{class:"coding-pill effort",children:Cn(h)}),n("span",{class:`coding-pill status ${M}`,children:h.status})]}),n(Le,{content:h.task,className:"coding-task-title markdown-content"}),n("div",{class:"coding-task-submeta",children:[n("span",{children:Tn(h)}),n("span",{children:"•"}),n("span",{children:Cn(h)}),n("span",{children:"•"}),n("span",{children:[n(He,{size:13})," ",Ti(h)]}),h.worktreePath?n(te,{children:[n("span",{children:"•"}),n("span",{title:h.worktreePath,children:["worktree",h.worktreeCleanup?`: ${h.worktreeCleanup.status}`:""]})]}):null,n("span",{children:"•"}),n("span",{class:"coding-pill",children:[h.totalCost!=null?`$${h.totalCost.toFixed(2)}`:"$--"," · ",h.inputTokens!=null||h.outputTokens!=null?`${((h.inputTokens??0)+(h.outputTokens??0)).toLocaleString()} tok`:"-- tok"]}),n("span",{children:Cc(h.startedAt)})]})]}),P?n("button",{class:`coding-task-action ${M}`,type:"button",disabled:d.has(h.id),onClick:()=>{g(h.id)},children:d.has(h.id)?"Cancelling…":"Cancel"}):null]}),n("div",{class:`coding-task-progress ${M}`}),_.length>0&&n("details",{class:"coding-subagents",open:!0,children:[n("summary",{children:[n(Ft,{size:14})," Subagents (",_.length,")"]}),n("div",{class:"coding-subagents-list",children:_.map(C=>{const x=vt(C.status),y=Si(C.id),R=C.liveOutput||C.outputPreview;return n("details",{class:`coding-subagent-card ${x}`,style:{"--card-accent":y.color,"--card-accent-soft":y.soft},open:C.status==="running"||C.status==="validating",children:[n("summary",{class:"coding-subagent-header",children:[n("span",{class:"coding-subagent-chevron",children:n(Ft,{size:13})}),n("span",{class:`coding-subagent-icon ${x}`,children:Ci(C.status)}),n("span",{class:"audit-id",children:C.id}),n("span",{class:"coding-pill",children:Sn(C)}),n("span",{class:"coding-pill model",title:C.model||"",children:Tn(C)}),n("span",{class:"coding-pill effort",children:Cn(C)}),n("span",{class:`ca-status-badge ${C.status}`,children:C.status}),C.wave!=null&&n("span",{class:"coding-pill",children:["Wave ",C.wave+1]}),C.retryCount?n("span",{class:"coding-pill",style:{color:"#d4a03c"},children:["retry #",C.retryCount]}):null,n("span",{class:"coding-pill",children:C.totalCost!=null?`$${C.totalCost.toFixed(2)}`:"$--"}),n("span",{class:"coding-subagent-time",children:[n(He,{size:12})," ",Ti(C)]}),C.status==="running"||C.status==="validating"?n("button",{class:`coding-task-action ${x}`,type:"button",disabled:d.has(C.id),onClick:$=>{$.preventDefault(),g(C.id)},style:{marginLeft:"auto",fontSize:"11px",padding:"2px 8px"},children:d.has(C.id)?"…":"Cancel"}):null]}),n("div",{class:"coding-subagent-body",children:[n(Le,{content:C.subtask||C.task,className:"coding-subagent-task markdown-content"}),R?n(Le,{content:R,className:`ca-output markdown-content ca-subagent-output${C.error?" ca-error":""}`}):null,!R&&C.error?n("div",{class:"ca-output ca-error",style:{fontSize:"12px",padding:"8px",whiteSpace:"pre-wrap"},children:C.error}):null,C.validationOutput?n("details",{class:"coding-validation-detail",children:[n("summary",{style:{fontSize:"11px",color:"var(--text-muted)",cursor:"pointer"},children:"Validation output"}),n("pre",{style:{fontSize:"11px",maxHeight:"200px",overflow:"auto",padding:"8px",background:"rgba(0,0,0,0.15)",borderRadius:"4px",margin:"4px 0"},children:C.validationOutput.slice(0,2e3)})]}):null]})]},C.id)})})]}),n("details",{class:"coding-output",children:[n("summary",{children:[n(Ft,{size:14})," Live output"]}),E?n(Le,{content:E,className:`ca-output markdown-content${h.error?" ca-error":""}`}):null,!E&&h.error?n(Le,{content:h.error,className:"ca-output markdown-content ca-error"}):null,!E&&!h.error&&h.synthesisResult?n(Le,{content:h.synthesisResult,className:"ca-output markdown-content"}):null]})]},h.id)}),b.length>p&&n("div",{style:{display:"flex",justifyContent:"center",gap:"8px",padding:"12px"},children:[n("button",{class:"btn btn-sm",disabled:o===0,onClick:()=>s(h=>Math.max(0,h-1)),children:"Previous"}),n("span",{style:{fontSize:"12px",color:"var(--text-muted)",alignSelf:"center"},children:[o*p+1,"–",Math.min((o+1)*p,b.length)," of ",b.length]}),n("button",{class:"btn btn-sm",disabled:(o+1)*p>=b.length,onClick:()=>s(h=>h+1),children:"Next"})]})]})]})}function Ai(e){if(e==null)return e;if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e}function Ec(e){if(e.type==="tool_use"&&e.detail!=null){const t=Ai(e.detail);if(t!==null&&typeof t=="object"&&!Array.isArray(t)){const r=t,i=r.tool||r.name||r.toolName||"",a=r.tool!=null?"tool":r.name!=null?"name":r.toolName!=null?"toolName":"",o=Object.entries(r).filter(([s])=>s!==a).map(([s,d])=>{const c=typeof d=="string"?`"${d.length>60?d.slice(0,57)+"...":d}"`:typeof d=="object"&&d!==null?JSON.stringify(d).slice(0,60):String(d);return`${s}: ${c}`}).join(", ");return i?`${i}({${o}})`:`{${o}}`}}if(e.summary){if(e.detail!=null&&typeof e.detail=="object"){const t=Object.entries(e.detail).slice(0,3).map(([r,i])=>`${r}: ${typeof i=="object"?JSON.stringify(i):String(i)}`);if(t.length>0)return`${e.summary} — ${t.join(", ")}`}return e.summary}if(e.detail!=null){const t=Ai(e.detail);return typeof t=="string"?t:JSON.stringify(t).slice(0,80)}return""}function Lc(e){return e===void 0?"":e>=1e3?`${(e/1e3).toFixed(1)}s`:`${Math.round(e)}ms`}function $c(){const[e,t]=w([]),[r,i]=w(0),[a,l]=w(0),[o,s]=w(""),[d,c]=w(""),[m,p]=w("all"),[v,g]=w(!0),[u,b]=w(new Set),S=20;j(()=>{l(0)},[d]),j(()=>{k()},[a,d]),j(()=>{const y=Math.max(0,Math.ceil(r/S)-1);a>y&&l(y)},[a,r]);async function k(){g(!0);try{const y=await ma({limit:S,offset:a*S,trigger:d||void 0});t(y.traces??[]),i(y.total??0)}catch(y){console.error("[audit] load failed",y)}finally{g(!1)}}function h(y){if(y.endedAt){const R=new Date(y.endedAt).getTime()-new Date(y.startedAt).getTime();return R>=1e3?`${(R/1e3).toFixed(1)}s`:`${Math.max(0,Math.round(R))}ms`}return"running"}function _(y){return new Date(y).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}const E=o.trim().toLowerCase(),M=e.filter(y=>m!=="all"&&y.status!==m?!1:E?y.trigger.toLowerCase().includes(E)||y.traceId.toLowerCase().includes(E)||y.events.some($=>`${$.type} ${$.summary}`.toLowerCase().includes(E)):!0),P=e.filter(y=>{const R=new Date(y.startedAt),$=new Date;return R.getFullYear()===$.getFullYear()&&R.getMonth()===$.getMonth()&&R.getDate()===$.getDate()}).length;function T(y){var R;return((R=y.events.find($=>$.summary.trim()))==null?void 0:R.summary)??`${y.events.length} events`}function C(y){b(R=>{const $=new Set(R);return $.has(y)?$.delete(y):$.add(y),$})}function x(y){return y.events.length>0}return n("div",{class:"audit-page",children:[n("div",{class:"page-header",children:[n("div",{class:"page-title",children:"Audit Log"}),n("div",{class:"header-actions",children:[n("div",{class:"audit-header-meta",children:[P," traces today"]}),n("button",{class:"btn-refresh",onClick:()=>k(),children:[n(ue,{size:14})," Refresh"]})]})]}),v&&e.length===0?n("div",{style:{display:"flex",justifyContent:"center",padding:"48px"},children:n("div",{class:"spinner"})}):n(te,{children:[n("div",{class:"audit-filters-row",children:[n("label",{class:"audit-search",children:[n(Nn,{size:14}),n("input",{value:o,onInput:y=>s(y.target.value),placeholder:"Search traces, events, tools…"})]}),n("div",{class:"audit-filter-controls",children:[n("select",{class:"btn btn-sm",value:d,onChange:y=>c(y.target.value),children:[n("option",{value:"",children:"All triggers"}),n("option",{value:"telegram",children:"Telegram"}),n("option",{value:"discord",children:"Discord"}),n("option",{value:"cron",children:"Cron"}),n("option",{value:"gateway",children:"Gateway"}),n("option",{value:"dashboard",children:"Dashboard"}),n("option",{value:"system",children:"System"})]}),n("select",{class:"btn btn-sm",value:m,onChange:y=>p(y.target.value),children:[n("option",{value:"all",children:"All status"}),n("option",{value:"success",children:"OK"}),n("option",{value:"error",children:"Error"}),n("option",{value:"running",children:"Running"})]})]})]}),n("div",{class:"audit-timeline",children:M.length===0?n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(Nn,{size:18})}),n("div",{class:"empty-state-text",children:"No audit traces"})]}):M.map((y,R)=>n("div",{class:"audit-row",children:[n("div",{class:"audit-time-col",children:[n("div",{class:"audit-time",children:_(y.startedAt)}),R<M.length-1&&n("div",{class:"audit-time-line"})]}),n("div",{class:`audit-card${x(y)?" audit-card-expandable":""}`,children:[n("div",{class:"audit-card-head",...x(y)?{role:"button",tabIndex:0,"aria-expanded":u.has(y.traceId),"aria-label":`Toggle details for trace ${y.traceId.slice(0,8)}`,onClick:()=>C(y.traceId),onKeyDown:$=>{($.key==="Enter"||$.key===" ")&&($.preventDefault(),C(y.traceId))},style:{cursor:"pointer"}}:{},children:[n("div",{class:"audit-chip-row",children:[n("span",{class:`audit-chip trigger ${y.trigger}`,children:y.trigger.toUpperCase()}),n("span",{class:"audit-chip id",children:y.traceId.slice(0,8)}),n("span",{class:`audit-chip status ${y.status}`,children:y.status==="success"?"OK":y.status==="error"?"Error":"Running"})]}),n("div",{class:"audit-card-head-right",children:[n("div",{class:"audit-duration",children:h(y)}),x(y)&&n("span",{class:"audit-expand-icon",children:u.has(y.traceId)?n(Ft,{size:12}):n(Zl,{size:12})})]})]}),n("div",{class:"audit-title-line",children:T(y)}),y.events.length>0&&n("div",{class:"audit-event-pills",children:y.events.slice(0,4).map(($,H)=>n("span",{class:"audit-chip soft",children:[$.type,$.durationMs!==void 0?` ${$.durationMs}ms`:""]},`${y.traceId}-${H}`))}),u.has(y.traceId)&&x(y)&&n("div",{class:"audit-detail-section",children:y.events.map(($,H)=>n("div",{class:"audit-event-row",children:[n("span",{class:`audit-event-type-label${$.type==="tool_use"?" tool":""}`,children:$.type}),n("span",{class:`audit-event-content${$.type==="tool_use"?" mono":""}`,children:Ec($)}),n("span",{class:"audit-event-dur",children:Lc($.durationMs)})]},`${y.traceId}-detail-${H}`))})]})]},y.traceId))}),r>S&&n("div",{style:{display:"flex",justifyContent:"center",gap:"8px",padding:"12px"},children:[n("button",{class:"btn btn-sm",disabled:a===0||v,onClick:()=>l(y=>Math.max(0,y-1)),children:"Previous"}),n("span",{style:{fontSize:"12px",color:"var(--text-muted)",alignSelf:"center"},children:[r===0?0:a*S+1,"–",Math.min((a+1)*S,r)," of ",r]}),n("button",{class:"btn btn-sm",disabled:(a+1)*S>=r||v,onClick:()=>l(y=>y+1),children:"Next"})]})]})]})}function Rc(e){const t=Date.now()-new Date(e).getTime(),r=Math.floor(t/1e3);if(r<60)return`${r}s`;const i=Math.floor(r/60),a=r%60;return`${i}m ${a.toString().padStart(2,"0")}s`}function Ei(e){const t=new Date(e);return t.toLocaleDateString("en-US",{month:"short",day:"numeric"})+", "+t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"})}function Mc(e){if(e.status==="expired")return"Expired after 5m (no response)";const t=e.approvedBy||e.deniedBy||"unknown",r=e.status==="approved"?"Approved":"Denied";if(e.resolvedAt&&e.createdAt){const i=new Date(e.resolvedAt).getTime()-new Date(e.createdAt).getTime(),a=Math.floor(i/1e3),l=a<60?`${a}s`:`${Math.floor(a/60)}m ${a%60}s`;return`${r} by ${t} · ${l} after request`}return`${r} by ${t}`}function Li(e){var r;const t=(r=e.channelMeta)==null?void 0:r.channel;return t==="telegram"?"Telegram":t==="discord"?"Discord":t==="dashboard"?"Dashboard":t||"System"}function $i(e){var r;const t=(r=e.channelMeta)==null?void 0:r.channel;return t==="telegram"||t==="discord"?n(rt,{size:12}):t==="dashboard"?n(rt,{size:12}):n(tr,{size:12})}function Ri(e){return e?e.replace(/^\/Users\/[^/]+/,"~"):""}function Mi(e){return e===1?"tier-1":e===2?"tier-2":"tier-3"}function Ic({showToast:e,onCountChange:t}){const[r,i]=w([]),[a,l]=w([]),[o,s]=w(!0),[d,c]=w(new Set),[m,p]=w(null),v=$e(0),[,g]=w(0);j(()=>{u(),b();const h=setInterval(u,5e3),_=setInterval(()=>{v.current++,g(v.current)},1e3);return()=>{clearInterval(h),clearInterval(_)}},[]);async function u(){var h;try{const _=await va();i(_.pending??[]),l((_.recent??[]).filter(E=>E.status!=="pending")),t==null||t(((h=_.pending)==null?void 0:h.length)??0)}catch{}finally{s(!1)}}async function b(){var h,_,E,M,P,T,C,x;try{const y=(await rr()).config,R=(E=(_=(h=y.channels)==null?void 0:h.telegram)==null?void 0:_.tools)==null?void 0:E.execApproval,$=(T=(P=(M=y.channels)==null?void 0:M.discord)==null?void 0:P.tools)==null?void 0:T.execApproval,H=(x=(C=y.heartbeat)==null?void 0:C.tools)==null?void 0:x.execApproval,X=R||$||H||{},A=Array.isArray(X.requireForTiers)&&X.requireForTiers.length>0?X.requireForTiers:[2,3];p({enabled:X.enabled!==!1,ttlMs:Number(X.ttlMs)>0?Number(X.ttlMs):3e5,tiers:A})}catch{p(null)}}async function S(h,_){c(E=>new Set([...E,h]));try{_?(await _a(h),e("Command approved","success")):(await ba(h),e("Command denied","warning")),await u()}catch{e("Action failed","error")}finally{c(E=>{const M=new Set(E);return M.delete(h),M})}}function k(h){return h==="approved"?n(Re,{size:18}):h==="denied"?n(it,{size:18}):h==="expired"?n(ni,{size:18}):n(On,{size:18})}return n("div",{class:"approvals-page",children:[n("div",{class:"page-header",children:[n("div",{class:"page-title",children:"Approvals"}),n("div",{class:"header-actions",children:[n("span",{class:"appr-auto-refresh",children:[n("span",{class:"appr-auto-dot"})," Auto-refresh 5s"]}),n("button",{class:"btn-refresh",onClick:u,children:[n(ue,{size:14})," Refresh"]})]})]}),o?n("div",{style:{display:"flex",justifyContent:"center",padding:"48px"},children:n("div",{class:"spinner"})}):n(te,{children:[m&&n("div",{class:"card",style:{marginBottom:16},children:[n("div",{class:"card-title",style:{fontWeight:700,marginBottom:8},children:"Exec Approval Policy"}),n("div",{style:{fontSize:13,color:"var(--text-dim)",lineHeight:1.5},children:["Gate: ",n("strong",{children:m.enabled?"Enabled":"Disabled"})," · ","Tiers: ",n("strong",{children:m.tiers.map(h=>`T${h}`).join(", ")})," · ","TTL: ",n("strong",{children:[Math.round(m.ttlMs/1e3),"s"]})]}),n("div",{class:"appr-tier-legend",children:[n("span",{class:"appr-chip tier tier-1",children:"TIER 1"}),n("span",{class:"appr-tier-label",children:"Low risk"}),n("span",{class:"appr-chip tier tier-2",children:"TIER 2"}),n("span",{class:"appr-tier-label",children:"Dangerous / review required"}),n("span",{class:"appr-chip tier tier-3",children:"TIER 3"}),n("span",{class:"appr-tier-label",children:"Catastrophic / irreversible"})]})]}),n("div",{class:"appr-section-label",children:["PENDING (",r.length,")"]}),r.length===0?n("div",{class:"empty-state",style:{marginBottom:32},children:[n("div",{class:"empty-state-icon",children:n(ha,{size:18})}),n("div",{class:"empty-state-text",children:"No pending approvals"})]}):n("div",{class:"appr-list",children:r.map(h=>n("div",{class:"appr-item pending",children:[n("div",{class:"appr-item-border pending"}),n("div",{class:"appr-item-body",children:[n("div",{class:"appr-item-head",children:[n("div",{class:"appr-item-icon pending",children:n(On,{size:18})}),n("span",{class:"appr-item-id",children:["req-",h.id]}),n("span",{class:`appr-chip tier ${Mi(h.tier)}`,children:["TIER ",h.tier]}),n("span",{class:"appr-chip pending",children:"PENDING"}),n("span",{class:"appr-elapsed",children:[n(ni,{size:12})," ",Rc(h.createdAt)]}),n("div",{style:{flex:1}}),n("div",{class:"appr-actions",children:[n("button",{class:"approval-btn-deny",disabled:d.has(h.id),onClick:()=>S(h.id,!1),children:"Deny"}),n("button",{class:"approval-btn-approve",disabled:d.has(h.id),onClick:()=>S(h.id,!0),children:[n(Re,{size:14})," Approve"]})]})]}),n("div",{class:"appr-reason",children:h.reason}),n("div",{class:"appr-cmd-block",children:h.command}),n("div",{class:"appr-footer",children:[n("span",{class:"appr-footer-item",children:[$i(h)," via ",Li(h)]}),h.cwd&&n("span",{class:"appr-footer-sep",children:"·"}),h.cwd&&n("span",{class:"appr-footer-item",children:Ri(h.cwd)}),n("span",{class:"appr-footer-sep",children:"·"}),n("span",{class:"appr-footer-item",children:Ei(h.createdAt)})]})]})]},h.id))}),a.length>0&&n(te,{children:[n("div",{class:"appr-section-label",style:{marginTop:32},children:"RECENT HISTORY"}),n("div",{class:"appr-list",children:a.slice(0,30).map(h=>n("div",{class:`appr-item ${h.status}`,children:[n("div",{class:`appr-item-border ${h.status}`}),n("div",{class:"appr-item-body",children:[n("div",{class:"appr-item-head",children:[n("div",{class:`appr-item-icon ${h.status}`,children:k(h.status)}),n("span",{class:"appr-item-id",children:["req-",h.id]}),n("span",{class:`appr-chip tier ${Mi(h.tier)}`,children:["TIER ",h.tier]}),n("span",{class:`appr-chip ${h.status}`,children:h.status.toUpperCase()})]}),n("div",{class:"appr-reason",children:h.reason}),n("div",{class:"appr-cmd-block",children:h.command}),n("div",{class:"appr-footer",children:[n("span",{class:"appr-footer-item",children:[$i(h)," via ",Li(h)]}),h.cwd&&n("span",{class:"appr-footer-sep",children:"·"}),h.cwd&&n("span",{class:"appr-footer-item",children:Ri(h.cwd)}),n("span",{class:"appr-footer-sep",children:"·"}),n("span",{class:"appr-footer-item",children:Ei(h.createdAt)}),n("span",{class:"appr-footer-sep",children:"·"}),n("span",{class:"appr-footer-resolution",children:Mc(h)})]})]})]},h.id))})]})]})]})}const Ii="main";function Dc(){const[e,t]=w([]),[r,i]=w(null),[a,l]=w(""),[o,s]=w(!0),[d,c]=w(!1);j(()=>{m()},[]);async function m(){s(!0);try{const v=await Rs(Ii);t(v.files??[])}catch(v){console.error("[memory] load failed",v)}finally{s(!1)}}async function p(v){i(v),c(!0);try{const g=await Ms(Ii,v);l(g.content??"")}catch(g){console.error("[memory] file load failed",g),l("")}finally{c(!1)}}return n("div",{class:"templates-page",children:[n("div",{class:"templates-header",children:[n("div",{class:"page-title",children:"Memory"}),n("div",{class:"header-actions",style:{display:"flex",gap:10,alignItems:"center"},children:n("button",{class:"btn-refresh",onClick:m,children:[n(ue,{size:14})," Refresh"]})})]}),o?n("div",{class:"templates-loading",children:n("div",{class:"spinner"})}):e.length===0?n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(Pn,{size:18})}),n("div",{class:"empty-state-text",children:"No memory files found"})]}):n("div",{class:"templates-layout",children:[n("div",{class:"templates-sidebar",children:n("div",{class:"templates-list",children:e.map(v=>n("button",{class:`templates-list-item${r===v.name?" active":""}`,onClick:()=>p(v.name),children:[n("div",{class:"templates-list-icon",children:v.name.substring(0,2).toUpperCase()}),n("div",{class:"templates-list-content",children:[n("div",{class:"templates-list-title",children:v.name}),n("div",{class:"templates-list-meta",children:[(v.size/1024).toFixed(1)," KB"]})]})]},v.name))})}),n("div",{class:"templates-main",children:r?d?n("div",{class:"templates-loading",children:n("div",{class:"spinner"})}):n("div",{class:"templates-content",children:n("div",{class:"templates-markdown-preview",children:n(Qt,{content:a})})}):n("div",{class:"templates-empty",children:[n(Pn,{size:32}),n("p",{children:"Select a file to view"})]})})]})]})}const Pc=/^[A-Za-z0-9._-]+\/[A-Za-z0-9._/-]+$/,Nc=/^[A-Za-z0-9.-]+$/,Oc=/^[A-Za-z0-9._/-]+$/;function zc(e,t){return t[e]?{ok:!0}:Pc.test(e)?{ok:!0}:Nc.test(e)&&/[-.]/.test(e)?{ok:!0}:!Oc.test(e)||e.includes("/")?{ok:!1,error:`Invalid model selection: "${e}". Use alias, provider/model, or model-id.`}:{ok:!1,error:`Unknown model alias: "${e}"`}}function Uc({showToast:e}){const[t,r]=w(""),[i,a]=w(""),[l,o]=w({}),[s,d]=w(!0),[c,m]=w(!1);j(()=>{p()},[]);async function p(){d(!0);try{const g=await Ts();r(g.current??""),a(g.current??""),o(g.aliases??{})}catch(g){console.error("[model] load failed",g)}finally{d(!1)}}async function v(){const g=i.trim();if(!g)return;const u=zc(g,l);if(!u.ok){e(u.error,"error");return}m(!0);try{const b=await Cs(g);r(b.model),a(b.model),e("Model updated","success")}catch{e("Failed to update model","error")}finally{m(!1)}}return n("div",{children:[n("div",{class:"page-header",children:n("div",{class:"page-title",children:"Model"})}),s?n("div",{style:{display:"flex",justifyContent:"center",padding:"48px"},children:n("div",{class:"spinner"})}):n("div",{style:{maxWidth:560},children:n("div",{class:"feed-card",style:{padding:"28px 32px"},children:[n("div",{style:{marginBottom:20},children:[n("div",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:600,marginBottom:8,textTransform:"uppercase",letterSpacing:"0.06em"},children:"Active Model"}),n("div",{style:{fontFamily:"var(--mono)",fontSize:15,color:"var(--accent)",fontWeight:600},children:t||"—"})]}),n("div",{style:{marginBottom:20},children:[n("div",{style:{fontSize:12,color:"var(--text-muted)",fontWeight:600,marginBottom:8,textTransform:"uppercase",letterSpacing:"0.06em"},children:"Switch Model"}),n("input",{type:"text",value:i,onInput:g=>a(g.target.value),placeholder:"Model ID or alias",style:{width:"100%",padding:"10px 14px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border)",background:"var(--surface-alt)",color:"var(--text)",fontFamily:"var(--mono)",fontSize:14,marginBottom:14,outline:"none"}}),n("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginBottom:16},children:Object.entries(l).sort(([g],[u])=>g.localeCompare(u)).map(([g,u])=>n("button",{class:`btn btn-sm${i===g?" btn-primary":""}`,onClick:()=>a(g),title:u,children:g},g))}),n("button",{class:"btn btn-primary",onClick:v,disabled:c||!i.trim(),children:c?"Saving…":"Switch Model"})]})]})})]})}const An={alias:"",agentId:"",model:"",thinking:"",promptOverlay:""},Bc=["","none","low","medium","high","xhigh"];function Di(e){return{alias:e.alias,agentId:e.agentId,model:e.model||"",thinking:e.thinking||"",promptOverlay:e.promptOverlay||""}}function Fc(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function Hc({showToast:e}){const[t,r]=w(null),[i,a]=w(""),[l,o]=w(An),[s,d]=w(!1),[c,m]=w(!0),[p,v]=w(!1);j(()=>{b()},[]);const g=ve(()=>(t==null?void 0:t.profiles.find(T=>T.alias===i))||null,[t,i]),u=ve(()=>{const T=new Map;for(const C of(t==null?void 0:t.bindings)||[])T.set(C.profileAlias,(T.get(C.profileAlias)||0)+1);return T},[t]);async function b(T){var C;m(!0);try{const x=await As();r(x);const y=T||i||((C=x.profiles[0])==null?void 0:C.alias)||"";a(y);const R=x.profiles.find($=>$.alias===y);o(R?Di(R):{...An,agentId:Object.keys(x.configuredAgents)[0]||""}),!R&&x.profiles.length===0&&d(!0)}catch{e("Failed to load agents","error")}finally{m(!1)}}function S(){const T=Object.keys((t==null?void 0:t.configuredAgents)||{})[0]||"";d(!0),a(""),o({...An,agentId:T})}async function k(){const T=l.alias.trim().replace(/^@/,"").toLowerCase(),C=l.agentId.trim();if(!(!T||!C)){v(!0);try{s&&await Es(T,C),await Ls(T,{agentId:C,model:l.model.trim()||void 0,thinking:l.thinking||void 0,promptOverlay:l.promptOverlay}),d(!1),e(`Saved @${T}`,"success"),await b(T)}catch{e("Failed to save agent profile","error")}finally{v(!1)}}}async function h(T){if(window.confirm(`Delete @${T}?`)){v(!0);try{await $s(T),e(`Deleted @${T}`,"warning"),a(""),await b()}catch{e("Failed to delete agent profile","error")}finally{v(!1)}}}function _(T){d(!1),a(T.alias),o(Di(T))}const E=(t==null?void 0:t.configuredAgents)||{},M=(t==null?void 0:t.modelAliases)||{},P=E[l.agentId];return n("div",{children:[n("div",{class:"page-header",children:[n("div",{class:"page-title",children:"Agents"}),n("div",{class:"header-actions",children:[n("button",{class:"btn btn-sm",onClick:S,children:[n(as,{size:14})," New"]}),n("button",{class:"btn-refresh",onClick:()=>void b(),children:[n(ue,{size:14})," Refresh"]})]})]}),c?n("div",{style:{display:"flex",justifyContent:"center",padding:"48px"},children:n("div",{class:"spinner"})}):n("div",{class:"agents-layout",children:[n("div",{class:"agents-list",children:((t==null?void 0:t.profiles)||[]).length===0?n("div",{class:"empty-state agents-empty",children:[n("div",{class:"empty-state-icon",children:n(Gl,{size:18})}),n("div",{class:"empty-state-text",children:"No agent profiles"})]}):t.profiles.map(T=>{const C=T.alias===i&&!s,x=E[T.agentId];return n("button",{class:`agent-profile-item${C?" active":""}`,onClick:()=>_(T),children:[n("span",{class:"agent-profile-icon",children:(x==null?void 0:x.emoji)||"@"}),n("span",{class:"agent-profile-main",children:[n("span",{class:"agent-profile-alias",children:["@",T.alias]}),n("span",{class:"agent-profile-meta",children:[T.agentId," · ",T.model||(x==null?void 0:x.model)||"model inherit"]})]}),n("span",{class:"agent-profile-count",children:u.get(T.alias)||0})]},T.alias)})}),n("div",{class:"agents-editor card",children:[n("div",{class:"agents-editor-header",children:[n("div",{children:[n("div",{class:"card-title",children:s?"New Profile":g?`@${g.alias}`:"Profile"}),n("div",{class:"agent-editor-subtitle",children:g?`Updated ${Fc(g.updatedAt)}`:"Discord profile"})]}),g&&!s?n("button",{class:"btn btn-sm btn-danger",onClick:()=>void h(g.alias),disabled:p,children:[n(us,{size:13})," Delete"]}):null]}),n("div",{class:"form-grid two",children:[n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Alias"}),n("input",{value:l.alias,disabled:!s,onInput:T=>o(C=>({...C,alias:T.target.value})),placeholder:"reviewer"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Configured agent"}),n("select",{value:l.agentId,onChange:T=>o(C=>({...C,agentId:T.target.value})),children:Object.entries(E).map(([T,C])=>n("option",{value:T,children:[C.emoji?`${C.emoji} `:"",T]},T))})]})]}),n("div",{class:"agent-inherit-row",children:[n("span",{children:(P==null?void 0:P.name)||l.agentId||"agent"}),n("code",{children:(P==null?void 0:P.model)||"model inherit"}),n("code",{children:(P==null?void 0:P.thinking)||"effort inherit"})]}),n("div",{class:"form-grid two",children:[n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Model override"}),n("input",{value:l.model,onInput:T=>o(C=>({...C,model:T.target.value})),placeholder:"inherit"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Effort override"}),n("select",{value:l.thinking,onChange:T=>o(C=>({...C,thinking:T.target.value})),children:Bc.map(T=>n("option",{value:T,children:T||"inherit"},T||"inherit"))})]})]}),n("div",{class:"agent-model-aliases",children:Object.entries(M).sort(([T],[C])=>T.localeCompare(C)).slice(0,14).map(([T,C])=>n("button",{class:"btn btn-sm",title:C,onClick:()=>o(x=>({...x,model:T})),children:T},T))}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Prompt overlay"}),n("textarea",{class:"agents-prompt",value:l.promptOverlay,onInput:T=>o(C=>({...C,promptOverlay:T.target.value})),placeholder:"Additional behavior for this profile"})]}),n("div",{class:"form-actions",children:n("button",{class:"btn btn-primary",onClick:()=>void k(),disabled:p||!l.alias.trim()||!l.agentId.trim(),children:[n(ls,{size:14})," ",p?"Saving...":"Save Profile"]})})]})]})]})}function jc(){const[e,t]=w([]),[r,i]=w(null),[a,l]=w(""),[o,s]=w(!0),[d,c]=w(!1);j(()=>{m()},[]);async function m(){s(!0);try{const v=await Ns();t(v.files??[])}catch(v){console.error("[logs] load failed",v)}finally{s(!1)}}async function p(v){i(v),c(!0);try{const g=await Os(`logs/${encodeURIComponent(v.name)}`);l(g.content??"")}catch(g){console.error("[logs] file load failed",g),l("Error loading log file.")}finally{c(!1)}}return n("div",{children:[n("div",{class:"page-header",children:[n("div",{class:"page-title",children:"Logs"}),n("div",{class:"header-actions",children:n("button",{class:"btn-refresh",onClick:m,children:[n(ue,{size:14})," Refresh"]})})]}),o?n("div",{style:{display:"flex",justifyContent:"center",padding:"48px"},children:n("div",{class:"spinner"})}):e.length===0?n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(je,{size:18})}),n("div",{class:"empty-state-text",children:"No log files found"})]}):n("div",{style:{display:"grid",gridTemplateColumns:"240px 1fr",gap:20},children:[n("div",{class:"feed-card",style:{height:"fit-content",overflow:"hidden"},children:n("div",{class:"feed",children:e.map(v=>n("button",{style:{display:"block",width:"100%",textAlign:"left",padding:"12px 16px",border:"none",borderBottom:"1px solid var(--border-light)",background:(r==null?void 0:r.name)===v.name?"var(--accent-soft)":"transparent",cursor:"pointer",fontFamily:"var(--sans)",color:(r==null?void 0:r.name)===v.name?"var(--accent)":"var(--text-dim)"},onClick:()=>p(v),children:[n("div",{style:{fontWeight:600,fontSize:13,marginBottom:2},children:v.name}),n("div",{style:{fontSize:11,color:"var(--text-muted)",fontFamily:"var(--mono)"},children:[(v.size/1024).toFixed(1)," KB"]})]},v.name))})}),n("div",{class:"feed-card",style:{padding:"20px 24px",maxHeight:"70vh",overflow:"auto"},children:r?d?n("div",{style:{display:"flex",justifyContent:"center",padding:"32px"},children:n("div",{class:"spinner"})}):n("div",{style:{fontFamily:"var(--mono)",fontSize:12,lineHeight:1.6},children:a.split(`
65
+ `).map((v,g)=>n("div",{style:{color:v.toLowerCase().includes("error")?"var(--log-error)":v.toLowerCase().includes("warn")?"var(--log-warn)":"var(--log-info)",padding:"1px 0"},children:v||" "},g))}):n("div",{class:"empty-state",style:{padding:"32px 0"},children:n("div",{class:"empty-state-text",children:"Select a log file to view"})})})]})]})}function Wc(e){var o,s,d,c,m,p,v,g;const t=(d=(s=(o=e.channels)==null?void 0:o.telegram)==null?void 0:s.tools)==null?void 0:d.execApproval,r=(p=(m=(c=e.channels)==null?void 0:c.discord)==null?void 0:m.tools)==null?void 0:p.execApproval,i=(g=(v=e.heartbeat)==null?void 0:v.tools)==null?void 0:g.execApproval,a=t||r||i||{},l=Array.isArray(a.requireForTiers)&&a.requireForTiers.length>0?a.requireForTiers:[2,3];return{enabled:a.enabled!==!1,ttlMs:Number(a.ttlMs)>0?Number(a.ttlMs):3e5,requireForTiers:l}}function qc({showToast:e}){const[t,r]=w(null),[i,a]=w(!0),[l,o]=w(!1),[s,d]=w(!1),[c,m]=w({gatewayHost:"127.0.0.1",gatewayPort:"18790",gatewayMode:"local",activeChannel:"",telegramEnabled:!0,discordEnabled:!1,agentsDefault:"main",heartbeatIntervalMs:"300000",heartbeatPrompt:"",heartbeatModel:"",execApprovalEnabled:!0,execApprovalTtlMs:"300000",execApprovalTier1:!1,execApprovalTier2:!0,execApprovalTier3:!0});j(()=>{p()},[]);async function p(){var u,b,S,k,h,_,E,M,P,T,C,x,y;a(!0);try{const $=(await rr()).config??{},H=Wc($);r($),m({gatewayHost:((u=$.gateway)==null?void 0:u.host)??"127.0.0.1",gatewayPort:String(((b=$.gateway)==null?void 0:b.port)??18790),gatewayMode:((S=$.gateway)==null?void 0:S.mode)==="remote"?"remote":"local",activeChannel:((k=$.channels)==null?void 0:k.active)==="telegram"||((h=$.channels)==null?void 0:h.active)==="discord"?$.channels.active:"",telegramEnabled:!!((E=(_=$.channels)==null?void 0:_.telegram)!=null&&E.enabled),discordEnabled:!!((P=(M=$.channels)==null?void 0:M.discord)!=null&&P.enabled),agentsDefault:((T=$.agents)==null?void 0:T.default)??"main",heartbeatIntervalMs:String(((C=$.heartbeat)==null?void 0:C.intervalMs)??3e5),heartbeatPrompt:((x=$.heartbeat)==null?void 0:x.prompt)??"",heartbeatModel:((y=$.heartbeat)==null?void 0:y.model)??"",execApprovalEnabled:H.enabled,execApprovalTtlMs:String(H.ttlMs),execApprovalTier1:H.requireForTiers.includes(1),execApprovalTier2:H.requireForTiers.includes(2),execApprovalTier3:H.requireForTiers.includes(3)})}catch(R){console.error("[config] load failed",R),e("Failed to load config","error")}finally{a(!1)}}async function v(){d(!0);try{await js(),e("Config reloaded","success"),await p()}catch(u){console.error("[config] reload failed",u),e("Reload failed","error")}finally{d(!1)}}async function g(){if(!t)return;const u=structuredClone(t);u.gateway=u.gateway||{},u.channels=u.channels||{},u.channels.telegram=u.channels.telegram||{},u.channels.discord=u.channels.discord||{},u.channels.telegram.tools=u.channels.telegram.tools||{},u.channels.discord.tools=u.channels.discord.tools||{},u.agents=u.agents||{},u.heartbeat=u.heartbeat||{},u.heartbeat.tools=u.heartbeat.tools||{},u.cron=u.cron||{jobs:[]},u.models=u.models||{providers:{},aliases:{}},u.gateway.host=c.gatewayHost.trim()||"127.0.0.1",u.gateway.port=Number(c.gatewayPort)||18790,u.gateway.mode=c.gatewayMode,c.activeChannel?u.channels.active=c.activeChannel:delete u.channels.active,u.channels.telegram.enabled=c.telegramEnabled,u.channels.discord.enabled=c.discordEnabled,u.agents.default=c.agentsDefault.trim()||"main",u.heartbeat.intervalMs=Number(c.heartbeatIntervalMs)||3e5,u.heartbeat.prompt=c.heartbeatPrompt,u.heartbeat.model=c.heartbeatModel.trim()||void 0;const b=[1,2,3].filter(k=>k===1?c.execApprovalTier1:k===2?c.execApprovalTier2:c.execApprovalTier3);b.length===0&&b.push(2,3);const S={enabled:c.execApprovalEnabled,ttlMs:Number(c.execApprovalTtlMs)||3e5,requireForTiers:b};u.channels.telegram.tools.execApproval=S,u.channels.discord.tools.execApproval=S,u.heartbeat.tools.execApproval=S,o(!0);try{await ya(u),r(u),e("Config saved","success")}catch(k){console.error("[config] save failed",k),e("Failed to save config","error")}finally{o(!1)}}return n("div",{children:[n("div",{class:"page-header",children:[n("div",{class:"page-title",children:"Config"}),n("div",{class:"header-actions",children:[n("button",{class:"btn btn-sm",onClick:()=>void v(),disabled:s,children:s?"Reloading…":"Reload"}),n("button",{class:"btn btn-sm btn-primary",onClick:()=>void g(),disabled:l,children:l?"Saving…":"Save"})]})]}),i?n("div",{style:{display:"flex",justifyContent:"center",padding:"48px"},children:n("div",{class:"spinner"})}):n("div",{style:{display:"grid",gap:14},children:[n("div",{class:"card",children:[n("div",{class:"card-title",style:{fontWeight:700},children:"Gateway"}),n("div",{class:"form-grid three",children:[n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Host"}),n("input",{value:c.gatewayHost,onInput:u=>m(b=>({...b,gatewayHost:u.target.value})),placeholder:"127.0.0.1"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Port"}),n("input",{value:c.gatewayPort,onInput:u=>m(b=>({...b,gatewayPort:u.target.value})),placeholder:"18790"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Mode"}),n("select",{value:c.gatewayMode,onChange:u=>m(b=>({...b,gatewayMode:u.target.value})),children:[n("option",{value:"local",children:"local"}),n("option",{value:"remote",children:"remote"})]})]})]})]}),n("div",{class:"card",children:[n("div",{class:"card-title",style:{fontWeight:700},children:"Channels"}),n("div",{class:"form-grid",children:[n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Active channel"}),n("select",{value:c.activeChannel,onChange:u=>m(b=>({...b,activeChannel:u.target.value})),children:[n("option",{value:"",children:"auto"}),n("option",{value:"telegram",children:"telegram"}),n("option",{value:"discord",children:"discord"})]})]}),n("div",{class:"form-check-row",children:[n("label",{class:"form-checkbox",children:[n("input",{type:"checkbox",checked:c.telegramEnabled,onChange:u=>m(b=>({...b,telegramEnabled:u.target.checked}))}),"Telegram enabled"]}),n("label",{class:"form-checkbox",children:[n("input",{type:"checkbox",checked:c.discordEnabled,onChange:u=>m(b=>({...b,discordEnabled:u.target.checked}))}),"Discord enabled"]})]})]})]}),n("div",{class:"card",children:[n("div",{class:"card-title",style:{fontWeight:700},children:"Agent"}),n("div",{class:"form-grid",children:n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Default agent"}),n("input",{value:c.agentsDefault,onInput:u=>m(b=>({...b,agentsDefault:u.target.value})),placeholder:"main"})]})})]}),n("div",{class:"card",children:[n("div",{class:"card-title",style:{fontWeight:700},children:"Heartbeat"}),n("div",{class:"form-grid two",style:{marginBottom:10},children:[n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Interval (ms)"}),n("input",{value:c.heartbeatIntervalMs,onInput:u=>m(b=>({...b,heartbeatIntervalMs:u.target.value})),placeholder:"300000"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Model override"}),n("input",{value:c.heartbeatModel,onInput:u=>m(b=>({...b,heartbeatModel:u.target.value})),placeholder:"optional"})]})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Prompt"}),n("textarea",{value:c.heartbeatPrompt,onInput:u=>m(b=>({...b,heartbeatPrompt:u.target.value})),placeholder:"Heartbeat prompt",style:{minHeight:120}})]})]}),n("div",{class:"card",children:[n("div",{class:"card-title",style:{fontWeight:700},children:"Exec Approvals"}),n("div",{class:"form-grid",style:{marginBottom:10},children:[n("div",{class:"form-check-col",children:[n("span",{class:"form-label",children:"Gate"}),n("label",{class:"form-checkbox",children:[n("input",{type:"checkbox",checked:c.execApprovalEnabled,onChange:u=>m(b=>({...b,execApprovalEnabled:u.target.checked}))}),"Enable approval gate"]})]}),n("label",{class:"form-field",style:{maxWidth:260},children:[n("span",{class:"form-label",children:"Approval TTL (ms)"}),n("input",{value:c.execApprovalTtlMs,onInput:u=>m(b=>({...b,execApprovalTtlMs:u.target.value})),placeholder:"300000",disabled:!c.execApprovalEnabled})]})]}),n("div",{class:"form-check-row tight",children:[n("label",{class:"form-checkbox",children:[n("input",{type:"checkbox",checked:c.execApprovalTier1,onChange:u=>m(b=>({...b,execApprovalTier1:u.target.checked}))}),"Require approval for Tier 1"]}),n("label",{class:"form-checkbox",children:[n("input",{type:"checkbox",checked:c.execApprovalTier2,onChange:u=>m(b=>({...b,execApprovalTier2:u.target.checked}))}),"Require approval for Tier 2"]}),n("label",{class:"form-checkbox",children:[n("input",{type:"checkbox",checked:c.execApprovalTier3,onChange:u=>m(b=>({...b,execApprovalTier3:u.target.checked}))}),"Require approval for Tier 3"]})]}),n("div",{style:{marginTop:8,fontSize:12,color:"var(--text-muted)"},children:"Applied to Telegram, Discord, and Heartbeat tool execution."}),n("div",{class:"appr-tier-legend",style:{marginTop:10},children:[n("span",{class:"appr-chip tier tier-1",children:"TIER 1"}),n("span",{class:"appr-tier-label",children:"Low risk operations"}),n("span",{class:"appr-chip tier tier-2",children:"TIER 2"}),n("span",{class:"appr-tier-label",children:"Dangerous operations"}),n("span",{class:"appr-chip tier tier-3",children:"TIER 3"}),n("span",{class:"appr-tier-label",children:"Catastrophic operations"})]})]})]})]})}function Gc(){var g;const[e,t]=w([]),[r,i]=w(null),[a,l]=w(null),[o,s]=w(!0),[d,c]=w(!1);j(()=>{m()},[]);async function m(){s(!0);try{const u=await Ws();t(u.digests??[])}finally{s(!1)}}async function p(u){i(u),c(!0);try{const b=await qs(u);l(b)}catch{l(null)}finally{c(!1)}}function v(u){return new Date(u).toLocaleString()}return n("div",{children:[n("div",{class:"page-header",children:[n("div",{class:"page-title",children:"Digests"}),n("div",{class:"header-actions",children:n("button",{class:"btn-refresh",onClick:()=>void m(),children:[n(ue,{size:14})," Refresh"]})})]}),o?n("div",{style:{display:"flex",justifyContent:"center",padding:"48px"},children:n("div",{class:"spinner"})}):e.length===0?n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(je,{size:18})}),n("div",{class:"empty-state-text",children:"No digests yet"})]}):n("div",{class:"split",children:[n("div",{class:"split-list",children:n("div",{class:"templates-list",children:e.map(u=>{var b;return n("button",{onClick:()=>void p(u.id),class:`templates-list-item${r===u.id?" active":""}`,children:[n("div",{class:"templates-list-icon",children:n(je,{size:14})}),n("div",{class:"templates-list-content",children:[n("div",{class:"templates-list-title",children:u.jobName}),n("div",{class:"templates-list-meta",children:[u.articleCount," article",u.articleCount===1?"":"s"," · ",v(u.createdAt)]}),((b=u.preview)==null?void 0:b.length)>0&&n("div",{style:{fontSize:12,color:"var(--text-dim)",marginTop:6,lineHeight:1.45},children:u.preview[0]})]})]},u.id)})})}),n("div",{class:"split-detail",children:r?d?n("div",{style:{display:"flex",justifyContent:"center",padding:"32px"},children:n("div",{class:"spinner"})}):a?n("div",{children:[n("div",{class:"digest-header",children:[n("div",{class:"digest-title",children:a.jobName}),n("div",{class:"digest-meta",children:v(a.createdAt)})]}),a.summary&&a.summary.trim().length>0&&n(Le,{content:a.summary,className:"digest-reader markdown-content",style:{marginBottom:12}}),((g=a.articles)==null?void 0:g.length)>0?n("div",{class:"digest-articles",children:a.articles.map(u=>n("div",{class:"digest-article-card",children:[n("div",{class:"source-badge",children:u.source}),n("a",{href:u.url,target:"_blank",rel:"noreferrer",class:"article-title",children:[u.title," ",n(Xl,{size:12})]}),(u.score!==void 0||u.comments!==void 0)&&n("div",{class:"article-stats",children:[u.score!==void 0?`Score ${u.score}`:"",u.comments!==void 0?`${u.score!==void 0?" · ":""}${u.comments} comments`:""]}),u.summary&&n(Le,{content:u.summary,className:"markdown-content",style:{fontSize:13,color:"var(--text-dim)",marginTop:8}})]},u.id))}):a.summary?null:n("div",{class:"empty-state",style:{padding:"24px 0"},children:n("div",{class:"empty-state-text",children:"No content in this digest"})})]}):n("div",{class:"empty-state",style:{padding:"32px 0"},children:n("div",{class:"empty-state-text",children:"Failed to load digest"})}):n("div",{class:"empty-state",style:{padding:"32px 0"},children:n("div",{class:"empty-state-text",children:"Select a digest"})})})]})]})}function Vc({showToast:e}){const[t,r]=w([]),[i,a]=w(null),[l,o]=w(null),[s,d]=w(!0),[c,m]=w(!1),[p,v]=w(""),[g,u]=w(""),[b,S]=w(!1),[k,h]=w(!1),[_,E]=w("raw"),[M,P]=w(!1),[T,C]=w("");j(()=>{x()},[]);async function x(){d(!0);try{const A=await Gs();r(A.skills??[])}catch{e("Failed to load skills","error")}finally{d(!1)}}async function y(A){a(A),E("markdown"),m(!0);try{const U=await Vs(A);o(U),C(U.rawContent||U.body||""),P(!1)}catch{e("Failed to load skill details","error"),o(null)}finally{m(!1)}}async function R(){if(l){h(!0);try{await Js(l.name,T),e("Skill updated","success"),await y(l.name)}catch{e("Failed to update skill","error")}finally{h(!1)}}}async function $(A){if(A.enabled!==void 0)try{await Ks(A.name,!A.enabled),e(`Skill ${A.name} ${A.enabled?"disabled":"enabled"}`,"success"),await x(),i===A.name&&await y(A.name)}catch{e("Failed to update skill","error")}}async function H(A){if(window.confirm(`Delete skill "${A}"? This action cannot be undone.`)){r(ce=>ce.filter(pe=>pe.name!==A)),i===A&&(a(null),o(null));try{await Ys(A),e(`Deleted ${A}`,"warning"),await x()}catch{e("Failed to delete skill","error"),await x()}}}async function X(){const A=p.trim();if(!(!A||!g.trim())){h(!0);try{await Zs(A,g),e("Skill created","success"),v(""),u(""),S(!1),await x(),await y(A)}catch{e("Failed to create skill","error")}finally{h(!1)}}}return n("div",{children:[n("div",{class:"page-header",children:[n("div",{class:"page-title",children:"Skills"}),n("div",{class:"header-actions",children:[n("button",{class:"btn btn-sm",onClick:()=>S(A=>!A),children:b?"Close":"New"}),n("button",{class:"btn-refresh",onClick:x,children:[n(ue,{size:14})," Refresh"]})]})]}),s?n("div",{style:{display:"flex",justifyContent:"center",padding:"48px"},children:n("div",{class:"spinner"})}):n("div",{children:[t.length===0?n("div",{class:"empty-state",style:{padding:"24px 16px"},children:[n("div",{class:"empty-state-icon",children:n(zn,{size:18})}),n("div",{class:"empty-state-text",children:"No skills found"})]}):n("div",{class:"skills-grid",style:{marginBottom:14},children:t.map(A=>n("div",{class:"skill-card",children:[n("div",{class:"skill-header",children:[n("div",{class:"skill-name",children:A.name}),n("div",{title:A.eligible?"Eligible":A.reason||"Ineligible",children:A.eligible===!1?n(Jl,{size:16,color:"var(--error)"}):n(ha,{size:16,color:"var(--success)"})})]}),n("div",{class:"skill-desc",children:A.description||"No description"}),A.tags&&A.tags.length>0&&n("div",{class:"skill-tags",children:A.tags.slice(0,4).map(U=>n("span",{class:"skill-tag",children:U},U))}),n("div",{style:{display:"flex",gap:8,marginTop:10},children:[n("button",{class:"btn btn-sm",onClick:()=>void y(A.name),children:"View"}),n("button",{class:"btn btn-sm",disabled:!0,title:"Coming soon",onClick:()=>void $(A),children:A.enabled?"Disable":"Enable"}),n("button",{class:"btn btn-sm btn-danger",onClick:()=>void H(A.name),children:"Delete"})]})]},A.name))}),n("div",{children:[b&&n("div",{class:"card",children:[n("div",{class:"card-title",style:{fontWeight:700,marginBottom:10},children:"Create Skill"}),n("label",{class:"form-field",style:{marginBottom:8},children:[n("span",{class:"form-label",children:"Skill name"}),n("input",{value:p,onInput:A=>v(A.target.value),placeholder:"skill-name"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"SKILL.md content"}),n("textarea",{value:g,onInput:A=>u(A.target.value),placeholder:"SKILL.md content",style:{minHeight:180}})]}),n("div",{class:"form-actions",children:n("button",{class:"btn btn-sm btn-primary",disabled:k||!p.trim()||!g.trim(),onClick:X,children:k?"Creating…":"Create"})})]}),n("div",{class:"card",children:i?c?n("div",{style:{display:"flex",justifyContent:"center",padding:"32px"},children:n("div",{class:"spinner"})}):l?n(te,{children:[n("div",{class:"audit-header",children:[n("div",{style:{fontWeight:700},children:l.name}),n("div",{style:{display:"flex",gap:8},children:[n("button",{class:"btn btn-sm",onClick:()=>E(A=>A==="raw"?"markdown":"raw"),children:_==="raw"?"Markdown":"Raw"}),n("button",{class:"btn btn-sm btn-danger",onClick:()=>void H(l.name),children:"Delete"})]})]}),n("div",{class:"audit-summary",style:{marginBottom:8},children:l.description||"No description"}),n("div",{class:"audit-meta",style:{marginBottom:12},children:[n("span",{children:["Eligible: ",l.eligible?"yes":"no"]}),n("span",{children:["Enabled: ",l.enabled?"yes":"no"]}),n("span",{children:["Priority: ",l.priority??100]})]}),M?n(te,{children:[n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Edit SKILL.md"}),n("textarea",{value:T,onInput:A=>C(A.target.value),style:{minHeight:280}})]}),n("div",{class:"form-actions",children:[n("button",{class:"btn btn-sm btn-primary",onClick:()=>void R(),disabled:k||!T.trim(),children:k?"Saving…":"Save"}),n("button",{class:"btn btn-sm",onClick:()=>{P(!1),C(l.rawContent||l.body||"")},children:"Cancel"})]})]}):_==="markdown"?n(Qt,{content:l.rawContent||l.body||""}):n("pre",{class:"ca-output",style:{marginTop:0,maxHeight:420},children:l.rawContent||l.body||"(empty)"})]}):n("div",{class:"empty-state",style:{padding:"32px 0"},children:n("div",{class:"empty-state-text",children:"Failed to load skill detail"})}):n("div",{class:"empty-state",style:{padding:"32px 0"},children:[n("div",{class:"empty-state-icon",children:n(zn,{size:18})}),n("div",{class:"empty-state-text",children:"Select a skill to inspect"})]})})]})]})]})}function Zc(){var h;const[e,t]=w(null),[r,i]=w(null),[a,l]=w(!0),[o,s]=w(!1);j(()=>{d()},[]);async function d(){l(!0);try{const[_,E]=await Promise.all([li(),si()]);t(_),i(E)}catch(_){console.error("[health] load failed",_)}finally{l(!1)}}async function c(){s(!0);try{const[_,E]=await Promise.all([li(),si()]);t(_),i(E)}catch(_){console.error("[health] recheck failed",_)}finally{s(!1)}}function m(_){return _==="ok"?"ok":_==="warn"?"warn":"error"}function p(_){return _==="ok"?"var(--success)":_==="warn"?"var(--warning)":"var(--error)"}function v(_){return"status"in _&&_.status?_:"ok"in _?{name:_.name,status:_.ok?"ok":_.fatal?"error":"warn",message:_.detail||_.remedy}:{name:_.name,status:"error"}}const u=(((h=r==null?void 0:r.report)==null?void 0:h.checks)??(e==null?void 0:e.checks)??[]).map(_=>v(_)),b=u.filter(_=>_.status==="error").length,S=u.filter(_=>_.status==="warn").length,k=u.filter(_=>_.status==="ok").length;return n("div",{children:[n("div",{class:"page-header",children:[n("div",{class:"page-title",children:"Health"}),n("div",{class:"header-actions",children:n("button",{class:"btn btn-sm",id:"healthRecheckBtn",onClick:c,disabled:o||a,children:o?"Checking…":"Recheck"})})]}),a?n("div",{style:{display:"flex",justifyContent:"center",padding:"48px"},children:n("div",{class:"spinner"})}):n("div",{children:[n("div",{class:"stats-grid",style:{gridTemplateColumns:"repeat(3, 1fr)",marginBottom:28},children:[n("div",{class:"stat-card",children:[n("div",{class:"stat-icon green",children:n(Kl,{size:16})}),n("div",{class:"stat-label",children:"System"}),n("div",{class:"stat-value",children:e!=null&&e.ok?"OK":"Issue"}),n("div",{class:"stat-sub",children:[u.length," checks"]})]}),n("div",{class:"stat-card",children:[n("div",{class:"stat-icon sage",children:n(Re,{size:16})}),n("div",{class:"stat-label",children:"Checks Passing"}),n("div",{class:"stat-value",style:{color:"var(--success)"},children:k}),n("div",{class:"stat-sub",children:["out of ",u.length]})]}),n("div",{class:"stat-card",children:[n("div",{class:"stat-icon",style:{background:b>0?"var(--error-soft)":S>0?"var(--warning-soft)":"var(--success-soft)",color:b>0?"var(--error)":S>0?"var(--warning)":"var(--success)"},children:b>0?n(it,{size:16}):S>0?n(ri,{size:16}):n(Re,{size:16})}),n("div",{class:"stat-label",children:"Issues"}),n("div",{class:"stat-value",style:{color:b>0?"var(--error)":S>0?"var(--warning)":"var(--success)"},children:b+S}),n("div",{class:"stat-sub",children:[b," errors, ",S," warnings"]})]})]}),n("div",{id:"doctorSummary",children:[n("div",{class:"section-header",style:{marginBottom:16},children:[n("div",{class:"section-title",children:"Diagnostics"}),n("div",{class:"header-meta",id:"doctorTimestamp",children:new Date().toLocaleTimeString()})]}),n("div",{id:"doctorCategories",children:u.length===0?n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(fa,{size:18})}),n("div",{class:"empty-state-text",children:"No diagnostics available"})]}):n("div",{class:"feed-card",children:n("div",{class:"feed",children:u.map((_,E)=>n("div",{class:"feed-item",children:[n("div",{style:{width:32,height:32,borderRadius:"var(--radius-sm)",background:p(_.status)+"18",color:p(_.status),display:"flex",alignItems:"center",justifyContent:"center",fontWeight:700,fontSize:14,flexShrink:0},children:m(_.status)==="ok"?n(Re,{size:14}):m(_.status)==="warn"?n(ri,{size:14}):n(it,{size:14})}),n("div",{children:[n("div",{class:"feed-title",children:_.name}),_.message&&n("div",{class:"feed-detail",children:_.message})]}),n("div",{style:{fontSize:12,color:p(_.status),fontWeight:600,fontFamily:"var(--mono)",whiteSpace:"nowrap"},children:_.status})]},E))})})})]}),n("div",{id:"healthEnvVars",style:{display:"none"}}),n("div",{id:"healthFeatures",style:{display:"none"}})]})]})}const Qe="main";function Kc({showToast:e}){const[t,r]=w([]),[i,a]=w(null),[l,o]=w(""),[s,d]=w(""),[c,m]=w(!0),[p,v]=w(!1),[g,u]=w(!1),[b,S]=w("edit");j(()=>{k()},[]);async function k(){m(!0);try{const T=await Is(Qe);r(T.templates??[])}catch(T){console.error("[templates] load failed",T)}finally{m(!1)}}async function h(T){a(T),S(T.toLowerCase().endsWith(".md")?"preview":"edit"),v(!0);try{const x=(await Ds(Qe,T)).content??"";o(x),d(x)}catch(C){console.error("[templates] file load failed",C),o(""),d("")}finally{v(!1)}}async function _(){if(i){u(!0);try{await Ps(Qe,i,l),d(l),e("Template saved","success")}catch{e("Failed to save template","error")}finally{u(!1)}}}function E(){o(s)}const M=l!==s,P=t.find(T=>T.name===i);return n("div",{class:"templates-page",children:[n("div",{class:"templates-header",children:[n("div",{class:"page-title",children:"Templates"}),n("button",{class:"btn-refresh",onClick:k,children:[n(ue,{size:14})," Refresh"]})]}),c?n("div",{class:"templates-loading",children:n("div",{class:"spinner"})}):t.length===0?n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(je,{size:18})}),n("div",{class:"empty-state-text",children:"No templates found"})]}):n("div",{class:"templates-layout",children:[n("div",{class:"templates-sidebar",children:[n("div",{class:"templates-sidebar-header",children:[n("div",{class:"templates-sidebar-label",children:"Agent Templates"}),n("select",{class:"templates-agent-select",value:Qe,disabled:!0,children:n("option",{value:"main",children:"main"})})]}),n("div",{class:"templates-list",children:t.map(T=>n("button",{class:`templates-list-item${i===T.name?" active":""}`,onClick:()=>h(T.name),children:[n("div",{class:"templates-list-icon",children:T.name.substring(0,2).toUpperCase()}),n("div",{class:"templates-list-content",children:[n("div",{class:"templates-list-title",children:T.name}),n("div",{class:"templates-list-meta",children:[Math.round((T.size||0)/1024),"KB"]})]})]},T.name))})]}),n("div",{class:"templates-main",children:i?p?n("div",{class:"templates-loading",children:n("div",{class:"spinner"})}):n(te,{children:[n("div",{class:"templates-editor-header",children:[n("div",{class:"templates-editor-title-row",children:[n("h2",{class:"templates-editor-title",children:i}),M&&n("span",{class:"templates-unsaved-pill",children:"Unsaved changes"})]}),n("div",{class:"templates-editor-actions",children:[M&&n("button",{class:"templates-discard-btn",onClick:E,children:"Discard"}),n("button",{class:"templates-save-btn",onClick:_,disabled:g||!M,children:g?"Saving…":"Save"})]})]}),n("div",{class:"templates-tabs",children:[n("button",{class:`templates-tab${b==="edit"?" active":""}`,onClick:()=>S("edit"),children:"Edit"}),n("button",{class:`templates-tab${b==="preview"?" active":""}`,onClick:()=>S("preview"),children:"Preview"})]}),P&&n("div",{class:"templates-metadata",children:[n("div",{class:"templates-metadata-item",children:[n("div",{class:"templates-metadata-label",children:"SIZE"}),n("div",{class:"templates-metadata-value",children:(P.size||0)>1024?`${Math.round((P.size||0)/1024)}KB`:`${P.size||0}B`})]}),n("div",{class:"templates-metadata-item",children:[n("div",{class:"templates-metadata-label",children:"LAST EDITED"}),n("div",{class:"templates-metadata-value",children:"—"})]}),n("div",{class:"templates-metadata-item",children:[n("div",{class:"templates-metadata-label",children:"AGENT"}),n("div",{class:"templates-metadata-value",children:Qe})]}),n("div",{class:"templates-metadata-item",children:[n("div",{class:"templates-metadata-label",children:"PATH"}),n("div",{class:"templates-metadata-value templates-metadata-path",children:["~/.skimpyclaw/agents/",Qe,"/",i]})]})]}),n("div",{class:"templates-content",children:b==="preview"?n("div",{class:"templates-markdown-preview",children:n(Qt,{content:l})}):n("textarea",{class:"templates-textarea",value:l,onInput:T=>o(T.target.value),spellcheck:!1})})]}):n("div",{class:"templates-empty",children:[n(je,{size:32}),n("p",{children:"Select a template to edit"})]})})]})]})}function _t(e){return e===0?"$0.00":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function bt(e){return e===0?"0":e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function Jc(e){const t=Date.now()-new Date(e).getTime(),r=Math.floor(t/1e3);if(r<60)return`${r}s ago`;const i=Math.floor(r/60);if(i<60)return`${i}m ago`;const a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function Yc(){const[e,t]=w(null),[r,i]=w([]),[a,l]=w(0),[o,s]=w(0),[d,c]=w(!0),m=25;j(()=>{p();const S=setInterval(p,3e4);return()=>clearInterval(S)},[o]);async function p(){try{const[S,k]=await Promise.all([ir(),Xs({limit:m,offset:o*m})]);t(S),i(k.records??[]),l(k.total??0)}catch(S){console.error("[usage] load failed",S)}finally{c(!1)}}if(d&&!e)return n("div",{style:{display:"flex",justifyContent:"center",padding:"48px"},children:n("div",{class:"spinner"})});const v=e==null?void 0:e.today,g=e==null?void 0:e.week,u=e==null?void 0:e.month,b=u!=null&&u.byModel?Object.entries(u.byModel).sort((S,k)=>k[1].cost-S[1].cost):[];return n("div",{children:[n("div",{class:"page-header",children:[n("div",{class:"page-title",children:"Usage"}),n("div",{class:"header-actions",children:[n("div",{class:"coding-refresh-pill",children:[n("span",{class:"dot"})," Auto-refresh 30s"]}),n("button",{class:"btn-refresh",onClick:p,children:[n(ue,{size:14})," Refresh"]})]})]}),n("div",{class:"usage-stats-grid",children:[n("div",{class:"stat-card",children:[n("div",{class:"stat-icon rose",children:n(Be,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value",children:_t((v==null?void 0:v.totalCost)??0)}),n("div",{class:"stat-subtitle",children:"Cost today"})]})]}),n("div",{class:"stat-card",children:[n("div",{class:"stat-icon amber",children:n(Be,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value",children:_t((g==null?void 0:g.totalCost)??0)}),n("div",{class:"stat-subtitle",children:"Last 7 days"})]})]}),n("div",{class:"stat-card",children:[n("div",{class:"stat-icon sage",children:n(Be,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value",children:_t((u==null?void 0:u.totalCost)??0)}),n("div",{class:"stat-subtitle",children:"Last 30 days"})]})]}),n("div",{class:"stat-card",children:[n("div",{class:"stat-icon blue",children:n(rt,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value",children:(v==null?void 0:v.totalCalls)??0}),n("div",{class:"stat-subtitle",children:["Calls today · ",bt(((v==null?void 0:v.totalInputTokens)??0)+((v==null?void 0:v.totalOutputTokens)??0))," tok"]})]})]})]}),b.length>0&&n("div",{class:"section",children:[n("div",{class:"section-header",children:n("div",{class:"section-title",children:"Model Breakdown (30d)"})}),n("div",{class:"feed-card",children:n("table",{class:"usage-table",children:[n("thead",{children:n("tr",{children:[n("th",{children:"Model"}),n("th",{children:"Calls"}),n("th",{children:"Input Tokens"}),n("th",{children:"Output Tokens"}),n("th",{children:"Cost"})]})}),n("tbody",{children:b.map(([S,k])=>n("tr",{children:[n("td",{children:n("code",{class:"usage-model-pill",children:S})}),n("td",{children:k.calls}),n("td",{children:bt(k.inputTokens)}),n("td",{children:bt(k.outputTokens)}),n("td",{class:"usage-cost-cell",children:_t(k.cost)})]},S))})]})})]}),n("div",{class:"section",children:[n("div",{class:"section-header",children:[n("div",{class:"section-title",children:"Recent Calls"}),n("div",{class:"audit-header-meta",children:[a," total"]})]}),r.length===0?n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(Ql,{size:18})}),n("div",{class:"empty-state-text",children:"No usage records yet"})]}):n("div",{class:"feed-card",children:[n("div",{class:"feed",children:r.map(S=>n("div",{class:"feed-item",children:[n("div",{class:`feed-icon ${S.trigger==="telegram"?"telegram":S.trigger==="cron"?"cron":"system"}`,children:n(Be,{size:14})}),n("div",{children:[n("div",{class:"feed-title",children:[n("code",{class:"usage-model-pill",children:S.model})," ",n("span",{class:"audit-chip trigger muted",children:S.trigger})]}),n("div",{class:"feed-detail",children:[bt(S.inputTokens)," in · ",bt(S.outputTokens)," out · ",_t(S.totalCost)]})]}),n("div",{class:"feed-time",children:Jc(S.timestamp)})]},S.id))}),a>m&&n("div",{style:{display:"flex",justifyContent:"center",gap:"8px",padding:"12px"},children:[n("button",{class:"btn btn-sm",disabled:o===0,onClick:()=>s(S=>Math.max(0,S-1)),children:"Previous"}),n("span",{style:{fontSize:"12px",color:"var(--text-muted)",alignSelf:"center"},children:[o*m+1,"–",Math.min((o+1)*m,a)," of ",a]}),n("button",{class:"btn btn-sm",disabled:(o+1)*m>=a,onClick:()=>s(S=>S+1),children:"Next"})]})]})]})]})}const Xc=["overview","history","cron","memory","model","agents","coding","logs","audit","digests","skills","approvals","health","usage","config","templates"];function Qc(e){return Xc.includes(e)}function Pi(){const e=window.location.hash.replace(/^#/,"").split("/")[0].trim();return Qc(e)?e:"overview"}function ed(){const e=window.__SKIMPY_DASHBOARD__,t=typeof(e==null?void 0:e.botName)=="string"&&e.botName.trim()?e.botName:"SkimpyClaw",r=typeof(e==null?void 0:e.botEmoji)=="string"&&e.botEmoji.trim()?e.botEmoji:"👙🦞";return{name:t,emoji:r}}function td({onLogin:e,botName:t,botEmoji:r}){const[i,a]=w(""),[l,o]=w("");async function s(){const d=i.trim();if(d)try{if((await fetch("/api/dashboard/status",{headers:{Authorization:`Bearer ${d}`}})).status===401){o("Invalid token");return}vs(d),e(d)}catch{o("Could not reach server")}}return n("div",{style:{minHeight:"100vh",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--bg)"},children:n("div",{style:{background:"var(--surface)",border:"1px solid var(--border)",borderRadius:"var(--radius)",padding:"40px 48px",width:360,boxShadow:"var(--shadow-md)",textAlign:"center"},children:[n("div",{style:{fontSize:36,marginBottom:16},children:r}),n("div",{style:{fontFamily:"var(--serif)",fontSize:22,fontWeight:800,marginBottom:8},children:t}),n("div",{style:{fontSize:13,color:"var(--text-muted)",marginBottom:28},children:"Enter your dashboard token"}),n("input",{type:"password",placeholder:"Bearer token",value:i,onInput:d=>{a(d.target.value),o("")},onKeyDown:d=>d.key==="Enter"&&s(),style:{width:"100%",padding:"10px 14px",borderRadius:"var(--radius-sm)",border:`1px solid ${l?"var(--error)":"var(--border)"}`,background:"var(--surface-alt)",color:"var(--text)",fontFamily:"var(--mono)",fontSize:13,marginBottom:12,outline:"none",boxSizing:"border-box"}}),l&&n("div",{style:{fontSize:12,color:"var(--error)",marginBottom:12},children:l}),n("button",{class:"btn btn-primary",style:{width:"100%"},onClick:s,children:"Sign in"})]})})}function nd(){const e=ed(),[t,r]=w(!!ga()),[i,a]=w(()=>Pi()),[l,o]=w(()=>window.innerWidth<=980),[s,d]=w(()=>window.innerWidth>980),[c,m]=w(()=>localStorage.getItem("theme")??"light"),[p,v]=w(0),{toasts:g,showToast:u}=ms();j(()=>bs(()=>{r(!1)}),[]),j(()=>{document.documentElement.setAttribute("data-theme",c),localStorage.setItem("theme",c)},[c]),j(()=>{function h(){const _=window.innerWidth<=980;o(E=>(E!==_&&d(!_),_))}return window.addEventListener("resize",h),()=>window.removeEventListener("resize",h)},[]),j(()=>{if(!l||!s){document.body.style.overflow="";return}return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[l,s]),j(()=>{const h=()=>{const _=Pi();a(_),l&&d(!1)};return window.location.hash?h():window.location.hash="#overview",window.addEventListener("hashchange",h),()=>window.removeEventListener("hashchange",h)},[l]);function b(){m(h=>h==="light"?"dark":"light")}function S(h){const _=`#${h}`;window.location.hash!==_?window.location.hash=_:a(h),l&&d(!1)}if(!t)return n(td,{botName:e.name,botEmoji:e.emoji,onLogin:()=>r(!0)});function k(){switch(i){case"overview":return n(ci,{onNavigate:S,showToast:u});case"history":return n(co,{});case"cron":return n(ho,{showToast:u});case"usage":return n(Yc,{});case"coding":return n(Ac,{});case"audit":return n($c,{});case"approvals":return n(Ic,{showToast:u,onCountChange:v});case"memory":return n(Dc,{});case"model":return n(Uc,{showToast:u});case"agents":return n(Hc,{showToast:u});case"logs":return n(jc,{});case"config":return n(qc,{showToast:u});case"digests":return n(Gc,{});case"skills":return n(Vc,{showToast:u});case"health":return n(Zc,{});case"templates":return n(Kc,{showToast:u});default:return n(ci,{onNavigate:S,showToast:u})}}return n(te,{children:[n("div",{class:`shell${l?" shell-narrow":""}${l&&s?" sidebar-open":""}`,children:[l&&n("button",{class:"global-sidebar-toggle",onClick:()=>d(!0),"aria-label":"Open sidebar",children:n(rs,{size:16})}),n(fs,{currentPage:i,onNavigate:S,botName:e.name,botEmoji:e.emoji,pendingApprovals:p,isNarrow:l,onClose:()=>d(!1)}),l&&s?n("button",{class:"sidebar-backdrop",onClick:()=>d(!1),"aria-label":"Close sidebar"}):null,n("main",{class:"main",children:[n("button",{class:"global-theme-toggle",onClick:b,"aria-label":"Toggle theme",children:c==="light"?n(is,{size:16}):n(ds,{size:16})}),k()]})]}),n(gs,{toasts:g})]})}tt(n(nd,{}),document.getElementById("app"));