@waiaas/daemon 2.7.0-rc → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -1
- package/dist/api/routes/admin.d.ts +4 -1
- package/dist/api/routes/admin.d.ts.map +1 -1
- package/dist/api/routes/admin.js +30 -2
- package/dist/api/routes/admin.js.map +1 -1
- package/dist/api/routes/openapi-schemas.d.ts +48 -0
- package/dist/api/routes/openapi-schemas.d.ts.map +1 -1
- package/dist/api/routes/openapi-schemas.js +12 -0
- package/dist/api/routes/openapi-schemas.js.map +1 -1
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +2 -0
- package/dist/api/server.js.map +1 -1
- package/dist/infrastructure/adapter-pool.d.ts +54 -1
- package/dist/infrastructure/adapter-pool.d.ts.map +1 -1
- package/dist/infrastructure/adapter-pool.js +98 -1
- package/dist/infrastructure/adapter-pool.js.map +1 -1
- package/dist/infrastructure/settings/hot-reload.d.ts +15 -0
- package/dist/infrastructure/settings/hot-reload.d.ts.map +1 -1
- package/dist/infrastructure/settings/hot-reload.js +102 -0
- package/dist/infrastructure/settings/hot-reload.js.map +1 -1
- package/dist/infrastructure/settings/setting-keys.d.ts +1 -1
- package/dist/infrastructure/settings/setting-keys.d.ts.map +1 -1
- package/dist/infrastructure/settings/setting-keys.js +15 -0
- package/dist/infrastructure/settings/setting-keys.js.map +1 -1
- package/dist/lifecycle/daemon.d.ts +4 -0
- package/dist/lifecycle/daemon.d.ts.map +1 -1
- package/dist/lifecycle/daemon.js +46 -7
- package/dist/lifecycle/daemon.js.map +1 -1
- package/package.json +5 -5
- package/public/admin/assets/{index-B6PE0dLv.css → index-DDqQR5T7.css} +1 -1
- package/public/admin/assets/index-Dh1OYb8d.js +1 -0
- package/public/admin/index.html +2 -2
- package/public/admin/assets/index-C0nLGE6n.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var Mt,ee,Qn,ea,Ue,bn,ta,na,aa,dn,nn,an,vt={},la=[],Ga=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Ut=Array.isArray;function Te(t,n){for(var a in n)t[a]=n[a];return t}function un(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function za(t,n,a){var l,i,s,r={};for(s in n)s=="key"?l=n[s]:s=="ref"?i=n[s]:r[s]=n[s];if(arguments.length>2&&(r.children=arguments.length>3?Mt.call(arguments,2):a),typeof t=="function"&&t.defaultProps!=null)for(s in t.defaultProps)r[s]===void 0&&(r[s]=t.defaultProps[s]);return It(t,r,l,i,null)}function It(t,n,a,l,i){var s={type:t,props:n,key:a,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Qn,__i:-1,__u:0};return i==null&&ee.vnode!=null&&ee.vnode(s),s}function Y(t){return t.children}function ot(t,n){this.props=t,this.context=n}function Ye(t,n){if(n==null)return t.__?Ye(t.__,t.__i+1):null;for(var a;n<t.__k.length;n++)if((a=t.__k[n])!=null&&a.__e!=null)return a.__e;return typeof t.type=="function"?Ye(t):null}function ia(t){var n,a;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,n=0;n<t.__k.length;n++)if((a=t.__k[n])!=null&&a.__e!=null){t.__e=t.__c.base=a.__e;break}return ia(t)}}function wn(t){(!t.__d&&(t.__d=!0)&&Ue.push(t)&&!Ot.__r++||bn!=ee.debounceRendering)&&((bn=ee.debounceRendering)||ta)(Ot)}function Ot(){for(var t,n,a,l,i,s,r,c=1;Ue.length;)Ue.length>c&&Ue.sort(na),t=Ue.shift(),c=Ue.length,t.__d&&(a=void 0,l=void 0,i=(l=(n=t).__v).__e,s=[],r=[],n.__P&&((a=Te({},l)).__v=l.__v+1,ee.vnode&&ee.vnode(a),vn(n.__P,a,l,n.__n,n.__P.namespaceURI,32&l.__u?[i]:null,s,i??Ye(l),!!(32&l.__u),r),a.__v=l.__v,a.__.__k[a.__i]=a,oa(s,a,r),l.__e=l.__=null,a.__e!=i&&ia(a)));Ot.__r=0}function sa(t,n,a,l,i,s,r,c,h,o,v){var u,m,N,M,I,_,D,P=l&&l.__k||la,K=n.length;for(h=qa(a,n,P,h,K),u=0;u<K;u++)(N=a.__k[u])!=null&&(m=N.__i==-1?vt:P[N.__i]||vt,N.__i=u,_=vn(t,N,m,i,s,r,c,h,o,v),M=N.__e,N.ref&&m.ref!=N.ref&&(m.ref&&hn(m.ref,null,N),v.push(N.ref,N.__c||M,N)),I==null&&M!=null&&(I=M),(D=!!(4&N.__u))||m.__k===N.__k?h=ra(N,h,t,D):typeof N.type=="function"&&_!==void 0?h=_:M&&(h=M.nextSibling),N.__u&=-7);return a.__e=I,h}function qa(t,n,a,l,i){var s,r,c,h,o,v=a.length,u=v,m=0;for(t.__k=new Array(i),s=0;s<i;s++)(r=n[s])!=null&&typeof r!="boolean"&&typeof r!="function"?(typeof r=="string"||typeof r=="number"||typeof r=="bigint"||r.constructor==String?r=t.__k[s]=It(null,r,null,null,null):Ut(r)?r=t.__k[s]=It(Y,{children:r},null,null,null):r.constructor===void 0&&r.__b>0?r=t.__k[s]=It(r.type,r.props,r.key,r.ref?r.ref:null,r.__v):t.__k[s]=r,h=s+m,r.__=t,r.__b=t.__b+1,c=null,(o=r.__i=ja(r,a,h,u))!=-1&&(u--,(c=a[o])&&(c.__u|=2)),c==null||c.__v==null?(o==-1&&(i>v?m--:i<v&&m++),typeof r.type!="function"&&(r.__u|=4)):o!=h&&(o==h-1?m--:o==h+1?m++:(o>h?m--:m++,r.__u|=4))):t.__k[s]=null;if(u)for(s=0;s<v;s++)(c=a[s])!=null&&(2&c.__u)==0&&(c.__e==l&&(l=Ye(c)),da(c,c));return l}function ra(t,n,a,l){var i,s;if(typeof t.type=="function"){for(i=t.__k,s=0;i&&s<i.length;s++)i[s]&&(i[s].__=t,n=ra(i[s],n,a,l));return n}t.__e!=n&&(l&&(n&&t.type&&!n.parentNode&&(n=Ye(t)),a.insertBefore(t.__e,n||null)),n=t.__e);do n=n&&n.nextSibling;while(n!=null&&n.nodeType==8);return n}function ja(t,n,a,l){var i,s,r,c=t.key,h=t.type,o=n[a],v=o!=null&&(2&o.__u)==0;if(o===null&&c==null||v&&c==o.key&&h==o.type)return a;if(l>(v?1:0)){for(i=a-1,s=a+1;i>=0||s<n.length;)if((o=n[r=i>=0?i--:s++])!=null&&(2&o.__u)==0&&c==o.key&&h==o.type)return r}return-1}function Sn(t,n,a){n[0]=="-"?t.setProperty(n,a??""):t[n]=a==null?"":typeof a!="number"||Ga.test(n)?a:a+"px"}function St(t,n,a,l,i){var s,r;e:if(n=="style")if(typeof a=="string")t.style.cssText=a;else{if(typeof l=="string"&&(t.style.cssText=l=""),l)for(n in l)a&&n in a||Sn(t.style,n,"");if(a)for(n in a)l&&a[n]==l[n]||Sn(t.style,n,a[n])}else if(n[0]=="o"&&n[1]=="n")s=n!=(n=n.replace(aa,"$1")),r=n.toLowerCase(),n=r in t||n=="onFocusOut"||n=="onFocusIn"?r.slice(2):n.slice(2),t.l||(t.l={}),t.l[n+s]=a,a?l?a.u=l.u:(a.u=dn,t.addEventListener(n,s?an:nn,s)):t.removeEventListener(n,s?an:nn,s);else{if(i=="http://www.w3.org/2000/svg")n=n.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(n!="width"&&n!="height"&&n!="href"&&n!="list"&&n!="form"&&n!="tabIndex"&&n!="download"&&n!="rowSpan"&&n!="colSpan"&&n!="role"&&n!="popover"&&n in t)try{t[n]=a??"";break e}catch{}typeof a=="function"||(a==null||a===!1&&n[4]!="-"?t.removeAttribute(n):t.setAttribute(n,n=="popover"&&a==1?"":a))}}function kn(t){return function(n){if(this.l){var a=this.l[n.type+t];if(n.t==null)n.t=dn++;else if(n.t<a.u)return;return a(ee.event?ee.event(n):n)}}}function vn(t,n,a,l,i,s,r,c,h,o){var v,u,m,N,M,I,_,D,P,K,y,b,U,S,p,g,f,O=n.type;if(n.constructor!==void 0)return null;128&a.__u&&(h=!!(32&a.__u),s=[c=n.__e=a.__e]),(v=ee.__b)&&v(n);e:if(typeof O=="function")try{if(D=n.props,P="prototype"in O&&O.prototype.render,K=(v=O.contextType)&&l[v.__c],y=v?K?K.props.value:v.__:l,a.__c?_=(u=n.__c=a.__c).__=u.__E:(P?n.__c=u=new O(D,y):(n.__c=u=new ot(D,y),u.constructor=O,u.render=Xa),K&&K.sub(u),u.state||(u.state={}),u.__n=l,m=u.__d=!0,u.__h=[],u._sb=[]),P&&u.__s==null&&(u.__s=u.state),P&&O.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=Te({},u.__s)),Te(u.__s,O.getDerivedStateFromProps(D,u.__s))),N=u.props,M=u.state,u.__v=n,m)P&&O.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),P&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(P&&O.getDerivedStateFromProps==null&&D!==N&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(D,y),n.__v==a.__v||!u.__e&&u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(D,u.__s,y)===!1){for(n.__v!=a.__v&&(u.props=D,u.state=u.__s,u.__d=!1),n.__e=a.__e,n.__k=a.__k,n.__k.some(function(W){W&&(W.__=n)}),b=0;b<u._sb.length;b++)u.__h.push(u._sb[b]);u._sb=[],u.__h.length&&r.push(u);break e}u.componentWillUpdate!=null&&u.componentWillUpdate(D,u.__s,y),P&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(N,M,I)})}if(u.context=y,u.props=D,u.__P=t,u.__e=!1,U=ee.__r,S=0,P){for(u.state=u.__s,u.__d=!1,U&&U(n),v=u.render(u.props,u.state,u.context),p=0;p<u._sb.length;p++)u.__h.push(u._sb[p]);u._sb=[]}else do u.__d=!1,U&&U(n),v=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++S<25);u.state=u.__s,u.getChildContext!=null&&(l=Te(Te({},l),u.getChildContext())),P&&!m&&u.getSnapshotBeforeUpdate!=null&&(I=u.getSnapshotBeforeUpdate(N,M)),g=v,v!=null&&v.type===Y&&v.key==null&&(g=ca(v.props.children)),c=sa(t,Ut(g)?g:[g],n,a,l,i,s,r,c,h,o),u.base=n.__e,n.__u&=-161,u.__h.length&&r.push(u),_&&(u.__E=u.__=null)}catch(W){if(n.__v=null,h||s!=null)if(W.then){for(n.__u|=h?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;s[s.indexOf(c)]=null,n.__e=c}else{for(f=s.length;f--;)un(s[f]);ln(n)}else n.__e=a.__e,n.__k=a.__k,W.then||ln(n);ee.__e(W,n,a)}else s==null&&n.__v==a.__v?(n.__k=a.__k,n.__e=a.__e):c=n.__e=Ya(a.__e,n,a,l,i,s,r,h,o);return(v=ee.diffed)&&v(n),128&n.__u?void 0:c}function ln(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(ln)}function oa(t,n,a){for(var l=0;l<a.length;l++)hn(a[l],a[++l],a[++l]);ee.__c&&ee.__c(n,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(s){s.call(i)})}catch(s){ee.__e(s,i.__v)}})}function ca(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:Ut(t)?t.map(ca):Te({},t)}function Ya(t,n,a,l,i,s,r,c,h){var o,v,u,m,N,M,I,_=a.props||vt,D=n.props,P=n.type;if(P=="svg"?i="http://www.w3.org/2000/svg":P=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),s!=null){for(o=0;o<s.length;o++)if((N=s[o])&&"setAttribute"in N==!!P&&(P?N.localName==P:N.nodeType==3)){t=N,s[o]=null;break}}if(t==null){if(P==null)return document.createTextNode(D);t=document.createElementNS(i,P,D.is&&D),c&&(ee.__m&&ee.__m(n,s),c=!1),s=null}if(P==null)_===D||c&&t.data==D||(t.data=D);else{if(s=s&&Mt.call(t.childNodes),!c&&s!=null)for(_={},o=0;o<t.attributes.length;o++)_[(N=t.attributes[o]).name]=N.value;for(o in _)if(N=_[o],o!="children"){if(o=="dangerouslySetInnerHTML")u=N;else if(!(o in D)){if(o=="value"&&"defaultValue"in D||o=="checked"&&"defaultChecked"in D)continue;St(t,o,null,N,i)}}for(o in D)N=D[o],o=="children"?m=N:o=="dangerouslySetInnerHTML"?v=N:o=="value"?M=N:o=="checked"?I=N:c&&typeof N!="function"||_[o]===N||St(t,o,N,_[o],i);if(v)c||u&&(v.__html==u.__html||v.__html==t.innerHTML)||(t.innerHTML=v.__html),n.__k=[];else if(u&&(t.innerHTML=""),sa(n.type=="template"?t.content:t,Ut(m)?m:[m],n,a,l,P=="foreignObject"?"http://www.w3.org/1999/xhtml":i,s,r,s?s[0]:a.__k&&Ye(a,0),c,h),s!=null)for(o=s.length;o--;)un(s[o]);c||(o="value",P=="progress"&&M==null?t.removeAttribute("value"):M!=null&&(M!==t[o]||P=="progress"&&!M||P=="option"&&M!=_[o])&&St(t,o,M,_[o],i),o="checked",I!=null&&I!=t[o]&&St(t,o,I,_[o],i))}return t}function hn(t,n,a){try{if(typeof t=="function"){var l=typeof t.__u=="function";l&&t.__u(),l&&n==null||(t.__u=t(n))}else t.current=n}catch(i){ee.__e(i,a)}}function da(t,n,a){var l,i;if(ee.unmount&&ee.unmount(t),(l=t.ref)&&(l.current&&l.current!=t.__e||hn(l,null,n)),(l=t.__c)!=null){if(l.componentWillUnmount)try{l.componentWillUnmount()}catch(s){ee.__e(s,n)}l.base=l.__P=null}if(l=t.__k)for(i=0;i<l.length;i++)l[i]&&da(l[i],n,a||typeof t.type!="function");a||un(t.__e),t.__c=t.__=t.__e=void 0}function Xa(t,n,a){return this.constructor(t,a)}function Ja(t,n,a){var l,i,s,r;n==document&&(n=document.documentElement),ee.__&&ee.__(t,n),i=(l=!1)?null:n.__k,s=[],r=[],vn(n,t=n.__k=za(Y,null,[t]),i||vt,vt,n.namespaceURI,i?null:n.firstChild?Mt.call(n.childNodes):null,s,i?i.__e:n.firstChild,l,r),oa(s,t,r)}Mt=la.slice,ee={__e:function(t,n,a,l){for(var i,s,r;n=n.__;)if((i=n.__c)&&!i.__)try{if((s=i.constructor)&&s.getDerivedStateFromError!=null&&(i.setState(s.getDerivedStateFromError(t)),r=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,l||{}),r=i.__d),r)return i.__E=i}catch(c){t=c}throw t}},Qn=0,ea=function(t){return t!=null&&t.constructor===void 0},ot.prototype.setState=function(t,n){var a;a=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Te({},this.state),typeof t=="function"&&(t=t(Te({},a),this.props)),t&&Te(a,t),t!=null&&this.__v&&(n&&this._sb.push(n),wn(this))},ot.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),wn(this))},ot.prototype.render=Y,Ue=[],ta=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,na=function(t,n){return t.__v.__b-n.__v.__b},Ot.__r=0,aa=/(PointerCapture)$|Capture$/i,dn=0,nn=kn(!1),an=kn(!0);var Za=0;function e(t,n,a,l,i,s){n||(n={});var r,c,h=n;if("ref"in h)for(c in h={},n)c=="ref"?r=n[c]:h[c]=n[c];var o={type:t,props:h,key:a,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Za,__i:-1,__u:0,__source:i,__self:s};if(typeof t=="function"&&(r=t.defaultProps))for(c in r)h[c]===void 0&&(h[c]=r[c]);return ee.vnode&&ee.vnode(o),o}var xt,ge,zt,Tn,sn=0,ua=[],ce=ee,Nn=ce.__b,En=ce.__r,An=ce.diffed,Cn=ce.__c,In=ce.unmount,Dn=ce.__;function va(t,n){ce.__h&&ce.__h(ge,t,sn||n),sn=0;var a=ge.__H||(ge.__H={__:[],__h:[]});return t>=a.__.length&&a.__.push({}),a.__[t]}function F(t,n){var a=va(xt++,3);!ce.__s&&ha(a.__H,n)&&(a.__=t,a.u=n,ge.__H.__h.push(a))}function gt(t){return sn=5,Wt(function(){return{current:t}},[])}function Wt(t,n){var a=va(xt++,7);return ha(a.__H,n)&&(a.__=t(),a.__H=n,a.__h=t),a.__}function Qa(){for(var t;t=ua.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(Dt),t.__H.__h.forEach(rn),t.__H.__h=[]}catch(n){t.__H.__h=[],ce.__e(n,t.__v)}}ce.__b=function(t){ge=null,Nn&&Nn(t)},ce.__=function(t,n){t&&n.__k&&n.__k.__m&&(t.__m=n.__k.__m),Dn&&Dn(t,n)},ce.__r=function(t){En&&En(t),xt=0;var n=(ge=t.__c).__H;n&&(zt===ge?(n.__h=[],ge.__h=[],n.__.forEach(function(a){a.__N&&(a.__=a.__N),a.u=a.__N=void 0})):(n.__h.forEach(Dt),n.__h.forEach(rn),n.__h=[],xt=0)),zt=ge},ce.diffed=function(t){An&&An(t);var n=t.__c;n&&n.__H&&(n.__H.__h.length&&(ua.push(n)!==1&&Tn===ce.requestAnimationFrame||((Tn=ce.requestAnimationFrame)||el)(Qa)),n.__H.__.forEach(function(a){a.u&&(a.__H=a.u),a.u=void 0})),zt=ge=null},ce.__c=function(t,n){n.some(function(a){try{a.__h.forEach(Dt),a.__h=a.__h.filter(function(l){return!l.__||rn(l)})}catch(l){n.some(function(i){i.__h&&(i.__h=[])}),n=[],ce.__e(l,a.__v)}}),Cn&&Cn(t,n)},ce.unmount=function(t){In&&In(t);var n,a=t.__c;a&&a.__H&&(a.__H.__.forEach(function(l){try{Dt(l)}catch(i){n=i}}),a.__H=void 0,n&&ce.__e(n,a.__v))};var On=typeof requestAnimationFrame=="function";function el(t){var n,a=function(){clearTimeout(l),On&&cancelAnimationFrame(n),setTimeout(t)},l=setTimeout(a,35);On&&(n=requestAnimationFrame(a))}function Dt(t){var n=ge,a=t.__c;typeof a=="function"&&(t.__c=void 0,a()),ge=n}function rn(t){var n=ge;t.__c=t.__(),ge=n}function ha(t,n){return!t||t.length!==n.length||n.some(function(a,l){return a!==t[l]})}var tl=Symbol.for("preact-signals");function $t(){if(Le>1)Le--;else{for(var t,n=!1;ct!==void 0;){var a=ct;for(ct=void 0,on++;a!==void 0;){var l=a.o;if(a.o=void 0,a.f&=-3,!(8&a.f)&&fa(a))try{a.c()}catch(i){n||(t=i,n=!0)}a=l}}if(on=0,Le--,n)throw t}}function nl(t){if(Le>0)return t();Le++;try{return t()}finally{$t()}}var Q=void 0;function pa(t){var n=Q;Q=void 0;try{return t()}finally{Q=n}}var ct=void 0,Le=0,on=0,Lt=0;function ma(t){if(Q!==void 0){var n=t.n;if(n===void 0||n.t!==Q)return n={i:0,S:t,p:Q.s,n:void 0,t:Q,e:void 0,x:void 0,r:n},Q.s!==void 0&&(Q.s.n=n),Q.s=n,t.n=n,32&Q.f&&t.S(n),n;if(n.i===-1)return n.i=0,n.n!==void 0&&(n.n.p=n.p,n.p!==void 0&&(n.p.n=n.n),n.p=Q.s,n.n=void 0,Q.s.n=n,Q.s=n),n}}function pe(t,n){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=n?.watched,this.Z=n?.unwatched,this.name=n?.name}pe.prototype.brand=tl;pe.prototype.h=function(){return!0};pe.prototype.S=function(t){var n=this,a=this.t;a!==t&&t.e===void 0&&(t.x=a,this.t=t,a!==void 0?a.e=t:pa(function(){var l;(l=n.W)==null||l.call(n)}))};pe.prototype.U=function(t){var n=this;if(this.t!==void 0){var a=t.e,l=t.x;a!==void 0&&(a.x=l,t.e=void 0),l!==void 0&&(l.e=a,t.x=void 0),t===this.t&&(this.t=l,l===void 0&&pa(function(){var i;(i=n.Z)==null||i.call(n)}))}};pe.prototype.subscribe=function(t){var n=this;return yt(function(){var a=n.value,l=Q;Q=void 0;try{t(a)}finally{Q=l}},{name:"sub"})};pe.prototype.valueOf=function(){return this.value};pe.prototype.toString=function(){return this.value+""};pe.prototype.toJSON=function(){return this.value};pe.prototype.peek=function(){var t=Q;Q=void 0;try{return this.value}finally{Q=t}};Object.defineProperty(pe.prototype,"value",{get:function(){var t=ma(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(on>100)throw new Error("Cycle detected");this.v=t,this.i++,Lt++,Le++;try{for(var n=this.t;n!==void 0;n=n.x)n.t.N()}finally{$t()}}}});function fe(t,n){return new pe(t,n)}function fa(t){for(var n=t.s;n!==void 0;n=n.n)if(n.S.i!==n.i||!n.S.h()||n.S.i!==n.i)return!0;return!1}function ga(t){for(var n=t.s;n!==void 0;n=n.n){var a=n.S.n;if(a!==void 0&&(n.r=a),n.S.n=n,n.i=-1,n.n===void 0){t.s=n;break}}}function ya(t){for(var n=t.s,a=void 0;n!==void 0;){var l=n.p;n.i===-1?(n.S.U(n),l!==void 0&&(l.n=n.n),n.n!==void 0&&(n.n.p=l)):a=n,n.S.n=n.r,n.r!==void 0&&(n.r=void 0),n=l}t.s=a}function Fe(t,n){pe.call(this,void 0),this.x=t,this.s=void 0,this.g=Lt-1,this.f=4,this.W=n?.watched,this.Z=n?.unwatched,this.name=n?.name}Fe.prototype=new pe;Fe.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Lt))return!0;if(this.g=Lt,this.f|=1,this.i>0&&!fa(this))return this.f&=-2,!0;var t=Q;try{ga(this),Q=this;var n=this.x();(16&this.f||this.v!==n||this.i===0)&&(this.v=n,this.f&=-17,this.i++)}catch(a){this.v=a,this.f|=16,this.i++}return Q=t,ya(this),this.f&=-2,!0};Fe.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var n=this.s;n!==void 0;n=n.n)n.S.S(n)}pe.prototype.S.call(this,t)};Fe.prototype.U=function(t){if(this.t!==void 0&&(pe.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var n=this.s;n!==void 0;n=n.n)n.S.U(n)}};Fe.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}};Object.defineProperty(Fe.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=ma(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function ht(t,n){return new Fe(t,n)}function _a(t){var n=t.u;if(t.u=void 0,typeof n=="function"){Le++;var a=Q;Q=void 0;try{n()}catch(l){throw t.f&=-2,t.f|=8,pn(t),l}finally{Q=a,$t()}}}function pn(t){for(var n=t.s;n!==void 0;n=n.n)n.S.U(n);t.x=void 0,t.s=void 0,_a(t)}function al(t){if(Q!==this)throw new Error("Out-of-order effect");ya(this),Q=t,this.f&=-2,8&this.f&&pn(this),$t()}function Xe(t,n){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=n?.name}Xe.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var n=this.x();typeof n=="function"&&(this.u=n)}finally{t()}};Xe.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,_a(this),ga(this),Le++;var t=Q;return Q=this,al.bind(this,t)};Xe.prototype.N=function(){2&this.f||(this.f|=2,this.o=ct,ct=this)};Xe.prototype.d=function(){this.f|=8,1&this.f||pn(this)};Xe.prototype.dispose=function(){this.d()};function yt(t,n){var a=new Xe(t,n);try{a.c()}catch(i){throw a.d(),i}var l=a.d.bind(a);return l[Symbol.dispose]=l,l}var ba,Kt,kt,ll=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__,wa=[];yt(function(){ba=this.N})();function Je(t,n){ee[t]=n.bind(null,ee[t]||function(){})}function Rt(t){if(kt){var n=kt;kt=void 0,n()}kt=t&&t.S()}function Sa(t){var n=this,a=t.data,l=d(a);l.value=a;var i=Wt(function(){for(var c=n,h=n.__v;h=h.__;)if(h.__c){h.__c.__$f|=4;break}var o=ht(function(){var N=l.value.value;return N===0?0:N===!0?"":N||""}),v=ht(function(){return!Array.isArray(o.value)&&!ea(o.value)}),u=yt(function(){if(this.N=ka,v.value){var N=o.value;c.__v&&c.__v.__e&&c.__v.__e.nodeType===3&&(c.__v.__e.data=N)}}),m=n.__$u.d;return n.__$u.d=function(){u(),m.call(this)},[v,o]},[]),s=i[0],r=i[1];return s.value?r.peek():r.value}Sa.displayName="ReactiveTextNode";Object.defineProperties(pe.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Sa},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});Je("__b",function(t,n){if(typeof n.type=="string"){var a,l=n.props;for(var i in l)if(i!=="children"){var s=l[i];s instanceof pe&&(a||(n.__np=a={}),a[i]=s,l[i]=s.peek())}}t(n)});Je("__r",function(t,n){if(t(n),n.type!==Y){Rt();var a,l=n.__c;l&&(l.__$f&=-2,(a=l.__$u)===void 0&&(l.__$u=a=(function(i,s){var r;return yt(function(){r=this},{name:s}),r.c=i,r})(function(){var i;ll&&((i=a.y)==null||i.call(a)),l.__$f|=1,l.setState({})},typeof n.type=="function"?n.type.displayName||n.type.name:""))),Kt=l,Rt(a)}});Je("__e",function(t,n,a,l){Rt(),Kt=void 0,t(n,a,l)});Je("diffed",function(t,n){Rt(),Kt=void 0;var a;if(typeof n.type=="string"&&(a=n.__e)){var l=n.__np,i=n.props;if(l){var s=a.U;if(s)for(var r in s){var c=s[r];c!==void 0&&!(r in l)&&(c.d(),s[r]=void 0)}else s={},a.U=s;for(var h in l){var o=s[h],v=l[h];o===void 0?(o=il(a,h,v,i),s[h]=o):o.o(v,i)}}}t(n)});function il(t,n,a,l){var i=n in t&&t.ownerSVGElement===void 0,s=fe(a);return{o:function(r,c){s.value=r,l=c},d:yt(function(){this.N=ka;var r=s.value.value;l[n]!==r&&(l[n]=r,i?t[n]=r:r!=null&&(r!==!1||n[4]==="-")?t.setAttribute(n,r):t.removeAttribute(n))})}}Je("unmount",function(t,n){if(typeof n.type=="string"){var a=n.__e;if(a){var l=a.U;if(l){a.U=void 0;for(var i in l){var s=l[i];s&&s.d()}}}}else{var r=n.__c;if(r){var c=r.__$u;c&&(r.__$u=void 0,c.d())}}t(n)});Je("__h",function(t,n,a,l){(l<3||l===9)&&(n.__$f|=2),t(n,a,l)});ot.prototype.shouldComponentUpdate=function(t,n){if(this.__R)return!0;var a=this.__$u,l=a&&a.s!==void 0;for(var i in n)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){var s=2&this.__$f;if(!(l||s||4&this.__$f)||1&this.__$f)return!0}else if(!(l||4&this.__$f)||3&this.__$f)return!0;for(var r in t)if(r!=="__source"&&t[r]!==this.props[r])return!0;for(var c in this.props)if(!(c in t))return!0;return!1};function d(t,n){return Wt(function(){return fe(t,n)},[])}function Ft(t,n){var a=gt(t);return a.current=t,Kt.__$f|=4,Wt(function(){return ht(function(){return a.current()},n)},[])}var sl=function(t){queueMicrotask(function(){queueMicrotask(t)})};function rl(){nl(function(){for(var t;t=wa.shift();)ba.call(t)})}function ka(){wa.push(this)===1&&(ee.requestAnimationFrame||sl)(rl)}const pt=fe(null),ol=ht(()=>pt.value!==null),Ta=fe(900),cl=fe(!1);let qe=null;const je=()=>{mn()};function dl(){document.addEventListener("mousemove",je,{passive:!0}),document.addEventListener("keydown",je,{passive:!0}),document.addEventListener("click",je,{passive:!0}),mn()}function ul(){document.removeEventListener("mousemove",je),document.removeEventListener("keydown",je),document.removeEventListener("click",je),qe!==null&&(clearTimeout(qe),qe=null)}function mn(){qe!==null&&clearTimeout(qe),qe=setTimeout(()=>{fn()},Ta.value*1e3)}function vl(t,n){pt.value=t,n!==void 0&&(Ta.value=n),dl(),location.hash="#/dashboard"}function fn(){pt.value=null,ul(),location.hash="#/login"}const L={ADMIN_STATUS:"/v1/admin/status",ADMIN_KILL_SWITCH:"/v1/admin/kill-switch",ADMIN_KILL_SWITCH_ESCALATE:"/v1/admin/kill-switch/escalate",ADMIN_RECOVER:"/v1/admin/recover",ADMIN_SHUTDOWN:"/v1/admin/shutdown",ADMIN_ROTATE_SECRET:"/v1/admin/rotate-secret",WALLETS:"/v1/wallets",WALLET:t=>`/v1/wallets/${t}`,SESSIONS:"/v1/sessions",SESSION:t=>`/v1/sessions/${t}`,POLICIES:"/v1/policies",POLICY:t=>`/v1/policies/${t}`,TOKENS:"/v1/tokens",ADMIN_NOTIFICATIONS_STATUS:"/v1/admin/notifications/status",ADMIN_NOTIFICATIONS_TEST:"/v1/admin/notifications/test",ADMIN_NOTIFICATIONS_LOG:"/v1/admin/notifications/log",MCP_TOKENS:"/v1/mcp/tokens",ADMIN_SETTINGS:"/v1/admin/settings",ADMIN_SETTINGS_TEST_RPC:"/v1/admin/settings/test-rpc",ADMIN_RPC_STATUS:"/v1/admin/rpc-status",WALLET_NETWORKS:t=>`/v1/wallets/${t}/networks`,WALLET_DEFAULT_NETWORK:t=>`/v1/wallets/${t}/default-network`,ADMIN_WALLET_BALANCE:t=>`/v1/admin/wallets/${t}/balance`,ADMIN_WALLET_TRANSACTIONS:t=>`/v1/admin/wallets/${t}/transactions`,ADMIN_API_KEYS:"/v1/admin/api-keys",ADMIN_API_KEY:t=>`/v1/admin/api-keys/${t}`,ADMIN_FOREX_RATES:"/v1/admin/forex/rates",ADMIN_TELEGRAM_USERS:"/v1/admin/telegram-users",ADMIN_TELEGRAM_USER:t=>`/v1/admin/telegram-users/${t}`,WALLET_OWNER:t=>`/v1/wallets/${t}/owner`,WALLET_WITHDRAW:t=>`/v1/wallets/${t}/withdraw`,WALLET_WC_PAIR:t=>`/v1/wallets/${t}/wc/pair`,WALLET_WC_SESSION:t=>`/v1/wallets/${t}/wc/session`,WALLET_WC_PAIR_STATUS:t=>`/v1/wallets/${t}/wc/pair/status`,WALLET_OWNER_VERIFY:t=>`/v1/wallets/${t}/owner/verify`,WALLET_SUSPEND:t=>`/v1/wallets/${t}/suspend`,WALLET_RESUME:t=>`/v1/wallets/${t}/resume`,ADMIN_AGENT_PROMPT:"/v1/admin/agent-prompt",ADMIN_SESSION_REISSUE:t=>`/v1/admin/sessions/${t}/reissue`,ADMIN_TRANSACTIONS:"/v1/admin/transactions",ADMIN_TX_CANCEL:t=>`/v1/admin/transactions/${t}/cancel`,ADMIN_TX_REJECT:t=>`/v1/admin/transactions/${t}/reject`,ADMIN_INCOMING:"/v1/admin/incoming",WALLET_PATCH:t=>`/v1/wallets/${t}`,TOKENS_RESOLVE:"/v1/tokens/resolve",ACTIONS_PROVIDERS:"/v1/actions/providers",ADMIN_WALLET_STAKING:t=>`/v1/admin/wallets/${t}/staking`},dt=fe(""),ze=fe(null),ut=fe(!1),Ce={wrapper:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:"100vh",background:"var(--color-bg-secondary)"},card:{background:"var(--color-bg)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-lg)",padding:"var(--space-8)",width:"100%",maxWidth:"360px",boxShadow:"var(--shadow-md)"},title:{fontSize:"var(--font-size-2xl)",fontWeight:"var(--font-weight-bold)",textAlign:"center",marginBottom:"var(--space-1)"},subtitle:{fontSize:"var(--font-size-sm)",color:"var(--color-text-secondary)",textAlign:"center",marginBottom:"var(--space-6)"},input:{width:"100%",padding:"var(--space-2) var(--space-3)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",fontSize:"var(--font-size-base)",outline:"none"},button:{width:"100%",padding:"var(--space-2) var(--space-4)",background:"var(--color-primary)",color:"white",border:"none",borderRadius:"var(--radius-md)",fontSize:"var(--font-size-base)",fontWeight:"var(--font-weight-medium)",marginTop:"var(--space-4)"},buttonDisabled:{opacity:.6,cursor:"not-allowed"},error:{color:"var(--color-danger)",fontSize:"var(--font-size-sm)",textAlign:"center",marginTop:"var(--space-3)"}},hl=async t=>{if(t.preventDefault(),!!dt.value.trim()){ut.value=!0,ze.value=null;try{const n=await fetch(L.ADMIN_STATUS,{headers:{"X-Master-Password":dt.value},signal:AbortSignal.timeout(1e4)});if(n.status===401){ze.value="Invalid master password";return}if(!n.ok){ze.value="Cannot connect to daemon";return}const a=await n.json();vl(dt.value,a.adminTimeout)}catch{ze.value="Cannot connect to daemon"}finally{ut.value=!1}}};function pl(){return e("div",{style:Ce.wrapper,children:e("form",{style:Ce.card,onSubmit:hl,children:[e("h1",{style:Ce.title,children:"WAIaaS Admin"}),e("p",{style:Ce.subtitle,children:"Enter master password to continue"}),e("input",{type:"password",placeholder:"Master password",autoFocus:!0,value:dt.value,onInput:t=>{dt.value=t.target.value},style:Ce.input}),e("button",{type:"submit",disabled:ut.value,style:{...Ce.button,...ut.value?Ce.buttonDisabled:{}},children:ut.value?"Signing in...":"Sign in"}),ze.value&&e("p",{style:Ce.error,children:ze.value})]})})}const ml=[{id:"wallets.rpc.solana_mainnet",label:"Solana Mainnet",description:"RPC endpoint URL for Solana mainnet",page:"/wallets",tab:"rpc",fieldName:"rpc.solana_mainnet",keywords:["blockchain","rpc","solana","url","endpoint"]},{id:"wallets.rpc.solana_devnet",label:"Solana Devnet",description:"RPC endpoint URL for Solana devnet",page:"/wallets",tab:"rpc",fieldName:"rpc.solana_devnet",keywords:["blockchain","rpc","solana","url","endpoint","test"]},{id:"wallets.rpc.solana_testnet",label:"Solana Testnet",description:"RPC endpoint URL for Solana testnet",page:"/wallets",tab:"rpc",fieldName:"rpc.solana_testnet",keywords:["blockchain","rpc","solana","url","endpoint","test"]},{id:"wallets.rpc.evm_ethereum_mainnet",label:"Ethereum Mainnet",description:"RPC endpoint URL for Ethereum mainnet",page:"/wallets",tab:"rpc",fieldName:"rpc.evm_ethereum_mainnet",keywords:["blockchain","rpc","evm","ethereum","url","endpoint"]},{id:"wallets.rpc.evm_ethereum_sepolia",label:"Ethereum Sepolia",description:"RPC endpoint URL for Ethereum Sepolia testnet",page:"/wallets",tab:"rpc",fieldName:"rpc.evm_ethereum_sepolia",keywords:["blockchain","rpc","evm","ethereum","url","endpoint","test"]},{id:"wallets.rpc.evm_polygon_mainnet",label:"Polygon Mainnet",description:"RPC endpoint URL for Polygon mainnet",page:"/wallets",tab:"rpc",fieldName:"rpc.evm_polygon_mainnet",keywords:["blockchain","rpc","evm","polygon","matic","url","endpoint"]},{id:"wallets.rpc.evm_polygon_amoy",label:"Polygon Amoy",description:"RPC endpoint URL for Polygon Amoy testnet",page:"/wallets",tab:"rpc",fieldName:"rpc.evm_polygon_amoy",keywords:["blockchain","rpc","evm","polygon","url","endpoint","test"]},{id:"wallets.rpc.evm_arbitrum_mainnet",label:"Arbitrum Mainnet",description:"RPC endpoint URL for Arbitrum mainnet",page:"/wallets",tab:"rpc",fieldName:"rpc.evm_arbitrum_mainnet",keywords:["blockchain","rpc","evm","arbitrum","l2","url","endpoint"]},{id:"wallets.rpc.evm_arbitrum_sepolia",label:"Arbitrum Sepolia",description:"RPC endpoint URL for Arbitrum Sepolia testnet",page:"/wallets",tab:"rpc",fieldName:"rpc.evm_arbitrum_sepolia",keywords:["blockchain","rpc","evm","arbitrum","l2","url","endpoint","test"]},{id:"wallets.rpc.evm_optimism_mainnet",label:"Optimism Mainnet",description:"RPC endpoint URL for Optimism mainnet",page:"/wallets",tab:"rpc",fieldName:"rpc.evm_optimism_mainnet",keywords:["blockchain","rpc","evm","optimism","l2","url","endpoint"]},{id:"wallets.rpc.evm_optimism_sepolia",label:"Optimism Sepolia",description:"RPC endpoint URL for Optimism Sepolia testnet",page:"/wallets",tab:"rpc",fieldName:"rpc.evm_optimism_sepolia",keywords:["blockchain","rpc","evm","optimism","l2","url","endpoint","test"]},{id:"wallets.rpc.evm_base_mainnet",label:"Base Mainnet",description:"RPC endpoint URL for Base mainnet",page:"/wallets",tab:"rpc",fieldName:"rpc.evm_base_mainnet",keywords:["blockchain","rpc","evm","base","coinbase","l2","url","endpoint"]},{id:"wallets.rpc.evm_base_sepolia",label:"Base Sepolia",description:"RPC endpoint URL for Base Sepolia testnet",page:"/wallets",tab:"rpc",fieldName:"rpc.evm_base_sepolia",keywords:["blockchain","rpc","evm","base","coinbase","l2","url","endpoint","test"]},{id:"wallets.rpc.evm_default_network",label:"Default EVM Network",description:"Default EVM network for new wallets",page:"/wallets",tab:"rpc",fieldName:"rpc.evm_default_network",keywords:["blockchain","evm","default","network"]},{id:"notifications.balance.enabled",label:"Enabled",description:"Enable or disable balance monitoring",page:"/notifications",tab:"balance",fieldName:"monitoring.enabled",keywords:["balance","monitoring","toggle","enable"]},{id:"notifications.balance.check_interval_sec",label:"Check Interval (seconds)",description:"How often to check wallet balances",page:"/notifications",tab:"balance",fieldName:"monitoring.check_interval_sec",keywords:["balance","monitoring","interval","frequency"]},{id:"notifications.balance.low_balance_threshold_sol",label:"Low Balance Threshold (SOL)",description:"Alert when SOL balance drops below this amount",page:"/notifications",tab:"balance",fieldName:"monitoring.low_balance_threshold_sol",keywords:["balance","monitoring","threshold","solana","alert","low"]},{id:"notifications.balance.low_balance_threshold_eth",label:"Low Balance Threshold (ETH)",description:"Alert when ETH balance drops below this amount",page:"/notifications",tab:"balance",fieldName:"monitoring.low_balance_threshold_eth",keywords:["balance","monitoring","threshold","ethereum","alert","low"]},{id:"notifications.balance.cooldown_hours",label:"Alert Cooldown (hours)",description:"Suppress duplicate alerts for this many hours",page:"/notifications",tab:"balance",fieldName:"monitoring.cooldown_hours",keywords:["balance","monitoring","cooldown","alert","suppress"]},{id:"wallets.walletconnect.project_id",label:"Project ID",description:"WalletConnect Cloud project identifier",page:"/wallets",tab:"walletconnect",fieldName:"walletconnect.project_id",keywords:["walletconnect","project","cloud","dapp"]},{id:"wallets.walletconnect.relay_url",label:"Relay URL",description:"WalletConnect relay server URL",page:"/wallets",tab:"walletconnect",fieldName:"walletconnect.relay_url",keywords:["walletconnect","relay","websocket","server"]},{id:"sessions.settings.session_ttl",label:"Session TTL (seconds)",description:"How long a session token is valid before renewal",page:"/sessions",tab:"settings",fieldName:"security.session_ttl",keywords:["session","ttl","lifetime","expiry","timeout"]},{id:"sessions.settings.session_absolute_lifetime",label:"Absolute Lifetime (seconds)",description:"Maximum total session duration regardless of renewals",page:"/sessions",tab:"settings",fieldName:"security.session_absolute_lifetime",keywords:["session","lifetime","absolute","maximum"]},{id:"sessions.settings.session_max_renewals",label:"Max Renewals",description:"Maximum number of times a session can be renewed",page:"/sessions",tab:"settings",fieldName:"security.session_max_renewals",keywords:["session","renewal","limit","maximum"]},{id:"sessions.settings.max_sessions_per_wallet",label:"Max Sessions per Wallet",description:"Maximum concurrent sessions for a single wallet",page:"/sessions",tab:"settings",fieldName:"security.max_sessions_per_wallet",keywords:["session","limit","concurrent","wallet"]},{id:"sessions.settings.max_pending_tx",label:"Max Pending Transactions",description:"Maximum in-flight transactions per session",page:"/sessions",tab:"settings",fieldName:"security.max_pending_tx",keywords:["transaction","pending","limit","queue"]},{id:"sessions.settings.rate_limit_session_rpm",label:"Session Rate Limit (RPM)",description:"Max requests per minute per session",page:"/sessions",tab:"settings",fieldName:"security.rate_limit_session_rpm",keywords:["rate","limit","rpm","session","throttle"]},{id:"sessions.settings.rate_limit_tx_rpm",label:"Transaction Rate Limit (RPM)",description:"Max transaction requests per minute per session",page:"/sessions",tab:"settings",fieldName:"security.rate_limit_tx_rpm",keywords:["rate","limit","rpm","transaction","throttle"]},{id:"policies.defaults.policy_defaults_delay_seconds",label:"Policy Delay (seconds)",description:"Default delay before executing delayed-tier transactions",page:"/policies",tab:"defaults",fieldName:"security.policy_defaults_delay_seconds",keywords:["policy","delay","default","seconds","timer"]},{id:"policies.defaults.policy_defaults_approval_timeout",label:"Approval Timeout (seconds)",description:"How long to wait for owner approval before timeout",page:"/policies",tab:"defaults",fieldName:"security.policy_defaults_approval_timeout",keywords:["policy","approval","timeout","owner","default"]},{id:"policies.defaults.default_deny_tokens",label:"Default Deny: Token Transfers",description:"Deny token transfers unless a matching whitelist policy exists",page:"/policies",tab:"defaults",fieldName:"policy.default_deny_tokens",keywords:["policy","deny","token","transfer","default","security"]},{id:"policies.defaults.default_deny_contracts",label:"Default Deny: Contract Calls",description:"Deny contract calls unless a matching whitelist policy exists",page:"/policies",tab:"defaults",fieldName:"policy.default_deny_contracts",keywords:["policy","deny","contract","call","default","security"]},{id:"policies.defaults.default_deny_spenders",label:"Default Deny: Token Approvals",description:"Deny token approvals unless a matching whitelist policy exists",page:"/policies",tab:"defaults",fieldName:"policy.default_deny_spenders",keywords:["policy","deny","spender","approval","default","security"]},{id:"notifications.settings.enabled",label:"Enabled",description:"Enable or disable notifications globally",page:"/notifications",tab:"settings",fieldName:"notifications.enabled",keywords:["notifications","enable","toggle","global"]},{id:"notifications.settings.telegram_bot_token",label:"Telegram Bot Token",description:"Bot token for Telegram notifications",page:"/notifications",tab:"settings",fieldName:"notifications.telegram_bot_token",keywords:["telegram","bot","token","notification","credential"]},{id:"notifications.settings.telegram_chat_id",label:"Telegram Chat ID",description:"Chat ID for Telegram notification delivery",page:"/notifications",tab:"settings",fieldName:"notifications.telegram_chat_id",keywords:["telegram","chat","notification"]},{id:"notifications.settings.locale",label:"Locale",description:"Language for notification messages",page:"/notifications",tab:"settings",fieldName:"notifications.locale",keywords:["locale","language","notification","i18n"]},{id:"notifications.settings.discord_webhook_url",label:"Discord Webhook URL",description:"Webhook URL for Discord notifications",page:"/notifications",tab:"settings",fieldName:"notifications.discord_webhook_url",keywords:["discord","webhook","notification","credential"]},{id:"notifications.settings.ntfy_server",label:"Ntfy Server",description:"Server URL for ntfy notifications",page:"/notifications",tab:"settings",fieldName:"notifications.ntfy_server",keywords:["ntfy","server","push","notification"]},{id:"notifications.settings.ntfy_topic",label:"Ntfy Topic",description:"Topic name for ntfy notifications",page:"/notifications",tab:"settings",fieldName:"notifications.ntfy_topic",keywords:["ntfy","topic","push","notification"]},{id:"notifications.settings.slack_webhook_url",label:"Slack Webhook URL",description:"Webhook URL for Slack notifications",page:"/notifications",tab:"settings",fieldName:"notifications.slack_webhook_url",keywords:["slack","webhook","notification","credential"]},{id:"notifications.settings.rate_limit_rpm",label:"Rate Limit (RPM)",description:"Max notifications per minute",page:"/notifications",tab:"settings",fieldName:"notifications.rate_limit_rpm",keywords:["rate","limit","rpm","notification","throttle"]},{id:"notifications.settings.notify_events",label:"Event Filter",description:"Per-event notification filter (choose which events are delivered)",page:"/notifications",tab:"settings",fieldName:"notifications.notify_events",keywords:["filter","event","category","notification","subscribe"]},{id:"notifications.settings.telegram_dedicated_bot_token",label:"Bot Token",description:"Dedicated bot token for Telegram bot (optional, uses notification token if empty)",page:"/notifications",tab:"settings",fieldName:"telegram.bot_token",keywords:["telegram","bot","token","credential"]},{id:"security.autostop.enabled",label:"Enabled",description:"Enable or disable AutoStop protection rules",page:"/security",tab:"autostop",fieldName:"autostop.enabled",keywords:["autostop","protection","enable","toggle","security"]},{id:"security.autostop.consecutive_failures_threshold",label:"Consecutive Failures Threshold",description:"Suspend wallet after this many consecutive failed transactions",page:"/security",tab:"autostop",fieldName:"autostop.consecutive_failures_threshold",keywords:["autostop","failure","threshold","suspend","security"]},{id:"security.autostop.unusual_activity_threshold",label:"Unusual Activity Threshold",description:"Max transactions within window before triggering unusual activity alert",page:"/security",tab:"autostop",fieldName:"autostop.unusual_activity_threshold",keywords:["autostop","unusual","activity","threshold","security"]},{id:"security.autostop.unusual_activity_window_sec",label:"Unusual Activity Window (seconds)",description:"Time window for unusual activity detection",page:"/security",tab:"autostop",fieldName:"autostop.unusual_activity_window_sec",keywords:["autostop","unusual","activity","window","time","security"]},{id:"security.autostop.idle_timeout_sec",label:"Idle Timeout (seconds)",description:"Revoke sessions with no activity for this duration",page:"/security",tab:"autostop",fieldName:"autostop.idle_timeout_sec",keywords:["autostop","idle","timeout","session","revoke","security"]},{id:"security.autostop.idle_check_interval_sec",label:"Idle Check Interval (seconds)",description:"How often to check for idle sessions",page:"/security",tab:"autostop",fieldName:"autostop.idle_check_interval_sec",keywords:["autostop","idle","check","interval","security"]},{id:"system..currency",label:"Display Currency",description:"Currency for USD amount conversion in dashboard and notifications",page:"/system",tab:"",fieldName:"display.currency",keywords:["currency","display","usd","conversion","fiat"]},{id:"system..rate_limit_global_ip_rpm",label:"Global IP Rate Limit (RPM)",description:"Maximum API requests per minute from a single IP address",page:"/system",tab:"",fieldName:"security.rate_limit_global_ip_rpm",keywords:["rate","limit","rpm","ip","global","throttle"]},{id:"system..log_level",label:"Log Level",description:"Daemon logging verbosity level",page:"/system",tab:"",fieldName:"daemon.log_level",keywords:["log","level","debug","info","warn","error","daemon"]},{id:"transactions.monitor.enabled",label:"Monitoring Enabled",description:"Enable or disable incoming transaction monitoring",page:"/transactions",tab:"monitor",fieldName:"incoming.enabled",keywords:["incoming","monitoring","enable","toggle"]},{id:"transactions.monitor.poll_interval",label:"Poll Interval (seconds)",description:"How often to poll for incoming transactions",page:"/transactions",tab:"monitor",fieldName:"incoming.poll_interval",keywords:["incoming","poll","interval","frequency"]},{id:"transactions.monitor.retention_days",label:"Retention Days",description:"How many days to retain incoming transaction records",page:"/transactions",tab:"monitor",fieldName:"incoming.retention_days",keywords:["incoming","retention","days","cleanup"]},{id:"transactions.monitor.suspicious_dust_usd",label:"Suspicious Dust USD Threshold",description:"USD threshold below which transactions are flagged as dust",page:"/transactions",tab:"monitor",fieldName:"incoming.suspicious_dust_usd",keywords:["incoming","suspicious","dust","threshold","usd"]},{id:"transactions.monitor.suspicious_amount_multiplier",label:"Suspicious Amount Multiplier",description:"Multiplier for detecting unusually large incoming amounts",page:"/transactions",tab:"monitor",fieldName:"incoming.suspicious_amount_multiplier",keywords:["incoming","suspicious","amount","multiplier","large"]},{id:"transactions.monitor.cooldown_minutes",label:"Notification Cooldown (minutes)",description:"Cooldown period between duplicate incoming TX notifications",page:"/transactions",tab:"monitor",fieldName:"incoming.cooldown_minutes",keywords:["incoming","cooldown","notification","minutes"]},{id:"transactions.monitor.wss_url",label:"WebSocket URL",description:"Custom WebSocket RPC URL for real-time incoming TX detection",page:"/transactions",tab:"monitor",fieldName:"incoming.wss_url",keywords:["incoming","websocket","wss","rpc","url"]},{id:"system..cross_validation_threshold",label:"Cross Validation Threshold (%)",description:"Maximum allowed deviation between price oracle sources",page:"/system",tab:"",fieldName:"oracle.cross_validation_threshold",keywords:["oracle","price","validation","threshold","deviation"]},{id:"system..signing_sdk_enabled",label:"SDK Enabled",description:"Enable Signing SDK for wallet app approval",page:"/system",tab:"",fieldName:"signing_sdk.enabled",keywords:["signing","sdk","wallet","app","enable"]},{id:"system..signing_sdk_request_expiry",label:"Request Expiry (min)",description:"Minutes before a sign request expires",page:"/system",tab:"",fieldName:"signing_sdk.request_expiry_min",keywords:["signing","sdk","expiry","timeout","request"]},{id:"system..signing_sdk_preferred_channel",label:"Preferred Channel",description:"Preferred signing channel for SDK requests",page:"/system",tab:"",fieldName:"signing_sdk.preferred_channel",keywords:["signing","sdk","channel","ntfy","telegram"]},{id:"system..signing_sdk_notifications",label:"Notifications Enabled",description:"Push event notifications to wallet apps",page:"/system",tab:"",fieldName:"signing_sdk.notifications_enabled",keywords:["signing","sdk","notification","wallet","push"]}],_e=fe(""),le=fe(null),fl={"/wallets":"Wallets","/sessions":"Sessions","/transactions":"Transactions","/policies":"Policies","/notifications":"Notifications","/security":"Security","/system":"System"};function gl(t){if(!t.trim())return[];const n=t.toLowerCase();return ml.filter(a=>[a.label,a.description,a.keywords.join(" ")].join(" ").toLowerCase().includes(n)).slice(0,10)}function yl(t){const n=fl[t.page]??t.page;return t.tab?`${n} > ${t.tab}`:n}function _l({open:t}){const n=d(""),a=d(0),l=gt(null),i=t.value?gl(n.value):[];if(F(()=>{t.value&&(n.value="",a.value=0,requestAnimationFrame(()=>{l.current?.focus()}))},[t.value]),!t.value)return null;const s=()=>{t.value=!1,n.value="",a.value=0},r=o=>{o.target.classList.contains("search-overlay")&&s()},c=o=>{window.location.hash="#"+o.page,o.tab?le.value={tab:o.tab,fieldName:o.fieldName}:setTimeout(()=>{_e.value=o.fieldName},100),s()};return e("div",{class:"search-overlay",onClick:r,children:e("div",{class:"search-popover",onKeyDown:o=>{if(o.key==="Escape"){s();return}if(o.key==="ArrowDown"){o.preventDefault(),a.value=Math.min(a.value+1,i.length-1);return}if(o.key==="ArrowUp"){o.preventDefault(),a.value=Math.max(a.value-1,0);return}if(o.key==="Enter"&&i.length>0){o.preventDefault(),c(i[a.value]);return}},children:[e("div",{class:"search-input-wrapper",children:e("input",{ref:l,class:"search-input",type:"text",placeholder:"Search settings...",value:n.value,onInput:o=>{n.value=o.target.value,a.value=0}})}),e("div",{class:"search-results",children:[n.value.trim()&&i.length===0&&e("div",{class:"search-empty",children:"No settings found"}),i.map((o,v)=>e("button",{class:`search-result-item${v===a.value?" selected":""}`,onClick:()=>c(o),onMouseEnter:()=>{a.value=v},children:[e("div",{class:"search-result-label",children:o.label}),e("div",{class:"search-result-desc",children:o.description}),e("div",{class:"search-result-path",children:yl(o)})]},o.id))]}),e("div",{class:"search-hint",children:[e("span",{children:[e("kbd",{children:"Esc"})," close"]}),e("span",{children:[e("kbd",{children:"↑"}),e("kbd",{children:"↓"})," navigate"]}),e("span",{children:[e("kbd",{children:"Enter"})," select"]})]})]})})}const $e=fe([]),Na=ht(()=>$e.value.some(t=>typeof t.isDirty=="function"&&t.isDirty()));function Ne(t){$e.value=[...$e.value.filter(n=>n.id!==t.id),t]}function ke(t){$e.value=$e.value.filter(n=>n.id!==t)}async function bl(){const t=$e.value.filter(n=>typeof n.isDirty=="function"&&n.isDirty());try{for(const n of t)await n.save();return!0}catch{return!1}}function wl(){const t=$e.value.filter(n=>typeof n.isDirty=="function"&&n.isDirty());for(const n of t)n.discard()}function A({label:t,name:n,type:a="text",value:l,onChange:i,options:s,error:r,required:c,disabled:h,placeholder:o,min:v,max:u,description:m}){const N=_e.value===n;if(F(()=>{if(N){const I=document.querySelector(`[name="${n}"]`);I&&I.closest(".form-field")?.scrollIntoView({behavior:"smooth",block:"center"});const _=setTimeout(()=>{_e.value=""},2500);return()=>clearTimeout(_)}},[N,n]),a==="checkbox")return e("div",{class:`form-field${N?" form-field--highlight":""}`,children:[e("label",{children:[e("input",{type:"checkbox",name:n,checked:!!l,onChange:I=>i(I.target.checked),disabled:h}),t,c&&e("span",{children:" *"})]}),m&&e("span",{class:"form-description",children:m}),r&&e("span",{class:"form-error",children:r})]});const M=`field-${n}`;return e("div",{class:`form-field${N?" form-field--highlight":""}`,children:[e("label",{for:M,children:[t,c&&e("span",{children:" *"})]}),a==="select"?e("select",{id:M,name:n,value:l,onChange:I=>i(I.target.value),disabled:h,children:s?.map(I=>e("option",{value:I.value,children:I.label},I.value))}):a==="textarea"?e("textarea",{id:M,name:n,value:l,onInput:I=>i(I.target.value),disabled:h,placeholder:o}):e("input",{id:M,type:a,name:n,value:l,onInput:I=>{const _=I.target;i(a==="number"?Number(_.value):_.value)},disabled:h,placeholder:o,min:v,max:u,required:c}),m&&e("span",{class:"form-description",children:m}),r&&e("span",{class:"form-error",children:r})]})}function R({variant:t="primary",size:n="md",loading:a=!1,disabled:l=!1,onClick:i,children:s,type:r="button"}){const c=["btn",`btn-${t}`,n==="sm"?"btn-sm":""].filter(Boolean).join(" ");return e("button",{type:r,class:c,disabled:l||a,onClick:i,children:a?"...":s})}function B({variant:t,children:n}){return e("span",{class:`badge badge-${t}`,children:n})}const st=fe(null),nt=fe(!1);function Ea(t){st.value=t}function Sl(){const t=st.value;if(!t)return null;const n=async()=>{nt.value=!0;const i=await bl();nt.value=!1,i&&(st.value=null,t.execute())},a=()=>{wl(),st.value=null,t.execute()},l=()=>{st.value=null};return e("div",{class:"modal-overlay",onClick:l,children:e("div",{class:"modal-card",onClick:i=>i.stopPropagation(),children:[e("div",{class:"modal-header",children:"Unsaved Changes"}),e("div",{class:"modal-body",children:e("p",{children:"You have unsaved changes. What would you like to do?"})}),e("div",{class:"modal-footer unsaved-dialog-footer",children:[e(R,{variant:"secondary",onClick:l,disabled:nt.value,children:"Cancel"}),e(R,{variant:"ghost",onClick:a,disabled:nt.value,children:"Discard & Navigate"}),e(R,{variant:"primary",onClick:n,loading:nt.value,children:"Save & Navigate"})]})]})})}class w extends Error{constructor(n,a,l){super(`[${n}] ${a}: ${l}`),this.status=n,this.code=a,this.serverMessage=l,this.name="ApiError"}}async function _t(t,n){const a={"Content-Type":"application/json",...n?.headers};pt.value!==null&&(a["X-Master-Password"]=pt.value);let l;try{l=await fetch(t,{...n,headers:a,signal:AbortSignal.timeout(1e4)})}catch(i){const s=i;throw s.name==="AbortError"||s.name==="TimeoutError"?new w(0,"TIMEOUT","Request timed out"):new w(0,"NETWORK_ERROR","Cannot connect to daemon")}if(l.status===401)throw t.startsWith("/v1/admin/")&&fn(),new w(401,"UNAUTHORIZED","Authentication failed");if(!l.ok){let i={};try{i=await l.json()}catch{}throw new w(l.status,i.code??"UNKNOWN",i.message??"Unknown error")}return mn(),await l.json()}const z=t=>_t(t,{method:"GET"}),se=(t,n)=>_t(t,{method:"POST",body:n?JSON.stringify(n):void 0}),he=(t,n)=>_t(t,{method:"PUT",body:n?JSON.stringify(n):void 0}),Ke=(t,n)=>_t(t,{method:"DELETE",body:n?JSON.stringify(n):void 0}),kl=(t,n)=>_t(t,{method:"PATCH",body:n?JSON.stringify(n):void 0});function Tl(t){const n=Math.floor(t/86400),a=Math.floor(t%86400/3600),l=Math.floor(t%3600/60);return n>0?`${n}d ${a}h ${l}m`:a>0?`${a}h ${l}m`:`${l}m`}function ve(t){const n=new Date(t*1e3),a=l=>l.toString().padStart(2,"0");return`${n.getFullYear()}-${a(n.getMonth()+1)}-${a(n.getDate())} ${a(n.getHours())}:${a(n.getMinutes())}`}function Pt(t){return t.length<=10?t:`${t.slice(0,4)}..${t.slice(-4)}`}const Nl=new Set(["KRW","JPY","VND","CLP","HUF","PKR"]),El=new Set(["KWD","BHD"]);function Al(t){return Nl.has(t)?0:El.has(t)?3:2}function Cl(t,n,a){const l=t*a,i=Al(n),s=new Intl.NumberFormat("en-US",{style:"currency",currency:n,minimumFractionDigits:i,maximumFractionDigits:i}).format(l);return n==="USD"?s:`≈${s}`}let Ve=null;const Il=300*1e3;async function Ht(){if(Ve&&Date.now()-Ve.fetchedAt<Il)return{currency:Ve.currency,rate:Ve.rate};try{const n=(await z(L.ADMIN_SETTINGS)).display?.["display.currency"]??"USD";if(n==="USD")return Ve={currency:"USD",rate:1,fetchedAt:Date.now()},{currency:"USD",rate:1};const i=(await z(`${L.ADMIN_FOREX_RATES}?currencies=${n}`)).rates[n]?.rate??null;return Ve={currency:n,rate:i,fetchedAt:Date.now()},{currency:n,rate:i}}catch{return{currency:"USD",rate:1}}}function mt(t,n,a){return t==null?"":a==null?`$${t.toFixed(2)}`:Cl(t,n,a)}function Ze({columns:t,data:n,onRowClick:a,emptyMessage:l="No data",loading:i=!1}){return e("div",{class:"table-container",children:e("table",{children:[e("thead",{children:e("tr",{children:t.map(s=>e("th",{style:s.width?{width:s.width}:void 0,children:s.header},s.key))})}),e("tbody",{children:i?e("tr",{children:e("td",{colSpan:t.length,class:"table-loading",children:"Loading..."})}):!n||n.length===0?e("tr",{children:e("td",{colSpan:t.length,class:"table-empty",children:l})}):n.map((s,r)=>e("tr",{class:a?"clickable":"",onClick:a?()=>a(s):void 0,children:t.map(c=>e("td",{children:c.render?c.render(s):s[c.key]},c.key))},r))})]})})}const Dl={INVALID_TOKEN:"Your authentication token is invalid. Please log in again.",TOKEN_EXPIRED:"Your session token has expired. Please log in again.",SESSION_REVOKED:"Your session has been revoked by an administrator.",INVALID_SIGNATURE:"The cryptographic signature is invalid.",INVALID_NONCE:"The authentication nonce is invalid or has expired.",INVALID_MASTER_PASSWORD:"Invalid master password. Please try again.",MASTER_PASSWORD_LOCKED:"Master password is locked due to too many failed attempts. Please wait.",SYSTEM_LOCKED:"The system is currently locked.",SESSION_NOT_FOUND:"Session not found.",SESSION_EXPIRED:"The session has expired.",SESSION_LIMIT_EXCEEDED:"Maximum number of sessions reached.",CONSTRAINT_VIOLATED:"A session constraint was violated.",RENEWAL_LIMIT_REACHED:"Session renewal limit has been reached. Create a new session.",SESSION_ABSOLUTE_LIFETIME_EXCEEDED:"Session has exceeded its maximum lifetime.",RENEWAL_TOO_EARLY:"Session renewal attempted too early. Please wait.",SESSION_RENEWAL_MISMATCH:"Session renewal count mismatch. The session may have been renewed elsewhere.",PIPELINE_HALTED:"Transaction is queued for delay or approval.",INSUFFICIENT_BALANCE:"Insufficient balance for this transaction.",INVALID_ADDRESS:"The blockchain address is invalid.",TX_NOT_FOUND:"Transaction not found.",TX_EXPIRED:"The transaction has expired.",TX_ALREADY_PROCESSED:"This transaction has already been processed.",CHAIN_ERROR:"A blockchain network error occurred. Please try again.",SIMULATION_FAILED:"Transaction simulation failed. The transaction may revert.",TOKEN_NOT_FOUND:"Token not found.",TOKEN_NOT_ALLOWED:"This token is not in the allowed list.",INSUFFICIENT_TOKEN_BALANCE:"Insufficient token balance.",CONTRACT_CALL_DISABLED:"Contract calls are disabled. Configure a CONTRACT_WHITELIST policy first.",CONTRACT_NOT_WHITELISTED:"This contract address is not whitelisted.",METHOD_NOT_WHITELISTED:"This contract method is not whitelisted.",APPROVE_DISABLED:"Token approvals are disabled. Configure an APPROVED_SPENDERS policy first.",SPENDER_NOT_APPROVED:"This spender address is not in the approved list.",APPROVE_AMOUNT_EXCEEDED:"The approve amount exceeds the configured limit.",UNLIMITED_APPROVE_BLOCKED:"Unlimited token approvals are blocked by policy.",BATCH_NOT_SUPPORTED:"Batch transactions are not supported on this chain.",BATCH_SIZE_EXCEEDED:"Batch contains too many instructions (maximum 20).",BATCH_POLICY_VIOLATION:"A policy violation occurred in the batch transaction.",POLICY_NOT_FOUND:"Policy not found.",POLICY_DENIED:"Transaction denied by policy.",SPENDING_LIMIT_EXCEEDED:"Spending limit has been exceeded.",RATE_LIMIT_EXCEEDED:"Rate limit exceeded. Please wait before retrying.",WHITELIST_DENIED:"The destination address is not in the whitelist.",OWNER_ALREADY_CONNECTED:"An owner wallet is already connected to this wallet.",OWNER_NOT_CONNECTED:"No owner wallet is connected to this wallet.",OWNER_NOT_FOUND:"Owner not found.",APPROVAL_TIMEOUT:"The approval request has timed out.",APPROVAL_NOT_FOUND:"Approval request not found.",OWNER_NOT_SET:"Owner address must be set before connecting WalletConnect.",OWNER_ADDRESS_MISMATCH:"Connected wallet address does not match registered owner.",KILL_SWITCH_ACTIVE:"Kill switch is active. All operations are suspended.",KILL_SWITCH_NOT_ACTIVE:"Kill switch is not currently active.",KEYSTORE_LOCKED:"The keystore is locked. Please try again.",CHAIN_NOT_SUPPORTED:"This blockchain is not supported.",SHUTTING_DOWN:"The daemon is shutting down.",ADAPTER_NOT_AVAILABLE:"Chain adapter is not available. Please try again.",WALLET_NOT_FOUND:"Wallet not found.",WALLET_SUSPENDED:"This wallet is currently suspended.",WALLET_TERMINATED:"This wallet has been terminated.",WC_NOT_CONFIGURED:"WalletConnect is not configured. Set the Project ID in Settings first.",WC_SESSION_NOT_FOUND:"No active WalletConnect session.",WC_SESSION_EXISTS:"A WalletConnect session already exists. Disconnect first.",WC_SIGNING_FAILED:"WalletConnect signing request failed.",NO_OWNER:"No owner connected. Withdrawal requires an owner wallet.",WITHDRAW_LOCKED_ONLY:"Withdrawal is only available when the owner state is LOCKED.",SWEEP_TOTAL_FAILURE:"All sweep operations failed. Please try again.",INSUFFICIENT_FOR_FEE:"Insufficient balance to cover transaction fees.",ACTION_NOT_FOUND:"Action not found.",ACTION_VALIDATION_FAILED:"Action input validation failed.",ACTION_RESOLVE_FAILED:"Action failed due to an external API error. Please try again.",ACTION_RETURN_INVALID:"Action returned an invalid result.",ACTION_PLUGIN_LOAD_FAILED:"Failed to load the action plugin.",ACTION_NAME_CONFLICT:"An action with this name already exists.",ACTION_CHAIN_MISMATCH:"The request chain does not match the action provider.",ROTATION_TOO_RECENT:"Key rotation was attempted too recently. Please wait.",NETWORK_ERROR:"Cannot connect to the daemon. Check if it is running.",TIMEOUT:"Request timed out. The daemon may be busy."},Ol=new Set(["ACTION_VALIDATION_FAILED","CONSTRAINT_VIOLATED","INVALID_ADDRESS","INVALID_SIGNATURE"]);function $(t,n){return n&&Ol.has(t)?n:Dl[t]??`An error occurred (${t}).`}const Oe=fe([]);let xl=0;function E(t,n){const a=xl++;Oe.value=[...Oe.value,{id:a,type:t,message:n}],setTimeout(()=>{Oe.value=Oe.value.filter(l=>l.id!==a)},5e3)}function Ll(t){Oe.value=Oe.value.filter(n=>n.id!==t)}function Rl(){return Oe.value.length===0?null:e("div",{class:"toast-container",children:Oe.value.map(t=>e("div",{class:`toast toast-${t.type}`,onClick:()=>Ll(t.id),children:t.message},t.id))})}const Pl={mainnet:"https://solscan.io/tx/{txHash}",devnet:"https://solscan.io/tx/{txHash}?cluster=devnet",testnet:"https://solscan.io/tx/{txHash}?cluster=testnet","ethereum-mainnet":"https://etherscan.io/tx/{txHash}","ethereum-sepolia":"https://sepolia.etherscan.io/tx/{txHash}","polygon-mainnet":"https://polygonscan.com/tx/{txHash}","polygon-amoy":"https://amoy.polygonscan.com/tx/{txHash}","arbitrum-mainnet":"https://arbiscan.io/tx/{txHash}","arbitrum-sepolia":"https://sepolia.arbiscan.io/tx/{txHash}","optimism-mainnet":"https://optimistic.etherscan.io/tx/{txHash}","optimism-sepolia":"https://sepolia-optimism.etherscan.io/tx/{txHash}","base-mainnet":"https://basescan.org/tx/{txHash}","base-sepolia":"https://sepolia.basescan.org/tx/{txHash}"};function Ml(t,n){const a=Pl[t];return a?a.replace("{txHash}",n):null}function Ul(t){return t.length<=16?t:t.slice(0,8)+"..."+t.slice(-6)}function gn({network:t,txHash:n,label:a}){if(!n)return null;const l=Ml(t,n),i=a??Ul(n);return l?e("a",{href:l,target:"_blank",rel:"noopener noreferrer",class:"explorer-link",children:i}):e("span",{class:"explorer-link-text",children:i})}function Se({label:t,value:n,loading:a,badge:l,href:i}){const s=e(Y,{children:[e("div",{class:"stat-label",children:[t,i&&e("span",{class:"stat-link-arrow",children:" →"})]}),a?e("div",{class:"stat-skeleton"}):l?e(B,{variant:l,children:n}):e("div",{class:"stat-value",children:n})]});return i?e("a",{href:i,class:"stat-card stat-card-link",style:{textDecoration:"none",color:"inherit",cursor:"pointer"},children:s}):e("div",{class:"stat-card",children:s})}function Wl(t,n){return[{key:"createdAt",header:"Time",render:a=>a.createdAt?ve(a.createdAt):"—"},{key:"walletName",header:"Wallet",render:a=>a.walletName??a.walletId.slice(0,8)},{key:"type",header:"Type"},{key:"amount",header:"Amount",render:a=>{if(!a.amount)return"—";const l=mt(a.amountUsd,t,n);return l?`${a.amount} (${l})`:a.amount}},{key:"network",header:"Network",render:a=>a.network??"—"},{key:"status",header:"Status",render:a=>{const l=a.status==="CONFIRMED"?"success":a.status==="FAILED"?"danger":"warning";return e(B,{variant:l,children:a.status})}},{key:"txHash",header:"Tx Hash",render:a=>e(gn,{network:a.network??"",txHash:a.txHash})}]}async function $l(t){try{await navigator.clipboard.writeText(t)}catch{const n=document.createElement("textarea");n.value=t,n.style.position="fixed",n.style.left="-9999px",document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n)}}function xn(){const t=d(null),n=d(!0),a=d(null),l=d("USD"),i=d(1),s=d(!1),r=d(null),c=d(null),h=async()=>{n.value=!0,a.value=null;try{const m=await z(L.ADMIN_STATUS);t.value=m}catch(m){m instanceof w?a.value=$(m.code):a.value="An unexpected error occurred."}finally{n.value=!1}},o=async()=>{s.value=!0;try{const m=await se(L.ADMIN_AGENT_PROMPT,{});if(m.walletCount===0){E("warning","No active wallets found");return}r.value=m.prompt,E("success",`Prompt generated for ${m.walletCount} wallet(s)`)}catch(m){m instanceof w?E("error",$(m.code)):E("error","Failed to generate agent prompt")}finally{s.value=!1}},v=async()=>{r.value&&(await $l(r.value),E("success","Copied to clipboard!"))};F(()=>{h(),Ht().then(({currency:N,rate:M})=>{l.value=N,i.value=M}).catch(()=>{}),z(L.ADMIN_TRANSACTIONS+"?status=APPROVED&limit=1").then(N=>{c.value=N.total}).catch(()=>{});const m=setInterval(h,3e4);return()=>clearInterval(m)},[]);const u=n.value&&!t.value;return e("div",{class:"page",children:[a.value&&e("div",{class:"dashboard-error",children:[e("span",{children:a.value}),e(R,{variant:"secondary",size:"sm",onClick:h,children:"Retry"})]}),t.value?.updateAvailable&&e("div",{class:"update-banner",role:"status",children:[e("span",{class:"update-banner-icon",children:"⬆"}),e("span",{children:[e("strong",{children:"Update available:"})," ",t.value.version," ","→"," ",t.value.latestVersion," — ","Run ",e("code",{children:"waiaas update"})," to update."]})]}),e("div",{class:"stat-grid",children:[e(Se,{label:"Version",value:t.value?.version??"—",loading:u,badge:t.value&&t.value.updateAvailable?"warning":void 0}),e(Se,{label:"Uptime",value:t.value?Tl(t.value.uptime):"—",loading:u}),e(Se,{label:"Wallets",value:t.value?.walletCount?.toString()??"—",loading:u,href:"#/wallets"}),e(Se,{label:"Active Sessions",value:t.value?.activeSessionCount?.toString()??"—",loading:u,href:"#/sessions"})]}),e("div",{class:"stat-grid",style:{marginTop:"var(--space-4)"},children:[e(Se,{label:"Kill Switch",value:t.value?.killSwitchState==="ACTIVATED"?"ACTIVATED":"NORMAL",loading:u,badge:t.value?t.value.killSwitchState==="ACTIVATED"?"danger":"success":void 0}),e(Se,{label:"Status",value:t.value?.status??"—",loading:u})]}),e("div",{class:"stat-grid",style:{marginTop:"var(--space-4)"},children:[e(Se,{label:"Policies",value:t.value?.policyCount?.toString()??"—",loading:u,href:"#/policies"}),e(Se,{label:"Recent Txns (24h)",value:t.value?.recentTxCount?.toString()??"—",loading:u,href:"#/transactions"}),e(Se,{label:"Failed Txns (24h)",value:t.value?.failedTxCount?.toString()??"—",loading:u,badge:t.value?t.value.failedTxCount===0?"success":"danger":void 0,href:"#/transactions?status=FAILED"}),e(Se,{label:"Approval Pending",value:c.value?.toString()??"—",loading:u,badge:c.value!=null&&c.value>0?"warning":void 0,href:"#/transactions?status=APPROVED"})]}),e("div",{class:"prompt-card",style:{marginTop:"var(--space-4)"},children:[e("h3",{style:{marginBottom:"var(--space-2)"},children:"Agent Connection Prompt"}),e("p",{class:"prompt-card-desc",children:"Generate a connection prompt for AI agents. Creates sessions for all active wallets."}),r.value?e(Y,{children:[e("pre",{class:"prompt-preview",children:r.value}),e("div",{style:{display:"flex",gap:"var(--space-2)",marginTop:"var(--space-3)"},children:[e(R,{variant:"primary",size:"sm",onClick:v,children:"Copy to Clipboard"}),e(R,{variant:"secondary",size:"sm",onClick:o,loading:s.value,children:"Regenerate"})]})]}):e(R,{variant:"primary",size:"sm",onClick:o,loading:s.value,style:{marginTop:"var(--space-2)"},children:"Generate"})]}),e("div",{style:{marginTop:"var(--space-4)"},children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"Recent Activity"}),e(Ze,{columns:Wl(l.value,i.value),data:t.value?.recentTransactions??[],loading:u,emptyMessage:"No recent transactions"})]})]})}function be({open:t,title:n,children:a,onConfirm:l,onCancel:i,confirmText:s="Confirm",cancelText:r="Cancel",confirmVariant:c="primary",confirmDisabled:h=!1,loading:o=!1}){return F(()=>{if(!t)return;const v=u=>{u.key==="Escape"&&i()};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[t,i]),t?e("div",{class:"modal-overlay",onClick:i,children:e("div",{class:"modal-card",onClick:v=>v.stopPropagation(),children:[e("div",{class:"modal-header",children:n}),e("div",{class:"modal-body",children:a}),e("div",{class:"modal-footer",children:[e(R,{variant:"secondary",onClick:i,disabled:o,children:r}),l&&e(R,{variant:c,onClick:l,loading:o,disabled:h,children:s})]})]})}):null}function ft({value:t,label:n}){const a=d(!1);return e("button",{class:"btn btn-ghost btn-sm",onClick:async()=>{try{await navigator.clipboard.writeText(t)}catch{const i=document.createElement("textarea");i.value=t,i.style.position="fixed",i.style.left="-9999px",document.body.appendChild(i),i.select(),document.execCommand("copy"),document.body.removeChild(i)}a.value=!0,setTimeout(()=>{a.value=!1},2e3)},children:a.value?"Copied!":n??"Copy"})}function Ln({title:t,description:n,actionLabel:a,onAction:l}){return e("div",{class:"empty-state",children:[e("h3",{children:t}),n&&e("p",{children:n}),a&&l&&e("button",{class:"btn btn-primary",onClick:l,children:a})]})}function He({tabs:t,activeTab:n,onTabChange:a}){return e("div",{class:"tab-nav",children:t.map(l=>e("button",{class:`tab-btn ${n===l.key?"active":""}`,onClick:()=>{l.key!==n&&(Na.value?Ea({type:"tab",execute:()=>a(l.key)}):a(l.key))},children:l.label},l.key))})}function Qe({pageName:t,tabName:n,onPageClick:a}){return n?e("nav",{class:"breadcrumb","aria-label":"Breadcrumb",children:[e("button",{class:"breadcrumb-page",onClick:a,type:"button",children:t}),e("span",{class:"breadcrumb-separator","aria-hidden":"true",children:">"}),e("span",{class:"breadcrumb-current","aria-current":"page",children:n})]}):null}function Aa({value:t,onSearch:n,placeholder:a="Search...",debounceMs:l=300}){const i=gt(null);function s(c){const h=c.target.value;i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>{n(h),i.current=null},l)}function r(){i.current!==null&&(clearTimeout(i.current),i.current=null),n("")}return e("div",{class:"search-input",children:[e("input",{type:"text",value:t,placeholder:a,onInput:s}),t&&e("button",{class:"search-clear",type:"button",onClick:r,children:"x"})]})}function Kl(){const t=window.location.hash,n=t.indexOf("?");if(n===-1)return{};const a=new URLSearchParams(t.slice(n+1)),l={};return a.forEach((i,s)=>{l[s]=i}),l}function Rn(t){const n=window.location.hash,a=n.indexOf("?"),l=a===-1?n:n.slice(0,a),i=new URLSearchParams;for(const[c,h]of Object.entries(t))h&&i.set(c,h);const s=i.toString(),r=s?`${l}?${s}`:l;window.history.replaceState(null,"",r)}function Bt({fields:t,values:n,onChange:a,syncUrl:l=!0}){F(()=>{if(!l)return;const r=Kl(),c={...n};let h=!1;for(const o of t){const v=r[o.key];v!==void 0&&v!==c[o.key]&&(c[o.key]=v,h=!0)}h&&a(c)},[]);function i(r,c){const h={...n,[r]:c};a(h),l&&Rn(h)}function s(){const r={};for(const c of t)r[c.key]="";a(r),l&&Rn(r)}return e("div",{class:"filter-bar",children:[t.map(r=>e("div",{class:"filter-field",children:[e("label",{children:r.label}),r.type==="select"?e("select",{value:n[r.key]??"",onChange:c=>i(r.key,c.target.value),children:[e("option",{value:"",children:"All"}),r.options?.map(c=>e("option",{value:c.value,children:c.label},c.value))]}):e("input",{type:"date",value:n[r.key]??"",placeholder:r.placeholder,onChange:c=>i(r.key,c.target.value)})]},r.key)),e("button",{class:"btn btn-secondary filter-clear",type:"button",onClick:s,children:"Clear"})]})}const Fl=new Set(["notifications.telegram_bot_token","notifications.discord_webhook_url","notifications.slack_webhook_url","telegram.bot_token"]);function Hl(t){return Fl.has(t)}function V(t){return{enabled:"Enabled",telegram_bot_token:"Telegram Bot Token",telegram_chat_id:"Telegram Chat ID",discord_webhook_url:"Discord Webhook URL",ntfy_server:"Ntfy Server",ntfy_topic:"Ntfy Topic",locale:"Locale",rate_limit_rpm:"Rate Limit (RPM)",solana_mainnet:"Solana Mainnet",solana_devnet:"Solana Devnet",solana_testnet:"Solana Testnet",evm_ethereum_mainnet:"Ethereum Mainnet",evm_ethereum_sepolia:"Ethereum Sepolia",evm_polygon_mainnet:"Polygon Mainnet",evm_polygon_amoy:"Polygon Amoy",evm_arbitrum_mainnet:"Arbitrum Mainnet",evm_arbitrum_sepolia:"Arbitrum Sepolia",evm_optimism_mainnet:"Optimism Mainnet",evm_optimism_sepolia:"Optimism Sepolia",evm_base_mainnet:"Base Mainnet",evm_base_sepolia:"Base Sepolia",evm_default_network:"Default EVM Network",session_ttl:"Session TTL (seconds)",max_sessions_per_wallet:"Max Sessions per Wallet",max_pending_tx:"Max Pending Transactions",rate_limit_global_ip_rpm:"Global IP Rate Limit (RPM)",rate_limit_session_rpm:"Session Rate Limit (RPM)",rate_limit_tx_rpm:"Transaction Rate Limit (RPM)",policy_defaults_delay_seconds:"Policy Delay (seconds)",policy_defaults_approval_timeout:"Approval Timeout (seconds)",default_deny_tokens:"Default Deny: Token Transfers",default_deny_contracts:"Default Deny: Contract Calls",default_deny_spenders:"Default Deny: Token Approvals",default_deny_x402_domains:"Default Deny: x402 Domains",project_id:"Project ID",log_level:"Log Level",currency:"Display Currency",consecutive_failures_threshold:"Consecutive Failures Threshold",unusual_activity_threshold:"Unusual Activity Threshold",unusual_activity_window_sec:"Unusual Activity Window (seconds)",idle_timeout_sec:"Idle Timeout (seconds)",idle_check_interval_sec:"Idle Check Interval (seconds)",check_interval_sec:"Check Interval (seconds)",low_balance_threshold_sol:"Low Balance Threshold (SOL)",low_balance_threshold_eth:"Low Balance Threshold (ETH)",cooldown_hours:"Alert Cooldown (hours)",relay_url:"Relay URL",session_absolute_lifetime:"Absolute Lifetime (seconds)",session_max_renewals:"Max Renewals",bot_token:"Bot Token",request_expiry_min:"Request Expiry (minutes)",preferred_channel:"Preferred Channel",preferred_wallet:"Preferred Wallet",ntfy_request_topic_prefix:"Ntfy Request Topic Prefix",ntfy_response_topic_prefix:"Ntfy Response Topic Prefix",wallets:"Registered Wallets (JSON)",poll_interval_sec:"Poll Interval (seconds)",default_timeout_sec:"Default Timeout (seconds)",max_timeout_sec:"Max Timeout (seconds)",max_pending_count:"Max Pending Count"}[t]??t.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function J(t,n,a,l){const i=`${a}.${l}`;if(n[i]!==void 0)return n[i];const s=t[a];if(!s)return"";const r=s[l];return typeof r=="boolean"?Hl(i)?"":String(r):r??""}function xe(t,n,a,l){const i=`${a}.${l}`;if(n[i]!==void 0)return n[i]==="true";const s=t[a];if(!s)return!1;const r=s[l];return typeof r=="boolean"?r:r==="true"}function rt(t,n,a,l){const i=`${a}.${l}`;if(n[i]!==void 0)return!1;const s=t[a];return s?s[l]===!0:!1}function Ca(t){switch(t){case"NONE":return"neutral";case"GRACE":return"warning";case"LOCKED":return"success";default:return"neutral"}}function oe({label:t,value:n,copy:a,children:l}){return e("div",{class:"detail-row",children:[e("div",{class:"detail-row-label",children:t}),e("div",{class:"detail-row-value",children:[l??n??"—",a&&n&&e(ft,{value:n})]})]})}const Bl=[{value:null,label:"Auto (Global Fallback)",description:"System decides based on configured channels: Wallet App (ntfy) > Wallet App (Telegram) > WalletConnect > Telegram Bot > REST"},{value:"sdk_ntfy",label:"Wallet App (ntfy)",description:"Push sign request to wallet app via ntfy server",warning:"Signing SDK is not enabled. Go to System > Signing SDK settings.",warningCondition:t=>!t?.signingEnabled},{value:"sdk_telegram",label:"Wallet App (Telegram)",description:"Push sign request to wallet app via Telegram with universal link",warning:"Signing SDK or Telegram bot is not configured. Check System > Signing SDK and Notifications > Telegram settings.",warningCondition:t=>!t?.signingEnabled||!t?.telegramBotConfigured},{value:"walletconnect",label:"WalletConnect",description:"Approve via connected WalletConnect wallet (D'CENT, MetaMask, etc.)",warning:"WalletConnect project ID is not configured. Go to Wallets > WalletConnect tab.",warningCondition:t=>!t?.wcConfigured},{value:"telegram_bot",label:"Telegram Bot",description:"Approve/reject via Telegram bot /approve and /reject commands",warning:"Telegram bot token is not configured. Go to Notifications > Settings > Telegram.",warningCondition:t=>!t?.telegramBotConfigured},{value:"rest",label:"REST API",description:"Manual approval via REST API endpoints (POST /approve, /reject)"}],Vl=[{key:"overview",label:"Overview"},{key:"transactions",label:"Transactions"},{key:"owner",label:"Owner"},{key:"staking",label:"Staking"},{key:"mcp",label:"MCP"}],at=20,Gl=[{value:"PENDING",label:"PENDING"},{value:"APPROVED",label:"APPROVED"},{value:"SUBMITTED",label:"SUBMITTED"},{value:"CONFIRMED",label:"CONFIRMED"},{value:"FAILED",label:"FAILED"}],zl=[{value:"TRANSFER",label:"TRANSFER"},{value:"TOKEN_TRANSFER",label:"TOKEN_TRANSFER"},{value:"CONTRACT_CALL",label:"CONTRACT_CALL"},{value:"APPROVE",label:"APPROVE"},{value:"BATCH",label:"BATCH"}],ql=[{key:"status",label:"Status",type:"select",options:Gl},{key:"type",label:"Type",type:"select",options:zl}],qt=["Time","Type","To","Amount","Network","Status","Tx Hash"];function jl(t){return t==="CONFIRMED"?"success":t==="FAILED"?"danger":"warning"}function Yl({id:t}){const n=d(null),a=d(!0),l=d(!1),i=d(""),s=d(!1),r=d(!1),c=d(!1),h=d(!1),o=d(null),v=d([]),u=d(!0),m=d(!1),N=d(null),M=d(!0),I=d([]),_=d(!0),D=d(0),P=d(0),K=d({status:"",type:""}),y=d(!1),b=d(null),U=d(!1),S=d(null),p=d(!0),g=d(!1),f=d(null),O=d(!1),W=d(""),q=d(!1),ae=d(null),H=d(!1),ne=d(!1),de=d(""),re=d(!1),me=d("overview"),ie=d("USD"),Pe=d(1),Ee=d([]),Ae=d(!0),we=async()=>{try{const T=await z(L.WALLET(t));n.value=T}catch(T){const G=T instanceof w?T:new w(0,"UNKNOWN","Unknown error");E("error",$(G.code))}finally{a.value=!1}},et=async()=>{s.value=!0;try{const T=await he(L.WALLET(t),{name:i.value});n.value=T,l.value=!1,E("success","Wallet name updated")}catch(T){const G=T instanceof w?T:new w(0,"UNKNOWN","Unknown error");E("error",$(G.code))}finally{s.value=!1}},x=async()=>{c.value=!0;try{await Ke(L.WALLET(t)),E("success","Wallet terminated"),window.location.hash="#/wallets"}catch(T){const G=T instanceof w?T:new w(0,"UNKNOWN","Unknown error");E("error",$(G.code))}finally{c.value=!1}},te=async()=>{ne.value=!0;try{await se(L.WALLET_SUSPEND(t),{reason:de.value.trim()||void 0}),E("success","Wallet suspended"),H.value=!1,de.value="",await we()}catch(T){const G=T instanceof w?T:new w(0,"UNKNOWN","Unknown error");E("error",$(G.code))}finally{ne.value=!1}},ye=async()=>{re.value=!0;try{await se(L.WALLET_RESUME(t)),E("success","Wallet resumed"),await we()}catch(T){const G=T instanceof w?T:new w(0,"UNKNOWN","Unknown error");E("error",$(G.code))}finally{re.value=!1}},Vt=()=>{i.value=n.value.name,l.value=!0},Gt=()=>{l.value=!1},k=async()=>{h.value=!0;try{const T=await se(L.MCP_TOKENS,{walletId:t});o.value=T,E("success","MCP token provisioned successfully")}catch(T){const G=T instanceof w?T:new w(0,"UNKNOWN","Unknown error");E("error",$(G.code))}finally{h.value=!1}},C=async()=>{u.value=!0;try{const T=await z(L.WALLET_NETWORKS(t));v.value=T.availableNetworks??[]}catch(T){const G=T instanceof w?T:new w(0,"UNKNOWN","Unknown error");E("error",$(G.code)),v.value=[]}finally{u.value=!1}},Z=async()=>{M.value=!0;try{N.value=await z(L.ADMIN_WALLET_BALANCE(t))}catch{N.value=null}finally{M.value=!1}},ue=async T=>{_.value=!0;try{const X=(T??P.value)*at,wt=await z(`${L.ADMIN_WALLET_TRANSACTIONS(t)}?offset=${X}&limit=${at}`);I.value=wt.items,D.value=wt.total}catch{I.value=[],D.value=0}finally{_.value=!1}},Me=Ft(()=>{let T=I.value;const G=K.value;return G.status&&(T=T.filter(X=>X.status===G.status)),G.type&&(T=T.filter(X=>X.type===G.type)),T}),Be=async()=>{Ae.value=!0;try{const T=await z(L.ADMIN_WALLET_STAKING(t));Ee.value=T.positions??[]}catch{Ee.value=[]}finally{Ae.value=!1}},j=async()=>{p.value=!0;try{S.value=await z(L.WALLET_WC_SESSION(t))}catch{S.value=null}finally{p.value=!1}},tt=()=>{f.value&&clearInterval(f.value),f.value=setInterval(async()=>{try{const T=await z(L.WALLET_WC_PAIR_STATUS(t));T.status==="connected"?(f.value&&clearInterval(f.value),f.value=null,y.value=!1,b.value=null,S.value=T.session??null,E("success","Wallet connected via WalletConnect")):(T.status==="expired"||T.status==="none")&&(f.value&&clearInterval(f.value),f.value=null,y.value=!1,b.value=null,E("error","Pairing expired. Try again."))}catch{}},3e3)},bt=async()=>{U.value=!0;try{const T=await se(L.WALLET_WC_PAIR(t));b.value=T,y.value=!0,tt()}catch(T){const G=T instanceof w?T:new w(0,"UNKNOWN","Unknown error");G.code==="WC_NOT_CONFIGURED"?(E("error","WalletConnect is not configured. Redirecting to settings..."),le.value={tab:"walletconnect",fieldName:"walletconnect.project_id"},window.location.hash="#/wallets"):E("error",$(G.code))}finally{U.value=!1}},Da=async()=>{g.value=!0;try{await Ke(L.WALLET_WC_SESSION(t)),S.value=null,E("success","WalletConnect session disconnected")}catch(T){const G=T instanceof w?T:new w(0,"UNKNOWN","Unknown error");E("error",$(G.code))}finally{g.value=!1}},yn=()=>{W.value=n.value?.ownerAddress??"",O.value=!0},Oa=()=>{O.value=!1},xa=async()=>{if(!W.value.trim()){E("error","Owner address is required");return}q.value=!0;try{await he(L.WALLET_OWNER(t),{owner_address:W.value.trim()}),await we(),O.value=!1,E("success","Owner address updated")}catch(T){const G=T instanceof w?T:new w(0,"UNKNOWN","Unknown error");E("error",$(G.code,G.serverMessage))}finally{q.value=!1}},La=async T=>{m.value=!0;try{await he(L.WALLET_DEFAULT_NETWORK(t),{network:T}),E("success",`Default network changed to ${T}`),await we(),await C()}catch(G){const X=G instanceof w?G:new w(0,"UNKNOWN","Unknown error");E("error",$(X.code))}finally{m.value=!1}},Ra=async()=>{try{const T=await z(L.ADMIN_SETTINGS),G=T.signing_sdk?.enabled==="true",X=T.telegram?.bot_token===!0,wt=!!T.walletconnect?.project_id&&T.walletconnect.project_id!=="";ae.value={signingEnabled:G,telegramBotConfigured:X,wcConfigured:wt}}catch{}},Pa=async T=>{try{await he(L.WALLET_OWNER(t),{owner_address:n.value.ownerAddress,approval_method:T??null}),await we(),E("success","Approval method updated")}catch(G){const X=G instanceof w?G:new w(0,"UNKNOWN","Unknown error");E("error",$(X.code,X.serverMessage))}};F(()=>{we(),C(),Z(),ue(),j(),Be(),Ra(),Ht().then(({currency:T,rate:G})=>{ie.value=T,Pe.value=G}).catch(()=>{})},[t]),F(()=>()=>{f.value&&clearInterval(f.value)},[]),F(()=>{ue()},[P.value]);const _n=P.value*at,Ma=D.value>0?_n+1:0,Ua=Math.min(_n+at,D.value),Wa=P.value>0,$a=(P.value+1)*at<D.value;function Ka(){return n.value?e(Y,{children:[e("div",{class:"detail-grid",children:[e(oe,{label:"ID",value:n.value.id,copy:!0}),e(oe,{label:"Public Key",value:n.value.publicKey,copy:!0}),e(oe,{label:"Chain",value:n.value.chain}),e(oe,{label:"Environment",children:e(B,{variant:n.value.environment==="mainnet"?"warning":"info",children:n.value.environment})}),e(oe,{label:"Default Network",value:n.value.defaultNetwork??n.value.network}),e(oe,{label:"Status",children:e(B,{variant:n.value.status==="ACTIVE"?"success":n.value.status==="SUSPENDED"?"warning":"danger",children:n.value.status})}),n.value.status==="SUSPENDED"&&e(Y,{children:[e(oe,{label:"Suspended At",value:n.value.suspendedAt?ve(n.value.suspendedAt):"--"}),e(oe,{label:"Suspension Reason",value:n.value.suspensionReason??"--"})]}),e(oe,{label:"Created",value:ve(n.value.createdAt)}),e(oe,{label:"Updated",value:n.value.updatedAt?ve(n.value.updatedAt):"Never"})]}),e("div",{class:"balance-section",style:{marginTop:"var(--space-6)"},children:[e("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-3)",marginBottom:"var(--space-3)"},children:[e("h3",{style:{margin:0},children:"Balances"}),e(R,{variant:"secondary",size:"sm",onClick:Z,loading:M.value,children:"Refresh"})]}),M.value?e("div",{class:"stat-skeleton",style:{height:"60px"}}):N.value?.balances?.length?e("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-3)"},children:N.value.balances.map(T=>e("div",{style:{padding:"var(--space-3)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",background:T.isDefault?"var(--color-bg-secondary)":"transparent"},children:[e("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)",marginBottom:"var(--space-2)"},children:[e("strong",{children:T.network}),T.isDefault&&e("span",{class:"badge badge-info",style:{fontSize:"0.7rem"},children:"Default"})]}),T.error?e("p",{style:{color:"var(--color-text-secondary)",fontSize:"0.85rem"},children:T.error}):T.native?e("div",{children:[e(oe,{label:"Native",children:e("span",{children:[T.native.balance," ",T.native.symbol,T.native.usd!=null&&e("span",{style:{color:"var(--color-text-secondary)",marginLeft:"var(--space-2)",fontSize:"0.85rem"},children:["(",mt(T.native.usd,ie.value,Pe.value),")"]})]})}),T.tokens.length>0?T.tokens.map(G=>e(oe,{label:G.symbol,value:G.balance},G.address)):null]}):e("p",{style:{color:"var(--color-text-secondary)",fontSize:"0.85rem"},children:"Balance unavailable"})]},T.network))}):e("p",{style:{color:"var(--color-text-secondary)"},children:"No balance data available"})]}),e("div",{class:"networks-section",style:{marginTop:"var(--space-6)"},children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"Available Networks"}),u.value?e("div",{class:"stat-skeleton",style:{height:"80px"}}):e("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2)"},children:(v.value??[]).map(T=>e("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"var(--space-2) var(--space-3)",background:"var(--color-bg-secondary)",borderRadius:"var(--radius-md)"},children:[e("span",{children:[T.name??T.network,T.isDefault&&e("span",{style:{marginLeft:"var(--space-2)",display:"inline-block"},children:e(B,{variant:"success",children:"Default"})})]}),!T.isDefault&&n.value?.status==="ACTIVE"&&e(R,{size:"sm",variant:"secondary",onClick:()=>La(T.network),loading:m.value,children:"Set Default"})]},T.network))})]})]}):null}function Fa(){return e(Y,{children:[e(Bt,{fields:ql,values:K.value,onChange:T=>{K.value=T},syncUrl:!1}),e("div",{class:"table-container",style:{marginTop:"var(--space-3)"},children:e("table",{children:[e("thead",{children:e("tr",{children:qt.map(T=>e("th",{children:T},T))})}),e("tbody",{children:_.value&&Me.value.length===0?e("tr",{children:e("td",{colSpan:qt.length,class:"table-loading",children:"Loading..."})}):Me.value.length===0?e("tr",{children:e("td",{colSpan:qt.length,class:"table-empty",children:"No transactions yet"})}):Me.value.map(T=>e("tr",{children:[e("td",{children:T.createdAt?ve(T.createdAt):"—"}),e("td",{children:e(B,{variant:"info",children:T.type})}),e("td",{children:T.toAddress?Pt(T.toAddress):"—"}),e("td",{children:T.amount?T.formattedAmount??T.amount:"—"}),e("td",{children:T.network??"—"}),e("td",{children:e(B,{variant:jl(T.status),children:T.status})}),e("td",{children:e(gn,{network:T.network??"",txHash:T.txHash})})]},T.id))})]})}),e("div",{class:"pagination",style:{marginTop:"var(--space-3)"},children:[e("span",{class:"pagination-info",children:["Showing ",Ma,"-",Ua," of ",D.value]}),e("div",{class:"pagination-buttons",children:[e(R,{variant:"secondary",size:"sm",disabled:!Wa,onClick:()=>{P.value=P.value-1},children:"Previous"}),e(R,{variant:"secondary",size:"sm",disabled:!$a,onClick:()=>{P.value=P.value+1},children:"Next"})]})]})]})}function Ha(){return n.value?e("div",{class:"owner-section",children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"Owner Wallet"}),n.value.ownerState==="NONE"&&n.value.status!=="TERMINATED"&&e("div",{style:{background:"var(--color-bg-secondary)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"var(--space-3) var(--space-4)",marginBottom:"var(--space-4)"},children:[e("p",{style:{marginBottom:"var(--space-2)",fontWeight:500},children:"What is an Owner Wallet?"}),e("p",{style:{color:"var(--color-text-secondary)",fontSize:"0.85rem",marginBottom:"var(--space-3)"},children:"Register an Owner wallet to enable transaction approval (APPROVAL policy) for high-value transfers. Connect D'CENT, MetaMask, or other WalletConnect-compatible wallets to approve transactions directly."}),e(R,{size:"sm",onClick:yn,children:"Set Owner Address"})]}),e(oe,{label:"Address",children:O.value?e("div",{class:"inline-edit",children:[e("input",{value:W.value,onInput:T=>{W.value=T.target.value},class:"inline-edit-input",placeholder:"Enter owner wallet address"}),e(R,{size:"sm",onClick:xa,loading:q.value,children:"Save"}),e(R,{size:"sm",variant:"secondary",onClick:Oa,children:"Cancel"})]}):e("span",{children:[n.value.ownerAddress?e(Y,{children:[Pt(n.value.ownerAddress),e(ft,{value:n.value.ownerAddress})]}):"Not set",n.value.ownerState!=="LOCKED"&&n.value.status==="ACTIVE"&&e("button",{class:"btn btn-ghost btn-sm",onClick:yn,title:"Set owner address",children:"✎"})]})}),e(oe,{label:"State",children:e(B,{variant:Ca(n.value.ownerState),children:n.value.ownerState})}),n.value.ownerState==="GRACE"&&e("div",{style:{background:"var(--color-bg-secondary)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"var(--space-3) var(--space-4)",marginTop:"var(--space-3)"},children:[e("p",{style:{marginBottom:"var(--space-2)",fontWeight:500,fontSize:"0.85rem"},children:"Verify Owner"}),e("p",{style:{color:"var(--color-text-secondary)",fontSize:"0.85rem"},children:"Sign a verification message with the Owner wallet to transition from GRACE to LOCKED. Connect via WalletConnect first, then trigger an APPROVAL-tier transaction or use the CLI/SDK to call the verify endpoint."})]}),n.value.ownerState!=="NONE"&&e("div",{style:{marginTop:"var(--space-4)",paddingTop:"var(--space-3)",borderTop:"1px solid var(--color-border)"},children:[e("h4",{style:{marginBottom:"var(--space-2)",fontSize:"0.9rem"},children:"Approval Method"}),e("p",{style:{color:"var(--color-text-secondary)",fontSize:"0.85rem",marginBottom:"var(--space-3)"},children:'Choose how transaction approvals are delivered to the owner. Leave as "Auto (Global Fallback)" to use the system-wide priority.'}),e("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2)"},children:Bl.map(T=>e("label",{style:{display:"flex",alignItems:"flex-start",gap:"var(--space-2)",padding:"var(--space-2) var(--space-3)",background:n.value?.approvalMethod===T.value?"var(--color-bg-secondary)":"transparent",borderRadius:"var(--radius-md)",cursor:"pointer"},children:[e("input",{type:"radio",name:"approval_method",value:T.value??"",checked:n.value?.approvalMethod===T.value,onChange:()=>Pa(T.value),style:{marginTop:"2px"}}),e("div",{children:[e("div",{style:{fontWeight:500,fontSize:"0.9rem"},children:T.label}),e("div",{style:{color:"var(--color-text-secondary)",fontSize:"0.8rem"},children:T.description}),T.warning&&T.warningCondition?.(ae.value)&&e("div",{style:{marginTop:"var(--space-1)",padding:"var(--space-1) var(--space-2)",background:"var(--color-warning-bg, #fff3cd)",border:"1px solid var(--color-warning-border, #ffc107)",borderRadius:"var(--radius-sm)",fontSize:"0.75rem",color:"var(--color-warning-text, #856404)"},children:T.warning})]})]},T.value??"auto"))})]}),e("div",{style:{marginTop:"var(--space-4)",paddingTop:"var(--space-3)",borderTop:"1px solid var(--color-border)"},children:[e("h4",{style:{marginBottom:"var(--space-2)",fontSize:"0.9rem"},children:"WalletConnect"}),p.value?e("div",{class:"stat-skeleton",style:{height:"60px"}}):S.value?e("div",{children:[e(oe,{label:"Status",children:e(B,{variant:"success",children:"Connected"})}),e(oe,{label:"Peer",value:S.value.peerName??"Unknown"}),e(oe,{label:"Chain ID",value:S.value.chainId}),e(oe,{label:"Expires",value:ve(S.value.expiry)}),e("div",{style:{marginTop:"var(--space-3)"},children:e(R,{variant:"danger",onClick:Da,loading:g.value,children:"Disconnect"})})]}):e("div",{children:[e("p",{style:{marginBottom:"var(--space-3)",color:"var(--color-text-secondary)",fontSize:"0.85rem"},children:"Connect an external wallet (D'CENT, MetaMask, Phantom) via WalletConnect for transaction approval."}),n.value?.ownerAddress?e(R,{onClick:bt,loading:U.value,children:"Connect Wallet"}):e("p",{style:{color:"var(--color-text-secondary)",fontSize:"0.85rem"},children:"Set an Owner address first to enable WalletConnect."})]})]})]}):null}function Ba(){function T(X){return X==="lido"?"info":"neutral"}function G(X){return X==="COMPLETED"?"success":X==="TIMEOUT"?"danger":"warning"}return e("div",{children:[e("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-3)",marginBottom:"var(--space-3)"},children:[e("h3",{style:{margin:0},children:"Staking Positions"}),e(R,{variant:"secondary",size:"sm",onClick:Be,loading:Ae.value,children:"Refresh"})]}),Ae.value?e("div",{class:"stat-skeleton",style:{height:"80px"}}):Ee.value.length===0?e(Ln,{title:"No staking positions",description:"Stake ETH (Lido) or SOL (Jito) to see positions here."}):e("div",{class:"table-container",children:e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"Protocol"}),e("th",{children:"Asset"}),e("th",{children:"Balance"}),e("th",{children:"Balance (USD)"}),e("th",{children:"APY"}),e("th",{children:"Pending Unstake"})]})}),e("tbody",{children:Ee.value.map(X=>e("tr",{children:[e("td",{children:e(B,{variant:T(X.protocol),children:X.protocol==="lido"?"Lido":"Jito"})}),e("td",{children:X.asset}),e("td",{children:X.chain==="ethereum"?`${(Number(X.balance)/1e18).toFixed(6)} stETH`:`${(Number(X.balance)/1e9).toFixed(6)} JitoSOL`}),e("td",{children:X.balanceUsd?mt(Number(X.balanceUsd),ie.value,Pe.value):"—"}),e("td",{children:X.apy??"—"}),e("td",{children:X.pendingUnstake?e("span",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)"},children:[e(B,{variant:G(X.pendingUnstake.status),children:X.pendingUnstake.status}),e("span",{style:{fontSize:"0.85em",color:"var(--color-text-secondary)"},children:X.chain==="ethereum"?`${(Number(X.pendingUnstake.amount)/1e18).toFixed(4)} stETH`:`${(Number(X.pendingUnstake.amount)/1e9).toFixed(4)} JitoSOL`})]}):"—"})]},`${X.protocol}-${X.chain}`))})]})})]})}function Va(){return e("div",{class:"mcp-setup-section",children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"MCP Setup"}),o.value?e("div",{children:[e("div",{class:"detail-grid",style:{marginBottom:"var(--space-4)"},children:[e(oe,{label:"Token Path",value:o.value.tokenPath}),e(oe,{label:"Expires At",value:ve(o.value.expiresAt)})]}),e("div",{style:{marginBottom:"var(--space-2)"},children:e("strong",{children:"Claude Desktop Config"})}),e("div",{style:{position:"relative"},children:[e("pre",{children:e("code",{style:{display:"block",whiteSpace:"pre-wrap",wordBreak:"break-all",background:"var(--color-bg-secondary)",padding:"var(--space-3)",borderRadius:"var(--radius-md)",fontSize:"0.85rem",maxHeight:"300px",overflow:"auto"},children:JSON.stringify({mcpServers:o.value.claudeDesktopConfig},null,2)})}),e("div",{style:{marginTop:"var(--space-2)"},children:e(ft,{value:JSON.stringify({mcpServers:o.value.claudeDesktopConfig},null,2),label:"Copy Config"})})]}),e("div",{style:{marginTop:"var(--space-3)"},children:e(R,{variant:"secondary",onClick:k,loading:h.value,children:"Re-provision"})})]}):e("div",{children:[e("p",{style:{marginBottom:"var(--space-3)",color:"var(--color-text-secondary)"},children:"Provision an MCP token for Claude Desktop integration."}),e(R,{onClick:k,loading:h.value,children:"Setup MCP"})]})]})}return e("div",{class:"page",children:[e("a",{href:"#/wallets",class:"back-link",children:"← Back to Wallets"}),a.value?e("div",{class:"stat-skeleton",style:{height:"200px",marginTop:"var(--space-4)"}}):n.value?e("div",{class:"wallet-detail",children:[e("div",{class:"detail-header",children:[e("div",{class:"detail-name",children:l.value?e("div",{class:"inline-edit",children:[e("input",{value:i.value,onInput:T=>{i.value=T.target.value},class:"inline-edit-input"}),e(R,{size:"sm",onClick:et,loading:s.value,children:"Save"}),e(R,{size:"sm",variant:"secondary",onClick:Gt,children:"Cancel"})]}):e("span",{children:[n.value.name,e("button",{class:"btn btn-ghost btn-sm",onClick:Vt,title:"Edit name",children:"✎"})]})}),e("div",{style:{display:"flex",gap:"var(--space-2)"},children:[n.value.status==="ACTIVE"&&e(R,{variant:"secondary",onClick:()=>{H.value=!0},children:"Suspend Wallet"}),n.value.status==="SUSPENDED"&&e(R,{variant:"primary",onClick:ye,loading:re.value,children:"Resume Wallet"}),n.value.status!=="TERMINATED"&&e(R,{variant:"danger",onClick:()=>{r.value=!0},children:"Terminate Wallet"})]})]}),e(He,{tabs:Vl,activeTab:me.value,onTabChange:T=>{me.value=T}}),me.value==="overview"&&e(Ka,{}),me.value==="transactions"&&e(Fa,{}),me.value==="owner"&&e(Ha,{}),me.value==="staking"&&e(Ba,{}),me.value==="mcp"&&e(Va,{}),e(be,{open:r.value,title:"Terminate Wallet",onCancel:()=>{r.value=!1},onConfirm:x,confirmText:"Terminate",confirmVariant:"danger",loading:c.value,children:e("p",{children:["Are you sure you want to terminate wallet ",e("strong",{children:n.value.name}),"? This action cannot be undone."]})}),e(be,{open:y.value,title:"Scan QR Code",onCancel:()=>{y.value=!1,f.value&&clearInterval(f.value),f.value=null},children:b.value&&e("div",{style:{textAlign:"center"},children:[e("img",{src:b.value.qrCode,alt:"WalletConnect QR Code",style:{width:"280px",height:"280px",margin:"0 auto"}}),e("p",{style:{marginTop:"var(--space-3)",color:"var(--color-text-secondary)",fontSize:"0.85rem"},children:"Scan with D'CENT, MetaMask, Phantom, or any WalletConnect-compatible wallet"}),e("p",{style:{marginTop:"var(--space-2)",color:"var(--color-text-secondary)",fontSize:"0.75rem"},children:"Waiting for connection..."})]})}),e(be,{open:H.value,title:"Suspend Wallet",onCancel:()=>{H.value=!1,de.value=""},onConfirm:te,confirmText:"Suspend",confirmVariant:"danger",loading:ne.value,children:[e("p",{style:{marginBottom:"var(--space-3)"},children:["Are you sure you want to suspend wallet ",e("strong",{children:n.value.name}),"? Suspended wallets cannot process transactions until resumed."]}),e(A,{label:"Reason (optional)",name:"suspend-reason",value:de.value,onChange:T=>{de.value=T},placeholder:"e.g. suspicious activity"})]})]}):e(Ln,{title:"Wallet not found",description:"The wallet may have been deleted."})]})}const Xl=[{label:"Ethereum Mainnet",value:"ethereum-mainnet"},{label:"Ethereum Sepolia",value:"ethereum-sepolia"},{label:"Polygon Mainnet",value:"polygon-mainnet"},{label:"Polygon Amoy",value:"polygon-amoy"},{label:"Arbitrum Mainnet",value:"arbitrum-mainnet"},{label:"Arbitrum Sepolia",value:"arbitrum-sepolia"},{label:"Optimism Mainnet",value:"optimism-mainnet"},{label:"Optimism Sepolia",value:"optimism-sepolia"},{label:"Base Mainnet",value:"base-mainnet"},{label:"Base Sepolia",value:"base-sepolia"}],Jl={mainnet:["https://api.mainnet-beta.solana.com","https://rpc.ankr.com/solana","https://solana.drpc.org"],devnet:["https://api.devnet.solana.com","https://rpc.ankr.com/solana_devnet"],testnet:["https://api.testnet.solana.com"],"ethereum-mainnet":["https://eth.drpc.org","https://rpc.ankr.com/eth","https://ethereum.publicnode.com"],"ethereum-sepolia":["https://sepolia.drpc.org","https://ethereum-sepolia-rpc.publicnode.com"],"polygon-mainnet":["https://polygon.drpc.org","https://polygon-rpc.com","https://polygon.publicnode.com"],"polygon-amoy":["https://polygon-amoy.drpc.org"],"arbitrum-mainnet":["https://arbitrum.drpc.org","https://arbitrum.publicnode.com"],"arbitrum-sepolia":["https://arbitrum-sepolia.drpc.org","https://arbitrum-sepolia-rpc.publicnode.com"],"optimism-mainnet":["https://optimism.drpc.org","https://mainnet.optimism.io","https://optimism.publicnode.com"],"optimism-sepolia":["https://optimism-sepolia.drpc.org","https://optimism-sepolia-rpc.publicnode.com"],"base-mainnet":["https://base.drpc.org","https://base.publicnode.com"],"base-sepolia":["https://base-sepolia.drpc.org","https://base-sepolia-rpc.publicnode.com"]},Zl={mainnet:"Solana Mainnet",devnet:"Solana Devnet",testnet:"Solana Testnet","ethereum-mainnet":"Ethereum Mainnet","ethereum-sepolia":"Ethereum Sepolia","polygon-mainnet":"Polygon Mainnet","polygon-amoy":"Polygon Amoy","arbitrum-mainnet":"Arbitrum Mainnet","arbitrum-sepolia":"Arbitrum Sepolia","optimism-mainnet":"Optimism Mainnet","optimism-sepolia":"Optimism Sepolia","base-mainnet":"Base Mainnet","base-sepolia":"Base Sepolia"},Ge=["mainnet","devnet","testnet"],lt=["ethereum-mainnet","ethereum-sepolia","polygon-mainnet","polygon-amoy","arbitrum-mainnet","arbitrum-sepolia","optimism-mainnet","optimism-sepolia","base-mainnet","base-sepolia"];function Ql(t){if(t<=0)return"";const n=Math.ceil(t/1e3);if(n<60)return`${n}s`;const a=Math.floor(n/60),l=n%60;return l>0?`${a}m ${l}s`:`${a}m`}function ei(t){return Ge.includes(t)?"solana":"evm"}function ti(){const t=d({}),n=d({}),a=d({}),l=d(!1),i=d(!0),s=d({}),r=d({}),c=d(null),h=d({}),o=d({}),v=d({}),u=g=>{const f={},O=[...Ge,...lt];for(const W of O){const q=[],ae=g.rpc_pool;if(ae){const re=ae[W];if(typeof re=="string"&&re!=="[]")try{const me=JSON.parse(re);Array.isArray(me)&&q.push(...me.filter(ie=>typeof ie=="string"&&ie.length>0))}catch{}}const H=Jl[W]??[],ne=new Set(q),de=[];for(const re of q)de.push({url:re,isBuiltin:H.includes(re),enabled:!0});for(const re of H)ne.has(re)||de.push({url:re,isBuiltin:!0,enabled:!0});f[W]=de}return f},m=async()=>{try{const g=await z(L.ADMIN_SETTINGS);t.value=g;const f=u(g);a.value=f,n.value=JSON.parse(JSON.stringify(f))}catch(g){const f=g instanceof w?g:new w(0,"UNKNOWN","Unknown error");E("error",$(f.code))}finally{i.value=!1}};F(()=>{m()},[]),F(()=>{const g=async()=>{try{const O=await z(L.ADMIN_RPC_STATUS);h.value=O.networks??{}}catch{}};g();const f=setInterval(g,15e3);return()=>clearInterval(f)},[]);const N=async(g,f)=>{const O=`${g}:${f}`;o.value={...o.value,[O]:!0};try{const W=await se(L.ADMIN_SETTINGS_TEST_RPC,{url:f,chain:ei(g)});v.value={...v.value,[O]:W}}catch{v.value={...v.value,[O]:{success:!1,latencyMs:0,error:"Request failed"}}}finally{o.value={...o.value,[O]:!1}}},M=()=>{if(c.value!==null)return!0;for(const g of[...Ge,...lt]){const f=a.value[g]??[],O=n.value[g]??[];if(f.length!==O.length)return!0;for(let W=0;W<f.length;W++)if(f[W].url!==O[W].url||f[W].enabled!==O[W].enabled)return!0}return!1},I=Ft(()=>{let g=0;c.value!==null&&g++;for(const f of[...Ge,...lt]){const O=a.value[f]??[],W=n.value[f]??[];if(O.length!==W.length){g++;continue}for(let q=0;q<O.length;q++)if(O[q].url!==W[q].url||O[q].enabled!==W[q].enabled){g++;break}}return g}),_=async()=>{l.value=!0;try{const g=[];for(const W of[...Ge,...lt]){const ae=(n.value[W]??[]).filter(H=>!H.isBuiltin&&H.enabled).map(H=>H.url);g.push({key:`rpc_pool.${W}`,value:JSON.stringify(ae)})}c.value!==null&&g.push({key:"rpc.evm_default_network",value:c.value});const f=await he(L.ADMIN_SETTINGS,{settings:g});t.value=f.settings;const O=u(f.settings);a.value=O,n.value=JSON.parse(JSON.stringify(O)),c.value=null,E("success","RPC settings saved and applied")}catch(g){const f=g instanceof w?g:new w(0,"UNKNOWN","Unknown error");E("error",$(f.code))}finally{l.value=!1}},D=()=>{n.value=JSON.parse(JSON.stringify(a.value)),c.value=null};F(()=>(Ne({id:"wallets-rpc",isDirty:M,save:_,discard:D}),()=>ke("wallets-rpc")),[]);const P=g=>{s.value={...s.value,[g]:!s.value[g]}},K=g=>{const f=(r.value[g]??"").trim();if(!f)return;if(!f.startsWith("https://")){E("warning","URL must start with https://");return}const O=n.value[g]??[];if(O.some(ae=>ae.url===f)){E("warning","URL already exists in this network");return}const W=[...O];W.findIndex(ae=>ae.isBuiltin&&!O.slice(0,O.indexOf(ae)).some(H=>!H.isBuiltin));const q=W.reduce((ae,H,ne)=>H.isBuiltin?ae:ne+1,0);W.splice(q,0,{url:f,isBuiltin:!1,enabled:!0}),n.value={...n.value,[g]:W},r.value={...r.value,[g]:""}},y=(g,f)=>{const O=[...n.value[g]??[]];O[f]?.isBuiltin||(O.splice(f,1),n.value={...n.value,[g]:O})},b=(g,f,O)=>{const W=[...n.value[g]??[]],q=O==="up"?f-1:f+1;if(q<0||q>=W.length)return;const ae=W[f],H=W[q];!ae||!H||([W[f],W[q]]=[W[q],W[f]],n.value={...n.value,[g]:W})},U=(g,f)=>{const O=[...n.value[g]??[]],W=O[f];W?.isBuiltin&&(O[f]={...W,enabled:!W.enabled},n.value={...n.value,[g]:O})};function S({network:g}){const f=n.value[g]??[],O=s.value[g]??!1,W=f.filter(H=>H.enabled).length,q=h.value[g]??[],ae=H=>q.find(ne=>ne.url===H);return e("details",{class:"rpc-pool-network",open:O,"data-testid":`rpc-network-${g}`,children:[e("summary",{class:"rpc-pool-network-header",onClick:H=>{H.preventDefault(),P(g)},children:[e("span",{children:Zl[g]??g}),e("span",{class:"rpc-pool-url-count",children:[W," URL",W!==1?"s":""]})]}),O&&e("div",{class:"rpc-url-list",children:[f.map((H,ne)=>{const de=ae(H.url),re=`${g}:${H.url}`,me=o.value[re]??!1,ie=v.value[re];return e("div",{class:`rpc-url-item${H.isBuiltin?" rpc-url-item--builtin":""}${H.enabled?"":" rpc-url-disabled"}`,"data-testid":`rpc-url-${g}-${ne}`,children:[e("span",{class:"rpc-url-priority",children:["#",ne+1]}),e("span",{class:"rpc-url-item-url",title:H.url,children:H.url}),H.isBuiltin&&e("span",{class:"badge-builtin",children:"(built-in)"}),e("span",{class:"rpc-url-status","data-testid":`rpc-status-${g}-${ne}`,children:de?de.status==="available"?e(Y,{children:[e("span",{class:"rpc-url-status-dot rpc-url-status-dot--available"}),e("span",{children:"Available"})]}):e(Y,{children:[e("span",{class:"rpc-url-status-dot rpc-url-status-dot--cooldown"}),e("span",{children:"Cooldown"}),e("span",{class:"rpc-url-cooldown-info",children:[Ql(de.cooldownRemainingMs)," remaining"]}),e(B,{variant:"warning",children:[de.failureCount," fail",de.failureCount!==1?"s":""]})]}):e(Y,{children:[e("span",{class:"rpc-url-status-dot rpc-url-status-dot--unknown"}),e("span",{children:"Unknown"})]})}),e("span",{class:"rpc-url-test-inline",children:[e(R,{variant:"ghost",size:"sm",onClick:()=>N(g,H.url),loading:me,children:"Test"}),ie&&e("span",{class:`rpc-test-result ${ie.success?"rpc-test-result--success":"rpc-test-result--failure"}`,children:[e(B,{variant:ie.success?"success":"danger",children:ie.success?"OK":"FAIL"}),ie.success&&e(Y,{children:[" ",ie.latencyMs,"ms",ie.blockNumber!==void 0&&` (block #${ie.blockNumber.toLocaleString()})`]}),ie.error&&` - ${ie.error}`]})]}),e("span",{class:"rpc-url-actions",children:[e("button",{class:"btn btn-ghost btn-sm rpc-action-btn",onClick:()=>b(g,ne,"up"),disabled:ne===0,title:"Move up","aria-label":"Move up",children:"↑"}),e("button",{class:"btn btn-ghost btn-sm rpc-action-btn",onClick:()=>b(g,ne,"down"),disabled:ne===f.length-1,title:"Move down","aria-label":"Move down",children:"↓"}),H.isBuiltin?e("button",{class:`btn btn-ghost btn-sm rpc-action-btn${H.enabled?"":" rpc-toggle-off"}`,onClick:()=>U(g,ne),title:H.enabled?"Disable":"Enable","aria-label":H.enabled?"Disable":"Enable",children:H.enabled?"On":"Off"}):e("button",{class:"btn btn-ghost btn-sm rpc-action-btn rpc-delete-btn",onClick:()=>y(g,ne),title:"Remove","aria-label":"Remove",children:"×"})]})]},`${g}-${ne}`)}),e("div",{class:"rpc-add-url",children:[e("input",{type:"text",class:"rpc-add-url-input",placeholder:"https://your-rpc-url.com",value:r.value[g]??"",onInput:H=>{r.value={...r.value,[g]:H.target.value}},onKeyDown:H=>{H.key==="Enter"&&K(g)}}),e(R,{variant:"secondary",size:"sm",onClick:()=>K(g),children:"Add"})]})]})]})}if(i.value)return e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})});const p=c.value??(J(t.value,{},"rpc","evm_default_network")||"ethereum-sepolia");return e(Y,{children:[I.value>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[I.value," unsaved change",I.value>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(R,{variant:"ghost",size:"sm",onClick:D,children:"Discard"}),e(R,{variant:"primary",size:"sm",onClick:_,loading:l.value,children:"Save"})]})]}),e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"RPC Endpoints"}),e("p",{class:"settings-description",children:"Manage prioritized RPC URL lists per network. User URLs have highest priority; built-in defaults are appended automatically."})]}),e("div",{class:"settings-category-body",children:[e("div",{class:"settings-subgroup",children:[e("div",{class:"settings-subgroup-title",children:"Solana"}),Ge.map(g=>e(S,{network:g},g))]}),e("div",{class:"settings-subgroup",children:[e("div",{class:"settings-subgroup-title",children:"EVM"}),e("div",{class:"settings-field-full",style:{marginBottom:"var(--space-3)"},children:e(A,{label:V("evm_default_network"),name:"rpc.evm_default_network",type:"select",value:p,onChange:g=>{c.value=String(g)},options:Xl,description:"Default EVM network for new wallets"})}),lt.map(g=>e(S,{network:g},g))]})]})]})]})}function ni(){const t=d({}),n=d({}),a=d(!1),l=d(!0),i=async()=>{try{const o=await z(L.ADMIN_SETTINGS);t.value=o}catch(o){const v=o instanceof w?o:new w(0,"UNKNOWN","Unknown error");E("error",$(v.code))}finally{l.value=!1}};F(()=>{i()},[]);const s=(o,v)=>{const u=String(v);n.value={...n.value,[o]:u}},r=async()=>{a.value=!0;try{const o=Object.entries(n.value).filter(([u])=>u.startsWith("walletconnect.")).map(([u,m])=>({key:u,value:m})),v=await he(L.ADMIN_SETTINGS,{settings:o});t.value=v.settings,n.value={},E("success","Settings saved and applied")}catch(o){const v=o instanceof w?o:new w(0,"UNKNOWN","Unknown error");E("error",$(v.code))}finally{a.value=!1}},c=()=>{n.value={}};F(()=>(Ne({id:"wallets-walletconnect",isDirty:()=>Object.keys(n.value).filter(o=>o.startsWith("walletconnect.")).length>0,save:r,discard:c}),()=>ke("wallets-walletconnect")),[]);const h=Object.keys(n.value).filter(o=>o.startsWith("walletconnect.")).length;return l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(Y,{children:[h>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[h," unsaved change",h>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(R,{variant:"ghost",size:"sm",onClick:c,children:"Discard"}),e(R,{variant:"primary",size:"sm",onClick:r,loading:a.value,children:"Save"})]})]}),e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"WalletConnect"}),e("p",{class:"settings-description",children:"WalletConnect integration for dApp connections"})]}),e("div",{class:"settings-category-body",children:[e("div",{class:"settings-fields-grid",children:[e("div",{class:"settings-field-full",children:e(A,{label:V("project_id"),name:"walletconnect.project_id",type:"text",value:J(t.value,n.value,"walletconnect","project_id"),onChange:o=>s("walletconnect.project_id",o),description:"WalletConnect Cloud project identifier"})}),e("div",{class:"settings-field-full",children:e(A,{label:V("relay_url"),name:"walletconnect.relay_url",type:"text",value:J(t.value,n.value,"walletconnect","relay_url"),onChange:o=>s("walletconnect.relay_url",o),placeholder:"wss://relay.walletconnect.com",description:"WalletConnect relay server URL"})})]}),e("div",{class:"settings-info-box",children:["Get your project ID from"," ",e("a",{href:"https://cloud.walletconnect.com",target:"_blank",rel:"noopener noreferrer",children:"https://cloud.walletconnect.com"})," ","— Create a free account and project to obtain your project ID."]}),e("div",{class:"settings-info-box",children:"Relay URL defaults to wss://relay.walletconnect.com if not set."})]})]})]})}const ai=[{key:"chain",label:"Chain",type:"select",options:[{value:"solana",label:"Solana"},{value:"ethereum",label:"Ethereum"}]},{key:"environment",label:"Environment",type:"select",options:[{value:"testnet",label:"Testnet"},{value:"mainnet",label:"Mainnet"}]},{key:"status",label:"Status",type:"select",options:[{value:"ACTIVE",label:"ACTIVE"},{value:"SUSPENDED",label:"SUSPENDED"},{value:"TERMINATED",label:"TERMINATED"}]}],li=50;function ii(){const t=d([]),n=d(!0),a=d(!1),l=d(""),i=d("solana"),s=d("testnet"),r=d(null),c=d(!1),h=d(null),o=d(""),v=d({chain:"",environment:"",status:""}),u=d({}),m=d("USD"),N=d(1),M=async()=>{try{const b=await z(L.WALLETS);t.value=b.items}catch(b){const U=b instanceof w?b:new w(0,"UNKNOWN","Unknown error");E("error",$(U.code))}finally{n.value=!1}},I=async b=>{const U=b.slice(0,li),S={};await Promise.allSettled(U.map(async p=>{try{const f=(await z(L.ADMIN_WALLET_BALANCE(p.id))).balances?.find(O=>O.isDefault);f?.native?S[p.id]={balance:f.native.balance,symbol:f.native.symbol,usd:f.native.usd}:S[p.id]=null}catch{S[p.id]=null}})),u.value={...u.value,...S}},_=Ft(()=>{let b=t.value;const U=o.value.toLowerCase();U&&(b=b.filter(p=>p.name.toLowerCase().includes(U)||p.publicKey.toLowerCase().includes(U)));const S=v.value;return S.chain&&(b=b.filter(p=>p.chain===S.chain)),S.environment&&(b=b.filter(p=>p.environment===S.environment)),S.status&&(b=b.filter(p=>p.status===S.status)),b}),D=[{key:"name",header:"Name"},{key:"chain",header:"Chain"},{key:"environment",header:"Environment",render:b=>e(B,{variant:b.environment==="mainnet"?"warning":"info",children:b.environment})},{key:"publicKey",header:"Public Key",render:b=>e("span",{style:{display:"flex",alignItems:"center",gap:"0.25rem"},children:[Pt(b.publicKey)," ",e(ft,{value:b.publicKey})]})},{key:"balance",header:"Balance",render:b=>{const U=u.value[b.id];return U===void 0?e("span",{style:{color:"var(--color-text-secondary)"},children:"Loading..."}):U===null?e("span",{style:{color:"var(--color-text-secondary)"},children:"--"}):e("span",{children:[U.balance," ",U.symbol,U.usd!=null&&e("span",{style:{color:"var(--color-text-secondary)",marginLeft:"var(--space-1)",fontSize:"0.85em"},children:["(",mt(U.usd,m.value,N.value),")"]})]})}},{key:"status",header:"Status",render:b=>e(B,{variant:b.status==="ACTIVE"?"success":b.status==="SUSPENDED"?"warning":"danger",children:b.status})},{key:"ownerState",header:"Owner",render:b=>e(B,{variant:Ca(b.ownerState),children:b.ownerState})},{key:"createdAt",header:"Created",render:b=>ve(b.createdAt)}],P=async()=>{if(!l.value.trim()){r.value="Name is required";return}r.value=null,c.value=!0;try{const b=await se(L.WALLETS,{name:l.value.trim(),chain:i.value,environment:s.value});b.session?.token?(h.value=b.session.token,E("success","Wallet created with session")):E("success","Wallet created"),l.value="",i.value="solana",s.value="testnet",a.value=!1,n.value=!0,await M()}catch(b){const U=b instanceof w?b:new w(0,"UNKNOWN","Unknown error");r.value=$(U.code)}finally{c.value=!1}},K=b=>{window.location.hash="#/wallets/"+b.id},y=b=>{i.value=b};return F(()=>{M().then(()=>{t.value.length>0&&I(t.value)}),Ht().then(({currency:b,rate:U})=>{m.value=b,N.value=U}).catch(()=>{})},[]),e(Y,{children:[e("div",{class:"page-actions",children:!a.value&&e(R,{onClick:()=>{a.value=!0},children:"Create Wallet"})}),a.value&&e("div",{class:"inline-form",children:[e(A,{label:"Name",name:"name",value:l.value,onChange:b=>{l.value=b},required:!0,placeholder:"e.g. trading-bot",error:r.value??void 0}),e(A,{label:"Chain",name:"chain",type:"select",value:i.value,onChange:y,options:[{label:"Solana",value:"solana"},{label:"Ethereum",value:"ethereum"}]}),e(A,{label:"Environment",name:"environment",type:"select",value:s.value,onChange:b=>{s.value=b},options:[{label:"Testnet",value:"testnet"},{label:"Mainnet",value:"mainnet"}]}),e("div",{class:"inline-form-actions",children:[e(R,{onClick:P,loading:c.value,children:"Create"}),e(R,{variant:"secondary",onClick:()=>{a.value=!1,r.value=null},children:"Cancel"})]})]}),h.value&&e("div",{class:"inline-form",style:{marginBottom:"1rem"},children:[e("div",{style:{fontWeight:"bold",marginBottom:"0.5rem"},children:"Session Token (copy now — shown only once)"}),e("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[e("input",{type:"text",readOnly:!0,value:h.value,style:{flex:1,fontFamily:"monospace",fontSize:"0.85rem",padding:"0.5rem"},onClick:b=>b.target.select()}),e(R,{variant:"secondary",onClick:()=>{navigator.clipboard.writeText(h.value),E("success","Token copied")},children:"Copy"}),e(R,{variant:"secondary",onClick:()=>{h.value=null},children:"Dismiss"})]})]}),e(Bt,{fields:ai,values:v.value,onChange:b=>{v.value=b},syncUrl:!1}),e(Aa,{value:o.value,onSearch:b=>{o.value=b},placeholder:"Search by name or public key..."}),e(Ze,{columns:D,data:_.value,loading:n.value,onRowClick:K,emptyMessage:"No wallets yet"})]})}const Pn=[{key:"wallets",label:"Wallets"},{key:"rpc",label:"RPC Endpoints"},{key:"walletconnect",label:"WalletConnect"}];function si(){const t=d("wallets");return F(()=>{const n=le.value;n&&n.tab&&(t.value=n.tab,setTimeout(()=>{_e.value=n.fieldName},100),le.value=null)},[le.value]),e("div",{class:"page",children:[e(Qe,{pageName:"Wallets",tabName:Pn.find(n=>n.key===t.value)?.label??"",onPageClick:()=>{t.value="wallets"}}),e(He,{tabs:Pn,activeTab:t.value,onTabChange:n=>{t.value=n}}),t.value==="wallets"&&e(ii,{}),t.value==="rpc"&&e(ti,{}),t.value==="walletconnect"&&e(ni,{})]})}function Mn(){const t=De.value,n=t.startsWith("/wallets/")?t.slice(9):null;return n?e(Yl,{id:n}):e(si,{})}const Un=[{key:"transactions",label:"All Transactions"},{key:"monitor",label:"Monitor Settings"}],Ie=20,ri=[{value:"all",label:"All"},{value:"outgoing",label:"Outgoing"},{value:"incoming",label:"Incoming"}],oi=[{value:"TRANSFER",label:"TRANSFER"},{value:"TOKEN_TRANSFER",label:"TOKEN_TRANSFER"},{value:"CONTRACT_CALL",label:"CONTRACT_CALL"},{value:"APPROVE",label:"APPROVE"},{value:"BATCH",label:"BATCH"}],ci=[{value:"PENDING",label:"PENDING"},{value:"QUEUED",label:"QUEUED"},{value:"APPROVED",label:"APPROVED"},{value:"SUBMITTED",label:"SUBMITTED"},{value:"CONFIRMED",label:"CONFIRMED"},{value:"FAILED",label:"FAILED"},{value:"CANCELLED",label:"CANCELLED"}],di=[{value:"DETECTED",label:"DETECTED"},{value:"CONFIRMED",label:"CONFIRMED"}],ui=[{value:"solana",label:"Solana"},{value:"evm",label:"EVM"}],vi=[{value:"true",label:"Yes"},{value:"false",label:"No"}],hi=[{value:"mainnet",label:"mainnet"},{value:"devnet",label:"devnet"},{value:"testnet",label:"testnet"},{value:"ethereum-mainnet",label:"ethereum-mainnet"},{value:"ethereum-sepolia",label:"ethereum-sepolia"},{value:"polygon-mainnet",label:"polygon-mainnet"},{value:"polygon-amoy",label:"polygon-amoy"},{value:"arbitrum-mainnet",label:"arbitrum-mainnet"},{value:"arbitrum-sepolia",label:"arbitrum-sepolia"},{value:"optimism-mainnet",label:"optimism-mainnet"},{value:"optimism-sepolia",label:"optimism-sepolia"},{value:"base-mainnet",label:"base-mainnet"},{value:"base-sepolia",label:"base-sepolia"}],Tt=["Time","Direction","Wallet","Counterparty","Amount","Network","Status","Tx Hash"];function pi(t){return t==="CONFIRMED"?"success":t==="FAILED"?"danger":"warning"}function Wn(t){return{id:`out-${t.id}`,direction:"outgoing",time:t.createdAt,walletId:t.walletId,walletName:t.walletName,counterparty:t.toAddress,amount:t.amount,formattedAmount:t.formattedAmount,amountUsd:t.amountUsd,network:t.network??t.chain,status:t.status,txHash:t.txHash,chain:t.chain,outgoing:t}}function $n(t){return{id:`in-${t.id}`,direction:"incoming",time:t.detectedAt,walletId:t.walletId,walletName:t.walletName,counterparty:t.fromAddress,amount:t.amount,formattedAmount:t.formattedAmount,amountUsd:null,network:t.network,status:t.status,txHash:t.txHash,chain:t.chain,incoming:t}}function Kn(){const t=d("transactions"),n=d([]),a=d(0),l=d(0),i=d(!0),s=d(null),r=d("all"),c=d({wallet_id:"",type:"",status:"",network:"",chain:"",suspicious:"",since:"",until:""}),h=d(""),o=d(0),v=d(null),u=d("USD"),m=d(1),N=d([]),M=d({}),I=d({}),_=d(!1),D=d(!0),P=d([]),K=d(!0),y=d({}),b=d(null),U=(k,C)=>{I.value={...I.value,[k]:String(C)}},S=(k,C)=>J(M.value,I.value,k,C),p=async()=>{_.value=!0;try{const k=Object.entries(I.value).filter(([Z])=>Z.startsWith("incoming.")).map(([Z,ue])=>({key:Z,value:ue}));if(k.length===0){E("info","No changes to save"),_.value=!1;return}const C=await he(L.ADMIN_SETTINGS,{settings:k});M.value=C.settings,I.value={},E("success","Settings saved and applied")}catch(k){const C=k instanceof w?k:new w(0,"UNKNOWN","Unknown error");E("error",$(C.code))}finally{_.value=!1}},g=()=>{I.value={}};F(()=>(Object.keys(I.value).filter(C=>C.startsWith("incoming.")).length>0?Ne({id:"transactions-monitor",isDirty:()=>Object.keys(I.value).filter(C=>C.startsWith("incoming.")).length>0,save:p,discard:g}):ke("transactions-monitor"),()=>ke("transactions-monitor")),[I.value]);function f(){const k=r.value,C=[{key:"wallet_id",label:"Wallet",type:"select",options:N.value}];return(k==="outgoing"||k==="all")&&C.push({key:"type",label:"Type",type:"select",options:oi}),k==="outgoing"?C.push({key:"status",label:"Status",type:"select",options:ci}):k==="incoming"&&C.push({key:"status",label:"Status",type:"select",options:di}),C.push({key:"network",label:"Network",type:"select",options:hi}),(k==="incoming"||k==="all")&&(C.push({key:"chain",label:"Chain",type:"select",options:ui}),C.push({key:"suspicious",label:"Suspicious",type:"select",options:vi})),C.push({key:"since",label:"Since",type:"date"},{key:"until",label:"Until",type:"date"}),C}const O=async()=>{const k=new URLSearchParams,C=c.value;if(C.wallet_id&&k.set("wallet_id",C.wallet_id),C.type&&k.set("type",C.type),C.status&&r.value!=="all"&&k.set("status",C.status),C.network&&k.set("network",C.network),C.since){const Z=new Date(C.since);isNaN(Z.getTime())||k.set("since",String(Math.floor(Z.getTime()/1e3)))}if(C.until){const Z=new Date(C.until);isNaN(Z.getTime())||(Z.setHours(23,59,59,999),k.set("until",String(Math.floor(Z.getTime()/1e3))))}return h.value&&k.set("search",h.value),k.set("offset",String(o.value*Ie)),k.set("limit",String(Ie)),z(`${L.ADMIN_TRANSACTIONS}?${k.toString()}`)},W=async()=>{const k=new URLSearchParams,C=c.value;return C.wallet_id&&k.set("wallet_id",C.wallet_id),C.chain&&k.set("chain",C.chain),C.status&&r.value!=="all"&&k.set("status",C.status),C.suspicious&&k.set("suspicious",C.suspicious),k.set("offset",String(o.value*Ie)),k.set("limit",String(Ie)),z(`${L.ADMIN_INCOMING}?${k.toString()}`)},q=async()=>{i.value=!0,s.value=null;try{const k=r.value;if(k==="outgoing"){const C=await O();n.value=C.items.map(Wn),a.value=C.total,l.value=0}else if(k==="incoming"){const C=await W();n.value=C.items.map($n),a.value=0,l.value=C.total}else{const[C,Z]=await Promise.all([O(),W()]),ue=[...C.items.map(Wn),...Z.items.map($n)];ue.sort((Me,Be)=>(Be.time??0)-(Me.time??0)),n.value=ue,a.value=C.total,l.value=Z.total}}catch(k){k instanceof w?s.value=$(k.code):s.value="An unexpected error occurred."}finally{i.value=!1}},ae=async()=>{try{const k=await z(L.WALLETS),C=Array.isArray(k)?k:k.items??[];N.value=C.map(ue=>({value:ue.id,label:ue.name||ue.id.slice(0,8)})),P.value=C;const Z={};for(const ue of C)Z[ue.id]=ue.monitorIncoming??!1;y.value=Z}catch{}finally{K.value=!1}},H=async()=>{try{const k=await z(L.ADMIN_SETTINGS);M.value=k}catch(k){const C=k instanceof w?k:new w(0,"UNKNOWN","Unknown error");E("error",$(C.code))}finally{D.value=!1}};F(()=>{q(),ae(),Ht().then(({currency:k,rate:C})=>{u.value=k,m.value=C}).catch(()=>{}),H()},[]),F(()=>{q()},[c.value,h.value,o.value,r.value]),F(()=>{const k=le.value;k&&k.tab&&(t.value=k.tab,le.value=null,setTimeout(()=>{_e.value=k.fieldName},100))},[le.value]);function ne(k){t.value=k}function de(k){c.value=k,o.value=0}function re(k){h.value=k,o.value=0}function me(k){r.value=k,o.value=0,c.value={...c.value,type:"",status:"",chain:"",suspicious:""}}function ie(k){v.value=v.value===k.id?null:k.id}function Pe(){o.value>0&&(o.value=o.value-1)}function Ee(){const k=a.value+l.value;(o.value+1)*Ie<k&&(o.value=o.value+1)}async function Ae(k){if(window.confirm("Are you sure you want to cancel this transaction?"))try{await se(L.ADMIN_TX_CANCEL(k)),E("success","Transaction cancelled"),await q()}catch(C){const Z=C instanceof w?C:new w(0,"UNKNOWN","Unknown error");E("error",$(Z.code))}}async function we(k){if(window.confirm("Are you sure you want to reject this transaction?"))try{await se(L.ADMIN_TX_REJECT(k)),E("success","Transaction rejected"),await q()}catch(C){const Z=C instanceof w?C:new w(0,"UNKNOWN","Unknown error");E("error",$(Z.code))}}async function et(k){const C=y.value[k]??!1;b.value=k;try{const Z=await kl(L.WALLET_PATCH(k),{monitorIncoming:!C});y.value={...y.value,[k]:Z.monitorIncoming}}catch(Z){const ue=Z instanceof w?Z:new w(0,"UNKNOWN","Unknown error");E("error",$(ue.code))}finally{b.value=null}}function x(){const k=a.value+l.value,C=o.value*Ie,Z=k>0?C+1:0,ue=Math.min(C+Ie,k),Me=o.value>0,Be=(o.value+1)*Ie<k;return e(Y,{children:[s.value&&e("div",{class:"dashboard-error",children:[e("span",{children:s.value}),e(R,{variant:"secondary",size:"sm",onClick:q,children:"Retry"})]}),e("div",{class:"filter-bar",style:{marginBottom:0},children:e("div",{class:"filter-field",children:[e("label",{children:"Direction"}),e("select",{value:r.value,onChange:j=>me(j.target.value),children:ri.map(j=>e("option",{value:j.value,children:j.label},j.value))})]})}),e(Bt,{fields:f(),values:c.value,onChange:de}),r.value!=="incoming"&&e(Aa,{value:h.value,onSearch:re,placeholder:"Search by txHash or recipient address..."}),e("div",{class:"table-container",children:e("table",{children:[e("thead",{children:e("tr",{children:Tt.map(j=>e("th",{children:j},j))})}),e("tbody",{children:i.value&&n.value.length===0?e("tr",{children:e("td",{colSpan:Tt.length,class:"table-loading",children:"Loading..."})}):n.value.length===0?e("tr",{children:e("td",{colSpan:Tt.length,class:"table-empty",children:"No transactions found"})}):n.value.map(j=>e(Y,{children:[e("tr",{class:`clickable${v.value===j.id?" row-expanded":""}`,style:{cursor:"pointer"},onClick:()=>ie(j),children:[e("td",{children:j.time?ve(j.time):"—"}),e("td",{children:e(B,{variant:j.direction==="outgoing"?"info":"success",children:j.direction==="outgoing"?"Outgoing":"Incoming"})}),e("td",{children:j.walletName??j.walletId.slice(0,8)}),e("td",{children:j.counterparty?Pt(j.counterparty):"—"}),e("td",{children:j.amount?(()=>{const tt=j.formattedAmount??j.amount;if(j.amountUsd!=null){const bt=mt(j.amountUsd,u.value,m.value);return bt?`${tt} (${bt})`:tt}return tt})():"—"}),e("td",{children:j.network}),e("td",{children:e(B,{variant:pi(j.status),children:j.status})}),e("td",{children:e(gn,{network:j.network,txHash:j.txHash})})]},j.id),v.value===j.id&&e("tr",{class:"row-expand",children:e("td",{colSpan:Tt.length,children:[j.outgoing?te(j.outgoing):null,j.incoming?ye(j.incoming):null]})},`${j.id}-expand`)]}))})]})}),e("div",{class:"pagination",children:[e("span",{class:"pagination-info",children:["Showing ",Z,"-",ue," of ",k]}),e("div",{class:"pagination-buttons",children:[e(R,{variant:"secondary",size:"sm",disabled:!Me,onClick:Pe,children:"Previous"}),e(R,{variant:"secondary",size:"sm",disabled:!Be,onClick:Ee,children:"Next"})]})]})]})}function te(k){return e("div",{class:"detail-grid",children:[e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"ID"}),e("span",{class:"detail-value",children:k.id})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Wallet ID"}),e("span",{class:"detail-value",children:k.walletId})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Wallet Name"}),e("span",{class:"detail-value",children:k.walletName??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Type"}),e("span",{class:"detail-value",children:k.type})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Status"}),e("span",{class:"detail-value",children:k.status})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Tier"}),e("span",{class:"detail-value",children:k.tier??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"To Address"}),e("span",{class:"detail-value",children:k.toAddress??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Amount"}),e("span",{class:"detail-value",children:k.amount??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Amount USD"}),e("span",{class:"detail-value",children:k.amountUsd!=null?`$${k.amountUsd.toFixed(2)}`:"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Network"}),e("span",{class:"detail-value",children:k.network??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Chain"}),e("span",{class:"detail-value",children:k.chain})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Tx Hash"}),e("span",{class:"detail-value",children:k.txHash??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Created At"}),e("span",{class:"detail-value",children:k.createdAt?ve(k.createdAt):"—"})]}),k.status==="QUEUED"&&e("div",{class:"detail-item",style:{gridColumn:"1 / -1",marginTop:"var(--space-2)"},children:e("div",{style:{display:"flex",gap:"var(--space-2)"},children:[e(R,{variant:"danger",size:"sm",onClick:C=>{C.stopPropagation(),Ae(k.id)},children:"Cancel"}),e(R,{variant:"secondary",size:"sm",onClick:C=>{C.stopPropagation(),we(k.id)},children:"Reject"})]})})]})}function ye(k){return e("div",{class:"detail-grid",children:[e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"ID"}),e("span",{class:"detail-value",children:k.id})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Tx Hash"}),e("span",{class:"detail-value",children:k.txHash})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Wallet ID"}),e("span",{class:"detail-value",children:k.walletId})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Wallet Name"}),e("span",{class:"detail-value",children:k.walletName??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"From Address"}),e("span",{class:"detail-value",children:k.fromAddress})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Amount"}),e("span",{class:"detail-value",children:k.amount})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Token Address"}),e("span",{class:"detail-value",children:k.tokenAddress??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Chain"}),e("span",{class:"detail-value",children:k.chain})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Network"}),e("span",{class:"detail-value",children:k.network})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Status"}),e("span",{class:"detail-value",children:k.status})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Block Number"}),e("span",{class:"detail-value",children:k.blockNumber??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Detected At"}),e("span",{class:"detail-value",children:k.detectedAt?ve(k.detectedAt):"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Confirmed At"}),e("span",{class:"detail-value",children:k.confirmedAt?ve(k.confirmedAt):"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Suspicious"}),e("span",{class:"detail-value",children:k.suspicious?"Yes":"No"})]})]})}function Vt(){const k=Object.keys(I.value).filter(C=>C.startsWith("incoming.")).length;return e(Y,{children:[k>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[k," unsaved change",k>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(R,{variant:"ghost",size:"sm",onClick:g,children:"Discard"}),e(R,{variant:"primary",size:"sm",onClick:p,loading:_.value,children:"Save"})]})]}),e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Incoming TX Monitoring Settings"}),e("p",{class:"settings-description",children:"Monitor incoming transactions to wallets. Detects native and token transfers, flags suspicious activity (dust attacks, large amounts, unknown tokens)."})]}),e("div",{class:"settings-category-body",children:D.value?e("span",{children:"Loading settings..."}):e(Y,{children:[e("div",{class:"settings-fields-grid",children:[e(A,{label:"Monitoring Enabled",name:"incoming.enabled",type:"select",value:S("incoming","enabled")||"false",onChange:C=>U("incoming.enabled",C),options:[{label:"Yes",value:"true"},{label:"No",value:"false"}]}),e(A,{label:"Poll Interval (seconds)",name:"incoming.poll_interval",type:"number",value:Number(S("incoming","poll_interval"))||30,onChange:C=>U("incoming.poll_interval",C),min:5,max:3600}),e(A,{label:"Retention Days",name:"incoming.retention_days",type:"number",value:Number(S("incoming","retention_days"))||90,onChange:C=>U("incoming.retention_days",C),min:1,max:365}),e(A,{label:"Suspicious Dust USD Threshold",name:"incoming.suspicious_dust_usd",type:"number",value:Number(S("incoming","suspicious_dust_usd"))||.01,onChange:C=>U("incoming.suspicious_dust_usd",C),min:0,max:1e3}),e(A,{label:"Suspicious Amount Multiplier",name:"incoming.suspicious_amount_multiplier",type:"number",value:Number(S("incoming","suspicious_amount_multiplier"))||10,onChange:C=>U("incoming.suspicious_amount_multiplier",C),min:1,max:1e3}),e(A,{label:"Notification Cooldown (minutes)",name:"incoming.cooldown_minutes",type:"number",value:Number(S("incoming","cooldown_minutes"))||5,onChange:C=>U("incoming.cooldown_minutes",C),min:1,max:1440}),e(A,{label:"WebSocket URL (optional)",name:"incoming.wss_url",type:"text",value:S("incoming","wss_url"),onChange:C=>U("incoming.wss_url",C),placeholder:"wss://custom-rpc.example.com"})]}),e("div",{class:"settings-info-box",children:"Monitors wallets with incoming monitoring enabled for incoming transactions. Uses WebSocket subscription when available, falls back to polling. Suspicious transactions (dust attacks, unusually large amounts, unknown tokens) trigger broadcast alerts to all notification channels. Changes take effect immediately via hot-reload."})]})})]}),e("div",{class:"settings-category",style:{marginTop:"var(--space-4)"},children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Per-Wallet Monitoring"}),e("p",{class:"settings-description",children:"Enable or disable incoming transaction monitoring for individual wallets"})]}),e("div",{class:"settings-category-body",children:K.value?e("span",{children:"Loading wallets..."}):P.value.length===0?e("p",{class:"empty-text",children:"No wallets found"}):e("div",{class:"table-container",children:e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"Wallet Name"}),e("th",{children:"Chain"}),e("th",{children:"Status"}),e("th",{children:"Monitor Incoming"})]})}),e("tbody",{children:P.value.map(C=>e("tr",{children:[e("td",{children:C.name||C.id.slice(0,8)}),e("td",{children:C.chain}),e("td",{children:e(B,{variant:(C.status??"ACTIVE")==="ACTIVE"?"success":"warning",children:C.status??"ACTIVE"})}),e("td",{children:e(R,{variant:y.value[C.id]?"primary":"secondary",size:"sm",onClick:()=>et(C.id),loading:b.value===C.id,children:y.value[C.id]?"ON":"OFF"})})]},C.id))})]})})})]})]})}const Gt=Un.find(k=>k.key===t.value)?.label;return e("div",{class:"page",children:[e(Qe,{pageName:"Transactions",tabName:Gt,onPageClick:()=>{t.value="transactions"}}),e(He,{tabs:Un,activeTab:t.value,onTabChange:ne}),e("div",{style:{marginTop:"var(--space-4)"},children:t.value==="transactions"?x():Vt()})]})}const mi=["ethereum-mainnet","ethereum-sepolia","polygon-mainnet","polygon-amoy","arbitrum-mainnet","arbitrum-sepolia","optimism-mainnet","optimism-sepolia","base-mainnet","base-sepolia"],jt=["Symbol","Name","Address","Decimals","Source","Actions"];function fi(t){return t.length<=10?t:`${t.slice(0,6)}...${t.slice(-4)}`}function gi(){const t=d("ethereum-mainnet"),n=d([]),a=d(!0),l=d(null),i=d(!1),s=d(""),r=d(""),c=d(""),h=d("18"),o=d(!1),v=d(!1),u=d(null),m=gt(null),N=async()=>{a.value=!0,l.value=null;try{const y=await z(`${L.TOKENS}?network=${encodeURIComponent(t.value)}`);n.value=y.tokens}catch(y){y instanceof w?l.value=$(y.code):l.value="An unexpected error occurred.",n.value=[]}finally{a.value=!1}};F(()=>{N()},[t.value]);function M(y){t.value=y.target.value}function I(){s.value="",r.value="",c.value="",h.value="18",v.value=!1,i.value=!1,m.current&&clearTimeout(m.current)}async function _(y){v.value=!0;try{const b=await z(`${L.TOKENS_RESOLVE}?network=${encodeURIComponent(t.value)}&address=${encodeURIComponent(y)}`);r.value=b.symbol,c.value=b.name,h.value=String(b.decimals),E("success",`Resolved: ${b.symbol} (${b.name})`)}catch{}finally{v.value=!1}}function D(y){const b=y.target.value;s.value=b,m.current&&clearTimeout(m.current),/^0x[a-fA-F0-9]{40}$/.test(b)&&(m.current=setTimeout(()=>_(b),500))}async function P(){if(!s.value||!r.value||!c.value){E("error","Please fill in all required fields.");return}o.value=!0;try{await se(L.TOKENS,{network:t.value,address:s.value,symbol:r.value,name:c.value,decimals:Number(h.value)}),E("success",`Token ${r.value} added successfully.`),I(),await N()}catch(y){y instanceof w?E("error",$(y.code)):E("error","Failed to add token.")}finally{o.value=!1}}async function K(y){u.value=y;try{await Ke(L.TOKENS,{network:t.value,address:y}),E("success","Token removed successfully."),await N()}catch(b){b instanceof w?E("error",$(b.code)):E("error","Failed to remove token.")}finally{u.value=null}}return e("div",{class:"page",children:[l.value&&e("div",{class:"dashboard-error",children:[e("span",{children:l.value}),e(R,{variant:"secondary",size:"sm",onClick:N,children:"Retry"})]}),e("div",{class:"filter-bar",children:[e("div",{class:"filter-field",children:[e("label",{children:"Network"}),e("select",{value:t.value,onChange:M,children:mi.map(y=>e("option",{value:y,children:y},y))})]}),e("div",{style:{marginLeft:"auto"},children:e(R,{variant:"primary",size:"sm",onClick:()=>{i.value=!i.value},children:i.value?"Cancel":"Add Token"})})]}),i.value&&e("div",{class:"card",style:{marginTop:"var(--space-3)",padding:"var(--space-4)"},children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"Add Custom Token"}),e("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"var(--space-3)"},children:[e("div",{class:"form-field",children:[e("label",{for:"token-address",children:["Contract Address ",v.value&&e("span",{style:{color:"var(--warning)",fontSize:"0.85em"},children:"(resolving...)"})]}),e("input",{id:"token-address",type:"text",value:s.value,onInput:D,placeholder:"0x... (metadata auto-fetched)"})]}),e("div",{class:"form-field",children:[e("label",{for:"token-symbol",children:"Symbol"}),e("input",{id:"token-symbol",type:"text",value:r.value,onInput:y=>{r.value=y.target.value},placeholder:"e.g. USDC"})]}),e("div",{class:"form-field",children:[e("label",{for:"token-name",children:"Name"}),e("input",{id:"token-name",type:"text",value:c.value,onInput:y=>{c.value=y.target.value},placeholder:"e.g. USD Coin"})]}),e("div",{class:"form-field",children:[e("label",{for:"token-decimals",children:"Decimals"}),e("input",{id:"token-decimals",type:"number",value:h.value,onInput:y=>{h.value=y.target.value},placeholder:"18"})]})]}),e("div",{style:{marginTop:"var(--space-3)",display:"flex",gap:"var(--space-2)"},children:[e(R,{variant:"primary",size:"sm",loading:o.value,onClick:P,children:"Submit"}),e(R,{variant:"secondary",size:"sm",onClick:I,children:"Cancel"})]})]}),e("div",{class:"table-container",style:{marginTop:"var(--space-3)"},children:e("table",{children:[e("thead",{children:e("tr",{children:jt.map(y=>e("th",{children:y},y))})}),e("tbody",{children:a.value&&n.value.length===0?e("tr",{children:e("td",{colSpan:jt.length,class:"table-loading",children:"Loading..."})}):n.value.length===0?e("tr",{children:e("td",{colSpan:jt.length,class:"table-empty",children:"No tokens found for this network"})}):n.value.map(y=>e("tr",{children:[e("td",{children:y.symbol}),e("td",{children:y.name}),e("td",{title:y.address,children:fi(y.address)}),e("td",{children:y.decimals}),e("td",{children:e(B,{variant:y.source==="builtin"?"neutral":"info",children:y.source==="builtin"?"Built-in":"Custom"})}),e("td",{children:y.source==="custom"?e(R,{variant:"danger",size:"sm",loading:u.value===y.address,onClick:()=>K(y.address),children:"Delete"}):"—"})]},y.address))})]})})]})}function We({legend:t,children:n,description:a}){return e("fieldset",{class:"field-group",children:[e("legend",{class:"field-group-legend",children:t}),a&&e("p",{class:"field-group-description",children:a}),e("div",{class:"field-group-body",children:n})]})}function yi(t,n,a){n.value=t,a.value=!0}const Fn=[{key:"sessions",label:"Sessions"},{key:"settings",label:"Settings"}],Yt=["security.session_ttl","security.session_absolute_lifetime","security.session_max_renewals","security.max_sessions_per_wallet","security.max_pending_tx","security.rate_limit_session_rpm","security.rate_limit_tx_rpm"];function _i(){const t=d({}),n=d({}),a=d(!1),l=d(!0),i=async()=>{try{const o=await z(L.ADMIN_SETTINGS);t.value=o}catch(o){const v=o instanceof w?o:new w(0,"UNKNOWN","Unknown error");E("error",$(v.code))}finally{l.value=!1}};F(()=>{i()},[]);const s=(o,v)=>{const u=String(v);n.value={...n.value,[o]:u}},r=async()=>{a.value=!0;try{const o=Object.entries(n.value).filter(([u])=>Yt.includes(u)).map(([u,m])=>({key:u,value:m})),v=await he(L.ADMIN_SETTINGS,{settings:o});t.value=v.settings,n.value={},E("success","Session settings saved and applied")}catch(o){const v=o instanceof w?o:new w(0,"UNKNOWN","Unknown error");E("error",$(v.code))}finally{a.value=!1}},c=()=>{n.value={}};F(()=>(Ne({id:"sessions-settings",isDirty:()=>Object.keys(n.value).filter(o=>Yt.includes(o)).length>0,save:r,discard:c}),()=>ke("sessions-settings")),[]);const h=Object.keys(n.value).filter(o=>Yt.includes(o)).length;return l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(Y,{children:[h>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[h," unsaved change",h>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(R,{variant:"ghost",size:"sm",onClick:c,children:"Discard"}),e(R,{variant:"primary",size:"sm",onClick:r,loading:a.value,children:"Save"})]})]}),e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Session Configuration"}),e("p",{class:"settings-description",children:"Configure session lifetime, renewal limits, and request rate limiting. Changes apply immediately without daemon restart."})]}),e("div",{class:"settings-category-body",children:[e(We,{legend:"Lifetime",description:"Session duration and renewal limits",children:e("div",{class:"settings-fields-grid",children:[e(A,{label:V("session_ttl"),name:"security.session_ttl",type:"number",value:Number(J(t.value,n.value,"security","session_ttl"))||0,onChange:o=>s("security.session_ttl",o),min:300,description:"How long a session token is valid before renewal"}),e(A,{label:V("session_absolute_lifetime"),name:"security.session_absolute_lifetime",type:"number",value:Number(J(t.value,n.value,"security","session_absolute_lifetime"))||0,onChange:o=>s("security.session_absolute_lifetime",o),min:0,description:"Maximum total session duration regardless of renewals"}),e(A,{label:V("session_max_renewals"),name:"security.session_max_renewals",type:"number",value:Number(J(t.value,n.value,"security","session_max_renewals"))||0,onChange:o=>s("security.session_max_renewals",o),min:0,description:"Maximum number of times a session can be renewed"}),e(A,{label:V("max_sessions_per_wallet"),name:"security.max_sessions_per_wallet",type:"number",value:Number(J(t.value,n.value,"security","max_sessions_per_wallet"))||0,onChange:o=>s("security.max_sessions_per_wallet",o),min:1,max:100,description:"Maximum concurrent sessions for a single wallet"})]})}),e(We,{legend:"Rate Limits",description:"Request throttling per session and transaction",children:e("div",{class:"settings-fields-grid",children:[e(A,{label:V("max_pending_tx"),name:"security.max_pending_tx",type:"number",value:Number(J(t.value,n.value,"security","max_pending_tx"))||0,onChange:o=>s("security.max_pending_tx",o),min:1,max:100,description:"Maximum in-flight transactions per session"}),e(A,{label:V("rate_limit_session_rpm"),name:"security.rate_limit_session_rpm",type:"number",value:Number(J(t.value,n.value,"security","rate_limit_session_rpm"))||0,onChange:o=>s("security.rate_limit_session_rpm",o),min:10,description:"Max requests per minute per session"}),e(A,{label:V("rate_limit_tx_rpm"),name:"security.rate_limit_tx_rpm",type:"number",value:Number(J(t.value,n.value,"security","rate_limit_tx_rpm"))||0,onChange:o=>s("security.rate_limit_tx_rpm",o),min:1,description:"Max transaction requests per minute per session"})]})})]})]})]})}function bi(){const t=d("sessions");F(()=>{const p=le.value;p&&p.tab&&(t.value=p.tab,setTimeout(()=>{_e.value=p.fieldName},100),le.value=null)},[le.value]);const n=d([]),a=d(""),l=d(""),i=d([]),s=d(!1),r=d(!0),c=d(!1),h=d(!1),o=d(""),v=d(!1),u=d(""),m=d(!1),N=d(null),M=d(!1),I=d(new Set),_=d(""),D=async()=>{try{const p=await z(L.WALLETS);n.value=p.items.filter(g=>g.status==="ACTIVE")}catch(p){const g=p instanceof w?p:new w(0,"UNKNOWN","Unknown error");E("error",$(g.code))}finally{r.value=!1}},P=async()=>{s.value=!0;try{const p=a.value?`${L.SESSIONS}?walletId=${a.value}`:L.SESSIONS,g=await z(p);i.value=g}catch(p){const g=p instanceof w?p:new w(0,"UNKNOWN","Unknown error");E("error",$(g.code))}finally{s.value=!1}},K=p=>{const g=new Set(I.value);g.has(p)?(g.delete(p),_.value===p&&(_.value=g.size>0?Array.from(g)[0]??"":"")):(g.add(p),g.size===1&&(_.value=p)),I.value=g},y=async()=>{c.value=!0;try{const p=Array.from(I.value),g=p.length===1?{walletId:p[0]}:{walletIds:p,defaultWalletId:_.value||p[0]},f=await se(L.SESSIONS,g);o.value=f.token,h.value=!0,M.value=!1,await P()}catch(p){const g=p instanceof w?p:new w(0,"UNKNOWN","Unknown error");E("error",$(g.code))}finally{c.value=!1}},b=async()=>{m.value=!0;try{await Ke(L.SESSION(u.value)),E("success","Session revoked"),v.value=!1,await P()}catch(p){const g=p instanceof w?p:new w(0,"UNKNOWN","Unknown error");E("error",$(g.code))}finally{m.value=!1}},U=async p=>{N.value=p;try{const g=await se(L.ADMIN_SESSION_REISSUE(p),{});o.value=g.token,h.value=!0,await P()}catch(g){const f=g instanceof w?g:new w(0,"UNKNOWN","Unknown error");E("error",$(f.code))}finally{N.value=null}};F(()=>{D()},[]),F(()=>{i.value=[],P()},[a.value]);const S=[{key:"id",header:"ID",render:p=>p.id.slice(0,8)+"..."},{key:"walletName",header:"Wallet",render:p=>p.wallets&&p.wallets.length>0?e("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:p.wallets.map(g=>e("span",{children:[g.name??g.id.slice(0,8),g.isDefault&&e(B,{variant:"info",children:"default"})]},g.id))}):p.walletName??p.walletId.slice(0,8)+"..."},{key:"source",header:"Source",render:p=>e(B,{variant:p.source==="mcp"?"info":"neutral",children:p.source==="mcp"?"MCP":"API"})},{key:"status",header:"Status",render:p=>e(B,{variant:p.status==="ACTIVE"?"success":p.status==="EXPIRED"?"warning":"danger",children:p.status})},{key:"expiresAt",header:"Expires At",render:p=>ve(p.expiresAt)},{key:"renewals",header:"Renewals",render:p=>`${p.renewalCount}/${p.maxRenewals}`},{key:"tokenIssuedCount",header:"Tokens",render:p=>String(p.tokenIssuedCount??1)},{key:"createdAt",header:"Created",render:p=>ve(p.createdAt)},{key:"actions",header:"Actions",render:p=>p.status==="ACTIVE"?e("div",{style:{display:"flex",gap:"var(--space-1)"},children:[e(R,{size:"sm",variant:"secondary",onClick:()=>U(p.id),loading:N.value===p.id,children:"Reissue"}),e(R,{size:"sm",variant:"danger",onClick:()=>yi(p.id,u,v),children:"Revoke"})]}):null}];return e("div",{class:"page",children:[e(Qe,{pageName:"Sessions",tabName:Fn.find(p=>p.key===t.value)?.label??"",onPageClick:()=>{t.value="sessions"}}),e(He,{tabs:Fn,activeTab:t.value,onTabChange:p=>{t.value=p}}),t.value==="sessions"&&e(Y,{children:[e("div",{class:"session-controls",children:[e("div",{class:"session-wallet-select",children:[e("label",{for:"wallet-select",children:"Wallet"}),e("select",{id:"wallet-select",value:a.value,onChange:p=>{a.value=p.target.value},disabled:r.value,children:[e("option",{value:"",children:"All Wallets"}),n.value.map(p=>e("option",{value:p.id,children:[p.name," (",p.chain,"/",p.network,")"]},p.id))]})]}),e("div",{class:"session-wallet-select",children:[e("label",{for:"source-select",children:"Source"}),e("select",{id:"source-select",value:l.value,onChange:p=>{l.value=p.target.value},children:[e("option",{value:"",children:"All"}),e("option",{value:"api",children:"API"}),e("option",{value:"mcp",children:"MCP"})]})]}),e(R,{onClick:()=>{I.value=new Set,_.value="",M.value=!0},disabled:n.value.length===0,children:"Create Session"})]}),e(Ze,{columns:S,data:l.value?i.value.filter(p=>p.source===l.value):i.value,loading:s.value,emptyMessage:"No sessions"}),e(be,{open:h.value,title:"Session Created",onCancel:()=>{h.value=!1},cancelText:"Close",children:[e("p",{class:"token-warning",children:"Copy this token now. It will not be shown again."}),e("div",{class:"token-display",children:[e("code",{class:"token-value",children:o.value}),e(ft,{value:o.value,label:"Copy Token"})]})]}),e(be,{open:v.value,title:"Revoke Session",onCancel:()=>{v.value=!1},onConfirm:b,confirmText:"Revoke",confirmVariant:"danger",loading:m.value,children:e("p",{children:"Are you sure you want to revoke this session? The associated token will be immediately invalidated."})}),e(be,{open:M.value,title:"Create Session",onCancel:()=>{M.value=!1},onConfirm:y,confirmText:`Create Session (${I.value.size} wallet${I.value.size!==1?"s":""})`,confirmDisabled:I.value.size===0,loading:c.value,children:[e("div",{children:[e("label",{style:{fontWeight:600,display:"block",marginBottom:"var(--space-2)"},children:"Select Wallets"}),e("div",{style:{maxHeight:"250px",overflow:"auto",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"var(--space-2)"},children:n.value.map(p=>e("label",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)",padding:"var(--space-1) 0",cursor:"pointer"},children:[e("input",{type:"checkbox",checked:I.value.has(p.id),onChange:()=>K(p.id)}),e("span",{children:p.name}),e("span",{style:{color:"var(--color-text-secondary)",fontSize:"0.8rem"},children:["(",p.chain,"/",p.network,")"]})]},p.id))})]}),I.value.size>1&&e("div",{style:{marginTop:"var(--space-3)"},children:[e("label",{style:{fontWeight:600,display:"block",marginBottom:"var(--space-2)"},children:"Default Wallet"}),e("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"var(--space-2)"},children:n.value.filter(p=>I.value.has(p.id)).map(p=>e("label",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)",padding:"var(--space-1) 0",cursor:"pointer"},children:[e("input",{type:"radio",name:"defaultWallet",checked:_.value===p.id,onChange:()=>{_.value=p.id}}),e("span",{children:p.name}),e("span",{style:{color:"var(--color-text-secondary)",fontSize:"0.8rem"},children:["(",p.chain,"/",p.network,")"]})]},p.id))})]})]})]}),t.value==="settings"&&e(_i,{})]})}const wi={mainnet:"SOL",devnet:"SOL",testnet:"SOL","ethereum-mainnet":"ETH","ethereum-sepolia":"ETH","polygon-mainnet":"POL","polygon-amoy":"POL","arbitrum-mainnet":"ETH","arbitrum-sepolia":"ETH","optimism-mainnet":"ETH","optimism-sepolia":"ETH","base-mainnet":"ETH","base-sepolia":"ETH"};function Si(t){return t&&wi[t]||"Native"}const Hn=["ethereum-mainnet","ethereum-sepolia","polygon-mainnet","polygon-amoy","arbitrum-mainnet","arbitrum-sepolia","optimism-mainnet","optimism-sepolia","base-mainnet","base-sepolia"];function ki({rules:t,onChange:n,errors:a,network:l}){const i=d([]),s=d(!1),r=_=>D=>{n({...t,[_]:D})},c=_=>D=>{const P=Number(D),K={...t};D===""||D===0||Number.isNaN(P)?delete K[_]:K[_]=P,n(K)},h=t.token_limits||{},o=_=>D=>{const P=String(D),y={...h.native||{instant_max:"",notify_max:"",delay_max:""},[_]:P};if(!y.instant_max&&!y.notify_max&&!y.delay_max){const b={...h};delete b.native,n({...t,token_limits:Object.keys(b).length>0?b:void 0})}else n({...t,token_limits:{...h,native:y}})},v=(_,D,P)=>{const y={...h[_]||{instant_max:"0",notify_max:"0",delay_max:"0"},[D]:P};n({...t,token_limits:{...h,[_]:y}})},u=_=>{const D={...h};delete D[_],n({...t,token_limits:Object.keys(D).length>0?D:void 0})},m=_=>{if(!_||h[_])return;const D={instant_max:"0",notify_max:"0",delay_max:"0"};n({...t,token_limits:{...h,[_]:D}})},N=()=>{const _=prompt("Enter CAIP-19 asset ID (e.g., eip155:1/erc20:0xa0b8...)");if(!_||h[_])return;const D={instant_max:"0",notify_max:"0",delay_max:"0"};n({...t,token_limits:{...h,[_]:D}})};F(()=>{if(!l){i.value=[];return}if(!Hn.includes(l)){i.value=[];return}s.value=!0,z(`${L.TOKENS}?network=${l}`).then(_=>{i.value=_.tokens}).catch(()=>{i.value=[]}).finally(()=>{s.value=!1})},[l]);const M=Object.entries(h).filter(([_])=>_!=="native").map(([_,D])=>({assetId:_,symbol:i.value.find(P=>P.assetId===_)?.symbol||_.split("/").pop()?.split(":").pop()||_,instant_max:D.instant_max,notify_max:D.notify_max,delay_max:D.delay_max})),I=Si(l);return e("div",{class:"policy-form-fields",children:[e("h4",{children:"USD Amount Tiers"}),e("div",{class:"policy-form-grid",children:[e(A,{label:"Instant Max USD",name:"instant_max_usd",type:"number",value:t.instant_max_usd??"",onChange:c("instant_max_usd"),placeholder:"Optional"}),e(A,{label:"Notify Max USD",name:"notify_max_usd",type:"number",value:t.notify_max_usd??"",onChange:c("notify_max_usd"),placeholder:"Optional"}),e(A,{label:"Delay Max USD",name:"delay_max_usd",type:"number",value:t.delay_max_usd??"",onChange:c("delay_max_usd"),placeholder:"Optional"})]}),e("h4",{children:"Token-Specific Limits"}),e("h5",{children:["Native Token (",I,")"]}),e("div",{class:"policy-form-grid",children:[e(A,{label:`Instant Max (${I})`,name:"native_instant_max",value:h.native?.instant_max??"",onChange:o("instant_max"),placeholder:"e.g. 0.5",error:a["token_limits.native.instant_max"]}),e(A,{label:`Notify Max (${I})`,name:"native_notify_max",value:h.native?.notify_max??"",onChange:o("notify_max"),placeholder:"e.g. 0.5",error:a["token_limits.native.notify_max"]}),e(A,{label:`Delay Max (${I})`,name:"native_delay_max",value:h.native?.delay_max??"",onChange:o("delay_max"),placeholder:"e.g. 0.5",error:a["token_limits.native.delay_max"]})]}),e("p",{class:"form-description",children:"Human-readable amounts (e.g., 0.5 SOL, not lamports/wei)"}),e("h5",{style:{marginTop:"1rem"},children:"Custom Token Limits"}),M.map((_,D)=>e("div",{class:"token-limit-row",style:{border:"1px solid var(--border)",borderRadius:"0.5rem",padding:"0.75rem",marginBottom:"0.5rem"},children:[e("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"0.5rem"},children:[e("strong",{children:_.symbol}),e("span",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",flex:1,marginLeft:"0.5rem",overflow:"hidden",textOverflow:"ellipsis"},children:_.assetId}),e("button",{class:"btn btn-ghost btn-sm",onClick:()=>u(_.assetId),title:"Remove",children:"x"})]}),e("div",{class:"policy-form-grid",children:[e(A,{label:"Instant Max",name:`token-${D}-instant`,value:_.instant_max,onChange:P=>v(_.assetId,"instant_max",String(P)),placeholder:"e.g. 100",error:a[`token_limits.${_.assetId}.instant_max`]}),e(A,{label:"Notify Max",name:`token-${D}-notify`,value:_.notify_max,onChange:P=>v(_.assetId,"notify_max",String(P)),placeholder:"e.g. 500",error:a[`token_limits.${_.assetId}.notify_max`]}),e(A,{label:"Delay Max",name:`token-${D}-delay`,value:_.delay_max,onChange:P=>v(_.assetId,"delay_max",String(P)),placeholder:"e.g. 1000",error:a[`token_limits.${_.assetId}.delay_max`]})]})]},_.assetId)),l&&Hn.includes(l)&&i.value.length>0&&e("div",{style:{display:"flex",gap:"0.5rem",alignItems:"flex-end",marginTop:"0.5rem"},children:e(A,{label:"Select Token",name:"add-token-select",type:"select",value:"",onChange:_=>m(_),options:[{label:s.value?"Loading...":"-- Select a token --",value:""},...i.value.filter(_=>_.assetId&&!h[_.assetId]).map(_=>({label:`${_.symbol} (${_.name})`,value:_.assetId}))]})}),e("button",{class:"btn btn-secondary btn-sm",style:{marginTop:"0.5rem"},onClick:N,children:"+ Add Token Limit (manual CAIP-19)"}),e("h4",{children:"Cumulative USD Limits (Optional)"}),e("div",{class:"policy-form-grid",children:[e(A,{label:"Daily Limit USD (24h rolling)",name:"daily_limit_usd",type:"number",value:t.daily_limit_usd??"",onChange:c("daily_limit_usd"),placeholder:"e.g. 500",error:a.daily_limit_usd}),e(A,{label:"Monthly Limit USD (30d rolling)",name:"monthly_limit_usd",type:"number",value:t.monthly_limit_usd??"",onChange:c("monthly_limit_usd"),placeholder:"e.g. 5000",error:a.monthly_limit_usd})]}),e("h4",{children:["Legacy Raw Tiers ",e("span",{class:"badge badge-warning",children:"Deprecated"})]}),e("p",{class:"form-description",children:"Raw tiers use lamports/wei units and apply uniformly to all tokens. Use USD Tiers or Token-Specific Limits instead. These fields will be removed in a future version."}),e("div",{class:"policy-form-grid",children:[e(A,{label:"Instant Max (lamports/wei)",name:"instant_max",value:t.instant_max||"",onChange:r("instant_max"),error:a.instant_max}),e(A,{label:"Notify Max (lamports/wei)",name:"notify_max",value:t.notify_max||"",onChange:r("notify_max"),error:a.notify_max}),e(A,{label:"Delay Max (lamports/wei)",name:"delay_max",value:t.delay_max||"",onChange:r("delay_max"),error:a.delay_max})]}),e(A,{label:"Delay Duration (seconds, min 60)",name:"delay_seconds",type:"number",value:t.delay_seconds??900,onChange:r("delay_seconds"),error:a.delay_seconds,required:!0,min:60})]})}function Re({items:t,onAdd:n,onRemove:a,renderRow:l,onChange:i,addLabel:s="+ Add",minItems:r=0,error:c}){return e("div",{class:"dynamic-row-list",children:[t.map((h,o)=>e("div",{class:"dynamic-row",children:[e("div",{class:"dynamic-row-fields",children:l(h,o,i)}),e("button",{class:"btn btn-ghost btn-sm dynamic-row-remove",onClick:()=>a(o),disabled:t.length<=r,title:"Remove",children:"x"})]},o)),e("button",{class:"btn btn-secondary btn-sm",onClick:n,children:s}),c&&e("span",{class:"form-error",children:c})]})}function Ti({rules:t,onChange:n,errors:a}){const l=t.allowed_addresses||[];return e("div",{class:"policy-form-fields",children:e(Re,{items:l,onAdd:()=>n({...t,allowed_addresses:[...l,""]}),onRemove:i=>n({...t,allowed_addresses:l.filter((s,r)=>r!==i)}),onChange:(i,s)=>{const r=[...l];r[i]=s,n({...t,allowed_addresses:r})},renderRow:(i,s,r)=>e(A,{label:`Address ${s+1}`,name:`address-${s}`,value:i,onChange:c=>r(s,c),placeholder:"Wallet address",error:a[`allowed_addresses.${s}`],required:!0}),addLabel:"+ Add Address",error:a.allowed_addresses})})}function Ni({rules:t,onChange:n,errors:a}){const l=i=>s=>{n({...t,[i]:s})};return e("div",{class:"policy-form-fields",children:[e(A,{label:"Max Requests",name:"max_requests",type:"number",value:t.max_requests??100,onChange:l("max_requests"),error:a.max_requests,required:!0,min:1}),e(A,{label:"Window (seconds)",name:"window_seconds",type:"number",value:t.window_seconds??3600,onChange:l("window_seconds"),error:a.window_seconds,required:!0,min:1})]})}function Ei({rules:t,onChange:n,errors:a}){const l=i=>{const s={...t};i===""||i===void 0?delete s.maxAmount:s.maxAmount=i,n(s)};return e("div",{class:"policy-form-fields",children:[e(A,{label:"Max Amount (lamports/wei, optional)",name:"maxAmount",value:t.maxAmount??"",onChange:l,error:a.maxAmount,placeholder:"Leave empty for no limit"}),e(A,{label:"Block Unlimited Approvals",name:"blockUnlimited",type:"checkbox",value:t.blockUnlimited??!0,onChange:i=>n({...t,blockUnlimited:i})})]})}const Ai=[{label:"Instant",value:"INSTANT"},{label:"Notify",value:"NOTIFY"},{label:"Delay",value:"DELAY"},{label:"Approval",value:"APPROVAL"}];function Ci({rules:t,onChange:n,errors:a}){return e("div",{class:"policy-form-fields",children:e(A,{label:"Override Tier",name:"tier",type:"select",value:t.tier??"DELAY",onChange:l=>n({...t,tier:l}),options:Ai,error:a.tier})})}const Ii=[{label:"All Chains",value:""},{label:"Solana",value:"solana"},{label:"Ethereum",value:"ethereum"}];function Di({rules:t,onChange:n,errors:a}){const l=t.tokens||[];return e("div",{class:"policy-form-fields",children:e(Re,{items:l,onAdd:()=>n({...t,tokens:[...l,{address:"",symbol:"",chain:""}]}),onRemove:i=>n({...t,tokens:l.filter((s,r)=>r!==i)}),onChange:(i,s)=>{const r=[...l];r[i]=s,n({...t,tokens:r})},renderRow:(i,s,r)=>e("div",{class:"dynamic-row-fields",style:{display:"flex",gap:"0.5rem",flex:1},children:[e(A,{label:`Address ${s+1}`,name:`token-addr-${s}`,value:i.address,onChange:c=>r(s,{...i,address:c}),placeholder:"Token mint/contract address",error:a[`tokens.${s}.address`],required:!0}),e(A,{label:"Symbol",name:`token-symbol-${s}`,value:i.symbol,onChange:c=>r(s,{...i,symbol:c}),placeholder:"e.g. USDC"}),e(A,{label:"Chain",name:`token-chain-${s}`,type:"select",value:i.chain,onChange:c=>{const h={...i,chain:c};c||delete h.chain,r(s,h)},options:Ii})]}),addLabel:"+ Add Token",error:a.tokens})})}const Oi=[{label:"All Chains",value:""},{label:"Solana",value:"solana"},{label:"Ethereum",value:"ethereum"}];function xi({rules:t,onChange:n,errors:a}){const l=t.contracts||[];return e("div",{class:"policy-form-fields",children:e(Re,{items:l,onAdd:()=>n({...t,contracts:[...l,{address:"",name:"",chain:""}]}),onRemove:i=>n({...t,contracts:l.filter((s,r)=>r!==i)}),onChange:(i,s)=>{const r=[...l];r[i]=s,n({...t,contracts:r})},renderRow:(i,s,r)=>e("div",{class:"dynamic-row-fields",style:{display:"flex",gap:"0.5rem",flex:1},children:[e(A,{label:`Address ${s+1}`,name:`contract-addr-${s}`,value:i.address,onChange:c=>r(s,{...i,address:c}),placeholder:"Contract address",error:a[`contracts.${s}.address`],required:!0}),e(A,{label:"Name",name:`contract-name-${s}`,value:i.name,onChange:c=>r(s,{...i,name:c}),placeholder:"e.g. Uniswap Router"}),e(A,{label:"Chain",name:`contract-chain-${s}`,type:"select",value:i.chain,onChange:c=>{const h={...i,chain:c};c||delete h.chain,r(s,h)},options:Oi})]}),addLabel:"+ Add Contract",error:a.contracts})})}function Li({rules:t,onChange:n,errors:a}){const l=t.methods||[],i=s=>{n({...t,methods:s})};return e("div",{class:"policy-form-fields",children:e(Re,{items:l,onAdd:()=>i([...l,{contractAddress:"",selectors:[""]}]),onRemove:s=>i(l.filter((r,c)=>c!==s)),onChange:(s,r)=>{const c=[...l];c[s]=r,i(c)},renderRow:(s,r,c)=>e("div",{style:{flex:1},children:[e(A,{label:`Contract Address ${r+1}`,name:`method-addr-${r}`,value:s.contractAddress,onChange:h=>c(r,{...s,contractAddress:h}),placeholder:"Contract address",error:a[`methods.${r}.contractAddress`],required:!0}),e("div",{style:{marginTop:"0.5rem",marginLeft:"1rem"},children:[e("label",{style:{fontSize:"0.85rem",fontWeight:500},children:"Selectors"}),e(Re,{items:s.selectors,onAdd:()=>c(r,{...s,selectors:[...s.selectors,""]}),onRemove:h=>c(r,{...s,selectors:s.selectors.filter((o,v)=>v!==h)}),onChange:(h,o)=>{const v=[...s.selectors];v[h]=o,c(r,{...s,selectors:v})},renderRow:(h,o,v)=>e(A,{label:`Selector ${o+1}`,name:`method-sel-${r}-${o}`,value:h,onChange:u=>v(o,u),placeholder:"e.g. 0xa9059cbb or transfer(address,uint256)",error:a[`methods.${r}.selectors.${o}`],required:!0}),addLabel:"+ Add Selector",error:a[`methods.${r}.selectors`]})]})]}),addLabel:"+ Add Method Entry",error:a.methods})})}function Ri({rules:t,onChange:n,errors:a}){const l=t.spenders||[];return e("div",{class:"policy-form-fields",children:e(Re,{items:l,onAdd:()=>n({...t,spenders:[...l,{address:"",name:"",maxAmount:""}]}),onRemove:i=>n({...t,spenders:l.filter((s,r)=>r!==i)}),onChange:(i,s)=>{const r=[...l];r[i]=s,s.maxAmount||delete r[i].maxAmount,n({...t,spenders:r})},renderRow:(i,s,r)=>e("div",{class:"dynamic-row-fields",style:{display:"flex",gap:"0.5rem",flex:1},children:[e(A,{label:`Address ${s+1}`,name:`spender-addr-${s}`,value:i.address,onChange:c=>r(s,{...i,address:c}),placeholder:"Spender address",error:a[`spenders.${s}.address`],required:!0}),e(A,{label:"Name",name:`spender-name-${s}`,value:i.name,onChange:c=>r(s,{...i,name:c}),placeholder:"e.g. Uniswap"}),e(A,{label:"Max Amount",name:`spender-max-${s}`,value:i.maxAmount||"",onChange:c=>r(s,{...i,maxAmount:c}),placeholder:"Leave empty for unlimited",error:a[`spenders.${s}.maxAmount`]})]}),addLabel:"+ Add Spender",error:a.spenders})})}const Pi=Array.from({length:24},(t,n)=>({label:`${String(n).padStart(2,"0")}:00`,value:String(n)})),Mi=Array.from({length:24},(t,n)=>({label:`${String(n+1).padStart(2,"0")}:00`,value:String(n+1)})),Ui=[{label:"Sun",value:0},{label:"Mon",value:1},{label:"Tue",value:2},{label:"Wed",value:3},{label:"Thu",value:4},{label:"Fri",value:5},{label:"Sat",value:6}];function Wi({rules:t,onChange:n,errors:a}){const l=t.allowed_hours||{start:0,end:24},i=t.allowed_days||[],s=c=>h=>{const o={...l,[c]:Number(h)};n({...t,allowed_hours:o})},r=c=>{const h=i.includes(c)?i.filter(o=>o!==c):[...i,c].sort((o,v)=>o-v);n({...t,allowed_days:h})};return e("div",{class:"policy-form-fields",children:[e("h4",{children:"Allowed Hours"}),e("div",{class:"policy-form-grid",children:[e(A,{label:"Start Hour",name:"allowed_hours_start",type:"select",value:String(l.start),onChange:s("start"),options:Pi,error:a.allowed_hours}),e(A,{label:"End Hour",name:"allowed_hours_end",type:"select",value:String(l.end),onChange:s("end"),options:Mi})]}),e("h4",{children:"Allowed Days"}),e("div",{style:{display:"flex",gap:"0.75rem",flexWrap:"wrap"},children:Ui.map(c=>e("label",{style:{display:"flex",alignItems:"center",gap:"0.25rem",cursor:"pointer"},children:[e("input",{type:"checkbox",checked:i.includes(c.value),onChange:()=>r(c.value)}),c.label]},c.value))}),a.allowed_days&&e("span",{class:"form-error",children:a.allowed_days})]})}const $i=[{label:"mainnet",value:"mainnet"},{label:"devnet",value:"devnet"},{label:"testnet",value:"testnet"},{label:"ethereum-mainnet",value:"ethereum-mainnet"},{label:"ethereum-sepolia",value:"ethereum-sepolia"},{label:"polygon-mainnet",value:"polygon-mainnet"},{label:"polygon-amoy",value:"polygon-amoy"},{label:"arbitrum-mainnet",value:"arbitrum-mainnet"},{label:"arbitrum-sepolia",value:"arbitrum-sepolia"},{label:"optimism-mainnet",value:"optimism-mainnet"},{label:"optimism-sepolia",value:"optimism-sepolia"},{label:"base-mainnet",value:"base-mainnet"},{label:"base-sepolia",value:"base-sepolia"}];function Ki({rules:t,onChange:n,errors:a}){const l=t.networks||[];return e("div",{class:"policy-form-fields",children:e(Re,{items:l,onAdd:()=>n({...t,networks:[...l,{network:"mainnet",name:""}]}),onRemove:i=>n({...t,networks:l.filter((s,r)=>r!==i)}),onChange:(i,s)=>{const r=[...l];r[i]=s,n({...t,networks:r})},renderRow:(i,s,r)=>e("div",{class:"dynamic-row-fields",style:{display:"flex",gap:"0.5rem",flex:1},children:[e(A,{label:`Network ${s+1}`,name:`network-sel-${s}`,type:"select",value:i.network,onChange:c=>r(s,{...i,network:c}),options:$i,error:a[`networks.${s}.network`],required:!0}),e(A,{label:"Label",name:`network-name-${s}`,value:i.name,onChange:c=>r(s,{...i,name:c}),placeholder:"Optional label"})]}),addLabel:"+ Add Network",error:a.networks})})}function Fi({rules:t,onChange:n,errors:a}){const l=t.domains||[];return e("div",{class:"policy-form-fields",children:e(Re,{items:l,onAdd:()=>n({...t,domains:[...l,""]}),onRemove:i=>n({...t,domains:l.filter((s,r)=>r!==i)}),onChange:(i,s)=>{const r=[...l];r[i]=s,n({...t,domains:r})},renderRow:(i,s,r)=>e(A,{label:`Domain ${s+1}`,name:`domain-${s}`,value:i,onChange:c=>r(s,c),placeholder:"e.g. api.example.com or *.service.io",error:a[`domains.${s}`],required:!0}),addLabel:"+ Add Domain",error:a.domains})})}function Bn({type:t,rules:n,onChange:a,errors:l,network:i}){switch(t){case"SPENDING_LIMIT":return e(ki,{rules:n,onChange:a,errors:l,network:i});case"WHITELIST":return e(Ti,{rules:n,onChange:a,errors:l});case"RATE_LIMIT":return e(Ni,{rules:n,onChange:a,errors:l});case"APPROVE_AMOUNT_LIMIT":return e(Ei,{rules:n,onChange:a,errors:l});case"APPROVE_TIER_OVERRIDE":return e(Ci,{rules:n,onChange:a,errors:l});case"ALLOWED_TOKENS":return e(Di,{rules:n,onChange:a,errors:l});case"CONTRACT_WHITELIST":return e(xi,{rules:n,onChange:a,errors:l});case"METHOD_WHITELIST":return e(Li,{rules:n,onChange:a,errors:l});case"APPROVED_SPENDERS":return e(Ri,{rules:n,onChange:a,errors:l});case"TIME_RESTRICTION":return e(Wi,{rules:n,onChange:a,errors:l});case"ALLOWED_NETWORKS":return e(Ki,{rules:n,onChange:a,errors:l});case"X402_ALLOWED_DOMAINS":return e(Fi,{rules:n,onChange:a,errors:l});default:return e("p",{class:"policy-form-placeholder",children:"This policy type uses JSON editor. Toggle to JSON mode."})}}function cn(t){const n=typeof t=="string"?Number(t):t;return Number.isNaN(n)?String(t):n.toLocaleString("en-US")}function Hi(t){return t===86400?"1d":t%86400===0?`${t/86400}d`:t===3600?"1h":t%3600===0?`${t/3600}h`:t===60?"1m":t%60===0?`${t/60}m`:`${t}s`}const Xt=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Bi(t){if(!t||t.length===0)return"";const n=[...t].sort((l,i)=>l-i);let a=!0;for(let l=1;l<n.length;l++)if(n[l]!==n[l-1]+1){a=!1;break}return a&&n.length>2?`${Xt[n[0]]}-${Xt[n[n.length-1]]}`:n.map(l=>Xt[l]??String(l)).join(", ")}function Vn(t){return String(t).padStart(2,"0")}function Vi({rules:t}){const n=Number(t.instant_max??0),a=Number(t.notify_max??0),l=Number(t.delay_max??0),i=Math.max(n,a,l,1),s=[{label:"Instant",value:t.instant_max,width:n/i*100,cls:"instant"},{label:"Notify",value:t.notify_max,width:a/i*100,cls:"notify"},{label:"Delay",value:t.delay_max,width:l/i*100,cls:"delay"},{label:"Approval",value:"",width:100,cls:"approval"}];return e("div",{class:"tier-bars",children:s.map(r=>e("div",{class:"tier-bar",children:[e("span",{class:"tier-bar-label",children:r.label}),e("div",{class:"tier-bar-track",children:e("div",{class:`tier-bar-fill tier-bar-fill--${r.cls}`,style:{width:`${r.width}%`}})}),e("span",{class:"tier-bar-value",children:r.value?cn(r.value):""})]},r.cls))})}function Gn(t){return t.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:2})}function Gi({rules:t}){const n=t.daily_limit_usd,a=t.monthly_limit_usd;return!n&&!a?null:e("div",{class:"cumulative-limits",children:[e("div",{class:"cumulative-limits-label",children:"Cumulative Limits"}),n&&e("div",{class:"cumulative-limit-row",children:[e("span",{class:"cumulative-limit-type",children:"Daily (24h)"}),e("span",{class:"cumulative-limit-value",children:["$",Gn(n)]})]}),a&&e("div",{class:"cumulative-limit-row",children:[e("span",{class:"cumulative-limit-type",children:"Monthly (30d)"}),e("span",{class:"cumulative-limit-value",children:["$",Gn(a)]})]})]})}const zi={INSTANT:"success",NOTIFY:"info",DELAY:"warning",APPROVAL:"danger"};function qi({type:t,rules:n}){switch(t){case"SPENDING_LIMIT":return e("div",{class:"spending-limit-summary",children:[e(Vi,{rules:n}),e(Gi,{rules:n})]});case"ALLOWED_TOKENS":{const a=n.tokens||[];return a.length===0?e("span",{class:"rules-vis-text",children:"No tokens"}):e("div",{class:"rules-vis-badges",children:a.map((l,i)=>e(B,{variant:"info",children:l.symbol||(l.address?l.address.slice(0,8)+"...":"?")},i))})}case"RATE_LIMIT":{const a=n.max_requests,l=n.window_seconds;return e("span",{class:"rules-vis-text",children:[a," req / ",Hi(l)]})}case"WHITELIST":{const a=n.allowed_addresses||[];return e(B,{variant:"neutral",children:[a.length," addresses"]})}case"TIME_RESTRICTION":{const a=n.allowed_days||[],l=n.allowed_hours,i=Bi(a),s=l?`${Vn(l.start)}:00-${Vn(l.end)}:00`:"";return e("span",{class:"rules-vis-text",children:[i," ",s]})}case"CONTRACT_WHITELIST":{const a=n.contracts||[];if(a.length===0)return e("span",{class:"rules-vis-text",children:"No contracts"});const l=a.slice(0,3),i=a.length-3;return e("div",{class:"rules-vis-badges",children:[l.map((s,r)=>e(B,{variant:"neutral",children:s.name||(s.address?s.address.slice(0,8)+"...":"?")},r)),i>0&&e(B,{variant:"neutral",children:["+",i," more"]})]})}case"METHOD_WHITELIST":{const a=n.methods||[],l=a.length,i=a.reduce((s,r)=>s+(r.selectors?.length||0),0);return e(B,{variant:"neutral",children:[l," contracts, ",i," methods"]})}case"APPROVED_SPENDERS":{const a=n.spenders||[];return e(B,{variant:"neutral",children:[a.length," spenders"]})}case"APPROVE_AMOUNT_LIMIT":{const a=n.maxAmount,l=n.blockUnlimited;return a&&l?e("span",{class:"rules-vis-text",children:["Max: ",cn(a)," + Block unlimited"]}):a?e("span",{class:"rules-vis-text",children:["Max: ",cn(a)]}):l?e("span",{class:"rules-vis-text",children:"Block unlimited only"}):e("span",{class:"rules-vis-text",children:"No limits"})}case"APPROVE_TIER_OVERRIDE":{const a=n.tier||"DELAY",l=zi[a]||"neutral";return e(B,{variant:l,children:a})}case"ALLOWED_NETWORKS":{const a=n.networks||[];if(a.length===0)return e("span",{class:"rules-vis-text",children:"No networks"});const l=a.slice(0,3),i=a.length-3;return e("div",{class:"rules-vis-badges",children:[l.map((s,r)=>e(B,{variant:"info",children:s.network},r)),i>0&&e(B,{variant:"info",children:["+",i," more"]})]})}case"X402_ALLOWED_DOMAINS":{const a=n.domains||[];if(a.length===0)return e("span",{class:"rules-vis-text",children:"No domains"});const l=a.slice(0,3),i=a.length-3;return e("div",{class:"rules-vis-badges",children:[l.map((s,r)=>e(B,{variant:"neutral",children:s},r)),i>0&&e(B,{variant:"neutral",children:["+",i," more"]})]})}default:{const a=JSON.stringify(n);return e("span",{class:"rules-summary",children:a.length>60?a.slice(0,60)+"...":a})}}}const Ia=[{label:"Spending Limit",value:"SPENDING_LIMIT"},{label:"Whitelist",value:"WHITELIST"},{label:"Time Restriction",value:"TIME_RESTRICTION"},{label:"Rate Limit",value:"RATE_LIMIT"},{label:"Allowed Tokens",value:"ALLOWED_TOKENS"},{label:"Contract Whitelist",value:"CONTRACT_WHITELIST"},{label:"Method Whitelist",value:"METHOD_WHITELIST"},{label:"Approved Spenders",value:"APPROVED_SPENDERS"},{label:"Approve Amount Limit",value:"APPROVE_AMOUNT_LIMIT"},{label:"Approve Tier Override",value:"APPROVE_TIER_OVERRIDE"},{label:"Allowed Networks",value:"ALLOWED_NETWORKS"},{label:"x402 Allowed Domains",value:"X402_ALLOWED_DOMAINS"}],Jt={SPENDING_LIMIT:"Set per-transaction and cumulative spending limits by security tier (instant, notify, delay, approval).",WHITELIST:"Allow transfers only to pre-approved recipient addresses.",TIME_RESTRICTION:"Restrict transactions to specific time windows or days of the week.",RATE_LIMIT:"Limit the maximum number of transactions within a time window.",ALLOWED_TOKENS:"Allow only specified tokens for transfers; all others are denied.",CONTRACT_WHITELIST:"Allow contract calls only to pre-approved contract addresses.",METHOD_WHITELIST:"Allow only specific contract methods (function selectors) to be called.",APPROVED_SPENDERS:"Allow token approvals only for pre-approved spender addresses.",APPROVE_AMOUNT_LIMIT:"Set maximum token approval amounts and optionally block unlimited approvals.",APPROVE_TIER_OVERRIDE:"Force a specific security tier for all token approval transactions.",ALLOWED_NETWORKS:"Restrict transactions to specific blockchain networks only.",X402_ALLOWED_DOMAINS:"Allow x402 payments only to pre-approved domains."},it={SPENDING_LIMIT:{instant_max_usd:"10",notify_max_usd:"100",delay_max_usd:"1000",delay_seconds:300,approval_timeout:3600},WHITELIST:{allowed_addresses:[]},TIME_RESTRICTION:{allowed_hours:{start:0,end:24},allowed_days:[0,1,2,3,4,5,6]},RATE_LIMIT:{max_requests:100,window_seconds:3600},ALLOWED_TOKENS:{tokens:[]},CONTRACT_WHITELIST:{contracts:[]},METHOD_WHITELIST:{methods:[]},APPROVED_SPENDERS:{spenders:[]},APPROVE_AMOUNT_LIMIT:{maxAmount:"1000000",blockUnlimited:!0},APPROVE_TIER_OVERRIDE:{tier:"DELAY"},ALLOWED_NETWORKS:{networks:[]},X402_ALLOWED_DOMAINS:{domains:[]}};function Nt(t,n){const a={};if(t==="SPENDING_LIMIT"){n.instant_max&&!/^\d+$/.test(n.instant_max)&&(a.instant_max="Positive integer required"),n.notify_max&&!/^\d+$/.test(n.notify_max)&&(a.notify_max="Positive integer required"),n.delay_max&&!/^\d+$/.test(n.delay_max)&&(a.delay_max="Positive integer required");const l=!!(n.instant_max||n.notify_max||n.delay_max),i=!!(n.instant_max_usd||n.notify_max_usd||n.delay_max_usd),s=n.token_limits,r=s&&Object.keys(s).length>0;if(!l&&!i&&!r&&(a.__form="At least one of USD limits, token limits, or raw limits required"),s){const v=/^\d+(\.\d+)?$/;for(const[u,m]of Object.entries(s)){const N=m;if(!N||typeof N!="object")continue;N.instant_max&&!v.test(N.instant_max)&&(a[`token_limits.${u}.instant_max`]="Must be a non-negative decimal"),N.notify_max&&!v.test(N.notify_max)&&(a[`token_limits.${u}.notify_max`]="Must be a non-negative decimal"),N.delay_max&&!v.test(N.delay_max)&&(a[`token_limits.${u}.delay_max`]="Must be a non-negative decimal");const M=parseFloat(N.instant_max||"0"),I=parseFloat(N.notify_max||"0"),_=parseFloat(N.delay_max||"0");M>I&&(a[`token_limits.${u}.instant_max`]="Must be <= Notify Max"),I>_&&(a[`token_limits.${u}.notify_max`]="Must be <= Delay Max")}}const c=Number(n.delay_seconds);(n.delay_seconds===void 0||n.delay_seconds===""||Number.isNaN(c)||c<60)&&(a.delay_seconds="Minimum 60 seconds");const h=n.daily_limit_usd;if(h!==void 0&&h!==""){const v=Number(h);(Number.isNaN(v)||v<=0)&&(a.daily_limit_usd="Must be a positive number")}const o=n.monthly_limit_usd;if(o!==void 0&&o!==""){const v=Number(o);(Number.isNaN(v)||v<=0)&&(a.monthly_limit_usd="Must be a positive number")}}else if(t==="WHITELIST"){const l=n.allowed_addresses||[];l.length===0&&(a.allowed_addresses="At least one address required"),l.forEach((i,s)=>{(!i||i.trim()==="")&&(a[`allowed_addresses.${s}`]="Address required")})}else if(t==="RATE_LIMIT"){const l=Number(n.max_requests);(!n.max_requests||Number.isNaN(l)||l<1||!Number.isInteger(l))&&(a.max_requests="Positive integer required");const i=Number(n.window_seconds);(!n.window_seconds||Number.isNaN(i)||i<1||!Number.isInteger(i))&&(a.window_seconds="Positive integer required")}else if(t==="APPROVE_AMOUNT_LIMIT")n.maxAmount&&!/^\d+$/.test(n.maxAmount)&&(a.maxAmount="Must be a positive integer string");else if(t==="ALLOWED_TOKENS"){const l=n.tokens||[];l.length===0&&(a.tokens="At least one token required"),l.forEach((i,s)=>{(!i.address||i.address.trim()==="")&&(a[`tokens.${s}.address`]="Address required")})}else if(t==="CONTRACT_WHITELIST"){const l=n.contracts||[];l.length===0&&(a.contracts="At least one contract required"),l.forEach((i,s)=>{(!i.address||i.address.trim()==="")&&(a[`contracts.${s}.address`]="Address required")})}else if(t==="METHOD_WHITELIST"){const l=n.methods||[];l.length===0&&(a.methods="At least one method entry required"),l.forEach((i,s)=>{(!i.contractAddress||i.contractAddress.trim()==="")&&(a[`methods.${s}.contractAddress`]="Contract address required"),!i.selectors||i.selectors.length===0?a[`methods.${s}.selectors`]="At least one selector required":i.selectors.forEach((r,c)=>{(!r||r.trim()==="")&&(a[`methods.${s}.selectors.${c}`]="Selector required")})})}else if(t==="APPROVED_SPENDERS"){const l=n.spenders||[];l.length===0&&(a.spenders="At least one spender required"),l.forEach((i,s)=>{(!i.address||i.address.trim()==="")&&(a[`spenders.${s}.address`]="Address required"),i.maxAmount&&!/^\d+$/.test(i.maxAmount)&&(a[`spenders.${s}.maxAmount`]="Must be a positive integer")})}else if(t==="TIME_RESTRICTION"){(n.allowed_days||[]).length===0&&(a.allowed_days="At least one day required");const i=n.allowed_hours;i&&i.start>=i.end&&(a.allowed_hours="Start must be before end")}else if(t==="ALLOWED_NETWORKS"){const l=n.networks||[];l.length===0&&(a.networks="At least one network required"),l.forEach((i,s)=>{(!i.network||i.network.trim()==="")&&(a[`networks.${s}.network`]="Network required")})}else if(t==="X402_ALLOWED_DOMAINS"){const l=n.domains||[];l.length===0&&(a.domains="At least one domain required"),l.forEach((i,s)=>{(!i||i.trim()==="")&&(a[`domains.${s}`]="Domain required")})}return a}function ji(t,n){if(!t)return"Global";const a=n.find(l=>l.id===t);return a?a.name:t.slice(0,8)+"..."}function Zt(t){const n=Ia.find(a=>a.value===t);return n?n.label:t}const zn=[{key:"policies",label:"Policies"},{key:"defaults",label:"Defaults"}],Qt=["security.policy_defaults_delay_seconds","security.policy_defaults_approval_timeout","policy.default_deny_tokens","policy.default_deny_contracts","policy.default_deny_spenders","policy.default_deny_x402_domains"];function Yi(){const t=d({}),n=d({}),a=d(!1),l=d(!0),i=async()=>{try{const o=await z(L.ADMIN_SETTINGS);t.value=o}catch(o){const v=o instanceof w?o:new w(0,"UNKNOWN","Unknown error");E("error",$(v.code))}finally{l.value=!1}};F(()=>{i()},[]);const s=(o,v)=>{const u=String(v);n.value={...n.value,[o]:u}},r=async()=>{a.value=!0;try{const o=Object.entries(n.value).filter(([u])=>Qt.includes(u)).map(([u,m])=>({key:u,value:m})),v=await he(L.ADMIN_SETTINGS,{settings:o});t.value=v.settings,n.value={},E("success","Policy defaults saved and applied")}catch(o){const v=o instanceof w?o:new w(0,"UNKNOWN","Unknown error");E("error",$(v.code))}finally{a.value=!1}},c=()=>{n.value={}};F(()=>(Ne({id:"policies-defaults",isDirty:()=>Object.keys(n.value).filter(o=>Qt.includes(o)).length>0,save:r,discard:c}),()=>ke("policies-defaults")),[]);const h=Object.keys(n.value).filter(o=>Qt.includes(o)).length;return l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(Y,{children:[h>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[h," unsaved change",h>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(R,{variant:"ghost",size:"sm",onClick:c,children:"Discard"}),e(R,{variant:"primary",size:"sm",onClick:r,loading:a.value,children:"Save"})]})]}),e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Policy Defaults"}),e("p",{class:"settings-description",children:"Configure default delay, approval timeout, and default-deny policies. Changes apply immediately without daemon restart."})]}),e("div",{class:"settings-category-body",children:[e("div",{class:"settings-fields-grid",children:[e(A,{label:V("policy_defaults_delay_seconds"),name:"security.policy_defaults_delay_seconds",type:"number",value:Number(J(t.value,n.value,"security","policy_defaults_delay_seconds"))||0,onChange:o=>s("security.policy_defaults_delay_seconds",o),min:0,description:"Default delay before executing delayed-tier transactions"}),e(A,{label:V("policy_defaults_approval_timeout"),name:"security.policy_defaults_approval_timeout",type:"number",value:Number(J(t.value,n.value,"security","policy_defaults_approval_timeout"))||0,onChange:o=>s("security.policy_defaults_approval_timeout",o),min:60,description:"How long to wait for owner approval before timeout"})]}),e("div",{class:"settings-subgroup",style:{marginTop:"1rem",borderTop:"1px solid var(--border)",paddingTop:"1rem"},children:[e("h4",{style:{margin:"0 0 0.5rem 0",fontSize:"0.875rem",fontWeight:600,color:"var(--text-secondary)"},children:"Default Deny Policies"}),e("div",{class:"settings-fields-grid",children:[e(A,{label:V("default_deny_tokens"),name:"policy.default_deny_tokens",type:"checkbox",value:xe(t.value,n.value,"policy","default_deny_tokens"),onChange:o=>s("policy.default_deny_tokens",o),description:"Deny token transfers unless a matching whitelist policy exists"}),e(A,{label:V("default_deny_contracts"),name:"policy.default_deny_contracts",type:"checkbox",value:xe(t.value,n.value,"policy","default_deny_contracts"),onChange:o=>s("policy.default_deny_contracts",o),description:"Deny contract calls unless a matching whitelist policy exists"}),e(A,{label:V("default_deny_spenders"),name:"policy.default_deny_spenders",type:"checkbox",value:xe(t.value,n.value,"policy","default_deny_spenders"),onChange:o=>s("policy.default_deny_spenders",o),description:"Deny token approvals unless a matching whitelist policy exists"}),e(A,{label:V("default_deny_x402_domains"),name:"policy.default_deny_x402_domains",type:"checkbox",value:xe(t.value,n.value,"policy","default_deny_x402_domains"),onChange:o=>s("policy.default_deny_x402_domains",o),description:"Deny x402 payments unless a matching domain whitelist policy exists"})]})]}),e("div",{class:"settings-info-box",children:"When enabled, transactions are denied if no matching whitelist policy exists. Disable to allow all transactions of that type when no policy is configured."})]})]})]})}function Xi(){const t=d("policies");F(()=>{const x=le.value;x&&x.tab&&(t.value=x.tab,setTimeout(()=>{_e.value=x.fieldName},100),le.value=null)},[le.value]);const n=d([]),a=d([]),l=d("__all__"),i=d(!1),s=d(!0),r=d(!1),c=d("SPENDING_LIMIT"),h=d(""),o=d(JSON.stringify(it.SPENDING_LIMIT,null,2)),v=d(it.SPENDING_LIMIT),u=d({}),m=d(!1),N=d(0),M=d(!0),I=d(""),_=d(null),D=d(!1),P=d(!1),K=d(null),y=d(""),b=d({}),U=d(!1),S=d({}),p=d(0),g=d(!0),f=d(null),O=d(!1),W=d(!1),q=d(null),ae=d(!1),H=async()=>{try{const x=await z(L.WALLETS);n.value=x.items}catch(x){const te=x instanceof w?x:new w(0,"UNKNOWN","Unknown error");E("error",$(te.code))}finally{s.value=!1}},ne=async()=>{i.value=!0;try{let x=L.POLICIES;l.value!=="__all__"&&l.value!=="__global__"&&(x=`${L.POLICIES}?walletId=${l.value}`);const te=await z(x);l.value==="__global__"?a.value=te.filter(ye=>ye.walletId===null):a.value=te}catch(x){const te=x instanceof w?x:new w(0,"UNKNOWN","Unknown error");E("error",$(te.code))}finally{i.value=!1}},de=async()=>{_.value=null;let x;if(m.value)try{x=JSON.parse(o.value)}catch{_.value="Invalid JSON in rules field";return}else{const te=Nt(c.value,v.value);if(Object.keys(te).length>0){u.value=te;return}u.value={},x=v.value}D.value=!0;try{await se(L.POLICIES,{walletId:h.value||void 0,type:c.value,rules:x,priority:N.value,enabled:M.value,network:I.value||void 0}),E("success","Policy created"),r.value=!1,c.value="SPENDING_LIMIT",h.value="",I.value="",o.value=JSON.stringify(it.SPENDING_LIMIT,null,2),v.value=it.SPENDING_LIMIT,u.value={},m.value=!1,N.value=0,M.value=!0,_.value=null,await ne()}catch(te){const ye=te instanceof w?te:new w(0,"UNKNOWN","Unknown error");E("error",$(ye.code))}finally{D.value=!1}},re=x=>{K.value=x,y.value=JSON.stringify(x.rules,null,2),b.value={...x.rules},U.value=!1,S.value={},p.value=x.priority,g.value=x.enabled,f.value=null,P.value=!0},me=async()=>{f.value=null;let x;if(U.value)try{x=JSON.parse(y.value)}catch{f.value="Invalid JSON in rules field";return}else{const te=Nt(K.value.type,b.value);if(Object.keys(te).length>0){S.value=te;return}S.value={},x=b.value}O.value=!0;try{await he(L.POLICY(K.value.id),{rules:x,priority:p.value,enabled:g.value}),E("success","Policy updated"),P.value=!1,await ne()}catch(te){const ye=te instanceof w?te:new w(0,"UNKNOWN","Unknown error");E("error",$(ye.code))}finally{O.value=!1}},ie=()=>{if(!U.value)y.value=JSON.stringify(b.value,null,2);else try{b.value=JSON.parse(y.value),f.value=null}catch{f.value="Invalid JSON — cannot switch to form mode";return}U.value=!U.value},Pe=x=>{q.value=x,W.value=!0},Ee=async()=>{ae.value=!0;try{await Ke(L.POLICY(q.value.id)),E("success","Policy deleted"),W.value=!1,await ne()}catch(x){const te=x instanceof w?x:new w(0,"UNKNOWN","Unknown error");E("error",$(te.code))}finally{ae.value=!1}},Ae=x=>{const te=x;c.value=te;const ye=it[te];ye&&(o.value=JSON.stringify(ye,null,2),v.value={...ye}),u.value={},m.value=!1},we=()=>{if(!m.value)o.value=JSON.stringify(v.value,null,2);else try{v.value=JSON.parse(o.value),_.value=null}catch{_.value="Invalid JSON — cannot switch to form mode";return}m.value=!m.value};F(()=>{H()},[]),F(()=>{ne()},[l.value]);const et=[{key:"type",header:"Type",render:x=>e(B,{variant:x.type==="SPENDING_LIMIT"?"success":"info",children:Zt(x.type)})},{key:"walletId",header:"Wallet",render:x=>ji(x.walletId,n.value)},{key:"network",header:"Network",render:x=>x.network??"All"},{key:"rules",header:"Rules",render:x=>e(qi,{type:x.type,rules:x.rules})},{key:"priority",header:"Priority"},{key:"enabled",header:"Enabled",render:x=>e(B,{variant:x.enabled?"success":"danger",children:x.enabled?"ON":"OFF"})},{key:"actions",header:"Actions",render:x=>e("span",{style:{display:"flex",gap:"0.25rem"},children:[e("button",{class:"btn btn-ghost btn-sm",onClick:te=>{te.stopPropagation(),re(x)},children:"Edit"}),e(R,{size:"sm",variant:"danger",onClick:()=>Pe(x),children:"Delete"})]})}];return e("div",{class:"page",children:[e(Qe,{pageName:"Policies",tabName:zn.find(x=>x.key===t.value)?.label??"",onPageClick:()=>{t.value="policies"}}),e(He,{tabs:zn,activeTab:t.value,onTabChange:x=>{t.value=x}}),t.value==="policies"&&e(Y,{children:[e("div",{class:"policy-controls",children:[e("div",{class:"policy-filter-select",children:[e("label",{for:"policy-wallet-filter",children:"Filter by Wallet"}),e("select",{id:"policy-wallet-filter",value:l.value,onChange:x=>{l.value=x.target.value},disabled:s.value,children:[e("option",{value:"__all__",children:"All Policies"}),e("option",{value:"__global__",children:"Global Only"}),n.value.map(x=>e("option",{value:x.id,children:[x.name," (",x.chain,"/",x.network,")"]},x.id))]})]}),!r.value&&e(R,{onClick:()=>{r.value=!0},children:"Create Policy"})]}),r.value&&e("div",{class:"inline-form",children:[e(A,{label:"Type",name:"type",type:"select",value:c.value,onChange:Ae,options:Ia,description:Jt[c.value]??""}),e(A,{label:"Wallet",name:"walletId",type:"select",value:h.value,onChange:x=>{h.value=x},options:[{label:"Global (no wallet)",value:""},...n.value.map(x=>({label:`${x.name} (${x.chain}/${x.network})`,value:x.id}))]}),e(A,{label:"Network Scope",name:"network",value:I.value,onChange:x=>{I.value=x},placeholder:"e.g. polygon-mainnet (leave empty for all networks)"}),e("div",{class:"policy-form-section",children:[e("div",{class:"policy-form-header",children:[e("label",{children:"Rules"}),e("button",{class:"btn btn-ghost btn-sm json-toggle",onClick:we,children:m.value?"Switch to Form":"JSON Direct Edit"})]}),m.value?e(A,{label:"",name:"rules",type:"textarea",value:o.value,onChange:x=>{o.value=x},error:_.value??void 0}):e(Bn,{type:c.value,rules:v.value,onChange:x=>{v.value=x,Object.keys(u.value).length>0&&(u.value=Nt(c.value,x))},errors:u.value,network:I.value})]}),e(A,{label:"Priority",name:"priority",type:"number",value:N.value,onChange:x=>{N.value=x},min:0,max:999}),e(A,{label:"Enabled",name:"enabled",type:"checkbox",value:M.value,onChange:x=>{M.value=x}}),e("div",{class:"inline-form-actions",children:[e(R,{onClick:de,loading:D.value,children:"Create"}),e(R,{variant:"secondary",onClick:()=>{r.value=!1,_.value=null},children:"Cancel"})]})]}),e(Ze,{columns:et,data:a.value,loading:i.value,emptyMessage:"No policies found"}),e(be,{open:P.value,title:"Edit Policy",onCancel:()=>{P.value=!1},onConfirm:me,confirmText:"Save",loading:O.value,children:K.value&&e("div",{children:[e("div",{class:"policy-type-readonly",children:["Type: ",Zt(K.value.type),Jt[K.value.type]&&e("span",{class:"form-description",children:Jt[K.value.type]})]}),e("div",{class:"policy-form-section",children:[e("div",{class:"policy-form-header",children:[e("label",{children:"Rules"}),e("button",{class:"btn btn-ghost btn-sm json-toggle",onClick:ie,children:U.value?"Switch to Form":"JSON Direct Edit"})]}),U.value?e("div",{class:"edit-rules-textarea",children:e(A,{label:"",name:"edit-rules",type:"textarea",value:y.value,onChange:x=>{y.value=x},error:f.value??void 0})}):e(Bn,{type:K.value.type,rules:b.value,onChange:x=>{b.value=x,Object.keys(S.value).length>0&&(S.value=Nt(K.value.type,x))},errors:S.value,network:K.value.network??""})]}),e(A,{label:"Priority",name:"edit-priority",type:"number",value:p.value,onChange:x=>{p.value=x},min:0,max:999}),e(A,{label:"Enabled",name:"edit-enabled",type:"checkbox",value:g.value,onChange:x=>{g.value=x}})]})}),e(be,{open:W.value,title:"Delete Policy",onCancel:()=>{W.value=!1},onConfirm:Ee,confirmText:"Delete",confirmVariant:"danger",loading:ae.value,children:q.value&&e("p",{children:["Are you sure you want to delete this"," ",e("strong",{children:Zt(q.value.type)})," policy? This action cannot be undone."]})})]}),t.value==="defaults"&&e(Yi,{})]})}function Ji(){return e(Zi,{})}function Zi(){const t=d([]),n=d(!0),a=d(!1),l=d(null),i=d("ADMIN"),s=d(!1),r=d(!1),c=d(null),h=d(!1),o=async()=>{n.value=!0;try{const _=await z(L.ADMIN_TELEGRAM_USERS);t.value=_.users}catch(_){const D=_ instanceof w?_:new w(0,"UNKNOWN","Unknown error");E("error",$(D.code))}finally{n.value=!1}};F(()=>{o()},[]);const v=_=>{l.value=_,i.value="ADMIN",a.value=!0},u=async()=>{if(l.value){s.value=!0;try{await he(L.ADMIN_TELEGRAM_USER(l.value.chat_id),{role:i.value}),E("success",`User approved as ${i.value}`),a.value=!1,l.value=null,await o()}catch(_){const D=_ instanceof w?_:new w(0,"UNKNOWN","Unknown error");E("error",$(D.code))}finally{s.value=!1}}},m=_=>{c.value=_,r.value=!0},N=async()=>{if(c.value){h.value=!0;try{await Ke(L.ADMIN_TELEGRAM_USER(c.value.chat_id)),E("success","User deleted"),r.value=!1,c.value=null,await o()}catch(_){const D=_ instanceof w?_:new w(0,"UNKNOWN","Unknown error");E("error",$(D.code))}finally{h.value=!1}}},M=_=>_==="PENDING"?"warning":_==="ADMIN"?"success":"info";return e("div",{class:"page",children:[e(Ze,{columns:[{key:"chat_id",header:"Chat ID",render:_=>String(_.chat_id)},{key:"username",header:"Username",render:_=>_.username??"-"},{key:"role",header:"Role",render:_=>e(B,{variant:M(_.role),children:_.role})},{key:"registered_at",header:"Registered",render:_=>ve(_.registered_at)},{key:"approved_at",header:"Approved",render:_=>_.approved_at?ve(_.approved_at):"-"},{key:"actions",header:"Actions",render:_=>e("div",{style:{display:"flex",gap:"var(--space-1)"},children:[_.role==="PENDING"&&e(R,{size:"sm",variant:"primary",onClick:()=>v(_),children:"Approve"}),e(R,{size:"sm",variant:"danger",onClick:()=>m(_),children:"Delete"})]})}],data:t.value,loading:n.value,emptyMessage:"No Telegram users registered. Users appear here after sending /start to the bot."}),e(be,{open:a.value,title:"Approve Telegram User",onCancel:()=>{a.value=!1,l.value=null},onConfirm:u,confirmText:"Approve",confirmVariant:"primary",loading:s.value,children:l.value&&e("div",{children:[e("p",{children:[e("strong",{children:"Chat ID:"})," ",l.value.chat_id,l.value.username&&e("span",{children:[" (",e("strong",{children:["@",l.value.username]}),")"]})]}),e("div",{class:"form-field",style:{marginTop:"var(--space-3)"},children:[e("label",{for:"approve-role",children:"Role"}),e("select",{id:"approve-role",value:i.value,onChange:_=>{i.value=_.target.value},children:[e("option",{value:"ADMIN",children:"ADMIN"}),e("option",{value:"READONLY",children:"READONLY"})]})]})]})}),e(be,{open:r.value,title:"Delete Telegram User",onCancel:()=>{r.value=!1,c.value=null},onConfirm:N,confirmText:"Delete",confirmVariant:"danger",loading:h.value,children:e("p",{children:"Are you sure you want to remove this user? They will need to /start again to re-register."})})]})}const en=20,qn=[{key:"channels",label:"Channels & Logs"},{key:"telegram",label:"Telegram Users"},{key:"settings",label:"Settings"},{key:"balance",label:"Balance Monitor"}],Qi=[{key:"eventType",label:"Event Type",type:"select",options:[{value:"tx.submitted",label:"tx.submitted"},{value:"tx.confirmed",label:"tx.confirmed"},{value:"tx.failed",label:"tx.failed"},{value:"policy.violation",label:"policy.violation"},{value:"security.kill_switch",label:"security.kill_switch"},{value:"security.auto_stop",label:"security.auto_stop"},{value:"security.suspicious_tx",label:"security.suspicious_tx"},{value:"session.created",label:"session.created"},{value:"session.expired",label:"session.expired"},{value:"owner.registered",label:"owner.registered"},{value:"owner.verified",label:"owner.verified"},{value:"incoming.detected",label:"incoming.detected"},{value:"incoming.suspicious",label:"incoming.suspicious"}]},{key:"channel",label:"Channel",type:"select",options:[{value:"telegram",label:"Telegram"},{value:"discord",label:"Discord"},{value:"ntfy",label:"ntfy"},{value:"slack",label:"Slack"},{value:"wallet_app",label:"Wallet App"}]},{key:"status",label:"Status",type:"select",options:[{value:"sent",label:"Sent"},{value:"failed",label:"Failed"}]},{key:"since",label:"Since",type:"date"},{key:"until",label:"Until",type:"date"}];function es(){const t=d({}),n=d({}),a=d(!1),l=d(!0),i=d([]),s=d(!1),r=async()=>{try{const m=await z(L.ADMIN_SETTINGS);t.value=m}catch(m){const N=m instanceof w?m:new w(0,"UNKNOWN","Unknown error");E("error",$(N.code))}finally{l.value=!1}};F(()=>{r()},[]);const c=(m,N)=>{const M=String(N);n.value={...n.value,[m]:M}},h=async()=>{a.value=!0;try{const m=Object.entries(n.value).filter(([M])=>M.startsWith("notifications.")||M.startsWith("telegram.")).map(([M,I])=>({key:M,value:I})),N=await he(L.ADMIN_SETTINGS,{settings:m});t.value=N.settings,n.value={},E("success","Notification settings saved and applied")}catch(m){const N=m instanceof w?m:new w(0,"UNKNOWN","Unknown error");E("error",$(N.code))}finally{a.value=!1}},o=()=>{n.value={}};F(()=>(Ne({id:"notifications-settings",isDirty:()=>Object.keys(n.value).filter(m=>m.startsWith("notifications.")||m.startsWith("telegram.")).length>0,save:h,discard:o}),()=>ke("notifications-settings")),[]);const v=async()=>{s.value=!0,i.value=[];try{const m=await se(L.ADMIN_NOTIFICATIONS_TEST,{});if(i.value=m.results,m.results.length===0)E("info","No notification channels configured");else{const N=m.results.every(M=>M.success);E(N?"success":"warning",N?"All test notifications sent":"Some channels failed")}}catch(m){const N=m instanceof w?m:new w(0,"UNKNOWN","Unknown error");E("error",$(N.code))}finally{s.value=!1}},u=Object.keys(n.value).filter(m=>m.startsWith("notifications.")||m.startsWith("telegram.")).length;return l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(Y,{children:[u>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[u," unsaved change",u>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(R,{variant:"ghost",size:"sm",onClick:o,children:"Discard"}),e(R,{variant:"primary",size:"sm",onClick:h,loading:a.value,children:"Save"})]})]}),e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Notification Configuration"}),e("p",{class:"settings-description",children:"Configure notification channels for transaction alerts. Changes apply immediately via hot-reload."})]}),e("div",{class:"settings-category-body",children:[e("div",{class:"settings-fields-grid",style:{marginBottom:"var(--space-4)"},children:[e("div",{class:"settings-field-full",children:e(A,{label:"Enabled",name:"notifications.enabled",type:"checkbox",value:xe(t.value,n.value,"notifications","enabled"),onChange:m=>c("notifications.enabled",m),description:"Enable or disable notifications globally"})}),e(A,{label:V("locale"),name:"notifications.locale",type:"select",value:J(t.value,n.value,"notifications","locale")||"en",onChange:m=>c("notifications.locale",m),options:[{label:"English",value:"en"},{label:"Korean",value:"ko"}],description:"Language for notification messages"})]}),e(We,{legend:"Telegram",description:"Telegram notification channel and bot configuration",children:[e("div",{class:"settings-info-box",style:{marginBottom:"0.75rem"},children:["Get your bot token from"," ",e("a",{href:"https://t.me/BotFather",target:"_blank",rel:"noopener noreferrer",children:"@BotFather"})," ","— send /newbot and follow the instructions. To get your Chat ID, send a message to your bot then visit"," ",e("a",{href:"https://api.telegram.org",target:"_blank",rel:"noopener noreferrer",children:"Telegram Bot API"}),"."]}),e("div",{class:"settings-fields-grid",children:[e(A,{label:V("telegram_bot_token"),name:"notifications.telegram_bot_token",type:"password",value:J(t.value,n.value,"notifications","telegram_bot_token"),onChange:m=>c("notifications.telegram_bot_token",m),placeholder:rt(t.value,n.value,"notifications","telegram_bot_token")?"(configured)":"",description:"Bot token for Telegram notifications"}),e(A,{label:V("telegram_chat_id"),name:"notifications.telegram_chat_id",type:"text",value:J(t.value,n.value,"notifications","telegram_chat_id"),onChange:m=>c("notifications.telegram_chat_id",m),description:"Chat ID for Telegram notification delivery"})]}),e("div",{class:"settings-subgroup",style:{marginTop:"0.75rem",borderTop:"1px solid var(--border)",paddingTop:"0.75rem"},children:[e("div",{class:"settings-subgroup-title",children:"Telegram Bot"}),e("div",{class:"settings-fields-grid",children:[e(A,{label:V("bot_token"),name:"telegram.bot_token",type:"password",value:J(t.value,n.value,"telegram","bot_token"),onChange:m=>c("telegram.bot_token",m),placeholder:rt(t.value,n.value,"telegram","bot_token")?"(configured)":"Leave empty to use notification token",description:"Dedicated bot token for Telegram bot (optional, uses notification token if empty)"}),e(A,{label:"Locale",name:"telegram.locale",type:"select",value:J(t.value,n.value,"telegram","locale")||"en",onChange:m=>c("telegram.locale",m),options:[{label:"English",value:"en"},{label:"한국어",value:"ko"}],description:"Language for Telegram bot messages"})]})]})]}),e(We,{legend:"Other Channels",description:"Discord, ntfy, Slack, and rate limiting",children:[e("div",{class:"settings-info-box",style:{marginBottom:"0.75rem"},children:[e("strong",{children:"Discord:"})," Create a webhook in Server Settings > Integrations >"," ",e("a",{href:"https://support.discord.com/hc/en-us/articles/228383668",target:"_blank",rel:"noopener noreferrer",children:"Webhooks"}),"."," ",e("strong",{children:"ntfy:"})," Use any"," ",e("a",{href:"https://ntfy.sh",target:"_blank",rel:"noopener noreferrer",children:"ntfy server"})," (self-hosted or ntfy.sh)."," ",e("strong",{children:"Slack:"})," Create an"," ",e("a",{href:"https://api.slack.com/messaging/webhooks",target:"_blank",rel:"noopener noreferrer",children:"Incoming Webhook"})," in your Slack workspace."]}),e("div",{class:"settings-fields-grid",children:[e(A,{label:V("discord_webhook_url"),name:"notifications.discord_webhook_url",type:"password",value:J(t.value,n.value,"notifications","discord_webhook_url"),onChange:m=>c("notifications.discord_webhook_url",m),placeholder:rt(t.value,n.value,"notifications","discord_webhook_url")?"(configured)":"",description:"Webhook URL for Discord notifications"}),e(A,{label:V("ntfy_server"),name:"notifications.ntfy_server",type:"text",value:J(t.value,n.value,"notifications","ntfy_server"),onChange:m=>c("notifications.ntfy_server",m),description:"Server URL for ntfy notifications"}),e(A,{label:V("ntfy_topic"),name:"notifications.ntfy_topic",type:"text",value:J(t.value,n.value,"notifications","ntfy_topic"),onChange:m=>c("notifications.ntfy_topic",m),description:"Topic name for ntfy notifications"}),e(A,{label:"Slack Webhook URL",name:"notifications.slack_webhook_url",type:"password",value:J(t.value,n.value,"notifications","slack_webhook_url"),onChange:m=>c("notifications.slack_webhook_url",m),placeholder:rt(t.value,n.value,"notifications","slack_webhook_url")?"(configured)":"",description:"Webhook URL for Slack notifications"}),e(A,{label:V("rate_limit_rpm"),name:"notifications.rate_limit_rpm",type:"number",value:Number(J(t.value,n.value,"notifications","rate_limit_rpm"))||20,onChange:m=>c("notifications.rate_limit_rpm",m),min:1,max:1e3,description:"Max notifications per minute"})]})]}),e(We,{legend:"Event Filter",description:"Choose which notification events are delivered. All checked = receive all.",children:[(()=>{const m=new Set(["KILL_SWITCH_ACTIVATED","KILL_SWITCH_RECOVERED","AUTO_STOP_TRIGGERED","TX_INCOMING_SUSPICIOUS"]),N=[{category:"transaction",label:"Transaction Events",events:[{event:"TX_REQUESTED",desc:"Transaction request received"},{event:"TX_QUEUED",desc:"Waiting in time-delay queue"},{event:"TX_SUBMITTED",desc:"Submitted to blockchain"},{event:"TX_CONFIRMED",desc:"Confirmed on-chain"},{event:"TX_FAILED",desc:"Transaction failed"},{event:"TX_CANCELLED",desc:"Cancelled by user or policy"},{event:"TX_DOWNGRADED_DELAY",desc:"Auto-approved demoted to time-delay"},{event:"TX_APPROVAL_REQUIRED",desc:"Owner approval required"},{event:"TX_APPROVAL_EXPIRED",desc:"Approval wait timed out"},{event:"TX_INCOMING",desc:"Incoming transaction detected"}]},{category:"policy",label:"Policy",events:[{event:"POLICY_VIOLATION",desc:"Blocked by policy rule"},{event:"CUMULATIVE_LIMIT_WARNING",desc:"Cumulative spend limit warning"}]},{category:"security_alert",label:"Security Alerts",events:[{event:"WALLET_SUSPENDED",desc:"Wallet suspended"},{event:"KILL_SWITCH_ACTIVATED",desc:"Emergency lock activated"},{event:"KILL_SWITCH_RECOVERED",desc:"Emergency lock released"},{event:"KILL_SWITCH_ESCALATED",desc:"Kill switch escalated"},{event:"AUTO_STOP_TRIGGERED",desc:"Auto-stop triggered"},{event:"TX_INCOMING_SUSPICIOUS",desc:"Suspicious incoming transaction"}]},{category:"session",label:"Session Events",events:[{event:"SESSION_EXPIRING_SOON",desc:"Session expiring soon"},{event:"SESSION_EXPIRED",desc:"Session expired"},{event:"SESSION_CREATED",desc:"Session created"},{event:"SESSION_WALLET_ADDED",desc:"Wallet added to session"},{event:"SESSION_WALLET_REMOVED",desc:"Wallet removed from session"}]},{category:"owner",label:"Owner Events",events:[{event:"OWNER_SET",desc:"Owner address registered"},{event:"OWNER_REMOVED",desc:"Owner address removed"},{event:"OWNER_VERIFIED",desc:"Owner address verified"}]},{category:"system",label:"System Notifications",events:[{event:"DAILY_SUMMARY",desc:"Daily summary report"},{event:"LOW_BALANCE",desc:"Low balance warning"},{event:"APPROVAL_CHANNEL_SWITCHED",desc:"Approval channel changed"},{event:"UPDATE_AVAILABLE",desc:"Daemon update available"}]}],M=N.flatMap(y=>y.events.map(b=>b.event)).filter(y=>!m.has(y)),I=J(t.value,n.value,"notifications","notify_events")||"[]";let _=[];try{const y=JSON.parse(I);Array.isArray(y)&&(_=y)}catch{}const D=_.length===0?M:_,P=(y,b)=>{const U=b?[...D,y]:D.filter(p=>p!==y),S=U.length===M.length&&M.every(p=>U.includes(p))?[]:U;c("notifications.notify_events",JSON.stringify(S))},K=(y,b)=>{const U=y.events.filter(g=>!m.has(g.event)).map(g=>g.event);let S;if(b)S=[...new Set([...D,...U])];else{const g=new Set(U);S=D.filter(f=>!g.has(f))}const p=S.length===M.length&&M.every(g=>S.includes(g))?[]:S;c("notifications.notify_events",JSON.stringify(p))};return e("div",{class:"event-filter-groups",children:N.map(y=>{const b=y.events.filter(p=>!m.has(p.event)),U=b.every(p=>D.includes(p.event)),S=b.some(p=>D.includes(p.event));return e("details",{class:"event-filter-group",open:!0,children:[e("summary",{class:"event-filter-group-header",children:[e("span",{class:"event-filter-group-label",children:y.label}),e("label",{class:"event-filter-group-all",onClick:p=>p.stopPropagation(),children:[e("input",{type:"checkbox",checked:U,ref:p=>{p&&(p.indeterminate=S&&!U)},onChange:p=>K(y,p.target.checked)})," All"]})]}),e("div",{class:"event-filter-events",children:y.events.map(p=>{const g=m.has(p.event);return e("label",{class:`event-filter-event ${g?"event-broadcast":""}`,children:[e("input",{type:"checkbox",checked:g||D.includes(p.event),disabled:g,onChange:f=>P(p.event,f.target.checked)}),e("code",{children:p.event}),e("span",{class:"event-desc",children:p.desc}),g&&e("span",{class:"event-broadcast-badge",children:"Always sent"})]},p.event)})})]},y.category)})})})(),e("div",{class:"settings-info-box",style:{marginTop:"0.5rem"},children:"Applies to all notification channels (Telegram, Discord, ntfy, Slack) and wallet app side channel. Broadcast events (Kill Switch, Auto Stop, Suspicious TX) always bypass the filter."})]}),e("div",{class:"notif-test-section",children:[e(R,{variant:"secondary",size:"sm",onClick:v,loading:s.value,children:"Test Notification"}),i.value.length>0&&e("div",{class:"test-results",children:i.value.map(m=>e("div",{class:`test-result-item ${m.success?"test-result-success":"test-result-failure"}`,children:[e(B,{variant:m.success?"success":"danger",children:m.success?"OK":"FAIL"}),e("span",{children:m.channel}),m.error&&e("span",{style:"font-size: var(--font-size-xs); color: var(--color-danger);",children:[" - ",m.error]})]},m.channel))})]})]})]})]})}const jn={enabled:"Enable or disable balance monitoring",check_interval_sec:"How often to check wallet balances",low_balance_threshold_sol:"Alert when SOL balance drops below this amount",low_balance_threshold_eth:"Alert when ETH balance drops below this amount",cooldown_hours:"Suppress duplicate alerts for this many hours"};function ts(){const t=d({}),n=d({}),a=d(!1),l=d(!0),i=async()=>{try{const v=await z(L.ADMIN_SETTINGS);t.value=v}catch(v){const u=v instanceof w?v:new w(0,"UNKNOWN","Unknown error");E("error",$(u.code))}finally{l.value=!1}};F(()=>{i()},[]);const s=(v,u)=>{const m=String(u);n.value={...n.value,[v]:m}},r=async()=>{a.value=!0;try{const v=Object.entries(n.value).filter(([m])=>m.startsWith("monitoring.")).map(([m,N])=>({key:m,value:N})),u=await he(L.ADMIN_SETTINGS,{settings:v});t.value=u.settings,n.value={},E("success","Settings saved and applied")}catch(v){const u=v instanceof w?v:new w(0,"UNKNOWN","Unknown error");E("error",$(u.code))}finally{a.value=!1}},c=()=>{n.value={}};F(()=>(Ne({id:"notifications-balance",isDirty:()=>Object.keys(n.value).filter(v=>v.startsWith("monitoring.")).length>0,save:r,discard:c}),()=>ke("notifications-balance")),[]);const h=[{key:"enabled",type:"checkbox"},{key:"check_interval_sec",type:"number",min:60,max:86400},{key:"low_balance_threshold_sol",type:"number",min:0},{key:"low_balance_threshold_eth",type:"number",min:0},{key:"cooldown_hours",type:"number",min:1,max:168}],o=Object.keys(n.value).filter(v=>v.startsWith("monitoring.")).length;return l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(Y,{children:[o>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[o," unsaved change",o>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(R,{variant:"ghost",size:"sm",onClick:c,children:"Discard"}),e(R,{variant:"primary",size:"sm",onClick:r,loading:a.value,children:"Save"})]})]}),e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Balance Monitoring"}),e("p",{class:"settings-description",children:"Periodic balance checks for all active wallets. Sends LOW_BALANCE alerts when native token balance drops below thresholds. Changes apply immediately."})]}),e("div",{class:"settings-category-body",children:[e("div",{class:"settings-fields-grid",children:h.map(v=>v.type==="checkbox"?e("div",{class:"settings-field-full",children:e(A,{label:V(v.key),name:`monitoring.${v.key}`,type:"checkbox",value:xe(t.value,n.value,"monitoring",v.key),onChange:u=>s(`monitoring.${v.key}`,u),description:jn[v.key]})},v.key):e(A,{label:V(v.key),name:`monitoring.${v.key}`,type:"number",value:Number(J(t.value,n.value,"monitoring",v.key))||0,onChange:u=>s(`monitoring.${v.key}`,u),min:v.min,max:v.max,description:jn[v.key]},v.key))}),e("div",{class:"settings-info-box",children:"Monitors all active wallet native token balances (SOL, ETH) at the configured interval. When balance drops below threshold, a LOW_BALANCE notification is sent. Duplicate alerts are suppressed for the cooldown period (per wallet)."})]})]})]})}function Yn(){const t=d("channels");F(()=>{const S=le.value;S&&S.tab&&(t.value=S.tab,setTimeout(()=>{_e.value=S.fieldName},100),le.value=null)},[le.value]);const n=d(null),a=d(!0),l=d(!1),i=d(null),s=d(null),r=d(null),c=d(!0),h=d(1),o=d(null),v=d({eventType:"",channel:"",status:"",since:"",until:""}),u=async()=>{try{const S=await z(L.ADMIN_NOTIFICATIONS_STATUS);n.value=S}catch(S){const p=S instanceof w?S:new w(0,"UNKNOWN","Unknown error");E("error",$(p.code))}finally{a.value=!1}},m=async S=>{c.value=!0;try{const p=new URLSearchParams;p.set("page",String(S)),p.set("pageSize",String(en));const g=v.value;if(g.eventType&&p.set("eventType",g.eventType),g.channel&&p.set("channel",g.channel),g.status&&p.set("status",g.status),g.since){const O=new Date(g.since);isNaN(O.getTime())||p.set("since",String(Math.floor(O.getTime()/1e3)))}if(g.until){const O=new Date(g.until);isNaN(O.getTime())||(O.setHours(23,59,59,999),p.set("until",String(Math.floor(O.getTime()/1e3))))}const f=await z(`${L.ADMIN_NOTIFICATIONS_LOG}?${p.toString()}`);r.value=f}catch(p){const g=p instanceof w?p:new w(0,"UNKNOWN","Unknown error");E("error",$(g.code))}finally{c.value=!1}},N=async()=>{l.value=!0,s.value=null;try{const p=(await se(L.ADMIN_NOTIFICATIONS_TEST,{})).results;s.value=p,p.every(f=>f.success)?E("success","Test sent successfully"):E("warning","Some channels failed")}catch(S){const p=S instanceof w?S:new w(0,"UNKNOWN","Unknown error");E("error",$(p.code))}finally{l.value=!1}},M=async S=>{i.value=S,s.value=null;try{const g=(await se(L.ADMIN_NOTIFICATIONS_TEST,{channel:S})).results;s.value=g,g.every(O=>O.success)?E("success",`Test sent to ${S}`):E("warning",`${S} test failed`)}catch(p){const g=p instanceof w?p:new w(0,"UNKNOWN","Unknown error");E("error",$(g.code))}finally{i.value=null}},I=()=>{h.value>1&&(h.value-=1,m(h.value))},_=()=>{const S=r.value?Math.ceil(r.value.total/en):1;h.value<S&&(h.value+=1,m(h.value))},D=S=>{o.value=o.value?.id===S.id?null:S},P=S=>{v.value=S,h.value=1,m(1)};F(()=>{u(),m(1);const S=setInterval(()=>m(h.value),3e4);return()=>clearInterval(S)},[]);const K=a.value&&!n.value,y=n.value?.channels.some(S=>S.enabled)??!1,b=r.value?Math.max(1,Math.ceil(r.value.total/en)):1,U=[{key:"eventType",header:"Event Type"},{key:"walletId",header:"Wallet ID",render:S=>S.walletId?e("a",{href:`#/wallets/${S.walletId}`,class:"wallet-link",onClick:p=>p.stopPropagation(),title:S.walletId,children:[S.walletId.slice(0,8),"..."]}):"—"},{key:"channel",header:"Channel",render:S=>e("span",{style:{textTransform:"capitalize"},children:S.channel})},{key:"status",header:"Status",render:S=>e(B,{variant:S.status==="sent"?"success":"danger",children:S.status})},{key:"createdAt",header:"Time",render:S=>ve(S.createdAt)}];return e("div",{class:"page",children:[e(Qe,{pageName:"Notifications",tabName:qn.find(S=>S.key===t.value)?.label??"",onPageClick:()=>{t.value="channels"}}),e(He,{tabs:qn,activeTab:t.value,onTabChange:S=>{t.value=S}}),t.value==="telegram"?e(Ji,{}):t.value==="settings"?e(es,{}):t.value==="balance"?e(ts,{}):e(Y,{children:[e("h2",{children:"Channel Status"}),n.value&&!n.value.enabled&&e("div",{class:"notif-disabled-banner",children:["Notifications are disabled."," ",e("a",{href:"#",onClick:S=>{S.preventDefault(),t.value="settings"},children:"Enable them in the Settings tab"})]}),K?e("div",{class:"channel-grid",children:[1,2,3].map(S=>e("div",{class:"channel-card",children:e("div",{class:"stat-skeleton"})},S))}):e("div",{class:"channel-grid",children:n.value?.channels.map(S=>e("div",{class:"channel-card",children:e("div",{class:"channel-card-header",children:[e("span",{class:"channel-card-name",children:S.name}),e("div",{class:"channel-card-actions",children:[e(B,{variant:S.enabled?"success":"neutral",children:S.enabled?"Connected":"Not Configured"}),S.enabled&&e(R,{variant:"secondary",size:"sm",onClick:()=>M(S.name),loading:i.value===S.name,children:"Test"})]})]})},S.name))}),e("div",{style:{marginTop:"var(--space-4)",marginBottom:"var(--space-6)"},children:[e(R,{onClick:N,loading:l.value,disabled:!y,children:"Test All Channels"}),s.value&&e("div",{class:"test-results",children:s.value.map(S=>e("div",{class:"test-result-item",children:[e("span",{class:S.success?"test-result-success":"test-result-failure",children:S.success?"✓":"✗"}),e("span",{style:{textTransform:"capitalize"},children:S.channel}),!S.success&&S.error&&e("span",{class:"test-result-failure",children:[" - ",S.error]})]},S.channel))})]}),e("h2",{children:"Delivery Log"}),e(Bt,{fields:Qi,values:v.value,onChange:P,syncUrl:!1}),e(Ze,{columns:U,data:r.value?.logs??[],loading:c.value,emptyMessage:"No notification logs",onRowClick:D}),o.value&&e("div",{class:"log-message-detail",children:[e("div",{class:"log-message-detail-header",children:[e("strong",{children:o.value.eventType})," via ",e("span",{style:{textTransform:"capitalize"},children:o.value.channel}),e(R,{variant:"ghost",size:"sm",onClick:()=>{o.value=null},children:"Close"})]}),e("div",{class:"log-message-detail-body",children:o.value.message?e("pre",{style:{whiteSpace:"pre-wrap",margin:0,fontSize:"var(--font-size-sm)"},children:o.value.message}):e("span",{class:"text-muted",children:"(No message recorded)"})})]}),e("div",{class:"pagination",children:[e("span",{class:"pagination-info",children:["Page ",h.value," of ",b,r.value?` (${r.value.total} total)`:""]}),e("div",{class:"pagination-buttons",children:[e(R,{variant:"secondary",size:"sm",onClick:I,disabled:h.value<=1,children:"Previous"}),e(R,{variant:"secondary",size:"sm",onClick:_,disabled:h.value>=b,children:"Next"})]})]}),e("div",{class:"config-guidance",children:e("p",{children:"Configure notification channels in the Settings tab above. Changes are applied immediately via hot-reload."})})]})]})}const Xn=[{key:"killswitch",label:"Kill Switch"},{key:"autostop",label:"AutoStop Rules"},{key:"jwt",label:"Invalidate Sessions"}];function ns(){const t=d(null),n=d(!0),a=d(!1),l=async()=>{try{const u=await z(L.ADMIN_KILL_SWITCH);t.value=u}catch(u){const m=u instanceof w?u:new w(0,"UNKNOWN","Unknown error");E("error",$(m.code))}finally{n.value=!1}};F(()=>{l()},[]);const i=async()=>{a.value=!0;try{await se(L.ADMIN_KILL_SWITCH),E("success","Kill switch activated - all operations suspended"),await l()}catch(u){const m=u instanceof w?u:new w(0,"UNKNOWN","Unknown error");E("error",$(m.code))}finally{a.value=!1}},s=async()=>{a.value=!0;try{await se(L.ADMIN_KILL_SWITCH_ESCALATE),E("success","Kill switch escalated to LOCKED"),await l()}catch(u){const m=u instanceof w?u:new w(0,"UNKNOWN","Unknown error");E("error",$(m.code))}finally{a.value=!1}},r=async()=>{a.value=!0;try{await se(L.ADMIN_RECOVER),E("success","Kill switch recovered - operations resumed"),await l()}catch(u){const m=u instanceof w?u:new w(0,"UNKNOWN","Unknown error");E("error",$(m.code))}finally{a.value=!1}},c=t.value,h=c?.state==="ACTIVE",o=c?.state==="SUSPENDED",v=c?.state==="LOCKED";return e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Kill Switch"}),e("p",{class:"settings-description",children:"Emergency stop - suspends all wallet operations immediately. 3-state: ACTIVE (normal) → SUSPENDED (paused) → LOCKED (permanent)."})]}),e("div",{class:"settings-category-body",children:n.value?e("span",{children:"Loading..."}):c?e(Y,{children:[e("div",{class:"ks-state-card",style:{marginBottom:"var(--space-4)"},children:[e(B,{variant:h?"success":v?"danger":"warning",children:c.state}),!h&&c.activatedAt&&e("span",{class:"ks-state-info",children:["Since ",ve(c.activatedAt),c.activatedBy?` by ${c.activatedBy}`:""]})]}),e("div",{style:{display:"flex",gap:"var(--space-2)",flexWrap:"wrap"},children:[h&&e(R,{variant:"danger",onClick:i,loading:a.value,children:"Activate Kill Switch"}),o&&e(Y,{children:[e(R,{variant:"primary",onClick:r,loading:a.value,children:"Recover"}),e(R,{variant:"danger",onClick:s,loading:a.value,children:"Escalate to LOCKED"})]}),v&&e(R,{variant:"primary",onClick:r,loading:a.value,children:"Recover from LOCKED (5s wait)"})]}),o&&e("div",{class:"settings-info-box",style:{marginTop:"var(--space-3)"},children:"All wallet operations are suspended. Sessions revoked, transactions cancelled. You can Recover to resume operations, or Escalate to LOCKED for permanent lockdown."}),v&&e("div",{class:"settings-info-box",style:{marginTop:"var(--space-3)",borderColor:"var(--color-danger)"},children:"System is permanently locked. Recovery requires dual-auth (Owner signature + Master password) and has a mandatory 5-second wait period."})]}):null})]})}function as(){const t=d({}),n=d({}),a=d(!1),l=d(!0),i=async()=>{try{const o=await z(L.ADMIN_SETTINGS);t.value=o}catch(o){const v=o instanceof w?o:new w(0,"UNKNOWN","Unknown error");E("error",$(v.code))}finally{l.value=!1}};F(()=>{i()},[]);const s=(o,v)=>{const u=String(v);n.value={...n.value,[o]:u}},r=async()=>{a.value=!0;try{const o=Object.entries(n.value).filter(([u])=>u.startsWith("autostop.")).map(([u,m])=>({key:u,value:m})),v=await he(L.ADMIN_SETTINGS,{settings:o});t.value=v.settings,n.value={},E("success","AutoStop settings saved and applied")}catch(o){const v=o instanceof w?o:new w(0,"UNKNOWN","Unknown error");E("error",$(v.code))}finally{a.value=!1}},c=()=>{n.value={}};F(()=>(Ne({id:"security-autostop",isDirty:()=>Object.keys(n.value).filter(o=>o.startsWith("autostop.")).length>0,save:r,discard:c}),()=>ke("security-autostop")),[]);const h=Object.keys(n.value).filter(o=>o.startsWith("autostop.")).length;return l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(Y,{children:[h>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[h," unsaved change",h>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(R,{variant:"ghost",size:"sm",onClick:c,children:"Discard"}),e(R,{variant:"primary",size:"sm",onClick:r,loading:a.value,children:"Save"})]})]}),e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"AutoStop Rules"}),e("p",{class:"settings-description",children:"Automatic protection rules that suspend wallets or trigger Kill Switch on anomalies. Changes apply immediately without daemon restart."})]}),e("div",{class:"settings-category-body",children:[e("div",{class:"settings-field-full",style:{marginBottom:"var(--space-4)"},children:e(A,{label:V("enabled"),name:"autostop.enabled",type:"checkbox",value:xe(t.value,n.value,"autostop","enabled"),onChange:o=>s("autostop.enabled",o),description:"Enable or disable AutoStop protection rules"})}),e(We,{legend:"Activity Detection",description:"Detects failures and unusual transaction patterns",children:e("div",{class:"settings-fields-grid",children:[e(A,{label:V("consecutive_failures_threshold"),name:"autostop.consecutive_failures_threshold",type:"number",value:Number(J(t.value,n.value,"autostop","consecutive_failures_threshold"))||0,onChange:o=>s("autostop.consecutive_failures_threshold",o),min:1,max:100,description:"Suspend wallet after this many consecutive failed transactions"}),e(A,{label:V("unusual_activity_threshold"),name:"autostop.unusual_activity_threshold",type:"number",value:Number(J(t.value,n.value,"autostop","unusual_activity_threshold"))||0,onChange:o=>s("autostop.unusual_activity_threshold",o),min:5,max:1e3,description:"Max transactions within window before triggering unusual activity alert"}),e(A,{label:V("unusual_activity_window_sec"),name:"autostop.unusual_activity_window_sec",type:"number",value:Number(J(t.value,n.value,"autostop","unusual_activity_window_sec"))||0,onChange:o=>s("autostop.unusual_activity_window_sec",o),min:60,max:86400,description:"Time window for unusual activity detection"})]})}),e(We,{legend:"Idle Detection",description:"Monitors inactivity and revokes idle sessions",children:e("div",{class:"settings-fields-grid",children:[e(A,{label:V("idle_timeout_sec"),name:"autostop.idle_timeout_sec",type:"number",value:Number(J(t.value,n.value,"autostop","idle_timeout_sec"))||0,onChange:o=>s("autostop.idle_timeout_sec",o),min:60,max:604800,description:"Revoke sessions with no activity for this duration"}),e(A,{label:V("idle_check_interval_sec"),name:"autostop.idle_check_interval_sec",type:"number",value:Number(J(t.value,n.value,"autostop","idle_check_interval_sec"))||0,onChange:o=>s("autostop.idle_check_interval_sec",o),min:10,max:3600,description:"How often to check for idle sessions"})]})}),e("div",{class:"settings-info-box",children:[e("strong",{children:"Consecutive Failures:"})," Suspends wallet after N consecutive failed transactions.",e("br",{}),e("strong",{children:"Unusual Activity:"})," Suspends wallet if transaction count exceeds threshold within the time window.",e("br",{}),e("strong",{children:"Idle Timeout:"})," Revokes sessions with no activity for the configured duration."]})]})]})]})}function ls(){const t=d(!1),n=d(!1),a=async()=>{n.value=!0;try{await se(L.ADMIN_ROTATE_SECRET),t.value=!1,E("success","All session tokens invalidated. Old tokens remain valid for 5 minutes.")}catch(l){const i=l instanceof w?l:new w(0,"UNKNOWN","Unknown error");E("error",$(i.code))}finally{n.value=!1}};return e(Y,{children:[e("div",{class:"settings-section",children:[e("div",{class:"settings-section-header",children:[e("h3",{children:"Invalidate All Session Tokens"}),e("p",{class:"settings-description",children:"Revoke all active session tokens by rotating the signing key. Existing tokens remain valid for 5 minutes, then all wallets must create new sessions."})]}),e("div",{class:"settings-section-body",children:e(R,{variant:"secondary",onClick:()=>{t.value=!0},children:"Invalidate All Tokens"})})]}),e(be,{open:t.value,title:"Invalidate All Session Tokens",onCancel:()=>{t.value=!1},onConfirm:a,confirmText:"Invalidate",confirmVariant:"primary",loading:n.value,children:e("p",{children:"This will rotate the signing key and invalidate all active session tokens after 5 minutes. Every wallet will need to create a new session to continue API access. Use this when a token may have been compromised."})})]})}function is(){const t=d("killswitch");F(()=>{const a=le.value;a&&a.tab&&(t.value=a.tab,setTimeout(()=>{_e.value=a.fieldName},100),le.value=null)},[le.value]);const n=Xn.find(a=>a.key===t.value)?.label??"";return e("div",{class:"page",children:[e(Qe,{pageName:"Security",tabName:n,onPageClick:()=>{t.value="killswitch"}}),e(He,{tabs:Xn,activeTab:t.value,onTabChange:a=>{t.value=a}}),t.value==="killswitch"&&e(ns,{}),t.value==="autostop"&&e(as,{}),t.value==="jwt"&&e(ls,{})]})}const Et=[{code:"USD",name:"US Dollar",symbol:"$"},{code:"KRW",name:"Korean Won",symbol:"₩"},{code:"JPY",name:"Japanese Yen",symbol:"¥"},{code:"EUR",name:"Euro",symbol:"€"},{code:"GBP",name:"British Pound",symbol:"£"},{code:"CNY",name:"Chinese Yuan",symbol:"¥"},{code:"CAD",name:"Canadian Dollar",symbol:"CA$"},{code:"AUD",name:"Australian Dollar",symbol:"A$"},{code:"CHF",name:"Swiss Franc",symbol:"CHF"},{code:"SGD",name:"Singapore Dollar",symbol:"S$"},{code:"HKD",name:"Hong Kong Dollar",symbol:"HK$"},{code:"INR",name:"Indian Rupee",symbol:"₹"},{code:"TWD",name:"Taiwan Dollar",symbol:"NT$"},{code:"THB",name:"Thai Baht",symbol:"฿"},{code:"MYR",name:"Malaysian Ringgit",symbol:"RM"},{code:"IDR",name:"Indonesian Rupiah",symbol:"Rp"},{code:"PHP",name:"Philippine Peso",symbol:"₱"},{code:"VND",name:"Vietnamese Dong",symbol:"₫"},{code:"BRL",name:"Brazilian Real",symbol:"R$"},{code:"MXN",name:"Mexican Peso",symbol:"MX$"},{code:"CLP",name:"Chilean Peso",symbol:"CL$"},{code:"TRY",name:"Turkish Lira",symbol:"₺"},{code:"PLN",name:"Polish Zloty",symbol:"zł"},{code:"CZK",name:"Czech Koruna",symbol:"Kč"},{code:"HUF",name:"Hungarian Forint",symbol:"Ft"},{code:"SEK",name:"Swedish Krona",symbol:"kr"},{code:"NOK",name:"Norwegian Krone",symbol:"kr"},{code:"DKK",name:"Danish Krone",symbol:"kr"},{code:"NZD",name:"New Zealand Dollar",symbol:"NZ$"},{code:"ZAR",name:"South African Rand",symbol:"R"},{code:"ILS",name:"Israeli Shekel",symbol:"₪"},{code:"SAR",name:"Saudi Riyal",symbol:"SR"},{code:"AED",name:"UAE Dirham",symbol:"AED"},{code:"KWD",name:"Kuwaiti Dinar",symbol:"KD"},{code:"BHD",name:"Bahraini Dinar",symbol:"BD"},{code:"NGN",name:"Nigerian Naira",symbol:"₦"},{code:"RUB",name:"Russian Ruble",symbol:"₽"},{code:"UAH",name:"Ukrainian Hryvnia",symbol:"₴"},{code:"PKR",name:"Pakistani Rupee",symbol:"Rs"},{code:"BDT",name:"Bangladeshi Taka",symbol:"৳"},{code:"LKR",name:"Sri Lankan Rupee",symbol:"Rs"},{code:"MMK",name:"Myanmar Kyat",symbol:"K"},{code:"GEL",name:"Georgian Lari",symbol:"₾"}];function ss({value:t,onChange:n,name:a}){const l=d(""),i=d(!1),s=d(null),r=d(!1),c=gt(null),h=Ft(()=>{const v=l.value.toLowerCase();return v?Et.filter(u=>u.code.toLowerCase().includes(v)||u.name.toLowerCase().includes(v)||u.symbol.includes(v)):Et});F(()=>{if(t==="USD"){s.value="1 USD = $1.00";return}r.value=!0,z(`${L.ADMIN_FOREX_RATES}?currencies=${t}`).then(v=>{const u=v.rates[t];s.value=u?.preview??null}).catch(()=>{s.value=null}).finally(()=>{r.value=!1})},[t]),F(()=>{const v=u=>{c.current&&!c.current.contains(u.target)&&(i.value=!1,l.value="")};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[]);const o=Et.find(v=>v.code===t)??Et[0];return e("div",{class:"currency-select",ref:c,children:[a&&e("input",{type:"hidden",name:a,value:t}),e("button",{type:"button",class:"currency-select-trigger",onClick:()=>{i.value=!i.value},children:[e("span",{class:"currency-select-value",children:[o.code," - ",o.name," (",o.symbol,")"]}),e("span",{class:"currency-select-chevron",children:i.value?"▲":"▼"})]}),s.value&&e("div",{class:"currency-rate-preview",children:r.value?"...":s.value}),i.value&&e("div",{class:"currency-select-dropdown",children:[e("input",{type:"text",class:"currency-select-search",placeholder:"Search currency...",value:l.value,onInput:v=>{l.value=v.target.value},autoFocus:!0}),e("div",{class:"currency-select-list",children:[h.value.map(v=>e("button",{type:"button",class:`currency-select-option ${v.code===t?"currency-select-option--active":""}`,onClick:()=>{n(v.code),i.value=!1,l.value=""},children:[e("span",{class:"currency-option-code",children:v.code}),e("span",{class:"currency-option-name",children:v.name}),e("span",{class:"currency-option-symbol",children:v.symbol})]},v.code)),h.value.length===0&&e("div",{class:"currency-select-empty",children:"No currencies found"})]})]})]})}const rs=["display.","daemon.","oracle.","signing_sdk.","gas_condition."],os=new Set(["security.rate_limit_global_ip_rpm"]);function tn(t){return rs.some(n=>t.startsWith(n))||os.has(t)}function cs(){const t=d({}),n=d({}),a=d(!1),l=d(!0),i=d([]),s=d(!0);d(null),d(""),d(!1);const r=d(!1),c=d(!1),h=d(""),o=d(!1),v=async()=>{try{const f=await z(L.ADMIN_SETTINGS);t.value=f}catch(f){const O=f instanceof w?f:new w(0,"UNKNOWN","Unknown error");E("error",$(O.code))}finally{l.value=!1}},u=async()=>{try{const f=await z(L.ADMIN_API_KEYS);i.value=f.keys}catch{}finally{s.value=!1}};F(()=>{v(),u()},[]),F(()=>{const f=le.value;f&&(setTimeout(()=>{_e.value=f.fieldName},100),le.value=null)},[le.value]);const m=(f,O)=>J(t.value,n.value,f,O),N=(f,O)=>xe(t.value,n.value,f,O),M=(f,O)=>rt(t.value,n.value,f,O),I=(f,O)=>{const W=String(O);n.value={...n.value,[f]:W}},_=async()=>{a.value=!0;try{const f=Object.entries(n.value).filter(([W])=>tn(W)).map(([W,q])=>({key:W,value:q})),O=await he(L.ADMIN_SETTINGS,{settings:f});t.value=O.settings,n.value={},E("success","Settings saved and applied")}catch(f){const O=f instanceof w?f:new w(0,"UNKNOWN","Unknown error");E("error",$(O.code))}finally{a.value=!1}},D=()=>{n.value={}};F(()=>(Ne({id:"system-settings",isDirty:()=>Object.keys(n.value).filter(f=>tn(f)).length>0,save:_,discard:D}),()=>ke("system-settings")),[]);const P=async()=>{c.value=!0;try{await se(L.ADMIN_SHUTDOWN),r.value=!1,h.value="",E("info","Shutdown initiated"),o.value=!0}catch(f){const O=f instanceof w?f:new w(0,"UNKNOWN","Unknown error");E("error",$(O.code))}finally{c.value=!1}},K=Object.keys(n.value).filter(f=>tn(f)).length;function y(){return e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Oracle"}),e("p",{class:"settings-description",children:"Price oracle configuration for cross-validation"})]}),e("div",{class:"settings-category-body",children:[e("div",{class:"settings-fields-grid",children:e(A,{label:"Cross Validation Threshold (%)",name:"oracle.cross_validation_threshold",type:"number",value:Number(m("oracle","cross_validation_threshold"))||5,onChange:f=>I("oracle.cross_validation_threshold",f),min:0,max:100,description:"Maximum allowed deviation between price oracle sources"})}),e("div",{style:{borderTop:"1px solid var(--border)",paddingTop:"var(--space-3)",marginTop:"var(--space-3)"},children:e(A,{label:"CoinGecko API Key",name:"oracle.coingecko_api_key",type:"password",value:M("oracle","coingecko_api_key")?"••••••••":"",onChange:f=>I("oracle.coingecko_api_key",f),placeholder:"Enter CoinGecko Pro API key (optional)",description:"Pro API key for higher rate limits. Free tier: ~30 req/min."})}),e("div",{class:"settings-info-box",children:["Maximum allowed deviation between price sources before flagging a discrepancy. Default is 5%. CoinGecko Pro API key increases rate limits for reliable price data. Get your API key from"," ",e("a",{href:"https://www.coingecko.com/en/api",target:"_blank",rel:"noopener noreferrer",children:"CoinGecko API Dashboard"}),"."]})]})]})}function b(){const f=_e.value==="display.currency";return F(()=>{if(f){const O=document.querySelector('[name="display.currency"]');O&&O.closest(".form-field")?.scrollIntoView({behavior:"smooth",block:"center"});const W=setTimeout(()=>{_e.value=""},2500);return()=>clearTimeout(W)}},[f]),e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Display Currency"}),e("p",{class:"settings-description",children:"Configure display currency for USD amount conversion"})]}),e("div",{class:"settings-category-body",children:[e("div",{class:"settings-fields-grid",children:e("div",{class:`form-field${f?" form-field--highlight":""}`,children:[e("label",{children:V("currency")}),e(ss,{name:"display.currency",value:m("display","currency")||"USD",onChange:O=>I("display.currency",O)})]})}),e("div",{class:"settings-info-box",children:"All USD amounts in the dashboard, notifications, and API responses will be converted to the selected currency. Policy evaluation always uses USD. The “≈” prefix indicates an approximate conversion."})]})]})}function U(){return e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Global IP Rate Limit"}),e("p",{class:"settings-description",children:"Maximum API requests per minute from a single IP address"})]}),e("div",{class:"settings-category-body",children:e("div",{class:"settings-fields-grid",children:e(A,{label:V("rate_limit_global_ip_rpm"),name:"security.rate_limit_global_ip_rpm",type:"number",value:Number(m("security","rate_limit_global_ip_rpm"))||0,onChange:f=>I("security.rate_limit_global_ip_rpm",f),min:10,description:"Maximum API requests per minute from a single IP address"})})})]})}function S(){return e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Log Level"}),e("p",{class:"settings-description",children:"General daemon configuration"})]}),e("div",{class:"settings-category-body",children:e("div",{class:"settings-fields-grid",children:e(A,{label:V("log_level"),name:"daemon.log_level",type:"select",value:m("daemon","log_level")||"info",onChange:f=>I("daemon.log_level",f),options:[{label:"debug",value:"debug"},{label:"info",value:"info"},{label:"warn",value:"warn"},{label:"error",value:"error"}],description:"Daemon logging verbosity level"})})})]})}function p(){return e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Signing SDK"}),e("p",{class:"settings-description",children:"Configure the Wallet Signing SDK for owner approval via mobile wallet app"})]}),e("div",{class:"settings-category-body",children:[e("div",{class:"settings-fields-grid",children:[e(A,{label:"SDK Enabled",name:"signing_sdk.enabled",type:"select",value:m("signing_sdk","enabled")||"false",onChange:f=>I("signing_sdk.enabled",f),options:[{label:"Yes",value:"true"},{label:"No",value:"false"}],description:"Enable Signing SDK for wallet app approval"}),e(A,{label:V("request_expiry_min"),name:"signing_sdk.request_expiry_min",type:"number",value:Number(m("signing_sdk","request_expiry_min"))||30,onChange:f=>I("signing_sdk.request_expiry_min",f),min:1,max:1440,description:"Minutes before a sign request expires"}),e(A,{label:V("preferred_channel"),name:"signing_sdk.preferred_channel",type:"select",value:m("signing_sdk","preferred_channel")||"ntfy",onChange:f=>I("signing_sdk.preferred_channel",f),options:[{label:"ntfy",value:"ntfy"},{label:"Telegram",value:"telegram"}],description:"Preferred signing channel for SDK requests"}),e(A,{label:V("preferred_wallet"),name:"signing_sdk.preferred_wallet",type:"text",value:m("signing_sdk","preferred_wallet"),onChange:f=>I("signing_sdk.preferred_wallet",f),placeholder:"Optional wallet app name",description:"Preferred wallet app for deep linking"}),e(A,{label:V("ntfy_request_topic_prefix"),name:"signing_sdk.ntfy_request_topic_prefix",type:"text",value:m("signing_sdk","ntfy_request_topic_prefix"),onChange:f=>I("signing_sdk.ntfy_request_topic_prefix",f),description:"ntfy topic prefix for sign requests"}),e(A,{label:V("ntfy_response_topic_prefix"),name:"signing_sdk.ntfy_response_topic_prefix",type:"text",value:m("signing_sdk","ntfy_response_topic_prefix"),onChange:f=>I("signing_sdk.ntfy_response_topic_prefix",f),description:"ntfy topic prefix for sign responses"})]}),e("div",{class:"settings-info-box",children:"Enable the Signing SDK to allow wallet owners to approve/reject transactions from their mobile wallet app. Requires a signing channel (ntfy or Telegram) to deliver sign requests."}),e("div",{class:"settings-subgroup",style:{marginTop:"1rem",borderTop:"1px solid var(--border)",paddingTop:"1rem"},children:[e("div",{class:"settings-subgroup-title",children:"Wallet App Notifications"}),e("p",{class:"settings-description",style:{marginBottom:"0.75rem"},children:"Push notifications to wallet apps via ntfy side channel."}),e("div",{class:"settings-fields-grid",children:e("div",{class:"settings-field-full",children:e(A,{label:"Notifications Enabled",name:"signing_sdk.notifications_enabled",type:"checkbox",value:N("signing_sdk","notifications_enabled"),onChange:f=>I("signing_sdk.notifications_enabled",f),description:"Push event notifications to wallet apps"})})}),e("div",{class:"settings-info-box",style:{marginTop:"0.5rem"},children:"Category filtering is configured in Notifications > Settings."})]})]})]})}function g(){return e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Gas Condition"}),e("p",{class:"settings-description",children:"Configure gas conditional execution for deferred transactions"})]}),e("div",{class:"settings-category-body",children:[e("div",{class:"settings-fields-grid",children:[e(A,{label:"Gas Condition Enabled",name:"gas_condition.enabled",type:"select",value:m("gas_condition","enabled")||"true",onChange:f=>I("gas_condition.enabled",f),options:[{label:"Yes",value:"true"},{label:"No",value:"false"}],description:"Enable gas conditional execution for agents"}),e(A,{label:V("poll_interval_sec"),name:"gas_condition.poll_interval_sec",type:"number",value:Number(m("gas_condition","poll_interval_sec"))||30,onChange:f=>I("gas_condition.poll_interval_sec",f),min:10,max:300,description:"How often to check gas prices (seconds)"}),e(A,{label:V("default_timeout_sec"),name:"gas_condition.default_timeout_sec",type:"number",value:Number(m("gas_condition","default_timeout_sec"))||3600,onChange:f=>I("gas_condition.default_timeout_sec",f),min:60,max:86400,description:"Default wait timeout when not specified in request (seconds)"}),e(A,{label:V("max_timeout_sec"),name:"gas_condition.max_timeout_sec",type:"number",value:Number(m("gas_condition","max_timeout_sec"))||86400,onChange:f=>I("gas_condition.max_timeout_sec",f),min:60,max:86400,description:"Maximum allowed timeout for gas conditions (seconds)"}),e(A,{label:V("max_pending_count"),name:"gas_condition.max_pending_count",type:"number",value:Number(m("gas_condition","max_pending_count"))||100,onChange:f=>I("gas_condition.max_pending_count",f),min:1,max:1e4,description:"Maximum number of concurrent GAS_WAITING transactions"})]}),e("div",{class:"settings-info-box",children:"Gas conditional execution allows agents to specify gas price conditions. Transactions wait until gas prices fall below the specified threshold before executing."})]})]})}return e("div",{class:"page",children:[o.value&&e("div",{class:"shutdown-overlay",children:[e("h2",{children:"Daemon is shutting down..."}),e("p",{children:"You can close this tab."})]}),K>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[K," unsaved change",K>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(R,{variant:"ghost",size:"sm",onClick:D,children:"Discard"}),e(R,{variant:"primary",size:"sm",onClick:_,loading:a.value,children:"Save"})]})]}),l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(Y,{children:[e(y,{}),e(b,{}),e(U,{}),e(S,{}),e(p,{}),e(g,{})]}),e("div",{class:"settings-section settings-section--danger",children:[e("div",{class:"settings-section-header",children:[e("h3",{children:"Danger Zone"}),e("p",{class:"settings-description",children:"Irreversible actions. Proceed with caution."})]}),e("div",{class:"settings-section-body",children:e(R,{variant:"danger",onClick:()=>{r.value=!0},children:"Shutdown Daemon"})})]}),e(be,{open:r.value,title:"Shutdown Daemon",onCancel:()=>{r.value=!1,h.value=""},onConfirm:P,confirmText:"Shutdown",confirmVariant:"danger",confirmDisabled:h.value!=="SHUTDOWN",loading:c.value,children:[e("p",{children:"This will gracefully stop the daemon process. All active connections will be terminated."}),e("div",{class:"shutdown-confirm-input",children:[e("label",{children:["Type ",e("strong",{children:"SHUTDOWN"})," to confirm"]}),e("input",{type:"text",value:h.value,onInput:f=>{h.value=f.target.value},placeholder:"SHUTDOWN"})]})]})]})}const Jn=[{key:"jupiter_swap",name:"Jupiter Swap",description:"Solana DEX aggregator",chain:"solana",requiresApiKey:!1,docsUrl:"https://station.jup.ag/docs"},{key:"zerox_swap",name:"0x Swap",description:"EVM DEX aggregator (AllowanceHolder)",chain:"evm",requiresApiKey:!0,docsUrl:"https://dashboard.0x.org"},{key:"lifi",name:"LI.FI",description:"Multi-chain DEX/bridge aggregator",chain:"multi",requiresApiKey:!1,docsUrl:"https://docs.li.fi"},{key:"lido_staking",name:"Lido Staking",description:"ETH liquid staking (stETH/wstETH)",chain:"evm",requiresApiKey:!1,docsUrl:"https://docs.lido.fi"},{key:"jito_staking",name:"Jito Staking",description:"SOL liquid staking (JitoSOL)",chain:"solana",requiresApiKey:!1,docsUrl:"https://www.jito.network/docs"}];function ds(){const t=d([]),n=d({}),a=d([]),l=d(!0),i=d(null),s=d(""),r=d(!1),c=d(null),h=async()=>{try{const y=await z(L.ADMIN_SETTINGS);n.value=y}catch(y){const b=y instanceof w?y:new w(0,"UNKNOWN","Unknown error");E("error",$(b.code))}},o=async()=>{try{const y=await z(L.ADMIN_API_KEYS);a.value=y.keys}catch{}},v=async()=>{try{const y=await z(L.ACTIONS_PROVIDERS);t.value=y.providers??[]}catch{}},u=async()=>{l.value=!0,await Promise.all([h(),o(),v()]),l.value=!1};F(()=>{u()},[]);const m=async(y,b)=>{const U=`actions.${y}_enabled`;c.value=y;try{const S=await he(L.ADMIN_SETTINGS,{settings:[{key:U,value:String(b)}]});n.value=S.settings,E("success",`${b?"Enabled":"Disabled"} ${y.replace(/_/g," ")}`)}catch(S){const p=S instanceof w?S:new w(0,"UNKNOWN","Unknown error");E("error",$(p.code))}finally{c.value=null}},N=async y=>{r.value=!0;try{await he(L.ADMIN_API_KEY(y),{apiKey:s.value}),E("success",`API key saved for ${y}`),i.value=null,s.value="",await o()}catch(b){const U=b instanceof w?b:new w(0,"UNKNOWN","Unknown error");E("error",$(U.code))}finally{r.value=!1}},M=async y=>{try{await Ke(L.ADMIN_API_KEY(y)),E("success",`API key deleted for ${y}`),await o()}catch(b){const U=b instanceof w?b:new w(0,"UNKNOWN","Unknown error");E("error",$(U.code))}};function I(y){const b=n.value.actions;return b?b[`${y}_enabled`]==="true":!1}function _(y){return t.value.some(b=>b.name.toLowerCase().replace(/[\s-]/g,"_")===y||b.name.toLowerCase().includes(y.replace(/_/g," ")))}function D(y){return a.value.find(b=>b.providerName===y||b.providerName.toLowerCase().replace(/[\s-]/g,"_")===y)}function P(y){return t.value.find(b=>b.name.toLowerCase().replace(/[\s-]/g,"_")===y||b.name.toLowerCase().includes(y.replace(/_/g," ")))}function K(y){const b=I(y.key),U=_(y.key);return b&&y.requiresApiKey&&!D(y.key)?.hasKey?{label:"Requires API Key",variant:"warning"}:b&&U?{label:"Active",variant:"success"}:{label:"Inactive",variant:"neutral"}}return l.value?e("div",{class:"page",children:e("div",{class:"empty-state",children:e("p",{children:"Loading action providers..."})})}):e("div",{class:"page",children:[Jn.map(y=>{const b=K(y),U=I(y.key),S=P(y.key),p=D(y.key),g=c.value===y.key;return e("div",{class:"settings-category",style:{marginBottom:"var(--space-4)"},children:[e("div",{class:"settings-category-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e("div",{children:[e("h3",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)",margin:0},children:[y.name,S&&e(B,{variant:"info",children:S.version}),e(B,{variant:(y.chain==="solana","info"),children:y.chain})]}),e("p",{class:"settings-description",style:{marginTop:"var(--space-1)"},children:[y.description,y.docsUrl&&e(Y,{children:[" ","—"," ",e("a",{href:y.docsUrl,target:"_blank",rel:"noopener noreferrer",children:"Docs"})]})]})]}),e(B,{variant:b.variant,children:b.label})]}),e("div",{class:"settings-category-body",children:[e("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-3)",marginBottom:"var(--space-3)"},children:[e(A,{label:"Enabled",name:`actions.${y.key}_enabled`,type:"checkbox",value:U,onChange:f=>m(y.key,!!f),disabled:g}),g&&e("span",{style:{fontSize:"var(--font-size-sm)",color:"var(--text-secondary)"},children:"Saving..."})]}),y.requiresApiKey&&e("div",{style:{borderTop:"1px solid var(--border)",paddingTop:"var(--space-3)",marginBottom:"var(--space-3)"},children:[e("div",{style:{fontWeight:600,fontSize:"var(--font-size-sm)",marginBottom:"var(--space-2)",color:"var(--text-secondary)"},children:"API Key"}),i.value===y.key?e("div",{style:{display:"flex",alignItems:"flex-end",gap:"var(--space-2)"},children:[e(A,{label:"API Key",type:"password",name:`apikey-${y.key}`,value:s.value,onChange:f=>{s.value=String(f)},placeholder:"Enter API key"}),e(R,{onClick:()=>N(y.key),loading:r.value,size:"sm",children:"Save"}),e(R,{variant:"ghost",onClick:()=>{i.value=null,s.value=""},size:"sm",children:"Cancel"})]}):e("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)"},children:[e("span",{style:{fontFamily:"monospace",fontSize:"var(--font-size-sm)",color:"var(--text-secondary)"},children:p?.hasKey?p.maskedKey:"Not set"}),e(R,{variant:"ghost",onClick:()=>{i.value=y.key,s.value=""},size:"sm",children:p?.hasKey?"Update":"Set"}),p?.hasKey&&e(R,{variant:"danger",onClick:()=>M(y.key),size:"sm",children:"Delete"})]})]}),U&&S&&S.actions.length>0&&e("div",{style:{borderTop:"1px solid var(--border)",paddingTop:"var(--space-3)"},children:[e("div",{style:{fontWeight:600,fontSize:"var(--font-size-sm)",marginBottom:"var(--space-2)",color:"var(--text-secondary)"},children:"Registered Actions"}),e("table",{class:"table",children:[e("thead",{children:e("tr",{children:[e("th",{children:"Name"}),e("th",{children:"Chain"}),e("th",{children:"Risk Level"}),e("th",{children:"Default Tier"})]})}),e("tbody",{children:S.actions.map(f=>e("tr",{children:[e("td",{children:f.name}),e("td",{children:e(B,{variant:"info",children:f.chain})}),e("td",{children:f.riskLevel}),e("td",{children:f.defaultTier})]},f.name))})]})]})]})]},y.key)}),Jn.length===0&&e("div",{class:"empty-state",children:e("p",{children:"No action providers available."})})]})}const De=fe(window.location.hash.slice(1)||"/dashboard"),At=fe(!1);window.addEventListener("hashchange",()=>{De.value=window.location.hash.slice(1)||"/dashboard"});const us={"/dashboard":"Dashboard","/wallets":"Wallets","/transactions":"Transactions","/sessions":"Sessions","/tokens":"Token Registry","/actions":"Actions","/policies":"Policies","/notifications":"Notifications","/security":"Security","/system":"System"},vs={"/dashboard":"System overview and key metrics","/wallets":"Manage wallets, balances, and connections","/transactions":"View all transactions and configure incoming monitoring","/sessions":"View and manage active sessions","/tokens":"Manage EVM token registry per network","/actions":"Manage DeFi action providers and API keys","/policies":"Configure transaction policies and rules","/notifications":"Channel status, delivery logs, and settings","/security":"Emergency controls and automatic protection rules","/system":"API keys, display preferences, and daemon configuration"};function hs(t){return t.startsWith("/wallets/")?"Wallet Detail":us[t]??"Dashboard"}function Zn(t){return vs[t]}const ps=[{path:"/dashboard",label:"Dashboard"},{path:"/wallets",label:"Wallets"},{path:"/transactions",label:"Transactions"},{path:"/sessions",label:"Sessions"},{path:"/tokens",label:"Tokens"},{path:"/actions",label:"Actions"},{path:"/policies",label:"Policies"},{path:"/notifications",label:"Notifications"},{path:"/security",label:"Security"},{path:"/system",label:"System"}];function ms(){const t=De.value;return t==="/transactions"?e(Kn,{}):t==="/incoming"?(window.location.hash="#/transactions",e(Kn,{})):t==="/tokens"?e(gi,{}):t==="/actions"?e(ds,{}):t==="/sessions"?e(bi,{}):t==="/policies"?e(Xi,{}):t==="/notifications"?e(Yn,{}):t==="/telegram-users"?(window.location.hash="#/notifications",e(Yn,{})):t==="/settings"?(window.location.hash="#/dashboard",e(xn,{})):t==="/walletconnect"?(window.location.hash="#/wallets",e(Mn,{})):t==="/security"?e(is,{}):t==="/system"?e(cs,{}):t.startsWith("/wallets")?e(Mn,{}):e(xn,{})}function fs(){return F(()=>{const t=n=>{(n.metaKey||n.ctrlKey)&&n.key==="k"&&(n.preventDefault(),At.value=!At.value)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[]),e("div",{class:"layout",children:[e("aside",{class:"sidebar",children:[e("div",{class:"sidebar-brand",children:"WAIaaS"}),e("nav",{class:"sidebar-nav",children:ps.map(t=>{const n=t.path==="/wallets"?De.value.startsWith("/wallets"):De.value===t.path;return e("a",{href:`#${t.path}`,class:`sidebar-link ${n?"active":""}`,onClick:a=>{Na.value&&(a.preventDefault(),Ea({type:"nav",execute:()=>{window.location.hash=`#${t.path}`}}))},children:t.label})})})]}),e("main",{class:"main",children:[e("header",{class:"header",children:[e("div",{class:"header-left",children:[e("h1",{class:"header-title",children:hs(De.value)}),Zn(De.value)&&e("p",{class:"header-subtitle",children:Zn(De.value)})]}),e("div",{class:"header-actions",children:[e("button",{class:"btn-search",onClick:()=>{At.value=!0},title:"Search settings (Ctrl+K)",children:"🔍"}),e("button",{class:"btn-logout",onClick:()=>fn(),children:"Logout"})]})]}),e("div",{class:"content",children:e(ms,{})})]}),e(_l,{open:At}),e(Sl,{})]})}const Ct={overlay:{position:"fixed",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0, 0, 0, 0.7)",color:"white",zIndex:9999},content:{textAlign:"center"},title:{fontSize:"var(--font-size-2xl)",fontWeight:"var(--font-weight-bold)",marginBottom:"var(--space-2)"},message:{fontSize:"var(--font-size-base)",color:"var(--color-text-muted)"}};function gs(){return e("div",{style:Ct.overlay,children:e("div",{style:Ct.content,children:[e("h1",{style:Ct.title,children:"Daemon Shutting Down"}),e("p",{style:Ct.message,children:"The daemon is shutting down. Please wait or restart."})]})})}function ys(){return cl.value?e(gs,{}):ol.value?e(Y,{children:[e(fs,{}),e(Rl,{})]}):e(pl,{})}Ja(e(ys,{}),document.getElementById("app"));
|