skimpyclaw 0.3.6 → 0.3.8
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.
- package/README.md +14 -6
- package/dist/__tests__/api.test.js +1 -0
- package/dist/__tests__/channels.test.js +1 -1
- package/dist/__tests__/code-agents-orchestrator.test.js +74 -7
- package/dist/__tests__/code-agents-sandbox.test.d.ts +1 -0
- package/dist/__tests__/code-agents-sandbox.test.js +163 -0
- package/dist/__tests__/context-manager.test.d.ts +1 -0
- package/dist/__tests__/context-manager.test.js +236 -0
- package/dist/__tests__/package-manager-detection.test.js +5 -5
- package/dist/__tests__/setup.test.js +7 -5
- package/dist/__tests__/skills.test.js +2 -2
- package/dist/__tests__/structured-context.test.d.ts +1 -0
- package/dist/__tests__/structured-context.test.js +100 -0
- package/dist/__tests__/tools.test.js +65 -3
- package/dist/agent.js +4 -5
- package/dist/api.js +10 -58
- package/dist/audit.js +5 -51
- package/dist/channels/telegram/handlers.js +2 -60
- package/dist/channels/telegram/index.js +0 -7
- package/dist/channels.js +1 -1
- package/dist/cli.js +151 -16
- package/dist/code-agents/executor.d.ts +9 -4
- package/dist/code-agents/executor.js +187 -13
- package/dist/code-agents/index.d.ts +1 -1
- package/dist/code-agents/index.js +23 -21
- package/dist/code-agents/orchestrator.d.ts +8 -2
- package/dist/code-agents/orchestrator.js +297 -27
- package/dist/code-agents/structured-context.d.ts +7 -0
- package/dist/code-agents/structured-context.js +54 -0
- package/dist/code-agents/types.d.ts +2 -0
- package/dist/code-agents/utils.js +12 -2
- package/dist/code-agents/worktree.d.ts +40 -0
- package/dist/code-agents/worktree.js +215 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.js +5 -3
- package/dist/cron.js +18 -4
- package/dist/dashboard/assets/{index-CkonC7Cd.js → index-BoTHPby4.js} +20 -20
- package/dist/dashboard/assets/{index-EAg6lqF5.css → index-D4mufvBg.css} +1 -1
- package/dist/dashboard/index.html +2 -2
- package/dist/discord.js +4 -40
- package/dist/exec-approval.js +1 -1
- package/dist/file-lock.js +1 -1
- package/dist/gateway.js +3 -10
- package/dist/providers/anthropic.js +9 -5
- package/dist/providers/codex.js +10 -6
- package/dist/providers/context-manager.d.ts +22 -0
- package/dist/providers/context-manager.js +100 -0
- package/dist/providers/openai.js +9 -5
- package/dist/providers/types.d.ts +1 -0
- package/dist/security.js +9 -0
- package/dist/setup.js +112 -14
- package/dist/skills.js +9 -2
- package/dist/subagent.js +33 -2
- package/dist/tools/bash-tool.js +8 -0
- package/dist/tools/browser-tool.js +2 -1
- package/dist/tools/definitions.d.ts +0 -27
- package/dist/tools/definitions.js +0 -18
- package/dist/tools/execute-context.d.ts +4 -4
- package/dist/tools/file-tools.d.ts +1 -1
- package/dist/tools/file-tools.js +1 -1
- package/dist/tools.d.ts +5 -5
- package/dist/tools.js +87 -98
- package/dist/types.d.ts +14 -22
- package/dist/usage.d.ts +1 -0
- package/dist/usage.js +30 -46
- package/dist/utils.d.ts +18 -0
- package/dist/utils.js +71 -0
- package/dist/voice.js +9 -7
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var Bs=Object.defineProperty;var Fs=(e,t,r)=>t in e?Bs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var q=(e,t,r)=>Fs(e,typeof t!="symbol"?t+"":t,r);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function r(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function i(s){if(s.ep)return;s.ep=!0;const a=r(s);fetch(s.href,a)}})();var xt,P,Ri,Oe,$r,$i,Mi,Ii,jn,wn,Sn,Di,Ft={},Ht=[],Hs=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,wt=Array.isArray;function ke(e,t){for(var r in t)e[r]=t[r];return e}function qn(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Ee(e,t,r){var i,s,a,o={};for(a in t)a=="key"?i=t[a]:a=="ref"?s=t[a]:o[a]=t[a];if(arguments.length>2&&(o.children=arguments.length>3?xt.call(arguments,2):r),typeof e=="function"&&e.defaultProps!=null)for(a in e.defaultProps)o[a]===void 0&&(o[a]=e.defaultProps[a]);return yt(e,o,i,s,null)}function yt(e,t,r,i,s){var a={type:e,props:t,key:r,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s??++Ri,__i:-1,__u:0};return s==null&&P.vnode!=null&&P.vnode(a),a}function Ws(){return{current:null}}function ne(e){return e.children}function xe(e,t){this.props=e,this.context=t}function Ye(e,t){if(t==null)return e.__?Ye(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"?Ye(e):null}function js(e){if(e.__P&&e.__d){var t=e.__v,r=t.__e,i=[],s=[],a=ke({},t);a.__v=t.__v+1,P.vnode&&P.vnode(a),Gn(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[r]:null,i,r??Ye(t),!!(32&t.__u),s),a.__v=t.__v,a.__.__k[a.__i]=a,zi(i,a,s),t.__e=t.__=null,a.__e!=r&&Pi(a)}}function Pi(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}),Pi(e)}function Tn(e){(!e.__d&&(e.__d=!0)&&Oe.push(e)&&!Wt.__r++||$r!=P.debounceRendering)&&(($r=P.debounceRendering)||$i)(Wt)}function Wt(){for(var e,t=1;Oe.length;)Oe.length>t&&Oe.sort(Mi),e=Oe.shift(),t=Oe.length,js(e);Wt.__r=0}function Ni(e,t,r,i,s,a,o,l,d,c,m){var h,v,g,u,b,x,k,f=i&&i.__k||Ht,_=t.length;for(d=qs(r,t,f,d,_),h=0;h<_;h++)(g=r.__k[h])!=null&&(v=g.__i!=-1&&f[g.__i]||Ft,g.__i=h,x=Gn(e,g,v,s,a,o,l,d,c,m),u=g.__e,g.ref&&v.ref!=g.ref&&(v.ref&&Vn(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=Oi(g,d,e,k):typeof g.type=="function"&&x!==void 0?d=x:u&&(d=u.nextSibling),g.__u&=-7);return r.__e=b,d}function qs(e,t,r,i,s){var a,o,l,d,c,m=r.length,h=m,v=0;for(e.__k=new Array(s),a=0;a<s;a++)(o=t[a])!=null&&typeof o!="boolean"&&typeof o!="function"?(typeof o=="string"||typeof o=="number"||typeof o=="bigint"||o.constructor==String?o=e.__k[a]=yt(null,o,null,null,null):wt(o)?o=e.__k[a]=yt(ne,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=yt(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,d=a+v,o.__=e,o.__b=e.__b+1,l=null,(c=o.__i=Gs(o,r,d,h))!=-1&&(h--,(l=r[c])&&(l.__u|=2)),l==null||l.__v==null?(c==-1&&(s>m?v--:s<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[a]=null;if(h)for(a=0;a<m;a++)(l=r[a])!=null&&!(2&l.__u)&&(l.__e==i&&(i=Ye(l)),Bi(l,l));return i}function Oi(e,t,r,i){var s,a;if(typeof e.type=="function"){for(s=e.__k,a=0;s&&a<s.length;a++)s[a]&&(s[a].__=e,t=Oi(s[a],t,r,i));return t}e.__e!=t&&(i&&(t&&e.type&&!t.parentNode&&(t=Ye(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"||(wt(e)?e.some(function(r){Ae(r,t)}):t.push(e)),t}function Gs(e,t,r,i){var s,a,o,l=e.key,d=e.type,c=t[r],m=c!=null&&(2&c.__u)==0;if(c===null&&l==null||m&&l==c.key&&d==c.type)return r;if(i>(m?1:0)){for(s=r-1,a=r+1;s>=0||a<t.length;)if((c=t[o=s>=0?s--:a++])!=null&&!(2&c.__u)&&l==c.key&&d==c.type)return o}return-1}function Mr(e,t,r){t[0]=="-"?e.setProperty(t,r??""):e[t]=r==null?"":typeof r!="number"||Hs.test(t)?r:r+"px"}function It(e,t,r,i,s){var a,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||Mr(e.style,t,"");if(r)for(t in r)i&&r[t]==i[t]||Mr(e.style,t,r[t])}else if(t[0]=="o"&&t[1]=="n")a=t!=(t=t.replace(Ii,"$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+a]=r,r?i?r.u=i.u:(r.u=jn,e.addEventListener(t,a?Sn:wn,a)):e.removeEventListener(t,a?Sn:wn,a);else{if(s=="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 Ir(e){return function(t){if(this.l){var r=this.l[t.type+e];if(t.t==null)t.t=jn++;else if(t.t<r.u)return;return r(P.event?P.event(t):t)}}}function Gn(e,t,r,i,s,a,o,l,d,c){var m,h,v,g,u,b,x,k,f,_,A,R,O,I,D,S=t.type;if(t.constructor!==void 0)return null;128&r.__u&&(d=!!(32&r.__u),a=[l=t.__e=r.__e]),(m=P.__b)&&m(t);e:if(typeof S=="function")try{if(k=t.props,f="prototype"in S&&S.prototype.render,_=(m=S.contextType)&&i[m.__c],A=m?_?_.props.value:m.__:i,r.__c?x=(h=t.__c=r.__c).__=h.__E:(f?t.__c=h=new S(k,A):(t.__c=h=new xe(k,A),h.constructor=S,h.render=Zs),_&&_.sub(h),h.state||(h.state={}),h.__n=i,v=h.__d=!0,h.__h=[],h._sb=[]),f&&h.__s==null&&(h.__s=h.state),f&&S.getDerivedStateFromProps!=null&&(h.__s==h.state&&(h.__s=ke({},h.__s)),ke(h.__s,S.getDerivedStateFromProps(k,h.__s))),g=h.props,u=h.state,h.__v=t,v)f&&S.getDerivedStateFromProps==null&&h.componentWillMount!=null&&h.componentWillMount(),f&&h.componentDidMount!=null&&h.__h.push(h.componentDidMount);else{if(f&&S.getDerivedStateFromProps==null&&k!==g&&h.componentWillReceiveProps!=null&&h.componentWillReceiveProps(k,A),t.__v==r.__v||!h.__e&&h.shouldComponentUpdate!=null&&h.shouldComponentUpdate(k,h.__s,A)===!1){t.__v!=r.__v&&(h.props=k,h.state=h.__s,h.__d=!1),t.__e=r.__e,t.__k=r.__k,t.__k.some(function(y){y&&(y.__=t)}),Ht.push.apply(h.__h,h._sb),h._sb=[],h.__h.length&&o.push(h);break e}h.componentWillUpdate!=null&&h.componentWillUpdate(k,h.__s,A),f&&h.componentDidUpdate!=null&&h.__h.push(function(){h.componentDidUpdate(g,u,b)})}if(h.context=A,h.props=k,h.__P=e,h.__e=!1,R=P.__r,O=0,f)h.state=h.__s,h.__d=!1,R&&R(t),m=h.render(h.props,h.state,h.context),Ht.push.apply(h.__h,h._sb),h._sb=[];else do h.__d=!1,R&&R(t),m=h.render(h.props,h.state,h.context),h.state=h.__s;while(h.__d&&++O<25);h.state=h.__s,h.getChildContext!=null&&(i=ke(ke({},i),h.getChildContext())),f&&!v&&h.getSnapshotBeforeUpdate!=null&&(b=h.getSnapshotBeforeUpdate(g,u)),I=m!=null&&m.type===ne&&m.key==null?Ui(m.props.children):m,l=Ni(e,wt(I)?I:[I],t,r,i,s,a,o,l,d,c),h.base=t.__e,t.__u&=-161,h.__h.length&&o.push(h),x&&(h.__E=h.__=null)}catch(y){if(t.__v=null,d||a!=null)if(y.then){for(t.__u|=d?160:128;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;a[a.indexOf(l)]=null,t.__e=l}else{for(D=a.length;D--;)qn(a[D]);Cn(t)}else t.__e=r.__e,t.__k=r.__k,y.then||Cn(t);P.__e(y,t,r)}else a==null&&t.__v==r.__v?(t.__k=r.__k,t.__e=r.__e):l=t.__e=Vs(r.__e,t,r,i,s,a,o,d,c);return(m=P.diffed)&&m(t),128&t.__u?void 0:l}function Cn(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(Cn))}function zi(e,t,r){for(var i=0;i<r.length;i++)Vn(r[i],r[++i],r[++i]);P.__c&&P.__c(t,e),e.some(function(s){try{e=s.__h,s.__h=[],e.some(function(a){a.call(s)})}catch(a){P.__e(a,s.__v)}})}function Ui(e){return typeof e!="object"||e==null||e.__b>0?e:wt(e)?e.map(Ui):ke({},e)}function Vs(e,t,r,i,s,a,o,l,d){var c,m,h,v,g,u,b,x=r.props||Ft,k=t.props,f=t.type;if(f=="svg"?s="http://www.w3.org/2000/svg":f=="math"?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),a!=null){for(c=0;c<a.length;c++)if((g=a[c])&&"setAttribute"in g==!!f&&(f?g.localName==f:g.nodeType==3)){e=g,a[c]=null;break}}if(e==null){if(f==null)return document.createTextNode(k);e=document.createElementNS(s,f,k.is&&k),l&&(P.__m&&P.__m(t,a),l=!1),a=null}if(f==null)x===k||l&&e.data==k||(e.data=k);else{if(a=a&&xt.call(e.childNodes),!l&&a!=null)for(x={},c=0;c<e.attributes.length;c++)x[(g=e.attributes[c]).name]=g.value;for(c in x)g=x[c],c=="dangerouslySetInnerHTML"?h=g:c=="children"||c in k||c=="value"&&"defaultValue"in k||c=="checked"&&"defaultChecked"in k||It(e,c,null,g,s);for(c in k)g=k[c],c=="children"?v=g:c=="dangerouslySetInnerHTML"?m=g:c=="value"?u=g:c=="checked"?b=g:l&&typeof g!="function"||x[c]===g||It(e,c,g,x[c],s);if(m)l||h&&(m.__html==h.__html||m.__html==e.innerHTML)||(e.innerHTML=m.__html),t.__k=[];else if(h&&(e.innerHTML=""),Ni(t.type=="template"?e.content:e,wt(v)?v:[v],t,r,i,f=="foreignObject"?"http://www.w3.org/1999/xhtml":s,a,o,a?a[0]:r.__k&&Ye(r,0),l,d),a!=null)for(c=a.length;c--;)qn(a[c]);l||(c="value",f=="progress"&&u==null?e.removeAttribute("value"):u!=null&&(u!==e[c]||f=="progress"&&!u||f=="option"&&u!=x[c])&&It(e,c,u,x[c],s),c="checked",b!=null&&b!=e[c]&&It(e,c,b,x[c],s))}return e}function Vn(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(s){P.__e(s,r)}}function Bi(e,t,r){var i,s;if(P.unmount&&P.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||Vn(i,null,t)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(a){P.__e(a,t)}i.base=i.__P=null}if(i=e.__k)for(s=0;s<i.length;s++)i[s]&&Bi(i[s],t,r||typeof e.type!="function");r||qn(e.__e),e.__c=e.__=e.__e=void 0}function Zs(e,t,r){return this.constructor(e,r)}function Xe(e,t,r){var i,s,a,o;t==document&&(t=document.documentElement),P.__&&P.__(e,t),s=(i=typeof r=="function")?null:r&&r.__k||t.__k,a=[],o=[],Gn(t,e=(!i&&r||t).__k=Ee(ne,null,[e]),s||Ft,Ft,t.namespaceURI,!i&&r?[r]:s?null:t.firstChild?xt.call(t.childNodes):null,a,!i&&r?r:s?s.__e:t.firstChild,i,o),zi(a,e,o)}function Fi(e,t){Xe(e,t,Fi)}function Ks(e,t,r){var i,s,a,o,l=ke({},e.props);for(a in e.type&&e.type.defaultProps&&(o=e.type.defaultProps),t)a=="key"?i=t[a]:a=="ref"?s=t[a]:l[a]=t[a]===void 0&&o!=null?o[a]:t[a];return arguments.length>2&&(l.children=arguments.length>3?xt.call(arguments,2):r),yt(e.type,l,i||e.key,s||e.ref,null)}function Js(e){function t(r){var i,s;return this.getChildContext||(i=new Set,(s={})[t.__c]=this,this.getChildContext=function(){return s},this.componentWillUnmount=function(){i=null},this.shouldComponentUpdate=function(a){this.props.value!=a.value&&i.forEach(function(o){o.__e=!0,Tn(o)})},this.sub=function(a){i.add(a);var o=a.componentWillUnmount;a.componentWillUnmount=function(){i&&i.delete(a),o&&o.call(a)}}),r.children}return t.__c="__cC"+Di++,t.__=e,t.Provider=t.__l=(t.Consumer=function(r,i){return r.children(i)}).contextType=t,t}xt=Ht.slice,P={__e:function(e,t,r,i){for(var s,a,o;t=t.__;)if((s=t.__c)&&!s.__)try{if((a=s.constructor)&&a.getDerivedStateFromError!=null&&(s.setState(a.getDerivedStateFromError(e)),o=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(e,i||{}),o=s.__d),o)return s.__E=s}catch(l){e=l}throw e}},Ri=0,xe.prototype.setState=function(e,t){var r;r=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=ke({},this.state),typeof e=="function"&&(e=e(ke({},r),this.props)),e&&ke(r,e),e!=null&&this.__v&&(t&&this._sb.push(t),Tn(this))},xe.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Tn(this))},xe.prototype.render=ne,Oe=[],$i=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Mi=function(e,t){return e.__v.__b-t.__v.__b},Wt.__r=0,Ii=/(PointerCapture)$|Capture$/i,jn=0,wn=Ir(!1),Sn=Ir(!0),Di=0;var Ys=0;function n(e,t,r,i,s,a){t||(t={});var o,l,d=t;if("ref"in d)for(l in d={},t)l=="ref"?o=t[l]:d[l]=t[l];var c={type:e,props:d,key:r,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ys,__i:-1,__u:0,__source:s,__self:a};if(typeof e=="function"&&(o=e.defaultProps))for(l in o)d[l]===void 0&&(d[l]=o[l]);return P.vnode&&P.vnode(c),c}var $e,V,fn,Dr,Qe=0,Hi=[],J=P,Pr=J.__b,Nr=J.__r,Or=J.diffed,zr=J.__c,Ur=J.unmount,Br=J.__;function rt(e,t){J.__h&&J.__h(V,e,Qe||t),Qe=0;var r=V.__H||(V.__H={__:[],__h:[]});return e>=r.__.length&&r.__.push({}),r.__[e]}function w(e){return Qe=1,Zn(Vi,e)}function Zn(e,t,r){var i=rt($e++,2);if(i.t=e,!i.__c&&(i.__=[r?r(t):Vi(void 0,t),function(l){var d=i.__N?i.__N[0]:i.__[0],c=i.t(d,l);d!==c&&(i.__N=[c,i.__[1]],i.__c.setState({}))}],i.__c=V,!V.__f)){var s=function(l,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!a||a.call(this,l,d,c);var h=i.__c.props!==l;return m.some(function(v){if(v.__N){var g=v.__[0];v.__=v.__N,v.__N=void 0,g!==v.__[0]&&(h=!0)}}),a&&a.call(this,l,d,c)||h};V.__f=!0;var a=V.shouldComponentUpdate,o=V.componentWillUpdate;V.componentWillUpdate=function(l,d,c){if(this.__e){var m=a;a=void 0,s(l,d,c),a=m}o&&o.call(this,l,d,c)},V.shouldComponentUpdate=s}return i.__N||i.__}function W(e,t){var r=rt($e++,3);!J.__s&&Jn(r.__H,t)&&(r.__=e,r.u=t,V.__H.__h.push(r))}function St(e,t){var r=rt($e++,4);!J.__s&&Jn(r.__H,t)&&(r.__=e,r.u=t,V.__h.push(r))}function Le(e){return Qe=5,Ce(function(){return{current:e}},[])}function Wi(e,t,r){Qe=6,St(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 Ce(e,t){var r=rt($e++,7);return Jn(r.__H,t)&&(r.__=e(),r.__H=t,r.__h=e),r.__}function Kn(e,t){return Qe=8,Ce(function(){return e},t)}function ji(e){var t=V.context[e.__c],r=rt($e++,9);return r.c=e,t?(r.__==null&&(r.__=!0,t.sub(V)),t.props.value):e.__}function qi(e,t){J.useDebugValue&&J.useDebugValue(t?t(e):e)}function Gi(){var e=rt($e++,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 Xs(){for(var e;e=Hi.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(zt),t.__h.some(An),t.__h=[]}catch(r){t.__h=[],J.__e(r,e.__v)}}}J.__b=function(e){V=null,Pr&&Pr(e)},J.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Br&&Br(e,t)},J.__r=function(e){Nr&&Nr(e),$e=0;var t=(V=e.__c).__H;t&&(fn===V?(t.__h=[],V.__h=[],t.__.some(function(r){r.__N&&(r.__=r.__N),r.u=r.__N=void 0})):(t.__h.some(zt),t.__h.some(An),t.__h=[],$e=0)),fn=V},J.diffed=function(e){Or&&Or(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Hi.push(t)!==1&&Dr===J.requestAnimationFrame||((Dr=J.requestAnimationFrame)||Qs)(Xs)),t.__H.__.some(function(r){r.u&&(r.__H=r.u),r.u=void 0})),fn=V=null},J.__c=function(e,t){t.some(function(r){try{r.__h.some(zt),r.__h=r.__h.filter(function(i){return!i.__||An(i)})}catch(i){t.some(function(s){s.__h&&(s.__h=[])}),t=[],J.__e(i,r.__v)}}),zr&&zr(e,t)},J.unmount=function(e){Ur&&Ur(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.some(function(i){try{zt(i)}catch(s){t=s}}),r.__H=void 0,t&&J.__e(t,r.__v))};var Fr=typeof requestAnimationFrame=="function";function Qs(e){var t,r=function(){clearTimeout(i),Fr&&cancelAnimationFrame(t),setTimeout(e)},i=setTimeout(r,35);Fr&&(t=requestAnimationFrame(r))}function zt(e){var t=V,r=e.__c;typeof r=="function"&&(e.__c=void 0,r()),V=t}function An(e){var t=V;e.__c=e.__(),V=t}function Jn(e,t){return!e||e.length!==t.length||t.some(function(r,i){return r!==e[i]})}function Vi(e,t){return typeof t=="function"?t(e):t}function Zi(e,t){for(var r in t)e[r]=t[r];return e}function En(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 Ki(e,t){var r=t(),i=w({t:{__:r,u:t}}),s=i[0].t,a=i[1];return St(function(){s.__=r,s.u=t,gn(s)&&a({t:s})},[e,r,t]),W(function(){return gn(s)&&a({t:s}),e(function(){gn(s)&&a({t:s})})},[e]),r}function gn(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 Ji(e){e()}function Yi(e){return e}function Xi(){return[!1,Ji]}var Qi=St;function Ln(e,t){this.props=e,this.context=t}function ea(e,t){function r(s){var a=this.props.ref,o=a==s.ref;return!o&&a&&(a.call?a(null):a.current=null),t?!t(this.props,s)||!o:En(this.props,s)}function i(s){return this.shouldComponentUpdate=r,Ee(e,s)}return i.displayName="Memo("+(e.displayName||e.name)+")",i.prototype.isReactComponent=!0,i.__f=!0,i.type=e,i}(Ln.prototype=new xe).isPureReactComponent=!0,Ln.prototype.shouldComponentUpdate=function(e,t){return En(this.props,e)||En(this.state,t)};var Hr=P.__b;P.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Hr&&Hr(e)};var ta=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function na(e){function t(r){var i=Zi({},r);return delete i.ref,e(i,r.ref||null)}return t.$$typeof=ta,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(e.displayName||e.name)+")",t}var Wr=function(e,t){return e==null?null:Ae(Ae(e).map(t))},ra={map:Wr,forEach:Wr,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},ia=P.__e;P.__e=function(e,t,r,i){if(e.then){for(var s,a=t;a=a.__;)if((s=a.__c)&&s.__c)return t.__e==null&&(t.__e=r.__e,t.__k=r.__k),s.__c(e,t)}ia(e,t,r,i)};var jr=P.unmount;function es(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=Zi({},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 es(i,t,r)})),e}function ts(e,t,r){return e&&r&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(i){return ts(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 Ut(){this.__u=0,this.o=null,this.__b=null}function ns(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function sa(e){var t,r,i,s=null;function a(o){if(t||(t=e()).then(function(l){l&&(s=l.default||l),i=!0},function(l){r=l,i=!0}),r)throw r;if(!i)throw t;return s?Ee(s,o):null}return a.displayName="Lazy",a.__f=!0,a}function _t(){this.i=null,this.l=null}P.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),jr&&jr(e)},(Ut.prototype=new xe).__c=function(e,t){var r=t.__c,i=this;i.o==null&&(i.o=[]),i.o.push(r);var s=ns(i.__v),a=!1,o=function(){a||i.__z||(a=!0,r.__R=null,s?s(d):d())};r.__R=o;var l=r.__P;r.__P=null;var d=function(){if(!--i.__u){if(i.state.__a){var c=i.state.__a;i.__v.__k[0]=ts(c,c.__c.__P,c.__c.__O)}var m;for(i.setState({__a:i.__b=null});m=i.o.pop();)m.__P=l,m.forceUpdate()}};i.__u++||32&t.__u||i.setState({__a:i.__b=i.__v.__k[0]}),e.then(o,o)},Ut.prototype.componentWillUnmount=function(){this.o=[]},Ut.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]=es(this.__b,r,i.__O=i.__P)}this.__b=null}var s=t.__a&&Ee(ne,null,e.fallback);return s&&(s.__u&=-33),[Ee(ne,null,t.__a?null:e.children),s]};var qr=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 aa(e){return this.getChildContext=function(){return e.context},e.children}function la(e){var t=this,r=e.h;if(t.componentWillUnmount=function(){Xe(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(s,a){this.childNodes.push(s),t.h.insertBefore(s,a)},removeChild:function(s){this.childNodes.splice(this.childNodes.indexOf(s)>>>1,1),t.h.removeChild(s)}}}Xe(Ee(aa,{context:t.context},e.__v),t.v)}function oa(e,t){var r=Ee(la,{__v:e,h:t});return r.containerInfo=t,r}(_t.prototype=new xe).__a=function(e){var t=this,r=ns(t.__v),i=t.l.get(e);return i[0]++,function(s){var a=function(){t.props.revealOrder?(i.push(s),qr(t,e,i)):s()};r?r(a):a()}},_t.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},_t.prototype.componentDidUpdate=_t.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,r){qr(e,r,t)})};var rs=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,ca=/^(?: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]/,da=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,ua=/[A-Z0-9]/g,ha=typeof document<"u",pa=function(e){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(e)};function fa(e,t,r){return t.__k==null&&(t.textContent=""),Xe(e,t),typeof r=="function"&&r(),e?e.__c:null}function ga(e,t,r){return Fi(e,t),typeof r=="function"&&r(),e?e.__c:null}xe.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(xe.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var Gr=P.event;function ma(){}function va(){return this.cancelBubble}function _a(){return this.defaultPrevented}P.event=function(e){return Gr&&(e=Gr(e)),e.persist=ma,e.isPropagationStopped=va,e.isDefaultPrevented=_a,e.nativeEvent=e};var Yn,ba={enumerable:!1,configurable:!0,get:function(){return this.class}},Vr=P.vnode;P.vnode=function(e){typeof e.type=="string"&&function(t){var r=t.props,i=t.type,s={},a=i.indexOf("-")===-1;for(var o in r){var l=r[o];if(!(o==="value"&&"defaultValue"in r&&l==null||ha&&o==="children"&&i==="noscript"||o==="class"||o==="className")){var d=o.toLowerCase();o==="defaultValue"&&"value"in r&&r.value==null?o="value":o==="download"&&l===!0?l="":d==="translate"&&l==="no"?l=!1:d[0]==="o"&&d[1]==="n"?d==="ondoubleclick"?o="ondblclick":d!=="onchange"||i!=="input"&&i!=="textarea"||pa(r.type)?d==="onfocus"?o="onfocusin":d==="onblur"?o="onfocusout":da.test(o)&&(o=d):d=o="oninput":a&&ca.test(o)?o=o.replace(ua,"-$&").toLowerCase():l===null&&(l=void 0),d==="oninput"&&s[o=d]&&(o="oninputCapture"),s[o]=l}}i=="select"&&s.multiple&&Array.isArray(s.value)&&(s.value=Ae(r.children).forEach(function(c){c.props.selected=s.value.indexOf(c.props.value)!=-1})),i=="select"&&s.defaultValue!=null&&(s.value=Ae(r.children).forEach(function(c){c.props.selected=s.multiple?s.defaultValue.indexOf(c.props.value)!=-1:s.defaultValue==c.props.value})),r.class&&!r.className?(s.class=r.class,Object.defineProperty(s,"className",ba)):r.className&&(s.class=s.className=r.className),t.props=s}(e),e.$$typeof=rs,Vr&&Vr(e)};var Zr=P.__r;P.__r=function(e){Zr&&Zr(e),Yn=e.__c};var Kr=P.diffed;P.diffed=function(e){Kr&&Kr(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),Yn=null};var ya={ReactCurrentDispatcher:{current:{readContext:function(e){return Yn.__n[e.__c].props.value},useCallback:Kn,useContext:ji,useDebugValue:qi,useDeferredValue:Yi,useEffect:W,useId:Gi,useImperativeHandle:Wi,useInsertionEffect:Qi,useLayoutEffect:St,useMemo:Ce,useReducer:Zn,useRef:Le,useState:w,useSyncExternalStore:Ki,useTransition:Xi}}};function ka(e){return Ee.bind(null,e)}function Yt(e){return!!e&&e.$$typeof===rs}function xa(e){return Yt(e)&&e.type===ne}function wa(e){return!!e&&typeof e.displayName=="string"&&e.displayName.startsWith("Memo(")}function Sa(e){return Yt(e)?Ks.apply(null,arguments):e}function Ta(e){return!!e.__k&&(Xe(null,e),!0)}function Ca(e){return e&&(e.base||e.nodeType===1&&e)||null}var Aa=function(e,t){return e(t)},Ea=function(e,t){return e(t)},La=ne,Ra=Yt,Be={useState:w,useId:Gi,useReducer:Zn,useEffect:W,useLayoutEffect:St,useInsertionEffect:Qi,useTransition:Xi,useDeferredValue:Yi,useSyncExternalStore:Ki,startTransition:Ji,useRef:Le,useImperativeHandle:Wi,useMemo:Ce,useCallback:Kn,useContext:ji,useDebugValue:qi,version:"18.3.1",Children:ra,render:fa,hydrate:ga,unmountComponentAtNode:Ta,createPortal:oa,createElement:Ee,createContext:Js,createFactory:ka,cloneElement:Sa,createRef:Ws,Fragment:ne,isValidElement:Yt,isElement:Ra,isFragment:xa,isMemo:wa,findDOMNode:Ca,Component:xe,PureComponent:Ln,memo:ea,forwardRef:na,flushSync:Ea,unstable_batchedUpdates:Aa,StrictMode:La,Suspense:Ut,SuspenseList:_t,lazy:sa,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:ya},is={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Jr=Be.createContext&&Be.createContext(is),$a=["attr","size","title"];function Ma(e,t){if(e==null)return{};var r=Ia(e,t),i,s;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(s=0;s<a.length;s++)i=a[s],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(r[i]=e[i])}return r}function Ia(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 jt(){return jt=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},jt.apply(this,arguments)}function Yr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,i)}return r}function qt(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Yr(Object(r),!0).forEach(function(i){Da(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Yr(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function Da(e,t,r){return t=Pa(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Pa(e){var t=Na(e,"string");return typeof t=="symbol"?t:t+""}function Na(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 ss(e){return e&&e.map((t,r)=>Be.createElement(t.tag,qt({key:r},t.attr),ss(t.child)))}function U(e){return t=>Be.createElement(Oa,jt({attr:qt({},e.attr)},t),ss(e.child))}function Oa(e){var t=r=>{var{attr:i,size:s,title:a}=e,o=Ma(e,$a),l=s||r.size||"1em",d;return r.className&&(d=r.className),e.className&&(d=(d?d+" ":"")+e.className),Be.createElement("svg",jt({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},r.attr,i,o,{className:d,style:qt(qt({color:e.color||r.color},r.style),e.style),height:l,width:l,xmlns:"http://www.w3.org/2000/svg"}),a&&Be.createElement("title",null,a),e.children)};return Jr!==void 0?Be.createElement(Jr.Consumer,null,r=>t(r)):t(is)}function Xr(e){return U({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 za(e){return U({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 Ua(e){return U({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 Re(e){return U({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 Rn(e){return U({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 Ba(e){return U({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 Fa(e){return U({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 as(e){return U({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 Ha(e){return U({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 Wa(e){return U({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 et(e){return U({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 ja(e){return U({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 Qr(e){return U({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 Xn(e){return U({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 ls(e){return U({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 $n(e){return U({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 Ue(e){return U({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 qa(e){return U({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 Gt(e){return U({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 Ga(e){return U({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 os(e){return U({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 Va(e){return U({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 Za(e){return U({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 Ka(e){return U({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 Ja(e){return U({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 tt(e){return U({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 Ya(e){return U({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 Mn(e){return U({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2"},child:[]},{tag:"path",attr:{d:"M18 14h-8"},child:[]},{tag:"path",attr:{d:"M15 18h-5"},child:[]},{tag:"path",attr:{d:"M10 6h8v4h-8V6Z"},child:[]}]})(e)}function ue(e){return U({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 In(e){return U({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 Xa(e){return U({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 Qa(e){return U({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 el(e){return U({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 Dn(e){return U({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 tl(e){return U({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 ei(e){return U({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 nt(e){return U({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 Pn(e){return U({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)}const ti=[{id:"overview",label:"Overview",icon:Za,section:"dashboard"},{id:"history",label:"Messages",icon:tt,section:"dashboard"},{id:"approvals",label:"Approvals",icon:za,section:"dashboard"},{id:"digests",label:"Digests",icon:Mn,section:"dashboard"},{id:"audit",label:"Audit",icon:In,section:"dashboard"},{id:"usage",label:"Usage",icon:Ue,section:"dashboard"},{id:"coding",label:"Coding Agent",icon:Xn,section:"dashboard"},{id:"memory",label:"Memory",icon:$n,section:"settings"},{id:"templates",label:"Templates",icon:Gt,section:"settings"},{id:"model",label:"Model",icon:ls,section:"settings"},{id:"skills",label:"Skills",icon:Pn,section:"settings"},{id:"cron",label:"Scheduled Jobs",icon:et,section:"settings"},{id:"config",label:"Config",icon:el,section:"settings"},{id:"logs",label:"Logs",icon:Ka,section:"footer"},{id:"health",label:"Health",icon:os,section:"footer"}],nl=[{id:"dashboard",label:"Dashboard"},{id:"settings",label:"Settings"}];function rl({currentPage:e,onNavigate:t,botName:r,botEmoji:i,pendingApprovals:s,isNarrow:a,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"})]}),a&&n("button",{class:"sidebar-close-btn",onClick:o,"aria-label":"Close sidebar",children:n(Ba,{size:16})})]}),nl.map(l=>{const d=ti.filter(c=>c.section===l.id);return n("div",{class:"sidebar-section",children:[n("div",{class:"sidebar-section-label",children:l.label}),d.map(c=>{const m=c.id==="approvals"&&s?s:void 0,h=c.icon;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(h,{size:16})}),n("span",{class:"sidebar-item-label",children:c.label}),m?n("span",{class:"item-badge",children:m}):null]},c.id)})]},l.id)}),n("div",{class:"sidebar-spacer"}),n("div",{class:"sidebar-footer",children:[ti.filter(l=>l.section==="footer").map(l=>{const d=l.icon;return n("button",{"data-page":l.id,class:`sidebar-footer-item${e===l.id?" active":""}`,onClick:()=>t(l.id),children:[n("span",{class:"sidebar-item-icon",children:n(d,{size:16})}),n("span",{class:"sidebar-item-label",children:l.label})]},l.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(Ua,{size:16})}),n("span",{class:"sidebar-item-label",children:"Help Docs"})]})]})]})}function il({toasts:e}){return n("div",{class:"toast-container",children:e.map(t=>n("div",{class:`toast ${t.type}`,children:t.message},t.id))})}function sl(){const[e,t]=w([]),r=Kn((i,s="info",a=3e3)=>{const o=crypto.randomUUID();t(l=>[...l,{id:o,message:i,type:s}]),setTimeout(()=>{t(l=>l.filter(d=>d.id!==o))},a)},[]);return{toasts:e,showToast:r}}const Qn="dashboard_token",Nn="skimpy-dashboard-unauthorized";function cs(){return localStorage.getItem(Qn)??""}function al(e){localStorage.setItem(Qn,e)}function ll(){localStorage.removeItem(Qn)}function ol(e){const t=()=>e();return window.addEventListener(Nn,t),()=>window.removeEventListener(Nn,t)}class cl extends Error{constructor(t,r){super(r),this.status=t,this.name="ApiError"}}async function B(e,t={}){const r=cs(),i={...r?{Authorization:`Bearer ${r}`}:{},...t.headers??{}};t.body&&(i["Content-Type"]="application/json");const s=await fetch(`/api/dashboard/${e}`,{...t,headers:i});if(!s.ok){s.status===401&&(ll(),window.dispatchEvent(new Event(Nn)));const a=await s.text().catch(()=>s.statusText);throw new cl(s.status,a)}return s.json()}const dl=()=>B("status"),ni=()=>B("health"),ri=()=>B("doctor");function ds(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 B(`audit${r?`?${r}`:""}`)}const us=()=>B("approvals"),hs=e=>B(`approvals/${encodeURIComponent(e)}/approve`,{method:"POST"}),ps=e=>B(`approvals/${encodeURIComponent(e)}/deny`,{method:"POST"}),ul=()=>B("cron"),hl=e=>B(`cron/${encodeURIComponent(e)}/run`,{method:"POST"}),pl=e=>B(`cron/prompt-file?path=${encodeURIComponent(e)}`),fl=()=>B("model"),gl=e=>B("model",{method:"POST",body:JSON.stringify({model:e})}),ml=e=>B(`memory/${encodeURIComponent(e)}`),vl=(e,t)=>B(`memory/${encodeURIComponent(e)}/${encodeURIComponent(t)}`),_l=e=>B(`templates/${encodeURIComponent(e)}`),bl=(e,t)=>B(`templates/${encodeURIComponent(e)}/${encodeURIComponent(t)}`),yl=(e,t,r)=>B(`templates/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({content:r})}),kl=()=>B("logs"),xl=e=>B(e),wl=()=>B("code-agents"),Sl=e=>B(`code-agents/${encodeURIComponent(e)}/cancel`,{method:"POST"}),Tl=(e,t)=>B("messages/agent",{method:"POST",body:JSON.stringify({message:e,model:t})}),Cl=e=>{const t=e?`?channel=${encodeURIComponent(e)}`:"";return B(`conversations${t}`)},Al=(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 B(`conversations/${encodeURIComponent(e)}${i?`?${i}`:""}`)},er=()=>B("config"),fs=e=>B("config",{method:"PUT",body:JSON.stringify({config:e})}),El=()=>B("reload",{method:"POST"}),Ll=()=>B("digests"),Rl=e=>B(`digests/${encodeURIComponent(e)}`),$l=()=>B("skills"),Ml=e=>B(`skills/${encodeURIComponent(e)}`),Il=(e,t)=>B("skills",{method:"POST",body:JSON.stringify({name:e,content:t})}),Dl=(e,t)=>B(`skills/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({enabled:t})}),Pl=(e,t)=>B(`skills/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({content:t})}),Nl=e=>B(`skills/${encodeURIComponent(e)}`,{method:"DELETE"}),tr=()=>B("usage");function Ol(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 B(`usage/records${r?`?${r}`:""}`)}function mn(e){const t=Math.floor(e/1e3);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 zl(){const e=new Date().getHours();return e<12?"Good morning":e<17?"Good afternoon":"Good evening"}function Ul(e){const t=new Date(e),r=Date.now()-t.getTime(),i=Math.floor(r/1e3);if(i<60)return`${i}s ago`;const s=Math.floor(i/60);if(s<60)return`${s}m ago`;const a=Math.floor(s/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function Bl(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 ii(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 Fl(e){return e?e==="telegram"?"Telegram":e==="discord"?"Discord":e:"—"}function Hl(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 si({onNavigate:e,showToast:t}){var f;const[r,i]=w(null),[s,a]=w([]),[o,l]=w([]),[d,c]=w(null),[m,h]=w(new Set),[v,g]=w(!0);W(()=>{u();const _=setInterval(u,1e4);return()=>clearInterval(_)},[]);async function u(){const[_,A,R,O]=await Promise.allSettled([dl(),ds({limit:8,offset:0}),us(),tr()]);_.status==="fulfilled"?i(_.value):console.error("[overview] status load failed",_.reason),A.status==="fulfilled"?a(A.value.traces??[]):console.error("[overview] audit load failed",A.reason),R.status==="fulfilled"?l(R.value.pending??[]):console.error("[overview] approvals load failed",R.reason),O.status==="fulfilled"&&c(O.value),g(!1)}async function b(_,A){h(R=>new Set([...R,_]));try{A?(await hs(_),t==null||t("Command approved","success")):(await ps(_),t==null||t("Command denied","warning")),await u()}catch{t==null||t("Action failed","error")}finally{h(R=>{const O=new Set(R);return O.delete(_),O})}}const x=_=>_==="telegram"?n(Xa,{size:14}):_==="cron"?n(et,{size:14}):n(Qa,{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((_,A)=>_!=null&&_.nextRun?A.nextRun?new Date(_.nextRun)<new Date(A.nextRun)?_:A:_:A,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?mn(r.uptime):"—"]})})]}),n("div",{class:"welcome-banner",children:[n("div",{class:"welcome-greeting",children:[zl(),", Katrina"]}),n("div",{class:"welcome-sub",children:r?`Running for ${mn(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(Dn,{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:Bl(_.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-5",children:[n("div",{class:"stat-card",children:[n("div",{class:"stat-icon sage",children:n(et,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value",children:r?mn(r.uptime):"—"}),n("div",{class:"stat-subtitle",children:"Uptime"})]})]}),n("div",{class:"stat-card",children:[n("div",{class:"stat-icon amber",children:n(ja,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value stat-value-md",children:ii(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(ls,{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(tt,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value stat-value-md",children:Fl((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(Ue,{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(Xr,{size:14})]})})]}),n("div",{class:"feed-card",children:n("div",{class:"feed",children:s.length===0?n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(Va,{size:18})}),n("div",{class:"empty-state-text",children:"No recent audit logs"})]}):s.slice(0,6).map(_=>n("div",{class:"feed-item",children:[n("div",{class:`feed-icon ${_.trigger==="telegram"?"telegram":_.trigger==="cron"?"cron":"system"}`,children:x(_.trigger)}),n("div",{children:[n("div",{class:"feed-title",children:_.trigger}),n("div",{class:"feed-detail",children:Hl(_)})]}),n("div",{class:"feed-time",children:Ul(_.startedAt)})]},_.traceId))})})]}),(((f=r==null?void 0:r.cronJobs)==null?void 0:f.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(Xr,{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:ii(_.nextRun)})]},_.id))})]})]})}function On(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Wl(e){const t=e.trim();return/^(https?:|mailto:|\/|#)/i.test(t)?t:"#"}function lt(e){let t=On(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,s)=>`<a href="${On(Wl(s))}" target="_blank" rel="noreferrer">${i}</a>`),t}function jl(e){const t=e.replace(/\r\n/g,`
|
|
1
|
+
var Fs=Object.defineProperty;var Hs=(e,t,r)=>t in e?Fs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var q=(e,t,r)=>Hs(e,typeof t!="symbol"?t+"":t,r);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function r(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function i(s){if(s.ep)return;s.ep=!0;const a=r(s);fetch(s.href,a)}})();var xt,P,$i,Oe,$r,Mi,Ii,Di,jn,Sn,Tn,Pi,Ht={},Wt=[],Ws=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,wt=Array.isArray;function ke(e,t){for(var r in t)e[r]=t[r];return e}function qn(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Ee(e,t,r){var i,s,a,o={};for(a in t)a=="key"?i=t[a]:a=="ref"?s=t[a]:o[a]=t[a];if(arguments.length>2&&(o.children=arguments.length>3?xt.call(arguments,2):r),typeof e=="function"&&e.defaultProps!=null)for(a in e.defaultProps)o[a]===void 0&&(o[a]=e.defaultProps[a]);return kt(e,o,i,s,null)}function kt(e,t,r,i,s){var a={type:e,props:t,key:r,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s??++$i,__i:-1,__u:0};return s==null&&P.vnode!=null&&P.vnode(a),a}function js(){return{current:null}}function ne(e){return e.children}function xe(e,t){this.props=e,this.context=t}function Qe(e,t){if(t==null)return e.__?Qe(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"?Qe(e):null}function qs(e){if(e.__P&&e.__d){var t=e.__v,r=t.__e,i=[],s=[],a=ke({},t);a.__v=t.__v+1,P.vnode&&P.vnode(a),Gn(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[r]:null,i,r??Qe(t),!!(32&t.__u),s),a.__v=t.__v,a.__.__k[a.__i]=a,Ui(i,a,s),t.__e=t.__=null,a.__e!=r&&Ni(a)}}function Ni(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}),Ni(e)}function Cn(e){(!e.__d&&(e.__d=!0)&&Oe.push(e)&&!jt.__r++||$r!=P.debounceRendering)&&(($r=P.debounceRendering)||Mi)(jt)}function jt(){for(var e,t=1;Oe.length;)Oe.length>t&&Oe.sort(Ii),e=Oe.shift(),t=Oe.length,qs(e);jt.__r=0}function Oi(e,t,r,i,s,a,o,l,d,c,m){var h,v,g,u,b,x,k,f=i&&i.__k||Wt,_=t.length;for(d=Gs(r,t,f,d,_),h=0;h<_;h++)(g=r.__k[h])!=null&&(v=g.__i!=-1&&f[g.__i]||Ht,g.__i=h,x=Gn(e,g,v,s,a,o,l,d,c,m),u=g.__e,g.ref&&v.ref!=g.ref&&(v.ref&&Vn(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=zi(g,d,e,k):typeof g.type=="function"&&x!==void 0?d=x:u&&(d=u.nextSibling),g.__u&=-7);return r.__e=b,d}function Gs(e,t,r,i,s){var a,o,l,d,c,m=r.length,h=m,v=0;for(e.__k=new Array(s),a=0;a<s;a++)(o=t[a])!=null&&typeof o!="boolean"&&typeof o!="function"?(typeof o=="string"||typeof o=="number"||typeof o=="bigint"||o.constructor==String?o=e.__k[a]=kt(null,o,null,null,null):wt(o)?o=e.__k[a]=kt(ne,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=kt(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,d=a+v,o.__=e,o.__b=e.__b+1,l=null,(c=o.__i=Vs(o,r,d,h))!=-1&&(h--,(l=r[c])&&(l.__u|=2)),l==null||l.__v==null?(c==-1&&(s>m?v--:s<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[a]=null;if(h)for(a=0;a<m;a++)(l=r[a])!=null&&!(2&l.__u)&&(l.__e==i&&(i=Qe(l)),Fi(l,l));return i}function zi(e,t,r,i){var s,a;if(typeof e.type=="function"){for(s=e.__k,a=0;s&&a<s.length;a++)s[a]&&(s[a].__=e,t=zi(s[a],t,r,i));return t}e.__e!=t&&(i&&(t&&e.type&&!t.parentNode&&(t=Qe(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"||(wt(e)?e.some(function(r){Ae(r,t)}):t.push(e)),t}function Vs(e,t,r,i){var s,a,o,l=e.key,d=e.type,c=t[r],m=c!=null&&(2&c.__u)==0;if(c===null&&l==null||m&&l==c.key&&d==c.type)return r;if(i>(m?1:0)){for(s=r-1,a=r+1;s>=0||a<t.length;)if((c=t[o=s>=0?s--:a++])!=null&&!(2&c.__u)&&l==c.key&&d==c.type)return o}return-1}function Mr(e,t,r){t[0]=="-"?e.setProperty(t,r??""):e[t]=r==null?"":typeof r!="number"||Ws.test(t)?r:r+"px"}function It(e,t,r,i,s){var a,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||Mr(e.style,t,"");if(r)for(t in r)i&&r[t]==i[t]||Mr(e.style,t,r[t])}else if(t[0]=="o"&&t[1]=="n")a=t!=(t=t.replace(Di,"$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+a]=r,r?i?r.u=i.u:(r.u=jn,e.addEventListener(t,a?Tn:Sn,a)):e.removeEventListener(t,a?Tn:Sn,a);else{if(s=="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 Ir(e){return function(t){if(this.l){var r=this.l[t.type+e];if(t.t==null)t.t=jn++;else if(t.t<r.u)return;return r(P.event?P.event(t):t)}}}function Gn(e,t,r,i,s,a,o,l,d,c){var m,h,v,g,u,b,x,k,f,_,A,M,O,D,L,S=t.type;if(t.constructor!==void 0)return null;128&r.__u&&(d=!!(32&r.__u),a=[l=t.__e=r.__e]),(m=P.__b)&&m(t);e:if(typeof S=="function")try{if(k=t.props,f="prototype"in S&&S.prototype.render,_=(m=S.contextType)&&i[m.__c],A=m?_?_.props.value:m.__:i,r.__c?x=(h=t.__c=r.__c).__=h.__E:(f?t.__c=h=new S(k,A):(t.__c=h=new xe(k,A),h.constructor=S,h.render=Ks),_&&_.sub(h),h.state||(h.state={}),h.__n=i,v=h.__d=!0,h.__h=[],h._sb=[]),f&&h.__s==null&&(h.__s=h.state),f&&S.getDerivedStateFromProps!=null&&(h.__s==h.state&&(h.__s=ke({},h.__s)),ke(h.__s,S.getDerivedStateFromProps(k,h.__s))),g=h.props,u=h.state,h.__v=t,v)f&&S.getDerivedStateFromProps==null&&h.componentWillMount!=null&&h.componentWillMount(),f&&h.componentDidMount!=null&&h.__h.push(h.componentDidMount);else{if(f&&S.getDerivedStateFromProps==null&&k!==g&&h.componentWillReceiveProps!=null&&h.componentWillReceiveProps(k,A),t.__v==r.__v||!h.__e&&h.shouldComponentUpdate!=null&&h.shouldComponentUpdate(k,h.__s,A)===!1){t.__v!=r.__v&&(h.props=k,h.state=h.__s,h.__d=!1),t.__e=r.__e,t.__k=r.__k,t.__k.some(function(y){y&&(y.__=t)}),Wt.push.apply(h.__h,h._sb),h._sb=[],h.__h.length&&o.push(h);break e}h.componentWillUpdate!=null&&h.componentWillUpdate(k,h.__s,A),f&&h.componentDidUpdate!=null&&h.__h.push(function(){h.componentDidUpdate(g,u,b)})}if(h.context=A,h.props=k,h.__P=e,h.__e=!1,M=P.__r,O=0,f)h.state=h.__s,h.__d=!1,M&&M(t),m=h.render(h.props,h.state,h.context),Wt.push.apply(h.__h,h._sb),h._sb=[];else do h.__d=!1,M&&M(t),m=h.render(h.props,h.state,h.context),h.state=h.__s;while(h.__d&&++O<25);h.state=h.__s,h.getChildContext!=null&&(i=ke(ke({},i),h.getChildContext())),f&&!v&&h.getSnapshotBeforeUpdate!=null&&(b=h.getSnapshotBeforeUpdate(g,u)),D=m!=null&&m.type===ne&&m.key==null?Bi(m.props.children):m,l=Oi(e,wt(D)?D:[D],t,r,i,s,a,o,l,d,c),h.base=t.__e,t.__u&=-161,h.__h.length&&o.push(h),x&&(h.__E=h.__=null)}catch(y){if(t.__v=null,d||a!=null)if(y.then){for(t.__u|=d?160:128;l&&l.nodeType==8&&l.nextSibling;)l=l.nextSibling;a[a.indexOf(l)]=null,t.__e=l}else{for(L=a.length;L--;)qn(a[L]);An(t)}else t.__e=r.__e,t.__k=r.__k,y.then||An(t);P.__e(y,t,r)}else a==null&&t.__v==r.__v?(t.__k=r.__k,t.__e=r.__e):l=t.__e=Zs(r.__e,t,r,i,s,a,o,d,c);return(m=P.diffed)&&m(t),128&t.__u?void 0:l}function An(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(An))}function Ui(e,t,r){for(var i=0;i<r.length;i++)Vn(r[i],r[++i],r[++i]);P.__c&&P.__c(t,e),e.some(function(s){try{e=s.__h,s.__h=[],e.some(function(a){a.call(s)})}catch(a){P.__e(a,s.__v)}})}function Bi(e){return typeof e!="object"||e==null||e.__b>0?e:wt(e)?e.map(Bi):ke({},e)}function Zs(e,t,r,i,s,a,o,l,d){var c,m,h,v,g,u,b,x=r.props||Ht,k=t.props,f=t.type;if(f=="svg"?s="http://www.w3.org/2000/svg":f=="math"?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),a!=null){for(c=0;c<a.length;c++)if((g=a[c])&&"setAttribute"in g==!!f&&(f?g.localName==f:g.nodeType==3)){e=g,a[c]=null;break}}if(e==null){if(f==null)return document.createTextNode(k);e=document.createElementNS(s,f,k.is&&k),l&&(P.__m&&P.__m(t,a),l=!1),a=null}if(f==null)x===k||l&&e.data==k||(e.data=k);else{if(a=a&&xt.call(e.childNodes),!l&&a!=null)for(x={},c=0;c<e.attributes.length;c++)x[(g=e.attributes[c]).name]=g.value;for(c in x)g=x[c],c=="dangerouslySetInnerHTML"?h=g:c=="children"||c in k||c=="value"&&"defaultValue"in k||c=="checked"&&"defaultChecked"in k||It(e,c,null,g,s);for(c in k)g=k[c],c=="children"?v=g:c=="dangerouslySetInnerHTML"?m=g:c=="value"?u=g:c=="checked"?b=g:l&&typeof g!="function"||x[c]===g||It(e,c,g,x[c],s);if(m)l||h&&(m.__html==h.__html||m.__html==e.innerHTML)||(e.innerHTML=m.__html),t.__k=[];else if(h&&(e.innerHTML=""),Oi(t.type=="template"?e.content:e,wt(v)?v:[v],t,r,i,f=="foreignObject"?"http://www.w3.org/1999/xhtml":s,a,o,a?a[0]:r.__k&&Qe(r,0),l,d),a!=null)for(c=a.length;c--;)qn(a[c]);l||(c="value",f=="progress"&&u==null?e.removeAttribute("value"):u!=null&&(u!==e[c]||f=="progress"&&!u||f=="option"&&u!=x[c])&&It(e,c,u,x[c],s),c="checked",b!=null&&b!=e[c]&&It(e,c,b,x[c],s))}return e}function Vn(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(s){P.__e(s,r)}}function Fi(e,t,r){var i,s;if(P.unmount&&P.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||Vn(i,null,t)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(a){P.__e(a,t)}i.base=i.__P=null}if(i=e.__k)for(s=0;s<i.length;s++)i[s]&&Fi(i[s],t,r||typeof e.type!="function");r||qn(e.__e),e.__c=e.__=e.__e=void 0}function Ks(e,t,r){return this.constructor(e,r)}function et(e,t,r){var i,s,a,o;t==document&&(t=document.documentElement),P.__&&P.__(e,t),s=(i=typeof r=="function")?null:r&&r.__k||t.__k,a=[],o=[],Gn(t,e=(!i&&r||t).__k=Ee(ne,null,[e]),s||Ht,Ht,t.namespaceURI,!i&&r?[r]:s?null:t.firstChild?xt.call(t.childNodes):null,a,!i&&r?r:s?s.__e:t.firstChild,i,o),Ui(a,e,o)}function Hi(e,t){et(e,t,Hi)}function Js(e,t,r){var i,s,a,o,l=ke({},e.props);for(a in e.type&&e.type.defaultProps&&(o=e.type.defaultProps),t)a=="key"?i=t[a]:a=="ref"?s=t[a]:l[a]=t[a]===void 0&&o!=null?o[a]:t[a];return arguments.length>2&&(l.children=arguments.length>3?xt.call(arguments,2):r),kt(e.type,l,i||e.key,s||e.ref,null)}function Ys(e){function t(r){var i,s;return this.getChildContext||(i=new Set,(s={})[t.__c]=this,this.getChildContext=function(){return s},this.componentWillUnmount=function(){i=null},this.shouldComponentUpdate=function(a){this.props.value!=a.value&&i.forEach(function(o){o.__e=!0,Cn(o)})},this.sub=function(a){i.add(a);var o=a.componentWillUnmount;a.componentWillUnmount=function(){i&&i.delete(a),o&&o.call(a)}}),r.children}return t.__c="__cC"+Pi++,t.__=e,t.Provider=t.__l=(t.Consumer=function(r,i){return r.children(i)}).contextType=t,t}xt=Wt.slice,P={__e:function(e,t,r,i){for(var s,a,o;t=t.__;)if((s=t.__c)&&!s.__)try{if((a=s.constructor)&&a.getDerivedStateFromError!=null&&(s.setState(a.getDerivedStateFromError(e)),o=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(e,i||{}),o=s.__d),o)return s.__E=s}catch(l){e=l}throw e}},$i=0,xe.prototype.setState=function(e,t){var r;r=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=ke({},this.state),typeof e=="function"&&(e=e(ke({},r),this.props)),e&&ke(r,e),e!=null&&this.__v&&(t&&this._sb.push(t),Cn(this))},xe.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Cn(this))},xe.prototype.render=ne,Oe=[],Mi=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ii=function(e,t){return e.__v.__b-t.__v.__b},jt.__r=0,Di=/(PointerCapture)$|Capture$/i,jn=0,Sn=Ir(!1),Tn=Ir(!0),Pi=0;var Xs=0;function n(e,t,r,i,s,a){t||(t={});var o,l,d=t;if("ref"in d)for(l in d={},t)l=="ref"?o=t[l]:d[l]=t[l];var c={type:e,props:d,key:r,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Xs,__i:-1,__u:0,__source:s,__self:a};if(typeof e=="function"&&(o=e.defaultProps))for(l in o)d[l]===void 0&&(d[l]=o[l]);return P.vnode&&P.vnode(c),c}var $e,V,gn,Dr,tt=0,Wi=[],J=P,Pr=J.__b,Nr=J.__r,Or=J.diffed,zr=J.__c,Ur=J.unmount,Br=J.__;function it(e,t){J.__h&&J.__h(V,e,tt||t),tt=0;var r=V.__H||(V.__H={__:[],__h:[]});return e>=r.__.length&&r.__.push({}),r.__[e]}function w(e){return tt=1,Zn(Zi,e)}function Zn(e,t,r){var i=it($e++,2);if(i.t=e,!i.__c&&(i.__=[r?r(t):Zi(void 0,t),function(l){var d=i.__N?i.__N[0]:i.__[0],c=i.t(d,l);d!==c&&(i.__N=[c,i.__[1]],i.__c.setState({}))}],i.__c=V,!V.__f)){var s=function(l,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!a||a.call(this,l,d,c);var h=i.__c.props!==l;return m.some(function(v){if(v.__N){var g=v.__[0];v.__=v.__N,v.__N=void 0,g!==v.__[0]&&(h=!0)}}),a&&a.call(this,l,d,c)||h};V.__f=!0;var a=V.shouldComponentUpdate,o=V.componentWillUpdate;V.componentWillUpdate=function(l,d,c){if(this.__e){var m=a;a=void 0,s(l,d,c),a=m}o&&o.call(this,l,d,c)},V.shouldComponentUpdate=s}return i.__N||i.__}function W(e,t){var r=it($e++,3);!J.__s&&Jn(r.__H,t)&&(r.__=e,r.u=t,V.__H.__h.push(r))}function St(e,t){var r=it($e++,4);!J.__s&&Jn(r.__H,t)&&(r.__=e,r.u=t,V.__h.push(r))}function Le(e){return tt=5,Ce(function(){return{current:e}},[])}function ji(e,t,r){tt=6,St(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 Ce(e,t){var r=it($e++,7);return Jn(r.__H,t)&&(r.__=e(),r.__H=t,r.__h=e),r.__}function Kn(e,t){return tt=8,Ce(function(){return e},t)}function qi(e){var t=V.context[e.__c],r=it($e++,9);return r.c=e,t?(r.__==null&&(r.__=!0,t.sub(V)),t.props.value):e.__}function Gi(e,t){J.useDebugValue&&J.useDebugValue(t?t(e):e)}function Vi(){var e=it($e++,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 Qs(){for(var e;e=Wi.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(zt),t.__h.some(En),t.__h=[]}catch(r){t.__h=[],J.__e(r,e.__v)}}}J.__b=function(e){V=null,Pr&&Pr(e)},J.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Br&&Br(e,t)},J.__r=function(e){Nr&&Nr(e),$e=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(zt),t.__h.some(En),t.__h=[],$e=0)),gn=V},J.diffed=function(e){Or&&Or(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Wi.push(t)!==1&&Dr===J.requestAnimationFrame||((Dr=J.requestAnimationFrame)||ea)(Qs)),t.__H.__.some(function(r){r.u&&(r.__H=r.u),r.u=void 0})),gn=V=null},J.__c=function(e,t){t.some(function(r){try{r.__h.some(zt),r.__h=r.__h.filter(function(i){return!i.__||En(i)})}catch(i){t.some(function(s){s.__h&&(s.__h=[])}),t=[],J.__e(i,r.__v)}}),zr&&zr(e,t)},J.unmount=function(e){Ur&&Ur(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.some(function(i){try{zt(i)}catch(s){t=s}}),r.__H=void 0,t&&J.__e(t,r.__v))};var Fr=typeof requestAnimationFrame=="function";function ea(e){var t,r=function(){clearTimeout(i),Fr&&cancelAnimationFrame(t),setTimeout(e)},i=setTimeout(r,35);Fr&&(t=requestAnimationFrame(r))}function zt(e){var t=V,r=e.__c;typeof r=="function"&&(e.__c=void 0,r()),V=t}function En(e){var t=V;e.__c=e.__(),V=t}function Jn(e,t){return!e||e.length!==t.length||t.some(function(r,i){return r!==e[i]})}function Zi(e,t){return typeof t=="function"?t(e):t}function Ki(e,t){for(var r in t)e[r]=t[r];return e}function Ln(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 Ji(e,t){var r=t(),i=w({t:{__:r,u:t}}),s=i[0].t,a=i[1];return St(function(){s.__=r,s.u=t,mn(s)&&a({t:s})},[e,r,t]),W(function(){return mn(s)&&a({t:s}),e(function(){mn(s)&&a({t:s})})},[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 Yi(e){e()}function Xi(e){return e}function Qi(){return[!1,Yi]}var es=St;function Rn(e,t){this.props=e,this.context=t}function ta(e,t){function r(s){var a=this.props.ref,o=a==s.ref;return!o&&a&&(a.call?a(null):a.current=null),t?!t(this.props,s)||!o:Ln(this.props,s)}function i(s){return this.shouldComponentUpdate=r,Ee(e,s)}return i.displayName="Memo("+(e.displayName||e.name)+")",i.prototype.isReactComponent=!0,i.__f=!0,i.type=e,i}(Rn.prototype=new xe).isPureReactComponent=!0,Rn.prototype.shouldComponentUpdate=function(e,t){return Ln(this.props,e)||Ln(this.state,t)};var Hr=P.__b;P.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Hr&&Hr(e)};var na=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function ra(e){function t(r){var i=Ki({},r);return delete i.ref,e(i,r.ref||null)}return t.$$typeof=na,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(e.displayName||e.name)+")",t}var Wr=function(e,t){return e==null?null:Ae(Ae(e).map(t))},ia={map:Wr,forEach:Wr,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},sa=P.__e;P.__e=function(e,t,r,i){if(e.then){for(var s,a=t;a=a.__;)if((s=a.__c)&&s.__c)return t.__e==null&&(t.__e=r.__e,t.__k=r.__k),s.__c(e,t)}sa(e,t,r,i)};var jr=P.unmount;function ts(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=Ki({},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 ts(i,t,r)})),e}function ns(e,t,r){return e&&r&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(i){return ns(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 Ut(){this.__u=0,this.o=null,this.__b=null}function rs(e){if(!e.__)return null;var t=e.__.__c;return t&&t.__a&&t.__a(e)}function aa(e){var t,r,i,s=null;function a(o){if(t||(t=e()).then(function(l){l&&(s=l.default||l),i=!0},function(l){r=l,i=!0}),r)throw r;if(!i)throw t;return s?Ee(s,o):null}return a.displayName="Lazy",a.__f=!0,a}function bt(){this.i=null,this.l=null}P.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),jr&&jr(e)},(Ut.prototype=new xe).__c=function(e,t){var r=t.__c,i=this;i.o==null&&(i.o=[]),i.o.push(r);var s=rs(i.__v),a=!1,o=function(){a||i.__z||(a=!0,r.__R=null,s?s(d):d())};r.__R=o;var l=r.__P;r.__P=null;var d=function(){if(!--i.__u){if(i.state.__a){var c=i.state.__a;i.__v.__k[0]=ns(c,c.__c.__P,c.__c.__O)}var m;for(i.setState({__a:i.__b=null});m=i.o.pop();)m.__P=l,m.forceUpdate()}};i.__u++||32&t.__u||i.setState({__a:i.__b=i.__v.__k[0]}),e.then(o,o)},Ut.prototype.componentWillUnmount=function(){this.o=[]},Ut.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]=ts(this.__b,r,i.__O=i.__P)}this.__b=null}var s=t.__a&&Ee(ne,null,e.fallback);return s&&(s.__u&=-33),[Ee(ne,null,t.__a?null:e.children),s]};var qr=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 la(e){return this.getChildContext=function(){return e.context},e.children}function oa(e){var t=this,r=e.h;if(t.componentWillUnmount=function(){et(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(s,a){this.childNodes.push(s),t.h.insertBefore(s,a)},removeChild:function(s){this.childNodes.splice(this.childNodes.indexOf(s)>>>1,1),t.h.removeChild(s)}}}et(Ee(la,{context:t.context},e.__v),t.v)}function ca(e,t){var r=Ee(oa,{__v:e,h:t});return r.containerInfo=t,r}(bt.prototype=new xe).__a=function(e){var t=this,r=rs(t.__v),i=t.l.get(e);return i[0]++,function(s){var a=function(){t.props.revealOrder?(i.push(s),qr(t,e,i)):s()};r?r(a):a()}},bt.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},bt.prototype.componentDidUpdate=bt.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,r){qr(e,r,t)})};var is=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,da=/^(?: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]/,ua=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,ha=/[A-Z0-9]/g,pa=typeof document<"u",fa=function(e){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(e)};function ga(e,t,r){return t.__k==null&&(t.textContent=""),et(e,t),typeof r=="function"&&r(),e?e.__c:null}function ma(e,t,r){return Hi(e,t),typeof r=="function"&&r(),e?e.__c:null}xe.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(xe.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var Gr=P.event;function va(){}function _a(){return this.cancelBubble}function ba(){return this.defaultPrevented}P.event=function(e){return Gr&&(e=Gr(e)),e.persist=va,e.isPropagationStopped=_a,e.isDefaultPrevented=ba,e.nativeEvent=e};var Yn,ya={enumerable:!1,configurable:!0,get:function(){return this.class}},Vr=P.vnode;P.vnode=function(e){typeof e.type=="string"&&function(t){var r=t.props,i=t.type,s={},a=i.indexOf("-")===-1;for(var o in r){var l=r[o];if(!(o==="value"&&"defaultValue"in r&&l==null||pa&&o==="children"&&i==="noscript"||o==="class"||o==="className")){var d=o.toLowerCase();o==="defaultValue"&&"value"in r&&r.value==null?o="value":o==="download"&&l===!0?l="":d==="translate"&&l==="no"?l=!1:d[0]==="o"&&d[1]==="n"?d==="ondoubleclick"?o="ondblclick":d!=="onchange"||i!=="input"&&i!=="textarea"||fa(r.type)?d==="onfocus"?o="onfocusin":d==="onblur"?o="onfocusout":ua.test(o)&&(o=d):d=o="oninput":a&&da.test(o)?o=o.replace(ha,"-$&").toLowerCase():l===null&&(l=void 0),d==="oninput"&&s[o=d]&&(o="oninputCapture"),s[o]=l}}i=="select"&&s.multiple&&Array.isArray(s.value)&&(s.value=Ae(r.children).forEach(function(c){c.props.selected=s.value.indexOf(c.props.value)!=-1})),i=="select"&&s.defaultValue!=null&&(s.value=Ae(r.children).forEach(function(c){c.props.selected=s.multiple?s.defaultValue.indexOf(c.props.value)!=-1:s.defaultValue==c.props.value})),r.class&&!r.className?(s.class=r.class,Object.defineProperty(s,"className",ya)):r.className&&(s.class=s.className=r.className),t.props=s}(e),e.$$typeof=is,Vr&&Vr(e)};var Zr=P.__r;P.__r=function(e){Zr&&Zr(e),Yn=e.__c};var Kr=P.diffed;P.diffed=function(e){Kr&&Kr(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),Yn=null};var ka={ReactCurrentDispatcher:{current:{readContext:function(e){return Yn.__n[e.__c].props.value},useCallback:Kn,useContext:qi,useDebugValue:Gi,useDeferredValue:Xi,useEffect:W,useId:Vi,useImperativeHandle:ji,useInsertionEffect:es,useLayoutEffect:St,useMemo:Ce,useReducer:Zn,useRef:Le,useState:w,useSyncExternalStore:Ji,useTransition:Qi}}};function xa(e){return Ee.bind(null,e)}function Xt(e){return!!e&&e.$$typeof===is}function wa(e){return Xt(e)&&e.type===ne}function Sa(e){return!!e&&typeof e.displayName=="string"&&e.displayName.startsWith("Memo(")}function Ta(e){return Xt(e)?Js.apply(null,arguments):e}function Ca(e){return!!e.__k&&(et(null,e),!0)}function Aa(e){return e&&(e.base||e.nodeType===1&&e)||null}var Ea=function(e,t){return e(t)},La=function(e,t){return e(t)},Ra=ne,$a=Xt,Be={useState:w,useId:Vi,useReducer:Zn,useEffect:W,useLayoutEffect:St,useInsertionEffect:es,useTransition:Qi,useDeferredValue:Xi,useSyncExternalStore:Ji,startTransition:Yi,useRef:Le,useImperativeHandle:ji,useMemo:Ce,useCallback:Kn,useContext:qi,useDebugValue:Gi,version:"18.3.1",Children:ia,render:ga,hydrate:ma,unmountComponentAtNode:Ca,createPortal:ca,createElement:Ee,createContext:Ys,createFactory:xa,cloneElement:Ta,createRef:js,Fragment:ne,isValidElement:Xt,isElement:$a,isFragment:wa,isMemo:Sa,findDOMNode:Aa,Component:xe,PureComponent:Rn,memo:ta,forwardRef:ra,flushSync:La,unstable_batchedUpdates:Ea,StrictMode:Ra,Suspense:Ut,SuspenseList:bt,lazy:aa,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:ka},ss={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Jr=Be.createContext&&Be.createContext(ss),Ma=["attr","size","title"];function Ia(e,t){if(e==null)return{};var r=Da(e,t),i,s;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(s=0;s<a.length;s++)i=a[s],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(r[i]=e[i])}return r}function Da(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 qt(){return qt=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},qt.apply(this,arguments)}function Yr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,i)}return r}function Gt(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Yr(Object(r),!0).forEach(function(i){Pa(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Yr(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function Pa(e,t,r){return t=Na(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Na(e){var t=Oa(e,"string");return typeof t=="symbol"?t:t+""}function Oa(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 as(e){return e&&e.map((t,r)=>Be.createElement(t.tag,Gt({key:r},t.attr),as(t.child)))}function U(e){return t=>Be.createElement(za,qt({attr:Gt({},e.attr)},t),as(e.child))}function za(e){var t=r=>{var{attr:i,size:s,title:a}=e,o=Ia(e,Ma),l=s||r.size||"1em",d;return r.className&&(d=r.className),e.className&&(d=(d?d+" ":"")+e.className),Be.createElement("svg",qt({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},r.attr,i,o,{className:d,style:Gt(Gt({color:e.color||r.color},r.style),e.style),height:l,width:l,xmlns:"http://www.w3.org/2000/svg"}),a&&Be.createElement("title",null,a),e.children)};return Jr!==void 0?Be.createElement(Jr.Consumer,null,r=>t(r)):t(ss)}function Xr(e){return U({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 Ua(e){return U({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 Ba(e){return U({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 Re(e){return U({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 Bt(e){return U({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 Fa(e){return U({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 Ha(e){return U({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 ls(e){return U({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 Wa(e){return U({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 ja(e){return U({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 Fe(e){return U({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 qa(e){return U({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 Qr(e){return U({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 Xn(e){return U({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 os(e){return U({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 $n(e){return U({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 Ue(e){return U({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 Ga(e){return U({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 Vt(e){return U({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 Va(e){return U({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 cs(e){return U({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 Za(e){return U({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 Ka(e){return U({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 Ja(e){return U({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 Ya(e){return U({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 nt(e){return U({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 Xa(e){return U({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 Mn(e){return U({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2"},child:[]},{tag:"path",attr:{d:"M18 14h-8"},child:[]},{tag:"path",attr:{d:"M15 18h-5"},child:[]},{tag:"path",attr:{d:"M10 6h8v4h-8V6Z"},child:[]}]})(e)}function ue(e){return U({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 In(e){return U({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 Qa(e){return U({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 el(e){return U({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 tl(e){return U({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 Dn(e){return U({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 nl(e){return U({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 ei(e){return U({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 rt(e){return U({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 Pn(e){return U({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)}const ti=[{id:"overview",label:"Overview",icon:Ka,section:"dashboard"},{id:"history",label:"Messages",icon:nt,section:"dashboard"},{id:"approvals",label:"Approvals",icon:Ua,section:"dashboard"},{id:"digests",label:"Digests",icon:Mn,section:"dashboard"},{id:"audit",label:"Audit",icon:In,section:"dashboard"},{id:"usage",label:"Usage",icon:Ue,section:"dashboard"},{id:"coding",label:"Coding Agent",icon:Xn,section:"dashboard"},{id:"memory",label:"Memory",icon:$n,section:"settings"},{id:"templates",label:"Templates",icon:Vt,section:"settings"},{id:"model",label:"Model",icon:os,section:"settings"},{id:"skills",label:"Skills",icon:Pn,section:"settings"},{id:"cron",label:"Scheduled Jobs",icon:Fe,section:"settings"},{id:"config",label:"Config",icon:tl,section:"settings"},{id:"logs",label:"Logs",icon:Ja,section:"footer"},{id:"health",label:"Health",icon:cs,section:"footer"}],rl=[{id:"dashboard",label:"Dashboard"},{id:"settings",label:"Settings"}];function il({currentPage:e,onNavigate:t,botName:r,botEmoji:i,pendingApprovals:s,isNarrow:a,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"})]}),a&&n("button",{class:"sidebar-close-btn",onClick:o,"aria-label":"Close sidebar",children:n(Fa,{size:16})})]}),rl.map(l=>{const d=ti.filter(c=>c.section===l.id);return n("div",{class:"sidebar-section",children:[n("div",{class:"sidebar-section-label",children:l.label}),d.map(c=>{const m=c.id==="approvals"&&s?s:void 0,h=c.icon;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(h,{size:16})}),n("span",{class:"sidebar-item-label",children:c.label}),m?n("span",{class:"item-badge",children:m}):null]},c.id)})]},l.id)}),n("div",{class:"sidebar-spacer"}),n("div",{class:"sidebar-footer",children:[ti.filter(l=>l.section==="footer").map(l=>{const d=l.icon;return n("button",{"data-page":l.id,class:`sidebar-footer-item${e===l.id?" active":""}`,onClick:()=>t(l.id),children:[n("span",{class:"sidebar-item-icon",children:n(d,{size:16})}),n("span",{class:"sidebar-item-label",children:l.label})]},l.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(Ba,{size:16})}),n("span",{class:"sidebar-item-label",children:"Help Docs"})]})]})]})}function sl({toasts:e}){return n("div",{class:"toast-container",children:e.map(t=>n("div",{class:`toast ${t.type}`,children:t.message},t.id))})}function al(){const[e,t]=w([]),r=Kn((i,s="info",a=3e3)=>{const o=crypto.randomUUID();t(l=>[...l,{id:o,message:i,type:s}]),setTimeout(()=>{t(l=>l.filter(d=>d.id!==o))},a)},[]);return{toasts:e,showToast:r}}const Qn="dashboard_token",Nn="skimpy-dashboard-unauthorized";function ds(){return localStorage.getItem(Qn)??""}function ll(e){localStorage.setItem(Qn,e)}function ol(){localStorage.removeItem(Qn)}function cl(e){const t=()=>e();return window.addEventListener(Nn,t),()=>window.removeEventListener(Nn,t)}class dl extends Error{constructor(t,r){super(r),this.status=t,this.name="ApiError"}}async function B(e,t={}){const r=ds(),i={...r?{Authorization:`Bearer ${r}`}:{},...t.headers??{}};t.body&&(i["Content-Type"]="application/json");const s=await fetch(`/api/dashboard/${e}`,{...t,headers:i});if(!s.ok){s.status===401&&(ol(),window.dispatchEvent(new Event(Nn)));const a=await s.text().catch(()=>s.statusText);throw new dl(s.status,a)}return s.json()}const ul=()=>B("status"),ni=()=>B("health"),ri=()=>B("doctor");function us(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 B(`audit${r?`?${r}`:""}`)}const hs=()=>B("approvals"),ps=e=>B(`approvals/${encodeURIComponent(e)}/approve`,{method:"POST"}),fs=e=>B(`approvals/${encodeURIComponent(e)}/deny`,{method:"POST"}),hl=()=>B("cron"),pl=e=>B(`cron/${encodeURIComponent(e)}/run`,{method:"POST"}),fl=e=>B(`cron/prompt-file?path=${encodeURIComponent(e)}`),gl=()=>B("model"),ml=e=>B("model",{method:"POST",body:JSON.stringify({model:e})}),vl=e=>B(`memory/${encodeURIComponent(e)}`),_l=(e,t)=>B(`memory/${encodeURIComponent(e)}/${encodeURIComponent(t)}`),bl=e=>B(`templates/${encodeURIComponent(e)}`),yl=(e,t)=>B(`templates/${encodeURIComponent(e)}/${encodeURIComponent(t)}`),kl=(e,t,r)=>B(`templates/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({content:r})}),xl=()=>B("logs"),wl=e=>B(e),Sl=()=>B("code-agents"),Tl=e=>B(`code-agents/${encodeURIComponent(e)}/cancel`,{method:"POST"}),Cl=(e,t)=>B("messages/agent",{method:"POST",body:JSON.stringify({message:e,model:t})}),Al=e=>{const t=e?`?channel=${encodeURIComponent(e)}`:"";return B(`conversations${t}`)},El=(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 B(`conversations/${encodeURIComponent(e)}${i?`?${i}`:""}`)},er=()=>B("config"),gs=e=>B("config",{method:"PUT",body:JSON.stringify({config:e})}),Ll=()=>B("reload",{method:"POST"}),Rl=()=>B("digests"),$l=e=>B(`digests/${encodeURIComponent(e)}`),Ml=()=>B("skills"),Il=e=>B(`skills/${encodeURIComponent(e)}`),Dl=(e,t)=>B("skills",{method:"POST",body:JSON.stringify({name:e,content:t})}),Pl=(e,t)=>B(`skills/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({enabled:t})}),Nl=(e,t)=>B(`skills/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({content:t})}),Ol=e=>B(`skills/${encodeURIComponent(e)}`,{method:"DELETE"}),tr=()=>B("usage");function zl(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 B(`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 Ul(){const e=new Date().getHours();return e<12?"Good morning":e<17?"Good afternoon":"Good evening"}function Bl(e){const t=new Date(e),r=Date.now()-t.getTime(),i=Math.floor(r/1e3);if(i<60)return`${i}s ago`;const s=Math.floor(i/60);if(s<60)return`${s}m ago`;const a=Math.floor(s/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function Fl(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 ii(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 Hl(e){return e?e==="telegram"?"Telegram":e==="discord"?"Discord":e:"—"}function Wl(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 si({onNavigate:e,showToast:t}){var f;const[r,i]=w(null),[s,a]=w([]),[o,l]=w([]),[d,c]=w(null),[m,h]=w(new Set),[v,g]=w(!0);W(()=>{u();const _=setInterval(u,1e4);return()=>clearInterval(_)},[]);async function u(){const[_,A,M,O]=await Promise.allSettled([ul(),us({limit:8,offset:0}),hs(),tr()]);_.status==="fulfilled"?i(_.value):console.error("[overview] status load failed",_.reason),A.status==="fulfilled"?a(A.value.traces??[]):console.error("[overview] audit load failed",A.reason),M.status==="fulfilled"?l(M.value.pending??[]):console.error("[overview] approvals load failed",M.reason),O.status==="fulfilled"&&c(O.value),g(!1)}async function b(_,A){h(M=>new Set([...M,_]));try{A?(await ps(_),t==null||t("Command approved","success")):(await fs(_),t==null||t("Command denied","warning")),await u()}catch{t==null||t("Action failed","error")}finally{h(M=>{const O=new Set(M);return O.delete(_),O})}}const x=_=>_==="telegram"?n(Qa,{size:14}):_==="cron"?n(Fe,{size:14}):n(el,{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((_,A)=>_!=null&&_.nextRun?A.nextRun?new Date(_.nextRun)<new Date(A.nextRun)?_:A:_:A,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:[Ul(),", 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(Dn,{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:Fl(_.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-5",children:[n("div",{class:"stat-card",children:[n("div",{class:"stat-icon sage",children:n(Fe,{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(qa,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value stat-value-md",children:ii(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(os,{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(nt,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value stat-value-md",children:Hl((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(Ue,{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(Xr,{size:14})]})})]}),n("div",{class:"feed-card",children:n("div",{class:"feed",children:s.length===0?n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(Za,{size:18})}),n("div",{class:"empty-state-text",children:"No recent audit logs"})]}):s.slice(0,6).map(_=>n("div",{class:"feed-item",children:[n("div",{class:`feed-icon ${_.trigger==="telegram"?"telegram":_.trigger==="cron"?"cron":"system"}`,children:x(_.trigger)}),n("div",{children:[n("div",{class:"feed-title",children:_.trigger}),n("div",{class:"feed-detail",children:Wl(_)})]}),n("div",{class:"feed-time",children:Bl(_.startedAt)})]},_.traceId))})})]}),(((f=r==null?void 0:r.cronJobs)==null?void 0:f.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(Xr,{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:ii(_.nextRun)})]},_.id))})]})]})}function On(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function jl(e){const t=e.trim();return/^(https?:|mailto:|\/|#)/i.test(t)?t:"#"}function ot(e){let t=On(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,s)=>`<a href="${On(jl(s))}" target="_blank" rel="noreferrer">${i}</a>`),t}function ql(e){const t=e.replace(/\r\n/g,`
|
|
2
2
|
`).split(`
|
|
3
|
-
`),r=[];let i=!1,s=[],a=null,o=[];function l(){a&&(r.push(`</${a}>`),a=null)}function d(){o.length!==0&&(r.push(`<p>${
|
|
4
|
-
`))}</code></pre>`),s=[],i=!1)}for(const m of t){if(m.trim().startsWith("```")){d(),l(),i?c():i=!0;continue}if(i){s.push(m);continue}const h=/^(#{1,6})\s+(.*)$/.exec(m);if(h){d(),l();const u=h[1].length;r.push(`<h${u}>${
|
|
5
|
-
`)}function Xt({content:e}){const t=Ce(()=>jl(e||""),[e]);return n("div",{class:"markdown-view",dangerouslySetInnerHTML:{__html:t}})}const gs="dashboard_agent_messages_v1";function ql(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 Gl(){try{const e=localStorage.getItem(gs);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(ql).slice(-300):[]}catch{return[]}}function Vl(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 s=Math.floor(i/60);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}function Zl(){const[e,t]=w([]),[r,i]=w([]),[s,a]=w(()=>Gl()),[o,l]=w("all"),[d,c]=w(1),[m,h]=w(!1),[v,g]=w(!1),[u,b]=w(!0),[x,k]=w(""),[f,_]=w(!1),A=Le(null),R=Le(!0),O=Le(!1),I=Le(0),D=Le(0),S=(o==="all"?[...r,...s]:r).sort((T,N)=>new Date(T.ts).getTime()-new Date(N.ts).getTime()),y=()=>{const T=A.current;T&&(T.scrollTop=T.scrollHeight)};W(()=>{c(1),h(!1),g(!1),R.current=!0},[o]),W(()=>{$()},[o,d]),W(()=>{const T=setInterval(()=>{$()},5e3);return()=>clearInterval(T)},[o,d]),W(()=>{try{localStorage.setItem(gs,JSON.stringify(s.slice(-300)))}catch{}},[s]),W(()=>{const T=A.current;if(T){if(O.current){const N=T.scrollHeight;T.scrollTop=Math.max(0,N-I.current+D.current),O.current=!1,g(!1);return}if(R.current){requestAnimationFrame(y);const N=setTimeout(y,80);return()=>clearTimeout(N)}}},[S.length,u]);async function $(){b(!0);try{const N=(await Cl(o==="all"?void 0:o)).conversations??[];if(t(N),N.length===0){i([]);return}const ce=N.slice(0,12),pe=Math.max(20,d*30),Me=await Promise.all(ce.map(async re=>{const G=await Al(re.id,{limit:pe});return{hasMore:!!G.hasMore,messages:(G.messages??[]).map(De=>({...De,conversationId:re.id,channel:re.channel,chatId:re.chatId}))}})),Ie=Me.some(re=>re.hasMore);h(Ie);const K=Me.flatMap(re=>re.messages).sort((re,G)=>new Date(re.ts).getTime()-new Date(G.ts).getTime());i(K)}catch(T){console.error("[messages] load failed",T)}finally{b(!1)}}function E(T){const N=T.currentTarget,ce=N.scrollHeight-(N.scrollTop+N.clientHeight);R.current=ce<24,N.scrollTop<=40&&m&&!v&&!u&&(O.current=!0,I.current=N.scrollHeight,D.current=N.scrollTop,g(!0),c(pe=>pe+1))}async function H(){const T=x.trim();if(!(!T||f)){_(!0),R.current=!0;try{a(ce=>[...ce,{role:"user",content:T,ts:new Date().toISOString(),conversationId:"dashboard-agent",channel:"dashboard",chatId:"active"}]);const N=await Tl(T);a(ce=>[...ce,{role:"assistant",content:N.response,ts:N.timestamp||new Date().toISOString(),conversationId:"dashboard-agent",channel:"dashboard",chatId:"agent"}]),k("")}catch(N){console.error("[messages] send failed",N)}finally{_(!1)}}}function X(T){return T==="dashboard"?"Dashboard":T==="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:T=>l(T.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 $(),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(tt,{size:18})}),n("div",{class:"empty-state-text",children:"No messages yet"})]})}):n("div",{class:"card messages-chat-card",children:[S.length===0?n("div",{class:"empty-state",children:n("div",{class:"empty-state-text",children:"No conversation messages"})}):n("div",{ref:A,class:"chat-list messages-chat-list",onScroll:E,children:[v&&n("div",{style:{display:"flex",justifyContent:"center",padding:"6px 0"},children:n("div",{class:"spinner",style:{width:14,height:14}})}),S.map((T,N)=>n("div",{class:`chat-row ${T.role==="user"?"user":"assistant"}`,children:[n("div",{class:"chat-meta",children:[T.role==="user"?"You":"SkimpyClaw"," · ",X(T.channel)," · ",Vl(T.ts)]}),n("div",{class:`chat-bubble ${T.role==="user"?"user":"assistant"}`,children:n(Xt,{content:T.content})})]},`${T.ts}-${N}`))]}),n("div",{class:"messages-composer-inline",children:n("div",{style:{display:"flex",gap:8},children:[n("input",{value:x,onInput:T=>k(T.target.value),onKeyDown:T=>{T.key==="Enter"&&(T.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:f||!x.trim(),children:f?"Sending…":"Send"})]})})]})]})}function Kl(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 Jl({showToast:e}){const[t,r]=w([]),[i,s]=w(!0),[a,o]=w(new Set),[l,d]=w(null),[c,m]=w(null),[h,v]=w(!1),[g,u]=w(null),[b,x]=w(null),[k,f]=w({id:"",name:"",scheduleExpr:"",tz:"America/Chicago",model:"",payloadKind:"agentTurn",message:"",script:"",url:"",cwd:"",timeoutMs:"",sendAsVoice:!1});W(()=>{_()},[]);async function _(){s(!0);try{const[S,y]=await Promise.all([ul(),er()]);r(S.jobs??[]);const $=y.config??{};d($)}catch{e("Failed to load cron jobs","error")}finally{s(!1)}}async function A(S){var T,N,ce,pe,Me,Ie,K,re,G;const y=((T=S.payload)==null?void 0:T.kind)||"agentTurn",$=((N=S.payload)==null?void 0:N.message)||"";let E=$,H=null,X=null;if(y==="agentTurn"&&typeof $=="string"&&$.trim().endsWith(".md"))try{const De=await pl($);E=De.content,H=$,X=De.content}catch{}u(H),x(X),f({id:S.id||"",name:S.name||"",scheduleExpr:((ce=S.schedule)==null?void 0:ce.expr)||"",tz:((pe=S.schedule)==null?void 0:pe.tz)||"America/Chicago",model:S.model||"",payloadKind:y,message:E,script:((Me=S.payload)==null?void 0:Me.script)||"",url:((Ie=S.payload)==null?void 0:Ie.url)||"",cwd:((K=S.payload)==null?void 0:K.cwd)||"",timeoutMs:(re=S.payload)!=null&&re.timeoutMs?String(S.payload.timeoutMs):"",sendAsVoice:!!((G=S.payload)!=null&&G.sendAsVoice)})}function R(){m(null),u(null),x(null),f({id:"",name:"",scheduleExpr:"",tz:"America/Chicago",model:"",payloadKind:"agentTurn",message:"",script:"",url:"",cwd:"",timeoutMs:"",sendAsVoice:!1})}function O(S){var $;m(S);const y=((($=l==null?void 0:l.cron)==null?void 0:$.jobs)??[]).find(E=>E.id===S);y&&A(y)}async function I(){if(!l)return;const S=k.id.trim(),y=k.name.trim(),$=k.scheduleExpr.trim();if(!S||!y||!$){e("ID, name, and schedule are required","error");return}const E=structuredClone(l);E.cron||(E.cron={jobs:[]}),Array.isArray(E.cron.jobs)||(E.cron.jobs=[]);const H={kind:k.payloadKind};if(k.payloadKind==="agentTurn"){const N=g&&b!==null&&k.message===b;H.message=N?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);const X={id:S,name:y,schedule:{kind:"cron",expr:$,tz:k.tz.trim()||"America/Chicago"},payload:H,model:k.model.trim()||void 0},T=E.cron.jobs.findIndex(N=>N.id===S);T>=0?E.cron.jobs[T]=X:E.cron.jobs.push(X),v(!0);try{await fs(E),e(T>=0?"Cron job updated":"Cron job created","success"),d(E),m(S),await _()}catch{e("Failed to save cron job","error")}finally{v(!1)}}async function D(S){o(y=>new Set([...y,S]));try{await hl(S),e("Job triggered","success")}catch{e("Failed to trigger job","error")}finally{o(y=>{const $=new Set(y);return $.delete(S),$})}}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:R,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(et,{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(S=>n("button",{class:`templates-list-item${c===S.id?" active":""}`,onClick:()=>O(S.id),children:[n("div",{class:"templates-list-icon",children:n(et,{size:14})}),n("div",{class:"templates-list-content",children:[n("div",{class:"templates-list-title",children:S.name}),n("div",{class:"templates-list-meta",children:[S.id," · ",Kl(S.nextRun)]})]})]},S.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:S=>f(y=>({...y,id:S.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:S=>f(y=>({...y,name:S.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:S=>f(y=>({...y,scheduleExpr:S.target.value})),placeholder:"*/30 * * * *"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Timezone"}),n("input",{value:k.tz,onInput:S=>f(y=>({...y,tz:S.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:S=>f(y=>({...y,model:S.target.value})),placeholder:"optional"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Payload kind"}),n("select",{value:k.payloadKind,onChange:S=>f(y=>({...y,payloadKind:S.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:S=>f(y=>({...y,message:S.target.value})),placeholder:"Message prompt",style:{minHeight:120}})]}),k.payloadKind==="script"&&n(ne,{children:[n("label",{class:"form-field",style:{marginTop:10},children:[n("span",{class:"form-label",children:"Script"}),n("textarea",{value:k.script,onInput:S=>f(y=>({...y,script:S.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:S=>f(y=>({...y,cwd:S.target.value})),placeholder:"optional"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Timeout ms"}),n("input",{value:k.timeoutMs,onInput:S=>f(y=>({...y,timeoutMs:S.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:S=>f(y=>({...y,url:S.target.value})),placeholder:"https://..."})]}),n("label",{class:"form-checkbox",style:{marginTop:10},children:[n("input",{type:"checkbox",checked:k.sendAsVoice,onChange:S=>f(y=>({...y,sendAsVoice:S.target.checked}))}),"Send output as voice"]}),n("div",{class:"form-actions",children:[c&&n("button",{class:"btn btn-sm",disabled:a.has(c),onClick:()=>D(c),children:a.has(c)?"Running…":"Run now"}),n("button",{class:"btn btn-sm btn-primary",onClick:I,disabled:h,children:h?"Saving…":"Save Job"})]})]})]})]})}function nr(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var He=nr();function ms(e){He=e}var ze={exec:()=>null};function F(e,t=""){let r=typeof e=="string"?e:e.source,i={replace:(s,a)=>{let o=typeof a=="string"?a:a.source;return o=o.replace(ae.caret,"$1"),r=r.replace(s,o),i},getRegex:()=>new RegExp(r,t)};return i}var Yl=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),ae={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)}}>`)},Xl=/^(?:[ \t]*(?:\n|$))+/,Ql=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,eo=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Tt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,to=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,rr=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,vs=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_s=F(vs).replace(/bull/g,rr).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(),no=F(vs).replace(/bull/g,rr).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(),ir=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ro=/^[^\n]+/,sr=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,io=F(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",sr).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),so=F(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,rr).getRegex(),Qt="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",ar=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ao=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",ar).replace("tag",Qt).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),bs=F(ir).replace("hr",Tt).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",Qt).getRegex(),lo=F(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",bs).getRegex(),lr={blockquote:lo,code:Ql,def:io,fences:eo,heading:to,hr:Tt,html:ao,lheading:_s,list:so,newline:Xl,paragraph:bs,table:ze,text:ro},ai=F("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Tt).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",Qt).getRegex(),oo={...lr,lheading:no,table:ai,paragraph:F(ir).replace("hr",Tt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ai).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",Qt).getRegex()},co={...lr,html:F(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ar).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:ze,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:F(ir).replace("hr",Tt).replace("heading",` *#{1,6} *[^
|
|
6
|
-
]`).replace("lheading",
|
|
3
|
+
`),r=[];let i=!1,s=[],a=null,o=[];function l(){a&&(r.push(`</${a}>`),a=null)}function d(){o.length!==0&&(r.push(`<p>${ot(o.join(" "))}</p>`),o=[])}function c(){i&&(r.push(`<pre><code>${On(s.join(`
|
|
4
|
+
`))}</code></pre>`),s=[],i=!1)}for(const m of t){if(m.trim().startsWith("```")){d(),l(),i?c():i=!0;continue}if(i){s.push(m);continue}const h=/^(#{1,6})\s+(.*)$/.exec(m);if(h){d(),l();const u=h[1].length;r.push(`<h${u}>${ot(h[2])}</h${u}>`);continue}const v=/^[-*]\s+(.*)$/.exec(m);if(v){d(),a!=="ul"&&(l(),a="ul",r.push("<ul>")),r.push(`<li>${ot(v[1])}</li>`);continue}const g=/^\d+\.\s+(.*)$/.exec(m);if(g){d(),a!=="ol"&&(l(),a="ol",r.push("<ol>")),r.push(`<li>${ot(g[1])}</li>`);continue}if(m.trim()===""){d(),l();continue}if(l(),m.startsWith("> ")){d(),r.push(`<blockquote>${ot(m.slice(2))}</blockquote>`);continue}o.push(m.trim())}return d(),l(),c(),r.join(`
|
|
5
|
+
`)}function Qt({content:e}){const t=Ce(()=>ql(e||""),[e]);return n("div",{class:"markdown-view",dangerouslySetInnerHTML:{__html:t}})}const ms="dashboard_agent_messages_v1";function Gl(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 Vl(){try{const e=localStorage.getItem(ms);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(Gl).slice(-300):[]}catch{return[]}}function Zl(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 s=Math.floor(i/60);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}function Kl(){const[e,t]=w([]),[r,i]=w([]),[s,a]=w(()=>Vl()),[o,l]=w("all"),[d,c]=w(1),[m,h]=w(!1),[v,g]=w(!1),[u,b]=w(!0),[x,k]=w(""),[f,_]=w(!1),A=Le(null),M=Le(!0),O=Le(!1),D=Le(0),L=Le(0),S=(o==="all"?[...r,...s]:r).sort((T,N)=>new Date(T.ts).getTime()-new Date(N.ts).getTime()),y=()=>{const T=A.current;T&&(T.scrollTop=T.scrollHeight)};W(()=>{c(1),h(!1),g(!1),M.current=!0},[o]),W(()=>{R()},[o,d]),W(()=>{const T=setInterval(()=>{R()},5e3);return()=>clearInterval(T)},[o,d]),W(()=>{try{localStorage.setItem(ms,JSON.stringify(s.slice(-300)))}catch{}},[s]),W(()=>{const T=A.current;if(T){if(O.current){const N=T.scrollHeight;T.scrollTop=Math.max(0,N-D.current+L.current),O.current=!1,g(!1);return}if(M.current){requestAnimationFrame(y);const N=setTimeout(y,80);return()=>clearTimeout(N)}}},[S.length,u]);async function R(){b(!0);try{const N=(await Al(o==="all"?void 0:o)).conversations??[];if(t(N),N.length===0){i([]);return}const ce=N.slice(0,12),pe=Math.max(20,d*30),Me=await Promise.all(ce.map(async re=>{const G=await El(re.id,{limit:pe});return{hasMore:!!G.hasMore,messages:(G.messages??[]).map(De=>({...De,conversationId:re.id,channel:re.channel,chatId:re.chatId}))}})),Ie=Me.some(re=>re.hasMore);h(Ie);const K=Me.flatMap(re=>re.messages).sort((re,G)=>new Date(re.ts).getTime()-new Date(G.ts).getTime());i(K)}catch(T){console.error("[messages] load failed",T)}finally{b(!1)}}function E(T){const N=T.currentTarget,ce=N.scrollHeight-(N.scrollTop+N.clientHeight);M.current=ce<24,N.scrollTop<=40&&m&&!v&&!u&&(O.current=!0,D.current=N.scrollHeight,L.current=N.scrollTop,g(!0),c(pe=>pe+1))}async function H(){const T=x.trim();if(!(!T||f)){_(!0),M.current=!0;try{a(ce=>[...ce,{role:"user",content:T,ts:new Date().toISOString(),conversationId:"dashboard-agent",channel:"dashboard",chatId:"active"}]);const N=await Cl(T);a(ce=>[...ce,{role:"assistant",content:N.response,ts:N.timestamp||new Date().toISOString(),conversationId:"dashboard-agent",channel:"dashboard",chatId:"agent"}]),k("")}catch(N){console.error("[messages] send failed",N)}finally{_(!1)}}}function X(T){return T==="dashboard"?"Dashboard":T==="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:T=>l(T.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(nt,{size:18})}),n("div",{class:"empty-state-text",children:"No messages yet"})]})}):n("div",{class:"card messages-chat-card",children:[S.length===0?n("div",{class:"empty-state",children:n("div",{class:"empty-state-text",children:"No conversation messages"})}):n("div",{ref:A,class:"chat-list messages-chat-list",onScroll:E,children:[v&&n("div",{style:{display:"flex",justifyContent:"center",padding:"6px 0"},children:n("div",{class:"spinner",style:{width:14,height:14}})}),S.map((T,N)=>n("div",{class:`chat-row ${T.role==="user"?"user":"assistant"}`,children:[n("div",{class:"chat-meta",children:[T.role==="user"?"You":"SkimpyClaw"," · ",X(T.channel)," · ",Zl(T.ts)]}),n("div",{class:`chat-bubble ${T.role==="user"?"user":"assistant"}`,children:n(Qt,{content:T.content})})]},`${T.ts}-${N}`))]}),n("div",{class:"messages-composer-inline",children:n("div",{style:{display:"flex",gap:8},children:[n("input",{value:x,onInput:T=>k(T.target.value),onKeyDown:T=>{T.key==="Enter"&&(T.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:f||!x.trim(),children:f?"Sending…":"Send"})]})})]})]})}function Jl(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 Yl({showToast:e}){const[t,r]=w([]),[i,s]=w(!0),[a,o]=w(new Set),[l,d]=w(null),[c,m]=w(null),[h,v]=w(!1),[g,u]=w(null),[b,x]=w(null),[k,f]=w({id:"",name:"",scheduleExpr:"",tz:"America/Chicago",model:"",payloadKind:"agentTurn",message:"",script:"",url:"",cwd:"",timeoutMs:"",sendAsVoice:!1});W(()=>{_()},[]);async function _(){s(!0);try{const[S,y]=await Promise.all([hl(),er()]);r(S.jobs??[]);const R=y.config??{};d(R)}catch{e("Failed to load cron jobs","error")}finally{s(!1)}}async function A(S){var T,N,ce,pe,Me,Ie,K,re,G;const y=((T=S.payload)==null?void 0:T.kind)||"agentTurn",R=((N=S.payload)==null?void 0:N.message)||"";let E=R,H=null,X=null;if(y==="agentTurn"&&typeof R=="string"&&R.trim().endsWith(".md"))try{const De=await fl(R);E=De.content,H=R,X=De.content}catch{}u(H),x(X),f({id:S.id||"",name:S.name||"",scheduleExpr:((ce=S.schedule)==null?void 0:ce.expr)||"",tz:((pe=S.schedule)==null?void 0:pe.tz)||"America/Chicago",model:S.model||"",payloadKind:y,message:E,script:((Me=S.payload)==null?void 0:Me.script)||"",url:((Ie=S.payload)==null?void 0:Ie.url)||"",cwd:((K=S.payload)==null?void 0:K.cwd)||"",timeoutMs:(re=S.payload)!=null&&re.timeoutMs?String(S.payload.timeoutMs):"",sendAsVoice:!!((G=S.payload)!=null&&G.sendAsVoice)})}function M(){m(null),u(null),x(null),f({id:"",name:"",scheduleExpr:"",tz:"America/Chicago",model:"",payloadKind:"agentTurn",message:"",script:"",url:"",cwd:"",timeoutMs:"",sendAsVoice:!1})}function O(S){var R;m(S);const y=(((R=l==null?void 0:l.cron)==null?void 0:R.jobs)??[]).find(E=>E.id===S);y&&A(y)}async function D(){if(!l)return;const S=k.id.trim(),y=k.name.trim(),R=k.scheduleExpr.trim();if(!S||!y||!R){e("ID, name, and schedule are required","error");return}const E=structuredClone(l);E.cron||(E.cron={jobs:[]}),Array.isArray(E.cron.jobs)||(E.cron.jobs=[]);const H={kind:k.payloadKind};if(k.payloadKind==="agentTurn"){const N=g&&b!==null&&k.message===b;H.message=N?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);const X={id:S,name:y,schedule:{kind:"cron",expr:R,tz:k.tz.trim()||"America/Chicago"},payload:H,model:k.model.trim()||void 0},T=E.cron.jobs.findIndex(N=>N.id===S);T>=0?E.cron.jobs[T]=X:E.cron.jobs.push(X),v(!0);try{await gs(E),e(T>=0?"Cron job updated":"Cron job created","success"),d(E),m(S),await _()}catch{e("Failed to save cron job","error")}finally{v(!1)}}async function L(S){o(y=>new Set([...y,S]));try{await pl(S),e("Job triggered","success")}catch{e("Failed to trigger job","error")}finally{o(y=>{const R=new Set(y);return R.delete(S),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(Fe,{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(S=>n("button",{class:`templates-list-item${c===S.id?" active":""}`,onClick:()=>O(S.id),children:[n("div",{class:"templates-list-icon",children:n(Fe,{size:14})}),n("div",{class:"templates-list-content",children:[n("div",{class:"templates-list-title",children:S.name}),n("div",{class:"templates-list-meta",children:[S.id," · ",Jl(S.nextRun)]})]})]},S.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:S=>f(y=>({...y,id:S.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:S=>f(y=>({...y,name:S.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:S=>f(y=>({...y,scheduleExpr:S.target.value})),placeholder:"*/30 * * * *"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Timezone"}),n("input",{value:k.tz,onInput:S=>f(y=>({...y,tz:S.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:S=>f(y=>({...y,model:S.target.value})),placeholder:"optional"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Payload kind"}),n("select",{value:k.payloadKind,onChange:S=>f(y=>({...y,payloadKind:S.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:S=>f(y=>({...y,message:S.target.value})),placeholder:"Message prompt",style:{minHeight:120}})]}),k.payloadKind==="script"&&n(ne,{children:[n("label",{class:"form-field",style:{marginTop:10},children:[n("span",{class:"form-label",children:"Script"}),n("textarea",{value:k.script,onInput:S=>f(y=>({...y,script:S.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:S=>f(y=>({...y,cwd:S.target.value})),placeholder:"optional"})]}),n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Timeout ms"}),n("input",{value:k.timeoutMs,onInput:S=>f(y=>({...y,timeoutMs:S.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:S=>f(y=>({...y,url:S.target.value})),placeholder:"https://..."})]}),n("label",{class:"form-checkbox",style:{marginTop:10},children:[n("input",{type:"checkbox",checked:k.sendAsVoice,onChange:S=>f(y=>({...y,sendAsVoice:S.target.checked}))}),"Send output as voice"]}),n("div",{class:"form-actions",children:[c&&n("button",{class:"btn btn-sm",disabled:a.has(c),onClick:()=>L(c),children:a.has(c)?"Running…":"Run now"}),n("button",{class:"btn btn-sm btn-primary",onClick:D,disabled:h,children:h?"Saving…":"Save Job"})]})]})]})]})}function nr(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var We=nr();function vs(e){We=e}var ze={exec:()=>null};function F(e,t=""){let r=typeof e=="string"?e:e.source,i={replace:(s,a)=>{let o=typeof a=="string"?a:a.source;return o=o.replace(ae.caret,"$1"),r=r.replace(s,o),i},getRegex:()=>new RegExp(r,t)};return i}var Xl=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),ae={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)}}>`)},Ql=/^(?:[ \t]*(?:\n|$))+/,eo=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,to=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Tt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,no=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,rr=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,_s=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,bs=F(_s).replace(/bull/g,rr).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(),ro=F(_s).replace(/bull/g,rr).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(),ir=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,io=/^[^\n]+/,sr=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,so=F(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",sr).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ao=F(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,rr).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",ar=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,lo=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",ar).replace("tag",en).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ys=F(ir).replace("hr",Tt).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(),oo=F(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ys).getRegex(),lr={blockquote:oo,code:eo,def:so,fences:to,heading:no,hr:Tt,html:lo,lheading:bs,list:ao,newline:Ql,paragraph:ys,table:ze,text:io},ai=F("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Tt).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(),co={...lr,lheading:ro,table:ai,paragraph:F(ir).replace("hr",Tt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ai).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()},uo={...lr,html:F(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ar).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:ze,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:F(ir).replace("hr",Tt).replace("heading",` *#{1,6} *[^
|
|
6
|
+
]`).replace("lheading",bs).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ho=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,po=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ks=/^( {2,}|\\)\n(?!\s*$)/,fo=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,tn=/[\p{P}\p{S}]/u,or=/[\s\p{P}\p{S}]/u,xs=/[^\s\p{P}\p{S}]/u,go=F(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,or).getRegex(),ws=/(?!~)[\p{P}\p{S}]/u,mo=/(?!~)[\s\p{P}\p{S}]/u,vo=/(?:[^\s\p{P}\p{S}]|~)/u,Ss=/(?![*_])[\p{P}\p{S}]/u,_o=/(?![*_])[\s\p{P}\p{S}]/u,bo=/(?:[^\s\p{P}\p{S}]|[*_])/u,yo=F(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Xl?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Ts=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,ko=F(Ts,"u").replace(/punct/g,tn).getRegex(),xo=F(Ts,"u").replace(/punct/g,ws).getRegex(),Cs="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",wo=F(Cs,"gu").replace(/notPunctSpace/g,xs).replace(/punctSpace/g,or).replace(/punct/g,tn).getRegex(),So=F(Cs,"gu").replace(/notPunctSpace/g,vo).replace(/punctSpace/g,mo).replace(/punct/g,ws).getRegex(),To=F("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,xs).replace(/punctSpace/g,or).replace(/punct/g,tn).getRegex(),Co=F(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Ss).getRegex(),Ao="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Eo=F(Ao,"gu").replace(/notPunctSpace/g,bo).replace(/punctSpace/g,_o).replace(/punct/g,Ss).getRegex(),Lo=F(/\\(punct)/,"gu").replace(/punct/g,tn).getRegex(),Ro=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(),$o=F(ar).replace("(?:-->|$)","-->").getRegex(),Mo=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",$o).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Zt=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Io=F(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Zt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),As=F(/^!?\[(label)\]\[(ref)\]/).replace("label",Zt).replace("ref",sr).getRegex(),Es=F(/^!?\[(ref)\](?:\[\])?/).replace("ref",sr).getRegex(),Do=F("reflink|nolink(?!\\()","g").replace("reflink",As).replace("nolink",Es).getRegex(),li=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,cr={_backpedal:ze,anyPunctuation:Lo,autolink:Ro,blockSkip:yo,br:ks,code:po,del:ze,delLDelim:ze,delRDelim:ze,emStrongLDelim:ko,emStrongRDelimAst:wo,emStrongRDelimUnd:To,escape:ho,link:Io,nolink:Es,punctuation:go,reflink:As,reflinkSearch:Do,tag:Mo,text:fo,url:ze},Po={...cr,link:F(/^!?\[(label)\]\((.*?)\)/).replace("label",Zt).getRegex(),reflink:F(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Zt).getRegex()},zn={...cr,emStrongRDelimAst:So,emStrongLDelim:xo,delLDelim:Co,delRDelim:Eo,url:F(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",li).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",li).getRegex()},No={...zn,br:F(ks).replace("{2,}","*").getRegex(),text:F(zn.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Dt={normal:lr,gfm:co,pedantic:uo},ct={normal:cr,gfm:zn,breaks:No,pedantic:Po},Oo={"&":"&","<":"<",">":">",'"':""","'":"'"},oi=e=>Oo[e];function be(e,t){if(t){if(ae.escapeTest.test(e))return e.replace(ae.escapeReplace,oi)}else if(ae.escapeTestNoEncode.test(e))return e.replace(ae.escapeReplaceNoEncode,oi);return e}function ci(e){try{e=encodeURI(e).replace(ae.percentDecode,"%")}catch{return null}return e}function di(e,t){var a;let r=e.replace(ae.findPipe,(o,l,d)=>{let c=!1,m=l;for(;--m>=0&&d[m]==="\\";)c=!c;return c?"|":" |"}),i=r.split(ae.splitPipe),s=0;if(i[0].trim()||i.shift(),i.length>0&&!((a=i.at(-1))!=null&&a.trim())&&i.pop(),t)if(i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;s<i.length;s++)i[s]=i[s].trim().replace(ae.slashPipe,"|");return i}function dt(e,t,r){let i=e.length;if(i===0)return"";let s=0;for(;s<i&&e.charAt(i-s-1)===t;)s++;return e.slice(0,i-s)}function zo(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 Uo(e,t=0){let r=t,i="";for(let s of e)if(s===" "){let a=4-r%4;i+=" ".repeat(a),r+=a}else i+=s,r++;return i}function ui(e,t,r,i,s){let a=t.href,o=t.title||null,l=e[1].replace(s.other.outputLinkReplace,"$1");i.state.inLink=!0;let d={type:e[0].charAt(0)==="!"?"image":"link",raw:r,href:a,title:o,text:l,tokens:i.inlineTokens(l)};return i.state.inLink=!1,d}function Bo(e,t,r){let i=e.match(r.other.indentCodeCompensation);if(i===null)return t;let s=i[1];return t.split(`
|
|
7
7
|
`).map(a=>{let o=a.match(r.other.beginningSpace);if(o===null)return a;let[l]=o;return l.length>=s.length?a.slice(s.length):a}).join(`
|
|
8
|
-
`)}var
|
|
9
|
-
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let r=t[0],i=
|
|
10
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let r=
|
|
8
|
+
`)}var Kt=class{constructor(e){q(this,"options");q(this,"rules");q(this,"lexer");this.options=e||We}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:dt(r,`
|
|
9
|
+
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let r=t[0],i=Bo(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=dt(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:dt(t[0],`
|
|
10
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let r=dt(t[0],`
|
|
11
11
|
`).split(`
|
|
12
12
|
`),i="",s="",a=[];for(;r.length>0;){let o=!1,l=[],d;for(d=0;d<r.length;d++)if(this.rules.other.blockquoteStart.test(r[d]))l.push(r[d]),o=!0;else if(!o)l.push(r[d]);else break;r=r.slice(d);let c=l.join(`
|
|
13
13
|
`),m=c.replace(this.rules.other.blockquoteSetextReplace,`
|
|
@@ -18,16 +18,16 @@ ${m}`:m;let h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
18
18
|
`),b=this.blockquote(u);a[a.length-1]=b,i=i.substring(0,i.length-g.raw.length)+b.raw,s=s.substring(0,s.length-g.text.length)+b.text;break}else if((v==null?void 0:v.type)==="list"){let g=v,u=g.raw+`
|
|
19
19
|
`+r.join(`
|
|
20
20
|
`),b=this.list(u);a[a.length-1]=b,i=i.substring(0,i.length-v.raw.length)+b.raw,s=s.substring(0,s.length-g.raw.length)+b.raw,r=u.substring(a.at(-1).raw.length).split(`
|
|
21
|
-
`);continue}}return{type:"blockquote",raw:i,tokens:a,text:s}}}list(e){var r,i;let t=this.rules.block.list.exec(e);if(t){let s=t[1].trim(),a=s.length>1,o={type:"list",raw:"",ordered:a,start:a?+s.slice(0,-1):"",loose:!1,items:[]};s=a?`\\d{1,9}\\${s.slice(-1)}`:`\\${s}`,this.options.pedantic&&(s=a?s:"[*+-]");let l=this.rules.other.listItemRegex(s),d=!1;for(;e;){let m=!1,h="",v="";if(!(t=l.exec(e))||this.rules.block.hr.test(e))break;h=t[0],e=e.substring(h.length);let g=
|
|
21
|
+
`);continue}}return{type:"blockquote",raw:i,tokens:a,text:s}}}list(e){var r,i;let t=this.rules.block.list.exec(e);if(t){let s=t[1].trim(),a=s.length>1,o={type:"list",raw:"",ordered:a,start:a?+s.slice(0,-1):"",loose:!1,items:[]};s=a?`\\d{1,9}\\${s.slice(-1)}`:`\\${s}`,this.options.pedantic&&(s=a?s:"[*+-]");let l=this.rules.other.listItemRegex(s),d=!1;for(;e;){let m=!1,h="",v="";if(!(t=l.exec(e))||this.rules.block.hr.test(e))break;h=t[0],e=e.substring(h.length);let g=Uo(t[2].split(`
|
|
22
22
|
`,1)[0],t[1].length),u=e.split(`
|
|
23
23
|
`,1)[0],b=!g.trim(),x=0;if(this.options.pedantic?(x=2,v=g.trimStart()):b?x=t[1].length+1:(x=g.search(this.rules.other.nonSpaceChar),x=x>4?1:x,v=g.slice(x),x+=t[1].length),b&&this.rules.other.blankLine.test(u)&&(h+=u+`
|
|
24
|
-
`,e=e.substring(u.length+1),m=!0),!m){let k=this.rules.other.nextBulletRegex(x),f=this.rules.other.hrRegex(x),_=this.rules.other.fencesBeginRegex(x),A=this.rules.other.headingBeginRegex(x),
|
|
25
|
-
`,1)[0],
|
|
26
|
-
`+
|
|
27
|
-
`+u}b=!u.trim(),h+=
|
|
28
|
-
`,e=e.substring(
|
|
24
|
+
`,e=e.substring(u.length+1),m=!0),!m){let k=this.rules.other.nextBulletRegex(x),f=this.rules.other.hrRegex(x),_=this.rules.other.fencesBeginRegex(x),A=this.rules.other.headingBeginRegex(x),M=this.rules.other.htmlBeginRegex(x),O=this.rules.other.blockquoteBeginRegex(x);for(;e;){let D=e.split(`
|
|
25
|
+
`,1)[0],L;if(u=D,this.options.pedantic?(u=u.replace(this.rules.other.listReplaceNesting," "),L=u):L=u.replace(this.rules.other.tabCharGlobal," "),_.test(u)||A.test(u)||M.test(u)||O.test(u)||k.test(u)||f.test(u))break;if(L.search(this.rules.other.nonSpaceChar)>=x||!u.trim())v+=`
|
|
26
|
+
`+L.slice(x);else{if(b||g.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||_.test(g)||A.test(g)||f.test(g))break;v+=`
|
|
27
|
+
`+u}b=!u.trim(),h+=D+`
|
|
28
|
+
`,e=e.substring(D.length+1),g=L.slice(x)}}o.loose||(d?o.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(d=!0)),o.items.push({type:"list_item",raw:h,task:!!this.options.gfm&&this.rules.other.listIsTask.test(v),loose:!1,text:v,tokens:[]}),o.raw+=h}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 h=this.rules.other.listTaskCheckbox.exec(m.raw);if(h){let v={type:"checkbox",raw:h[0]+" ",checked:h[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 h=m.tokens.filter(g=>g.type==="space"),v=h.length>0&&h.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 h of m.tokens)h.type==="text"&&(h.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"):"",s=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:s}}}table(e){var o;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let r=di(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=(o=t[3])!=null&&o.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
29
29
|
`):[],a={type:"table",raw:t[0],header:[],align:[],rows:[]};if(r.length===i.length){for(let l of i)this.rules.other.tableAlignRight.test(l)?a.align.push("right"):this.rules.other.tableAlignCenter.test(l)?a.align.push("center"):this.rules.other.tableAlignLeft.test(l)?a.align.push("left"):a.align.push(null);for(let l=0;l<r.length;l++)a.header.push({text:r[l],tokens:this.lexer.inline(r[l]),header:!0,align:a.align[l]});for(let l of s)a.rows.push(di(l,a.header.length).map((d,c)=>({text:d,tokens:this.lexer.inline(d),header:!1,align:a.align[c]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let 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 a=
|
|
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 a=dt(r.slice(0,-1),"\\");if((r.length-a.length)%2===0)return}else{let a=zo(t[2],"()");if(a===-2)return;if(a>-1){let o=(t[0].indexOf("!")===0?5:4)+t[1].length+a;t[2]=t[2].substring(0,a),t[0]=t[0].substring(0,o).trim(),t[3]=""}}let i=t[2],s="";if(this.options.pedantic){let a=this.rules.other.pedanticHrefTitle.exec(i);a&&(i=a[1],s=a[3])}else s=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)),ui(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.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," "),s=t[i.toLowerCase()];if(!s){let a=r[0].charAt(0);return{type:"text",raw:a,text:a}}return ui(r,s,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 s=[...i[0]].length-1,a,o,l=s,d=0,c=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+s);(i=c.exec(t))!=null;){if(a=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!a)continue;if(o=[...a].length,i[3]||i[4]){l+=o;continue}else if((i[5]||i[6])&&s%3&&!((s+o)%3)){d+=o;continue}if(l-=o,l>0)continue;o=Math.min(o,o+l+d);let m=[...i[0]][0].length,h=e.slice(0,s+i.index+m+o);if(Math.min(s,o)%2){let g=h.slice(1,-1);return{type:"em",raw:h,text:g,tokens:this.lexer.inlineTokens(g)}}let v=h.slice(2,-2);return{type:"strong",raw:h,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),s=this.rules.other.startingSpaceChar.test(r)&&this.rules.other.endingSpaceChar.test(r);return i&&s&&(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 s=[...i[0]].length-1,a,o,l=s,d=this.rules.inline.delRDelim;for(d.lastIndex=0,t=t.slice(-1*e.length+s);(i=d.exec(t))!=null;){if(a=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!a||(o=[...a].length,o!==s))continue;if(i[3]||i[4]){l+=o;continue}if(l-=o,l>0)continue;o=Math.min(o,o+l);let c=[...i[0]][0].length,m=e.slice(0,s+i.index+c+o),h=m.slice(s,-s);return{type:"del",raw:m,text:h,tokens:this.lexer.inlineTokens(h)}}}}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,s;if(t[2]==="@")i=t[0],s="mailto:"+i;else{let a;do a=t[0],t[0]=((r=this.rules.inline._backpedal.exec(t[0]))==null?void 0:r[0])??"";while(a!==t[0]);i=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:i,href:s,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 Un{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||We,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:ae,block:Dt.normal,inline:ct.normal};this.options.pedantic?(r.block=Dt.pedantic,r.inline=ct.pedantic):this.options.gfm&&(r.block=Dt.gfm,this.options.breaks?r.inline=ct.breaks:r.inline=ct.gfm),this.tokenizer.rules=r}static get rules(){return{block:Dt,inline:ct}}static lex(t,r){return new Un(r).lex(t)}static lexInline(t,r){return new Un(r).inlineTokens(t)}lex(t){t=t.replace(ae.carriageReturn,`
|
|
31
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 s,a,o;for(this.options.pedantic&&(t=t.replace(ae.tabCharGlobal," ").replace(ae.spaceLine,""));t;){let l;if((a=(s=this.options.extensions)==null?void 0:s.block)!=null&&a.some(c=>(l=c.call({lexer:this},t,r))?(t=t.substring(l.raw.length),r.push(l),!0):!1))continue;if(l=this.tokenizer.space(t)){t=t.substring(l.raw.length);let c=r.at(-1);l.raw.length===1&&c!==void 0?c.raw+=`
|
|
32
32
|
`:r.push(l);continue}if(l=this.tokenizer.code(t)){t=t.substring(l.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
33
|
`)?"":`
|
|
@@ -41,7 +41,7 @@ ${m}`:m;let h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
41
41
|
`+l.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):r.push(l),i=d.length!==t.length,t=t.substring(l.raw.length);continue}if(l=this.tokenizer.text(t)){t=t.substring(l.raw.length);let c=r.at(-1);(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
|
|
42
42
|
`)?"":`
|
|
43
43
|
`)+l.raw,c.text+=`
|
|
44
|
-
`+l.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):r.push(l);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,h,v;let i=t,s=null;if(this.tokens.links){let g=Object.keys(this.tokens.links);if(g.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)g.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(i))!=null;)i=i.slice(0,s.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let a;for(;(s=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)a=s[2]?s[2].length:0,i=i.slice(0,s.index+a)+"["+"a".repeat(s[0].length-a-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,l="";for(;t;){o||(l=""),o=!1;let g;if((h=(m=this.options.extensions)==null?void 0:m.inline)!=null&&h.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,l)){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,l)){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,x=t.slice(1),k;this.options.extensions.startInline.forEach(f=>{k=f.call({lexer:this},x),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)!=="_"&&(l=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}},
|
|
44
|
+
`+l.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):r.push(l);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,h,v;let i=t,s=null;if(this.tokens.links){let g=Object.keys(this.tokens.links);if(g.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)g.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(i))!=null;)i=i.slice(0,s.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let a;for(;(s=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)a=s[2]?s[2].length:0,i=i.slice(0,s.index+a)+"["+"a".repeat(s[0].length-a-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,l="";for(;t;){o||(l=""),o=!1;let g;if((h=(m=this.options.extensions)==null?void 0:m.inline)!=null&&h.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,l)){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,l)){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,x=t.slice(1),k;this.options.extensions.startInline.forEach(f=>{k=f.call({lexer:this},x),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)!=="_"&&(l=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||We}space(e){return""}code({text:e,lang:t,escaped:r}){var a;let i=(a=(t||"").match(ae.notSpaceStart))==null?void 0:a[0],s=e.replace(ae.endingNewline,"")+`
|
|
45
45
|
`;return i?'<pre><code class="language-'+be(i)+'">'+(r?s:be(s,!0))+`</code></pre>
|
|
46
46
|
`:"<pre><code>"+(r?s:be(s,!0))+`</code></pre>
|
|
47
47
|
`}blockquote({tokens:e}){return`<blockquote>
|
|
@@ -59,7 +59,7 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
59
59
|
`}tablerow({text:e}){return`<tr>
|
|
60
60
|
${e}</tr>
|
|
61
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>${be(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),s=ci(e);if(s===null)return i;e=s;let a='<a href="'+e+'"';return t&&(a+=' title="'+be(t)+'"'),a+=">"+i+"</a>",a}image({href:e,title:t,text:r,tokens:i}){i&&(r=this.parser.parseInline(i,this.parser.textRenderer));let s=ci(e);if(s===null)return be(r);e=s;let a=`<img src="${e}" alt="${be(r)}"`;return t&&(a+=` title="${be(t)}"`),a+=">",a}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:be(e.text)}},dr=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 Bn{constructor(t){q(this,"options");q(this,"renderer");q(this,"textRenderer");this.options=t||
|
|
63
|
-
Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+be(r.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(r);throw r}}},Fe=new Bo;function j(e,t){return Fe.parse(e,t)}j.options=j.setOptions=function(e){return Fe.setOptions(e),j.defaults=Fe.defaults,ms(j.defaults),j};j.getDefaults=nr;j.defaults=He;j.use=function(...e){return Fe.use(...e),j.defaults=Fe.defaults,ms(j.defaults),j};j.walkTokens=function(e,t){return Fe.walkTokens(e,t)};j.parseInline=Fe.parseInline;j.Parser=me;j.parser=me.parse;j.Renderer=Kt;j.TextRenderer=dr;j.Lexer=ge;j.lexer=ge.lex;j.Tokenizer=Zt;j.Hooks=bt;j.parse=j;j.options;j.setOptions;j.use;j.walkTokens;j.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:Es,setPrototypeOf:hi,isFrozen:Fo,getPrototypeOf:Ho,getOwnPropertyDescriptor:Wo}=Object;let{freeze:le,seal:he,create:Fn}=Object,{apply:Hn,construct:Wn}=typeof Reflect<"u"&&Reflect;le||(le=function(t){return t});he||(he=function(t){return t});Hn||(Hn=function(t,r){for(var i=arguments.length,s=new Array(i>2?i-2:0),a=2;a<i;a++)s[a-2]=arguments[a];return t.apply(r,s)});Wn||(Wn=function(t){for(var r=arguments.length,i=new Array(r>1?r-1:0),s=1;s<r;s++)i[s-1]=arguments[s];return new t(...i)});const Pt=oe(Array.prototype.forEach),jo=oe(Array.prototype.lastIndexOf),pi=oe(Array.prototype.pop),dt=oe(Array.prototype.push),qo=oe(Array.prototype.splice),Bt=oe(String.prototype.toLowerCase),vn=oe(String.prototype.toString),_n=oe(String.prototype.match),ut=oe(String.prototype.replace),Go=oe(String.prototype.indexOf),Vo=oe(String.prototype.trim),fe=oe(Object.prototype.hasOwnProperty),se=oe(RegExp.prototype.test),ht=Zo(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),s=1;s<r;s++)i[s-1]=arguments[s];return Hn(e,t,i)}}function Zo(e){return function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return Wn(e,r)}}function z(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Bt;hi&&hi(e,null);let i=t.length;for(;i--;){let s=t[i];if(typeof s=="string"){const a=r(s);a!==s&&(Fo(t)||(t[i]=a),s=a)}e[s]=!0}return e}function Ko(e){for(let t=0;t<e.length;t++)fe(e,t)||(e[t]=null);return e}function ye(e){const t=Fn(null);for(const[r,i]of Es(e))fe(e,r)&&(Array.isArray(i)?t[r]=Ko(i):i&&typeof i=="object"&&i.constructor===Object?t[r]=ye(i):t[r]=i);return t}function pt(e,t){for(;e!==null;){const i=Wo(e,t);if(i){if(i.get)return oe(i.get);if(typeof i.value=="function")return oe(i.value)}e=Ho(e)}function r(){return null}return r}const fi=le(["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"]),bn=le(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),yn=le(["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"]),Jo=le(["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"]),kn=le(["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"]),Yo=le(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),gi=le(["#text"]),mi=le(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),xn=le(["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"]),vi=le(["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"]),Nt=le(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Xo=he(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Qo=he(/<%[\w\W]*|[\w\W]*%>/gm),ec=he(/\$\{[\w\W]*/gm),tc=he(/^data-[\-\w.\u00B7-\uFFFF]+$/),nc=he(/^aria-[\-\w]+$/),Ls=he(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),rc=he(/^(?:\w+script|data):/i),ic=he(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Rs=he(/^html$/i),sc=he(/^[a-z][.\w]*(-[.\w]+)+$/i);var _i=Object.freeze({__proto__:null,ARIA_ATTR:nc,ATTR_WHITESPACE:ic,CUSTOM_ELEMENT:sc,DATA_ATTR:tc,DOCTYPE_NAME:Rs,ERB_EXPR:Qo,IS_ALLOWED_URI:Ls,IS_SCRIPT_OR_DATA:rc,MUSTACHE_EXPR:Xo,TMPLIT_EXPR:ec});const ft={element:1,text:3,progressingInstruction:7,comment:8,document:9},ac=function(){return typeof window>"u"?null:window},lc=function(t,r){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let i=null;const s="data-tt-policy-suffix";r&&r.hasAttribute(s)&&(i=r.getAttribute(s));const a="dompurify"+(i?"#"+i:"");try{return t.createPolicy(a,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},bi=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function $s(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ac();const t=M=>$s(M);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==ft.document||!e.Element)return t.isSupported=!1,t;let{document:r}=e;const i=r,s=i.currentScript,{DocumentFragment:a,HTMLTemplateElement:o,Node:l,Element:d,NodeFilter:c,NamedNodeMap:m=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:h,DOMParser:v,trustedTypes:g}=e,u=d.prototype,b=pt(u,"cloneNode"),x=pt(u,"remove"),k=pt(u,"nextSibling"),f=pt(u,"childNodes"),_=pt(u,"parentNode");if(typeof o=="function"){const M=r.createElement("template");M.content&&M.content.ownerDocument&&(r=M.content.ownerDocument)}let A,R="";const{implementation:O,createNodeIterator:I,createDocumentFragment:D,getElementsByTagName:S}=r,{importNode:y}=i;let $=bi();t.isSupported=typeof Es=="function"&&typeof _=="function"&&O&&O.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:E,ERB_EXPR:H,TMPLIT_EXPR:X,DATA_ATTR:T,ARIA_ATTR:N,IS_SCRIPT_OR_DATA:ce,ATTR_WHITESPACE:pe,CUSTOM_ELEMENT:Me}=_i;let{IS_ALLOWED_URI:Ie}=_i,K=null;const re=z({},[...fi,...bn,...yn,...kn,...gi]);let G=null;const De=z({},[...mi,...xn,...vi,...Nt]);let Y=Object.seal(Fn(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),it=null,tn=null;const We=Object.seal(Fn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ur=!0,nn=!0,hr=!1,pr=!0,je=!1,Ct=!0,Pe=!1,rn=!1,sn=!1,qe=!1,At=!1,Et=!1,fr=!0,gr=!1;const Ms="user-content-";let an=!0,st=!1,Ge={},ve=null;const ln=z({},["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 mr=null;const vr=z({},["audio","video","img","source","image","track"]);let on=null;const _r=z({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Lt="http://www.w3.org/1998/Math/MathML",Rt="http://www.w3.org/2000/svg",we="http://www.w3.org/1999/xhtml";let Ve=we,cn=!1,dn=null;const Is=z({},[Lt,Rt,we],vn);let $t=z({},["mi","mo","mn","ms","mtext"]),Mt=z({},["annotation-xml"]);const Ds=z({},["title","style","font","a","script"]);let at=null;const Ps=["application/xhtml+xml","text/html"],Ns="text/html";let ee=null,Ze=null;const Os=r.createElement("form"),br=function(p){return p instanceof RegExp||p instanceof Function},un=function(){let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ze&&Ze===p)){if((!p||typeof p!="object")&&(p={}),p=ye(p),at=Ps.indexOf(p.PARSER_MEDIA_TYPE)===-1?Ns:p.PARSER_MEDIA_TYPE,ee=at==="application/xhtml+xml"?vn:Bt,K=fe(p,"ALLOWED_TAGS")?z({},p.ALLOWED_TAGS,ee):re,G=fe(p,"ALLOWED_ATTR")?z({},p.ALLOWED_ATTR,ee):De,dn=fe(p,"ALLOWED_NAMESPACES")?z({},p.ALLOWED_NAMESPACES,vn):Is,on=fe(p,"ADD_URI_SAFE_ATTR")?z(ye(_r),p.ADD_URI_SAFE_ATTR,ee):_r,mr=fe(p,"ADD_DATA_URI_TAGS")?z(ye(vr),p.ADD_DATA_URI_TAGS,ee):vr,ve=fe(p,"FORBID_CONTENTS")?z({},p.FORBID_CONTENTS,ee):ln,it=fe(p,"FORBID_TAGS")?z({},p.FORBID_TAGS,ee):ye({}),tn=fe(p,"FORBID_ATTR")?z({},p.FORBID_ATTR,ee):ye({}),Ge=fe(p,"USE_PROFILES")?p.USE_PROFILES:!1,ur=p.ALLOW_ARIA_ATTR!==!1,nn=p.ALLOW_DATA_ATTR!==!1,hr=p.ALLOW_UNKNOWN_PROTOCOLS||!1,pr=p.ALLOW_SELF_CLOSE_IN_ATTR!==!1,je=p.SAFE_FOR_TEMPLATES||!1,Ct=p.SAFE_FOR_XML!==!1,Pe=p.WHOLE_DOCUMENT||!1,qe=p.RETURN_DOM||!1,At=p.RETURN_DOM_FRAGMENT||!1,Et=p.RETURN_TRUSTED_TYPE||!1,sn=p.FORCE_BODY||!1,fr=p.SANITIZE_DOM!==!1,gr=p.SANITIZE_NAMED_PROPS||!1,an=p.KEEP_CONTENT!==!1,st=p.IN_PLACE||!1,Ie=p.ALLOWED_URI_REGEXP||Ls,Ve=p.NAMESPACE||we,$t=p.MATHML_TEXT_INTEGRATION_POINTS||$t,Mt=p.HTML_INTEGRATION_POINTS||Mt,Y=p.CUSTOM_ELEMENT_HANDLING||{},p.CUSTOM_ELEMENT_HANDLING&&br(p.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Y.tagNameCheck=p.CUSTOM_ELEMENT_HANDLING.tagNameCheck),p.CUSTOM_ELEMENT_HANDLING&&br(p.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Y.attributeNameCheck=p.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),p.CUSTOM_ELEMENT_HANDLING&&typeof p.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Y.allowCustomizedBuiltInElements=p.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),je&&(nn=!1),At&&(qe=!0),Ge&&(K=z({},gi),G=[],Ge.html===!0&&(z(K,fi),z(G,mi)),Ge.svg===!0&&(z(K,bn),z(G,xn),z(G,Nt)),Ge.svgFilters===!0&&(z(K,yn),z(G,xn),z(G,Nt)),Ge.mathMl===!0&&(z(K,kn),z(G,vi),z(G,Nt))),p.ADD_TAGS&&(typeof p.ADD_TAGS=="function"?We.tagCheck=p.ADD_TAGS:(K===re&&(K=ye(K)),z(K,p.ADD_TAGS,ee))),p.ADD_ATTR&&(typeof p.ADD_ATTR=="function"?We.attributeCheck=p.ADD_ATTR:(G===De&&(G=ye(G)),z(G,p.ADD_ATTR,ee))),p.ADD_URI_SAFE_ATTR&&z(on,p.ADD_URI_SAFE_ATTR,ee),p.FORBID_CONTENTS&&(ve===ln&&(ve=ye(ve)),z(ve,p.FORBID_CONTENTS,ee)),p.ADD_FORBID_CONTENTS&&(ve===ln&&(ve=ye(ve)),z(ve,p.ADD_FORBID_CONTENTS,ee)),an&&(K["#text"]=!0),Pe&&z(K,["html","head","body"]),K.table&&(z(K,["tbody"]),delete it.tbody),p.TRUSTED_TYPES_POLICY){if(typeof p.TRUSTED_TYPES_POLICY.createHTML!="function")throw ht('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof p.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ht('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');A=p.TRUSTED_TYPES_POLICY,R=A.createHTML("")}else A===void 0&&(A=lc(g,s)),A!==null&&typeof R=="string"&&(R=A.createHTML(""));le&&le(p),Ze=p}},yr=z({},[...bn,...yn,...Jo]),kr=z({},[...kn,...Yo]),zs=function(p){let C=_(p);(!C||!C.tagName)&&(C={namespaceURI:Ve,tagName:"template"});const L=Bt(p.tagName),Z=Bt(C.tagName);return dn[p.namespaceURI]?p.namespaceURI===Rt?C.namespaceURI===we?L==="svg":C.namespaceURI===Lt?L==="svg"&&(Z==="annotation-xml"||$t[Z]):!!yr[L]:p.namespaceURI===Lt?C.namespaceURI===we?L==="math":C.namespaceURI===Rt?L==="math"&&Mt[Z]:!!kr[L]:p.namespaceURI===we?C.namespaceURI===Rt&&!Mt[Z]||C.namespaceURI===Lt&&!$t[Z]?!1:!kr[L]&&(Ds[L]||!yr[L]):!!(at==="application/xhtml+xml"&&dn[p.namespaceURI]):!1},_e=function(p){dt(t.removed,{element:p});try{_(p).removeChild(p)}catch{x(p)}},Ne=function(p,C){try{dt(t.removed,{attribute:C.getAttributeNode(p),from:C})}catch{dt(t.removed,{attribute:null,from:C})}if(C.removeAttribute(p),p==="is")if(qe||At)try{_e(C)}catch{}else try{C.setAttribute(p,"")}catch{}},xr=function(p){let C=null,L=null;if(sn)p="<remove></remove>"+p;else{const Q=_n(p,/^[\r\n\t ]+/);L=Q&&Q[0]}at==="application/xhtml+xml"&&Ve===we&&(p='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+p+"</body></html>");const Z=A?A.createHTML(p):p;if(Ve===we)try{C=new v().parseFromString(Z,at)}catch{}if(!C||!C.documentElement){C=O.createDocument(Ve,"template",null);try{C.documentElement.innerHTML=cn?R:Z}catch{}}const ie=C.body||C.documentElement;return p&&L&&ie.insertBefore(r.createTextNode(L),ie.childNodes[0]||null),Ve===we?S.call(C,Pe?"html":"body")[0]:Pe?C.documentElement:ie},wr=function(p){return I.call(p.ownerDocument||p,p,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},hn=function(p){return p instanceof h&&(typeof p.nodeName!="string"||typeof p.textContent!="string"||typeof p.removeChild!="function"||!(p.attributes instanceof m)||typeof p.removeAttribute!="function"||typeof p.setAttribute!="function"||typeof p.namespaceURI!="string"||typeof p.insertBefore!="function"||typeof p.hasChildNodes!="function")},Sr=function(p){return typeof l=="function"&&p instanceof l};function Se(M,p,C){Pt(M,L=>{L.call(t,p,C,Ze)})}const Tr=function(p){let C=null;if(Se($.beforeSanitizeElements,p,null),hn(p))return _e(p),!0;const L=ee(p.nodeName);if(Se($.uponSanitizeElement,p,{tagName:L,allowedTags:K}),Ct&&p.hasChildNodes()&&!Sr(p.firstElementChild)&&se(/<[/\w!]/g,p.innerHTML)&&se(/<[/\w!]/g,p.textContent)||p.nodeType===ft.progressingInstruction||Ct&&p.nodeType===ft.comment&&se(/<[/\w]/g,p.data))return _e(p),!0;if(!(We.tagCheck instanceof Function&&We.tagCheck(L))&&(!K[L]||it[L])){if(!it[L]&&Ar(L)&&(Y.tagNameCheck instanceof RegExp&&se(Y.tagNameCheck,L)||Y.tagNameCheck instanceof Function&&Y.tagNameCheck(L)))return!1;if(an&&!ve[L]){const Z=_(p)||p.parentNode,ie=f(p)||p.childNodes;if(ie&&Z){const Q=ie.length;for(let de=Q-1;de>=0;--de){const Te=b(ie[de],!0);Te.__removalCount=(p.__removalCount||0)+1,Z.insertBefore(Te,k(p))}}}return _e(p),!0}return p instanceof d&&!zs(p)||(L==="noscript"||L==="noembed"||L==="noframes")&&se(/<\/no(script|embed|frames)/i,p.innerHTML)?(_e(p),!0):(je&&p.nodeType===ft.text&&(C=p.textContent,Pt([E,H,X],Z=>{C=ut(C,Z," ")}),p.textContent!==C&&(dt(t.removed,{element:p.cloneNode()}),p.textContent=C)),Se($.afterSanitizeElements,p,null),!1)},Cr=function(p,C,L){if(fr&&(C==="id"||C==="name")&&(L in r||L in Os))return!1;if(!(nn&&!tn[C]&&se(T,C))){if(!(ur&&se(N,C))){if(!(We.attributeCheck instanceof Function&&We.attributeCheck(C,p))){if(!G[C]||tn[C]){if(!(Ar(p)&&(Y.tagNameCheck instanceof RegExp&&se(Y.tagNameCheck,p)||Y.tagNameCheck instanceof Function&&Y.tagNameCheck(p))&&(Y.attributeNameCheck instanceof RegExp&&se(Y.attributeNameCheck,C)||Y.attributeNameCheck instanceof Function&&Y.attributeNameCheck(C,p))||C==="is"&&Y.allowCustomizedBuiltInElements&&(Y.tagNameCheck instanceof RegExp&&se(Y.tagNameCheck,L)||Y.tagNameCheck instanceof Function&&Y.tagNameCheck(L))))return!1}else if(!on[C]){if(!se(Ie,ut(L,pe,""))){if(!((C==="src"||C==="xlink:href"||C==="href")&&p!=="script"&&Go(L,"data:")===0&&mr[p])){if(!(hr&&!se(ce,ut(L,pe,"")))){if(L)return!1}}}}}}}return!0},Ar=function(p){return p!=="annotation-xml"&&_n(p,Me)},Er=function(p){Se($.beforeSanitizeAttributes,p,null);const{attributes:C}=p;if(!C||hn(p))return;const L={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:G,forceKeepAttr:void 0};let Z=C.length;for(;Z--;){const ie=C[Z],{name:Q,namespaceURI:de,value:Te}=ie,Ke=ee(Q),pn=Te;let te=Q==="value"?pn:Vo(pn);if(L.attrName=Ke,L.attrValue=te,L.keepAttr=!0,L.forceKeepAttr=void 0,Se($.uponSanitizeAttribute,p,L),te=L.attrValue,gr&&(Ke==="id"||Ke==="name")&&(Ne(Q,p),te=Ms+te),Ct&&se(/((--!?|])>)|<\/(style|title|textarea)/i,te)){Ne(Q,p);continue}if(Ke==="attributename"&&_n(te,"href")){Ne(Q,p);continue}if(L.forceKeepAttr)continue;if(!L.keepAttr){Ne(Q,p);continue}if(!pr&&se(/\/>/i,te)){Ne(Q,p);continue}je&&Pt([E,H,X],Rr=>{te=ut(te,Rr," ")});const Lr=ee(p.nodeName);if(!Cr(Lr,Ke,te)){Ne(Q,p);continue}if(A&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!de)switch(g.getAttributeType(Lr,Ke)){case"TrustedHTML":{te=A.createHTML(te);break}case"TrustedScriptURL":{te=A.createScriptURL(te);break}}if(te!==pn)try{de?p.setAttributeNS(de,Q,te):p.setAttribute(Q,te),hn(p)?_e(p):pi(t.removed)}catch{Ne(Q,p)}}Se($.afterSanitizeAttributes,p,null)},Us=function M(p){let C=null;const L=wr(p);for(Se($.beforeSanitizeShadowDOM,p,null);C=L.nextNode();)Se($.uponSanitizeShadowNode,C,null),Tr(C),Er(C),C.content instanceof a&&M(C.content);Se($.afterSanitizeShadowDOM,p,null)};return t.sanitize=function(M){let p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},C=null,L=null,Z=null,ie=null;if(cn=!M,cn&&(M="<!-->"),typeof M!="string"&&!Sr(M))if(typeof M.toString=="function"){if(M=M.toString(),typeof M!="string")throw ht("dirty is not a string, aborting")}else throw ht("toString is not a function");if(!t.isSupported)return M;if(rn||un(p),t.removed=[],typeof M=="string"&&(st=!1),st){if(M.nodeName){const Te=ee(M.nodeName);if(!K[Te]||it[Te])throw ht("root node is forbidden and cannot be sanitized in-place")}}else if(M instanceof l)C=xr("<!---->"),L=C.ownerDocument.importNode(M,!0),L.nodeType===ft.element&&L.nodeName==="BODY"||L.nodeName==="HTML"?C=L:C.appendChild(L);else{if(!qe&&!je&&!Pe&&M.indexOf("<")===-1)return A&&Et?A.createHTML(M):M;if(C=xr(M),!C)return qe?null:Et?R:""}C&&sn&&_e(C.firstChild);const Q=wr(st?M:C);for(;Z=Q.nextNode();)Tr(Z),Er(Z),Z.content instanceof a&&Us(Z.content);if(st)return M;if(qe){if(At)for(ie=D.call(C.ownerDocument);C.firstChild;)ie.appendChild(C.firstChild);else ie=C;return(G.shadowroot||G.shadowrootmode)&&(ie=y.call(i,ie,!0)),ie}let de=Pe?C.outerHTML:C.innerHTML;return Pe&&K["!doctype"]&&C.ownerDocument&&C.ownerDocument.doctype&&C.ownerDocument.doctype.name&&se(Rs,C.ownerDocument.doctype.name)&&(de="<!DOCTYPE "+C.ownerDocument.doctype.name+`>
|
|
64
|
-
`+de),je&&Pt([E,H,X],Te=>{de=ut(de,Te," ")}),A&&Et?A.createHTML(de):de},t.setConfig=function(){let M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};un(M),rn=!0},t.clearConfig=function(){Ze=null,rn=!1},t.isValidAttribute=function(M,p,C){Ze||un({});const L=ee(M),Z=ee(p);return Cr(L,Z,C)},t.addHook=function(M,p){typeof p=="function"&&dt($[M],p)},t.removeHook=function(M,p){if(p!==void 0){const C=jo($[M],p);return C===-1?void 0:qo($[M],C,1)[0]}return pi($[M])},t.removeHooks=function(M){$[M]=[]},t.removeAllHooks=function(){$=bi()},t}var oc=$s();function kt({content:e,className:t,style:r}){if(!e)return null;const i=j.parse(e,{breaks:!0,gfm:!0}),s=oc.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:s}})}const Jt=[{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 cc(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 dc(e){return Jt[cc(e)%Jt.length]}function uc(e){return typeof e.durationSeconds=="number"?e.durationSeconds:Math.max(0,Math.round((Date.now()-new Date(e.startedAt).getTime())/1e3))}function yi(e){const t=uc(e);if(t<60)return`${t}s`;const r=Math.floor(t/60),i=t%60;return`${r}m ${i}s`}function gt(e){return e==="completed"?"completed":e==="cancelled"||e==="failed"||e==="timeout"?"failed":e==="pending"?"pending":"running"}function hc(e){return e?new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"--:--"}function ki(e){return e==="completed"?n(Re,{size:20}):e==="cancelled"?n(nt,{size:20}):e==="failed"||e==="timeout"?n(nt,{size:20}):n(ue,{size:20})}function pc(){const[e,t]=w([]),[r,i]=w(0),[s,a]=w(!0),[o,l]=w(0),[d,c]=w(new Set),[m]=w(()=>Jt[Math.floor(Math.random()*Jt.length)]),h=10;W(()=>{v();const f=setInterval(v,3e3);return()=>clearInterval(f)},[]);async function v(){try{const[f,_]=await Promise.all([wl(),tr().catch(()=>null)]);t(f.agents??[]),_&&i(_.today.totalCost)}catch{}finally{a(!1)}}async function g(f){if(!d.has(f)){c(_=>new Set(_).add(f));try{await Sl(f),await v()}catch{}finally{c(_=>{const A=new Set(_);return A.delete(f),A})}}}const u=Ce(()=>{const f=new Map;for(const _ of e){if(!_.parentTaskId)continue;const A=f.get(_.parentTaskId)??[];A.push(_),f.set(_.parentTaskId,A)}return f},[e]),b=Ce(()=>e.filter(f=>!f.parentTaskId),[e]),x=Ce(()=>{const f=o*h;return b.slice(f,f+h)},[b,o]);W(()=>{const f=Math.max(0,Math.ceil(b.length/h)-1);o>f&&l(f)},[b.length,o]);const k=Ce(()=>{const f=b.filter(R=>gt(R.status)==="running").length,_=b.filter(R=>gt(R.status)==="completed").length,A=b.filter(R=>gt(R.status)==="failed").length;return{running:f,completed:_,failed:A,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"]})]})]}),s&&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(Xn,{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(nt,{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(Ue,{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"})]})]})]}),x.map(f=>{const _=u.get(f.id)??[],A=f.liveOutput||f.outputPreview,R=gt(f.status),O=R==="running",I=dc(f.id);return n("div",{class:`coding-task-card ${R}`,style:{"--card-accent":I.color,"--card-accent-soft":I.soft},children:[n("div",{class:"coding-task-main",children:[n("div",{class:`coding-task-icon ${R}`,children:ki(f.status)}),n("div",{class:"coding-task-content",children:[n("div",{class:"coding-task-pills",children:[n("span",{class:"coding-pill id",children:f.id}),n("span",{class:"coding-pill",children:["TEAM (",_.length,")"]}),n("span",{class:`coding-pill status ${R}`,children:f.status})]}),n("div",{class:"coding-task-title",children:f.task}),n("div",{class:"coding-task-submeta",children:[f.model&&n("span",{children:f.model}),n("span",{children:"•"}),n("span",{children:[n(et,{size:13})," ",yi(f)]}),n("span",{children:"•"}),n("span",{class:"coding-pill",children:[f.totalCost!=null?`$${f.totalCost.toFixed(2)}`:"$--"," · ",f.inputTokens!=null||f.outputTokens!=null?`${((f.inputTokens??0)+(f.outputTokens??0)).toLocaleString()} tok`:"-- tok"]}),n("span",{children:hc(f.startedAt)})]})]}),O?n("button",{class:`coding-task-action ${R}`,type:"button",disabled:d.has(f.id),onClick:()=>{g(f.id)},children:d.has(f.id)?"Cancelling…":"Cancel"}):null]}),n("div",{class:`coding-task-progress ${R}`}),_.length>0&&n("details",{class:"coding-subagents",open:!0,children:[n("summary",{children:[n(Rn,{size:14})," Subagents (",_.length,")"]}),n("div",{class:"coding-subagents-list",children:_.map(D=>n("div",{class:"coding-subagent-row",children:[n("span",{class:`coding-subagent-icon ${gt(D.status)}`,children:ki(D.status)}),n("span",{class:"audit-id",children:D.id}),n("span",{class:`ca-status-badge ${D.status}`,children:D.status}),n("span",{class:"coding-pill",children:D.totalCost!=null?`$${D.totalCost.toFixed(2)}`:"$--"}),n("span",{class:"coding-subagent-task",children:D.subtask||D.task}),n("span",{class:"coding-subagent-time",children:yi(D)})]},D.id))})]}),n("details",{class:"coding-output",children:[n("summary",{children:[n(Rn,{size:14})," Live output"]}),A?n(kt,{content:A,className:`ca-output markdown-content${f.error?" ca-error":""}`}):null,!A&&f.error?n(kt,{content:f.error,className:"ca-output markdown-content ca-error"}):null,!A&&!f.error&&f.synthesisResult?n(kt,{content:f.synthesisResult,className:"ca-output markdown-content"}):null]})]},f.id)}),b.length>h&&n("div",{style:{display:"flex",justifyContent:"center",gap:"8px",padding:"12px"},children:[n("button",{class:"btn btn-sm",disabled:o===0,onClick:()=>l(f=>Math.max(0,f-1)),children:"Previous"}),n("span",{style:{fontSize:"12px",color:"var(--text-muted)",alignSelf:"center"},children:[o*h+1,"–",Math.min((o+1)*h,b.length)," of ",b.length]}),n("button",{class:"btn btn-sm",disabled:(o+1)*h>=b.length,onClick:()=>l(f=>f+1),children:"Next"})]})]})]})}function xi(e){if(e==null)return e;if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e}function fc(e){if(e.type==="tool_use"&&e.detail!=null){const t=xi(e.detail);if(t!==null&&typeof t=="object"&&!Array.isArray(t)){const r=t,i=r.tool||r.name||r.toolName||"",s=r.tool!=null?"tool":r.name!=null?"name":r.toolName!=null?"toolName":"",o=Object.entries(r).filter(([l])=>l!==s).map(([l,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`${l}: ${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=xi(e.detail);return typeof t=="string"?t:JSON.stringify(t).slice(0,80)}return""}function gc(e){return e===void 0?"":e>=1e3?`${(e/1e3).toFixed(1)}s`:`${Math.round(e)}ms`}function mc(){const[e,t]=w([]),[r,i]=w(0),[s,a]=w(0),[o,l]=w(""),[d,c]=w(""),[m,h]=w("all"),[v,g]=w(!0),[u,b]=w(new Set),x=20;W(()=>{a(0)},[d]),W(()=>{k()},[s,d]),W(()=>{const y=Math.max(0,Math.ceil(r/x)-1);s>y&&a(y)},[s,r]);async function k(){g(!0);try{const y=await ds({limit:x,offset:s*x,trigger:d||void 0});t(y.traces??[]),i(y.total??0)}catch(y){console.error("[audit] load failed",y)}finally{g(!1)}}function f(y){if(y.endedAt){const $=new Date(y.endedAt).getTime()-new Date(y.startedAt).getTime();return $>=1e3?`${($/1e3).toFixed(1)}s`:`${Math.max(0,Math.round($))}ms`}return"running"}function _(y){return new Date(y).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}const A=o.trim().toLowerCase(),R=e.filter(y=>m!=="all"&&y.status!==m?!1:A?y.trigger.toLowerCase().includes(A)||y.traceId.toLowerCase().includes(A)||y.events.some(E=>`${E.type} ${E.summary}`.toLowerCase().includes(A)):!0),O=e.filter(y=>{const $=new Date(y.startedAt),E=new Date;return $.getFullYear()===E.getFullYear()&&$.getMonth()===E.getMonth()&&$.getDate()===E.getDate()}).length;function I(y){var $;return(($=y.events.find(E=>E.summary.trim()))==null?void 0:$.summary)??`${y.events.length} events`}function D(y){b($=>{const E=new Set($);return E.has(y)?E.delete(y):E.add(y),E})}function S(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:[O," 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(ne,{children:[n("div",{class:"audit-filters-row",children:[n("label",{class:"audit-search",children:[n(In,{size:14}),n("input",{value:o,onInput:y=>l(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=>h(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:R.length===0?n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(In,{size:18})}),n("div",{class:"empty-state-text",children:"No audit traces"})]}):R.map((y,$)=>n("div",{class:"audit-row",children:[n("div",{class:"audit-time-col",children:[n("div",{class:"audit-time",children:_(y.startedAt)}),$<R.length-1&&n("div",{class:"audit-time-line"})]}),n("div",{class:`audit-card${S(y)?" audit-card-expandable":""}`,children:[n("div",{class:"audit-card-head",...S(y)?{role:"button",tabIndex:0,"aria-expanded":u.has(y.traceId),"aria-label":`Toggle details for trace ${y.traceId.slice(0,8)}`,onClick:()=>D(y.traceId),onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),D(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:f(y)}),S(y)&&n("span",{class:"audit-expand-icon",children:u.has(y.traceId)?n(Rn,{size:12}):n(Fa,{size:12})})]})]}),n("div",{class:"audit-title-line",children:I(y)}),y.events.length>0&&n("div",{class:"audit-event-pills",children:y.events.slice(0,4).map((E,H)=>n("span",{class:"audit-chip soft",children:[E.type,E.durationMs!==void 0?` ${E.durationMs}ms`:""]},`${y.traceId}-${H}`))}),u.has(y.traceId)&&S(y)&&n("div",{class:"audit-detail-section",children:y.events.map((E,H)=>n("div",{class:"audit-event-row",children:[n("span",{class:`audit-event-type-label${E.type==="tool_use"?" tool":""}`,children:E.type}),n("span",{class:`audit-event-content${E.type==="tool_use"?" mono":""}`,children:fc(E)}),n("span",{class:"audit-event-dur",children:gc(E.durationMs)})]},`${y.traceId}-detail-${H}`))})]})]},y.traceId))}),r>x&&n("div",{style:{display:"flex",justifyContent:"center",gap:"8px",padding:"12px"},children:[n("button",{class:"btn btn-sm",disabled:s===0||v,onClick:()=>a(y=>Math.max(0,y-1)),children:"Previous"}),n("span",{style:{fontSize:"12px",color:"var(--text-muted)",alignSelf:"center"},children:[r===0?0:s*x+1,"–",Math.min((s+1)*x,r)," of ",r]}),n("button",{class:"btn btn-sm",disabled:(s+1)*x>=r||v,onClick:()=>a(y=>y+1),children:"Next"})]})]})]})}function vc(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),s=r%60;return`${i}m ${s.toString().padStart(2,"0")}s`}function wi(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 _c(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(),s=Math.floor(i/1e3),a=s<60?`${s}s`:`${Math.floor(s/60)}m ${s%60}s`;return`${r} by ${t} · ${a} after request`}return`${r} by ${t}`}function Si(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 Ti(e){var r;const t=(r=e.channelMeta)==null?void 0:r.channel;return t==="telegram"||t==="discord"?n(tt,{size:12}):t==="dashboard"?n(tt,{size:12}):n(Xn,{size:12})}function Ci(e){return e?e.replace(/^\/Users\/[^/]+/,"~"):""}function Ai(e){return e===1?"tier-1":e===2?"tier-2":"tier-3"}function bc({showToast:e,onCountChange:t}){const[r,i]=w([]),[s,a]=w([]),[o,l]=w(!0),[d,c]=w(new Set),[m,h]=w(null),v=Le(0),[,g]=w(0);W(()=>{u(),b();const f=setInterval(u,5e3),_=setInterval(()=>{v.current++,g(v.current)},1e3);return()=>{clearInterval(f),clearInterval(_)}},[]);async function u(){var f;try{const _=await us();i(_.pending??[]),a((_.recent??[]).filter(A=>A.status!=="pending")),t==null||t(((f=_.pending)==null?void 0:f.length)??0)}catch{}finally{l(!1)}}async function b(){var f,_,A,R,O,I,D,S;try{const y=(await er()).config,$=(A=(_=(f=y.channels)==null?void 0:f.telegram)==null?void 0:_.tools)==null?void 0:A.execApproval,E=(I=(O=(R=y.channels)==null?void 0:R.discord)==null?void 0:O.tools)==null?void 0:I.execApproval,H=(S=(D=y.heartbeat)==null?void 0:D.tools)==null?void 0:S.execApproval,X=$||E||H||{},T=Array.isArray(X.requireForTiers)&&X.requireForTiers.length>0?X.requireForTiers:[2,3];h({enabled:X.enabled!==!1,ttlMs:Number(X.ttlMs)>0?Number(X.ttlMs):3e5,tiers:T})}catch{h(null)}}async function x(f,_){c(A=>new Set([...A,f]));try{_?(await hs(f),e("Command approved","success")):(await ps(f),e("Command denied","warning")),await u()}catch{e("Action failed","error")}finally{c(A=>{const R=new Set(A);return R.delete(f),R})}}function k(f){return f==="approved"?n(Re,{size:18}):f==="denied"?n(nt,{size:18}):f==="expired"?n(Qr,{size:18}):n(Dn,{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(ne,{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(f=>`T${f}`).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(as,{size:18})}),n("div",{class:"empty-state-text",children:"No pending approvals"})]}):n("div",{class:"appr-list",children:r.map(f=>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(Dn,{size:18})}),n("span",{class:"appr-item-id",children:["req-",f.id]}),n("span",{class:`appr-chip tier ${Ai(f.tier)}`,children:["TIER ",f.tier]}),n("span",{class:"appr-chip pending",children:"PENDING"}),n("span",{class:"appr-elapsed",children:[n(Qr,{size:12})," ",vc(f.createdAt)]}),n("div",{style:{flex:1}}),n("div",{class:"appr-actions",children:[n("button",{class:"approval-btn-deny",disabled:d.has(f.id),onClick:()=>x(f.id,!1),children:"Deny"}),n("button",{class:"approval-btn-approve",disabled:d.has(f.id),onClick:()=>x(f.id,!0),children:[n(Re,{size:14})," Approve"]})]})]}),n("div",{class:"appr-reason",children:f.reason}),n("div",{class:"appr-cmd-block",children:f.command}),n("div",{class:"appr-footer",children:[n("span",{class:"appr-footer-item",children:[Ti(f)," via ",Si(f)]}),f.cwd&&n("span",{class:"appr-footer-sep",children:"·"}),f.cwd&&n("span",{class:"appr-footer-item",children:Ci(f.cwd)}),n("span",{class:"appr-footer-sep",children:"·"}),n("span",{class:"appr-footer-item",children:wi(f.createdAt)})]})]})]},f.id))}),s.length>0&&n(ne,{children:[n("div",{class:"appr-section-label",style:{marginTop:32},children:"RECENT HISTORY"}),n("div",{class:"appr-list",children:s.slice(0,30).map(f=>n("div",{class:`appr-item ${f.status}`,children:[n("div",{class:`appr-item-border ${f.status}`}),n("div",{class:"appr-item-body",children:[n("div",{class:"appr-item-head",children:[n("div",{class:`appr-item-icon ${f.status}`,children:k(f.status)}),n("span",{class:"appr-item-id",children:["req-",f.id]}),n("span",{class:`appr-chip tier ${Ai(f.tier)}`,children:["TIER ",f.tier]}),n("span",{class:`appr-chip ${f.status}`,children:f.status.toUpperCase()})]}),n("div",{class:"appr-reason",children:f.reason}),n("div",{class:"appr-cmd-block",children:f.command}),n("div",{class:"appr-footer",children:[n("span",{class:"appr-footer-item",children:[Ti(f)," via ",Si(f)]}),f.cwd&&n("span",{class:"appr-footer-sep",children:"·"}),f.cwd&&n("span",{class:"appr-footer-item",children:Ci(f.cwd)}),n("span",{class:"appr-footer-sep",children:"·"}),n("span",{class:"appr-footer-item",children:wi(f.createdAt)}),n("span",{class:"appr-footer-sep",children:"·"}),n("span",{class:"appr-footer-resolution",children:_c(f)})]})]})]},f.id))})]})]})]})}const Ei="main";function yc(){const[e,t]=w([]),[r,i]=w(null),[s,a]=w(""),[o,l]=w(!0),[d,c]=w(!1);W(()=>{m()},[]);async function m(){l(!0);try{const v=await ml(Ei);t(v.files??[])}catch(v){console.error("[memory] load failed",v)}finally{l(!1)}}async function h(v){i(v),c(!0);try{const g=await vl(Ei,v);a(g.content??"")}catch(g){console.error("[memory] file load failed",g),a("")}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($n,{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:()=>h(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(Xt,{content:s})})}):n("div",{class:"templates-empty",children:[n($n,{size:32}),n("p",{children:"Select a file to view"})]})})]})]})}const kc=/^[A-Za-z0-9._-]+\/[A-Za-z0-9._/-]+$/,xc=/^[A-Za-z0-9.-]+$/,wc=/^[A-Za-z0-9._/-]+$/;function Sc(e,t){return t[e]?{ok:!0}:kc.test(e)?{ok:!0}:xc.test(e)&&/[-.]/.test(e)?{ok:!0}:!wc.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 Tc({showToast:e}){const[t,r]=w(""),[i,s]=w(""),[a,o]=w({}),[l,d]=w(!0),[c,m]=w(!1);W(()=>{h()},[]);async function h(){d(!0);try{const g=await fl();r(g.current??""),s(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=Sc(g,a);if(!u.ok){e(u.error,"error");return}m(!0);try{const b=await gl(g);r(b.model),s(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"})}),l?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=>s(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(a).sort(([g],[u])=>g.localeCompare(u)).map(([g,u])=>n("button",{class:`btn btn-sm${i===g?" btn-primary":""}`,onClick:()=>s(g),title:u,children:g},g))}),n("button",{class:"btn btn-primary",onClick:v,disabled:c||!i.trim(),children:c?"Saving…":"Switch Model"})]})]})})]})}function Cc(){const[e,t]=w([]),[r,i]=w(null),[s,a]=w(""),[o,l]=w(!0),[d,c]=w(!1);W(()=>{m()},[]);async function m(){l(!0);try{const v=await kl();t(v.files??[])}catch(v){console.error("[logs] load failed",v)}finally{l(!1)}}async function h(v){i(v),c(!0);try{const g=await xl(`logs/${encodeURIComponent(v.name)}`);a(g.content??"")}catch(g){console.error("[logs] file load failed",g),a("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(Gt,{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:()=>h(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:s.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 Ac(e){var o,l,d,c,m,h,v,g;const t=(d=(l=(o=e.channels)==null?void 0:o.telegram)==null?void 0:l.tools)==null?void 0:d.execApproval,r=(h=(m=(c=e.channels)==null?void 0:c.discord)==null?void 0:m.tools)==null?void 0:h.execApproval,i=(g=(v=e.heartbeat)==null?void 0:v.tools)==null?void 0:g.execApproval,s=t||r||i||{},a=Array.isArray(s.requireForTiers)&&s.requireForTiers.length>0?s.requireForTiers:[2,3];return{enabled:s.enabled!==!1,ttlMs:Number(s.ttlMs)>0?Number(s.ttlMs):3e5,requireForTiers:a}}function Ec({showToast:e}){const[t,r]=w(null),[i,s]=w(!0),[a,o]=w(!1),[l,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});W(()=>{h()},[]);async function h(){var u,b,x,k,f,_,A,R,O,I,D,S,y;s(!0);try{const E=(await er()).config??{},H=Ac(E);r(E),m({gatewayHost:((u=E.gateway)==null?void 0:u.host)??"127.0.0.1",gatewayPort:String(((b=E.gateway)==null?void 0:b.port)??18790),gatewayMode:((x=E.gateway)==null?void 0:x.mode)==="remote"?"remote":"local",activeChannel:((k=E.channels)==null?void 0:k.active)==="telegram"||((f=E.channels)==null?void 0:f.active)==="discord"?E.channels.active:"",telegramEnabled:!!((A=(_=E.channels)==null?void 0:_.telegram)!=null&&A.enabled),discordEnabled:!!((O=(R=E.channels)==null?void 0:R.discord)!=null&&O.enabled),agentsDefault:((I=E.agents)==null?void 0:I.default)??"main",heartbeatIntervalMs:String(((D=E.heartbeat)==null?void 0:D.intervalMs)??3e5),heartbeatPrompt:((S=E.heartbeat)==null?void 0:S.prompt)??"",heartbeatModel:((y=E.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($){console.error("[config] load failed",$),e("Failed to load config","error")}finally{s(!1)}}async function v(){d(!0);try{await El(),e("Config reloaded","success"),await h()}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 x={enabled:c.execApprovalEnabled,ttlMs:Number(c.execApprovalTtlMs)||3e5,requireForTiers:b};u.channels.telegram.tools.execApproval=x,u.channels.discord.tools.execApproval=x,u.heartbeat.tools.execApproval=x,o(!0);try{await fs(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:l,children:l?"Reloading…":"Reload"}),n("button",{class:"btn btn-sm btn-primary",onClick:()=>void g(),disabled:a,children:a?"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 Lc(){var g;const[e,t]=w([]),[r,i]=w(null),[s,a]=w(null),[o,l]=w(!0),[d,c]=w(!1);W(()=>{m()},[]);async function m(){l(!0);try{const u=await Ll();t(u.digests??[])}finally{l(!1)}}async function h(u){i(u),c(!0);try{const b=await Rl(u);a(b)}catch{a(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(Mn,{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 h(u.id),class:`templates-list-item${r===u.id?" active":""}`,children:[n("div",{class:"templates-list-icon",children:n(Mn,{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"})}):s?n("div",{children:[n("div",{class:"digest-header",children:[n("div",{class:"digest-title",children:s.jobName}),n("div",{class:"digest-meta",children:v(s.createdAt)})]}),s.summary&&s.summary.trim().length>0&&n(kt,{content:s.summary,className:"digest-reader markdown-content",style:{marginBottom:12}}),((g=s.articles)==null?void 0:g.length)>0?n("div",{class:"digest-articles",children:s.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(qa,{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(kt,{content:u.summary,className:"markdown-content",style:{fontSize:13,color:"var(--text-dim)",marginTop:8}})]},u.id))}):s.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 Rc({showToast:e}){const[t,r]=w([]),[i,s]=w(null),[a,o]=w(null),[l,d]=w(!0),[c,m]=w(!1),[h,v]=w(""),[g,u]=w(""),[b,x]=w(!1),[k,f]=w(!1),[_,A]=w("raw"),[R,O]=w(!1),[I,D]=w("");W(()=>{S()},[]);async function S(){d(!0);try{const T=await $l();r(T.skills??[])}catch{e("Failed to load skills","error")}finally{d(!1)}}async function y(T){s(T),A("markdown"),m(!0);try{const N=await Ml(T);o(N),D(N.rawContent||N.body||""),O(!1)}catch{e("Failed to load skill details","error"),o(null)}finally{m(!1)}}async function $(){if(a){f(!0);try{await Pl(a.name,I),e("Skill updated","success"),await y(a.name)}catch{e("Failed to update skill","error")}finally{f(!1)}}}async function E(T){if(T.enabled!==void 0)try{await Dl(T.name,!T.enabled),e(`Skill ${T.name} ${T.enabled?"disabled":"enabled"}`,"success"),await S(),i===T.name&&await y(T.name)}catch{e("Failed to update skill","error")}}async function H(T){if(window.confirm(`Delete skill "${T}"? This action cannot be undone.`)){r(ce=>ce.filter(pe=>pe.name!==T)),i===T&&(s(null),o(null));try{await Nl(T),e(`Deleted ${T}`,"warning"),await S()}catch{e("Failed to delete skill","error"),await S()}}}async function X(){const T=h.trim();if(!(!T||!g.trim())){f(!0);try{await Il(T,g),e("Skill created","success"),v(""),u(""),x(!1),await S(),await y(T)}catch{e("Failed to create skill","error")}finally{f(!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:()=>x(T=>!T),children:b?"Close":"New"}),n("button",{class:"btn-refresh",onClick:S,children:[n(ue,{size:14})," Refresh"]})]})]}),l?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(Pn,{size:18})}),n("div",{class:"empty-state-text",children:"No skills found"})]}):n("div",{class:"skills-grid",style:{marginBottom:14},children:t.map(T=>n("div",{class:"skill-card",children:[n("div",{class:"skill-header",children:[n("div",{class:"skill-name",children:T.name}),n("div",{title:T.eligible?"Eligible":T.reason||"Ineligible",children:T.eligible===!1?n(Wa,{size:16,color:"var(--error)"}):n(as,{size:16,color:"var(--success)"})})]}),n("div",{class:"skill-desc",children:T.description||"No description"}),T.tags&&T.tags.length>0&&n("div",{class:"skill-tags",children:T.tags.slice(0,4).map(N=>n("span",{class:"skill-tag",children:N},N))}),n("div",{style:{display:"flex",gap:8,marginTop:10},children:[n("button",{class:"btn btn-sm",onClick:()=>void y(T.name),children:"View"}),n("button",{class:"btn btn-sm",disabled:!0,title:"Coming soon",onClick:()=>void E(T),children:T.enabled?"Disable":"Enable"}),n("button",{class:"btn btn-sm btn-danger",onClick:()=>void H(T.name),children:"Delete"})]})]},T.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:h,onInput:T=>v(T.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:T=>u(T.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||!h.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"})}):a?n(ne,{children:[n("div",{class:"audit-header",children:[n("div",{style:{fontWeight:700},children:a.name}),n("div",{style:{display:"flex",gap:8},children:[n("button",{class:"btn btn-sm",onClick:()=>A(T=>T==="raw"?"markdown":"raw"),children:_==="raw"?"Markdown":"Raw"}),n("button",{class:"btn btn-sm btn-danger",onClick:()=>void H(a.name),children:"Delete"})]})]}),n("div",{class:"audit-summary",style:{marginBottom:8},children:a.description||"No description"}),n("div",{class:"audit-meta",style:{marginBottom:12},children:[n("span",{children:["Eligible: ",a.eligible?"yes":"no"]}),n("span",{children:["Enabled: ",a.enabled?"yes":"no"]}),n("span",{children:["Priority: ",a.priority??100]})]}),R?n(ne,{children:[n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Edit SKILL.md"}),n("textarea",{value:I,onInput:T=>D(T.target.value),style:{minHeight:280}})]}),n("div",{class:"form-actions",children:[n("button",{class:"btn btn-sm btn-primary",onClick:()=>void $(),disabled:k||!I.trim(),children:k?"Saving…":"Save"}),n("button",{class:"btn btn-sm",onClick:()=>{O(!1),D(a.rawContent||a.body||"")},children:"Cancel"})]})]}):_==="markdown"?n(Xt,{content:a.rawContent||a.body||""}):n("pre",{class:"ca-output",style:{marginTop:0,maxHeight:420},children:a.rawContent||a.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(Pn,{size:18})}),n("div",{class:"empty-state-text",children:"Select a skill to inspect"})]})})]})]})]})}function $c(){var f;const[e,t]=w(null),[r,i]=w(null),[s,a]=w(!0),[o,l]=w(!1);W(()=>{d()},[]);async function d(){a(!0);try{const[_,A]=await Promise.all([ni(),ri()]);t(_),i(A)}catch(_){console.error("[health] load failed",_)}finally{a(!1)}}async function c(){l(!0);try{const[_,A]=await Promise.all([ni(),ri()]);t(_),i(A)}catch(_){console.error("[health] recheck failed",_)}finally{l(!1)}}function m(_){return _==="ok"?"ok":_==="warn"?"warn":"error"}function h(_){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=(((f=r==null?void 0:r.report)==null?void 0:f.checks)??(e==null?void 0:e.checks)??[]).map(_=>v(_)),b=u.filter(_=>_.status==="error").length,x=u.filter(_=>_.status==="warn").length,k=u.filter(_=>_.status==="ok").length;return n("div",{children:[n("div",{class:"page-header",id:"healthRecheckBtn",children:[n("div",{class:"page-title",children:"Health"}),n("button",{class:"btn btn-sm",id:"healthRecheckBtn",onClick:c,disabled:o||s,children:o?"Checking…":"Recheck"})]}),s?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(Ha,{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)":x>0?"var(--warning-soft)":"var(--success-soft)",color:b>0?"var(--error)":x>0?"var(--warning)":"var(--success)"},children:b>0?n(nt,{size:16}):x>0?n(ei,{size:16}):n(Re,{size:16})}),n("div",{class:"stat-label",children:"Issues"}),n("div",{class:"stat-value",style:{color:b>0?"var(--error)":x>0?"var(--warning)":"var(--success)"},children:b+x}),n("div",{class:"stat-sub",children:[b," errors, ",x," 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(os,{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((_,A)=>n("div",{class:"feed-item",children:[n("div",{style:{width:32,height:32,borderRadius:"var(--radius-sm)",background:h(_.status)+"18",color:h(_.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(ei,{size:14}):n(nt,{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:h(_.status),fontWeight:600,fontFamily:"var(--mono)",whiteSpace:"nowrap"},children:_.status})]},A))})})})]}),n("div",{id:"healthEnvVars",style:{display:"none"}}),n("div",{id:"healthFeatures",style:{display:"none"}})]})]})}const Je="main";function Mc({showToast:e}){const[t,r]=w([]),[i,s]=w(null),[a,o]=w(""),[l,d]=w(""),[c,m]=w(!0),[h,v]=w(!1),[g,u]=w(!1),[b,x]=w("edit");W(()=>{k()},[]);async function k(){m(!0);try{const I=await _l(Je);r(I.templates??[])}catch(I){console.error("[templates] load failed",I)}finally{m(!1)}}async function f(I){s(I),x(I.toLowerCase().endsWith(".md")?"preview":"edit"),v(!0);try{const S=(await bl(Je,I)).content??"";o(S),d(S)}catch(D){console.error("[templates] file load failed",D),o(""),d("")}finally{v(!1)}}async function _(){if(i){u(!0);try{await yl(Je,i,a),d(a),e("Template saved","success")}catch{e("Failed to save template","error")}finally{u(!1)}}}function A(){o(l)}const R=a!==l,O=t.find(I=>I.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(Gt,{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:Je,disabled:!0,children:n("option",{value:"main",children:"main"})})]}),n("div",{class:"templates-list",children:t.map(I=>n("button",{class:`templates-list-item${i===I.name?" active":""}`,onClick:()=>f(I.name),children:[n("div",{class:"templates-list-icon",children:I.name.substring(0,2).toUpperCase()}),n("div",{class:"templates-list-content",children:[n("div",{class:"templates-list-title",children:I.name}),n("div",{class:"templates-list-meta",children:[Math.round((I.size||0)/1024),"KB"]})]})]},I.name))})]}),n("div",{class:"templates-main",children:i?h?n("div",{class:"templates-loading",children:n("div",{class:"spinner"})}):n(ne,{children:[n("div",{class:"templates-editor-header",children:[n("div",{class:"templates-editor-title-row",children:[n("h2",{class:"templates-editor-title",children:i}),R&&n("span",{class:"templates-unsaved-pill",children:"Unsaved changes"})]}),n("div",{class:"templates-editor-actions",children:[R&&n("button",{class:"templates-discard-btn",onClick:A,children:"Discard"}),n("button",{class:"templates-save-btn",onClick:_,disabled:g||!R,children:g?"Saving…":"Save"})]})]}),n("div",{class:"templates-tabs",children:[n("button",{class:`templates-tab${b==="edit"?" active":""}`,onClick:()=>x("edit"),children:"Edit"}),n("button",{class:`templates-tab${b==="preview"?" active":""}`,onClick:()=>x("preview"),children:"Preview"})]}),O&&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:(O.size||0)>1024?`${Math.round((O.size||0)/1024)}KB`:`${O.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:Je})]}),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/",Je,"/",i]})]})]}),n("div",{class:"templates-content",children:b==="preview"?n("div",{class:"templates-markdown-preview",children:n(Xt,{content:a})}):n("textarea",{class:"templates-textarea",value:a,onInput:I=>o(I.target.value),spellcheck:!1})})]}):n("div",{class:"templates-empty",children:[n(Gt,{size:32}),n("p",{children:"Select a template to edit"})]})})]})]})}function mt(e){return e===0?"$0.00":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function vt(e){return e===0?"0":e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function Ic(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 s=Math.floor(i/60);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}function Dc(){const[e,t]=w(null),[r,i]=w([]),[s,a]=w(0),[o,l]=w(0),[d,c]=w(!0),m=25;W(()=>{h();const x=setInterval(h,3e4);return()=>clearInterval(x)},[o]);async function h(){try{const[x,k]=await Promise.all([tr(),Ol({limit:m,offset:o*m})]);t(x),i(k.records??[]),a(k.total??0)}catch(x){console.error("[usage] load failed",x)}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((x,k)=>k[1].cost-x[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:h,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(Ue,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value",children:mt((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(Ue,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value",children:mt((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(Ue,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value",children:mt((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(tt,{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 · ",vt(((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(([x,k])=>n("tr",{children:[n("td",{children:n("code",{class:"usage-model-pill",children:x})}),n("td",{children:k.calls}),n("td",{children:vt(k.inputTokens)}),n("td",{children:vt(k.outputTokens)}),n("td",{class:"usage-cost-cell",children:mt(k.cost)})]},x))})]})})]}),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:[s," total"]})]}),r.length===0?n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(Ga,{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(x=>n("div",{class:"feed-item",children:[n("div",{class:`feed-icon ${x.trigger==="telegram"?"telegram":x.trigger==="cron"?"cron":"system"}`,children:n(Ue,{size:14})}),n("div",{children:[n("div",{class:"feed-title",children:[n("code",{class:"usage-model-pill",children:x.model})," ",n("span",{class:"audit-chip trigger muted",children:x.trigger})]}),n("div",{class:"feed-detail",children:[vt(x.inputTokens)," in · ",vt(x.outputTokens)," out · ",mt(x.totalCost)]})]}),n("div",{class:"feed-time",children:Ic(x.timestamp)})]},x.id))}),s>m&&n("div",{style:{display:"flex",justifyContent:"center",gap:"8px",padding:"12px"},children:[n("button",{class:"btn btn-sm",disabled:o===0,onClick:()=>l(x=>Math.max(0,x-1)),children:"Previous"}),n("span",{style:{fontSize:"12px",color:"var(--text-muted)",alignSelf:"center"},children:[o*m+1,"–",Math.min((o+1)*m,s)," of ",s]}),n("button",{class:"btn btn-sm",disabled:(o+1)*m>=s,onClick:()=>l(x=>x+1),children:"Next"})]})]})]})]})}const Pc=["overview","history","cron","memory","model","coding","logs","audit","digests","skills","approvals","health","usage","config","templates"];function Nc(e){return Pc.includes(e)}function Li(){const e=window.location.hash.replace(/^#/,"").trim();return Nc(e)?e:"overview"}function Oc(){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 zc({onLogin:e,botName:t,botEmoji:r}){const[i,s]=w(""),[a,o]=w("");async function l(){const d=i.trim();if(d)try{if((await fetch("/api/dashboard/status",{headers:{Authorization:`Bearer ${d}`}})).status===401){o("Invalid token");return}al(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=>{s(d.target.value),o("")},onKeyDown:d=>d.key==="Enter"&&l(),style:{width:"100%",padding:"10px 14px",borderRadius:"var(--radius-sm)",border:`1px solid ${a?"var(--error)":"var(--border)"}`,background:"var(--surface-alt)",color:"var(--text)",fontFamily:"var(--mono)",fontSize:13,marginBottom:12,outline:"none",boxSizing:"border-box"}}),a&&n("div",{style:{fontSize:12,color:"var(--error)",marginBottom:12},children:a}),n("button",{class:"btn btn-primary",style:{width:"100%"},onClick:l,children:"Sign in"})]})})}function Uc(){const e=Oc(),[t,r]=w(!!cs()),[i,s]=w(()=>Li()),[a,o]=w(()=>window.innerWidth<=980),[l,d]=w(()=>window.innerWidth>980),[c,m]=w(()=>localStorage.getItem("theme")??"light"),[h,v]=w(0),{toasts:g,showToast:u}=sl();W(()=>ol(()=>{r(!1)}),[]),W(()=>{document.documentElement.setAttribute("data-theme",c),localStorage.setItem("theme",c)},[c]),W(()=>{function f(){const _=window.innerWidth<=980;o(A=>(A!==_&&d(!_),_))}return window.addEventListener("resize",f),()=>window.removeEventListener("resize",f)},[]),W(()=>{if(!a||!l){document.body.style.overflow="";return}return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[a,l]),W(()=>{const f=()=>{const _=Li();s(_),a&&d(!1)};return window.location.hash?f():window.location.hash="#overview",window.addEventListener("hashchange",f),()=>window.removeEventListener("hashchange",f)},[a]);function b(){m(f=>f==="light"?"dark":"light")}function x(f){const _=`#${f}`;window.location.hash!==_?window.location.hash=_:s(f),a&&d(!1)}if(!t)return n(zc,{botName:e.name,botEmoji:e.emoji,onLogin:()=>r(!0)});function k(){switch(i){case"overview":return n(si,{onNavigate:x,showToast:u});case"history":return n(Zl,{});case"cron":return n(Jl,{showToast:u});case"usage":return n(Dc,{});case"coding":return n(pc,{});case"audit":return n(mc,{});case"approvals":return n(bc,{showToast:u,onCountChange:v});case"memory":return n(yc,{});case"model":return n(Tc,{showToast:u});case"logs":return n(Cc,{});case"config":return n(Ec,{showToast:u});case"digests":return n(Lc,{});case"skills":return n(Rc,{showToast:u});case"health":return n($c,{});case"templates":return n(Mc,{showToast:u});default:return n(si,{onNavigate:x,showToast:u})}}return n(ne,{children:[n("div",{class:`shell${a?" shell-narrow":""}${a&&l?" sidebar-open":""}`,children:[a&&n("button",{class:"global-sidebar-toggle",onClick:()=>d(!0),"aria-label":"Open sidebar",children:n(Ja,{size:16})}),n(rl,{currentPage:i,onNavigate:x,botName:e.name,botEmoji:e.emoji,pendingApprovals:h,isNarrow:a,onClose:()=>d(!1)}),a&&l?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(Ya,{size:16}):n(tl,{size:16})}),k()]})]}),n(il,{toasts:g})]})}Xe(n(Uc,{}),document.getElementById("app"));
|
|
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>${be(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),s=ci(e);if(s===null)return i;e=s;let a='<a href="'+e+'"';return t&&(a+=' title="'+be(t)+'"'),a+=">"+i+"</a>",a}image({href:e,title:t,text:r,tokens:i}){i&&(r=this.parser.parseInline(i,this.parser.textRenderer));let s=ci(e);if(s===null)return be(r);e=s;let a=`<img src="${e}" alt="${be(r)}"`;return t&&(a+=` title="${be(t)}"`),a+=">",a}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:be(e.text)}},dr=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 Bn{constructor(t){q(this,"options");q(this,"renderer");q(this,"textRenderer");this.options=t||We,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 dr}static parse(t,r){return new Bn(r).parse(t)}static parseInline(t,r){return new Bn(r).parseInline(t)}parse(t){var i,s;let r="";for(let a=0;a<t.length;a++){let o=t[a];if((s=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&s[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 l=o;switch(l.type){case"space":{r+=this.renderer.space(l);break}case"hr":{r+=this.renderer.hr(l);break}case"heading":{r+=this.renderer.heading(l);break}case"code":{r+=this.renderer.code(l);break}case"table":{r+=this.renderer.table(l);break}case"blockquote":{r+=this.renderer.blockquote(l);break}case"list":{r+=this.renderer.list(l);break}case"checkbox":{r+=this.renderer.checkbox(l);break}case"html":{r+=this.renderer.html(l);break}case"def":{r+=this.renderer.def(l);break}case"paragraph":{r+=this.renderer.paragraph(l);break}case"text":{r+=this.renderer.text(l);break}default:{let d='Token with "'+l.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 s,a;let i="";for(let o=0;o<t.length;o++){let l=t[o];if((a=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&a[l.type]){let c=this.options.extensions.renderers[l.type].call({parser:this},l);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(l.type)){i+=c||"";continue}}let d=l;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}},Ot,yt=(Ot=class{constructor(e){q(this,"options");q(this,"block");this.options=e||We}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(Ot,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),q(Ot,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Ot),Fo=class{constructor(...e){q(this,"defaults",nr());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",dr);q(this,"Lexer",ge);q(this,"Tokenizer",Kt);q(this,"Hooks",yt);this.use(...e)}walkTokens(e,t){var i,s;let r=[];for(let a of e)switch(r=r.concat(t.call(this,a)),a.type){case"table":{let o=a;for(let l of o.header)r=r.concat(this.walkTokens(l.tokens,t));for(let l of o.rows)for(let d of l)r=r.concat(this.walkTokens(d.tokens,t));break}case"list":{let o=a;r=r.concat(this.walkTokens(o.items,t));break}default:{let o=a;(s=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&s[o.type]?this.defaults.extensions.childTokens[o.type].forEach(l=>{let d=o[l].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(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){let a=t.renderers[s.name];a?t.renderers[s.name]=function(...o){let l=s.renderer.apply(this,o);return l===!1&&(l=a.apply(this,o)),l}:t.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let a=t[s.level];a?a.unshift(s.tokenizer):t[s.level]=[s.tokenizer],s.start&&(s.level==="block"?t.startBlock?t.startBlock.push(s.start):t.startBlock=[s.start]:s.level==="inline"&&(t.startInline?t.startInline.push(s.start):t.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(t.childTokens[s.name]=s.childTokens)}),i.extensions=t),r.renderer){let s=this.defaults.renderer||new Jt(this.defaults);for(let a in r.renderer){if(!(a in s))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;let o=a,l=r.renderer[o],d=s[o];s[o]=(...c)=>{let m=l.apply(s,c);return m===!1&&(m=d.apply(s,c)),m||""}}i.renderer=s}if(r.tokenizer){let s=this.defaults.tokenizer||new Kt(this.defaults);for(let a in r.tokenizer){if(!(a in s))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;let o=a,l=r.tokenizer[o],d=s[o];s[o]=(...c)=>{let m=l.apply(s,c);return m===!1&&(m=d.apply(s,c)),m}}i.tokenizer=s}if(r.hooks){let s=this.defaults.hooks||new yt;for(let a in r.hooks){if(!(a in s))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;let o=a,l=r.hooks[o],d=s[o];yt.passThroughHooks.has(a)?s[o]=c=>{if(this.defaults.async&&yt.passThroughHooksRespectAsync.has(a))return(async()=>{let h=await l.call(s,c);return d.call(s,h)})();let m=l.call(s,c);return d.call(s,m)}:s[o]=(...c)=>{if(this.defaults.async)return(async()=>{let h=await l.apply(s,c);return h===!1&&(h=await d.apply(s,c)),h})();let m=l.apply(s,c);return m===!1&&(m=d.apply(s,c)),m}}i.hooks=s}if(r.walkTokens){let s=this.defaults.walkTokens,a=r.walkTokens;i.walkTokens=function(o){let l=[];return l.push(a.call(this,o)),s&&(l=l.concat(s.call(this,o))),l}}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},s={...this.defaults,...i},a=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&i.async===!1)return a(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return(async()=>{let o=s.hooks?await s.hooks.preprocess(t):t,l=await(s.hooks?await s.hooks.provideLexer():e?ge.lex:ge.lexInline)(o,s),d=s.hooks?await s.hooks.processAllTokens(l):l;s.walkTokens&&await Promise.all(this.walkTokens(d,s.walkTokens));let c=await(s.hooks?await s.hooks.provideParser():e?me.parse:me.parseInline)(d,s);return s.hooks?await s.hooks.postprocess(c):c})().catch(a);try{s.hooks&&(t=s.hooks.preprocess(t));let o=(s.hooks?s.hooks.provideLexer():e?ge.lex:ge.lexInline)(t,s);s.hooks&&(o=s.hooks.processAllTokens(o)),s.walkTokens&&this.walkTokens(o,s.walkTokens);let l=(s.hooks?s.hooks.provideParser():e?me.parse:me.parseInline)(o,s);return s.hooks&&(l=s.hooks.postprocess(l)),l}catch(o){return a(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>"+be(r.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(r);throw r}}},He=new Fo;function j(e,t){return He.parse(e,t)}j.options=j.setOptions=function(e){return He.setOptions(e),j.defaults=He.defaults,vs(j.defaults),j};j.getDefaults=nr;j.defaults=We;j.use=function(...e){return He.use(...e),j.defaults=He.defaults,vs(j.defaults),j};j.walkTokens=function(e,t){return He.walkTokens(e,t)};j.parseInline=He.parseInline;j.Parser=me;j.parser=me.parse;j.Renderer=Jt;j.TextRenderer=dr;j.Lexer=ge;j.lexer=ge.lex;j.Tokenizer=Kt;j.Hooks=yt;j.parse=j;j.options;j.setOptions;j.use;j.walkTokens;j.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:Ls,setPrototypeOf:hi,isFrozen:Ho,getPrototypeOf:Wo,getOwnPropertyDescriptor:jo}=Object;let{freeze:le,seal:he,create:Fn}=Object,{apply:Hn,construct:Wn}=typeof Reflect<"u"&&Reflect;le||(le=function(t){return t});he||(he=function(t){return t});Hn||(Hn=function(t,r){for(var i=arguments.length,s=new Array(i>2?i-2:0),a=2;a<i;a++)s[a-2]=arguments[a];return t.apply(r,s)});Wn||(Wn=function(t){for(var r=arguments.length,i=new Array(r>1?r-1:0),s=1;s<r;s++)i[s-1]=arguments[s];return new t(...i)});const Pt=oe(Array.prototype.forEach),qo=oe(Array.prototype.lastIndexOf),pi=oe(Array.prototype.pop),ut=oe(Array.prototype.push),Go=oe(Array.prototype.splice),Ft=oe(String.prototype.toLowerCase),_n=oe(String.prototype.toString),bn=oe(String.prototype.match),ht=oe(String.prototype.replace),Vo=oe(String.prototype.indexOf),Zo=oe(String.prototype.trim),fe=oe(Object.prototype.hasOwnProperty),se=oe(RegExp.prototype.test),pt=Ko(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),s=1;s<r;s++)i[s-1]=arguments[s];return Hn(e,t,i)}}function Ko(e){return function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return Wn(e,r)}}function z(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ft;hi&&hi(e,null);let i=t.length;for(;i--;){let s=t[i];if(typeof s=="string"){const a=r(s);a!==s&&(Ho(t)||(t[i]=a),s=a)}e[s]=!0}return e}function Jo(e){for(let t=0;t<e.length;t++)fe(e,t)||(e[t]=null);return e}function ye(e){const t=Fn(null);for(const[r,i]of Ls(e))fe(e,r)&&(Array.isArray(i)?t[r]=Jo(i):i&&typeof i=="object"&&i.constructor===Object?t[r]=ye(i):t[r]=i);return t}function ft(e,t){for(;e!==null;){const i=jo(e,t);if(i){if(i.get)return oe(i.get);if(typeof i.value=="function")return oe(i.value)}e=Wo(e)}function r(){return null}return r}const fi=le(["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=le(["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=le(["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"]),Yo=le(["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=le(["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"]),Xo=le(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),gi=le(["#text"]),mi=le(["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=le(["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"]),vi=le(["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"]),Nt=le(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Qo=he(/\{\{[\w\W]*|[\w\W]*\}\}/gm),ec=he(/<%[\w\W]*|[\w\W]*%>/gm),tc=he(/\$\{[\w\W]*/gm),nc=he(/^data-[\-\w.\u00B7-\uFFFF]+$/),rc=he(/^aria-[\-\w]+$/),Rs=he(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ic=he(/^(?:\w+script|data):/i),sc=he(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),$s=he(/^html$/i),ac=he(/^[a-z][.\w]*(-[.\w]+)+$/i);var _i=Object.freeze({__proto__:null,ARIA_ATTR:rc,ATTR_WHITESPACE:sc,CUSTOM_ELEMENT:ac,DATA_ATTR:nc,DOCTYPE_NAME:$s,ERB_EXPR:ec,IS_ALLOWED_URI:Rs,IS_SCRIPT_OR_DATA:ic,MUSTACHE_EXPR:Qo,TMPLIT_EXPR:tc});const gt={element:1,text:3,progressingInstruction:7,comment:8,document:9},lc=function(){return typeof window>"u"?null:window},oc=function(t,r){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let i=null;const s="data-tt-policy-suffix";r&&r.hasAttribute(s)&&(i=r.getAttribute(s));const a="dompurify"+(i?"#"+i:"");try{return t.createPolicy(a,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},bi=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Ms(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:lc();const t=I=>Ms(I);if(t.version="3.3.1",t.removed=[],!e||!e.document||e.document.nodeType!==gt.document||!e.Element)return t.isSupported=!1,t;let{document:r}=e;const i=r,s=i.currentScript,{DocumentFragment:a,HTMLTemplateElement:o,Node:l,Element:d,NodeFilter:c,NamedNodeMap:m=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:h,DOMParser:v,trustedTypes:g}=e,u=d.prototype,b=ft(u,"cloneNode"),x=ft(u,"remove"),k=ft(u,"nextSibling"),f=ft(u,"childNodes"),_=ft(u,"parentNode");if(typeof o=="function"){const I=r.createElement("template");I.content&&I.content.ownerDocument&&(r=I.content.ownerDocument)}let A,M="";const{implementation:O,createNodeIterator:D,createDocumentFragment:L,getElementsByTagName:S}=r,{importNode:y}=i;let R=bi();t.isSupported=typeof Ls=="function"&&typeof _=="function"&&O&&O.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:E,ERB_EXPR:H,TMPLIT_EXPR:X,DATA_ATTR:T,ARIA_ATTR:N,IS_SCRIPT_OR_DATA:ce,ATTR_WHITESPACE:pe,CUSTOM_ELEMENT:Me}=_i;let{IS_ALLOWED_URI:Ie}=_i,K=null;const re=z({},[...fi,...yn,...kn,...xn,...gi]);let G=null;const De=z({},[...mi,...wn,...vi,...Nt]);let Y=Object.seal(Fn(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}})),st=null,nn=null;const je=Object.seal(Fn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ur=!0,rn=!0,hr=!1,pr=!0,qe=!1,Ct=!0,Pe=!1,sn=!1,an=!1,Ge=!1,At=!1,Et=!1,fr=!0,gr=!1;const Is="user-content-";let ln=!0,at=!1,Ve={},ve=null;const on=z({},["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 mr=null;const vr=z({},["audio","video","img","source","image","track"]);let cn=null;const _r=z({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Lt="http://www.w3.org/1998/Math/MathML",Rt="http://www.w3.org/2000/svg",we="http://www.w3.org/1999/xhtml";let Ze=we,dn=!1,un=null;const Ds=z({},[Lt,Rt,we],_n);let $t=z({},["mi","mo","mn","ms","mtext"]),Mt=z({},["annotation-xml"]);const Ps=z({},["title","style","font","a","script"]);let lt=null;const Ns=["application/xhtml+xml","text/html"],Os="text/html";let ee=null,Ke=null;const zs=r.createElement("form"),br=function(p){return p instanceof RegExp||p instanceof Function},hn=function(){let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ke&&Ke===p)){if((!p||typeof p!="object")&&(p={}),p=ye(p),lt=Ns.indexOf(p.PARSER_MEDIA_TYPE)===-1?Os:p.PARSER_MEDIA_TYPE,ee=lt==="application/xhtml+xml"?_n:Ft,K=fe(p,"ALLOWED_TAGS")?z({},p.ALLOWED_TAGS,ee):re,G=fe(p,"ALLOWED_ATTR")?z({},p.ALLOWED_ATTR,ee):De,un=fe(p,"ALLOWED_NAMESPACES")?z({},p.ALLOWED_NAMESPACES,_n):Ds,cn=fe(p,"ADD_URI_SAFE_ATTR")?z(ye(_r),p.ADD_URI_SAFE_ATTR,ee):_r,mr=fe(p,"ADD_DATA_URI_TAGS")?z(ye(vr),p.ADD_DATA_URI_TAGS,ee):vr,ve=fe(p,"FORBID_CONTENTS")?z({},p.FORBID_CONTENTS,ee):on,st=fe(p,"FORBID_TAGS")?z({},p.FORBID_TAGS,ee):ye({}),nn=fe(p,"FORBID_ATTR")?z({},p.FORBID_ATTR,ee):ye({}),Ve=fe(p,"USE_PROFILES")?p.USE_PROFILES:!1,ur=p.ALLOW_ARIA_ATTR!==!1,rn=p.ALLOW_DATA_ATTR!==!1,hr=p.ALLOW_UNKNOWN_PROTOCOLS||!1,pr=p.ALLOW_SELF_CLOSE_IN_ATTR!==!1,qe=p.SAFE_FOR_TEMPLATES||!1,Ct=p.SAFE_FOR_XML!==!1,Pe=p.WHOLE_DOCUMENT||!1,Ge=p.RETURN_DOM||!1,At=p.RETURN_DOM_FRAGMENT||!1,Et=p.RETURN_TRUSTED_TYPE||!1,an=p.FORCE_BODY||!1,fr=p.SANITIZE_DOM!==!1,gr=p.SANITIZE_NAMED_PROPS||!1,ln=p.KEEP_CONTENT!==!1,at=p.IN_PLACE||!1,Ie=p.ALLOWED_URI_REGEXP||Rs,Ze=p.NAMESPACE||we,$t=p.MATHML_TEXT_INTEGRATION_POINTS||$t,Mt=p.HTML_INTEGRATION_POINTS||Mt,Y=p.CUSTOM_ELEMENT_HANDLING||{},p.CUSTOM_ELEMENT_HANDLING&&br(p.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Y.tagNameCheck=p.CUSTOM_ELEMENT_HANDLING.tagNameCheck),p.CUSTOM_ELEMENT_HANDLING&&br(p.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Y.attributeNameCheck=p.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),p.CUSTOM_ELEMENT_HANDLING&&typeof p.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Y.allowCustomizedBuiltInElements=p.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),qe&&(rn=!1),At&&(Ge=!0),Ve&&(K=z({},gi),G=[],Ve.html===!0&&(z(K,fi),z(G,mi)),Ve.svg===!0&&(z(K,yn),z(G,wn),z(G,Nt)),Ve.svgFilters===!0&&(z(K,kn),z(G,wn),z(G,Nt)),Ve.mathMl===!0&&(z(K,xn),z(G,vi),z(G,Nt))),p.ADD_TAGS&&(typeof p.ADD_TAGS=="function"?je.tagCheck=p.ADD_TAGS:(K===re&&(K=ye(K)),z(K,p.ADD_TAGS,ee))),p.ADD_ATTR&&(typeof p.ADD_ATTR=="function"?je.attributeCheck=p.ADD_ATTR:(G===De&&(G=ye(G)),z(G,p.ADD_ATTR,ee))),p.ADD_URI_SAFE_ATTR&&z(cn,p.ADD_URI_SAFE_ATTR,ee),p.FORBID_CONTENTS&&(ve===on&&(ve=ye(ve)),z(ve,p.FORBID_CONTENTS,ee)),p.ADD_FORBID_CONTENTS&&(ve===on&&(ve=ye(ve)),z(ve,p.ADD_FORBID_CONTENTS,ee)),ln&&(K["#text"]=!0),Pe&&z(K,["html","head","body"]),K.table&&(z(K,["tbody"]),delete st.tbody),p.TRUSTED_TYPES_POLICY){if(typeof p.TRUSTED_TYPES_POLICY.createHTML!="function")throw pt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof p.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw pt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');A=p.TRUSTED_TYPES_POLICY,M=A.createHTML("")}else A===void 0&&(A=oc(g,s)),A!==null&&typeof M=="string"&&(M=A.createHTML(""));le&&le(p),Ke=p}},yr=z({},[...yn,...kn,...Yo]),kr=z({},[...xn,...Xo]),Us=function(p){let C=_(p);(!C||!C.tagName)&&(C={namespaceURI:Ze,tagName:"template"});const $=Ft(p.tagName),Z=Ft(C.tagName);return un[p.namespaceURI]?p.namespaceURI===Rt?C.namespaceURI===we?$==="svg":C.namespaceURI===Lt?$==="svg"&&(Z==="annotation-xml"||$t[Z]):!!yr[$]:p.namespaceURI===Lt?C.namespaceURI===we?$==="math":C.namespaceURI===Rt?$==="math"&&Mt[Z]:!!kr[$]:p.namespaceURI===we?C.namespaceURI===Rt&&!Mt[Z]||C.namespaceURI===Lt&&!$t[Z]?!1:!kr[$]&&(Ps[$]||!yr[$]):!!(lt==="application/xhtml+xml"&&un[p.namespaceURI]):!1},_e=function(p){ut(t.removed,{element:p});try{_(p).removeChild(p)}catch{x(p)}},Ne=function(p,C){try{ut(t.removed,{attribute:C.getAttributeNode(p),from:C})}catch{ut(t.removed,{attribute:null,from:C})}if(C.removeAttribute(p),p==="is")if(Ge||At)try{_e(C)}catch{}else try{C.setAttribute(p,"")}catch{}},xr=function(p){let C=null,$=null;if(an)p="<remove></remove>"+p;else{const Q=bn(p,/^[\r\n\t ]+/);$=Q&&Q[0]}lt==="application/xhtml+xml"&&Ze===we&&(p='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+p+"</body></html>");const Z=A?A.createHTML(p):p;if(Ze===we)try{C=new v().parseFromString(Z,lt)}catch{}if(!C||!C.documentElement){C=O.createDocument(Ze,"template",null);try{C.documentElement.innerHTML=dn?M:Z}catch{}}const ie=C.body||C.documentElement;return p&&$&&ie.insertBefore(r.createTextNode($),ie.childNodes[0]||null),Ze===we?S.call(C,Pe?"html":"body")[0]:Pe?C.documentElement:ie},wr=function(p){return D.call(p.ownerDocument||p,p,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},pn=function(p){return p instanceof h&&(typeof p.nodeName!="string"||typeof p.textContent!="string"||typeof p.removeChild!="function"||!(p.attributes instanceof m)||typeof p.removeAttribute!="function"||typeof p.setAttribute!="function"||typeof p.namespaceURI!="string"||typeof p.insertBefore!="function"||typeof p.hasChildNodes!="function")},Sr=function(p){return typeof l=="function"&&p instanceof l};function Se(I,p,C){Pt(I,$=>{$.call(t,p,C,Ke)})}const Tr=function(p){let C=null;if(Se(R.beforeSanitizeElements,p,null),pn(p))return _e(p),!0;const $=ee(p.nodeName);if(Se(R.uponSanitizeElement,p,{tagName:$,allowedTags:K}),Ct&&p.hasChildNodes()&&!Sr(p.firstElementChild)&&se(/<[/\w!]/g,p.innerHTML)&&se(/<[/\w!]/g,p.textContent)||p.nodeType===gt.progressingInstruction||Ct&&p.nodeType===gt.comment&&se(/<[/\w]/g,p.data))return _e(p),!0;if(!(je.tagCheck instanceof Function&&je.tagCheck($))&&(!K[$]||st[$])){if(!st[$]&&Ar($)&&(Y.tagNameCheck instanceof RegExp&&se(Y.tagNameCheck,$)||Y.tagNameCheck instanceof Function&&Y.tagNameCheck($)))return!1;if(ln&&!ve[$]){const Z=_(p)||p.parentNode,ie=f(p)||p.childNodes;if(ie&&Z){const Q=ie.length;for(let de=Q-1;de>=0;--de){const Te=b(ie[de],!0);Te.__removalCount=(p.__removalCount||0)+1,Z.insertBefore(Te,k(p))}}}return _e(p),!0}return p instanceof d&&!Us(p)||($==="noscript"||$==="noembed"||$==="noframes")&&se(/<\/no(script|embed|frames)/i,p.innerHTML)?(_e(p),!0):(qe&&p.nodeType===gt.text&&(C=p.textContent,Pt([E,H,X],Z=>{C=ht(C,Z," ")}),p.textContent!==C&&(ut(t.removed,{element:p.cloneNode()}),p.textContent=C)),Se(R.afterSanitizeElements,p,null),!1)},Cr=function(p,C,$){if(fr&&(C==="id"||C==="name")&&($ in r||$ in zs))return!1;if(!(rn&&!nn[C]&&se(T,C))){if(!(ur&&se(N,C))){if(!(je.attributeCheck instanceof Function&&je.attributeCheck(C,p))){if(!G[C]||nn[C]){if(!(Ar(p)&&(Y.tagNameCheck instanceof RegExp&&se(Y.tagNameCheck,p)||Y.tagNameCheck instanceof Function&&Y.tagNameCheck(p))&&(Y.attributeNameCheck instanceof RegExp&&se(Y.attributeNameCheck,C)||Y.attributeNameCheck instanceof Function&&Y.attributeNameCheck(C,p))||C==="is"&&Y.allowCustomizedBuiltInElements&&(Y.tagNameCheck instanceof RegExp&&se(Y.tagNameCheck,$)||Y.tagNameCheck instanceof Function&&Y.tagNameCheck($))))return!1}else if(!cn[C]){if(!se(Ie,ht($,pe,""))){if(!((C==="src"||C==="xlink:href"||C==="href")&&p!=="script"&&Vo($,"data:")===0&&mr[p])){if(!(hr&&!se(ce,ht($,pe,"")))){if($)return!1}}}}}}}return!0},Ar=function(p){return p!=="annotation-xml"&&bn(p,Me)},Er=function(p){Se(R.beforeSanitizeAttributes,p,null);const{attributes:C}=p;if(!C||pn(p))return;const $={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:G,forceKeepAttr:void 0};let Z=C.length;for(;Z--;){const ie=C[Z],{name:Q,namespaceURI:de,value:Te}=ie,Je=ee(Q),fn=Te;let te=Q==="value"?fn:Zo(fn);if($.attrName=Je,$.attrValue=te,$.keepAttr=!0,$.forceKeepAttr=void 0,Se(R.uponSanitizeAttribute,p,$),te=$.attrValue,gr&&(Je==="id"||Je==="name")&&(Ne(Q,p),te=Is+te),Ct&&se(/((--!?|])>)|<\/(style|title|textarea)/i,te)){Ne(Q,p);continue}if(Je==="attributename"&&bn(te,"href")){Ne(Q,p);continue}if($.forceKeepAttr)continue;if(!$.keepAttr){Ne(Q,p);continue}if(!pr&&se(/\/>/i,te)){Ne(Q,p);continue}qe&&Pt([E,H,X],Rr=>{te=ht(te,Rr," ")});const Lr=ee(p.nodeName);if(!Cr(Lr,Je,te)){Ne(Q,p);continue}if(A&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!de)switch(g.getAttributeType(Lr,Je)){case"TrustedHTML":{te=A.createHTML(te);break}case"TrustedScriptURL":{te=A.createScriptURL(te);break}}if(te!==fn)try{de?p.setAttributeNS(de,Q,te):p.setAttribute(Q,te),pn(p)?_e(p):pi(t.removed)}catch{Ne(Q,p)}}Se(R.afterSanitizeAttributes,p,null)},Bs=function I(p){let C=null;const $=wr(p);for(Se(R.beforeSanitizeShadowDOM,p,null);C=$.nextNode();)Se(R.uponSanitizeShadowNode,C,null),Tr(C),Er(C),C.content instanceof a&&I(C.content);Se(R.afterSanitizeShadowDOM,p,null)};return t.sanitize=function(I){let p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},C=null,$=null,Z=null,ie=null;if(dn=!I,dn&&(I="<!-->"),typeof I!="string"&&!Sr(I))if(typeof I.toString=="function"){if(I=I.toString(),typeof I!="string")throw pt("dirty is not a string, aborting")}else throw pt("toString is not a function");if(!t.isSupported)return I;if(sn||hn(p),t.removed=[],typeof I=="string"&&(at=!1),at){if(I.nodeName){const Te=ee(I.nodeName);if(!K[Te]||st[Te])throw pt("root node is forbidden and cannot be sanitized in-place")}}else if(I instanceof l)C=xr("<!---->"),$=C.ownerDocument.importNode(I,!0),$.nodeType===gt.element&&$.nodeName==="BODY"||$.nodeName==="HTML"?C=$:C.appendChild($);else{if(!Ge&&!qe&&!Pe&&I.indexOf("<")===-1)return A&&Et?A.createHTML(I):I;if(C=xr(I),!C)return Ge?null:Et?M:""}C&&an&&_e(C.firstChild);const Q=wr(at?I:C);for(;Z=Q.nextNode();)Tr(Z),Er(Z),Z.content instanceof a&&Bs(Z.content);if(at)return I;if(Ge){if(At)for(ie=L.call(C.ownerDocument);C.firstChild;)ie.appendChild(C.firstChild);else ie=C;return(G.shadowroot||G.shadowrootmode)&&(ie=y.call(i,ie,!0)),ie}let de=Pe?C.outerHTML:C.innerHTML;return Pe&&K["!doctype"]&&C.ownerDocument&&C.ownerDocument.doctype&&C.ownerDocument.doctype.name&&se($s,C.ownerDocument.doctype.name)&&(de="<!DOCTYPE "+C.ownerDocument.doctype.name+`>
|
|
64
|
+
`+de),qe&&Pt([E,H,X],Te=>{de=ht(de,Te," ")}),A&&Et?A.createHTML(de):de},t.setConfig=function(){let I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};hn(I),sn=!0},t.clearConfig=function(){Ke=null,sn=!1},t.isValidAttribute=function(I,p,C){Ke||hn({});const $=ee(I),Z=ee(p);return Cr($,Z,C)},t.addHook=function(I,p){typeof p=="function"&&ut(R[I],p)},t.removeHook=function(I,p){if(p!==void 0){const C=qo(R[I],p);return C===-1?void 0:Go(R[I],C,1)[0]}return pi(R[I])},t.removeHooks=function(I){R[I]=[]},t.removeAllHooks=function(){R=bi()},t}var cc=Ms();function Xe({content:e,className:t,style:r}){if(!e)return null;const i=j.parse(e,{breaks:!0,gfm:!0}),s=cc.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:s}})}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 dc(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 yi(e){return Yt[dc(e)%Yt.length]}function uc(e){return typeof e.durationSeconds=="number"?e.durationSeconds:Math.max(0,Math.round((Date.now()-new Date(e.startedAt).getTime())/1e3))}function ki(e){const t=uc(e);if(t<60)return`${t}s`;const r=Math.floor(t/60),i=t%60;return`${r}m ${i}s`}function mt(e){return e==="completed"?"completed":e==="cancelled"||e==="failed"||e==="timeout"?"failed":e==="pending"?"pending":"running"}function hc(e){return e?new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"--:--"}function xi(e){return e==="completed"?n(Re,{size:20}):e==="cancelled"?n(rt,{size:20}):e==="failed"||e==="timeout"?n(rt,{size:20}):n(ue,{size:20})}function pc(){const[e,t]=w([]),[r,i]=w(0),[s,a]=w(!0),[o,l]=w(0),[d,c]=w(new Set),[m]=w(()=>Yt[Math.floor(Math.random()*Yt.length)]),h=10;W(()=>{v();const f=setInterval(v,3e3);return()=>clearInterval(f)},[]);async function v(){try{const[f,_]=await Promise.all([Sl(),tr().catch(()=>null)]);t(f.agents??[]),_&&i(_.today.totalCost)}catch{}finally{a(!1)}}async function g(f){if(!d.has(f)){c(_=>new Set(_).add(f));try{await Tl(f),await v()}catch{}finally{c(_=>{const A=new Set(_);return A.delete(f),A})}}}const u=Ce(()=>{const f=new Map;for(const _ of e){if(!_.parentTaskId)continue;const A=f.get(_.parentTaskId)??[];A.push(_),f.set(_.parentTaskId,A)}return f},[e]),b=Ce(()=>e.filter(f=>!f.parentTaskId),[e]),x=Ce(()=>{const f=o*h;return b.slice(f,f+h)},[b,o]);W(()=>{const f=Math.max(0,Math.ceil(b.length/h)-1);o>f&&l(f)},[b.length,o]);const k=Ce(()=>{const f=b.filter(M=>mt(M.status)==="running").length,_=b.filter(M=>mt(M.status)==="completed").length,A=b.filter(M=>mt(M.status)==="failed").length;return{running:f,completed:_,failed:A,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"]})]})]}),s&&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(Xn,{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(rt,{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(Ue,{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"})]})]})]}),x.map(f=>{const _=u.get(f.id)??[],A=f.liveOutput||f.outputPreview,M=mt(f.status),O=M==="running",D=yi(f.id);return n("div",{class:`coding-task-card ${M}`,style:{"--card-accent":D.color,"--card-accent-soft":D.soft},children:[n("div",{class:"coding-task-main",children:[n("div",{class:`coding-task-icon ${M}`,children:xi(f.status)}),n("div",{class:"coding-task-content",children:[n("div",{class:"coding-task-pills",children:[n("span",{class:"coding-pill id",children:f.id}),n("span",{class:"coding-pill",children:["TEAM (",_.length,")"]}),n("span",{class:`coding-pill status ${M}`,children:f.status})]}),n("div",{class:"coding-task-title",children:f.task}),n("div",{class:"coding-task-submeta",children:[f.model&&n("span",{children:f.model}),n("span",{children:"•"}),n("span",{children:[n(Fe,{size:13})," ",ki(f)]}),n("span",{children:"•"}),n("span",{class:"coding-pill",children:[f.totalCost!=null?`$${f.totalCost.toFixed(2)}`:"$--"," · ",f.inputTokens!=null||f.outputTokens!=null?`${((f.inputTokens??0)+(f.outputTokens??0)).toLocaleString()} tok`:"-- tok"]}),n("span",{children:hc(f.startedAt)})]})]}),O?n("button",{class:`coding-task-action ${M}`,type:"button",disabled:d.has(f.id),onClick:()=>{g(f.id)},children:d.has(f.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(Bt,{size:14})," Subagents (",_.length,")"]}),n("div",{class:"coding-subagents-list",children:_.map(L=>{const S=mt(L.status),y=yi(L.id),R=L.liveOutput||L.outputPreview;return n("details",{class:`coding-subagent-card ${S}`,style:{"--card-accent":y.color,"--card-accent-soft":y.soft},open:L.status==="running"||L.status==="validating",children:[n("summary",{class:"coding-subagent-header",children:[n("span",{class:"coding-subagent-chevron",children:n(Bt,{size:13})}),n("span",{class:`coding-subagent-icon ${S}`,children:xi(L.status)}),n("span",{class:"audit-id",children:L.id}),n("span",{class:`ca-status-badge ${L.status}`,children:L.status}),L.wave!=null&&n("span",{class:"coding-pill",children:["Wave ",L.wave+1]}),L.retryCount?n("span",{class:"coding-pill",style:{color:"#d4a03c"},children:["retry #",L.retryCount]}):null,n("span",{class:"coding-pill",children:L.totalCost!=null?`$${L.totalCost.toFixed(2)}`:"$--"}),n("span",{class:"coding-subagent-time",children:[n(Fe,{size:12})," ",ki(L)]}),L.status==="running"||L.status==="validating"?n("button",{class:`coding-task-action ${S}`,type:"button",disabled:d.has(L.id),onClick:E=>{E.preventDefault(),g(L.id)},style:{marginLeft:"auto",fontSize:"11px",padding:"2px 8px"},children:d.has(L.id)?"…":"Cancel"}):null]}),n("div",{class:"coding-subagent-body",children:[n("div",{class:"coding-subagent-task",children:L.subtask||L.task}),R?n(Xe,{content:R,className:`ca-output markdown-content ca-subagent-output${L.error?" ca-error":""}`}):null,!R&&L.error?n("div",{class:"ca-output ca-error",style:{fontSize:"12px",padding:"8px",whiteSpace:"pre-wrap"},children:L.error}):null,L.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:L.validationOutput.slice(0,2e3)})]}):null]})]},L.id)})})]}),n("details",{class:"coding-output",children:[n("summary",{children:[n(Bt,{size:14})," Live output"]}),A?n(Xe,{content:A,className:`ca-output markdown-content${f.error?" ca-error":""}`}):null,!A&&f.error?n(Xe,{content:f.error,className:"ca-output markdown-content ca-error"}):null,!A&&!f.error&&f.synthesisResult?n(Xe,{content:f.synthesisResult,className:"ca-output markdown-content"}):null]})]},f.id)}),b.length>h&&n("div",{style:{display:"flex",justifyContent:"center",gap:"8px",padding:"12px"},children:[n("button",{class:"btn btn-sm",disabled:o===0,onClick:()=>l(f=>Math.max(0,f-1)),children:"Previous"}),n("span",{style:{fontSize:"12px",color:"var(--text-muted)",alignSelf:"center"},children:[o*h+1,"–",Math.min((o+1)*h,b.length)," of ",b.length]}),n("button",{class:"btn btn-sm",disabled:(o+1)*h>=b.length,onClick:()=>l(f=>f+1),children:"Next"})]})]})]})}function wi(e){if(e==null)return e;if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e}function fc(e){if(e.type==="tool_use"&&e.detail!=null){const t=wi(e.detail);if(t!==null&&typeof t=="object"&&!Array.isArray(t)){const r=t,i=r.tool||r.name||r.toolName||"",s=r.tool!=null?"tool":r.name!=null?"name":r.toolName!=null?"toolName":"",o=Object.entries(r).filter(([l])=>l!==s).map(([l,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`${l}: ${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=wi(e.detail);return typeof t=="string"?t:JSON.stringify(t).slice(0,80)}return""}function gc(e){return e===void 0?"":e>=1e3?`${(e/1e3).toFixed(1)}s`:`${Math.round(e)}ms`}function mc(){const[e,t]=w([]),[r,i]=w(0),[s,a]=w(0),[o,l]=w(""),[d,c]=w(""),[m,h]=w("all"),[v,g]=w(!0),[u,b]=w(new Set),x=20;W(()=>{a(0)},[d]),W(()=>{k()},[s,d]),W(()=>{const y=Math.max(0,Math.ceil(r/x)-1);s>y&&a(y)},[s,r]);async function k(){g(!0);try{const y=await us({limit:x,offset:s*x,trigger:d||void 0});t(y.traces??[]),i(y.total??0)}catch(y){console.error("[audit] load failed",y)}finally{g(!1)}}function f(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 A=o.trim().toLowerCase(),M=e.filter(y=>m!=="all"&&y.status!==m?!1:A?y.trigger.toLowerCase().includes(A)||y.traceId.toLowerCase().includes(A)||y.events.some(E=>`${E.type} ${E.summary}`.toLowerCase().includes(A)):!0),O=e.filter(y=>{const R=new Date(y.startedAt),E=new Date;return R.getFullYear()===E.getFullYear()&&R.getMonth()===E.getMonth()&&R.getDate()===E.getDate()}).length;function D(y){var R;return((R=y.events.find(E=>E.summary.trim()))==null?void 0:R.summary)??`${y.events.length} events`}function L(y){b(R=>{const E=new Set(R);return E.has(y)?E.delete(y):E.add(y),E})}function S(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:[O," 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(ne,{children:[n("div",{class:"audit-filters-row",children:[n("label",{class:"audit-search",children:[n(In,{size:14}),n("input",{value:o,onInput:y=>l(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=>h(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(In,{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${S(y)?" audit-card-expandable":""}`,children:[n("div",{class:"audit-card-head",...S(y)?{role:"button",tabIndex:0,"aria-expanded":u.has(y.traceId),"aria-label":`Toggle details for trace ${y.traceId.slice(0,8)}`,onClick:()=>L(y.traceId),onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),L(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:f(y)}),S(y)&&n("span",{class:"audit-expand-icon",children:u.has(y.traceId)?n(Bt,{size:12}):n(Ha,{size:12})})]})]}),n("div",{class:"audit-title-line",children:D(y)}),y.events.length>0&&n("div",{class:"audit-event-pills",children:y.events.slice(0,4).map((E,H)=>n("span",{class:"audit-chip soft",children:[E.type,E.durationMs!==void 0?` ${E.durationMs}ms`:""]},`${y.traceId}-${H}`))}),u.has(y.traceId)&&S(y)&&n("div",{class:"audit-detail-section",children:y.events.map((E,H)=>n("div",{class:"audit-event-row",children:[n("span",{class:`audit-event-type-label${E.type==="tool_use"?" tool":""}`,children:E.type}),n("span",{class:`audit-event-content${E.type==="tool_use"?" mono":""}`,children:fc(E)}),n("span",{class:"audit-event-dur",children:gc(E.durationMs)})]},`${y.traceId}-detail-${H}`))})]})]},y.traceId))}),r>x&&n("div",{style:{display:"flex",justifyContent:"center",gap:"8px",padding:"12px"},children:[n("button",{class:"btn btn-sm",disabled:s===0||v,onClick:()=>a(y=>Math.max(0,y-1)),children:"Previous"}),n("span",{style:{fontSize:"12px",color:"var(--text-muted)",alignSelf:"center"},children:[r===0?0:s*x+1,"–",Math.min((s+1)*x,r)," of ",r]}),n("button",{class:"btn btn-sm",disabled:(s+1)*x>=r||v,onClick:()=>a(y=>y+1),children:"Next"})]})]})]})}function vc(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),s=r%60;return`${i}m ${s.toString().padStart(2,"0")}s`}function Si(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 _c(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(),s=Math.floor(i/1e3),a=s<60?`${s}s`:`${Math.floor(s/60)}m ${s%60}s`;return`${r} by ${t} · ${a} after request`}return`${r} by ${t}`}function Ti(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 Ci(e){var r;const t=(r=e.channelMeta)==null?void 0:r.channel;return t==="telegram"||t==="discord"?n(nt,{size:12}):t==="dashboard"?n(nt,{size:12}):n(Xn,{size:12})}function Ai(e){return e?e.replace(/^\/Users\/[^/]+/,"~"):""}function Ei(e){return e===1?"tier-1":e===2?"tier-2":"tier-3"}function bc({showToast:e,onCountChange:t}){const[r,i]=w([]),[s,a]=w([]),[o,l]=w(!0),[d,c]=w(new Set),[m,h]=w(null),v=Le(0),[,g]=w(0);W(()=>{u(),b();const f=setInterval(u,5e3),_=setInterval(()=>{v.current++,g(v.current)},1e3);return()=>{clearInterval(f),clearInterval(_)}},[]);async function u(){var f;try{const _=await hs();i(_.pending??[]),a((_.recent??[]).filter(A=>A.status!=="pending")),t==null||t(((f=_.pending)==null?void 0:f.length)??0)}catch{}finally{l(!1)}}async function b(){var f,_,A,M,O,D,L,S;try{const y=(await er()).config,R=(A=(_=(f=y.channels)==null?void 0:f.telegram)==null?void 0:_.tools)==null?void 0:A.execApproval,E=(D=(O=(M=y.channels)==null?void 0:M.discord)==null?void 0:O.tools)==null?void 0:D.execApproval,H=(S=(L=y.heartbeat)==null?void 0:L.tools)==null?void 0:S.execApproval,X=R||E||H||{},T=Array.isArray(X.requireForTiers)&&X.requireForTiers.length>0?X.requireForTiers:[2,3];h({enabled:X.enabled!==!1,ttlMs:Number(X.ttlMs)>0?Number(X.ttlMs):3e5,tiers:T})}catch{h(null)}}async function x(f,_){c(A=>new Set([...A,f]));try{_?(await ps(f),e("Command approved","success")):(await fs(f),e("Command denied","warning")),await u()}catch{e("Action failed","error")}finally{c(A=>{const M=new Set(A);return M.delete(f),M})}}function k(f){return f==="approved"?n(Re,{size:18}):f==="denied"?n(rt,{size:18}):f==="expired"?n(Qr,{size:18}):n(Dn,{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(ne,{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(f=>`T${f}`).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(ls,{size:18})}),n("div",{class:"empty-state-text",children:"No pending approvals"})]}):n("div",{class:"appr-list",children:r.map(f=>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(Dn,{size:18})}),n("span",{class:"appr-item-id",children:["req-",f.id]}),n("span",{class:`appr-chip tier ${Ei(f.tier)}`,children:["TIER ",f.tier]}),n("span",{class:"appr-chip pending",children:"PENDING"}),n("span",{class:"appr-elapsed",children:[n(Qr,{size:12})," ",vc(f.createdAt)]}),n("div",{style:{flex:1}}),n("div",{class:"appr-actions",children:[n("button",{class:"approval-btn-deny",disabled:d.has(f.id),onClick:()=>x(f.id,!1),children:"Deny"}),n("button",{class:"approval-btn-approve",disabled:d.has(f.id),onClick:()=>x(f.id,!0),children:[n(Re,{size:14})," Approve"]})]})]}),n("div",{class:"appr-reason",children:f.reason}),n("div",{class:"appr-cmd-block",children:f.command}),n("div",{class:"appr-footer",children:[n("span",{class:"appr-footer-item",children:[Ci(f)," via ",Ti(f)]}),f.cwd&&n("span",{class:"appr-footer-sep",children:"·"}),f.cwd&&n("span",{class:"appr-footer-item",children:Ai(f.cwd)}),n("span",{class:"appr-footer-sep",children:"·"}),n("span",{class:"appr-footer-item",children:Si(f.createdAt)})]})]})]},f.id))}),s.length>0&&n(ne,{children:[n("div",{class:"appr-section-label",style:{marginTop:32},children:"RECENT HISTORY"}),n("div",{class:"appr-list",children:s.slice(0,30).map(f=>n("div",{class:`appr-item ${f.status}`,children:[n("div",{class:`appr-item-border ${f.status}`}),n("div",{class:"appr-item-body",children:[n("div",{class:"appr-item-head",children:[n("div",{class:`appr-item-icon ${f.status}`,children:k(f.status)}),n("span",{class:"appr-item-id",children:["req-",f.id]}),n("span",{class:`appr-chip tier ${Ei(f.tier)}`,children:["TIER ",f.tier]}),n("span",{class:`appr-chip ${f.status}`,children:f.status.toUpperCase()})]}),n("div",{class:"appr-reason",children:f.reason}),n("div",{class:"appr-cmd-block",children:f.command}),n("div",{class:"appr-footer",children:[n("span",{class:"appr-footer-item",children:[Ci(f)," via ",Ti(f)]}),f.cwd&&n("span",{class:"appr-footer-sep",children:"·"}),f.cwd&&n("span",{class:"appr-footer-item",children:Ai(f.cwd)}),n("span",{class:"appr-footer-sep",children:"·"}),n("span",{class:"appr-footer-item",children:Si(f.createdAt)}),n("span",{class:"appr-footer-sep",children:"·"}),n("span",{class:"appr-footer-resolution",children:_c(f)})]})]})]},f.id))})]})]})]})}const Li="main";function yc(){const[e,t]=w([]),[r,i]=w(null),[s,a]=w(""),[o,l]=w(!0),[d,c]=w(!1);W(()=>{m()},[]);async function m(){l(!0);try{const v=await vl(Li);t(v.files??[])}catch(v){console.error("[memory] load failed",v)}finally{l(!1)}}async function h(v){i(v),c(!0);try{const g=await _l(Li,v);a(g.content??"")}catch(g){console.error("[memory] file load failed",g),a("")}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($n,{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:()=>h(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:s})})}):n("div",{class:"templates-empty",children:[n($n,{size:32}),n("p",{children:"Select a file to view"})]})})]})]})}const kc=/^[A-Za-z0-9._-]+\/[A-Za-z0-9._/-]+$/,xc=/^[A-Za-z0-9.-]+$/,wc=/^[A-Za-z0-9._/-]+$/;function Sc(e,t){return t[e]?{ok:!0}:kc.test(e)?{ok:!0}:xc.test(e)&&/[-.]/.test(e)?{ok:!0}:!wc.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 Tc({showToast:e}){const[t,r]=w(""),[i,s]=w(""),[a,o]=w({}),[l,d]=w(!0),[c,m]=w(!1);W(()=>{h()},[]);async function h(){d(!0);try{const g=await gl();r(g.current??""),s(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=Sc(g,a);if(!u.ok){e(u.error,"error");return}m(!0);try{const b=await ml(g);r(b.model),s(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"})}),l?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=>s(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(a).sort(([g],[u])=>g.localeCompare(u)).map(([g,u])=>n("button",{class:`btn btn-sm${i===g?" btn-primary":""}`,onClick:()=>s(g),title:u,children:g},g))}),n("button",{class:"btn btn-primary",onClick:v,disabled:c||!i.trim(),children:c?"Saving…":"Switch Model"})]})]})})]})}function Cc(){const[e,t]=w([]),[r,i]=w(null),[s,a]=w(""),[o,l]=w(!0),[d,c]=w(!1);W(()=>{m()},[]);async function m(){l(!0);try{const v=await xl();t(v.files??[])}catch(v){console.error("[logs] load failed",v)}finally{l(!1)}}async function h(v){i(v),c(!0);try{const g=await wl(`logs/${encodeURIComponent(v.name)}`);a(g.content??"")}catch(g){console.error("[logs] file load failed",g),a("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(Vt,{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:()=>h(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:s.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 Ac(e){var o,l,d,c,m,h,v,g;const t=(d=(l=(o=e.channels)==null?void 0:o.telegram)==null?void 0:l.tools)==null?void 0:d.execApproval,r=(h=(m=(c=e.channels)==null?void 0:c.discord)==null?void 0:m.tools)==null?void 0:h.execApproval,i=(g=(v=e.heartbeat)==null?void 0:v.tools)==null?void 0:g.execApproval,s=t||r||i||{},a=Array.isArray(s.requireForTiers)&&s.requireForTiers.length>0?s.requireForTiers:[2,3];return{enabled:s.enabled!==!1,ttlMs:Number(s.ttlMs)>0?Number(s.ttlMs):3e5,requireForTiers:a}}function Ec({showToast:e}){const[t,r]=w(null),[i,s]=w(!0),[a,o]=w(!1),[l,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});W(()=>{h()},[]);async function h(){var u,b,x,k,f,_,A,M,O,D,L,S,y;s(!0);try{const E=(await er()).config??{},H=Ac(E);r(E),m({gatewayHost:((u=E.gateway)==null?void 0:u.host)??"127.0.0.1",gatewayPort:String(((b=E.gateway)==null?void 0:b.port)??18790),gatewayMode:((x=E.gateway)==null?void 0:x.mode)==="remote"?"remote":"local",activeChannel:((k=E.channels)==null?void 0:k.active)==="telegram"||((f=E.channels)==null?void 0:f.active)==="discord"?E.channels.active:"",telegramEnabled:!!((A=(_=E.channels)==null?void 0:_.telegram)!=null&&A.enabled),discordEnabled:!!((O=(M=E.channels)==null?void 0:M.discord)!=null&&O.enabled),agentsDefault:((D=E.agents)==null?void 0:D.default)??"main",heartbeatIntervalMs:String(((L=E.heartbeat)==null?void 0:L.intervalMs)??3e5),heartbeatPrompt:((S=E.heartbeat)==null?void 0:S.prompt)??"",heartbeatModel:((y=E.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{s(!1)}}async function v(){d(!0);try{await Ll(),e("Config reloaded","success"),await h()}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 x={enabled:c.execApprovalEnabled,ttlMs:Number(c.execApprovalTtlMs)||3e5,requireForTiers:b};u.channels.telegram.tools.execApproval=x,u.channels.discord.tools.execApproval=x,u.heartbeat.tools.execApproval=x,o(!0);try{await gs(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:l,children:l?"Reloading…":"Reload"}),n("button",{class:"btn btn-sm btn-primary",onClick:()=>void g(),disabled:a,children:a?"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 Lc(){var g;const[e,t]=w([]),[r,i]=w(null),[s,a]=w(null),[o,l]=w(!0),[d,c]=w(!1);W(()=>{m()},[]);async function m(){l(!0);try{const u=await Rl();t(u.digests??[])}finally{l(!1)}}async function h(u){i(u),c(!0);try{const b=await $l(u);a(b)}catch{a(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(Mn,{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 h(u.id),class:`templates-list-item${r===u.id?" active":""}`,children:[n("div",{class:"templates-list-icon",children:n(Mn,{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"})}):s?n("div",{children:[n("div",{class:"digest-header",children:[n("div",{class:"digest-title",children:s.jobName}),n("div",{class:"digest-meta",children:v(s.createdAt)})]}),s.summary&&s.summary.trim().length>0&&n(Xe,{content:s.summary,className:"digest-reader markdown-content",style:{marginBottom:12}}),((g=s.articles)==null?void 0:g.length)>0?n("div",{class:"digest-articles",children:s.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(Ga,{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(Xe,{content:u.summary,className:"markdown-content",style:{fontSize:13,color:"var(--text-dim)",marginTop:8}})]},u.id))}):s.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 Rc({showToast:e}){const[t,r]=w([]),[i,s]=w(null),[a,o]=w(null),[l,d]=w(!0),[c,m]=w(!1),[h,v]=w(""),[g,u]=w(""),[b,x]=w(!1),[k,f]=w(!1),[_,A]=w("raw"),[M,O]=w(!1),[D,L]=w("");W(()=>{S()},[]);async function S(){d(!0);try{const T=await Ml();r(T.skills??[])}catch{e("Failed to load skills","error")}finally{d(!1)}}async function y(T){s(T),A("markdown"),m(!0);try{const N=await Il(T);o(N),L(N.rawContent||N.body||""),O(!1)}catch{e("Failed to load skill details","error"),o(null)}finally{m(!1)}}async function R(){if(a){f(!0);try{await Nl(a.name,D),e("Skill updated","success"),await y(a.name)}catch{e("Failed to update skill","error")}finally{f(!1)}}}async function E(T){if(T.enabled!==void 0)try{await Pl(T.name,!T.enabled),e(`Skill ${T.name} ${T.enabled?"disabled":"enabled"}`,"success"),await S(),i===T.name&&await y(T.name)}catch{e("Failed to update skill","error")}}async function H(T){if(window.confirm(`Delete skill "${T}"? This action cannot be undone.`)){r(ce=>ce.filter(pe=>pe.name!==T)),i===T&&(s(null),o(null));try{await Ol(T),e(`Deleted ${T}`,"warning"),await S()}catch{e("Failed to delete skill","error"),await S()}}}async function X(){const T=h.trim();if(!(!T||!g.trim())){f(!0);try{await Dl(T,g),e("Skill created","success"),v(""),u(""),x(!1),await S(),await y(T)}catch{e("Failed to create skill","error")}finally{f(!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:()=>x(T=>!T),children:b?"Close":"New"}),n("button",{class:"btn-refresh",onClick:S,children:[n(ue,{size:14})," Refresh"]})]})]}),l?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(Pn,{size:18})}),n("div",{class:"empty-state-text",children:"No skills found"})]}):n("div",{class:"skills-grid",style:{marginBottom:14},children:t.map(T=>n("div",{class:"skill-card",children:[n("div",{class:"skill-header",children:[n("div",{class:"skill-name",children:T.name}),n("div",{title:T.eligible?"Eligible":T.reason||"Ineligible",children:T.eligible===!1?n(ja,{size:16,color:"var(--error)"}):n(ls,{size:16,color:"var(--success)"})})]}),n("div",{class:"skill-desc",children:T.description||"No description"}),T.tags&&T.tags.length>0&&n("div",{class:"skill-tags",children:T.tags.slice(0,4).map(N=>n("span",{class:"skill-tag",children:N},N))}),n("div",{style:{display:"flex",gap:8,marginTop:10},children:[n("button",{class:"btn btn-sm",onClick:()=>void y(T.name),children:"View"}),n("button",{class:"btn btn-sm",disabled:!0,title:"Coming soon",onClick:()=>void E(T),children:T.enabled?"Disable":"Enable"}),n("button",{class:"btn btn-sm btn-danger",onClick:()=>void H(T.name),children:"Delete"})]})]},T.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:h,onInput:T=>v(T.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:T=>u(T.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||!h.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"})}):a?n(ne,{children:[n("div",{class:"audit-header",children:[n("div",{style:{fontWeight:700},children:a.name}),n("div",{style:{display:"flex",gap:8},children:[n("button",{class:"btn btn-sm",onClick:()=>A(T=>T==="raw"?"markdown":"raw"),children:_==="raw"?"Markdown":"Raw"}),n("button",{class:"btn btn-sm btn-danger",onClick:()=>void H(a.name),children:"Delete"})]})]}),n("div",{class:"audit-summary",style:{marginBottom:8},children:a.description||"No description"}),n("div",{class:"audit-meta",style:{marginBottom:12},children:[n("span",{children:["Eligible: ",a.eligible?"yes":"no"]}),n("span",{children:["Enabled: ",a.enabled?"yes":"no"]}),n("span",{children:["Priority: ",a.priority??100]})]}),M?n(ne,{children:[n("label",{class:"form-field",children:[n("span",{class:"form-label",children:"Edit SKILL.md"}),n("textarea",{value:D,onInput:T=>L(T.target.value),style:{minHeight:280}})]}),n("div",{class:"form-actions",children:[n("button",{class:"btn btn-sm btn-primary",onClick:()=>void R(),disabled:k||!D.trim(),children:k?"Saving…":"Save"}),n("button",{class:"btn btn-sm",onClick:()=>{O(!1),L(a.rawContent||a.body||"")},children:"Cancel"})]})]}):_==="markdown"?n(Qt,{content:a.rawContent||a.body||""}):n("pre",{class:"ca-output",style:{marginTop:0,maxHeight:420},children:a.rawContent||a.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(Pn,{size:18})}),n("div",{class:"empty-state-text",children:"Select a skill to inspect"})]})})]})]})]})}function $c(){var f;const[e,t]=w(null),[r,i]=w(null),[s,a]=w(!0),[o,l]=w(!1);W(()=>{d()},[]);async function d(){a(!0);try{const[_,A]=await Promise.all([ni(),ri()]);t(_),i(A)}catch(_){console.error("[health] load failed",_)}finally{a(!1)}}async function c(){l(!0);try{const[_,A]=await Promise.all([ni(),ri()]);t(_),i(A)}catch(_){console.error("[health] recheck failed",_)}finally{l(!1)}}function m(_){return _==="ok"?"ok":_==="warn"?"warn":"error"}function h(_){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=(((f=r==null?void 0:r.report)==null?void 0:f.checks)??(e==null?void 0:e.checks)??[]).map(_=>v(_)),b=u.filter(_=>_.status==="error").length,x=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||s,children:o?"Checking…":"Recheck"})})]}),s?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(Wa,{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)":x>0?"var(--warning-soft)":"var(--success-soft)",color:b>0?"var(--error)":x>0?"var(--warning)":"var(--success)"},children:b>0?n(rt,{size:16}):x>0?n(ei,{size:16}):n(Re,{size:16})}),n("div",{class:"stat-label",children:"Issues"}),n("div",{class:"stat-value",style:{color:b>0?"var(--error)":x>0?"var(--warning)":"var(--success)"},children:b+x}),n("div",{class:"stat-sub",children:[b," errors, ",x," 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(cs,{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((_,A)=>n("div",{class:"feed-item",children:[n("div",{style:{width:32,height:32,borderRadius:"var(--radius-sm)",background:h(_.status)+"18",color:h(_.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(ei,{size:14}):n(rt,{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:h(_.status),fontWeight:600,fontFamily:"var(--mono)",whiteSpace:"nowrap"},children:_.status})]},A))})})})]}),n("div",{id:"healthEnvVars",style:{display:"none"}}),n("div",{id:"healthFeatures",style:{display:"none"}})]})]})}const Ye="main";function Mc({showToast:e}){const[t,r]=w([]),[i,s]=w(null),[a,o]=w(""),[l,d]=w(""),[c,m]=w(!0),[h,v]=w(!1),[g,u]=w(!1),[b,x]=w("edit");W(()=>{k()},[]);async function k(){m(!0);try{const D=await bl(Ye);r(D.templates??[])}catch(D){console.error("[templates] load failed",D)}finally{m(!1)}}async function f(D){s(D),x(D.toLowerCase().endsWith(".md")?"preview":"edit"),v(!0);try{const S=(await yl(Ye,D)).content??"";o(S),d(S)}catch(L){console.error("[templates] file load failed",L),o(""),d("")}finally{v(!1)}}async function _(){if(i){u(!0);try{await kl(Ye,i,a),d(a),e("Template saved","success")}catch{e("Failed to save template","error")}finally{u(!1)}}}function A(){o(l)}const M=a!==l,O=t.find(D=>D.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(Vt,{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:Ye,disabled:!0,children:n("option",{value:"main",children:"main"})})]}),n("div",{class:"templates-list",children:t.map(D=>n("button",{class:`templates-list-item${i===D.name?" active":""}`,onClick:()=>f(D.name),children:[n("div",{class:"templates-list-icon",children:D.name.substring(0,2).toUpperCase()}),n("div",{class:"templates-list-content",children:[n("div",{class:"templates-list-title",children:D.name}),n("div",{class:"templates-list-meta",children:[Math.round((D.size||0)/1024),"KB"]})]})]},D.name))})]}),n("div",{class:"templates-main",children:i?h?n("div",{class:"templates-loading",children:n("div",{class:"spinner"})}):n(ne,{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:A,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:()=>x("edit"),children:"Edit"}),n("button",{class:`templates-tab${b==="preview"?" active":""}`,onClick:()=>x("preview"),children:"Preview"})]}),O&&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:(O.size||0)>1024?`${Math.round((O.size||0)/1024)}KB`:`${O.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:Ye})]}),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/",Ye,"/",i]})]})]}),n("div",{class:"templates-content",children:b==="preview"?n("div",{class:"templates-markdown-preview",children:n(Qt,{content:a})}):n("textarea",{class:"templates-textarea",value:a,onInput:D=>o(D.target.value),spellcheck:!1})})]}):n("div",{class:"templates-empty",children:[n(Vt,{size:32}),n("p",{children:"Select a template to edit"})]})})]})]})}function vt(e){return e===0?"$0.00":e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function _t(e){return e===0?"0":e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function Ic(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 s=Math.floor(i/60);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}function Dc(){const[e,t]=w(null),[r,i]=w([]),[s,a]=w(0),[o,l]=w(0),[d,c]=w(!0),m=25;W(()=>{h();const x=setInterval(h,3e4);return()=>clearInterval(x)},[o]);async function h(){try{const[x,k]=await Promise.all([tr(),zl({limit:m,offset:o*m})]);t(x),i(k.records??[]),a(k.total??0)}catch(x){console.error("[usage] load failed",x)}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((x,k)=>k[1].cost-x[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:h,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(Ue,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value",children:vt((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(Ue,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value",children:vt((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(Ue,{size:16})}),n("div",{class:"stat-body",children:[n("div",{class:"stat-value",children:vt((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(nt,{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 · ",_t(((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(([x,k])=>n("tr",{children:[n("td",{children:n("code",{class:"usage-model-pill",children:x})}),n("td",{children:k.calls}),n("td",{children:_t(k.inputTokens)}),n("td",{children:_t(k.outputTokens)}),n("td",{class:"usage-cost-cell",children:vt(k.cost)})]},x))})]})})]}),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:[s," total"]})]}),r.length===0?n("div",{class:"empty-state",children:[n("div",{class:"empty-state-icon",children:n(Va,{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(x=>n("div",{class:"feed-item",children:[n("div",{class:`feed-icon ${x.trigger==="telegram"?"telegram":x.trigger==="cron"?"cron":"system"}`,children:n(Ue,{size:14})}),n("div",{children:[n("div",{class:"feed-title",children:[n("code",{class:"usage-model-pill",children:x.model})," ",n("span",{class:"audit-chip trigger muted",children:x.trigger})]}),n("div",{class:"feed-detail",children:[_t(x.inputTokens)," in · ",_t(x.outputTokens)," out · ",vt(x.totalCost)]})]}),n("div",{class:"feed-time",children:Ic(x.timestamp)})]},x.id))}),s>m&&n("div",{style:{display:"flex",justifyContent:"center",gap:"8px",padding:"12px"},children:[n("button",{class:"btn btn-sm",disabled:o===0,onClick:()=>l(x=>Math.max(0,x-1)),children:"Previous"}),n("span",{style:{fontSize:"12px",color:"var(--text-muted)",alignSelf:"center"},children:[o*m+1,"–",Math.min((o+1)*m,s)," of ",s]}),n("button",{class:"btn btn-sm",disabled:(o+1)*m>=s,onClick:()=>l(x=>x+1),children:"Next"})]})]})]})]})}const Pc=["overview","history","cron","memory","model","coding","logs","audit","digests","skills","approvals","health","usage","config","templates"];function Nc(e){return Pc.includes(e)}function Ri(){const e=window.location.hash.replace(/^#/,"").trim();return Nc(e)?e:"overview"}function Oc(){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 zc({onLogin:e,botName:t,botEmoji:r}){const[i,s]=w(""),[a,o]=w("");async function l(){const d=i.trim();if(d)try{if((await fetch("/api/dashboard/status",{headers:{Authorization:`Bearer ${d}`}})).status===401){o("Invalid token");return}ll(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=>{s(d.target.value),o("")},onKeyDown:d=>d.key==="Enter"&&l(),style:{width:"100%",padding:"10px 14px",borderRadius:"var(--radius-sm)",border:`1px solid ${a?"var(--error)":"var(--border)"}`,background:"var(--surface-alt)",color:"var(--text)",fontFamily:"var(--mono)",fontSize:13,marginBottom:12,outline:"none",boxSizing:"border-box"}}),a&&n("div",{style:{fontSize:12,color:"var(--error)",marginBottom:12},children:a}),n("button",{class:"btn btn-primary",style:{width:"100%"},onClick:l,children:"Sign in"})]})})}function Uc(){const e=Oc(),[t,r]=w(!!ds()),[i,s]=w(()=>Ri()),[a,o]=w(()=>window.innerWidth<=980),[l,d]=w(()=>window.innerWidth>980),[c,m]=w(()=>localStorage.getItem("theme")??"light"),[h,v]=w(0),{toasts:g,showToast:u}=al();W(()=>cl(()=>{r(!1)}),[]),W(()=>{document.documentElement.setAttribute("data-theme",c),localStorage.setItem("theme",c)},[c]),W(()=>{function f(){const _=window.innerWidth<=980;o(A=>(A!==_&&d(!_),_))}return window.addEventListener("resize",f),()=>window.removeEventListener("resize",f)},[]),W(()=>{if(!a||!l){document.body.style.overflow="";return}return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[a,l]),W(()=>{const f=()=>{const _=Ri();s(_),a&&d(!1)};return window.location.hash?f():window.location.hash="#overview",window.addEventListener("hashchange",f),()=>window.removeEventListener("hashchange",f)},[a]);function b(){m(f=>f==="light"?"dark":"light")}function x(f){const _=`#${f}`;window.location.hash!==_?window.location.hash=_:s(f),a&&d(!1)}if(!t)return n(zc,{botName:e.name,botEmoji:e.emoji,onLogin:()=>r(!0)});function k(){switch(i){case"overview":return n(si,{onNavigate:x,showToast:u});case"history":return n(Kl,{});case"cron":return n(Yl,{showToast:u});case"usage":return n(Dc,{});case"coding":return n(pc,{});case"audit":return n(mc,{});case"approvals":return n(bc,{showToast:u,onCountChange:v});case"memory":return n(yc,{});case"model":return n(Tc,{showToast:u});case"logs":return n(Cc,{});case"config":return n(Ec,{showToast:u});case"digests":return n(Lc,{});case"skills":return n(Rc,{showToast:u});case"health":return n($c,{});case"templates":return n(Mc,{showToast:u});default:return n(si,{onNavigate:x,showToast:u})}}return n(ne,{children:[n("div",{class:`shell${a?" shell-narrow":""}${a&&l?" sidebar-open":""}`,children:[a&&n("button",{class:"global-sidebar-toggle",onClick:()=>d(!0),"aria-label":"Open sidebar",children:n(Ya,{size:16})}),n(il,{currentPage:i,onNavigate:x,botName:e.name,botEmoji:e.emoji,pendingApprovals:h,isNarrow:a,onClose:()=>d(!1)}),a&&l?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(Xa,{size:16}):n(nl,{size:16})}),k()]})]}),n(sl,{toasts:g})]})}et(n(Uc,{}),document.getElementById("app"));
|