@waiaas/daemon 2.12.0 → 2.13.0-rc

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.
@@ -0,0 +1,4 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/setup-wizard-CuTGFqla.js","assets/wizard-store-CZoifFis.js"])))=>i.map(i=>d[i]);
2
+ var Ct,ue,Ll,Pl,ua,$n,Ol,Ul,Wl,bn,dn,un,za={},Ml=[],Ji=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,It=Array.isArray;function Ve(t,a){for(var n in a)t[n]=a[n];return t}function wn(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function Qi(t,a,n){var l,i,r,s={};for(r in a)r=="key"?l=a[r]:r=="ref"?i=a[r]:s[r]=a[r];if(arguments.length>2&&(s.children=arguments.length>3?Ct.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(r in t.defaultProps)s[r]===void 0&&(s[r]=t.defaultProps[r]);return _t(t,s,l,i,null)}function _t(t,a,n,l,i){var r={type:t,props:a,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Ll,__i:-1,__u:0};return i==null&&ue.vnode!=null&&ue.vnode(r),r}function le(t){return t.children}function Wa(t,a){this.props=t,this.context=a}function ka(t,a){if(a==null)return t.__?ka(t.__,t.__i+1):null;for(var n;a<t.__k.length;a++)if((n=t.__k[a])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?ka(t):null}function $l(t){var a,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,a=0;a<t.__k.length;a++)if((n=t.__k[a])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return $l(t)}}function Fn(t){(!t.__d&&(t.__d=!0)&&ua.push(t)&&!wt.__r++||$n!=ue.debounceRendering)&&(($n=ue.debounceRendering)||Ol)(wt)}function wt(){for(var t,a,n,l,i,r,s,o=1;ua.length;)ua.length>o&&ua.sort(Ul),t=ua.shift(),o=ua.length,t.__d&&(n=void 0,l=void 0,i=(l=(a=t).__v).__e,r=[],s=[],a.__P&&((n=Ve({},l)).__v=l.__v+1,ue.vnode&&ue.vnode(n),Tn(a.__P,n,l,a.__n,a.__P.namespaceURI,32&l.__u?[i]:null,r,i??ka(l),!!(32&l.__u),s),n.__v=l.__v,n.__.__k[n.__i]=n,Kl(r,n,s),l.__e=l.__=null,n.__e!=i&&$l(n)));wt.__r=0}function Fl(t,a,n,l,i,r,s,o,u,d,v){var h,m,b,U,W,p,T,D=l&&l.__k||Ml,M=a.length;for(u=Zi(n,a,D,u,M),h=0;h<M;h++)(b=n.__k[h])!=null&&(m=b.__i==-1?za:D[b.__i]||za,b.__i=h,p=Tn(t,b,m,i,r,s,o,u,d,v),U=b.__e,b.ref&&m.ref!=b.ref&&(m.ref&&Sn(m.ref,null,b),v.push(b.ref,b.__c||U,b)),W==null&&U!=null&&(W=U),(T=!!(4&b.__u))||m.__k===b.__k?u=zl(b,u,t,T):typeof b.type=="function"&&p!==void 0?u=p:U&&(u=U.nextSibling),b.__u&=-7);return n.__e=W,u}function Zi(t,a,n,l,i){var r,s,o,u,d,v=n.length,h=v,m=0;for(t.__k=new Array(i),r=0;r<i;r++)(s=a[r])!=null&&typeof s!="boolean"&&typeof s!="function"?(typeof s=="string"||typeof s=="number"||typeof s=="bigint"||s.constructor==String?s=t.__k[r]=_t(null,s,null,null,null):It(s)?s=t.__k[r]=_t(le,{children:s},null,null,null):s.constructor===void 0&&s.__b>0?s=t.__k[r]=_t(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):t.__k[r]=s,u=r+m,s.__=t,s.__b=t.__b+1,o=null,(d=s.__i=er(s,n,u,h))!=-1&&(h--,(o=n[d])&&(o.__u|=2)),o==null||o.__v==null?(d==-1&&(i>v?m--:i<v&&m++),typeof s.type!="function"&&(s.__u|=4)):d!=u&&(d==u-1?m--:d==u+1?m++:(d>u?m--:m++,s.__u|=4))):t.__k[r]=null;if(h)for(r=0;r<v;r++)(o=n[r])!=null&&(2&o.__u)==0&&(o.__e==l&&(l=ka(o)),Hl(o,o));return l}function zl(t,a,n,l){var i,r;if(typeof t.type=="function"){for(i=t.__k,r=0;i&&r<i.length;r++)i[r]&&(i[r].__=t,a=zl(i[r],a,n,l));return a}t.__e!=a&&(l&&(a&&t.type&&!a.parentNode&&(a=ka(t)),n.insertBefore(t.__e,a||null)),a=t.__e);do a=a&&a.nextSibling;while(a!=null&&a.nodeType==8);return a}function er(t,a,n,l){var i,r,s,o=t.key,u=t.type,d=a[n],v=d!=null&&(2&d.__u)==0;if(d===null&&o==null||v&&o==d.key&&u==d.type)return n;if(l>(v?1:0)){for(i=n-1,r=n+1;i>=0||r<a.length;)if((d=a[s=i>=0?i--:r++])!=null&&(2&d.__u)==0&&o==d.key&&u==d.type)return s}return-1}function zn(t,a,n){a[0]=="-"?t.setProperty(a,n??""):t[a]=n==null?"":typeof n!="number"||Ji.test(a)?n:n+"px"}function ct(t,a,n,l,i){var r,s;e:if(a=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof l=="string"&&(t.style.cssText=l=""),l)for(a in l)n&&a in n||zn(t.style,a,"");if(n)for(a in n)l&&n[a]==l[a]||zn(t.style,a,n[a])}else if(a[0]=="o"&&a[1]=="n")r=a!=(a=a.replace(Wl,"$1")),s=a.toLowerCase(),a=s in t||a=="onFocusOut"||a=="onFocusIn"?s.slice(2):a.slice(2),t.l||(t.l={}),t.l[a+r]=n,n?l?n.u=l.u:(n.u=bn,t.addEventListener(a,r?un:dn,r)):t.removeEventListener(a,r?un:dn,r);else{if(i=="http://www.w3.org/2000/svg")a=a.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(a!="width"&&a!="height"&&a!="href"&&a!="list"&&a!="form"&&a!="tabIndex"&&a!="download"&&a!="rowSpan"&&a!="colSpan"&&a!="role"&&a!="popover"&&a in t)try{t[a]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&a[4]!="-"?t.removeAttribute(a):t.setAttribute(a,a=="popover"&&n==1?"":n))}}function Kn(t){return function(a){if(this.l){var n=this.l[a.type+t];if(a.t==null)a.t=bn++;else if(a.t<n.u)return;return n(ue.event?ue.event(a):a)}}}function Tn(t,a,n,l,i,r,s,o,u,d){var v,h,m,b,U,W,p,T,D,M,O,q,S,C,N,k,V,w=a.type;if(a.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),r=[o=a.__e=n.__e]),(v=ue.__b)&&v(a);e:if(typeof w=="function")try{if(T=a.props,D="prototype"in w&&w.prototype.render,M=(v=w.contextType)&&l[v.__c],O=v?M?M.props.value:v.__:l,n.__c?p=(h=a.__c=n.__c).__=h.__E:(D?a.__c=h=new w(T,O):(a.__c=h=new Wa(T,O),h.constructor=w,h.render=tr),M&&M.sub(h),h.state||(h.state={}),h.__n=l,m=h.__d=!0,h.__h=[],h._sb=[]),D&&h.__s==null&&(h.__s=h.state),D&&w.getDerivedStateFromProps!=null&&(h.__s==h.state&&(h.__s=Ve({},h.__s)),Ve(h.__s,w.getDerivedStateFromProps(T,h.__s))),b=h.props,U=h.state,h.__v=a,m)D&&w.getDerivedStateFromProps==null&&h.componentWillMount!=null&&h.componentWillMount(),D&&h.componentDidMount!=null&&h.__h.push(h.componentDidMount);else{if(D&&w.getDerivedStateFromProps==null&&T!==b&&h.componentWillReceiveProps!=null&&h.componentWillReceiveProps(T,O),a.__v==n.__v||!h.__e&&h.shouldComponentUpdate!=null&&h.shouldComponentUpdate(T,h.__s,O)===!1){for(a.__v!=n.__v&&(h.props=T,h.state=h.__s,h.__d=!1),a.__e=n.__e,a.__k=n.__k,a.__k.some(function(H){H&&(H.__=a)}),q=0;q<h._sb.length;q++)h.__h.push(h._sb[q]);h._sb=[],h.__h.length&&s.push(h);break e}h.componentWillUpdate!=null&&h.componentWillUpdate(T,h.__s,O),D&&h.componentDidUpdate!=null&&h.__h.push(function(){h.componentDidUpdate(b,U,W)})}if(h.context=O,h.props=T,h.__P=t,h.__e=!1,S=ue.__r,C=0,D){for(h.state=h.__s,h.__d=!1,S&&S(a),v=h.render(h.props,h.state,h.context),N=0;N<h._sb.length;N++)h.__h.push(h._sb[N]);h._sb=[]}else do h.__d=!1,S&&S(a),v=h.render(h.props,h.state,h.context),h.state=h.__s;while(h.__d&&++C<25);h.state=h.__s,h.getChildContext!=null&&(l=Ve(Ve({},l),h.getChildContext())),D&&!m&&h.getSnapshotBeforeUpdate!=null&&(W=h.getSnapshotBeforeUpdate(b,U)),k=v,v!=null&&v.type===le&&v.key==null&&(k=Bl(v.props.children)),o=Fl(t,It(k)?k:[k],a,n,l,i,r,s,o,u,d),h.base=a.__e,a.__u&=-161,h.__h.length&&s.push(h),p&&(h.__E=h.__=null)}catch(H){if(a.__v=null,u||r!=null)if(H.then){for(a.__u|=u?160:128;o&&o.nodeType==8&&o.nextSibling;)o=o.nextSibling;r[r.indexOf(o)]=null,a.__e=o}else{for(V=r.length;V--;)wn(r[V]);vn(a)}else a.__e=n.__e,a.__k=n.__k,H.then||vn(a);ue.__e(H,a,n)}else r==null&&a.__v==n.__v?(a.__k=n.__k,a.__e=n.__e):o=a.__e=ar(n.__e,a,n,l,i,r,s,u,d);return(v=ue.diffed)&&v(a),128&a.__u?void 0:o}function vn(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(vn)}function Kl(t,a,n){for(var l=0;l<n.length;l++)Sn(n[l],n[++l],n[++l]);ue.__c&&ue.__c(a,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(r){r.call(i)})}catch(r){ue.__e(r,i.__v)}})}function Bl(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:It(t)?t.map(Bl):Ve({},t)}function ar(t,a,n,l,i,r,s,o,u){var d,v,h,m,b,U,W,p=n.props||za,T=a.props,D=a.type;if(D=="svg"?i="http://www.w3.org/2000/svg":D=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),r!=null){for(d=0;d<r.length;d++)if((b=r[d])&&"setAttribute"in b==!!D&&(D?b.localName==D:b.nodeType==3)){t=b,r[d]=null;break}}if(t==null){if(D==null)return document.createTextNode(T);t=document.createElementNS(i,D,T.is&&T),o&&(ue.__m&&ue.__m(a,r),o=!1),r=null}if(D==null)p===T||o&&t.data==T||(t.data=T);else{if(r=r&&Ct.call(t.childNodes),!o&&r!=null)for(p={},d=0;d<t.attributes.length;d++)p[(b=t.attributes[d]).name]=b.value;for(d in p)if(b=p[d],d!="children"){if(d=="dangerouslySetInnerHTML")h=b;else if(!(d in T)){if(d=="value"&&"defaultValue"in T||d=="checked"&&"defaultChecked"in T)continue;ct(t,d,null,b,i)}}for(d in T)b=T[d],d=="children"?m=b:d=="dangerouslySetInnerHTML"?v=b:d=="value"?U=b:d=="checked"?W=b:o&&typeof b!="function"||p[d]===b||ct(t,d,b,p[d],i);if(v)o||h&&(v.__html==h.__html||v.__html==t.innerHTML)||(t.innerHTML=v.__html),a.__k=[];else if(h&&(t.innerHTML=""),Fl(a.type=="template"?t.content:t,It(m)?m:[m],a,n,l,D=="foreignObject"?"http://www.w3.org/1999/xhtml":i,r,s,r?r[0]:n.__k&&ka(n,0),o,u),r!=null)for(d=r.length;d--;)wn(r[d]);o||(d="value",D=="progress"&&U==null?t.removeAttribute("value"):U!=null&&(U!==t[d]||D=="progress"&&!U||D=="option"&&U!=p[d])&&ct(t,d,U,p[d],i),d="checked",W!=null&&W!=t[d]&&ct(t,d,W,p[d],i))}return t}function Sn(t,a,n){try{if(typeof t=="function"){var l=typeof t.__u=="function";l&&t.__u(),l&&a==null||(t.__u=t(a))}else t.current=a}catch(i){ue.__e(i,n)}}function Hl(t,a,n){var l,i;if(ue.unmount&&ue.unmount(t),(l=t.ref)&&(l.current&&l.current!=t.__e||Sn(l,null,a)),(l=t.__c)!=null){if(l.componentWillUnmount)try{l.componentWillUnmount()}catch(r){ue.__e(r,a)}l.base=l.__P=null}if(l=t.__k)for(i=0;i<l.length;i++)l[i]&&Hl(l[i],a,n||typeof t.type!="function");n||wn(t.__e),t.__c=t.__=t.__e=void 0}function tr(t,a,n){return this.constructor(t,n)}function nr(t,a,n){var l,i,r,s;a==document&&(a=document.documentElement),ue.__&&ue.__(t,a),i=(l=!1)?null:a.__k,r=[],s=[],Tn(a,t=a.__k=Qi(le,null,[t]),i||za,za,a.namespaceURI,i?null:a.firstChild?Ct.call(a.childNodes):null,r,i?i.__e:a.firstChild,l,s),Kl(r,t,s)}Ct=Ml.slice,ue={__e:function(t,a,n,l){for(var i,r,s;a=a.__;)if((i=a.__c)&&!i.__)try{if((r=i.constructor)&&r.getDerivedStateFromError!=null&&(i.setState(r.getDerivedStateFromError(t)),s=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,l||{}),s=i.__d),s)return i.__E=i}catch(o){t=o}throw t}},Ll=0,Pl=function(t){return t!=null&&t.constructor===void 0},Wa.prototype.setState=function(t,a){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Ve({},this.state),typeof t=="function"&&(t=t(Ve({},n),this.props)),t&&Ve(n,t),t!=null&&this.__v&&(a&&this._sb.push(a),Fn(this))},Wa.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),Fn(this))},Wa.prototype.render=le,ua=[],Ol=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ul=function(t,a){return t.__v.__b-a.__v.__b},wt.__r=0,Wl=/(PointerCapture)$|Capture$/i,bn=0,dn=Kn(!1),un=Kn(!0);var lr=0;function e(t,a,n,l,i,r){a||(a={});var s,o,u=a;if("ref"in u)for(o in u={},a)o=="ref"?s=a[o]:u[o]=a[o];var d={type:t,props:u,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--lr,__i:-1,__u:0,__source:i,__self:r};if(typeof t=="function"&&(s=t.defaultProps))for(o in s)u[o]===void 0&&(u[o]=s[o]);return ue.vnode&&ue.vnode(d),d}const ir=(function(){const a=typeof document<"u"&&document.createElement("link").relList;return a&&a.supports&&a.supports("modulepreload")?"modulepreload":"preload"})(),rr=function(t){return"/admin/"+t},Bn={},Gt=function(a,n,l){let i=Promise.resolve();if(n&&n.length>0){let s=function(d){return Promise.all(d.map(v=>Promise.resolve(v).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),u=o?.nonce||o?.getAttribute("nonce");i=s(n.map(d=>{if(d=rr(d),d in Bn)return;Bn[d]=!0;const v=d.endsWith(".css"),h=v?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${h}`))return;const m=document.createElement("link");if(m.rel=v?"stylesheet":ir,v||(m.as="script"),m.crossOrigin="",m.href=d,u&&m.setAttribute("nonce",u),document.head.appendChild(m),v)return new Promise((b,U)=>{m.addEventListener("load",b),m.addEventListener("error",()=>U(new Error(`Unable to preload CSS for ${d}`)))})}))}function r(s){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=s,window.dispatchEvent(o),!o.defaultPrevented)throw s}return i.then(s=>{for(const o of s||[])o.status==="rejected"&&r(o.reason);return a().catch(r)})};var Ka,ge,qt,Hn,Tt=0,Vl=[],be=ue,Vn=be.__b,Gn=be.__r,qn=be.diffed,jn=be.__c,Yn=be.unmount,Xn=be.__;function kn(t,a){be.__h&&be.__h(ge,t,Tt||a),Tt=0;var n=ge.__H||(ge.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function Cc(t){return Tt=1,sr(ql,t)}function sr(t,a,n){var l=kn(Ka++,2);if(l.t=t,!l.__c&&(l.__=[ql(void 0,a),function(o){var u=l.__N?l.__N[0]:l.__[0],d=l.t(u,o);u!==d&&(l.__N=[d,l.__[1]],l.__c.setState({}))}],l.__c=ge,!ge.__f)){var i=function(o,u,d){if(!l.__c.__H)return!0;var v=l.__c.__H.__.filter(function(m){return!!m.__c});if(v.every(function(m){return!m.__N}))return!r||r.call(this,o,u,d);var h=l.__c.props!==o;return v.forEach(function(m){if(m.__N){var b=m.__[0];m.__=m.__N,m.__N=void 0,b!==m.__[0]&&(h=!0)}}),r&&r.call(this,o,u,d)||h};ge.__f=!0;var r=ge.shouldComponentUpdate,s=ge.componentWillUpdate;ge.componentWillUpdate=function(o,u,d){if(this.__e){var v=r;r=void 0,i(o,u,d),r=v}s&&s.call(this,o,u,d)},ge.shouldComponentUpdate=i}return l.__N||l.__}function X(t,a){var n=kn(Ka++,3);!be.__s&&Gl(n.__H,a)&&(n.__=t,n.u=a,ge.__H.__h.push(n))}function qe(t){return Tt=5,xt(function(){return{current:t}},[])}function xt(t,a){var n=kn(Ka++,7);return Gl(n.__H,a)&&(n.__=t(),n.__H=a,n.__h=t),n.__}function or(){for(var t;t=Vl.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(bt),t.__H.__h.forEach(hn),t.__H.__h=[]}catch(a){t.__H.__h=[],be.__e(a,t.__v)}}be.__b=function(t){ge=null,Vn&&Vn(t)},be.__=function(t,a){t&&a.__k&&a.__k.__m&&(t.__m=a.__k.__m),Xn&&Xn(t,a)},be.__r=function(t){Gn&&Gn(t),Ka=0;var a=(ge=t.__c).__H;a&&(qt===ge?(a.__h=[],ge.__h=[],a.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(a.__h.forEach(bt),a.__h.forEach(hn),a.__h=[],Ka=0)),qt=ge},be.diffed=function(t){qn&&qn(t);var a=t.__c;a&&a.__H&&(a.__H.__h.length&&(Vl.push(a)!==1&&Hn===be.requestAnimationFrame||((Hn=be.requestAnimationFrame)||cr)(or)),a.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),qt=ge=null},be.__c=function(t,a){a.some(function(n){try{n.__h.forEach(bt),n.__h=n.__h.filter(function(l){return!l.__||hn(l)})}catch(l){a.some(function(i){i.__h&&(i.__h=[])}),a=[],be.__e(l,n.__v)}}),jn&&jn(t,a)},be.unmount=function(t){Yn&&Yn(t);var a,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(l){try{bt(l)}catch(i){a=i}}),n.__H=void 0,a&&be.__e(a,n.__v))};var Jn=typeof requestAnimationFrame=="function";function cr(t){var a,n=function(){clearTimeout(l),Jn&&cancelAnimationFrame(a),setTimeout(t)},l=setTimeout(n,35);Jn&&(a=requestAnimationFrame(n))}function bt(t){var a=ge,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),ge=a}function hn(t){var a=ge;t.__c=t.__(),ge=a}function Gl(t,a){return!t||t.length!==a.length||a.some(function(n,l){return n!==t[l]})}function ql(t,a){return typeof a=="function"?a(t):a}var dr=Symbol.for("preact-signals");function Dt(){if(la>1)la--;else{for(var t,a=!1;Ma!==void 0;){var n=Ma;for(Ma=void 0,pn++;n!==void 0;){var l=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Xl(n))try{n.c()}catch(i){a||(t=i,a=!0)}n=l}}if(pn=0,la--,a)throw t}}function ur(t){if(la>0)return t();la++;try{return t()}finally{Dt()}}var de=void 0;function jl(t){var a=de;de=void 0;try{return t()}finally{de=a}}var Ma=void 0,la=0,pn=0,St=0;function Yl(t){if(de!==void 0){var a=t.n;if(a===void 0||a.t!==de)return a={i:0,S:t,p:de.s,n:void 0,t:de,e:void 0,x:void 0,r:a},de.s!==void 0&&(de.s.n=a),de.s=a,t.n=a,32&de.f&&t.S(a),a;if(a.i===-1)return a.i=0,a.n!==void 0&&(a.n.p=a.p,a.p!==void 0&&(a.p.n=a.n),a.p=de.s,a.n=void 0,de.s.n=a,de.s=a),a}}function ke(t,a){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=a?.watched,this.Z=a?.unwatched,this.name=a?.name}ke.prototype.brand=dr;ke.prototype.h=function(){return!0};ke.prototype.S=function(t){var a=this,n=this.t;n!==t&&t.e===void 0&&(t.x=n,this.t=t,n!==void 0?n.e=t:jl(function(){var l;(l=a.W)==null||l.call(a)}))};ke.prototype.U=function(t){var a=this;if(this.t!==void 0){var n=t.e,l=t.x;n!==void 0&&(n.x=l,t.e=void 0),l!==void 0&&(l.e=n,t.x=void 0),t===this.t&&(this.t=l,l===void 0&&jl(function(){var i;(i=a.Z)==null||i.call(a)}))}};ke.prototype.subscribe=function(t){var a=this;return Va(function(){var n=a.value,l=de;de=void 0;try{t(n)}finally{de=l}},{name:"sub"})};ke.prototype.valueOf=function(){return this.value};ke.prototype.toString=function(){return this.value+""};ke.prototype.toJSON=function(){return this.value};ke.prototype.peek=function(){var t=de;de=void 0;try{return this.value}finally{de=t}};Object.defineProperty(ke.prototype,"value",{get:function(){var t=Yl(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(pn>100)throw new Error("Cycle detected");this.v=t,this.i++,St++,la++;try{for(var a=this.t;a!==void 0;a=a.x)a.t.N()}finally{Dt()}}}});function we(t,a){return new ke(t,a)}function Xl(t){for(var a=t.s;a!==void 0;a=a.n)if(a.S.i!==a.i||!a.S.h()||a.S.i!==a.i)return!0;return!1}function Jl(t){for(var a=t.s;a!==void 0;a=a.n){var n=a.S.n;if(n!==void 0&&(a.r=n),a.S.n=a,a.i=-1,a.n===void 0){t.s=a;break}}}function Ql(t){for(var a=t.s,n=void 0;a!==void 0;){var l=a.p;a.i===-1?(a.S.U(a),l!==void 0&&(l.n=a.n),a.n!==void 0&&(a.n.p=l)):n=a,a.S.n=a.r,a.r!==void 0&&(a.r=void 0),a=l}t.s=n}function ma(t,a){ke.call(this,void 0),this.x=t,this.s=void 0,this.g=St-1,this.f=4,this.W=a?.watched,this.Z=a?.unwatched,this.name=a?.name}ma.prototype=new ke;ma.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===St))return!0;if(this.g=St,this.f|=1,this.i>0&&!Xl(this))return this.f&=-2,!0;var t=de;try{Jl(this),de=this;var a=this.x();(16&this.f||this.v!==a||this.i===0)&&(this.v=a,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return de=t,Ql(this),this.f&=-2,!0};ma.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var a=this.s;a!==void 0;a=a.n)a.S.S(a)}ke.prototype.S.call(this,t)};ma.prototype.U=function(t){if(this.t!==void 0&&(ke.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var a=this.s;a!==void 0;a=a.n)a.S.U(a)}};ma.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(ma.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=Yl(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function Ba(t,a){return new ma(t,a)}function Zl(t){var a=t.u;if(t.u=void 0,typeof a=="function"){la++;var n=de;de=void 0;try{a()}catch(l){throw t.f&=-2,t.f|=8,En(t),l}finally{de=n,Dt()}}}function En(t){for(var a=t.s;a!==void 0;a=a.n)a.S.U(a);t.x=void 0,t.s=void 0,Zl(t)}function vr(t){if(de!==this)throw new Error("Out-of-order effect");Ql(this),de=t,this.f&=-2,8&this.f&&En(this),Dt()}function Na(t,a){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=a?.name}Na.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var a=this.x();typeof a=="function"&&(this.u=a)}finally{t()}};Na.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Zl(this),Jl(this),la++;var t=de;return de=this,vr.bind(this,t)};Na.prototype.N=function(){2&this.f||(this.f|=2,this.o=Ma,Ma=this)};Na.prototype.d=function(){this.f|=8,1&this.f||En(this)};Na.prototype.dispose=function(){this.d()};function Va(t,a){var n=new Na(t,a);try{n.c()}catch(i){throw n.d(),i}var l=n.d.bind(n);return l[Symbol.dispose]=l,l}var ei,Rt,dt,hr=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__,ai=[];Va(function(){ei=this.N})();function Aa(t,a){ue[t]=a.bind(null,ue[t]||function(){})}function kt(t){if(dt){var a=dt;dt=void 0,a()}dt=t&&t.S()}function ti(t){var a=this,n=t.data,l=c(n);l.value=n;var i=xt(function(){for(var o=a,u=a.__v;u=u.__;)if(u.__c){u.__c.__$f|=4;break}var d=Ba(function(){var b=l.value.value;return b===0?0:b===!0?"":b||""}),v=Ba(function(){return!Array.isArray(d.value)&&!Pl(d.value)}),h=Va(function(){if(this.N=ni,v.value){var b=d.value;o.__v&&o.__v.__e&&o.__v.__e.nodeType===3&&(o.__v.__e.data=b)}}),m=a.__$u.d;return a.__$u.d=function(){h(),m.call(this)},[v,d]},[]),r=i[0],s=i[1];return r.value?s.peek():s.value}ti.displayName="ReactiveTextNode";Object.defineProperties(ke.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:ti},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});Aa("__b",function(t,a){if(typeof a.type=="string"){var n,l=a.props;for(var i in l)if(i!=="children"){var r=l[i];r instanceof ke&&(n||(a.__np=n={}),n[i]=r,l[i]=r.peek())}}t(a)});Aa("__r",function(t,a){if(t(a),a.type!==le){kt();var n,l=a.__c;l&&(l.__$f&=-2,(n=l.__$u)===void 0&&(l.__$u=n=(function(i,r){var s;return Va(function(){s=this},{name:r}),s.c=i,s})(function(){var i;hr&&((i=n.y)==null||i.call(n)),l.__$f|=1,l.setState({})},typeof a.type=="function"?a.type.displayName||a.type.name:""))),Rt=l,kt(n)}});Aa("__e",function(t,a,n,l){kt(),Rt=void 0,t(a,n,l)});Aa("diffed",function(t,a){kt(),Rt=void 0;var n;if(typeof a.type=="string"&&(n=a.__e)){var l=a.__np,i=a.props;if(l){var r=n.U;if(r)for(var s in r){var o=r[s];o!==void 0&&!(s in l)&&(o.d(),r[s]=void 0)}else r={},n.U=r;for(var u in l){var d=r[u],v=l[u];d===void 0?(d=pr(n,u,v,i),r[u]=d):d.o(v,i)}}}t(a)});function pr(t,a,n,l){var i=a in t&&t.ownerSVGElement===void 0,r=we(n);return{o:function(s,o){r.value=s,l=o},d:Va(function(){this.N=ni;var s=r.value.value;l[a]!==s&&(l[a]=s,i?t[a]=s:s!=null&&(s!==!1||a[4]==="-")?t.setAttribute(a,s):t.removeAttribute(a))})}}Aa("unmount",function(t,a){if(typeof a.type=="string"){var n=a.__e;if(n){var l=n.U;if(l){n.U=void 0;for(var i in l){var r=l[i];r&&r.d()}}}}else{var s=a.__c;if(s){var o=s.__$u;o&&(s.__$u=void 0,o.d())}}t(a)});Aa("__h",function(t,a,n,l){(l<3||l===9)&&(a.__$f|=2),t(a,n,l)});Wa.prototype.shouldComponentUpdate=function(t,a){if(this.__R)return!0;var n=this.__$u,l=n&&n.s!==void 0;for(var i in a)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){var r=2&this.__$f;if(!(l||r||4&this.__$f)||1&this.__$f)return!0}else if(!(l||4&this.__$f)||3&this.__$f)return!0;for(var s in t)if(s!=="__source"&&t[s]!==this.props[s])return!0;for(var o in this.props)if(!(o in t))return!0;return!1};function c(t,a){return xt(function(){return we(t,a)},[])}function Lt(t,a){var n=qe(t);return n.current=t,Rt.__$f|=4,xt(function(){return Ba(function(){return n.current()},a)},[])}var mr=function(t){queueMicrotask(function(){queueMicrotask(t)})};function fr(){ur(function(){for(var t;t=ai.shift();)ei.call(t)})}function ni(){ai.push(this)===1&&(ue.requestAnimationFrame||mr)(fr)}const ha=we(null),yr=Ba(()=>ha.value!==null),li=we(900),gr=we(!1);let Ta=null;const Sa=()=>{Pt()};function _r(){document.addEventListener("mousemove",Sa,{passive:!0}),document.addEventListener("keydown",Sa,{passive:!0}),document.addEventListener("click",Sa,{passive:!0}),Pt()}function br(){document.removeEventListener("mousemove",Sa),document.removeEventListener("keydown",Sa),document.removeEventListener("click",Sa),Ta!==null&&(clearTimeout(Ta),Ta=null)}function Pt(){Ta!==null&&clearTimeout(Ta),Ta=setTimeout(()=>{Ga()},li.value*1e3)}function wr(t,a){ha.value=t,a!==void 0&&(li.value=a),_r(),location.hash="#/dashboard"}function Ga(){ha.value=null,br(),location.hash="#/login"}const Ha={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`,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`,WALLET_PURGE:t=>`/v1/wallets/${t}/purge`,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_ACTIONS:"/v1/admin/actions",ADMIN_WALLET_STAKING:t=>`/v1/admin/wallets/${t}/staking`,ADMIN_DEFI_POSITIONS:"/v1/admin/defi/positions",ADMIN_MASTER_PASSWORD:"/v1/admin/master-password",ADMIN_WALLET_APPS:"/v1/admin/wallet-apps",ADMIN_WALLET_APP:t=>`/v1/admin/wallet-apps/${t}`,ADMIN_WALLET_APP_TEST_NOTIFICATION:t=>`/v1/admin/wallet-apps/${t}/test-notification`,ADMIN_AUDIT_LOGS:"/v1/audit-logs",ADMIN_STATS:"/v1/admin/stats",ADMIN_AUTOSTOP_RULES:"/v1/admin/autostop/rules",ERC8004_AGENT:t=>`/v1/erc8004/agent/${t}`,ERC8004_REPUTATION:t=>`/v1/erc8004/agent/${t}/reputation`,ERC8004_REGISTRATION_FILE:t=>`/v1/erc8004/registration-file/${t}`,ERC8004_VALIDATION:t=>`/v1/erc8004/validation/${t}`,WALLET_PROVIDER:t=>`/v1/wallets/${t}/provider`,ADMIN_WALLET_NFTS:t=>`/v1/wallets/${t}/nfts`,ADMIN_WALLET_NFT_METADATA:(t,a)=>`/v1/wallets/${t}/nfts/${a}`,ADMIN_CREDENTIALS:"/v1/admin/credentials",ADMIN_CREDENTIAL_DELETE:t=>`/v1/admin/credentials/${t}`,ADMIN_CREDENTIAL_ROTATE:t=>`/v1/admin/credentials/${t}/rotate`,WALLET_CREDENTIALS:t=>`/v1/wallets/${t}/credentials`,WALLET_CREDENTIAL_DELETE:(t,a)=>`/v1/wallets/${t}/credentials/${a}`,WALLET_CREDENTIAL_ROTATE:(t,a)=>`/v1/wallets/${t}/credentials/${a}/rotate`,WALLET_ACTIONS:t=>`/v1/wallets/${t}/actions`,WALLET_ACTION_DETAIL:(t,a)=>`/v1/wallets/${t}/actions/${a}`},$a=we(""),wa=we(null),Fa=we(!1),Xe={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:"#0c0c0c",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)"}},Tr=async t=>{if(t.preventDefault(),!!$a.value.trim()){Fa.value=!0,wa.value=null;try{const a=await fetch(Ha.ADMIN_STATUS,{headers:{"X-Master-Password":$a.value},signal:AbortSignal.timeout(1e4)});if(a.status===401){wa.value="Invalid master password";return}if(!a.ok){wa.value="Cannot connect to daemon";return}const n=await a.json();wr($a.value,n.adminTimeout)}catch{wa.value="Cannot connect to daemon"}finally{Fa.value=!1}}};function Sr(){return e("div",{style:Xe.wrapper,children:e("form",{style:Xe.card,onSubmit:Tr,children:[e("h1",{style:Xe.title,children:"WAIaaS Admin"}),e("p",{style:Xe.subtitle,children:"Enter master password to continue"}),e("input",{type:"password",placeholder:"Master password",autoFocus:!0,value:$a.value,onInput:t=>{$a.value=t.target.value},style:Xe.input}),e("button",{type:"submit",disabled:Fa.value,style:{...Xe.button,...Fa.value?Xe.buttonDisabled:{}},children:Fa.value?"Signing in...":"Sign in"}),wa.value&&e("p",{style:Xe.error,children:wa.value})]})})}const kr=[{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_hyperevm_mainnet",label:"HyperEVM Mainnet",description:"RPC endpoint URL for HyperEVM mainnet (Hyperliquid)",page:"/wallets",tab:"rpc",fieldName:"rpc.evm_hyperevm_mainnet",keywords:["blockchain","rpc","evm","hyperevm","hyperliquid","url","endpoint"]},{id:"wallets.rpc.evm_hyperevm_testnet",label:"HyperEVM Testnet",description:"RPC endpoint URL for HyperEVM testnet (Hyperliquid)",page:"/wallets",tab:"rpc",fieldName:"rpc.evm_hyperevm_testnet",keywords:["blockchain","rpc","evm","hyperevm","hyperliquid","url","endpoint","test"]},{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.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:"policies.defaults.default_deny_erc8128_domains",label:"Default Deny: ERC-8128 Domains",description:"Deny ERC-8128 signing unless a matching domain whitelist policy exists",page:"/policies",tab:"defaults",fieldName:"policy.default_deny_erc8128_domains",keywords:["erc8128","deny","domain","whitelist","policy"]},{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.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:"protection.autostop.enabled",label:"Enabled",description:"Enable or disable AutoStop protection rules",page:"/protection",tab:"autostop",fieldName:"autostop.enabled",keywords:["autostop","protection","enable","toggle","security"]},{id:"protection.autostop.consecutive_failures_threshold",label:"Consecutive Failures Threshold",description:"Suspend wallet after this many consecutive failed transactions",page:"/protection",tab:"autostop",fieldName:"autostop.consecutive_failures_threshold",keywords:["autostop","failure","threshold","suspend","security","protection"]},{id:"protection.autostop.unusual_activity_threshold",label:"Unusual Activity Threshold",description:"Max transactions within window before triggering unusual activity alert",page:"/protection",tab:"autostop",fieldName:"autostop.unusual_activity_threshold",keywords:["autostop","unusual","activity","threshold","security","protection"]},{id:"protection.autostop.unusual_activity_window_sec",label:"Unusual Activity Window (seconds)",description:"Time window for unusual activity detection",page:"/protection",tab:"autostop",fieldName:"autostop.unusual_activity_window_sec",keywords:["autostop","unusual","activity","window","time","security","protection"]},{id:"protection.autostop.idle_timeout_sec",label:"Idle Timeout (seconds)",description:"Revoke sessions with no activity for this duration",page:"/protection",tab:"autostop",fieldName:"autostop.idle_timeout_sec",keywords:["autostop","idle","timeout","session","revoke","security","protection"]},{id:"protection.autostop.idle_check_interval_sec",label:"Idle Check Interval (seconds)",description:"How often to check for idle sessions",page:"/protection",tab:"autostop",fieldName:"autostop.idle_check_interval_sec",keywords:["autostop","idle","check","interval","security","protection"]},{id:"settings..currency",label:"Display Currency",description:"Currency for USD amount conversion in dashboard and notifications",page:"/settings",tab:"",fieldName:"display.currency",keywords:["currency","display","usd","conversion","fiat","system","settings"]},{id:"settings..rate_limit_global_ip_rpm",label:"Global IP Rate Limit (RPM)",description:"Maximum API requests per minute from a single IP address",page:"/settings",tab:"",fieldName:"security.rate_limit_global_ip_rpm",keywords:["rate","limit","rpm","ip","global","throttle","system","settings"]},{id:"settings..log_level",label:"Log Level",description:"Daemon logging verbosity level",page:"/settings",tab:"",fieldName:"daemon.log_level",keywords:["log","level","debug","info","warn","error","daemon","system","settings"]},{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:"settings..cross_validation_threshold",label:"Cross Validation Threshold (%)",description:"Maximum allowed deviation between price oracle sources",page:"/settings",tab:"",fieldName:"oracle.cross_validation_threshold",keywords:["oracle","price","validation","threshold","deviation"]},{id:"settings..signing_sdk_enabled",label:"SDK Enabled",description:"Enable Signing SDK for wallet app approval",page:"/settings",tab:"",fieldName:"signing_sdk.enabled",keywords:["signing","sdk","wallet","app","enable"]},{id:"settings..signing_sdk_request_expiry",label:"Request Expiry (min)",description:"Minutes before a sign request expires",page:"/settings",tab:"",fieldName:"signing_sdk.request_expiry_min",keywords:["signing","sdk","expiry","timeout","request"]},{id:"settings..signing_sdk_preferred_channel",label:"Preferred Channel",description:"Preferred signing channel for SDK requests",page:"/settings",tab:"",fieldName:"signing_sdk.preferred_channel",keywords:["signing","sdk","channel","push","relay","telegram"]},{id:"wallet-apps..signing_sdk_notifications",label:"Notifications Enabled",description:"Push event notifications to wallet apps",page:"/wallet-apps",tab:"",fieldName:"signing_sdk.notifications_enabled",keywords:["signing","sdk","notification","wallet","push"]},{id:"settings..smart_account_pimlico_api_key",label:"Pimlico API Key",description:"Global default Pimlico bundler API key for smart accounts",page:"/settings",tab:"",fieldName:"smart_account.pimlico.api_key",keywords:["smart","account","pimlico","bundler","api","key","erc4337"]},{id:"settings..smart_account_pimlico_policy_id",label:"Pimlico Paymaster Policy ID",description:"Global default Pimlico paymaster sponsorship policy ID",page:"/settings",tab:"",fieldName:"smart_account.pimlico.paymaster_policy_id",keywords:["smart","account","pimlico","paymaster","policy","erc4337"]},{id:"settings..smart_account_alchemy_api_key",label:"Alchemy API Key (AA)",description:"Global default Alchemy bundler API key for smart accounts",page:"/settings",tab:"",fieldName:"smart_account.alchemy.api_key",keywords:["smart","account","alchemy","bundler","api","key","erc4337"]},{id:"settings..smart_account_alchemy_policy_id",label:"Alchemy Paymaster Policy ID",description:"Global default Alchemy paymaster policy ID",page:"/settings",tab:"",fieldName:"smart_account.alchemy.paymaster_policy_id",keywords:["smart","account","alchemy","paymaster","policy","erc4337"]},{id:"settings..erc8128_enabled",label:"ERC-8128 Enabled",description:"Enable ERC-8128 HTTP message signing",page:"/settings",tab:"",fieldName:"erc8128.enabled",keywords:["erc8128","signing","http","rfc9421","enable"]},{id:"settings..erc8128_default_preset",label:"Default Preset",description:"Default covered components preset for ERC-8128",page:"/settings",tab:"",fieldName:"erc8128.default_preset",keywords:["erc8128","preset","minimal","standard","strict"]},{id:"settings..erc8128_default_ttl_sec",label:"Default TTL",description:"Default signature TTL in seconds",page:"/settings",tab:"",fieldName:"erc8128.default_ttl_sec",keywords:["erc8128","ttl","expiry","timeout"]},{id:"settings..erc8128_default_nonce",label:"Include Nonce",description:"Include nonce in ERC-8128 signatures by default",page:"/settings",tab:"",fieldName:"erc8128.default_nonce",keywords:["erc8128","nonce","replay"]},{id:"settings..erc8128_default_algorithm",label:"Algorithm",description:"ERC-8128 signing algorithm",page:"/settings",tab:"",fieldName:"erc8128.default_algorithm",keywords:["erc8128","algorithm","eip191"]},{id:"settings..erc8128_default_rate_limit_rpm",label:"Rate Limit",description:"ERC-8128 rate limit per domain per minute",page:"/settings",tab:"",fieldName:"erc8128.default_rate_limit_rpm",keywords:["erc8128","rate","limit","throttle"]}],Pe=we(""),me=we(null),Er={"/wallets":"Wallets","/sessions":"Sessions","/transactions":"Transactions","/policies":"Policies","/notifications":"Notifications","/protection":"Protection","/settings":"Settings","/providers":"Providers","/wallet-apps":"Wallet Apps"};function Nr(t){if(!t.trim())return[];const a=t.toLowerCase();return kr.filter(n=>[n.label,n.description,n.keywords.join(" ")].join(" ").toLowerCase().includes(a)).slice(0,10)}function Ar(t){const a=Er[t.page]??t.page;return t.tab?`${a} > ${t.tab}`:a}function Cr({open:t}){const a=c(""),n=c(0),l=qe(null),i=t.value?Nr(a.value):[];if(X(()=>{t.value&&(a.value="",n.value=0,requestAnimationFrame(()=>{l.current?.focus()}))},[t.value]),!t.value)return null;const r=()=>{t.value=!1,a.value="",n.value=0},s=d=>{d.target.classList.contains("search-overlay")&&r()},o=d=>{window.location.hash="#"+d.page,d.tab?me.value={tab:d.tab,fieldName:d.fieldName}:setTimeout(()=>{Pe.value=d.fieldName},100),r()};return e("div",{class:"search-overlay",onClick:s,children:e("div",{class:"search-popover",onKeyDown:d=>{if(d.key==="Escape"){r();return}if(d.key==="ArrowDown"){d.preventDefault(),n.value=Math.min(n.value+1,i.length-1);return}if(d.key==="ArrowUp"){d.preventDefault(),n.value=Math.max(n.value-1,0);return}if(d.key==="Enter"&&i.length>0){d.preventDefault(),o(i[n.value]);return}},children:[e("div",{class:"search-input-wrapper",children:e("input",{ref:l,class:"search-input",type:"text",placeholder:"Search settings...",value:a.value,onInput:d=>{a.value=d.target.value,n.value=0}})}),e("div",{class:"search-results",children:[a.value.trim()&&i.length===0&&e("div",{class:"search-empty",children:"No settings found"}),i.map((d,v)=>e("button",{class:`search-result-item${v===n.value?" selected":""}`,onClick:()=>o(d),onMouseEnter:()=>{n.value=v},children:[e("div",{class:"search-result-label",children:d.label}),e("div",{class:"search-result-desc",children:d.description}),e("div",{class:"search-result-path",children:Ar(d)})]},d.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 pa=we([]),ii=Ba(()=>pa.value.some(t=>typeof t.isDirty=="function"&&t.isDirty()));function ze(t){pa.value=[...pa.value.filter(a=>a.id!==t.id),t]}function Me(t){pa.value=pa.value.filter(a=>a.id!==t)}async function Ir(){const t=pa.value.filter(a=>typeof a.isDirty=="function"&&a.isDirty());try{for(const a of t)await a.save();return!0}catch{return!1}}function xr(){const t=pa.value.filter(a=>typeof a.isDirty=="function"&&a.isDirty());for(const a of t)a.discard()}function E({label:t,name:a,type:n="text",value:l,onChange:i,options:r,error:s,required:o,disabled:u,placeholder:d,min:v,max:h,description:m}){const b=Pe.value===a;if(X(()=>{if(b){const W=document.querySelector(`[name="${a}"]`);W&&W.closest(".form-field")?.scrollIntoView({behavior:"smooth",block:"center"});const p=setTimeout(()=>{Pe.value=""},2500);return()=>clearTimeout(p)}},[b,a]),n==="checkbox")return e("div",{class:`form-field${b?" form-field--highlight":""}`,children:[e("label",{children:[e("input",{type:"checkbox",name:a,checked:!!l,onChange:W=>i(W.target.checked),disabled:u}),t,o&&e("span",{children:" *"})]}),m&&e("span",{class:"form-description",children:m}),s&&e("span",{class:"form-error",children:s})]});const U=`field-${a}`;return e("div",{class:`form-field${b?" form-field--highlight":""}`,children:[e("label",{for:U,children:[t,o&&e("span",{children:" *"})]}),n==="select"?e("select",{id:U,name:a,value:l,onChange:W=>i(W.target.value),disabled:u,children:r?.map(W=>e("option",{value:W.value,children:W.label},W.value))}):n==="textarea"?e("textarea",{id:U,name:a,value:l,onInput:W=>i(W.target.value),disabled:u,placeholder:d}):e("input",{id:U,type:n,name:a,value:l,onInput:W=>{const p=W.target;i(n==="number"?Number(p.value):p.value)},disabled:u,placeholder:d,min:v,max:h,required:o}),m&&e("span",{class:"form-description",children:m}),s&&e("span",{class:"form-error",children:s})]})}function x({variant:t="primary",size:a="md",loading:n=!1,disabled:l=!1,onClick:i,children:r,type:s="button"}){const o=["btn",`btn-${t}`,a==="sm"?"btn-sm":""].filter(Boolean).join(" ");return e("button",{type:s,class:o,disabled:l||n,onClick:i,children:n?"...":r})}function Y({variant:t,children:a}){return e("span",{class:`badge badge-${t}`,children:a})}const Pa=we(null),Ca=we(!1);function ri(t){Pa.value=t}function Dr(){const t=Pa.value;if(!t)return null;const a=async()=>{Ca.value=!0;const i=await Ir();Ca.value=!1,i&&(Pa.value=null,t.execute())},n=()=>{xr(),Pa.value=null,t.execute()},l=()=>{Pa.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(x,{variant:"secondary",onClick:l,disabled:Ca.value,children:"Cancel"}),e(x,{variant:"ghost",onClick:n,disabled:Ca.value,children:"Discard & Navigate"}),e(x,{variant:"primary",onClick:a,loading:Ca.value,children:"Save & Navigate"})]})]})})}const Rr=/\{[^{}]+\}/g,Lr=()=>typeof process=="object"&&Number.parseInt(process?.versions?.node?.substring(0,2))>=18&&process.versions.undici;function Pr(){return Math.random().toString(36).slice(2,11)}function Or(t){let{baseUrl:a="",Request:n=globalThis.Request,fetch:l=globalThis.fetch,querySerializer:i,bodySerializer:r,pathSerializer:s,headers:o,requestInitExt:u=void 0,...d}={...t};u=Lr()?u:void 0,a=el(a);const v=[];async function h(m,b){const{baseUrl:U,fetch:W=l,Request:p=n,headers:T,params:D={},parseAs:M="json",querySerializer:O,bodySerializer:q=r??Wr,pathSerializer:S,body:C,middleware:N=[],...k}=b||{};let V=a;U&&(V=el(U)??a);let w=typeof i=="function"?i:Qn(i);O&&(w=typeof O=="function"?O:Qn({...typeof i=="object"?i:{},...O}));const H=S||s||Ur,Z=C===void 0?void 0:q(C,Zn(o,T,D.header)),A=Zn(Z===void 0||Z instanceof FormData?{}:{"Content-Type":"application/json"},o,T,D.header),B=[...v,...N],I={redirect:"follow",...d,...k,body:Z,headers:A};let g,F,j=new p(Mr(m,{baseUrl:V,params:D,querySerializer:w,pathSerializer:H}),I),J;for(const re in k)re in j||(j[re]=k[re]);if(B.length){g=Pr(),F=Object.freeze({baseUrl:V,fetch:W,parseAs:M,querySerializer:w,bodySerializer:q,pathSerializer:H});for(const re of B)if(re&&typeof re=="object"&&typeof re.onRequest=="function"){const ee=await re.onRequest({request:j,schemaPath:m,params:D,options:F,id:g});if(ee)if(ee instanceof p)j=ee;else if(ee instanceof Response){J=ee;break}else throw new Error("onRequest: must return new Request() or Response() when modifying the request")}}if(!J){try{J=await W(j,u)}catch(re){let ee=re;if(B.length)for(let _e=B.length-1;_e>=0;_e--){const K=B[_e];if(K&&typeof K=="object"&&typeof K.onError=="function"){const oe=await K.onError({request:j,error:ee,schemaPath:m,params:D,options:F,id:g});if(oe){if(oe instanceof Response){ee=void 0,J=oe;break}if(oe instanceof Error){ee=oe;continue}throw new Error("onError: must return new Response() or instance of Error")}}}if(ee)throw ee}if(B.length)for(let re=B.length-1;re>=0;re--){const ee=B[re];if(ee&&typeof ee=="object"&&typeof ee.onResponse=="function"){const _e=await ee.onResponse({request:j,response:J,schemaPath:m,params:D,options:F,id:g});if(_e){if(!(_e instanceof Response))throw new Error("onResponse: must return new Response() when modifying the response");J=_e}}}}const L=J.headers.get("Content-Length");if(J.status===204||j.method==="HEAD"||L==="0"&&!J.headers.get("Transfer-Encoding")?.includes("chunked"))return J.ok?{data:void 0,response:J}:{error:void 0,response:J};if(J.ok)return{data:await(async()=>{if(M==="stream")return J.body;if(M==="json"&&!L){const ee=await J.text();return ee?JSON.parse(ee):void 0}return await J[M]()})(),response:J};let Q=await J.text();try{Q=JSON.parse(Q)}catch{}return{error:Q,response:J}}return{request(m,b,U){return h(b,{...U,method:m.toUpperCase()})},GET(m,b){return h(m,{...b,method:"GET"})},PUT(m,b){return h(m,{...b,method:"PUT"})},POST(m,b){return h(m,{...b,method:"POST"})},DELETE(m,b){return h(m,{...b,method:"DELETE"})},OPTIONS(m,b){return h(m,{...b,method:"OPTIONS"})},HEAD(m,b){return h(m,{...b,method:"HEAD"})},PATCH(m,b){return h(m,{...b,method:"PATCH"})},TRACE(m,b){return h(m,{...b,method:"TRACE"})},use(...m){for(const b of m)if(b){if(typeof b!="object"||!("onRequest"in b||"onResponse"in b||"onError"in b))throw new Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");v.push(b)}},eject(...m){for(const b of m){const U=v.indexOf(b);U!==-1&&v.splice(U,1)}}}}function Ot(t,a,n){if(a==null)return"";if(typeof a=="object")throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${n?.allowReserved===!0?a:encodeURIComponent(a)}`}function si(t,a,n){if(!a||typeof a!="object")return"";const l=[],i={simple:",",label:".",matrix:";"}[n.style]||"&";if(n.style!=="deepObject"&&n.explode===!1){for(const o in a)l.push(o,n.allowReserved===!0?a[o]:encodeURIComponent(a[o]));const s=l.join(",");switch(n.style){case"form":return`${t}=${s}`;case"label":return`.${s}`;case"matrix":return`;${t}=${s}`;default:return s}}for(const s in a){const o=n.style==="deepObject"?`${t}[${s}]`:s;l.push(Ot(o,a[s],n))}const r=l.join(i);return n.style==="label"||n.style==="matrix"?`${i}${r}`:r}function oi(t,a,n){if(!Array.isArray(a))return"";if(n.explode===!1){const r={form:",",spaceDelimited:"%20",pipeDelimited:"|"}[n.style]||",",s=(n.allowReserved===!0?a:a.map(o=>encodeURIComponent(o))).join(r);switch(n.style){case"simple":return s;case"label":return`.${s}`;case"matrix":return`;${t}=${s}`;default:return`${t}=${s}`}}const l={simple:",",label:".",matrix:";"}[n.style]||"&",i=[];for(const r of a)n.style==="simple"||n.style==="label"?i.push(n.allowReserved===!0?r:encodeURIComponent(r)):i.push(Ot(t,r,n));return n.style==="label"||n.style==="matrix"?`${l}${i.join(l)}`:i.join(l)}function Qn(t){return function(n){const l=[];if(n&&typeof n=="object")for(const i in n){const r=n[i];if(r!=null){if(Array.isArray(r)){if(r.length===0)continue;l.push(oi(i,r,{style:"form",explode:!0,...t?.array,allowReserved:t?.allowReserved||!1}));continue}if(typeof r=="object"){l.push(si(i,r,{style:"deepObject",explode:!0,...t?.object,allowReserved:t?.allowReserved||!1}));continue}l.push(Ot(i,r,t))}}return l.join("&")}}function Ur(t,a){let n=t;for(const l of t.match(Rr)??[]){let i=l.substring(1,l.length-1),r=!1,s="simple";if(i.endsWith("*")&&(r=!0,i=i.substring(0,i.length-1)),i.startsWith(".")?(s="label",i=i.substring(1)):i.startsWith(";")&&(s="matrix",i=i.substring(1)),!a||a[i]===void 0||a[i]===null)continue;const o=a[i];if(Array.isArray(o)){n=n.replace(l,oi(i,o,{style:s,explode:r}));continue}if(typeof o=="object"){n=n.replace(l,si(i,o,{style:s,explode:r}));continue}if(s==="matrix"){n=n.replace(l,`;${Ot(i,o)}`);continue}n=n.replace(l,s==="label"?`.${encodeURIComponent(o)}`:encodeURIComponent(o))}return n}function Wr(t,a){return t instanceof FormData?t:a&&(a.get instanceof Function?a.get("Content-Type")??a.get("content-type"):a["Content-Type"]??a["content-type"])==="application/x-www-form-urlencoded"?new URLSearchParams(t).toString():JSON.stringify(t)}function Mr(t,a){let n=`${a.baseUrl}${t}`;a.params?.path&&(n=a.pathSerializer(n,a.params.path));let l=a.querySerializer(a.params.query??{});return l.startsWith("?")&&(l=l.substring(1)),l&&(n+=`?${l}`),n}function Zn(...t){const a=new Headers;for(const n of t){if(!n||typeof n!="object")continue;const l=n instanceof Headers?n.entries():Object.entries(n);for(const[i,r]of l)if(r===null)a.delete(i);else if(Array.isArray(r))for(const s of r)a.append(i,s);else r!==void 0&&a.set(i,r)}return a}function el(t){return t.endsWith("/")?t.substring(0,t.length-1):t}class _ extends Error{constructor(a,n,l){super(`[${a}] ${n}: ${l}`),this.status=a,this.code=n,this.serverMessage=l,this.name="ApiError"}}async function $r(t,a){const n={"Content-Type":"application/json",...a?.headers};ha.value!==null&&(n["X-Master-Password"]=ha.value);let l;try{l=await fetch(t,{...a,headers:n,signal:AbortSignal.timeout(1e4)})}catch(i){const r=i;throw r.name==="AbortError"||r.name==="TimeoutError"?new _(0,"TIMEOUT","Request timed out"):new _(0,"NETWORK_ERROR","Cannot connect to daemon")}if(l.status===401)throw t.startsWith("/v1/admin/")&&Ga(),new _(401,"UNAUTHORIZED","Authentication failed");if(!l.ok){let i={};try{i=await l.json()}catch{}throw new _(l.status,i.code??"UNKNOWN",i.message??"Unknown error")}return Pt(),await l.json()}const Se=t=>$r(t,{method:"GET"}),Fr=typeof globalThis.location<"u"?globalThis.location.origin:"";function zr(t){const a=Or({baseUrl:Fr});a.use({onRequest({request:l}){return ha.value!==null&&l.headers.set("X-Master-Password",ha.value),l.headers.has("Content-Type")||l.headers.set("Content-Type","application/json"),l}});const n={async onResponse({request:l,response:i}){if(i.status===401)throw new URL(l.url).pathname.startsWith("/v1/admin/")&&Ga(),new _(401,"UNAUTHORIZED","Authentication failed");if(!i.ok){let r={};try{r=await i.clone().json()}catch{}throw new _(i.status,r.code??"UNKNOWN",r.message??"Unknown error")}Pt()},onError({error:l}){const i=l;return i.name==="AbortError"||i.name==="TimeoutError"?new _(0,"TIMEOUT","Request timed out"):new _(0,"NETWORK_ERROR","Cannot connect to daemon")}};return a.use(n),a}const R=zr(),Kr=new Set(["notifications.telegram_bot_token","notifications.discord_webhook_url","notifications.slack_webhook_url","telegram.bot_token"]);function Br(t){return Kr.has(t)}const mn=new Map,ci=new Map;let Ia=null,al=!1;function Hr(){return al?Promise.resolve():Ia||(Ia=(async()=>{try{const{data:t}=await R.GET("/v1/admin/settings/schema");if(t&&"settings"in t&&Array.isArray(t.settings)){for(const a of t.settings){ci.set(a.key,a.label);const n=a.key.lastIndexOf("."),l=n>=0?a.key.slice(n+1):a.key;mn.has(l)||mn.set(l,a.label)}al=!0}}catch{}finally{Ia=null}})(),Ia)}function ce(t){const a=ci.get(t);if(a)return a;const n=mn.get(t);return n||t.replace(/_/g," ").replace(/\b\w/g,l=>l.toUpperCase())}function pe(t,a,n,l){const i=`${n}.${l}`;if(a[i]!==void 0)return a[i];const r=t[n];if(!r)return"";const s=r[l];return typeof s=="boolean"?Br(i)?"":String(s):s??""}function We(t,a,n,l){const i=`${n}.${l}`;if(a[i]!==void 0)return a[i]==="true";const r=t[n];if(!r)return!1;const s=r[l];return typeof s=="boolean"?s:s==="true"}const Vr=new Set(["jupiter_swap_default_slippage_bps","jupiter_swap_max_slippage_bps","zerox_swap_default_slippage_bps","zerox_swap_max_slippage_bps","pendle_yield_default_slippage_bps","pendle_yield_max_slippage_bps","dcent_swap_default_slippage_bps","dcent_swap_max_slippage_bps"]);function tl(t){return Vr.has(t)}function Gr(t){const a=Number(t);return isNaN(a)||t===""?t:String(a/100)}function qr(t){const a=Number(t);return isNaN(a)||t===""?t:String(Math.round(a*100))}function Oa(t,a,n,l){const i=`${n}.${l}`;if(a[i]!==void 0)return!1;const r=t[n];return r?r[l]===!0:!1}function jr(t){const a=Math.floor(t/86400),n=Math.floor(t%86400/3600),l=Math.floor(t%3600/60);return a>0?`${a}d ${n}h ${l}m`:n>0?`${n}h ${l}m`:`${l}m`}function ve(t){const a=new Date(t*1e3),n=l=>l.toString().padStart(2,"0");return`${a.getFullYear()}-${n(a.getMonth()+1)}-${n(a.getDate())} ${n(a.getHours())}:${n(a.getMinutes())}`}function ta(t){return t?t.length<=10?t:`${t.slice(0,4)}..${t.slice(-4)}`:""}const Yr=new Set(["KRW","JPY","VND","CLP","HUF","PKR"]),Xr=new Set(["KWD","BHD"]);function Jr(t){return Yr.has(t)?0:Xr.has(t)?3:2}function Qr(t,a,n){const l=t*n,i=Jr(a),r=new Intl.NumberFormat("en-US",{style:"currency",currency:a,minimumFractionDigits:i,maximumFractionDigits:i}).format(l);return a==="USD"?r:`≈${r}`}let _a=null;const Zr=300*1e3;async function Nn(){if(_a&&Date.now()-_a.fetchedAt<Zr)return{currency:_a.currency,rate:_a.rate};try{const a=(await Se(Ha.ADMIN_SETTINGS)).display?.["display.currency"]??"USD";if(a==="USD")return _a={currency:"USD",rate:1,fetchedAt:Date.now()},{currency:"USD",rate:1};const i=(await Se(`${Ha.ADMIN_FOREX_RATES}?currencies=${a}`)).rates[a]?.rate??null;return _a={currency:a,rate:i,fetchedAt:Date.now()},{currency:a,rate:i}}catch{return{currency:"USD",rate:1}}}function Ea(t,a,n){return t==null?"":n==null?`$${t.toFixed(2)}`:Qr(t,a,n)}function Le({columns:t,data:a,onRowClick:n,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(r=>e("th",{style:r.width?{width:r.width}:void 0,children:r.header},r.key))})}),e("tbody",{children:i?e("tr",{children:e("td",{colSpan:t.length,class:"table-loading",children:"Loading..."})}):!a||a.length===0?e("tr",{children:e("td",{colSpan:t.length,class:"table-empty",children:l})}):a.map((r,s)=>e("tr",{class:n?"clickable":"",onClick:n?()=>n(r):void 0,children:t.map(o=>e("td",{children:o.render?o.render(r):r[o.key]},o.key))},s))})]})})}const An=["solana-mainnet","solana-devnet","solana-testnet"],qa=["ethereum-mainnet","ethereum-sepolia","polygon-mainnet","polygon-amoy","arbitrum-mainnet","arbitrum-sepolia","optimism-mainnet","optimism-sepolia","base-mainnet","base-sepolia","hyperevm-mainnet","hyperevm-testnet"],Et={"solana-mainnet":"Solana Mainnet","solana-devnet":"Solana Devnet","solana-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","hyperevm-mainnet":"HyperEVM Mainnet","hyperevm-testnet":"HyperEVM Testnet"},es={"solana-mainnet":"SOL","solana-devnet":"SOL","solana-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","hyperevm-mainnet":"HYPE","hyperevm-testnet":"HYPE"};qa.map(t=>`evm_${t.replace(/-/g,"_")}`);An.map(t=>t.replace(/-/g,"_"));Object.fromEntries([...An.map(t=>[t.replace(/-/g,"_"),Et[t]]),...qa.map(t=>[`evm_${t.replace(/-/g,"_")}`,Et[t]])]);const as={SPENDING_LIMIT:"Spending Limit",WHITELIST:"Whitelist",TIME_RESTRICTION:"Time Restriction",RATE_LIMIT:"Rate Limit",ALLOWED_TOKENS:"Allowed Tokens",CONTRACT_WHITELIST:"Contract Whitelist",METHOD_WHITELIST:"Method Whitelist",APPROVED_SPENDERS:"Approved Spenders",APPROVE_AMOUNT_LIMIT:"Approve Amount Limit",APPROVE_TIER_OVERRIDE:"Approve Tier Override",ALLOWED_NETWORKS:"Allowed Networks",X402_ALLOWED_DOMAINS:"x402 Allowed Domains",LENDING_LTV_LIMIT:"Lending LTV Limit",LENDING_ASSET_WHITELIST:"Lending Asset Whitelist",PERP_MAX_LEVERAGE:"Perp Max Leverage",PERP_MAX_POSITION_USD:"Perp Max Position USD",PERP_ALLOWED_MARKETS:"Perp Allowed Markets",REPUTATION_THRESHOLD:"Reputation Threshold",ERC8128_ALLOWED_DOMAINS:"ERC-8128 Allowed Domains",VENUE_WHITELIST:"Venue Whitelist",ACTION_CATEGORY_LIMIT:"Action Category Limit"},ts={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.",LENDING_LTV_LIMIT:"Set maximum loan-to-value ratio for lending operations.",LENDING_ASSET_WHITELIST:"Allow lending operations only for pre-approved assets.",PERP_MAX_LEVERAGE:"Set maximum allowed leverage for perpetual futures positions.",PERP_MAX_POSITION_USD:"Set maximum position size in USD for perpetual futures.",PERP_ALLOWED_MARKETS:"Allow perpetual futures trading only on pre-approved markets.",REPUTATION_THRESHOLD:"Adjust security tier based on counterparty agent on-chain reputation score (ERC-8004).",ERC8128_ALLOWED_DOMAINS:"Allow ERC-8128 HTTP message signing only for pre-approved API domains.",VENUE_WHITELIST:"Allow external actions only from pre-approved venues (default-deny when enabled).",ACTION_CATEGORY_LIMIT:"Set per-action, daily, and monthly USD limits per action category with tier escalation."},ns={"api-key":"API Key","hmac-secret":"HMAC Secret","rsa-private-key":"RSA Private Key","session-token":"Session Token",custom:"Custom"},ls={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.",WALLET_NOT_TERMINATED:"Wallet must be terminated before purging.",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."},is=["ACTION_VALIDATION_FAILED","CONSTRAINT_VIOLATED","INVALID_ADDRESS","INVALID_SIGNATURE"],rs=new Set(is);function G(t,a){return a&&rs.has(t)?a:ls[t]??`An error occurred (${t}).`}const na=we([]);let ss=0;function y(t,a){const n=ss++;na.value=[...na.value,{id:n,type:t,message:a}],setTimeout(()=>{na.value=na.value.filter(l=>l.id!==n)},5e3)}function os(t){na.value=na.value.filter(a=>a.id!==t)}function cs(){return na.value.length===0?null:e("div",{class:"toast-container",children:na.value.map(t=>e("div",{class:`toast toast-${t.type}`,onClick:()=>os(t.id),children:t.message},t.id))})}const ds={"solana-mainnet":"https://solscan.io/tx/{txHash}","solana-devnet":"https://solscan.io/tx/{txHash}?cluster=devnet","solana-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 us(t,a){const n=ds[t];return n?n.replace("{txHash}",a):null}function vs(t){return t.length<=16?t:t.slice(0,8)+"..."+t.slice(-6)}function Cn({network:t,txHash:a,label:n}){if(!a)return null;const l=us(t,a),i=n??vs(a);return l?e("a",{href:l,target:"_blank",rel:"noopener noreferrer",class:"explorer-link",children:i}):e("span",{class:"explorer-link-text",children:i})}const Ut=1e4,di=3e4;function hs(t){if(t===0)return"0 B";const a=["B","KB","MB","GB"],n=1024,l=Math.min(Math.floor(Math.log(t)/Math.log(n)),a.length-1);return`${(t/Math.pow(n,l)).toFixed(l===0?0:1)} ${a[l]}`}const ps=["ALL","STAKING","LENDING","YIELD","PERP"];function Te({label:t,value:a,loading:n,badge:l,href:i}){const r=e(le,{children:[e("div",{class:"stat-label",children:[t,i&&e("span",{class:"stat-link-arrow",children:" →"})]}),n?e("div",{class:"stat-skeleton"}):l?e(Y,{variant:l,children:a}):e("div",{class:"stat-value",children:a})]});return i?e("a",{href:i,class:"stat-card stat-card-link",style:{textDecoration:"none",color:"inherit",cursor:"pointer"},children:r}):e("div",{class:"stat-card",children:r})}function ms(t,a){return[{key:"createdAt",header:"Time",render:n=>n.createdAt?ve(n.createdAt):"—"},{key:"walletName",header:"Wallet",render:n=>n.walletName??n.walletId.slice(0,8)},{key:"type",header:"Type"},{key:"amount",header:"Amount",render:n=>{if(!n.amount)return"—";const l=n.formattedAmount??n.amount,i=Ea(n.amountUsd,t,a);return i?`${l} (${i})`:l}},{key:"network",header:"Network",render:n=>n.network??"—"},{key:"status",header:"Status",render:n=>{const l=n.status==="CONFIRMED"?"success":n.status==="FAILED"?"danger":"warning";return e(Y,{variant:l,children:n.status})}},{key:"txHash",header:"Tx Hash",render:n=>e(Cn,{network:n.network??"",txHash:n.txHash})}]}function Re(t){return t.metadata&&typeof t.metadata=="object"?t.metadata:{}}const fs={lido:"Lido",jito:"Jito","aave-v3":"Aave V3",aave_v3:"Aave V3",pendle:"Pendle","hyperliquid-perp":"Hyperliquid Perp","hyperliquid-spot":"Hyperliquid Spot",kamino:"Kamino",drift:"Drift"};function ys(t){return fs[t]??t}function gs(t){const a=new Map;for(const n of t){const l=n.provider;a.has(l)||a.set(l,[]),a.get(l).push(n)}return a}function _s(t,a,n){const l=[];return n&&l.push({key:"category",header:"Category",render:i=>e(Y,{variant:"info",children:i.category})}),l.push({key:"chain",header:"Chain",render:i=>e(Y,{variant:"info",children:i.chain})},{key:"amount",header:"Amount"},{key:"amountUsd",header:"USD Value",render:i=>i.amountUsd===null?"—":Ea(i.amountUsd,t,a)??`$${i.amountUsd.toFixed(2)}`}),l}function bs(t){switch(t){case"STAKING":return[{key:"provider",header:"Protocol",render:a=>String(Re(a).protocol??a.provider)},{key:"metadata",header:"Exchange Rate",render:a=>{const n=Re(a).exchangeRate;return typeof n=="number"?n.toFixed(4):"—"}}];case"LENDING":return[{key:"metadata",header:"Type",render:a=>{const n=String(Re(a).positionType??"");return n?e(Y,{variant:n==="SUPPLY"?"success":"warning",children:n}):"—"}},{key:"provider",header:"Health Factor",render:a=>{const n=Re(a).healthFactor;if(typeof n!="number")return"—";const l=n<1.2?"danger":n<1.5?"warning":"success";return e(Y,{variant:l,children:n.toFixed(2)})}},{key:"status",header:"APY",render:a=>{const n=Re(a).apy;return typeof n=="number"?`${(n*100).toFixed(2)}%`:"—"}}];case"YIELD":return[{key:"metadata",header:"Token",render:a=>{const n=String(Re(a).tokenType??"");return n?e(Y,{variant:n==="PT"?"info":"warning",children:n}):"—"}},{key:"provider",header:"Maturity",render:a=>{const n=Re(a).maturity;if(typeof n!="number")return"—";const l=n*1e3<Date.now(),i=new Date(n*1e3).toLocaleDateString();return l?e(Y,{variant:"danger",children:["MATURED (",i,")"]}):i}},{key:"status",header:"Implied APY",render:a=>{const n=Re(a).impliedApy;return typeof n=="number"?`${(n*100).toFixed(2)}%`:"—"}}];case"PERP":return[{key:"metadata",header:"Market",render:a=>String(Re(a).market??"—")},{key:"provider",header:"Side",render:a=>{const n=String(Re(a).side??"");return n?e(Y,{variant:n==="LONG"?"success":"danger",children:n}):"—"}},{key:"status",header:"PnL",render:a=>{const n=Re(a).unrealizedPnl;if(n==null)return"—";const l=Number(n);if(isNaN(l))return String(n);const i=l>=0?"pnl-positive":"pnl-negative";return e("span",{class:i,children:[l>=0?"+":"",l.toFixed(2)]})}},{key:"walletId",header:"Liq. Price",render:a=>String(Re(a).liquidationPrice??"—")}];default:return[{key:"provider",header:"Provider"}]}}async function ws(t){try{await navigator.clipboard.writeText(t)}catch{const a=document.createElement("textarea");a.value=t,a.style.position="fixed",a.style.left="-9999px",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a)}}function Ts(){const t=c(null),a=c(!0),n=c(null),l=c("USD"),i=c(1),r=c(!1),s=c(null),o=c(null),u=c(null),d=c(!0),v=c("ALL"),h=c(""),m=c(typeof localStorage<"u"&&localStorage.getItem("defi-include-testnets")==="true"),b=c([]),U=c(null),W=c(!0),p=async()=>{try{const{data:S}=await R.GET("/v1/admin/stats");U.value=S}catch{}finally{W.value=!1}},T=async()=>{d.value=!0;try{const S={};h.value&&(S.wallet_id=h.value),v.value!=="ALL"&&(S.category=v.value),m.value&&(S.includeTestnets="true");const{data:C}=await R.GET("/v1/admin/defi/positions",{params:{query:S}});u.value=C}catch{}finally{d.value=!1}},D=async()=>{a.value=!0,n.value=null;try{const{data:S}=await R.GET("/v1/admin/status");t.value=S}catch(S){S instanceof _?n.value=G(S.code):n.value="An unexpected error occurred."}finally{a.value=!1}},M=async()=>{r.value=!0;try{const{data:S}=await R.POST("/v1/admin/agent-prompt",{body:{}});if(S.walletCount===0){y("warning","No active wallets found");return}s.value=S.prompt,y("success",`Prompt generated for ${S.walletCount} wallet(s)`)}catch(S){S instanceof _?y("error",G(S.code)):y("error","Failed to generate agent prompt")}finally{r.value=!1}},O=async()=>{s.value&&(await ws(s.value),y("success","Copied to clipboard!"))};X(()=>{D(),T(),p(),Nn().then(({currency:C,rate:N})=>{l.value=C,i.value=N}).catch(()=>{}),R.GET("/v1/admin/transactions",{params:{query:{status:"APPROVED",limit:1}}}).then(({data:C})=>{o.value=C.total}).catch(()=>{}),R.GET("/v1/wallets").then(({data:C})=>{const N=C.items;b.value=N.map(k=>({id:k.id,name:k.name??k.id.slice(0,8)}))}).catch(()=>{});const S=setInterval(()=>{D(),T(),p()},di);return()=>clearInterval(S)},[]),X(()=>{T()},[v.value,h.value,m.value]);const q=a.value&&!t.value;return e("div",{class:"page",children:[n.value&&e("div",{class:"dashboard-error",children:[e("span",{children:n.value}),e(x,{variant:"secondary",size:"sm",onClick:D,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."]})]}),t.value?.autoProvisioned&&e("div",{class:"auto-provision-banner",role:"alert",children:[e("span",{class:"auto-provision-banner-icon",children:"⚠"}),e("span",{children:[e("strong",{children:"Auto-provision mode active."})," ","Change the master password for security."," ",e("a",{href:"#/security?tab=password",class:"auto-provision-link",children:"Go to Security"})]})]}),e("div",{class:"stat-grid",children:[e(Te,{label:"Version",value:t.value?.version??"—",loading:q,badge:t.value&&t.value.updateAvailable?"warning":void 0}),e(Te,{label:"Uptime",value:t.value?jr(t.value.uptime):"—",loading:q}),e(Te,{label:"Wallets",value:t.value?.walletCount?.toString()??"—",loading:q,href:"#/wallets"}),e(Te,{label:"Active Sessions",value:t.value?.activeSessionCount?.toString()??"—",loading:q,href:"#/sessions"})]}),e("div",{class:"stat-grid",style:{marginTop:"var(--space-4)"},children:[e(Te,{label:"Kill Switch",value:t.value?.killSwitchState==="ACTIVATED"?"ACTIVATED":"NORMAL",loading:q,badge:t.value?t.value.killSwitchState==="ACTIVATED"?"danger":"success":void 0}),e(Te,{label:"Status",value:t.value?.status??"—",loading:q})]}),e("div",{class:"stat-grid",style:{marginTop:"var(--space-4)"},children:[e(Te,{label:"Policies",value:t.value?.policyCount?.toString()??"—",loading:q,href:"#/policies"}),e(Te,{label:"Recent Txns (24h)",value:t.value?.recentTxCount?.toString()??"—",loading:q,href:"#/transactions"}),e(Te,{label:"Failed Txns (24h)",value:t.value?.failedTxCount?.toString()??"—",loading:q,badge:t.value?t.value.failedTxCount===0?"success":"danger":void 0,href:"#/transactions?status=FAILED"}),e(Te,{label:"Approval Pending",value:o.value?.toString()??"—",loading:q,badge:o.value!=null&&o.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."}),s.value?e(le,{children:[e("pre",{class:"prompt-preview",children:s.value}),e("div",{style:{display:"flex",gap:"var(--space-2)",marginTop:"var(--space-3)"},children:[e(x,{variant:"primary",size:"sm",onClick:O,children:"Copy to Clipboard"}),e(x,{variant:"secondary",size:"sm",onClick:M,loading:r.value,children:"Regenerate"})]})]}):e(x,{variant:"primary",size:"sm",onClick:M,loading:r.value,style:{marginTop:"var(--space-2)"},children:"Generate"})]}),u.value&&u.value.worstHealthFactor!==null&&u.value.worstHealthFactor<1.5&&e("div",{class:"hf-warning-banner",role:"alert",style:{marginTop:"var(--space-4)"},children:[e("span",{class:"hf-warning-icon",children:"⚠"}),e("span",{children:[e("strong",{children:"Health Factor Warning:"})," ","Worst Health Factor is ",e("strong",{children:u.value.worstHealthFactor.toFixed(2)}),u.value.worstHealthFactor<1.2?" — Liquidation risk is HIGH!":" — Monitor closely."]})]}),u.value&&e("div",{style:{marginTop:"var(--space-4)"},children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"DeFi Positions"}),e("div",{class:"defi-filter-row",children:[e("div",{class:"defi-category-tabs",children:ps.map(S=>e("button",{class:v.value===S?"active":"",onClick:()=>{v.value=S},children:S},S))}),e("select",{class:"defi-wallet-select",value:h.value,onChange:S=>{h.value=S.target.value},children:[e("option",{value:"",children:"All Wallets"}),b.value.map(S=>e("option",{value:S.id,children:S.name},S.id))]}),e("label",{class:"defi-testnet-toggle",style:{display:"flex",alignItems:"center",gap:"var(--space-1)",cursor:"pointer",fontSize:"var(--font-sm)"},children:[e("input",{type:"checkbox",checked:m.value,onChange:S=>{const C=S.target.checked;m.value=C,localStorage.setItem("defi-include-testnets",String(C))}}),"Include testnets"]})]}),e("div",{class:"stat-grid",children:[e(Te,{label:"Total DeFi Value",value:u.value.totalValueUsd!==null?Ea(u.value.totalValueUsd,l.value,i.value)??`$${u.value.totalValueUsd.toFixed(2)}`:"—",loading:d.value}),e(Te,{label:"Health Factor",value:u.value.worstHealthFactor!==null?u.value.worstHealthFactor.toFixed(2):"N/A",loading:d.value,badge:u.value.worstHealthFactor!==null?u.value.worstHealthFactor<1.2?"danger":u.value.worstHealthFactor<1.5?"warning":"success":void 0}),e(Te,{label:"Active Positions",value:u.value.activeCount.toString(),loading:d.value})]}),e("div",{style:{marginTop:"var(--space-3)"},children:[Array.from(gs(u.value.positions)).map(([S,C])=>e("div",{class:"defi-provider-group",children:[e("h4",{class:"defi-provider-header",children:ys(S)}),e(Le,{columns:[..._s(l.value,i.value,v.value==="ALL"),...bs(v.value==="ALL"?"":v.value)],data:C,emptyMessage:"No positions"})]},S)),u.value.positions.length===0&&e("p",{style:{color:"var(--color-text-muted)",textAlign:"center",padding:"var(--space-4)"},children:"No active DeFi positions"})]})]}),e("div",{style:{marginTop:"var(--space-4)"},children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"Recent Activity"}),e(Le,{columns:ms(l.value,i.value),data:t.value?.recentTransactions??[],loading:q,emptyMessage:"No recent transactions"})]}),U.value&&e(le,{children:[U.value.rpc.byNetwork.length>0&&e("div",{style:{marginTop:"var(--space-4)"},children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"RPC Network Status"}),e(Le,{columns:[{key:"network",header:"Network"},{key:"calls",header:"Total Calls"},{key:"errors",header:"Errors"},{key:"avgLatencyMs",header:"Avg Latency (ms)",render:S=>S.avgLatencyMs.toFixed(1)}],data:U.value.rpc.byNetwork,emptyMessage:"No RPC data available"})]}),e("div",{style:{marginTop:"var(--space-4)"},children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"AutoStop Rules"}),e(Le,{columns:[{key:"id",header:"Rule"},{key:"displayName",header:"Name"},{key:"enabled",header:"Status",render:S=>e(Y,{variant:S.enabled?"success":"danger",children:S.enabled?"Enabled":"Disabled"})},{key:"trackedCount",header:"Tracked"}],data:U.value.autostop.rules,emptyMessage:"No rules configured"})]}),e("div",{class:"stat-grid",style:{marginTop:"var(--space-4)"},children:[e(Te,{label:"Notifications Sent (24h)",value:String(U.value.notifications.sentLast24h)}),e(Te,{label:"Failed Notifications (24h)",value:String(U.value.notifications.failedLast24h),badge:U.value.notifications.failedLast24h>0?"danger":void 0})]}),e("div",{class:"stat-grid",style:{marginTop:"var(--space-4)"},children:[e(Te,{label:"DB Size",value:hs(U.value.system.dbSizeBytes)}),e(Te,{label:"Schema Version",value:`v${U.value.system.schemaVersion}`}),e(Te,{label:"Node.js",value:U.value.system.nodeVersion}),e(Te,{label:"Platform",value:U.value.system.platform})]})]})]})}function he({open:t,title:a,children:n,onConfirm:l,onCancel:i,confirmText:r="Confirm",cancelText:s="Cancel",confirmVariant:o="primary",confirmDisabled:u=!1,loading:d=!1}){return X(()=>{if(!t)return;const v=h=>{h.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:a}),e("div",{class:"modal-body",children:n}),e("div",{class:"modal-footer",children:[e(x,{variant:"secondary",onClick:i,disabled:d,children:s}),l&&e(x,{variant:o,onClick:l,loading:d,disabled:u,children:r})]})]})}):null}function Ge({value:t,label:a}){const n=c(!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)}n.value=!0,setTimeout(()=>{n.value=!1},2e3)},children:n.value?"Copied!":a??"Copy"})}function Ue({title:t,description:a,actionLabel:n,onAction:l}){return e("div",{class:"empty-state",children:[e("h3",{children:t}),a&&e("p",{children:a}),n&&l&&e("button",{class:"btn btn-primary",onClick:l,children:n})]})}function Oe({tabs:t,activeTab:a,onTabChange:n}){return e("div",{class:"tab-nav",children:t.map(l=>e("button",{class:`tab-btn ${a===l.key?"active":""}`,onClick:()=>{l.key!==a&&(ii.value?ri({type:"tab",execute:()=>n(l.key)}):n(l.key))},children:l.label},l.key))})}function fa({pageName:t,tabName:a,onPageClick:n}){return a?e("nav",{class:"breadcrumb","aria-label":"Breadcrumb",children:[e("button",{class:"breadcrumb-page",onClick:n,type:"button",children:t}),e("span",{class:"breadcrumb-separator","aria-hidden":"true",children:">"}),e("span",{class:"breadcrumb-current","aria-current":"page",children:a})]}):null}function ui({value:t,onSearch:a,placeholder:n="Search...",debounceMs:l=300}){const i=qe(null);function r(o){const u=o.target.value;i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>{a(u),i.current=null},l)}function s(){i.current!==null&&(clearTimeout(i.current),i.current=null),a("")}return e("div",{class:"search-input",children:[e("input",{type:"text",value:t,placeholder:n,onInput:r}),t&&e("button",{class:"search-clear",type:"button",onClick:s,children:"x"})]})}function Ss(){const t=window.location.hash,a=t.indexOf("?");if(a===-1)return{};const n=new URLSearchParams(t.slice(a+1)),l={};return n.forEach((i,r)=>{l[r]=i}),l}function nl(t){const a=window.location.hash,n=a.indexOf("?"),l=n===-1?a:a.slice(0,n),i=new URLSearchParams;for(const[o,u]of Object.entries(t))u&&i.set(o,u);const r=i.toString(),s=r?`${l}?${r}`:l;window.history.replaceState(null,"",s)}function ja({fields:t,values:a,onChange:n,syncUrl:l=!0}){X(()=>{if(!l)return;const s=Ss(),o={...a};let u=!1;for(const d of t){const v=s[d.key];v!==void 0&&v!==o[d.key]&&(o[d.key]=v,u=!0)}u&&n(o)},[]);function i(s,o){const u={...a,[s]:o};n(u),l&&nl(u)}function r(){const s={};for(const o of t)s[o.key]="";n(s),l&&nl(s)}return e("div",{class:"filter-bar",children:[t.map(s=>e("div",{class:"filter-field",children:[e("label",{children:s.label}),s.type==="select"?e("select",{value:a[s.key]??"",onChange:o=>i(s.key,o.target.value),children:[e("option",{value:"",children:"All"}),s.options?.map(o=>e("option",{value:o.value,children:o.label},o.value))]}):e("input",{type:"date",value:a[s.key]??"",placeholder:s.placeholder,onChange:o=>i(s.key,o.target.value)})]},s.key)),e("button",{class:"btn btn-secondary filter-clear",type:"button",onClick:r,children:"Clear"})]})}const ks=qa,jt=["Symbol","Name","Address","Decimals","Source","Actions"];function Es(t){return t.length<=10?t:`${t.slice(0,6)}...${t.slice(-4)}`}function Ns(){const t=c("ethereum-mainnet"),a=c([]),n=c(!0),l=c(null),i=c(!1),r=c(""),s=c(""),o=c(""),u=c("18"),d=c(!1),v=c(!1),h=c(null),m=qe(null),b=async()=>{n.value=!0,l.value=null;try{const{data:O}=await R.GET("/v1/tokens",{params:{query:{network:t.value}}});a.value=O.tokens}catch(O){O instanceof _?l.value=G(O.code):l.value="An unexpected error occurred.",a.value=[]}finally{n.value=!1}};X(()=>{b()},[t.value]);function U(O){t.value=O.target.value}function W(){r.value="",s.value="",o.value="",u.value="18",v.value=!1,i.value=!1,m.current&&clearTimeout(m.current)}async function p(O){v.value=!0;try{const{data:q}=await R.GET("/v1/tokens/resolve",{params:{query:{network:t.value,address:O}}});s.value=q.symbol,o.value=q.name,u.value=String(q.decimals),y("success",`Resolved: ${q.symbol} (${q.name})`)}catch{}finally{v.value=!1}}function T(O){const q=O.target.value;r.value=q,m.current&&clearTimeout(m.current),/^0x[a-fA-F0-9]{40}$/.test(q)&&(m.current=setTimeout(()=>p(q),500))}async function D(){if(!r.value||!s.value||!o.value){y("error","Please fill in all required fields.");return}d.value=!0;try{await R.POST("/v1/tokens",{body:{network:t.value,address:r.value,symbol:s.value,name:o.value,decimals:Number(u.value)}}),y("success",`Token ${s.value} added successfully.`),W(),await b()}catch(O){O instanceof _?y("error",G(O.code)):y("error","Failed to add token.")}finally{d.value=!1}}async function M(O){h.value=O;try{await R.DELETE("/v1/tokens",{body:{network:t.value,address:O}}),y("success","Token removed successfully."),await b()}catch(q){q instanceof _?y("error",G(q.code)):y("error","Failed to remove token.")}finally{h.value=null}}return e(le,{children:[l.value&&e("div",{class:"dashboard-error",children:[e("span",{children:l.value}),e(x,{variant:"secondary",size:"sm",onClick:b,children:"Retry"})]}),e("div",{class:"filter-bar",children:[e("div",{class:"filter-field",children:[e("label",{children:"Network"}),e("select",{value:t.value,onChange:U,children:ks.map(O=>e("option",{value:O,children:Et[O]??O},O))})]}),e("div",{style:{marginLeft:"auto"},children:e(x,{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:r.value,onInput:T,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:s.value,onInput:O=>{s.value=O.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:o.value,onInput:O=>{o.value=O.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:u.value,onInput:O=>{u.value=O.target.value},placeholder:"18"})]})]}),e("div",{style:{marginTop:"var(--space-3)",display:"flex",gap:"var(--space-2)"},children:[e(x,{variant:"primary",size:"sm",loading:d.value,onClick:D,children:"Submit"}),e(x,{variant:"secondary",size:"sm",onClick:W,children:"Cancel"})]})]}),e("div",{class:"table-container",style:{marginTop:"var(--space-3)"},children:e("table",{children:[e("thead",{children:e("tr",{children:jt.map(O=>e("th",{children:O},O))})}),e("tbody",{children:n.value&&a.value.length===0?e("tr",{children:e("td",{colSpan:jt.length,class:"table-loading",children:"Loading..."})}):a.value.length===0?e("tr",{children:e("td",{colSpan:jt.length,class:"table-empty",children:"No tokens found for this network"})}):a.value.map(O=>e("tr",{children:[e("td",{children:O.symbol}),e("td",{children:O.name}),e("td",{title:O.address,children:Es(O.address)}),e("td",{children:O.decimals}),e("td",{children:e(Y,{variant:O.source==="builtin"?"neutral":"info",children:O.source==="builtin"?"Built-in":"Custom"})}),e("td",{children:O.source==="custom"?e(x,{variant:"danger",size:"sm",loading:h.value===O.address,onClick:()=>M(O.address),children:"Delete"}):"—"})]},O.address))})]})})]})}const vi="0x5d82735936c6Cd5DE57cC3c1A799f6B2E6F933Df",Ke=[{value:"dcent",label:"D'CENT Wallet",description:"D'CENT hardware wallet with push notification signing"}],ut={dcent:"Wallet App (Push)"},Yt={dcent:"sdk_push"},Nt=[{value:"none",label:"None (Lite mode)"},{value:"pimlico",label:"Pimlico"},{value:"alchemy",label:"Alchemy"},{value:"custom",label:"Custom"}],At={pimlico:"https://dashboard.pimlico.io",alchemy:"https://dashboard.alchemy.com"};function fn(t){switch(t){case"NONE":return"neutral";case"GRACE":return"warning";case"LOCKED":return"success";default:return"neutral"}}function ie({label:t,value:a,copy:n,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??a??"—",n&&a&&e(Ge,{value:a})]})]})}const Xt=[{value:null,label:"Auto (Global Fallback)",description:"System decides based on configured channels: Wallet App (Push) > Wallet App (Telegram) > WalletConnect > Telegram Bot > REST"},{value:"sdk_push",label:"Wallet App (Push)",description:"Push sign request to wallet app via Push Relay server",warning:"Signing SDK is not enabled. Go to Wallets > Human Wallet Apps 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 Wallets > Human Wallet Apps and Notifications > Settings > Telegram.",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)"}],As=[{key:"overview",label:"Overview"},{key:"activity",label:"Activity"},{key:"assets",label:"Assets"},{key:"setup",label:"Setup"}],xa=20,Cs=[{value:"PENDING",label:"PENDING"},{value:"APPROVED",label:"APPROVED"},{value:"SUBMITTED",label:"SUBMITTED"},{value:"CONFIRMED",label:"CONFIRMED"},{value:"FAILED",label:"FAILED"}],Is=[{value:"TRANSFER",label:"TRANSFER"},{value:"TOKEN_TRANSFER",label:"TOKEN_TRANSFER"},{value:"CONTRACT_CALL",label:"CONTRACT_CALL"},{value:"APPROVE",label:"APPROVE"},{value:"BATCH",label:"BATCH"},{value:"NFT_TRANSFER",label:"NFT_TRANSFER"}],xs=[{key:"status",label:"Status",type:"select",options:Cs},{key:"type",label:"Type",type:"select",options:Is}],Jt=["Time","Type","To","Amount","Network","Status","Tx Hash"];function Ds(t){return t==="CONFIRMED"?"success":t==="FAILED"?"danger":"warning"}function Rs({id:t}){const a=c(null),n=c(!0),l=c(!1),i=c(""),r=c(!1),s=c(!1),o=c(!1),u=c(!1),d=c(!1),v=c(!1),h=c(null),m=c([]),b=c(!0),U=c(null),W=c(!0),p=c([]),T=c(!0),D=c(0),M=c(0),O=c({status:"",type:""}),q=c(!1),S=c(null),C=c(!1),N=c(null),k=c(!0),V=c(!1),w=c(null),H=c(!1),Z=c(""),A=c(!1),B=c(""),I=c(!1),g=c(null),F=c(!1),j=c(!1),J=c(""),L=c(!1),Q=c("overview"),re=c(!1),ee=c("transactions"),_e=c("USD"),K=c(1),oe=c([]),Ee=c(!0),Ce=c([]),$e=c(!1),P=c(null),z=c("grid"),ae=c(null),fe=c(!1),ye=c(""),De=c(null),se=c(!1),je=c(!1),Ne=c("pimlico"),Ya=c(""),Xa=c(""),Ja=c(""),Qa=c(""),Wt=c(!1),Ye=async()=>{try{const{data:f}=await R.GET("/v1/wallets/{id}",{params:{path:{id:t}}});a.value=f??null}catch(f){const $=f instanceof _?f:new _(0,"UNKNOWN","Unknown error");y("error",G($.code))}finally{n.value=!1}},mi=async()=>{r.value=!0;try{await R.PUT("/v1/wallets/{id}",{params:{path:{id:t}},body:{name:i.value}}),await Ye(),l.value=!1,y("success","Wallet name updated")}catch(f){const $=f instanceof _?f:new _(0,"UNKNOWN","Unknown error");y("error",G($.code))}finally{r.value=!1}},fi=async()=>{o.value=!0;try{await R.DELETE("/v1/wallets/{id}",{params:{path:{id:t}}}),y("success","Wallet terminated"),window.location.hash="#/wallets"}catch(f){const $=f instanceof _?f:new _(0,"UNKNOWN","Unknown error");y("error",G($.code))}finally{o.value=!1}},yi=async()=>{d.value=!0;try{await R.DELETE("/v1/wallets/{id}/purge",{params:{path:{id:t}}}),y("success","Wallet permanently deleted"),window.location.hash="#/wallets"}catch(f){const $=f instanceof _?f:new _(0,"UNKNOWN","Unknown error");y("error",G($.code))}finally{d.value=!1}},gi=async()=>{j.value=!0;try{await R.POST("/v1/wallets/{id}/suspend",{params:{path:{id:t}},body:{reason:J.value.trim()||void 0}}),y("success","Wallet suspended"),F.value=!1,J.value="",await Ye()}catch(f){const $=f instanceof _?f:new _(0,"UNKNOWN","Unknown error");y("error",G($.code))}finally{j.value=!1}},_i=async()=>{L.value=!0;try{await R.POST("/v1/wallets/{id}/resume",{params:{path:{id:t}}}),y("success","Wallet resumed"),await Ye()}catch(f){const $=f instanceof _?f:new _(0,"UNKNOWN","Unknown error");y("error",G($.code))}finally{L.value=!1}},bi=async()=>{Wt.value=!0;try{const f=Ne.value==="custom"?{provider:"custom",bundlerUrl:Xa.value,paymasterUrl:Ja.value||void 0}:{provider:Ne.value,apiKey:Ya.value||void 0,policyId:Qa.value||void 0};await R.PUT("/v1/wallets/{id}/provider",{params:{path:{id:t}},body:f}),y("success","Provider updated"),je.value=!1,Ya.value="",Xa.value="",Ja.value="",Qa.value="",await Ye()}catch(f){const $=f instanceof _?f:new _(0,"UNKNOWN","Unknown error");y("error",G($.code))}finally{Wt.value=!1}},wi=()=>{a.value?.provider&&(Ne.value=a.value.provider.name),je.value=!0},Ti=()=>{i.value=a.value.name,l.value=!0},Si=()=>{l.value=!1},In=async()=>{v.value=!0;try{const{data:f}=await R.POST("/v1/mcp/tokens",{body:{walletId:t}});h.value=f??null,y("success","MCP token provisioned successfully")}catch(f){const $=f instanceof _?f:new _(0,"UNKNOWN","Unknown error");y("error",G($.code))}finally{v.value=!1}},ki=async()=>{b.value=!0;try{const{data:f}=await R.GET("/v1/wallets/{id}/networks",{params:{path:{id:t}}});m.value=f?.availableNetworks??[]}catch(f){const $=f instanceof _?f:new _(0,"UNKNOWN","Unknown error");y("error",G($.code)),m.value=[]}finally{b.value=!1}},xn=async()=>{W.value=!0;try{const{data:f}=await R.GET("/v1/admin/wallets/{id}/balance",{params:{path:{id:t}}});U.value=f??null}catch{U.value=null}finally{W.value=!1}},Dn=async f=>{T.value=!0;try{const te=(f??M.value)*xa,{data:ne}=await R.GET("/v1/admin/wallets/{id}/transactions",{params:{path:{id:t},query:{offset:te,limit:xa}}});p.value=ne?.items??[],D.value=ne?.total??0}catch{p.value=[],D.value=0}finally{T.value=!1}},Mt=Lt(()=>{let f=p.value;const $=O.value;return $.status&&(f=f.filter(te=>te.status===$.status)),$.type&&(f=f.filter(te=>te.type===$.type)),f}),Rn=async()=>{Ee.value=!0;try{const{data:f}=await R.GET("/v1/admin/wallets/{id}/staking",{params:{path:{id:t}}});oe.value=f?.positions??[]}catch{oe.value=[]}finally{Ee.value=!1}},Za=async(f,$)=>{const te=f??ye.value;if(te){$e.value=!0,P.value=null;try{const{data:ne}=await R.GET("/v1/wallets/{id}/nfts",{params:{path:{id:t},query:{network:te,pageSize:20,...$?{pageKey:$}:{}}}}),Ae=ne?.items??[],ot=ne?.pageKey;$?Ce.value=[...Ce.value,...Ae]:Ce.value=Ae,De.value=ot??null,se.value=!!ot}catch(ne){ne instanceof _&&ne.code==="INDEXER_NOT_CONFIGURED"?P.value="INDEXER_NOT_CONFIGURED":P.value="FETCH_ERROR",Ce.value=[]}finally{$e.value=!1}}},Ln=async f=>{if(ye.value){fe.value=!0;try{const{data:$}=await R.GET("/v1/wallets/{id}/nfts/{tokenIdentifier}",{params:{path:{id:t,tokenIdentifier:f},query:{network:ye.value}}});ae.value=$??null}catch{}finally{fe.value=!1}}},Ei=async()=>{k.value=!0;try{const{data:f}=await R.GET("/v1/wallets/{id}/wc/session",{params:{path:{id:t}}});N.value=f??null}catch{N.value=null}finally{k.value=!1}},Ni=()=>{w.value&&clearInterval(w.value),w.value=setInterval(async()=>{try{const{data:f}=await R.GET("/v1/wallets/{id}/wc/pair/status",{params:{path:{id:t}}});if(!f)return;f.status==="connected"?(w.value&&clearInterval(w.value),w.value=null,q.value=!1,S.value=null,N.value=f.session??null,y("success","Wallet connected via WalletConnect")):(f.status==="expired"||f.status==="none")&&(w.value&&clearInterval(w.value),w.value=null,q.value=!1,S.value=null,y("error","Pairing expired. Try again."))}catch{}},3e3)},Ai=async()=>{C.value=!0;try{const{data:f}=await R.POST("/v1/wallets/{id}/wc/pair",{params:{path:{id:t}}});S.value=f??null,q.value=!0,Ni()}catch(f){const $=f instanceof _?f:new _(0,"UNKNOWN","Unknown error");$.code==="WC_NOT_CONFIGURED"?(y("error","WalletConnect is not configured. Redirecting to settings..."),me.value={tab:"walletconnect",fieldName:"walletconnect.project_id"},window.location.hash="#/wallets"):y("error",G($.code))}finally{C.value=!1}},Ci=async()=>{V.value=!0;try{await R.DELETE("/v1/wallets/{id}/wc/session",{params:{path:{id:t}}}),N.value=null,y("success","WalletConnect session disconnected")}catch(f){const $=f instanceof _?f:new _(0,"UNKNOWN","Unknown error");y("error",G($.code))}finally{V.value=!1}},Pn=()=>{Z.value=a.value?.ownerAddress??"",B.value=a.value?.walletType??"",H.value=!0},Ii=()=>{H.value=!1},xi=async()=>{if(!Z.value.trim()){y("error","Owner address is required");return}A.value=!0;try{await R.PUT("/v1/wallets/{id}/owner",{params:{path:{id:t}},body:{owner_address:Z.value.trim(),...B.value?{wallet_type:B.value}:{}}}),await Ye(),H.value=!1;const f=Ke.find($=>$.value===B.value);f?y("success",`Owner set with ${f.label} auto-setup`):y("success","Owner address updated")}catch(f){const $=f instanceof _?f:new _(0,"UNKNOWN","Unknown error");y("error",G($.code,$.serverMessage))}finally{A.value=!1}},Di=async f=>{if(a.value?.ownerAddress){A.value=!0;try{await R.PUT("/v1/wallets/{id}/owner",{params:{path:{id:t}},body:{owner_address:a.value.ownerAddress,...f?{wallet_type:f}:{}}}),await Ye(),I.value=!1;const $=Ke.find(te=>te.value===f);$?y("success",`Wallet Type changed to ${$.label}`):y("success","Wallet Type cleared")}catch($){const te=$ instanceof _?$:new _(0,"UNKNOWN","Unknown error");y("error",G(te.code,te.serverMessage))}finally{A.value=!1}}},Ri=async()=>{try{const{data:f}=await R.GET("/v1/admin/settings"),$=f,te=$.signing_sdk?.enabled==="true",ne=$.telegram?.bot_token===!0||$.notifications?.telegram_bot_token===!0,Ae=!!$.walletconnect?.project_id&&$.walletconnect.project_id!=="";g.value={signingEnabled:te,telegramBotConfigured:ne,wcConfigured:Ae}}catch{}},Li=async f=>{const $=a.value?.walletType;if($){const te=Ke.find(Ae=>Ae.value===$),ne=te?Yt[$]:void 0;if(ne&&f!==ne){const Ae=te.label,ot=Xt.find(Xi=>Xi.value===ne)?.label??ne;if(!confirm(`${Ae} preset default is "${ot}". Changing the approval method may prevent sign requests from being delivered correctly.
3
+
4
+ Proceed with change?`))return}}try{await R.PUT("/v1/wallets/{id}/owner",{params:{path:{id:t}},body:{owner_address:a.value.ownerAddress,approval_method:f??null}}),await Ye(),y("success","Approval method updated")}catch(te){const ne=te instanceof _?te:new _(0,"UNKNOWN","Unknown error");y("error",G(ne.code,ne.serverMessage))}};X(()=>{Ye(),ki(),xn(),Dn(),Ei(),Rn(),Ri(),Nn().then(({currency:f,rate:$})=>{_e.value=f,K.value=$}).catch(()=>{})},[t]),X(()=>()=>{w.value&&clearInterval(w.value)},[]),X(()=>{Dn()},[M.value]);const On=M.value*xa,Pi=D.value>0?On+1:0,Oi=Math.min(On+xa,D.value),Ui=M.value>0,Wi=(M.value+1)*xa<D.value;function Mi(){return a.value?e(le,{children:[e("div",{class:"detail-grid",children:[e(ie,{label:"ID",value:a.value.id,copy:!0}),e(ie,{label:"Public Key",value:a.value.publicKey,copy:!0}),e(ie,{label:"Chain",value:a.value.chain}),e(ie,{label:"Environment",children:e(Y,{variant:a.value.environment==="mainnet"?"warning":"info",children:a.value.environment})}),e(ie,{label:"Status",children:e(Y,{variant:a.value.status==="ACTIVE"?"success":a.value.status==="SUSPENDED"?"warning":"danger",children:a.value.status})}),e(ie,{label:"Account Type",children:e(Y,{variant:a.value.accountType==="smart"?"info":"default",children:a.value.accountType==="smart"?"Smart Account":"EOA"})}),a.value.accountType==="smart"&&a.value.factoryAddress?.toLowerCase()===vi.toLowerCase()&&e("div",{style:{background:"var(--color-danger-bg)",border:"1px solid var(--color-danger)",borderRadius:"var(--radius)",padding:"var(--space-3)",marginBottom:"var(--space-3)"},children:[e("strong",{style:{color:"var(--color-danger)"},children:"Deprecated Smart Account"}),e("p",{style:{margin:"0.25rem 0 0",fontSize:"var(--font-size-sm)",color:"var(--text-secondary)"},children:"This Smart Account uses a deprecated factory (Solady). Transactions and UserOp operations will be rejected. Please create a new Smart Account wallet to continue."})]}),a.value.accountType==="smart"&&e(le,{children:[a.value.factoryAddress&&e(ie,{label:"Factory Address",value:a.value.factoryAddress,copy:!0}),a.value.factorySupportedNetworks&&a.value.factorySupportedNetworks.length>0&&e(ie,{label:"Factory Networks",children:e("div",{style:{display:"flex",flexWrap:"wrap",gap:"0.25rem"},children:a.value.factorySupportedNetworks.map(f=>e(Y,{variant:"default",children:f},f))})}),a.value.factoryVerifiedOnNetwork!==null&&a.value.factoryVerifiedOnNetwork!==void 0&&e(ie,{label:"Verified on Network",children:[e(Y,{variant:a.value.factoryVerifiedOnNetwork?"success":"danger",children:a.value.factoryVerifiedOnNetwork?"Verified":"Not Verified"}),!a.value.factoryVerifiedOnNetwork&&e("span",{style:{marginLeft:"0.5rem",fontSize:"0.85rem",color:"var(--color-danger)"},children:"Factory may not be deployed on this network"})]}),e(ie,{label:"Signer Key",value:a.value.signerKey??"--",copy:!0}),e(ie,{label:"Deployed",children:e(Y,{variant:a.value.deployed?"success":"warning",children:a.value.deployed?"Yes":"Not yet"})}),e(ie,{label:"Mode",children:[e(Y,{variant:a.value.provider?"success":"warning",children:a.value.provider?"Full":"Lite"}),!a.value.provider&&e("span",{style:{marginLeft:"0.5rem",fontSize:"0.85rem",color:"var(--color-text-secondary)"},children:"Use UserOp API for gas-sponsored transactions"})]}),a.value.provider?e(le,{children:[e(ie,{label:"Provider",children:e(Y,{variant:"info",children:a.value.provider.name})}),e(ie,{label:"Supported Chains",value:a.value.provider.supportedChains.join(", ")||"--"}),e(ie,{label:"Paymaster",children:e(Y,{variant:a.value.provider.paymasterEnabled?"success":"neutral",children:a.value.provider.paymasterEnabled?"Enabled":"Disabled"})})]}):e(ie,{label:"Provider",value:"Not configured"}),je.value?e("div",{class:"inline-form",style:{marginTop:"var(--space-3)",padding:"var(--space-3)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)"},children:[e(E,{label:"Provider",name:"editProvider",type:"select",value:Ne.value,onChange:f=>{Ne.value=f},options:Nt.map(f=>({label:f.label,value:f.value}))}),Ne.value!=="custom"&&Ne.value!=="none"?e(le,{children:[e(E,{label:"API Key",name:"editApiKey",value:Ya.value,onChange:f=>{Ya.value=f},placeholder:"Leave empty to use global default"}),e(E,{label:"Paymaster Policy ID",name:"editPolicyId",value:Qa.value,onChange:f=>{Qa.value=f},placeholder:"Leave empty to use global default"}),e("p",{style:{fontSize:"0.85rem",color:"var(--color-text-secondary)",margin:"0 0 0.5rem 0"},children:["Global defaults can be configured in"," ",e("a",{href:"/settings",style:{color:"var(--color-primary)"},children:"Settings > Smart Account"}),".",At[Ne.value]&&e(le,{children:[" ","Get API key at"," ",e("a",{href:At[Ne.value],target:"_blank",rel:"noopener noreferrer",children:[Nt.find(f=>f.value===Ne.value)?.label," Dashboard"]}),"."]})]})]}):Ne.value==="custom"?e(le,{children:[e(E,{label:"Bundler URL",name:"editBundlerUrl",value:Xa.value,onChange:f=>{Xa.value=f},placeholder:"https://..."}),e(E,{label:"Paymaster URL (optional)",name:"editPaymasterUrl",value:Ja.value,onChange:f=>{Ja.value=f},placeholder:"https://..."})]}):null,e("div",{style:{display:"flex",gap:"var(--space-2)",marginTop:"var(--space-2)"},children:[e(x,{onClick:bi,loading:Wt.value,children:"Save"}),e(x,{variant:"secondary",onClick:()=>{je.value=!1},children:"Cancel"})]})]}):e("div",{style:{marginTop:"var(--space-2)"},children:e(x,{variant:"secondary",size:"sm",onClick:wi,children:"Change Provider"})})]}),a.value.status==="SUSPENDED"&&e(le,{children:[e(ie,{label:"Suspended At",value:a.value.suspendedAt?ve(a.value.suspendedAt):"--"}),e(ie,{label:"Suspension Reason",value:a.value.suspensionReason??"--"})]}),e(ie,{label:"Created",value:ve(a.value.createdAt)}),e(ie,{label:"Updated",value:a.value.updatedAt?ve(a.value.updatedAt):"Never"})]}),e("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-lg)",padding:"var(--space-4)",marginTop:"var(--space-4)"},children:[e("h3",{style:{margin:"0 0 var(--space-3) 0",fontSize:"1rem"},children:"Owner Protection"}),a.value.ownerState==="NONE"?e("div",{children:[e("div",{style:{background:"var(--color-warning-bg, #fff3cd)",border:"1px solid var(--color-warning-border, #ffc107)",borderRadius:"var(--radius-md)",padding:"var(--space-2) var(--space-3)",marginBottom:"var(--space-3)",fontSize:"0.85rem",color:"var(--color-warning-text, #856404)"},children:"No owner registered. High-value transactions cannot use APPROVAL policy."}),e(x,{size:"sm",onClick:()=>{re.value=!re.value},children:re.value?"Hide Registration":"Register Owner"})]}):e("div",{children:[e("div",{class:"detail-grid",style:{marginBottom:"var(--space-3)"},children:[e(ie,{label:"State",children:e(Y,{variant:fn(a.value.ownerState),children:a.value.ownerState})}),e(ie,{label:"Approval Method",children:a.value.approvalMethod?Xt.find(f=>f.value===a.value.approvalMethod)?.label??a.value.approvalMethod:"Auto (Global Fallback)"}),e(ie,{label:"Address",children:[a.value.ownerAddress?ta(a.value.ownerAddress):"Not set",a.value.ownerAddress&&e(Ge,{value:a.value.ownerAddress})]})]}),e(x,{size:"sm",variant:"secondary",onClick:()=>{re.value=!re.value},children:re.value?"Hide Details":"Manage"})]}),re.value&&e("div",{style:{marginTop:"var(--space-4)",paddingTop:"var(--space-3)",borderTop:"1px solid var(--color-border)"},children:e(Fi,{})})]}),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(x,{variant:"secondary",size:"sm",onClick:xn,loading:W.value,children:"Refresh"})]}),W.value?e("div",{class:"stat-skeleton",style:{height:"60px"}}):U.value?.balances?.length?e("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-3)"},children:U.value.balances.map(f=>e("div",{style:{padding:"var(--space-3)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",background:"transparent"},children:[e("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)",marginBottom:"var(--space-2)"},children:e("strong",{children:f.network})}),f.error?e("p",{style:{color:"var(--color-text-secondary)",fontSize:"0.85rem"},children:f.error}):f.native?e("div",{children:[e(ie,{label:"Native",children:e("span",{children:[f.native.balance," ",f.native.symbol,f.native.usd!=null&&e("span",{style:{color:"var(--color-text-secondary)",marginLeft:"var(--space-2)",fontSize:"0.85rem"},children:["(",Ea(f.native.usd,_e.value,K.value),")"]})]})}),f.tokens.length>0?f.tokens.map($=>e(ie,{label:$.symbol,value:$.balance},$.address)):null]}):e("p",{style:{color:"var(--color-text-secondary)",fontSize:"0.85rem"},children:"Balance unavailable"})]},f.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"}),b.value?e("div",{class:"stat-skeleton",style:{height:"80px"}}):e("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2)"},children:(m.value??[]).map(f=>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:f.network})},f.network))})]})]}):null}function $i(){return e(le,{children:[e(ja,{fields:xs,values:O.value,onChange:f=>{O.value=f},syncUrl:!1}),e("div",{class:"table-container",style:{marginTop:"var(--space-3)"},children:e("table",{children:[e("thead",{children:e("tr",{children:Jt.map(f=>e("th",{children:f},f))})}),e("tbody",{children:T.value&&Mt.value.length===0?e("tr",{children:e("td",{colSpan:Jt.length,class:"table-loading",children:"Loading..."})}):Mt.value.length===0?e("tr",{children:e("td",{colSpan:Jt.length,class:"table-empty",children:"No transactions yet"})}):Mt.value.map(f=>e("tr",{children:[e("td",{children:f.createdAt?ve(f.createdAt):"—"}),e("td",{children:e(Y,{variant:"info",children:f.type})}),e("td",{children:f.contractName?e("span",{children:[e("strong",{children:f.contractName}),f.toAddress?e("span",{style:{marginLeft:"4px",fontSize:"0.8em",color:"var(--color-text-secondary)"},children:["(",ta(f.toAddress),")"]}):null]}):f.toAddress?ta(f.toAddress):"—"}),e("td",{children:f.amount?f.formattedAmount??f.amount:"—"}),e("td",{children:f.network??"—"}),e("td",{children:e(Y,{variant:Ds(f.status),children:f.status})}),e("td",{children:e(Cn,{network:f.network??"",txHash:f.txHash})})]},f.id))})]})}),e("div",{class:"pagination",style:{marginTop:"var(--space-3)"},children:[e("span",{class:"pagination-info",children:["Showing ",Pi,"-",Oi," of ",D.value]}),e("div",{class:"pagination-buttons",children:[e(x,{variant:"secondary",size:"sm",disabled:!Ui,onClick:()=>{M.value=M.value-1},children:"Previous"}),e(x,{variant:"secondary",size:"sm",disabled:!Wi,onClick:()=>{M.value=M.value+1},children:"Next"})]})]})]})}function Fi(){return a.value?e("div",{class:"owner-section",children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"Owner Wallet"}),a.value.ownerState==="NONE"&&a.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(x,{size:"sm",onClick:Pn,children:"Set Owner Address"})]}),H.value&&a.value.ownerState==="NONE"&&e("div",{style:{marginBottom:"var(--space-3)"},children:[e("label",{style:{display:"block",marginBottom:"var(--space-1)",fontSize:"0.85rem",fontWeight:500},children:"Wallet Type"}),e("select",{value:B.value,onChange:f=>{B.value=f.target.value},style:{width:"100%",padding:"var(--space-2) var(--space-3)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",background:"var(--color-bg)",color:"var(--color-text)",fontSize:"0.9rem"},children:[e("option",{value:"",children:"Custom (manual setup)"}),Ke.map(f=>e("option",{value:f.value,children:f.label},f.value))]}),B.value&&e("p",{style:{marginTop:"var(--space-1)",fontSize:"0.8rem",color:"var(--color-text-secondary)"},children:Ke.find(f=>f.value===B.value)?.description}),B.value&&ut[B.value]&&e("p",{style:{marginTop:"var(--space-1)",fontSize:"0.8rem",color:"var(--color-primary)"},children:["Approval: ",ut[B.value]]})]}),e(ie,{label:"Address",children:H.value?e("div",{class:"inline-edit",children:[e("input",{value:Z.value,onInput:f=>{Z.value=f.target.value},class:"inline-edit-input",placeholder:"Enter owner wallet address"}),e(x,{size:"sm",onClick:xi,loading:A.value,children:"Save"}),e(x,{size:"sm",variant:"secondary",onClick:Ii,children:"Cancel"})]}):e("span",{children:[a.value.ownerAddress?e(le,{children:[ta(a.value.ownerAddress),e(Ge,{value:a.value.ownerAddress})]}):"Not set",a.value.ownerState!=="LOCKED"&&a.value.status==="ACTIVE"&&e("button",{class:"btn btn-ghost btn-sm",onClick:Pn,title:"Set owner address",children:"✎"})]})}),e(ie,{label:"State",children:[e(Y,{variant:fn(a.value.ownerState),children:a.value.ownerState}),a.value.walletType&&e(Y,{variant:"info",style:{marginLeft:"var(--space-2)"},children:Ke.find(f=>f.value===a.value.walletType)?.label??a.value.walletType})]}),a.value.ownerState==="GRACE"&&e("div",{style:{marginTop:"var(--space-3)"},children:[e(ie,{label:"Wallet Type",children:I.value?e("div",{class:"inline-edit",children:[e("select",{value:B.value,onChange:f=>{B.value=f.target.value},style:{padding:"var(--space-1) var(--space-2)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",background:"var(--color-bg)",color:"var(--color-text)",fontSize:"0.85rem"},children:[e("option",{value:"",children:"Custom (manual setup)"}),Ke.map(f=>e("option",{value:f.value,children:f.label},f.value))]}),e(x,{size:"sm",onClick:()=>Di(B.value),loading:A.value,children:"Save"}),e(x,{size:"sm",variant:"secondary",onClick:()=>{I.value=!1},children:"Cancel"})]}):e("span",{children:[Ke.find(f=>f.value===a.value.walletType)?.label??a.value.walletType??"Custom",e("button",{class:"btn btn-ghost btn-sm",onClick:()=>{B.value=a.value?.walletType??"",I.value=!0},title:"Change wallet type",children:"✎"})]})}),I.value&&B.value&&ut[B.value]&&e("p",{style:{fontSize:"0.8rem",color:"var(--color-primary)",marginTop:"var(--space-1)"},children:["Approval: ",ut[B.value]]})]}),a.value.ownerState==="LOCKED"&&a.value.walletType&&e(ie,{label:"Wallet Type",children:e("span",{children:Ke.find(f=>f.value===a.value.walletType)?.label??a.value.walletType})}),a.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."})]}),a.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:[Xt.map(f=>e("label",{style:{display:"flex",alignItems:"flex-start",gap:"var(--space-2)",padding:"var(--space-2) var(--space-3)",background:a.value?.approvalMethod===f.value?"var(--color-bg-secondary)":"transparent",borderRadius:"var(--radius-md)",cursor:"pointer"},children:[e("input",{type:"radio",name:"approval_method",value:f.value??"",checked:a.value?.approvalMethod===f.value,onChange:()=>Li(f.value),style:{marginTop:"2px"},disabled:a.value?.ownerState==="LOCKED"||!!Yt[a.value?.walletType??""]}),e("div",{children:[e("div",{style:{fontWeight:500,fontSize:"0.9rem"},children:f.label}),e("div",{style:{color:"var(--color-text-secondary)",fontSize:"0.8rem"},children:f.description}),f.warning&&f.warningCondition?.(g.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:f.warning})]})]},f.value??"auto")),Yt[a.value?.walletType??""]&&e("p",{style:{fontSize:"0.8rem",color:"var(--color-text-secondary)",marginTop:"var(--space-2)",fontStyle:"italic"},children:"This wallet uses a preset type. The approval method is automatically managed by the preset."})]})]}),a.value?.approvalMethod==="walletconnect"&&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"}),k.value?e("div",{class:"stat-skeleton",style:{height:"60px"}}):N.value?e("div",{children:[e(ie,{label:"Status",children:e(Y,{variant:"success",children:"Connected"})}),e(ie,{label:"Peer",value:N.value.peerName??"Unknown"}),e(ie,{label:"Chain ID",value:N.value.chainId}),e(ie,{label:"Expires",value:ve(N.value.expiry)}),e("div",{style:{marginTop:"var(--space-3)"},children:e(x,{variant:"danger",onClick:Ci,loading:V.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."}),a.value?.ownerAddress?e(x,{onClick:Ai,loading:C.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 zi(){function f(te){return te==="lido"?"info":"neutral"}function $(te){return te==="COMPLETED"?"success":te==="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(x,{variant:"secondary",size:"sm",onClick:Rn,loading:Ee.value,children:"Refresh"})]}),Ee.value?e("div",{class:"stat-skeleton",style:{height:"80px"}}):oe.value.length===0?e(Ue,{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:oe.value.map(te=>e("tr",{children:[e("td",{children:e(Y,{variant:f(te.protocol),children:te.protocol==="lido"?"Lido":"Jito"})}),e("td",{children:te.asset}),e("td",{children:te.chain==="ethereum"?`${(Number(te.balance)/1e18).toFixed(6)} stETH`:`${(Number(te.balance)/1e9).toFixed(6)} JitoSOL`}),e("td",{children:te.balanceUsd?Ea(Number(te.balanceUsd),_e.value,K.value):"—"}),e("td",{children:te.apy??"—"}),e("td",{children:te.pendingUnstake?e("span",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)"},children:[e(Y,{variant:$(te.pendingUnstake.status),children:te.pendingUnstake.status}),e("span",{style:{fontSize:"0.85em",color:"var(--color-text-secondary)"},children:te.chain==="ethereum"?`${(Number(te.pendingUnstake.amount)/1e18).toFixed(4)} stETH`:`${(Number(te.pendingUnstake.amount)/1e9).toFixed(4)} JitoSOL`})]}):"—"})]},`${te.protocol}-${te.chain}`))})]})})]})}function Ki(){const f=m.value.map($=>$.network);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:"NFTs"}),e(E,{label:"",name:"nft-network",type:"select",value:ye.value,onChange:$=>{ye.value=String($),De.value=null,Za(String($))},options:[{value:"",label:"Select network..."},...f.map($=>({value:$,label:$}))]}),e(x,{variant:"ghost",size:"sm",onClick:()=>{z.value=z.value==="grid"?"list":"grid"},title:z.value==="grid"?"Switch to list view":"Switch to grid view",children:z.value==="grid"?"☰":"▦"}),ye.value&&e(x,{variant:"secondary",size:"sm",onClick:()=>Za(),loading:$e.value,children:"Refresh"})]}),ye.value?$e.value&&Ce.value.length===0?e("div",{class:"stat-skeleton",style:{height:"120px"}}):P.value==="INDEXER_NOT_CONFIGURED"?e(Ue,{title:"NFT indexer not configured",description:"Set up an Alchemy (EVM) or Helius (Solana) API key in Settings > API Keys to view NFTs."}):P.value?e(Ue,{title:"Failed to load NFTs",description:"An error occurred while fetching NFTs."}):Ce.value.length===0?e(Ue,{title:"No NFTs found",description:"This wallet has no NFTs on the selected network."}):z.value==="grid"?e("div",{children:[e("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(180px, 1fr))",gap:"var(--space-3)"},children:Ce.value.map($=>e("div",{class:"nft-card",style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-lg)",padding:"var(--space-2)",cursor:"pointer",textAlign:"center"},onClick:()=>{ae.value=$;const te=$.contractAddress.includes(":")?$.contractAddress:`${$.contractAddress}:${$.tokenId}`;Ln(te)},children:[$.image?e("img",{src:$.image,alt:$.name??"NFT",style:{width:"96px",height:"96px",objectFit:"cover",borderRadius:"var(--radius-md)",margin:"0 auto var(--space-2)",display:"block"}}):e("div",{style:{width:"96px",height:"96px",background:"var(--color-bg-secondary)",borderRadius:"var(--radius-md)",margin:"0 auto var(--space-2)",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-secondary)",fontSize:"0.8em"},children:"No image"}),e("div",{style:{fontSize:"0.85em",fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:$.name??`#${$.tokenId}`}),e(Y,{variant:"neutral",children:$.standard.toUpperCase()})]},`${$.contractAddress}-${$.tokenId}`))}),se.value&&e("div",{style:{textAlign:"center",marginTop:"var(--space-3)"},children:e(x,{variant:"secondary",onClick:()=>Za(void 0,De.value??void 0),loading:$e.value,children:"Load more"})})]}):e("div",{children:[e("div",{class:"table-container",children:e("table",{children:[e("thead",{children:e("tr",{children:[e("th",{children:"Image"}),e("th",{children:"Name"}),e("th",{children:"Token ID"}),e("th",{children:"Standard"}),e("th",{children:"Collection"})]})}),e("tbody",{children:Ce.value.map($=>e("tr",{style:{cursor:"pointer"},onClick:()=>{ae.value=$;const te=$.contractAddress.includes(":")?$.contractAddress:`${$.contractAddress}:${$.tokenId}`;Ln(te)},children:[e("td",{children:$.image?e("img",{src:$.image,alt:$.name??"NFT",style:{width:"48px",height:"48px",objectFit:"cover",borderRadius:"var(--radius-sm)"}}):e("div",{style:{width:"48px",height:"48px",background:"var(--color-bg-secondary)",borderRadius:"var(--radius-sm)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"0.7em",color:"var(--color-text-secondary)"},children:"-"})}),e("td",{children:$.name??"-"}),e("td",{style:{fontFamily:"monospace",fontSize:"0.85em"},children:$.tokenId}),e("td",{children:e(Y,{variant:"neutral",children:$.standard.toUpperCase()})}),e("td",{children:$.collection?.name??"-"})]},`${$.contractAddress}-${$.tokenId}`))})]})}),se.value&&e("div",{style:{textAlign:"center",marginTop:"var(--space-3)"},children:e(x,{variant:"secondary",onClick:()=>Za(void 0,De.value??void 0),loading:$e.value,children:"Load more"})})]}):e(Ue,{title:"Select a network",description:"Choose a network to view NFTs."}),e(he,{open:!!ae.value,title:ae.value?.name??"NFT Details",onCancel:()=>{ae.value=null},onConfirm:()=>{ae.value=null},confirmText:"Close",children:ae.value&&e("div",{children:[ae.value.image&&e("div",{style:{textAlign:"center",marginBottom:"var(--space-3)"},children:e("img",{src:ae.value.image,alt:ae.value.name??"NFT",style:{maxWidth:"300px",maxHeight:"300px",borderRadius:"var(--radius-lg)"}})}),ae.value.description&&e("p",{style:{color:"var(--color-text-secondary)",marginBottom:"var(--space-3)"},children:ae.value.description}),e("div",{class:"detail-grid",style:{marginBottom:"var(--space-3)"},children:[e(ie,{label:"Token ID",value:ae.value.tokenId}),e("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)"},children:[e(ie,{label:"Contract",value:ta(ae.value.contractAddress??"")}),e(Ge,{value:ae.value.contractAddress??""})]}),e(ie,{label:"Standard",value:(ae.value.standard??"").toUpperCase()}),ae.value.collection?.name&&e(ie,{label:"Collection",value:ae.value.collection.name}),ae.value.assetId&&e(ie,{label:"CAIP-19",value:ae.value.assetId})]}),ae.value.attributes&&ae.value.attributes.length>0&&e("div",{style:{marginBottom:"var(--space-3)"},children:[e("strong",{children:"Attributes"}),e("div",{style:{display:"flex",flexWrap:"wrap",gap:"var(--space-2)",marginTop:"var(--space-2)"},children:ae.value.attributes.map(($,te)=>e(Y,{variant:"info",children:[$.trait_type,": ",$.value]},te))})]}),ae.value.rawMetadata&&e("details",{style:{marginTop:"var(--space-2)"},children:[e("summary",{style:{cursor:"pointer",fontWeight:600},children:"Raw Metadata"}),e("pre",{style:{background:"var(--color-bg-secondary)",padding:"var(--space-2)",borderRadius:"var(--radius-md)",overflow:"auto",maxHeight:"200px",fontSize:"0.8em",marginTop:"var(--space-2)"},children:JSON.stringify(ae.value.rawMetadata,null,2)})]})]})})]})}const $t=c([]),Ft=c(!1),ra=c(!1),ya=c("api-key"),sa=c(""),oa=c(""),et=c(!1),at=c(!1),zt=c(null),Un=c(""),Kt=c(!1),tt=c(!1),Bt=c(null),Wn=c(""),ga=c(""),Ht=c(!1),Mn=Object.entries(ns).map(([f,$])=>({label:$,value:f})),nt=async()=>{Ft.value=!0;try{const{data:f}=await R.GET("/v1/wallets/{walletId}/credentials",{params:{path:{walletId:t}}});$t.value=f?.credentials??[]}catch(f){const $=f instanceof _?f:new _(0,"UNKNOWN","Unknown error");y("error",G($.code))}finally{Ft.value=!1}};function Bi(){X(()=>{nt()},[]);const f=async()=>{if(!sa.value.trim()||!oa.value.trim()){y("error","Name and value are required");return}et.value=!0;try{await R.POST("/v1/wallets/{walletId}/credentials",{params:{path:{walletId:t}},body:{type:ya.value,name:sa.value.trim(),value:oa.value}}),y("success","Credential created"),ra.value=!1,ya.value="api-key",sa.value="",oa.value="",await nt()}catch(ne){const Ae=ne instanceof _?ne:new _(0,"UNKNOWN","Unknown error");y("error",G(Ae.code))}finally{et.value=!1}},$=async()=>{if(zt.value){Kt.value=!0;try{await R.DELETE("/v1/wallets/{walletId}/credentials/{ref}",{params:{path:{walletId:t,ref:zt.value}}}),y("success","Credential deleted"),at.value=!1,await nt()}catch(ne){const Ae=ne instanceof _?ne:new _(0,"UNKNOWN","Unknown error");y("error",G(Ae.code))}finally{Kt.value=!1}}},te=async()=>{if(!(!Bt.value||!ga.value.trim())){Ht.value=!0;try{await R.PUT("/v1/wallets/{walletId}/credentials/{ref}/rotate",{params:{path:{walletId:t,ref:Bt.value}},body:{value:ga.value}}),y("success","Credential rotated"),tt.value=!1,ga.value="",await nt()}catch(ne){const Ae=ne instanceof _?ne:new _(0,"UNKNOWN","Unknown error");y("error",G(Ae.code))}finally{Ht.value=!1}}};return!Ft.value&&$t.value.length===0?e("div",{children:[e(Ue,{title:"No Credentials",description:"Add credentials for external service authentication.",actionLabel:"Add Credential",onAction:()=>{ra.value=!0}}),e(he,{open:ra.value,title:"Add Credential",onCancel:()=>{ra.value=!1},onConfirm:f,confirmText:"Create",loading:et.value,children:[e(E,{label:"Type",name:"wcred-type",type:"select",value:ya.value,onChange:ne=>{ya.value=ne},options:Mn}),e(E,{label:"Name",name:"wcred-name",value:sa.value,onChange:ne=>{sa.value=ne},placeholder:"e.g. exchange-api-key",required:!0}),e(E,{label:"Value",name:"wcred-value",type:"password",value:oa.value,onChange:ne=>{oa.value=ne},placeholder:"Secret value",required:!0})]})]}):e("div",{children:[e("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:"1rem"},children:e(x,{onClick:()=>{ra.value=!0},children:"Add Credential"})}),e("table",{class:"table",children:[e("thead",{children:e("tr",{children:[e("th",{children:"Name"}),e("th",{children:"Type"}),e("th",{children:"Expires"}),e("th",{children:"Created"}),e("th",{children:"Actions"})]})}),e("tbody",{children:$t.value.map(ne=>e("tr",{children:[e("td",{children:ne.name}),e("td",{children:e(Y,{variant:"info",children:ne.type})}),e("td",{children:ne.expiresAt?ve(ne.expiresAt):"Never"}),e("td",{children:ve(ne.createdAt)}),e("td",{children:e("span",{style:{display:"flex",gap:"0.25rem"},children:[e(x,{size:"sm",variant:"ghost",onClick:()=>{Bt.value=ne.name,Wn.value=ne.name,ga.value="",tt.value=!0},children:"Rotate"}),e(x,{size:"sm",variant:"danger",onClick:()=>{zt.value=ne.name,Un.value=ne.name,at.value=!0},children:"Delete"})]})})]},ne.id))})]}),e(he,{open:ra.value,title:"Add Credential",onCancel:()=>{ra.value=!1},onConfirm:f,confirmText:"Create",loading:et.value,children:[e(E,{label:"Type",name:"wcred-type",type:"select",value:ya.value,onChange:ne=>{ya.value=ne},options:Mn}),e(E,{label:"Name",name:"wcred-name",value:sa.value,onChange:ne=>{sa.value=ne},placeholder:"e.g. exchange-api-key",required:!0}),e(E,{label:"Value",name:"wcred-value",type:"password",value:oa.value,onChange:ne=>{oa.value=ne},placeholder:"Secret value",required:!0})]}),e(he,{open:at.value,title:"Delete Credential",onCancel:()=>{at.value=!1},onConfirm:$,confirmText:"Delete",confirmVariant:"danger",loading:Kt.value,children:e("p",{children:["Are you sure you want to delete credential ",e("strong",{children:Un.value}),"?"]})}),e(he,{open:tt.value,title:"Rotate Credential",onCancel:()=>{tt.value=!1},onConfirm:te,confirmText:"Rotate",loading:Ht.value,children:[e("p",{children:["Enter a new value for credential ",e("strong",{children:Wn.value}),":"]}),e(E,{label:"New Value",name:"wcred-rotate-value",type:"password",value:ga.value,onChange:ne=>{ga.value=ne},placeholder:"New secret value",required:!0})]})]})}const Vt=c([]),lt=c(!1),it=c("all"),rt=c(""),Ie=c(null);function Hi(f){switch(f.toLowerCase()){case"submitted":return"info";case"signed":case"completed":case"filled":case"settled":return"success";case"pending":case"partially_filled":return"warning";case"failed":case"canceled":case"expired":return"danger";default:return"info"}}const st=async()=>{lt.value=!0;try{const f={limit:50};it.value!=="all"&&(f.status=it.value),rt.value.trim()&&(f.venue=rt.value.trim());const{data:$}=await R.GET("/v1/wallets/{walletId}/actions",{params:{path:{walletId:t},query:f}});Vt.value=$?.actions??[]}catch(f){const $=f instanceof _?f:new _(0,"UNKNOWN","Unknown error");y("error",G($.code))}finally{lt.value=!1}};function Vi(){return X(()=>{st()},[]),e("div",{children:[e("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",alignItems:"flex-end"},children:[e("div",{class:"form-field",style:{flex:"0 0 auto"},children:[e("label",{for:"action-status-filter",children:"Status"}),e("select",{id:"action-status-filter",value:it.value,onChange:f=>{it.value=f.target.value,st()},children:[e("option",{value:"all",children:"All"}),e("option",{value:"submitted",children:"Submitted"}),e("option",{value:"signed",children:"Signed"}),e("option",{value:"pending",children:"Pending"}),e("option",{value:"failed",children:"Failed"}),e("option",{value:"completed",children:"Completed"}),e("option",{value:"filled",children:"Filled"}),e("option",{value:"settled",children:"Settled"})]})]}),e("div",{class:"form-field",style:{flex:"0 0 auto"},children:[e("label",{for:"action-venue-filter",children:"Venue"}),e("input",{id:"action-venue-filter",value:rt.value,onInput:f=>{rt.value=f.target.value},onKeyDown:f=>{f.key==="Enter"&&st()},placeholder:"Filter by venue"})]}),e(x,{variant:"secondary",size:"sm",onClick:()=>st(),children:"Refresh"})]}),!lt.value&&Vt.value.length===0?e(Ue,{title:"No External Actions",description:"No external actions recorded for this wallet."}):e("table",{class:"table",children:[e("thead",{children:e("tr",{children:[e("th",{children:"Venue"}),e("th",{children:"Operation"}),e("th",{children:"Status"}),e("th",{children:"Provider"}),e("th",{children:"Action"}),e("th",{children:"Created"})]})}),e("tbody",{children:Vt.value.map(f=>e("tr",{style:{cursor:"pointer"},onClick:()=>{Ie.value=f},children:[e("td",{children:f.venue?e(Y,{variant:"info",children:f.venue}):"-"}),e("td",{children:f.operation??"-"}),e("td",{children:e(Y,{variant:Hi(f.status),children:f.status})}),e("td",{children:f.provider??"-"}),e("td",{children:f.actionName??"-"}),e("td",{children:ve(f.createdAt)})]},f.id))})]}),lt.value&&e("div",{class:"empty-state",children:e("p",{children:"Loading..."})}),e(he,{open:!!Ie.value,title:"External Action Details",onCancel:()=>{Ie.value=null},onConfirm:()=>{Ie.value=null},confirmText:"Close",children:Ie.value&&e("div",{class:"detail-grid",children:[e(ie,{label:"ID",value:Ie.value.id}),e(ie,{label:"Kind",value:Ie.value.actionKind}),e(ie,{label:"Venue",value:Ie.value.venue??"-"}),e(ie,{label:"Operation",value:Ie.value.operation??"-"}),e(ie,{label:"Status",value:Ie.value.status}),e(ie,{label:"Provider",value:Ie.value.provider??"-"}),e(ie,{label:"Action",value:Ie.value.actionName??"-"}),e(ie,{label:"Created",value:ve(Ie.value.createdAt)})]})})]})}function Gi(){return e("div",{class:"mcp-setup-section",children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"MCP Setup"}),h.value?e("div",{children:[e("div",{class:"detail-grid",style:{marginBottom:"var(--space-4)"},children:[e(ie,{label:"Token Path",value:h.value.tokenPath}),e(ie,{label:"Expires At",value:ve(h.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:h.value.claudeDesktopConfig},null,2)})}),e("div",{style:{marginTop:"var(--space-2)"},children:e(Ge,{value:JSON.stringify({mcpServers:h.value.claudeDesktopConfig},null,2),label:"Copy Config"})})]}),e("div",{style:{marginTop:"var(--space-3)"},children:e(x,{variant:"secondary",onClick:In,loading:v.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(x,{onClick:In,loading:v.value,children:"Setup MCP"})]})]})}function qi(){return e("div",{children:[e("div",{style:{display:"flex",gap:"var(--space-2)",marginBottom:"var(--space-3)"},children:[e(x,{variant:ee.value==="transactions"?"primary":"secondary",size:"sm",onClick:()=>{ee.value="transactions"},children:"Transactions"}),e(x,{variant:ee.value==="external-actions"?"primary":"secondary",size:"sm",onClick:()=>{ee.value="external-actions"},children:"External Actions"})]}),ee.value==="transactions"&&e($i,{}),ee.value==="external-actions"&&e(Vi,{})]})}function ji(){return e("div",{children:[e(zi,{}),e("div",{style:{marginTop:"var(--space-6)",paddingTop:"var(--space-4)",borderTop:"1px solid var(--color-border)"},children:e(Ki,{})})]})}function Yi(){return e("div",{children:[e(Bi,{}),e("div",{style:{marginTop:"var(--space-6)",paddingTop:"var(--space-4)",borderTop:"1px solid var(--color-border)"},children:e(Gi,{})})]})}return e("div",{class:"page",children:[e("a",{href:"#/wallets",class:"back-link",children:"← Back to Wallets"}),n.value?e("div",{class:"stat-skeleton",style:{height:"200px",marginTop:"var(--space-4)"}}):a.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:f=>{i.value=f.target.value},class:"inline-edit-input"}),e(x,{size:"sm",onClick:mi,loading:r.value,children:"Save"}),e(x,{size:"sm",variant:"secondary",onClick:Si,children:"Cancel"})]}):e("span",{children:[a.value.name,e("button",{class:"btn btn-ghost btn-sm",onClick:Ti,title:"Edit name",children:"✎"})]})}),e("div",{style:{display:"flex",gap:"var(--space-2)"},children:[a.value.status==="ACTIVE"&&e(x,{variant:"secondary",onClick:()=>{F.value=!0},children:"Suspend Wallet"}),a.value.status==="SUSPENDED"&&e(x,{variant:"primary",onClick:_i,loading:L.value,children:"Resume Wallet"}),a.value.status!=="TERMINATED"&&e(x,{variant:"danger",onClick:()=>{s.value=!0},children:"Terminate Wallet"}),a.value.status==="TERMINATED"&&e(x,{variant:"danger",onClick:()=>{u.value=!0},children:"Permanently Delete"})]})]}),e(Oe,{tabs:As,activeTab:Q.value,onTabChange:f=>{Q.value=f}}),Q.value==="overview"&&e(Mi,{}),Q.value==="activity"&&e(qi,{}),Q.value==="assets"&&e(ji,{}),Q.value==="setup"&&e(Yi,{}),e(he,{open:s.value,title:"Terminate Wallet",onCancel:()=>{s.value=!1},onConfirm:fi,confirmText:"Terminate",confirmVariant:"danger",loading:o.value,children:e("p",{children:["Are you sure you want to terminate wallet ",e("strong",{children:a.value.name}),"? This action cannot be undone."]})}),e(he,{open:u.value,title:"Permanently Delete Wallet",onCancel:()=>{u.value=!1},onConfirm:yi,confirmText:"Delete Forever",confirmVariant:"danger",loading:d.value,children:e("p",{children:["Are you sure you want to ",e("strong",{children:"permanently delete"})," wallet"," ",e("strong",{children:a.value.name}),"? All associated data (transactions, sessions, policies, keys, audit logs) will be irreversibly removed. This cannot be undone."]})}),e(he,{open:q.value,title:"Scan QR Code",onCancel:()=>{q.value=!1,w.value&&clearInterval(w.value),w.value=null},children:S.value&&e("div",{style:{textAlign:"center"},children:[e("img",{src:S.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(he,{open:F.value,title:"Suspend Wallet",onCancel:()=>{F.value=!1,J.value=""},onConfirm:gi,confirmText:"Suspend",confirmVariant:"danger",loading:j.value,children:[e("p",{style:{marginBottom:"var(--space-3)"},children:["Are you sure you want to suspend wallet ",e("strong",{children:a.value.name}),"? Suspended wallets cannot process transactions until resumed."]}),e(E,{label:"Reason (optional)",name:"suspend-reason",value:J.value,onChange:f=>{J.value=f},placeholder:"e.g. suspicious activity"})]})]}):e(Ue,{title:"Wallet not found",description:"The wallet may have been deleted."})]})}const ba=An,Da=qa;function Ls(t){if(t<=0)return"";const a=Math.ceil(t/1e3);if(a<60)return`${a}s`;const n=Math.floor(a/60),l=a%60;return l>0?`${n}m ${l}s`:`${n}m`}function Ps(t){return ba.includes(t)?"solana":"ethereum"}function Os(){const t=c({}),a=c({}),n=c({}),l=c(!1),i=c(!0),r=c({}),s=c({}),o=c({}),u=c({}),d=c({}),v=c({}),h=(N,k={})=>{const V={},w=[...ba,...Da];for(const H of w){const Z=[],A=N.rpc_pool;if(A){const F=A[H];if(typeof F=="string"&&F!=="[]")try{const j=JSON.parse(F);Array.isArray(j)&&Z.push(...j.filter(J=>typeof J=="string"&&J.length>0))}catch{}}const B=k[H]??[],I=new Set(Z),g=[];for(const F of Z)g.push({url:F,isBuiltin:B.includes(F),enabled:!0});for(const F of B)I.has(F)||g.push({url:F,isBuiltin:!0,enabled:!0});V[H]=g}return V},m=async()=>{try{try{const{data:w}=await R.GET("/v1/admin/rpc-status");w&&(w.builtinUrls&&(u.value=w.builtinUrls),o.value=w.networks??{})}catch{}const{data:N}=await R.GET("/v1/admin/settings"),k=N;t.value=k;const V=h(k,u.value);n.value=V,a.value=JSON.parse(JSON.stringify(V))}catch(N){const k=N instanceof _?N:new _(0,"UNKNOWN","Unknown error");y("error",G(k.code))}finally{i.value=!1}};X(()=>{m()},[]),X(()=>{const N=async()=>{try{const{data:V}=await R.GET("/v1/admin/rpc-status");V&&(o.value=V.networks??{},V.builtinUrls&&(u.value=V.builtinUrls))}catch{}};N();const k=setInterval(N,15e3);return()=>clearInterval(k)},[]);const b=async(N,k)=>{const V=`${N}:${k}`;d.value={...d.value,[V]:!0};try{const{data:w}=await R.POST("/v1/admin/settings/test-rpc",{body:{url:k,chain:Ps(N)}});v.value={...v.value,[V]:w}}catch{v.value={...v.value,[V]:{success:!1,latencyMs:0,error:"Request failed"}}}finally{d.value={...d.value,[V]:!1}}},U=()=>{for(const N of[...ba,...Da]){const k=n.value[N]??[],V=a.value[N]??[];if(k.length!==V.length)return!0;for(let w=0;w<k.length;w++)if(k[w].url!==V[w].url||k[w].enabled!==V[w].enabled)return!0}return!1},W=Lt(()=>{let N=0;for(const k of[...ba,...Da]){const V=n.value[k]??[],w=a.value[k]??[];if(V.length!==w.length){N++;continue}for(let H=0;H<V.length;H++)if(V[H].url!==w[H].url||V[H].enabled!==w[H].enabled){N++;break}}return N}),p=async()=>{l.value=!0;try{const N=[];for(const H of[...ba,...Da]){const A=(a.value[H]??[]).filter(B=>!B.isBuiltin&&B.enabled).map(B=>B.url);N.push({key:`rpc_pool.${H}`,value:JSON.stringify(A)})}const{data:k}=await R.PUT("/v1/admin/settings",{body:{settings:N}}),V=k?.settings??{};t.value=V;const w=h(V,u.value);n.value=w,a.value=JSON.parse(JSON.stringify(w)),y("success","RPC settings saved and applied")}catch(N){const k=N instanceof _?N:new _(0,"UNKNOWN","Unknown error");y("error",G(k.code))}finally{l.value=!1}},T=()=>{a.value=JSON.parse(JSON.stringify(n.value))};X(()=>(ze({id:"wallets-rpc",isDirty:U,save:p,discard:T}),()=>Me("wallets-rpc")),[]);const D=N=>{r.value={...r.value,[N]:!r.value[N]}},M=N=>{const k=(s.value[N]??"").trim();if(!k)return;if(!k.startsWith("https://")){y("warning","URL must start with https://");return}const V=a.value[N]??[];if(V.some(Z=>Z.url===k)){y("warning","URL already exists in this network");return}const w=[...V];w.findIndex(Z=>Z.isBuiltin&&!V.slice(0,V.indexOf(Z)).some(A=>!A.isBuiltin));const H=w.reduce((Z,A,B)=>A.isBuiltin?Z:B+1,0);w.splice(H,0,{url:k,isBuiltin:!1,enabled:!0}),a.value={...a.value,[N]:w},s.value={...s.value,[N]:""}},O=(N,k)=>{const V=[...a.value[N]??[]];V[k]?.isBuiltin||(V.splice(k,1),a.value={...a.value,[N]:V})},q=(N,k,V)=>{const w=[...a.value[N]??[]],H=V==="up"?k-1:k+1;if(H<0||H>=w.length)return;const Z=w[k],A=w[H];!Z||!A||([w[k],w[H]]=[w[H],w[k]],a.value={...a.value,[N]:w})},S=(N,k)=>{const V=[...a.value[N]??[]],w=V[k];w?.isBuiltin&&(V[k]={...w,enabled:!w.enabled},a.value={...a.value,[N]:V})};function C({network:N}){const k=a.value[N]??[],V=r.value[N]??!1,w=k.filter(A=>A.enabled).length,H=o.value[N]??[],Z=A=>H.find(B=>B.url===A);return e("details",{class:"rpc-pool-network",open:V,"data-testid":`rpc-network-${N}`,children:[e("summary",{class:"rpc-pool-network-header",onClick:A=>{A.preventDefault(),D(N)},children:[e("span",{children:Et[N]??N}),e("span",{class:"rpc-pool-url-count",children:[w," URL",w!==1?"s":""]})]}),V&&e("div",{class:"rpc-url-list",children:[k.map((A,B)=>{const I=Z(A.url),g=`${N}:${A.url}`,F=d.value[g]??!1,j=v.value[g];return e("div",{class:`rpc-url-item${A.isBuiltin?" rpc-url-item--builtin":""}${A.enabled?"":" rpc-url-disabled"}`,"data-testid":`rpc-url-${N}-${B}`,children:[e("span",{class:"rpc-url-priority",children:["#",B+1]}),e("span",{class:"rpc-url-item-url",title:A.url,children:A.url}),A.isBuiltin&&e("span",{class:"badge-builtin",children:"(built-in)"}),e("span",{class:"rpc-url-status","data-testid":`rpc-status-${N}-${B}`,children:I?I.status==="available"?e(le,{children:[e("span",{class:"rpc-url-status-dot rpc-url-status-dot--available"}),e("span",{children:"Available"})]}):e(le,{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:[Ls(I.cooldownRemainingMs)," remaining"]}),e(Y,{variant:"warning",children:[I.failureCount," fail",I.failureCount!==1?"s":""]})]}):e(le,{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(x,{variant:"ghost",size:"sm",onClick:()=>b(N,A.url),loading:F,children:"Test"}),j&&e("span",{class:`rpc-test-result ${j.success?"rpc-test-result--success":"rpc-test-result--failure"}`,children:[e(Y,{variant:j.success?"success":"danger",children:j.success?"OK":"FAIL"}),j.success&&e(le,{children:[" ",j.latencyMs,"ms",j.blockNumber!==void 0&&` (block #${j.blockNumber.toLocaleString()})`]}),j.error&&` - ${j.error}`]})]}),e("span",{class:"rpc-url-actions",children:[e("button",{class:"btn btn-ghost btn-sm rpc-action-btn",onClick:()=>q(N,B,"up"),disabled:B===0,title:"Move up","aria-label":"Move up",children:"↑"}),e("button",{class:"btn btn-ghost btn-sm rpc-action-btn",onClick:()=>q(N,B,"down"),disabled:B===k.length-1,title:"Move down","aria-label":"Move down",children:"↓"}),A.isBuiltin?e("button",{class:`btn btn-ghost btn-sm rpc-action-btn${A.enabled?"":" rpc-toggle-off"}`,onClick:()=>S(N,B),title:A.enabled?"Disable":"Enable","aria-label":A.enabled?"Disable":"Enable",children:A.enabled?"On":"Off"}):e("button",{class:"btn btn-ghost btn-sm rpc-action-btn rpc-delete-btn",onClick:()=>O(N,B),title:"Remove","aria-label":"Remove",children:"×"})]})]},`${N}-${B}`)}),e("div",{class:"rpc-add-url",children:[e("input",{type:"text",class:"rpc-add-url-input",placeholder:"https://your-rpc-url.com",value:s.value[N]??"",onInput:A=>{s.value={...s.value,[N]:A.target.value}},onKeyDown:A=>{A.key==="Enter"&&M(N)}}),e(x,{variant:"secondary",size:"sm",onClick:()=>M(N),children:"Add"})]})]})]})}return i.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(le,{children:[W.value>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[W.value," unsaved change",W.value>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(x,{variant:"ghost",size:"sm",onClick:T,children:"Discard"}),e(x,{variant:"primary",size:"sm",onClick:p,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"}),ba.map(N=>e(C,{network:N},N))]}),e("div",{class:"settings-subgroup",children:[e("div",{class:"settings-subgroup-title",children:"EVM"}),Da.map(N=>e(C,{network:N},N))]})]})]})]})}function Us(){const t=c({}),a=c({}),n=c(!1),l=c(!0),i=async()=>{try{const{data:d}=await R.GET("/v1/admin/settings");t.value=d}catch(d){const v=d instanceof _?d:new _(0,"UNKNOWN","Unknown error");y("error",G(v.code))}finally{l.value=!1}};X(()=>{i()},[]);const r=(d,v)=>{const h=String(v);a.value={...a.value,[d]:h}},s=async()=>{n.value=!0;try{const d=Object.entries(a.value).filter(([h])=>h.startsWith("walletconnect.")).map(([h,m])=>({key:h,value:m})),{data:v}=await R.PUT("/v1/admin/settings",{body:{settings:d}});t.value=v?.settings??{},a.value={},y("success","Settings saved and applied")}catch(d){const v=d instanceof _?d:new _(0,"UNKNOWN","Unknown error");y("error",G(v.code))}finally{n.value=!1}},o=()=>{a.value={}};X(()=>(ze({id:"wallets-walletconnect",isDirty:()=>Object.keys(a.value).filter(d=>d.startsWith("walletconnect.")).length>0,save:s,discard:o}),()=>Me("wallets-walletconnect")),[]);const u=Object.keys(a.value).filter(d=>d.startsWith("walletconnect.")).length;return l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(le,{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(x,{variant:"ghost",size:"sm",onClick:o,children:"Discard"}),e(x,{variant:"primary",size:"sm",onClick:s,loading:n.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(E,{label:ce("project_id"),name:"walletconnect.project_id",type:"text",value:pe(t.value,a.value,"walletconnect","project_id"),onChange:d=>r("walletconnect.project_id",d),description:"WalletConnect Cloud project identifier"})}),e("div",{class:"settings-field-full",children:e(E,{label:ce("relay_url"),name:"walletconnect.relay_url",type:"text",value:pe(t.value,a.value,"walletconnect","relay_url"),onChange:d=>r("walletconnect.relay_url",d),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 Ws=[{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"}]}];function Ms(){const t=c([]),a=c(!0),n=c(!1),l=c(""),i=c("solana"),r=c("testnet"),s=c("eoa"),o=c("none"),u=c(""),d=c(""),v=c(""),h=c(null),m=c(!1),b=c(null),U=c(""),W=c({chain:"",environment:"",status:""}),p=async()=>{try{const{data:S}=await R.GET("/v1/wallets");t.value=S?.items??[]}catch(S){const C=S instanceof _?S:new _(0,"UNKNOWN","Unknown error");y("error",G(C.code))}finally{a.value=!1}},T=Lt(()=>{let S=t.value;const C=U.value.toLowerCase();C&&(S=S.filter(k=>k.name.toLowerCase().includes(C)||k.publicKey.toLowerCase().includes(C)));const N=W.value;return N.chain&&(S=S.filter(k=>k.chain===N.chain)),N.environment&&(S=S.filter(k=>k.environment===N.environment)),N.status&&(S=S.filter(k=>k.status===N.status)),S}),D=[{key:"name",header:"Name"},{key:"chain",header:"Chain"},{key:"environment",header:"Environment",render:S=>e(Y,{variant:S.environment==="mainnet"?"warning":"info",children:S.environment})},{key:"accountType",header:"Type",render:S=>S.accountType!=="smart"?e(Y,{variant:"default",children:"EOA"}):S.factoryAddress?.toLowerCase()===vi.toLowerCase()?e(Y,{variant:"danger",children:"Deprecated"}):e(Y,{variant:S.provider?"info":"warning",children:S.provider?"Smart (Full)":"Smart (Lite)"})},{key:"publicKey",header:"Public Key",render:S=>e("span",{style:{display:"flex",alignItems:"center",gap:"0.25rem"},children:[ta(S.publicKey)," ",e(Ge,{value:S.publicKey})]})},{key:"status",header:"Status",render:S=>e(Y,{variant:S.status==="ACTIVE"?"success":S.status==="SUSPENDED"?"warning":"danger",children:S.status})},{key:"ownerState",header:"Owner",render:S=>e(Y,{variant:fn(S.ownerState),children:S.ownerState})},{key:"createdAt",header:"Created",render:S=>ve(S.createdAt)}],M=async()=>{if(!l.value.trim()){h.value="Name is required";return}h.value=null,m.value=!0;try{const S={name:l.value.trim(),chain:i.value,environment:r.value};s.value==="smart"&&(S.accountType="smart",o.value!=="none"&&(o.value==="custom"?(S.aaProvider="custom",S.aaBundlerUrl=d.value,v.value&&(S.aaPaymasterUrl=v.value)):(S.aaProvider=o.value,S.aaProviderApiKey=u.value)));const{data:C}=await R.POST("/v1/wallets",{body:S});C?.session?.token?(b.value=C.session.token,y("success","Wallet created with session")):y("success","Wallet created"),l.value="",i.value="solana",r.value="testnet",s.value="eoa",o.value="none",u.value="",d.value="",v.value="",n.value=!1,a.value=!0,await p()}catch(S){const C=S instanceof _?S:new _(0,"UNKNOWN","Unknown error");h.value=G(C.code)}finally{m.value=!1}},O=S=>{window.location.hash="#/wallets/"+S.id},q=S=>{i.value=S,S==="solana"&&(s.value="eoa",o.value="none",u.value="",d.value="",v.value="")};return X(()=>{p()},[]),e(le,{children:[e("div",{class:"page-actions",children:!n.value&&e(x,{onClick:()=>{n.value=!0},children:"Create Wallet"})}),n.value&&e("div",{class:"inline-form",children:[e(E,{label:"Name",name:"name",value:l.value,onChange:S=>{l.value=S},required:!0,placeholder:"e.g. trading-bot",error:h.value??void 0}),e(E,{label:"Chain",name:"chain",type:"select",value:i.value,onChange:q,options:[{label:"Solana",value:"solana"},{label:"Ethereum",value:"ethereum"}]}),i.value==="ethereum"&&e(E,{label:"Account Type",name:"accountType",type:"select",value:s.value,onChange:S=>{s.value=S},options:[{label:"EOA (Standard)",value:"eoa"},{label:"Smart Account (ERC-4337)",value:"smart"}]}),s.value==="smart"&&i.value==="ethereum"&&e(le,{children:[e(E,{label:"Provider",name:"provider",type:"select",value:o.value,onChange:S=>{o.value=S},options:Nt.map(S=>({label:S.label,value:S.value}))}),o.value==="none"?null:o.value!=="custom"?e(le,{children:[e(E,{label:"API Key",name:"apiKey",value:u.value,onChange:S=>{u.value=S},placeholder:"Paste your provider API key"}),At[o.value]&&e("p",{style:{fontSize:"0.85rem",color:"var(--color-text-secondary)",margin:"0 0 0.5rem 0"},children:["Get your API key at:"," ",e("a",{href:At[o.value],target:"_blank",rel:"noopener noreferrer",children:[Nt.find(S=>S.value===o.value)?.label," Dashboard"]})]})]}):e(le,{children:[e(E,{label:"Bundler URL",name:"bundlerUrl",value:d.value,onChange:S=>{d.value=S},placeholder:"https://..."}),e(E,{label:"Paymaster URL (optional)",name:"paymasterUrl",value:v.value,onChange:S=>{v.value=S},placeholder:"https://..."})]})]}),e(E,{label:"Environment",name:"environment",type:"select",value:r.value,onChange:S=>{r.value=S},options:[{label:"Testnet",value:"testnet"},{label:"Mainnet",value:"mainnet"}]}),e("div",{class:"inline-form-actions",children:[e(x,{onClick:M,loading:m.value,children:"Create"}),e(x,{variant:"secondary",onClick:()=>{n.value=!1,h.value=null},children:"Cancel"})]})]}),b.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:b.value,style:{flex:1,fontFamily:"monospace",fontSize:"0.85rem",padding:"0.5rem"},onClick:S=>S.target.select()}),e(x,{variant:"secondary",onClick:()=>{navigator.clipboard.writeText(b.value),y("success","Token copied")},children:"Copy"}),e(x,{variant:"secondary",onClick:()=>{b.value=null},children:"Dismiss"})]})]}),e(ja,{fields:Ws,values:W.value,onChange:S=>{W.value=S},syncUrl:!1}),e(ui,{value:U.value,onSearch:S=>{U.value=S},placeholder:"Search by name or public key..."}),e(Le,{columns:D,data:T.value,loading:a.value,onRowClick:O,emptyMessage:"No wallets yet"})]})}const ll=[{key:"wallets",label:"Wallets"},{key:"tokens",label:"Tokens"},{key:"rpc",label:"RPC Endpoints"},{key:"walletconnect",label:"WalletConnect"}];function $s(){const t=c("wallets");return X(()=>{const a=me.value;a&&a.tab&&(t.value=a.tab,setTimeout(()=>{Pe.value=a.fieldName},100),me.value=null)},[me.value]),e("div",{class:"page",children:[e(fa,{pageName:"Wallets",tabName:ll.find(a=>a.key===t.value)?.label??"",onPageClick:()=>{t.value="wallets"}}),e(Oe,{tabs:ll,activeTab:t.value,onTabChange:a=>{t.value=a}}),t.value==="wallets"&&e(Ms,{}),t.value==="tokens"&&e(Ns,{}),t.value==="rpc"&&e(Os,{}),t.value==="walletconnect"&&e(Us,{})]})}function Qt(){const t=ia.value,a=t.startsWith("/wallets/")?t.slice(9):null;return a?e(Rs,{id:a}):e($s,{})}const il=[{key:"transactions",label:"History"},{key:"monitor",label:"Monitor Settings"}],Je=20,Fs=[{value:"all",label:"All"},{value:"outgoing",label:"Outgoing"},{value:"incoming",label:"Incoming"}],zs=[{value:"TRANSFER",label:"TRANSFER"},{value:"TOKEN_TRANSFER",label:"TOKEN_TRANSFER"},{value:"CONTRACT_CALL",label:"CONTRACT_CALL"},{value:"APPROVE",label:"APPROVE"},{value:"BATCH",label:"BATCH"}],Ks=[{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"}],Bs=[{value:"DETECTED",label:"DETECTED"},{value:"CONFIRMED",label:"CONFIRMED"}],Hs=[{value:"solana",label:"Solana"},{value:"evm",label:"EVM"}],Vs=[{value:"true",label:"Yes"},{value:"false",label:"No"}],Gs=[{value:"solana-mainnet",label:"solana-mainnet"},{value:"solana-devnet",label:"solana-devnet"},{value:"solana-testnet",label:"solana-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"}],vt=["Time","Direction","Wallet","Counterparty","Amount","Network","Status","Tx Hash"];function qs(t){return t==="CONFIRMED"?"success":t==="FAILED"?"danger":"warning"}function rl(t){return{id:`out-${t.id}`,direction:"outgoing",time:t.createdAt,walletId:t.walletId,walletName:t.walletName,counterparty:t.toAddress,contractName:t.contractName??null,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 sl(t){return{id:`in-${t.id}`,direction:"incoming",time:t.detectedAt,walletId:t.walletId,walletName:t.walletName,counterparty:t.fromAddress,contractName:null,amount:t.amount,formattedAmount:t.formattedAmount,amountUsd:null,network:t.network,status:t.status,txHash:t.txHash,chain:t.chain,incoming:t}}function ol(){const t=c("transactions"),a=c([]),n=c(0),l=c(0),i=c(!0),r=c(null),s=c("all"),o=c({wallet_id:"",type:"",status:"",network:"",chain:"",suspicious:"",since:"",until:""}),u=c(""),d=c(0),v=c(null),h=c("USD"),m=c(1),b=c([]),U=c({}),W=c({}),p=c(!1),T=c(!0),D=c([]),M=c(!0),O=c({}),q=c(null),S=(P,z)=>{W.value={...W.value,[P]:String(z)}},C=(P,z)=>pe(U.value,W.value,P,z),N=async()=>{p.value=!0;try{const P=Object.entries(W.value).filter(([ae])=>ae.startsWith("incoming.")).map(([ae,fe])=>({key:ae,value:fe}));if(P.length===0){y("info","No changes to save"),p.value=!1;return}const{data:z}=await R.PUT("/v1/admin/settings",{body:{settings:P}});U.value=z.settings,W.value={},y("success","Settings saved and applied")}catch(P){const z=P instanceof _?P:new _(0,"UNKNOWN","Unknown error");y("error",G(z.code))}finally{p.value=!1}},k=()=>{W.value={}};X(()=>(Object.keys(W.value).filter(z=>z.startsWith("incoming.")).length>0?ze({id:"transactions-monitor",isDirty:()=>Object.keys(W.value).filter(z=>z.startsWith("incoming.")).length>0,save:N,discard:k}):Me("transactions-monitor"),()=>Me("transactions-monitor")),[W.value]);function V(){const P=s.value,z=[{key:"wallet_id",label:"Wallet",type:"select",options:b.value}];return(P==="outgoing"||P==="all")&&z.push({key:"type",label:"Type",type:"select",options:zs}),P==="outgoing"?z.push({key:"status",label:"Status",type:"select",options:Ks}):P==="incoming"&&z.push({key:"status",label:"Status",type:"select",options:Bs}),z.push({key:"network",label:"Network",type:"select",options:Gs}),(P==="incoming"||P==="all")&&(z.push({key:"chain",label:"Chain",type:"select",options:Hs}),z.push({key:"suspicious",label:"Suspicious",type:"select",options:Vs})),z.push({key:"since",label:"Since",type:"date"},{key:"until",label:"Until",type:"date"}),z}const w=async()=>{const P=new URLSearchParams,z=o.value;if(z.wallet_id&&P.set("wallet_id",z.wallet_id),z.type&&P.set("type",z.type),z.status&&s.value!=="all"&&P.set("status",z.status),z.network&&P.set("network",z.network),z.since){const ye=new Date(z.since);isNaN(ye.getTime())||P.set("since",String(Math.floor(ye.getTime()/1e3)))}if(z.until){const ye=new Date(z.until);isNaN(ye.getTime())||(ye.setHours(23,59,59,999),P.set("until",String(Math.floor(ye.getTime()/1e3))))}u.value&&P.set("search",u.value),P.set("offset",String(d.value*Je)),P.set("limit",String(Je));const ae={};P.forEach((ye,De)=>{ae[De]=ye});const{data:fe}=await R.GET("/v1/admin/transactions",{params:{query:ae}});return fe},H=async()=>{const P=new URLSearchParams,z=o.value;z.wallet_id&&P.set("wallet_id",z.wallet_id),z.chain&&P.set("chain",z.chain),z.status&&s.value!=="all"&&P.set("status",z.status),z.suspicious&&P.set("suspicious",z.suspicious),P.set("offset",String(d.value*Je)),P.set("limit",String(Je));const ae={};P.forEach((ye,De)=>{ae[De]=ye});const{data:fe}=await R.GET("/v1/admin/incoming",{params:{query:ae}});return fe},Z=async()=>{i.value=!0,r.value=null;try{const P=s.value;if(P==="outgoing"){const z=await w();a.value=z.items.map(rl),n.value=z.total,l.value=0}else if(P==="incoming"){const z=await H();a.value=z.items.map(sl),n.value=0,l.value=z.total}else{const[z,ae]=await Promise.all([w(),H()]),fe=[...z.items.map(rl),...ae.items.map(sl)];fe.sort((ye,De)=>(De.time??0)-(ye.time??0)),a.value=fe,n.value=z.total,l.value=ae.total}}catch(P){P instanceof _?r.value=G(P.code):r.value="An unexpected error occurred."}finally{i.value=!1}},A=async()=>{try{const{data:P}=await R.GET("/v1/wallets"),z=P.items;b.value=z.map(fe=>({value:fe.id,label:fe.name||fe.id.slice(0,8)})),D.value=z;const ae={};for(const fe of z)ae[fe.id]=fe.monitorIncoming??!1;O.value=ae}catch{}finally{M.value=!1}},B=async()=>{try{const{data:P}=await R.GET("/v1/admin/settings");U.value=P}catch(P){const z=P instanceof _?P:new _(0,"UNKNOWN","Unknown error");y("error",G(z.code))}finally{T.value=!1}};X(()=>{Z(),A(),Nn().then(({currency:P,rate:z})=>{h.value=P,m.value=z}).catch(()=>{}),B()},[]),X(()=>{Z()},[o.value,u.value,d.value,s.value]),X(()=>{const P=me.value;P&&P.tab&&(t.value=P.tab,me.value=null,setTimeout(()=>{Pe.value=P.fieldName},100))},[me.value]);function I(P){t.value=P}function g(P){o.value=P,d.value=0}function F(P){u.value=P,d.value=0}function j(P){s.value=P,d.value=0,o.value={...o.value,type:"",status:"",chain:"",suspicious:""}}function J(P){v.value=v.value===P.id?null:P.id}function L(){d.value>0&&(d.value=d.value-1)}function Q(){const P=n.value+l.value;(d.value+1)*Je<P&&(d.value=d.value+1)}async function re(P){if(window.confirm("Are you sure you want to cancel this transaction?"))try{await R.POST("/v1/admin/transactions/{id}/cancel",{params:{path:{id:P}}}),y("success","Transaction cancelled"),await Z()}catch(z){const ae=z instanceof _?z:new _(0,"UNKNOWN","Unknown error");y("error",G(ae.code))}}async function ee(P){if(window.confirm("Are you sure you want to reject this transaction?"))try{await R.POST("/v1/admin/transactions/{id}/reject",{params:{path:{id:P}}}),y("success","Transaction rejected"),await Z()}catch(z){const ae=z instanceof _?z:new _(0,"UNKNOWN","Unknown error");y("error",G(ae.code))}}async function _e(P){const z=O.value[P]??!1;q.value=P;try{const{data:ae}=await R.PATCH("/v1/wallets/{id}",{params:{path:{id:P}},body:{monitorIncoming:!z}});O.value={...O.value,[P]:ae.monitorIncoming}}catch(ae){const fe=ae instanceof _?ae:new _(0,"UNKNOWN","Unknown error");y("error",G(fe.code))}finally{q.value=null}}function K(){const P=n.value+l.value,z=d.value*Je,ae=P>0?z+1:0,fe=Math.min(z+Je,P),ye=d.value>0,De=(d.value+1)*Je<P;return e(le,{children:[r.value&&e("div",{class:"dashboard-error",children:[e("span",{children:r.value}),e(x,{variant:"secondary",size:"sm",onClick:Z,children:"Retry"})]}),e("div",{class:"filter-bar",style:{marginBottom:0},children:e("div",{class:"filter-field",children:[e("label",{children:"Direction"}),e("select",{value:s.value,onChange:se=>j(se.target.value),children:Fs.map(se=>e("option",{value:se.value,children:se.label},se.value))})]})}),e(ja,{fields:V(),values:o.value,onChange:g}),s.value!=="incoming"&&e(ui,{value:u.value,onSearch:F,placeholder:"Search by txHash or recipient address..."}),e("div",{class:"table-container",children:e("table",{children:[e("thead",{children:e("tr",{children:vt.map(se=>e("th",{children:se},se))})}),e("tbody",{children:i.value&&a.value.length===0?e("tr",{children:e("td",{colSpan:vt.length,class:"table-loading",children:"Loading..."})}):a.value.length===0?e("tr",{children:e("td",{colSpan:vt.length,class:"table-empty",children:"No transactions found"})}):a.value.map(se=>e(le,{children:[e("tr",{class:`clickable${v.value===se.id?" row-expanded":""}`,style:{cursor:"pointer"},onClick:()=>J(se),children:[e("td",{children:se.time?ve(se.time):"—"}),e("td",{children:e(Y,{variant:se.direction==="outgoing"?"info":"success",children:se.direction==="outgoing"?"Outgoing":"Incoming"})}),e("td",{children:se.walletName??se.walletId.slice(0,8)}),e("td",{children:se.contractName?e("span",{children:[e("strong",{children:se.contractName}),se.counterparty?e("span",{style:{marginLeft:"4px",fontSize:"0.8em",color:"var(--color-text-secondary)"},children:["(",ta(se.counterparty),")"]}):null]}):se.counterparty?ta(se.counterparty):"—"}),e("td",{children:se.amount?(()=>{const je=se.formattedAmount??se.amount;if(se.amountUsd!=null){const Ne=Ea(se.amountUsd,h.value,m.value);return Ne?`${je} (${Ne})`:je}return je})():"—"}),e("td",{children:se.network}),e("td",{children:e(Y,{variant:qs(se.status),children:se.status})}),e("td",{children:e(Cn,{network:se.network,txHash:se.txHash})})]},se.id),v.value===se.id&&e("tr",{class:"row-expand",children:e("td",{colSpan:vt.length,children:[se.outgoing?oe(se.outgoing):null,se.incoming?Ee(se.incoming):null]})},`${se.id}-expand`)]}))})]})}),e("div",{class:"pagination",children:[e("span",{class:"pagination-info",children:["Showing ",ae,"-",fe," of ",P]}),e("div",{class:"pagination-buttons",children:[e(x,{variant:"secondary",size:"sm",disabled:!ye,onClick:L,children:"Previous"}),e(x,{variant:"secondary",size:"sm",disabled:!De,onClick:Q,children:"Next"})]})]})]})}function oe(P){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:P.id})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Wallet ID"}),e("span",{class:"detail-value",children:P.walletId})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Wallet Name"}),e("span",{class:"detail-value",children:P.walletName??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Type"}),e("span",{class:"detail-value",children:P.type})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Status"}),e("span",{class:"detail-value",children:P.status})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Tier"}),e("span",{class:"detail-value",children:P.tier??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"To Address"}),e("span",{class:"detail-value",children:P.toAddress??"—"})]}),P.contractName&&e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Contract Name"}),e("span",{class:"detail-value",children:P.contractName})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Amount"}),e("span",{class:"detail-value",children:P.amount??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Amount USD"}),e("span",{class:"detail-value",children:P.amountUsd!=null?`$${P.amountUsd.toFixed(2)}`:"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Network"}),e("span",{class:"detail-value",children:P.network??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Chain"}),e("span",{class:"detail-value",children:P.chain})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Tx Hash"}),e("span",{class:"detail-value",children:P.txHash??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Created At"}),e("span",{class:"detail-value",children:P.createdAt?ve(P.createdAt):"—"})]}),P.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(x,{variant:"danger",size:"sm",onClick:z=>{z.stopPropagation(),re(P.id)},children:"Cancel"}),e(x,{variant:"secondary",size:"sm",onClick:z=>{z.stopPropagation(),ee(P.id)},children:"Reject"})]})})]})}function Ee(P){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:P.id})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Tx Hash"}),e("span",{class:"detail-value",children:P.txHash})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Wallet ID"}),e("span",{class:"detail-value",children:P.walletId})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Wallet Name"}),e("span",{class:"detail-value",children:P.walletName??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"From Address"}),e("span",{class:"detail-value",children:P.fromAddress})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Amount"}),e("span",{class:"detail-value",children:P.amount})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Token Address"}),e("span",{class:"detail-value",children:P.tokenAddress??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Chain"}),e("span",{class:"detail-value",children:P.chain})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Network"}),e("span",{class:"detail-value",children:P.network})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Status"}),e("span",{class:"detail-value",children:P.status})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Block Number"}),e("span",{class:"detail-value",children:P.blockNumber??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Detected At"}),e("span",{class:"detail-value",children:P.detectedAt?ve(P.detectedAt):"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Confirmed At"}),e("span",{class:"detail-value",children:P.confirmedAt?ve(P.confirmedAt):"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Suspicious"}),e("span",{class:"detail-value",children:P.suspicious?"Yes":"No"})]})]})}function Ce(){const P=Object.keys(W.value).filter(z=>z.startsWith("incoming.")).length;return e(le,{children:[P>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[P," unsaved change",P>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(x,{variant:"ghost",size:"sm",onClick:k,children:"Discard"}),e(x,{variant:"primary",size:"sm",onClick:N,loading:p.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:T.value?e("span",{children:"Loading settings..."}):e(le,{children:[e("div",{class:"settings-fields-grid",children:[e(E,{label:"Monitoring Enabled",name:"incoming.enabled",type:"select",value:C("incoming","enabled")||"false",onChange:z=>S("incoming.enabled",z),options:[{label:"Yes",value:"true"},{label:"No",value:"false"}]}),e(E,{label:"Poll Interval (seconds)",name:"incoming.poll_interval",type:"number",value:Number(C("incoming","poll_interval"))||30,onChange:z=>S("incoming.poll_interval",z),min:5,max:3600}),e(E,{label:"Retention Days",name:"incoming.retention_days",type:"number",value:Number(C("incoming","retention_days"))||90,onChange:z=>S("incoming.retention_days",z),min:1,max:365}),e(E,{label:"Suspicious Dust USD Threshold",name:"incoming.suspicious_dust_usd",type:"number",value:Number(C("incoming","suspicious_dust_usd"))||.01,onChange:z=>S("incoming.suspicious_dust_usd",z),min:0,max:1e3}),e(E,{label:"Suspicious Amount Multiplier",name:"incoming.suspicious_amount_multiplier",type:"number",value:Number(C("incoming","suspicious_amount_multiplier"))||10,onChange:z=>S("incoming.suspicious_amount_multiplier",z),min:1,max:1e3}),e(E,{label:"Notification Cooldown (minutes)",name:"incoming.cooldown_minutes",type:"number",value:Number(C("incoming","cooldown_minutes"))||5,onChange:z=>S("incoming.cooldown_minutes",z),min:1,max:1440}),e(E,{label:"WebSocket URL (optional)",name:"incoming.wss_url",type:"text",value:C("incoming","wss_url"),onChange:z=>S("incoming.wss_url",z),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:M.value?e("span",{children:"Loading wallets..."}):D.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:D.value.map(z=>e("tr",{children:[e("td",{children:z.name||z.id.slice(0,8)}),e("td",{children:z.chain}),e("td",{children:e(Y,{variant:(z.status??"ACTIVE")==="ACTIVE"?"success":"warning",children:z.status??"ACTIVE"})}),e("td",{children:e(x,{variant:O.value[z.id]?"primary":"secondary",size:"sm",onClick:()=>_e(z.id),loading:q.value===z.id,children:O.value[z.id]?"ON":"OFF"})})]},z.id))})]})})})]})]})}const $e=il.find(P=>P.key===t.value)?.label;return e("div",{class:"page",children:[e(fa,{pageName:"Transactions",tabName:$e,onPageClick:()=>{t.value="transactions"}}),e(Oe,{tabs:il,activeTab:t.value,onTabChange:I}),e("div",{style:{marginTop:"var(--space-4)"},children:t.value==="transactions"?K():Ce()})]})}function va({legend:t,children:a,description:n}){return e("fieldset",{class:"field-group",children:[e("legend",{class:"field-group-legend",children:t}),n&&e("p",{class:"field-group-description",children:n}),e("div",{class:"field-group-body",children:a})]})}function js(t,a,n){a.value=t,n.value=!0}const cl=[{key:"sessions",label:"Sessions"},{key:"settings",label:"Settings"}],Zt=["security.max_sessions_per_wallet","security.max_pending_tx","security.rate_limit_session_rpm","security.rate_limit_tx_rpm"];function Ys(){const t=c({}),a=c({}),n=c(!1),l=c(!0),i=async()=>{try{const{data:d}=await R.GET("/v1/admin/settings");t.value=d}catch(d){const v=d instanceof _?d:new _(0,"UNKNOWN","Unknown error");y("error",G(v.code))}finally{l.value=!1}};X(()=>{i()},[]);const r=(d,v)=>{const h=String(v);a.value={...a.value,[d]:h}},s=async()=>{n.value=!0;try{const d=Object.entries(a.value).filter(([h])=>Zt.includes(h)).map(([h,m])=>({key:h,value:m})),{data:v}=await R.PUT("/v1/admin/settings",{body:{settings:d}});t.value=v.settings,a.value={},y("success","Session settings saved and applied")}catch(d){const v=d instanceof _?d:new _(0,"UNKNOWN","Unknown error");y("error",G(v.code))}finally{n.value=!1}},o=()=>{a.value={}};X(()=>(ze({id:"sessions-settings",isDirty:()=>Object.keys(a.value).filter(d=>Zt.includes(d)).length>0,save:s,discard:o}),()=>Me("sessions-settings")),[]);const u=Object.keys(a.value).filter(d=>Zt.includes(d)).length;return l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(le,{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(x,{variant:"ghost",size:"sm",onClick:o,children:"Discard"}),e(x,{variant:"primary",size:"sm",onClick:s,loading:n.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(va,{legend:"Limits",description:"Session concurrency limits",children:e("div",{class:"settings-fields-grid",children:e(E,{label:ce("max_sessions_per_wallet"),name:"security.max_sessions_per_wallet",type:"number",value:Number(pe(t.value,a.value,"security","max_sessions_per_wallet"))||0,onChange:d=>r("security.max_sessions_per_wallet",d),min:1,max:100,description:"Maximum concurrent sessions for a single wallet"})})}),e(va,{legend:"Rate Limits",description:"Request throttling per session and transaction",children:e("div",{class:"settings-fields-grid",children:[e(E,{label:ce("max_pending_tx"),name:"security.max_pending_tx",type:"number",value:Number(pe(t.value,a.value,"security","max_pending_tx"))||0,onChange:d=>r("security.max_pending_tx",d),min:1,max:100,description:"Maximum in-flight transactions per session"}),e(E,{label:ce("rate_limit_session_rpm"),name:"security.rate_limit_session_rpm",type:"number",value:Number(pe(t.value,a.value,"security","rate_limit_session_rpm"))||0,onChange:d=>r("security.rate_limit_session_rpm",d),min:10,description:"Max requests per minute per session"}),e(E,{label:ce("rate_limit_tx_rpm"),name:"security.rate_limit_tx_rpm",type:"number",value:Number(pe(t.value,a.value,"security","rate_limit_tx_rpm"))||0,onChange:d=>r("security.rate_limit_tx_rpm",d),min:1,description:"Max transaction requests per minute per session"})]})})]})]})]})}function Xs(){const t=c("sessions");X(()=>{const w=me.value;w&&w.tab&&(t.value=w.tab,setTimeout(()=>{Pe.value=w.fieldName},100),me.value=null)},[me.value]);const a=c([]),n=c(""),l=c(""),i=c([]),r=c(!1),s=c(!0),o=c(!1),u=c(!1),d=c(""),v=c(!1),h=c(""),m=c(!1),b=c(null),U=c(!1),W=c(new Set),p=c(!1),T=c(""),D=c(""),M=c(""),O=async()=>{try{const{data:w}=await R.GET("/v1/wallets");a.value=w.items.filter(H=>H.status==="ACTIVE")}catch(w){const H=w instanceof _?w:new _(0,"UNKNOWN","Unknown error");y("error",G(H.code))}finally{s.value=!1}},q=async()=>{r.value=!0;try{const w=n.value?{walletId:n.value}:void 0,{data:H}=await R.GET("/v1/sessions",{params:{query:w}}),Z=H;i.value=Z.data??H}catch(w){const H=w instanceof _?w:new _(0,"UNKNOWN","Unknown error");y("error",G(H.code))}finally{r.value=!1}},S=w=>{const H=new Set(W.value);H.has(w)?H.delete(w):H.add(w),W.value=H},C=async()=>{o.value=!0;try{const w=Array.from(W.value),H=w.length===1?{walletId:w[0]}:{walletIds:w},Z=Number(T.value);Z>0&&(H.ttl=Z*86400);const A=Number(D.value);D.value!==""&&A>=0&&(H.maxRenewals=A);const B=Number(M.value);B>0&&(H.absoluteLifetime=B*86400);const{data:I}=await R.POST("/v1/sessions",{body:H});d.value=I.token,u.value=!0,U.value=!1,p.value=!1,T.value="",D.value="",M.value="",await q()}catch(w){const H=w instanceof _?w:new _(0,"UNKNOWN","Unknown error");y("error",G(H.code))}finally{o.value=!1}},N=async()=>{m.value=!0;try{await R.DELETE("/v1/sessions/{id}",{params:{path:{id:h.value}}}),y("success","Session revoked"),v.value=!1,await q()}catch(w){const H=w instanceof _?w:new _(0,"UNKNOWN","Unknown error");y("error",G(H.code))}finally{m.value=!1}},k=async w=>{b.value=w;try{const{data:H}=await R.POST("/v1/admin/sessions/{id}/reissue",{params:{path:{id:w}}});d.value=H.token,u.value=!0,await q()}catch(H){const Z=H instanceof _?H:new _(0,"UNKNOWN","Unknown error");y("error",G(Z.code))}finally{b.value=null}};X(()=>{O()},[]),X(()=>{i.value=[],q()},[n.value]);const V=[{key:"id",header:"ID",render:w=>w.id.slice(0,8)+"..."},{key:"walletName",header:"Wallet",render:w=>w.wallets&&w.wallets.length>0?e("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:w.wallets.map(H=>e("span",{children:H.name??H.id.slice(0,8)},H.id))}):w.walletName??w.walletId.slice(0,8)+"..."},{key:"source",header:"Source",render:w=>e(Y,{variant:w.source==="mcp"?"info":"neutral",children:w.source==="mcp"?"MCP":"API"})},{key:"status",header:"Status",render:w=>e(Y,{variant:w.status==="ACTIVE"?"success":w.status==="EXPIRED"?"warning":"danger",children:w.status})},{key:"expiresAt",header:"Expires At",render:w=>w.expiresAt===0?"Never":ve(w.expiresAt)},{key:"renewals",header:"Renewals",render:w=>`${w.renewalCount}/${w.maxRenewals}`},{key:"tokenIssuedCount",header:"Tokens",render:w=>String(w.tokenIssuedCount??1)},{key:"createdAt",header:"Created",render:w=>ve(w.createdAt)},{key:"actions",header:"Actions",render:w=>w.status==="ACTIVE"?e("div",{style:{display:"flex",gap:"var(--space-1)"},children:[e(x,{size:"sm",variant:"secondary",onClick:()=>k(w.id),loading:b.value===w.id,children:"Reissue"}),e(x,{size:"sm",variant:"danger",onClick:()=>js(w.id,h,v),children:"Revoke"})]}):null}];return e("div",{class:"page",children:[e(fa,{pageName:"Sessions",tabName:cl.find(w=>w.key===t.value)?.label??"",onPageClick:()=>{t.value="sessions"}}),e(Oe,{tabs:cl,activeTab:t.value,onTabChange:w=>{t.value=w}}),t.value==="sessions"&&e(le,{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:n.value,onChange:w=>{n.value=w.target.value},disabled:s.value,children:[e("option",{value:"",children:"All Wallets"}),a.value.map(w=>e("option",{value:w.id,children:[w.name," (",w.chain,"/",w.network,")"]},w.id))]})]}),e("div",{class:"session-wallet-select",children:[e("label",{for:"source-select",children:"Source"}),e("select",{id:"source-select",value:l.value,onChange:w=>{l.value=w.target.value},children:[e("option",{value:"",children:"All"}),e("option",{value:"api",children:"API"}),e("option",{value:"mcp",children:"MCP"})]})]}),e(x,{onClick:()=>{W.value=new Set,U.value=!0},disabled:a.value.length===0,children:"Create Session"})]}),e(Le,{columns:V,data:l.value?i.value.filter(w=>w.source===l.value):i.value,loading:r.value,emptyMessage:"No sessions"}),e(he,{open:u.value,title:"Session Created",onCancel:()=>{u.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:d.value}),e(Ge,{value:d.value,label:"Copy Token"})]})]}),e(he,{open:v.value,title:"Revoke Session",onCancel:()=>{v.value=!1},onConfirm:N,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(he,{open:U.value,title:"Create Session",onCancel:()=>{U.value=!1},onConfirm:C,confirmText:`Create Session (${W.value.size} wallet${W.value.size!==1?"s":""})`,confirmDisabled:W.value.size===0,loading:o.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:a.value.map(w=>e("label",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)",padding:"var(--space-1) 0",cursor:"pointer"},children:[e("input",{type:"checkbox",checked:W.value.has(w.id),onChange:()=>S(w.id)}),e("span",{children:w.name}),e("span",{style:{color:"var(--color-text-secondary)",fontSize:"0.8rem"},children:["(",w.chain,"/",w.network,")"]})]},w.id))})]}),e("div",{style:{marginTop:"var(--space-3)"},children:[e("button",{type:"button",onClick:()=>{p.value=!p.value},style:{background:"none",border:"none",color:"var(--color-primary)",cursor:"pointer",padding:0,fontSize:"0.85rem"},children:[p.value?"Hide":"Show"," Advanced Options"]}),p.value&&e("div",{style:{marginTop:"var(--space-2)",display:"grid",gap:"var(--space-2)"},children:[e(E,{label:"TTL (days)",name:"create-ttl",type:"number",value:T.value,onChange:w=>{T.value=String(w)},min:0,description:"Leave empty for unlimited session",placeholder:"Unlimited"}),e(E,{label:"Max Renewals",name:"create-max-renewals",type:"number",value:D.value,onChange:w=>{D.value=String(w)},min:0,description:"0 = unlimited renewals",placeholder:"Unlimited"}),e(E,{label:"Absolute Lifetime (days)",name:"create-lifetime",type:"number",value:M.value,onChange:w=>{M.value=String(w)},min:0,description:"Leave empty for unlimited lifetime",placeholder:"Unlimited"})]})]})]})]}),t.value==="settings"&&e(Ys,{})]})}function Js(t){return t&&es[t]||"Native"}const dl=qa;function Qs({rules:t,onChange:a,errors:n,network:l}){const i=c([]),r=c(!1),s=p=>T=>{a({...t,[p]:T})},o=p=>T=>{const D=Number(T),M={...t};T===""||T===0||Number.isNaN(D)?delete M[p]:M[p]=D,a(M)},u=t.token_limits||{},d=p=>T=>{const D=String(T),O={...u.native||{instant_max:"",notify_max:"",delay_max:""},[p]:D};if(!O.instant_max&&!O.notify_max&&!O.delay_max){const q={...u};delete q.native,a({...t,token_limits:Object.keys(q).length>0?q:void 0})}else a({...t,token_limits:{...u,native:O}})},v=(p,T,D)=>{const O={...u[p]||{instant_max:"0",notify_max:"0",delay_max:"0"},[T]:D};a({...t,token_limits:{...u,[p]:O}})},h=p=>{const T={...u};delete T[p],a({...t,token_limits:Object.keys(T).length>0?T:void 0})},m=p=>{if(!p||u[p])return;const T={instant_max:"0",notify_max:"0",delay_max:"0"};a({...t,token_limits:{...u,[p]:T}})},b=()=>{const p=prompt("Enter CAIP-19 asset ID (e.g., eip155:1/erc20:0xa0b8...)");if(!p||u[p])return;const T={instant_max:"0",notify_max:"0",delay_max:"0"};a({...t,token_limits:{...u,[p]:T}})};X(()=>{if(!l){i.value=[];return}if(!dl.includes(l)){i.value=[];return}r.value=!0,Se(`${Ha.TOKENS}?network=${l}`).then(p=>{i.value=p.tokens}).catch(()=>{i.value=[]}).finally(()=>{r.value=!1})},[l]);const U=Object.entries(u).filter(([p])=>p!=="native").map(([p,T])=>({assetId:p,symbol:i.value.find(D=>D.assetId===p)?.symbol||p.split("/").pop()?.split(":").pop()||p,instant_max:T.instant_max,notify_max:T.notify_max,delay_max:T.delay_max})),W=Js(l);return e("div",{class:"policy-form-fields",children:[e("h4",{children:"USD Amount Tiers"}),e("div",{class:"policy-form-grid",children:[e(E,{label:"Instant Max USD",name:"instant_max_usd",type:"number",value:t.instant_max_usd??"",onChange:o("instant_max_usd"),placeholder:"Optional"}),e(E,{label:"Notify Max USD",name:"notify_max_usd",type:"number",value:t.notify_max_usd??"",onChange:o("notify_max_usd"),placeholder:"Optional"}),e(E,{label:"Delay Max USD",name:"delay_max_usd",type:"number",value:t.delay_max_usd??"",onChange:o("delay_max_usd"),placeholder:"Optional"})]}),e("h4",{children:"Token-Specific Limits"}),e("h5",{children:["Native Token (",W,")"]}),e("div",{class:"policy-form-grid",children:[e(E,{label:`Instant Max (${W})`,name:"native_instant_max",value:u.native?.instant_max??"",onChange:d("instant_max"),placeholder:"e.g. 0.5",error:n["token_limits.native.instant_max"]}),e(E,{label:`Notify Max (${W})`,name:"native_notify_max",value:u.native?.notify_max??"",onChange:d("notify_max"),placeholder:"e.g. 0.5",error:n["token_limits.native.notify_max"]}),e(E,{label:`Delay Max (${W})`,name:"native_delay_max",value:u.native?.delay_max??"",onChange:d("delay_max"),placeholder:"e.g. 0.5",error:n["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"}),U.map((p,T)=>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:p.symbol}),e("span",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",flex:1,marginLeft:"0.5rem",overflow:"hidden",textOverflow:"ellipsis"},children:p.assetId}),e("button",{class:"btn btn-ghost btn-sm",onClick:()=>h(p.assetId),title:"Remove",children:"x"})]}),e("div",{class:"policy-form-grid",children:[e(E,{label:"Instant Max",name:`token-${T}-instant`,value:p.instant_max,onChange:D=>v(p.assetId,"instant_max",String(D)),placeholder:"e.g. 100",error:n[`token_limits.${p.assetId}.instant_max`]}),e(E,{label:"Notify Max",name:`token-${T}-notify`,value:p.notify_max,onChange:D=>v(p.assetId,"notify_max",String(D)),placeholder:"e.g. 500",error:n[`token_limits.${p.assetId}.notify_max`]}),e(E,{label:"Delay Max",name:`token-${T}-delay`,value:p.delay_max,onChange:D=>v(p.assetId,"delay_max",String(D)),placeholder:"e.g. 1000",error:n[`token_limits.${p.assetId}.delay_max`]})]})]},p.assetId)),l&&dl.includes(l)&&i.value.length>0&&e("div",{style:{display:"flex",gap:"0.5rem",alignItems:"flex-end",marginTop:"0.5rem"},children:e(E,{label:"Select Token",name:"add-token-select",type:"select",value:"",onChange:p=>m(p),options:[{label:r.value?"Loading...":"-- Select a token --",value:""},...i.value.filter(p=>p.assetId&&!u[p.assetId]).map(p=>({label:`${p.symbol} (${p.name})`,value:p.assetId}))]})}),e("button",{class:"btn btn-secondary btn-sm",style:{marginTop:"0.5rem"},onClick:b,children:"+ Add Token Limit (manual CAIP-19)"}),e("h4",{children:"Cumulative USD Limits (Optional)"}),e("div",{class:"policy-form-grid",children:[e(E,{label:"Daily Limit USD (24h rolling)",name:"daily_limit_usd",type:"number",value:t.daily_limit_usd??"",onChange:o("daily_limit_usd"),placeholder:"e.g. 500",error:n.daily_limit_usd}),e(E,{label:"Monthly Limit USD (30d rolling)",name:"monthly_limit_usd",type:"number",value:t.monthly_limit_usd??"",onChange:o("monthly_limit_usd"),placeholder:"e.g. 5000",error:n.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(E,{label:"Instant Max (lamports/wei)",name:"instant_max",value:t.instant_max||"",onChange:s("instant_max"),error:n.instant_max}),e(E,{label:"Notify Max (lamports/wei)",name:"notify_max",value:t.notify_max||"",onChange:s("notify_max"),error:n.notify_max}),e(E,{label:"Delay Max (lamports/wei)",name:"delay_max",value:t.delay_max||"",onChange:s("delay_max"),error:n.delay_max})]}),e(E,{label:"Delay Duration (seconds, min 60)",name:"delay_seconds",type:"number",value:t.delay_seconds??900,onChange:s("delay_seconds"),error:n.delay_seconds,required:!0,min:60})]})}function Fe({items:t,onAdd:a,onRemove:n,renderRow:l,onChange:i,addLabel:r="+ Add",minItems:s=0,error:o}){return e("div",{class:"dynamic-row-list",children:[t.map((u,d)=>e("div",{class:"dynamic-row",children:[e("div",{class:"dynamic-row-fields",children:l(u,d,i)}),e("button",{class:"btn btn-ghost btn-sm dynamic-row-remove",onClick:()=>n(d),disabled:t.length<=s,title:"Remove",children:"x"})]},d)),e("button",{class:"btn btn-secondary btn-sm",onClick:a,children:r}),o&&e("span",{class:"form-error",children:o})]})}function Zs({rules:t,onChange:a,errors:n}){const l=t.allowed_addresses||[];return e("div",{class:"policy-form-fields",children:e(Fe,{items:l,onAdd:()=>a({...t,allowed_addresses:[...l,""]}),onRemove:i=>a({...t,allowed_addresses:l.filter((r,s)=>s!==i)}),onChange:(i,r)=>{const s=[...l];s[i]=r,a({...t,allowed_addresses:s})},renderRow:(i,r,s)=>e(E,{label:`Address ${r+1}`,name:`address-${r}`,value:i,onChange:o=>s(r,o),placeholder:"Wallet address",error:n[`allowed_addresses.${r}`],required:!0}),addLabel:"+ Add Address",error:n.allowed_addresses})})}function eo({rules:t,onChange:a,errors:n}){const l=i=>r=>{a({...t,[i]:r})};return e("div",{class:"policy-form-fields",children:[e(E,{label:"Max Requests",name:"max_requests",type:"number",value:t.max_requests??100,onChange:l("max_requests"),error:n.max_requests,required:!0,min:1}),e(E,{label:"Window (seconds)",name:"window_seconds",type:"number",value:t.window_seconds??3600,onChange:l("window_seconds"),error:n.window_seconds,required:!0,min:1})]})}function ao({rules:t,onChange:a,errors:n}){const l=i=>{const r={...t};i===""||i===void 0?delete r.maxAmount:r.maxAmount=i,a(r)};return e("div",{class:"policy-form-fields",children:[e(E,{label:"Max Amount (lamports/wei, optional)",name:"maxAmount",value:t.maxAmount??"",onChange:l,error:n.maxAmount,placeholder:"Leave empty for no limit"}),e(E,{label:"Block Unlimited Approvals",name:"blockUnlimited",type:"checkbox",value:t.blockUnlimited??!0,onChange:i=>a({...t,blockUnlimited:i})})]})}const to=[{label:"Instant",value:"INSTANT"},{label:"Notify",value:"NOTIFY"},{label:"Delay",value:"DELAY"},{label:"Approval",value:"APPROVAL"}];function no({rules:t,onChange:a,errors:n}){return e("div",{class:"policy-form-fields",children:e(E,{label:"Override Tier",name:"tier",type:"select",value:t.tier??"DELAY",onChange:l=>a({...t,tier:l}),options:to,error:n.tier})})}const lo=[{label:"All Chains",value:""},{label:"Solana",value:"solana"},{label:"Ethereum",value:"ethereum"}];function io({rules:t,onChange:a,errors:n}){const l=t.tokens||[];return e("div",{class:"policy-form-fields",children:e(Fe,{items:l,onAdd:()=>a({...t,tokens:[...l,{address:"",symbol:"",chain:""}]}),onRemove:i=>a({...t,tokens:l.filter((r,s)=>s!==i)}),onChange:(i,r)=>{const s=[...l];s[i]=r,a({...t,tokens:s})},renderRow:(i,r,s)=>e("div",{class:"dynamic-row-fields",style:{display:"flex",gap:"0.5rem",flex:1},children:[e(E,{label:`Address ${r+1}`,name:`token-addr-${r}`,value:i.address,onChange:o=>s(r,{...i,address:o}),placeholder:"Token mint/contract address",error:n[`tokens.${r}.address`],required:!0}),e(E,{label:"Symbol",name:`token-symbol-${r}`,value:i.symbol,onChange:o=>s(r,{...i,symbol:o}),placeholder:"e.g. USDC"}),e(E,{label:"Chain",name:`token-chain-${r}`,type:"select",value:i.chain,onChange:o=>{const u={...i,chain:o};o||delete u.chain,s(r,u)},options:lo})]}),addLabel:"+ Add Token",error:n.tokens})})}const ro=[{label:"All Chains",value:""},{label:"Solana",value:"solana"},{label:"Ethereum",value:"ethereum"}];function so({rules:t,onChange:a,errors:n}){const l=t.contracts||[];return e("div",{class:"policy-form-fields",children:e(Fe,{items:l,onAdd:()=>a({...t,contracts:[...l,{address:"",name:"",chain:""}]}),onRemove:i=>a({...t,contracts:l.filter((r,s)=>s!==i)}),onChange:(i,r)=>{const s=[...l];s[i]=r,a({...t,contracts:s})},renderRow:(i,r,s)=>e("div",{class:"dynamic-row-fields",style:{display:"flex",gap:"0.5rem",flex:1},children:[e(E,{label:`Address ${r+1}`,name:`contract-addr-${r}`,value:i.address,onChange:o=>s(r,{...i,address:o}),placeholder:"Contract address",error:n[`contracts.${r}.address`],required:!0}),e(E,{label:"Name",name:`contract-name-${r}`,value:i.name,onChange:o=>s(r,{...i,name:o}),placeholder:"e.g. Uniswap Router"}),e(E,{label:"Chain",name:`contract-chain-${r}`,type:"select",value:i.chain,onChange:o=>{const u={...i,chain:o};o||delete u.chain,s(r,u)},options:ro})]}),addLabel:"+ Add Contract",error:n.contracts})})}function oo({rules:t,onChange:a,errors:n}){const l=t.methods||[],i=r=>{a({...t,methods:r})};return e("div",{class:"policy-form-fields",children:e(Fe,{items:l,onAdd:()=>i([...l,{contractAddress:"",selectors:[""]}]),onRemove:r=>i(l.filter((s,o)=>o!==r)),onChange:(r,s)=>{const o=[...l];o[r]=s,i(o)},renderRow:(r,s,o)=>e("div",{style:{flex:1},children:[e(E,{label:`Contract Address ${s+1}`,name:`method-addr-${s}`,value:r.contractAddress,onChange:u=>o(s,{...r,contractAddress:u}),placeholder:"Contract address",error:n[`methods.${s}.contractAddress`],required:!0}),e("div",{style:{marginTop:"0.5rem",marginLeft:"1rem"},children:[e("label",{style:{fontSize:"0.85rem",fontWeight:500},children:"Selectors"}),e(Fe,{items:r.selectors,onAdd:()=>o(s,{...r,selectors:[...r.selectors,""]}),onRemove:u=>o(s,{...r,selectors:r.selectors.filter((d,v)=>v!==u)}),onChange:(u,d)=>{const v=[...r.selectors];v[u]=d,o(s,{...r,selectors:v})},renderRow:(u,d,v)=>e(E,{label:`Selector ${d+1}`,name:`method-sel-${s}-${d}`,value:u,onChange:h=>v(d,h),placeholder:"e.g. 0xa9059cbb or transfer(address,uint256)",error:n[`methods.${s}.selectors.${d}`],required:!0}),addLabel:"+ Add Selector",error:n[`methods.${s}.selectors`]})]})]}),addLabel:"+ Add Method Entry",error:n.methods})})}function co({rules:t,onChange:a,errors:n}){const l=t.spenders||[];return e("div",{class:"policy-form-fields",children:e(Fe,{items:l,onAdd:()=>a({...t,spenders:[...l,{address:"",name:"",maxAmount:""}]}),onRemove:i=>a({...t,spenders:l.filter((r,s)=>s!==i)}),onChange:(i,r)=>{const s=[...l];s[i]=r,r.maxAmount||delete s[i].maxAmount,a({...t,spenders:s})},renderRow:(i,r,s)=>e("div",{class:"dynamic-row-fields",style:{display:"flex",gap:"0.5rem",flex:1},children:[e(E,{label:`Address ${r+1}`,name:`spender-addr-${r}`,value:i.address,onChange:o=>s(r,{...i,address:o}),placeholder:"Spender address",error:n[`spenders.${r}.address`],required:!0}),e(E,{label:"Name",name:`spender-name-${r}`,value:i.name,onChange:o=>s(r,{...i,name:o}),placeholder:"e.g. Uniswap"}),e(E,{label:"Max Amount",name:`spender-max-${r}`,value:i.maxAmount||"",onChange:o=>s(r,{...i,maxAmount:o}),placeholder:"Leave empty for unlimited",error:n[`spenders.${r}.maxAmount`]})]}),addLabel:"+ Add Spender",error:n.spenders})})}const uo=Array.from({length:24},(t,a)=>({label:`${String(a).padStart(2,"0")}:00`,value:String(a)})),vo=Array.from({length:24},(t,a)=>({label:`${String(a+1).padStart(2,"0")}:00`,value:String(a+1)})),ho=[{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 po({rules:t,onChange:a,errors:n}){const l=t.allowed_hours||{start:0,end:24},i=t.allowed_days||[],r=o=>u=>{const d={...l,[o]:Number(u)};a({...t,allowed_hours:d})},s=o=>{const u=i.includes(o)?i.filter(d=>d!==o):[...i,o].sort((d,v)=>d-v);a({...t,allowed_days:u})};return e("div",{class:"policy-form-fields",children:[e("h4",{children:"Allowed Hours"}),e("div",{class:"policy-form-grid",children:[e(E,{label:"Start Hour",name:"allowed_hours_start",type:"select",value:String(l.start),onChange:r("start"),options:uo,error:n.allowed_hours}),e(E,{label:"End Hour",name:"allowed_hours_end",type:"select",value:String(l.end),onChange:r("end"),options:vo})]}),e("h4",{children:"Allowed Days"}),e("div",{style:{display:"flex",gap:"0.75rem",flexWrap:"wrap"},children:ho.map(o=>e("label",{style:{display:"flex",alignItems:"center",gap:"0.25rem",cursor:"pointer"},children:[e("input",{type:"checkbox",checked:i.includes(o.value),onChange:()=>s(o.value)}),o.label]},o.value))}),n.allowed_days&&e("span",{class:"form-error",children:n.allowed_days})]})}const mo=[{label:"solana-mainnet",value:"solana-mainnet"},{label:"solana-devnet",value:"solana-devnet"},{label:"solana-testnet",value:"solana-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 fo({rules:t,onChange:a,errors:n}){const l=t.networks||[];return e("div",{class:"policy-form-fields",children:e(Fe,{items:l,onAdd:()=>a({...t,networks:[...l,{network:"solana-mainnet",name:""}]}),onRemove:i=>a({...t,networks:l.filter((r,s)=>s!==i)}),onChange:(i,r)=>{const s=[...l];s[i]=r,a({...t,networks:s})},renderRow:(i,r,s)=>e("div",{class:"dynamic-row-fields",style:{display:"flex",gap:"0.5rem",flex:1},children:[e(E,{label:`Network ${r+1}`,name:`network-sel-${r}`,type:"select",value:i.network,onChange:o=>s(r,{...i,network:o}),options:mo,error:n[`networks.${r}.network`],required:!0}),e(E,{label:"Label",name:`network-name-${r}`,value:i.name,onChange:o=>s(r,{...i,name:o}),placeholder:"Optional label"})]}),addLabel:"+ Add Network",error:n.networks})})}function yo({rules:t,onChange:a,errors:n}){const l=t.domains||[];return e("div",{class:"policy-form-fields",children:e(Fe,{items:l,onAdd:()=>a({...t,domains:[...l,""]}),onRemove:i=>a({...t,domains:l.filter((r,s)=>s!==i)}),onChange:(i,r)=>{const s=[...l];s[i]=r,a({...t,domains:s})},renderRow:(i,r,s)=>e(E,{label:`Domain ${r+1}`,name:`domain-${r}`,value:i,onChange:o=>s(r,o),placeholder:"e.g. api.example.com or *.service.io",error:n[`domains.${r}`],required:!0}),addLabel:"+ Add Domain",error:n.domains})})}function go({rules:t,onChange:a,errors:n}){const l=t.domains||[];return e("div",{class:"policy-form-fields",children:e(Fe,{items:l,onAdd:()=>a({...t,domains:[...l,""]}),onRemove:i=>a({...t,domains:l.filter((r,s)=>s!==i)}),onChange:(i,r)=>{const s=[...l];s[i]=r,a({...t,domains:s})},renderRow:(i,r,s)=>e(E,{label:`Domain ${r+1}`,name:`domain-${r}`,value:i,onChange:o=>s(r,o),placeholder:"e.g. api.example.com or *.service.io",error:n[`domains.${r}`],required:!0}),addLabel:"+ Add Domain",error:n.domains})})}const ul=[{label:"Instant",value:"INSTANT"},{label:"Notify",value:"NOTIFY"},{label:"Delay",value:"DELAY"},{label:"Approval",value:"APPROVAL"}];function _o({rules:t,onChange:a,errors:n}){return e("div",{class:"policy-form-fields",children:[e(E,{label:"Minimum Score",name:"min_score",type:"number",value:t.min_score??50,onChange:l=>a({...t,min_score:Number(l)}),error:n.min_score,min:0,max:100,description:"Minimum reputation score threshold (0-100)"}),e(E,{label:"Below Threshold Tier",name:"below_threshold_tier",type:"select",value:t.below_threshold_tier??"APPROVAL",onChange:l=>a({...t,below_threshold_tier:l}),options:ul,error:n.below_threshold_tier,description:"Security tier when counterparty score is below minimum"}),e(E,{label:"Unrated Agent Tier",name:"unrated_tier",type:"select",value:t.unrated_tier??"APPROVAL",onChange:l=>a({...t,unrated_tier:l}),options:ul,error:n.unrated_tier,description:"Security tier when counterparty has no reputation data"}),e(E,{label:"Tag1 Filter",name:"tag1",type:"text",value:t.tag1??"",onChange:l=>a({...t,tag1:l}),error:n.tag1,placeholder:"Optional (max 32 chars)"}),e(E,{label:"Tag2 Filter",name:"tag2",type:"text",value:t.tag2??"",onChange:l=>a({...t,tag2:l}),error:n.tag2,placeholder:"Optional (max 32 chars)"}),e(E,{label:"Check Counterparty",name:"check_counterparty",type:"checkbox",value:!!t.check_counterparty,onChange:l=>a({...t,check_counterparty:l}),error:n.check_counterparty,description:"Also evaluate the reputation of the transaction recipient"})]})}function bo({rules:t,onChange:a,errors:n}){const l=t.venues||[];return e("div",{class:"policy-form-fields",children:e(Fe,{items:l,onAdd:()=>a({...t,venues:[...l,{id:"",name:""}]}),onRemove:i=>a({...t,venues:l.filter((r,s)=>s!==i)}),onChange:(i,r)=>{const s=[...l];s[i]=r,a({...t,venues:s})},renderRow:(i,r,s)=>e("div",{class:"dynamic-row-fields",style:{display:"flex",gap:"0.5rem",flex:1},children:[e(E,{label:`Venue ID ${r+1}`,name:`venue-id-${r}`,value:i.id,onChange:o=>s(r,{...i,id:o}),placeholder:"e.g. polymarket, hyperliquid",error:n[`venues.${r}.id`],required:!0}),e(E,{label:"Display Name",name:`venue-name-${r}`,value:i.name,onChange:o=>s(r,{...i,name:o}),placeholder:"Optional display name"})]}),addLabel:"+ Add Venue",error:n.venues})})}const wo=[{label:"Trade",value:"trade"},{label:"Withdraw",value:"withdraw"},{label:"Stake",value:"stake"},{label:"Lend",value:"lend"},{label:"Bridge",value:"bridge"},{label:"Swap",value:"swap"},{label:"Custom",value:"custom"}],To=[{label:"Instant",value:"INSTANT"},{label:"Notify",value:"NOTIFY"},{label:"Delay",value:"DELAY"},{label:"Approval",value:"APPROVAL"}];function So({rules:t,onChange:a,errors:n}){const l=t.category||"trade",i=t.per_action_limit_usd,r=t.daily_limit_usd,s=t.monthly_limit_usd,o=t.tier_on_exceed||"DELAY";return e("div",{class:"policy-form-fields",children:[e(E,{label:"Category",name:"category",type:"select",value:l,onChange:u=>a({...t,category:u}),options:wo,error:n.category,description:"Action category this limit applies to"}),e(E,{label:"Per-Action Limit (USD)",name:"per_action_limit_usd",type:"number",value:i??"",onChange:u=>{const d=Number(u);if(u===""||u===0){const{per_action_limit_usd:v,...h}=t;a(h)}else a({...t,per_action_limit_usd:d})},placeholder:"e.g. 1000",error:n.per_action_limit_usd,description:"Maximum USD value per single action (leave empty for no limit)",min:0}),e(E,{label:"Daily Limit (USD)",name:"daily_limit_usd",type:"number",value:r??"",onChange:u=>{const d=Number(u);if(u===""||u===0){const{daily_limit_usd:v,...h}=t;a(h)}else a({...t,daily_limit_usd:d})},placeholder:"e.g. 10000",error:n.daily_limit_usd,description:"Maximum cumulative USD per day (leave empty for no limit)",min:0}),e(E,{label:"Monthly Limit (USD)",name:"monthly_limit_usd",type:"number",value:s??"",onChange:u=>{const d=Number(u);if(u===""||u===0){const{monthly_limit_usd:v,...h}=t;a(h)}else a({...t,monthly_limit_usd:d})},placeholder:"e.g. 100000",error:n.monthly_limit_usd,description:"Maximum cumulative USD per month (leave empty for no limit)",min:0}),e(E,{label:"Tier on Exceed",name:"tier_on_exceed",type:"select",value:o,onChange:u=>a({...t,tier_on_exceed:u}),options:To,error:n.tier_on_exceed,description:"Security tier applied when limit is exceeded"})]})}function vl({type:t,rules:a,onChange:n,errors:l,network:i}){switch(t){case"SPENDING_LIMIT":return e(Qs,{rules:a,onChange:n,errors:l,network:i});case"WHITELIST":return e(Zs,{rules:a,onChange:n,errors:l});case"RATE_LIMIT":return e(eo,{rules:a,onChange:n,errors:l});case"APPROVE_AMOUNT_LIMIT":return e(ao,{rules:a,onChange:n,errors:l});case"APPROVE_TIER_OVERRIDE":return e(no,{rules:a,onChange:n,errors:l});case"ALLOWED_TOKENS":return e(io,{rules:a,onChange:n,errors:l});case"CONTRACT_WHITELIST":return e(so,{rules:a,onChange:n,errors:l});case"METHOD_WHITELIST":return e(oo,{rules:a,onChange:n,errors:l});case"APPROVED_SPENDERS":return e(co,{rules:a,onChange:n,errors:l});case"TIME_RESTRICTION":return e(po,{rules:a,onChange:n,errors:l});case"ALLOWED_NETWORKS":return e(fo,{rules:a,onChange:n,errors:l});case"X402_ALLOWED_DOMAINS":return e(yo,{rules:a,onChange:n,errors:l});case"ERC8128_ALLOWED_DOMAINS":return e(go,{rules:a,onChange:n,errors:l});case"REPUTATION_THRESHOLD":return e(_o,{rules:a,onChange:n,errors:l});case"VENUE_WHITELIST":return e(bo,{rules:a,onChange:n,errors:l});case"ACTION_CATEGORY_LIMIT":return e(So,{rules:a,onChange:n,errors:l});default:return e("p",{class:"policy-form-placeholder",children:"This policy type uses JSON editor. Toggle to JSON mode."})}}function yn(t){const a=typeof t=="string"?Number(t):t;return Number.isNaN(a)?String(t):a.toLocaleString("en-US")}function ko(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 en=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Eo(t){if(!t||t.length===0)return"";const a=[...t].sort((l,i)=>l-i);let n=!0;for(let l=1;l<a.length;l++)if(a[l]!==a[l-1]+1){n=!1;break}return n&&a.length>2?`${en[a[0]]}-${en[a[a.length-1]]}`:a.map(l=>en[l]??String(l)).join(", ")}function hl(t){return String(t).padStart(2,"0")}function No({rules:t}){const a=Number(t.instant_max_usd??t.instant_max??0),n=Number(t.notify_max_usd??t.notify_max??0),l=Number(t.delay_max_usd??t.delay_max??0),i=!!(t.instant_max_usd||t.notify_max_usd||t.delay_max_usd),r=Math.max(a,n,l,1),s=[{label:"Instant",value:t.instant_max_usd??t.instant_max,width:a/r*100,cls:"instant"},{label:"Notify",value:t.notify_max_usd??t.notify_max,width:n/r*100,cls:"notify"},{label:"Delay",value:t.delay_max_usd??t.delay_max,width:l/r*100,cls:"delay"},{label:"Approval",value:"",width:100,cls:"approval"}];return e("div",{class:"tier-bars",children:s.map(o=>e("div",{class:"tier-bar",children:[e("span",{class:"tier-bar-label",children:o.label}),e("div",{class:"tier-bar-track",children:e("div",{class:`tier-bar-fill tier-bar-fill--${o.cls}`,style:{width:`${o.width}%`}})}),e("span",{class:"tier-bar-value",children:o.value?`${i?"$":""}${yn(o.value)}`:""})]},o.cls))})}function pl(t){return t.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:2})}function Ao({rules:t}){const a=t.daily_limit_usd,n=t.monthly_limit_usd;return!a&&!n?null:e("div",{class:"cumulative-limits",children:[e("div",{class:"cumulative-limits-label",children:"Cumulative Limits"}),a&&e("div",{class:"cumulative-limit-row",children:[e("span",{class:"cumulative-limit-type",children:"Daily (24h)"}),e("span",{class:"cumulative-limit-value",children:["$",pl(a)]})]}),n&&e("div",{class:"cumulative-limit-row",children:[e("span",{class:"cumulative-limit-type",children:"Monthly (30d)"}),e("span",{class:"cumulative-limit-value",children:["$",pl(n)]})]})]})}const Co={INSTANT:"success",NOTIFY:"info",DELAY:"warning",APPROVAL:"danger"};function Io({type:t,rules:a}){switch(t){case"SPENDING_LIMIT":return e("div",{class:"spending-limit-summary",children:[e(No,{rules:a}),e(Ao,{rules:a})]});case"ALLOWED_TOKENS":{const n=a.tokens||[];return n.length===0?e("span",{class:"rules-vis-text",children:"No tokens"}):e("div",{class:"rules-vis-badges",children:n.map((l,i)=>e(Y,{variant:"info",children:l.symbol||(l.address?l.address.slice(0,8)+"...":"?")},i))})}case"RATE_LIMIT":{const n=a.max_requests,l=a.window_seconds;return e("span",{class:"rules-vis-text",children:[n," req / ",ko(l)]})}case"WHITELIST":{const n=a.allowed_addresses||[];return e(Y,{variant:"neutral",children:[n.length," addresses"]})}case"TIME_RESTRICTION":{const n=a.allowed_days||[],l=a.allowed_hours,i=Eo(n),r=l?`${hl(l.start)}:00-${hl(l.end)}:00`:"";return e("span",{class:"rules-vis-text",children:[i," ",r]})}case"CONTRACT_WHITELIST":{const n=a.contracts||[];if(n.length===0)return e("span",{class:"rules-vis-text",children:"No contracts"});const l=n.slice(0,3),i=n.length-3;return e("div",{class:"rules-vis-badges",children:[l.map((r,s)=>e(Y,{variant:"neutral",children:r.name||(r.address?r.address.slice(0,8)+"...":"?")},s)),i>0&&e(Y,{variant:"neutral",children:["+",i," more"]})]})}case"METHOD_WHITELIST":{const n=a.methods||[],l=n.length,i=n.reduce((r,s)=>r+(s.selectors?.length||0),0);return e(Y,{variant:"neutral",children:[l," contracts, ",i," methods"]})}case"APPROVED_SPENDERS":{const n=a.spenders||[];return e(Y,{variant:"neutral",children:[n.length," spenders"]})}case"APPROVE_AMOUNT_LIMIT":{const n=a.maxAmount,l=a.blockUnlimited;return n&&l?e("span",{class:"rules-vis-text",children:["Max: ",yn(n)," + Block unlimited"]}):n?e("span",{class:"rules-vis-text",children:["Max: ",yn(n)]}):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 n=a.tier||"DELAY",l=Co[n]||"neutral";return e(Y,{variant:l,children:n})}case"ALLOWED_NETWORKS":{const n=a.networks||[];if(n.length===0)return e("span",{class:"rules-vis-text",children:"No networks"});const l=n.slice(0,3),i=n.length-3;return e("div",{class:"rules-vis-badges",children:[l.map((r,s)=>e(Y,{variant:"info",children:r.network},s)),i>0&&e(Y,{variant:"info",children:["+",i," more"]})]})}case"X402_ALLOWED_DOMAINS":{const n=a.domains||[];if(n.length===0)return e("span",{class:"rules-vis-text",children:"No domains"});const l=n.slice(0,3),i=n.length-3;return e("div",{class:"rules-vis-badges",children:[l.map((r,s)=>e(Y,{variant:"neutral",children:r},s)),i>0&&e(Y,{variant:"neutral",children:["+",i," more"]})]})}default:{const n=JSON.stringify(a);return e("span",{class:"rules-summary",children:n.length>60?n.slice(0,60)+"...":n})}}}const hi=Object.entries(as).map(([t,a])=>({label:a,value:t})),an=ts,Ra={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:[]},ERC8128_ALLOWED_DOMAINS:{domains:[]},REPUTATION_THRESHOLD:{min_score:50,below_threshold_tier:"APPROVAL",unrated_tier:"APPROVAL",check_counterparty:!1},VENUE_WHITELIST:{venues:[{id:"",name:""}]},ACTION_CATEGORY_LIMIT:{category:"trade",per_action_limit_usd:1e3,daily_limit_usd:1e4,monthly_limit_usd:1e5,tier_on_exceed:"DELAY"}};function ht(t,a){const n={};if(t==="SPENDING_LIMIT"){a.instant_max&&!/^\d+$/.test(a.instant_max)&&(n.instant_max="Positive integer required"),a.notify_max&&!/^\d+$/.test(a.notify_max)&&(n.notify_max="Positive integer required"),a.delay_max&&!/^\d+$/.test(a.delay_max)&&(n.delay_max="Positive integer required");const l=!!(a.instant_max||a.notify_max||a.delay_max),i=!!(a.instant_max_usd||a.notify_max_usd||a.delay_max_usd),r=a.token_limits,s=r&&Object.keys(r).length>0;if(!l&&!i&&!s&&(n.__form="At least one of USD limits, token limits, or raw limits required"),r){const v=/^\d+(\.\d+)?$/;for(const[h,m]of Object.entries(r)){const b=m;if(!b||typeof b!="object")continue;b.instant_max&&!v.test(b.instant_max)&&(n[`token_limits.${h}.instant_max`]="Must be a non-negative decimal"),b.notify_max&&!v.test(b.notify_max)&&(n[`token_limits.${h}.notify_max`]="Must be a non-negative decimal"),b.delay_max&&!v.test(b.delay_max)&&(n[`token_limits.${h}.delay_max`]="Must be a non-negative decimal");const U=parseFloat(b.instant_max||"0"),W=parseFloat(b.notify_max||"0"),p=parseFloat(b.delay_max||"0");U>W&&(n[`token_limits.${h}.instant_max`]="Must be <= Notify Max"),W>p&&(n[`token_limits.${h}.notify_max`]="Must be <= Delay Max")}}const o=Number(a.delay_seconds);(a.delay_seconds===void 0||a.delay_seconds===""||Number.isNaN(o)||o<60)&&(n.delay_seconds="Minimum 60 seconds");const u=a.daily_limit_usd;if(u!==void 0&&u!==""){const v=Number(u);(Number.isNaN(v)||v<=0)&&(n.daily_limit_usd="Must be a positive number")}const d=a.monthly_limit_usd;if(d!==void 0&&d!==""){const v=Number(d);(Number.isNaN(v)||v<=0)&&(n.monthly_limit_usd="Must be a positive number")}}else if(t==="WHITELIST"){const l=a.allowed_addresses||[];l.length===0&&(n.allowed_addresses="At least one address required"),l.forEach((i,r)=>{(!i||i.trim()==="")&&(n[`allowed_addresses.${r}`]="Address required")})}else if(t==="RATE_LIMIT"){const l=Number(a.max_requests);(!a.max_requests||Number.isNaN(l)||l<1||!Number.isInteger(l))&&(n.max_requests="Positive integer required");const i=Number(a.window_seconds);(!a.window_seconds||Number.isNaN(i)||i<1||!Number.isInteger(i))&&(n.window_seconds="Positive integer required")}else if(t==="APPROVE_AMOUNT_LIMIT")a.maxAmount&&!/^\d+$/.test(a.maxAmount)&&(n.maxAmount="Must be a positive integer string");else if(t==="ALLOWED_TOKENS"){const l=a.tokens||[];l.length===0&&(n.tokens="At least one token required"),l.forEach((i,r)=>{(!i.address||i.address.trim()==="")&&(n[`tokens.${r}.address`]="Address required")})}else if(t==="CONTRACT_WHITELIST"){const l=a.contracts||[];l.length===0&&(n.contracts="At least one contract required"),l.forEach((i,r)=>{(!i.address||i.address.trim()==="")&&(n[`contracts.${r}.address`]="Address required")})}else if(t==="METHOD_WHITELIST"){const l=a.methods||[];l.length===0&&(n.methods="At least one method entry required"),l.forEach((i,r)=>{(!i.contractAddress||i.contractAddress.trim()==="")&&(n[`methods.${r}.contractAddress`]="Contract address required"),!i.selectors||i.selectors.length===0?n[`methods.${r}.selectors`]="At least one selector required":i.selectors.forEach((s,o)=>{(!s||s.trim()==="")&&(n[`methods.${r}.selectors.${o}`]="Selector required")})})}else if(t==="APPROVED_SPENDERS"){const l=a.spenders||[];l.length===0&&(n.spenders="At least one spender required"),l.forEach((i,r)=>{(!i.address||i.address.trim()==="")&&(n[`spenders.${r}.address`]="Address required"),i.maxAmount&&!/^\d+$/.test(i.maxAmount)&&(n[`spenders.${r}.maxAmount`]="Must be a positive integer")})}else if(t==="TIME_RESTRICTION"){(a.allowed_days||[]).length===0&&(n.allowed_days="At least one day required");const i=a.allowed_hours;i&&i.start>=i.end&&(n.allowed_hours="Start must be before end")}else if(t==="ALLOWED_NETWORKS"){const l=a.networks||[];l.length===0&&(n.networks="At least one network required"),l.forEach((i,r)=>{(!i.network||i.network.trim()==="")&&(n[`networks.${r}.network`]="Network required")})}else if(t==="X402_ALLOWED_DOMAINS"){const l=a.domains||[];l.length===0&&(n.domains="At least one domain required"),l.forEach((i,r)=>{(!i||i.trim()==="")&&(n[`domains.${r}`]="Domain required")})}return n}function xo(t,a){if(!t)return"Global";const n=a.find(l=>l.id===t);return n?n.name:t.slice(0,8)+"..."}function tn(t){const a=hi.find(n=>n.value===t);return a?a.label:t}const ml=[{key:"policies",label:"Rules"},{key:"defaults",label:"Defaults"}],nn=["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","policy.default_deny_erc8128_domains","policy.venue_whitelist_enabled"];function Do(){const t=c({}),a=c({}),n=c(!1),l=c(!0),i=async()=>{try{const{data:d}=await R.GET("/v1/admin/settings");t.value=d}catch(d){const v=d instanceof _?d:new _(0,"UNKNOWN","Unknown error");y("error",G(v.code))}finally{l.value=!1}};X(()=>{i()},[]);const r=(d,v)=>{const h=String(v);a.value={...a.value,[d]:h}},s=async()=>{n.value=!0;try{const d=Object.entries(a.value).filter(([h])=>nn.includes(h)).map(([h,m])=>({key:h,value:m})),{data:v}=await R.PUT("/v1/admin/settings",{body:{settings:d}});t.value=v.settings,a.value={},y("success","Policy defaults saved and applied")}catch(d){const v=d instanceof _?d:new _(0,"UNKNOWN","Unknown error");y("error",G(v.code))}finally{n.value=!1}},o=()=>{a.value={}};X(()=>(ze({id:"policies-defaults",isDirty:()=>Object.keys(a.value).filter(d=>nn.includes(d)).length>0,save:s,discard:o}),()=>Me("policies-defaults")),[]);const u=Object.keys(a.value).filter(d=>nn.includes(d)).length;return l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(le,{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(x,{variant:"ghost",size:"sm",onClick:o,children:"Discard"}),e(x,{variant:"primary",size:"sm",onClick:s,loading:n.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(E,{label:ce("policy_defaults_delay_seconds"),name:"security.policy_defaults_delay_seconds",type:"number",value:Number(pe(t.value,a.value,"security","policy_defaults_delay_seconds"))||0,onChange:d=>r("security.policy_defaults_delay_seconds",d),min:0,description:"Default delay before executing delayed-tier transactions"}),e(E,{label:ce("policy_defaults_approval_timeout"),name:"security.policy_defaults_approval_timeout",type:"number",value:Number(pe(t.value,a.value,"security","policy_defaults_approval_timeout"))||0,onChange:d=>r("security.policy_defaults_approval_timeout",d),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(E,{label:ce("default_deny_tokens"),name:"policy.default_deny_tokens",type:"checkbox",value:We(t.value,a.value,"policy","default_deny_tokens"),onChange:d=>r("policy.default_deny_tokens",d),description:"Deny token transfers unless a matching whitelist policy exists"}),e(E,{label:ce("default_deny_contracts"),name:"policy.default_deny_contracts",type:"checkbox",value:We(t.value,a.value,"policy","default_deny_contracts"),onChange:d=>r("policy.default_deny_contracts",d),description:"Deny contract calls unless a matching whitelist policy exists"}),e(E,{label:ce("default_deny_spenders"),name:"policy.default_deny_spenders",type:"checkbox",value:We(t.value,a.value,"policy","default_deny_spenders"),onChange:d=>r("policy.default_deny_spenders",d),description:"Deny token approvals unless a matching whitelist policy exists"}),e(E,{label:ce("default_deny_x402_domains"),name:"policy.default_deny_x402_domains",type:"checkbox",value:We(t.value,a.value,"policy","default_deny_x402_domains"),onChange:d=>r("policy.default_deny_x402_domains",d),description:"Deny x402 payments unless a matching domain whitelist policy exists"}),e(E,{label:ce("default_deny_erc8128_domains"),name:"policy.default_deny_erc8128_domains",type:"checkbox",value:We(t.value,a.value,"policy","default_deny_erc8128_domains"),onChange:d=>r("policy.default_deny_erc8128_domains",d),description:"Deny ERC-8128 signing unless a matching domain whitelist policy exists"}),e(E,{label:ce("venue_whitelist_enabled"),name:"policy.venue_whitelist_enabled",type:"checkbox",value:We(t.value,a.value,"policy","venue_whitelist_enabled"),onChange:d=>r("policy.venue_whitelist_enabled",d),description:"Enable venue whitelist: deny external actions from non-whitelisted venues"})]})]}),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 Ro(){const t=c("policies");X(()=>{const K=me.value;K&&K.tab&&(t.value=K.tab,setTimeout(()=>{Pe.value=K.fieldName},100),me.value=null)},[me.value]);const a=c([]),n=c([]),l=c("__all__"),i=c(!1),r=c(!0),s=c(!1),o=c("SPENDING_LIMIT"),u=c(""),d=c(JSON.stringify(Ra.SPENDING_LIMIT,null,2)),v=c(Ra.SPENDING_LIMIT),h=c({}),m=c(!1),b=c(0),U=c(!0),W=c(""),p=c(null),T=c(!1),D=c(!1),M=c(null),O=c(""),q=c({}),S=c(!1),C=c({}),N=c(0),k=c(!0),V=c(null),w=c(!1),H=c(!1),Z=c(null),A=c(!1),B=async()=>{try{const{data:K}=await R.GET("/v1/wallets");a.value=K.items}catch(K){const oe=K instanceof _?K:new _(0,"UNKNOWN","Unknown error");y("error",G(oe.code))}finally{r.value=!1}},I=async()=>{i.value=!0;try{const K=l.value!=="__all__"&&l.value!=="__global__"?{walletId:l.value}:void 0,{data:oe}=await R.GET("/v1/policies",{params:{query:K}}),Ce=oe.data??oe;l.value==="__global__"?n.value=Ce.filter($e=>$e.walletId===null):n.value=Ce}catch(K){const oe=K instanceof _?K:new _(0,"UNKNOWN","Unknown error");y("error",G(oe.code))}finally{i.value=!1}},g=async()=>{p.value=null;let K;if(m.value)try{K=JSON.parse(d.value)}catch{p.value="Invalid JSON in rules field";return}else{const oe=ht(o.value,v.value);if(Object.keys(oe).length>0){h.value=oe;return}h.value={},K=v.value}T.value=!0;try{await R.POST("/v1/policies",{body:{walletId:u.value||void 0,type:o.value,rules:K,priority:b.value,enabled:U.value,network:W.value||void 0}}),y("success","Policy created"),s.value=!1,o.value="SPENDING_LIMIT",u.value="",W.value="",d.value=JSON.stringify(Ra.SPENDING_LIMIT,null,2),v.value=Ra.SPENDING_LIMIT,h.value={},m.value=!1,b.value=0,U.value=!0,p.value=null,await I()}catch(oe){const Ee=oe instanceof _?oe:new _(0,"UNKNOWN","Unknown error");y("error",G(Ee.code))}finally{T.value=!1}},F=K=>{M.value=K,O.value=JSON.stringify(K.rules,null,2),q.value={...K.rules},S.value=!1,C.value={},N.value=K.priority,k.value=K.enabled,V.value=null,D.value=!0},j=async()=>{V.value=null;let K;if(S.value)try{K=JSON.parse(O.value)}catch{V.value="Invalid JSON in rules field";return}else{const oe=ht(M.value.type,q.value);if(Object.keys(oe).length>0){C.value=oe;return}C.value={},K=q.value}w.value=!0;try{await R.PUT("/v1/policies/{id}",{params:{path:{id:M.value.id}},body:{rules:K,priority:N.value,enabled:k.value}}),y("success","Policy updated"),D.value=!1,await I()}catch(oe){const Ee=oe instanceof _?oe:new _(0,"UNKNOWN","Unknown error");y("error",G(Ee.code))}finally{w.value=!1}},J=()=>{if(!S.value)O.value=JSON.stringify(q.value,null,2);else try{q.value=JSON.parse(O.value),V.value=null}catch{V.value="Invalid JSON — cannot switch to form mode";return}S.value=!S.value},L=K=>{Z.value=K,H.value=!0},Q=async()=>{A.value=!0;try{await R.DELETE("/v1/policies/{id}",{params:{path:{id:Z.value.id}}}),y("success","Policy deleted"),H.value=!1,await I()}catch(K){const oe=K instanceof _?K:new _(0,"UNKNOWN","Unknown error");y("error",G(oe.code))}finally{A.value=!1}},re=K=>{const oe=K;o.value=oe;const Ee=Ra[oe];Ee&&(d.value=JSON.stringify(Ee,null,2),v.value={...Ee}),h.value={},m.value=!1},ee=()=>{if(!m.value)d.value=JSON.stringify(v.value,null,2);else try{v.value=JSON.parse(d.value),p.value=null}catch{p.value="Invalid JSON — cannot switch to form mode";return}m.value=!m.value};X(()=>{B()},[]),X(()=>{I()},[l.value]);const _e=[{key:"type",header:"Type",render:K=>e(Y,{variant:K.type==="SPENDING_LIMIT"?"success":"info",children:tn(K.type)})},{key:"walletId",header:"Wallet",render:K=>xo(K.walletId,a.value)},{key:"network",header:"Network",render:K=>K.network??"All"},{key:"rules",header:"Rules",render:K=>e(Io,{type:K.type,rules:K.rules})},{key:"priority",header:"Priority"},{key:"enabled",header:"Enabled",render:K=>e(Y,{variant:K.enabled?"success":"danger",children:K.enabled?"ON":"OFF"})},{key:"actions",header:"Actions",render:K=>e("span",{style:{display:"flex",gap:"0.25rem"},children:[e("button",{class:"btn btn-ghost btn-sm",onClick:oe=>{oe.stopPropagation(),F(K)},children:"Edit"}),e(x,{size:"sm",variant:"danger",onClick:()=>L(K),children:"Delete"})]})}];return e("div",{class:"page",children:[e(fa,{pageName:"Policies",tabName:ml.find(K=>K.key===t.value)?.label??"",onPageClick:()=>{t.value="policies"}}),e(Oe,{tabs:ml,activeTab:t.value,onTabChange:K=>{t.value=K}}),t.value==="policies"&&e(le,{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:K=>{l.value=K.target.value},disabled:r.value,children:[e("option",{value:"__all__",children:"All Policies"}),e("option",{value:"__global__",children:"Global Only"}),a.value.map(K=>e("option",{value:K.id,children:[K.name," (",K.chain,"/",K.network,")"]},K.id))]})]}),!s.value&&e(x,{onClick:()=>{s.value=!0},children:"Create Policy"})]}),s.value&&e("div",{class:"inline-form",children:[e(E,{label:"Type",name:"type",type:"select",value:o.value,onChange:re,options:hi,description:an[o.value]??""}),e(E,{label:"Wallet",name:"walletId",type:"select",value:u.value,onChange:K=>{u.value=K},options:[{label:"Global (no wallet)",value:""},...a.value.map(K=>({label:`${K.name} (${K.chain}/${K.network})`,value:K.id}))]}),e(E,{label:"Network Scope",name:"network",value:W.value,onChange:K=>{W.value=K},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:ee,children:m.value?"Switch to Form":"JSON Direct Edit"})]}),m.value?e(E,{label:"",name:"rules",type:"textarea",value:d.value,onChange:K=>{d.value=K},error:p.value??void 0}):e(vl,{type:o.value,rules:v.value,onChange:K=>{v.value=K,Object.keys(h.value).length>0&&(h.value=ht(o.value,K))},errors:h.value,network:W.value})]}),e(E,{label:"Priority",name:"priority",type:"number",value:b.value,onChange:K=>{b.value=K},min:0,max:999}),e(E,{label:"Enabled",name:"enabled",type:"checkbox",value:U.value,onChange:K=>{U.value=K}}),e("div",{class:"inline-form-actions",children:[e(x,{onClick:g,loading:T.value,children:"Create"}),e(x,{variant:"secondary",onClick:()=>{s.value=!1,p.value=null},children:"Cancel"})]})]}),e(Le,{columns:_e,data:n.value,loading:i.value,emptyMessage:"No policies found"}),e(he,{open:D.value,title:"Edit Policy",onCancel:()=>{D.value=!1},onConfirm:j,confirmText:"Save",loading:w.value,children:M.value&&e("div",{children:[e("div",{class:"policy-type-readonly",children:["Type: ",tn(M.value.type),an[M.value.type]&&e("span",{class:"form-description",children:an[M.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:J,children:S.value?"Switch to Form":"JSON Direct Edit"})]}),S.value?e("div",{class:"edit-rules-textarea",children:e(E,{label:"",name:"edit-rules",type:"textarea",value:O.value,onChange:K=>{O.value=K},error:V.value??void 0})}):e(vl,{type:M.value.type,rules:q.value,onChange:K=>{q.value=K,Object.keys(C.value).length>0&&(C.value=ht(M.value.type,K))},errors:C.value,network:M.value.network??""})]}),e(E,{label:"Priority",name:"edit-priority",type:"number",value:N.value,onChange:K=>{N.value=K},min:0,max:999}),e(E,{label:"Enabled",name:"edit-enabled",type:"checkbox",value:k.value,onChange:K=>{k.value=K}})]})}),e(he,{open:H.value,title:"Delete Policy",onCancel:()=>{H.value=!1},onConfirm:Q,confirmText:"Delete",confirmVariant:"danger",loading:A.value,children:Z.value&&e("p",{children:["Are you sure you want to delete this"," ",e("strong",{children:tn(Z.value.type)})," policy? This action cannot be undone."]})})]}),t.value==="defaults"&&e(Do,{})]})}function Lo(){return e(Po,{})}function Po(){const t=c([]),a=c(!0),n=c(!1),l=c(null),i=c("ADMIN"),r=c(!1),s=c(!1),o=c(null),u=c(!1),d=async()=>{a.value=!0;try{const{data:p}=await R.GET("/v1/admin/telegram-users");t.value=p.users}catch(p){const T=p instanceof _?p:new _(0,"UNKNOWN","Unknown error");y("error",G(T.code))}finally{a.value=!1}};X(()=>{d()},[]);const v=p=>{l.value=p,i.value="ADMIN",n.value=!0},h=async()=>{if(l.value){r.value=!0;try{await R.PUT("/v1/admin/telegram-users/{chatId}",{params:{path:{chatId:l.value.chat_id}},body:{role:i.value}}),y("success",`User approved as ${i.value}`),n.value=!1,l.value=null,await d()}catch(p){const T=p instanceof _?p:new _(0,"UNKNOWN","Unknown error");y("error",G(T.code))}finally{r.value=!1}}},m=p=>{o.value=p,s.value=!0},b=async()=>{if(o.value){u.value=!0;try{await R.DELETE("/v1/admin/telegram-users/{chatId}",{params:{path:{chatId:o.value.chat_id}}}),y("success","User deleted"),s.value=!1,o.value=null,await d()}catch(p){const T=p instanceof _?p:new _(0,"UNKNOWN","Unknown error");y("error",G(T.code))}finally{u.value=!1}}},U=p=>p==="PENDING"?"warning":p==="ADMIN"?"success":"info";return e("div",{class:"page",children:[e(Le,{columns:[{key:"chat_id",header:"Chat ID",render:p=>String(p.chat_id)},{key:"username",header:"Username",render:p=>p.username??"-"},{key:"role",header:"Role",render:p=>e(Y,{variant:U(p.role),children:p.role})},{key:"registered_at",header:"Registered",render:p=>ve(p.registered_at)},{key:"approved_at",header:"Approved",render:p=>p.approved_at?ve(p.approved_at):"-"},{key:"actions",header:"Actions",render:p=>e("div",{style:{display:"flex",gap:"var(--space-1)"},children:[p.role==="PENDING"&&e(x,{size:"sm",variant:"primary",onClick:()=>v(p),children:"Approve"}),e(x,{size:"sm",variant:"danger",onClick:()=>m(p),children:"Delete"})]})}],data:t.value,loading:a.value,emptyMessage:"No Telegram users registered. Users appear here after sending /start to the bot."}),e(he,{open:n.value,title:"Approve Telegram User",onCancel:()=>{n.value=!1,l.value=null},onConfirm:h,confirmText:"Approve",confirmVariant:"primary",loading:r.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:p=>{i.value=p.target.value},children:[e("option",{value:"ADMIN",children:"ADMIN"}),e("option",{value:"READONLY",children:"READONLY"})]})]})]})}),e(he,{open:s.value,title:"Delete Telegram User",onCancel:()=>{s.value=!1,o.value=null},onConfirm:b,confirmText:"Delete",confirmVariant:"danger",loading:u.value,children:e("p",{children:"Are you sure you want to remove this user? They will need to /start again to re-register."})})]})}const ln=20,fl=[{key:"channels",label:"Channels & Logs"},{key:"telegram",label:"Telegram Users"},{key:"settings",label:"Settings"},{key:"balance",label:"Balance Monitor"}],Oo=[{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:"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 Uo(){const t=c({}),a=c({}),n=c(!1),l=c(!0),i=c([]),r=c(!1),s=async()=>{try{const{data:m}=await R.GET("/v1/admin/settings");t.value=m}catch(m){const b=m instanceof _?m:new _(0,"UNKNOWN","Unknown error");y("error",G(b.code))}finally{l.value=!1}};X(()=>{s()},[]);const o=(m,b)=>{const U=String(b);a.value={...a.value,[m]:U}},u=async()=>{n.value=!0;try{const m=Object.entries(a.value).filter(([U])=>U.startsWith("notifications.")||U.startsWith("telegram.")).map(([U,W])=>({key:U,value:W})),{data:b}=await R.PUT("/v1/admin/settings",{body:{settings:m}});t.value=b.settings,a.value={},y("success","Notification settings saved and applied")}catch(m){const b=m instanceof _?m:new _(0,"UNKNOWN","Unknown error");y("error",G(b.code))}finally{n.value=!1}},d=()=>{a.value={}};X(()=>(ze({id:"notifications-settings",isDirty:()=>Object.keys(a.value).filter(m=>m.startsWith("notifications.")||m.startsWith("telegram.")).length>0,save:u,discard:d}),()=>Me("notifications-settings")),[]);const v=async()=>{r.value=!0,i.value=[];try{const{data:m}=await R.POST("/v1/admin/notifications/test",{});if(i.value=m.results,m.results.length===0)y("info","No notification channels configured");else{const b=m.results.every(U=>U.success);y(b?"success":"warning",b?"All test notifications sent":"Some channels failed")}}catch(m){const b=m instanceof _?m:new _(0,"UNKNOWN","Unknown error");y("error",G(b.code))}finally{r.value=!1}},h=Object.keys(a.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(le,{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(x,{variant:"ghost",size:"sm",onClick:d,children:"Discard"}),e(x,{variant:"primary",size:"sm",onClick:u,loading:n.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(E,{label:"Enabled",name:"notifications.enabled",type:"checkbox",value:We(t.value,a.value,"notifications","enabled"),onChange:m=>o("notifications.enabled",m),description:"Enable or disable notifications globally"})}),e(E,{label:ce("locale"),name:"notifications.locale",type:"select",value:pe(t.value,a.value,"notifications","locale")||"en",onChange:m=>o("notifications.locale",m),options:[{label:"English",value:"en"},{label:"Korean",value:"ko"}],description:"Language for notification messages"})]}),e(va,{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(E,{label:ce("telegram_bot_token"),name:"notifications.telegram_bot_token",type:"password",value:pe(t.value,a.value,"notifications","telegram_bot_token"),onChange:m=>o("notifications.telegram_bot_token",m),placeholder:Oa(t.value,a.value,"notifications","telegram_bot_token")?"(configured)":"",description:"Bot token for Telegram notifications"}),e(E,{label:ce("telegram_chat_id"),name:"notifications.telegram_chat_id",type:"text",value:pe(t.value,a.value,"notifications","telegram_chat_id"),onChange:m=>o("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(E,{label:ce("bot_token"),name:"telegram.bot_token",type:"password",value:pe(t.value,a.value,"telegram","bot_token"),onChange:m=>o("telegram.bot_token",m),placeholder:Oa(t.value,a.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(E,{label:"Locale",name:"telegram.locale",type:"select",value:pe(t.value,a.value,"telegram","locale")||"en",onChange:m=>o("telegram.locale",m),options:[{label:"English",value:"en"},{label:"한국어",value:"ko"}],description:"Language for Telegram bot messages"})]})]})]}),e(va,{legend:"Other Channels",description:"Discord, 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:"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(E,{label:ce("discord_webhook_url"),name:"notifications.discord_webhook_url",type:"password",value:pe(t.value,a.value,"notifications","discord_webhook_url"),onChange:m=>o("notifications.discord_webhook_url",m),placeholder:Oa(t.value,a.value,"notifications","discord_webhook_url")?"(configured)":"",description:"Webhook URL for Discord notifications"}),e(E,{label:"Slack Webhook URL",name:"notifications.slack_webhook_url",type:"password",value:pe(t.value,a.value,"notifications","slack_webhook_url"),onChange:m=>o("notifications.slack_webhook_url",m),placeholder:Oa(t.value,a.value,"notifications","slack_webhook_url")?"(configured)":"",description:"Webhook URL for Slack notifications"}),e(E,{label:ce("rate_limit_rpm"),name:"notifications.rate_limit_rpm",type:"number",value:Number(pe(t.value,a.value,"notifications","rate_limit_rpm"))||20,onChange:m=>o("notifications.rate_limit_rpm",m),min:1,max:1e3,description:"Max notifications per minute"})]})]}),e(va,{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"]),b=[{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"}]}],U=b.flatMap(O=>O.events.map(q=>q.event)).filter(O=>!m.has(O)),W=pe(t.value,a.value,"notifications","notify_events")||"[]";let p=[];try{const O=JSON.parse(W);Array.isArray(O)&&(p=O)}catch{}const T=p.length===0?U:p,D=(O,q)=>{const S=q?[...T,O]:T.filter(N=>N!==O),C=S.length===U.length&&U.every(N=>S.includes(N))?[]:S;o("notifications.notify_events",JSON.stringify(C))},M=(O,q)=>{const S=O.events.filter(k=>!m.has(k.event)).map(k=>k.event);let C;if(q)C=[...new Set([...T,...S])];else{const k=new Set(S);C=T.filter(V=>!k.has(V))}const N=C.length===U.length&&U.every(k=>C.includes(k))?[]:C;o("notifications.notify_events",JSON.stringify(N))};return e("div",{class:"event-filter-groups",children:b.map(O=>{const q=O.events.filter(N=>!m.has(N.event)),S=q.every(N=>T.includes(N.event)),C=q.some(N=>T.includes(N.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:O.label}),e("label",{class:"event-filter-group-all",onClick:N=>N.stopPropagation(),children:[e("input",{type:"checkbox",checked:S,ref:N=>{N&&(N.indeterminate=C&&!S)},onChange:N=>M(O,N.target.checked)})," All"]})]}),e("div",{class:"event-filter-events",children:O.events.map(N=>{const k=m.has(N.event);return e("label",{class:`event-filter-event ${k?"event-broadcast":""}`,children:[e("input",{type:"checkbox",checked:k||T.includes(N.event),disabled:k,onChange:V=>D(N.event,V.target.checked)}),e("code",{children:N.event}),e("span",{class:"event-desc",children:N.desc}),k&&e("span",{class:"event-broadcast-badge",children:"Always sent"})]},N.event)})})]},O.category)})})})(),e("div",{class:"settings-info-box",style:{marginTop:"0.5rem"},children:"Applies to all notification channels (Telegram, Discord, 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(x,{variant:"secondary",size:"sm",onClick:v,loading:r.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(Y,{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 yl={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 Wo(){const t=c({}),a=c({}),n=c(!1),l=c(!0),i=async()=>{try{const{data:v}=await R.GET("/v1/admin/settings");t.value=v}catch(v){const h=v instanceof _?v:new _(0,"UNKNOWN","Unknown error");y("error",G(h.code))}finally{l.value=!1}};X(()=>{i()},[]);const r=(v,h)=>{const m=String(h);a.value={...a.value,[v]:m}},s=async()=>{n.value=!0;try{const v=Object.entries(a.value).filter(([m])=>m.startsWith("monitoring.")).map(([m,b])=>({key:m,value:b})),{data:h}=await R.PUT("/v1/admin/settings",{body:{settings:v}});t.value=h.settings,a.value={},y("success","Settings saved and applied")}catch(v){const h=v instanceof _?v:new _(0,"UNKNOWN","Unknown error");y("error",G(h.code))}finally{n.value=!1}},o=()=>{a.value={}};X(()=>(ze({id:"notifications-balance",isDirty:()=>Object.keys(a.value).filter(v=>v.startsWith("monitoring.")).length>0,save:s,discard:o}),()=>Me("notifications-balance")),[]);const u=[{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}],d=Object.keys(a.value).filter(v=>v.startsWith("monitoring.")).length;return l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(le,{children:[d>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[d," unsaved change",d>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(x,{variant:"ghost",size:"sm",onClick:o,children:"Discard"}),e(x,{variant:"primary",size:"sm",onClick:s,loading:n.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:u.map(v=>v.type==="checkbox"?e("div",{class:"settings-field-full",children:e(E,{label:ce(v.key),name:`monitoring.${v.key}`,type:"checkbox",value:We(t.value,a.value,"monitoring",v.key),onChange:h=>r(`monitoring.${v.key}`,h),description:yl[v.key]})},v.key):e(E,{label:ce(v.key),name:`monitoring.${v.key}`,type:"number",value:Number(pe(t.value,a.value,"monitoring",v.key))||0,onChange:h=>r(`monitoring.${v.key}`,h),min:v.min,max:v.max,description:yl[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 gl(){const t=c("channels");X(()=>{const C=me.value;C&&C.tab&&(t.value=C.tab,setTimeout(()=>{Pe.value=C.fieldName},100),me.value=null)},[me.value]);const a=c(null),n=c(!0),l=c(!1),i=c(null),r=c(null),s=c(null),o=c(!0),u=c(1),d=c(null),v=c({eventType:"",channel:"",status:"",since:"",until:""}),h=async()=>{try{const{data:C}=await R.GET("/v1/admin/notifications/status");a.value=C}catch(C){const N=C instanceof _?C:new _(0,"UNKNOWN","Unknown error");y("error",G(N.code))}finally{n.value=!1}},m=async C=>{o.value=!0;try{const N=new URLSearchParams;N.set("page",String(C)),N.set("pageSize",String(ln));const k=v.value;if(k.eventType&&N.set("eventType",k.eventType),k.channel&&N.set("channel",k.channel),k.status&&N.set("status",k.status),k.since){const H=new Date(k.since);isNaN(H.getTime())||N.set("since",String(Math.floor(H.getTime()/1e3)))}if(k.until){const H=new Date(k.until);isNaN(H.getTime())||(H.setHours(23,59,59,999),N.set("until",String(Math.floor(H.getTime()/1e3))))}const V={};N.forEach((H,Z)=>{V[Z]=H});const{data:w}=await R.GET("/v1/admin/notifications/log",{params:{query:V}});s.value=w}catch(N){const k=N instanceof _?N:new _(0,"UNKNOWN","Unknown error");y("error",G(k.code))}finally{o.value=!1}},b=async()=>{l.value=!0,r.value=null;try{const{data:C}=await R.POST("/v1/admin/notifications/test",{}),N=C.results;r.value=N,N.every(V=>V.success)?y("success","Test sent successfully"):y("warning","Some channels failed")}catch(C){const N=C instanceof _?C:new _(0,"UNKNOWN","Unknown error");y("error",G(N.code))}finally{l.value=!1}},U=async C=>{i.value=C,r.value=null;try{const{data:N}=await R.POST("/v1/admin/notifications/test",{body:{channel:C}}),k=N.results;r.value=k,k.every(w=>w.success)?y("success",`Test sent to ${C}`):y("warning",`${C} test failed`)}catch(N){const k=N instanceof _?N:new _(0,"UNKNOWN","Unknown error");y("error",G(k.code))}finally{i.value=null}},W=()=>{u.value>1&&(u.value-=1,m(u.value))},p=()=>{const C=s.value?Math.ceil(s.value.total/ln):1;u.value<C&&(u.value+=1,m(u.value))},T=C=>{d.value=d.value?.id===C.id?null:C},D=C=>{v.value=C,u.value=1,m(1)};X(()=>{h(),m(1);const C=setInterval(()=>m(u.value),di);return()=>clearInterval(C)},[]);const M=n.value&&!a.value,O=a.value?.channels.some(C=>C.enabled)??!1,q=s.value?Math.max(1,Math.ceil(s.value.total/ln)):1,S=[{key:"eventType",header:"Event Type"},{key:"walletId",header:"Wallet ID",render:C=>C.walletId?e("a",{href:`#/wallets/${C.walletId}`,class:"wallet-link",onClick:N=>N.stopPropagation(),title:C.walletId,children:[C.walletId.slice(0,8),"..."]}):"—"},{key:"channel",header:"Channel",render:C=>e("span",{style:{textTransform:"capitalize"},children:C.channel})},{key:"status",header:"Status",render:C=>e(Y,{variant:C.status==="sent"?"success":"danger",children:C.status})},{key:"createdAt",header:"Time",render:C=>ve(C.createdAt)}];return e("div",{class:"page",children:[e(fa,{pageName:"Notifications",tabName:fl.find(C=>C.key===t.value)?.label??"",onPageClick:()=>{t.value="channels"}}),e(Oe,{tabs:fl,activeTab:t.value,onTabChange:C=>{t.value=C}}),t.value==="telegram"?e(Lo,{}):t.value==="settings"?e(Uo,{}):t.value==="balance"?e(Wo,{}):e(le,{children:[e("h2",{children:"Channel Status"}),a.value&&!a.value.enabled&&e("div",{class:"notif-disabled-banner",children:["Notifications are disabled."," ",e("a",{href:"#",onClick:C=>{C.preventDefault(),t.value="settings"},children:"Enable them in the Settings tab"})]}),M?e("div",{class:"channel-grid",children:[1,2,3].map(C=>e("div",{class:"channel-card",children:e("div",{class:"stat-skeleton"})},C))}):e("div",{class:"channel-grid",children:a.value?.channels.map(C=>e("div",{class:"channel-card",children:e("div",{class:"channel-card-header",children:[e("span",{class:"channel-card-name",children:C.name}),e("div",{class:"channel-card-actions",children:[e(Y,{variant:C.enabled?"success":"neutral",children:C.enabled?C.configuredWallets!=null?`${C.configuredWallets} wallet${C.configuredWallets!==1?"s":""} configured`:"Connected":"Not Configured"}),C.enabled&&e(x,{variant:"secondary",size:"sm",onClick:()=>U(C.name),loading:i.value===C.name,children:"Test"})]})]})},C.name))}),e("div",{style:{marginTop:"var(--space-4)",marginBottom:"var(--space-6)"},children:[e(x,{onClick:b,loading:l.value,disabled:!O,children:"Test All Channels"}),r.value&&e("div",{class:"test-results",children:r.value.map(C=>e("div",{class:"test-result-item",children:[e("span",{class:C.success?"test-result-success":"test-result-failure",children:C.success?"✓":"✗"}),e("span",{style:{textTransform:"capitalize"},children:C.channel}),!C.success&&C.error&&e("span",{class:"test-result-failure",children:[" - ",C.error]})]},C.channel))})]}),e("h2",{children:"Delivery Log"}),e(ja,{fields:Oo,values:v.value,onChange:D,syncUrl:!1}),e(Le,{columns:S,data:s.value?.logs??[],loading:o.value,emptyMessage:"No notification logs",onRowClick:T}),d.value&&e("div",{class:"log-message-detail",children:[e("div",{class:"log-message-detail-header",children:[e("strong",{children:d.value.eventType})," via ",e("span",{style:{textTransform:"capitalize"},children:d.value.channel}),e(x,{variant:"ghost",size:"sm",onClick:()=>{d.value=null},children:"Close"})]}),e("div",{class:"log-message-detail-body",children:d.value.message?e("pre",{style:{whiteSpace:"pre-wrap",margin:0,fontSize:"var(--font-size-sm)"},children:d.value.message}):e("span",{class:"text-muted",children:"(No message recorded)"})})]}),e("div",{class:"pagination",children:[e("span",{class:"pagination-info",children:["Page ",u.value," of ",q,s.value?` (${s.value.total} total)`:""]}),e("div",{class:"pagination-buttons",children:[e(x,{variant:"secondary",size:"sm",onClick:W,disabled:u.value<=1,children:"Previous"}),e(x,{variant:"secondary",size:"sm",onClick:p,disabled:u.value>=q,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 rn=[{key:"killswitch",label:"Kill Switch"},{key:"autostop",label:"AutoStop Rules"},{key:"jwt",label:"Invalidate Sessions"},{key:"password",label:"Master Password"}];function Mo(){const t=c(null),a=c(!0),n=c(!1),l=async()=>{try{const{data:h}=await R.GET("/v1/admin/kill-switch");t.value=h}catch(h){const m=h instanceof _?h:new _(0,"UNKNOWN","Unknown error");y("error",G(m.code))}finally{a.value=!1}};X(()=>{l()},[]);const i=async()=>{n.value=!0;try{await R.POST("/v1/admin/kill-switch"),y("success","Kill switch activated - all operations suspended"),await l()}catch(h){const m=h instanceof _?h:new _(0,"UNKNOWN","Unknown error");y("error",G(m.code))}finally{n.value=!1}},r=async()=>{n.value=!0;try{await R.POST("/v1/admin/kill-switch/escalate"),y("success","Kill switch escalated to LOCKED"),await l()}catch(h){const m=h instanceof _?h:new _(0,"UNKNOWN","Unknown error");y("error",G(m.code))}finally{n.value=!1}},s=async()=>{n.value=!0;try{await R.POST("/v1/admin/recover"),y("success","Kill switch recovered - operations resumed"),await l()}catch(h){const m=h instanceof _?h:new _(0,"UNKNOWN","Unknown error");y("error",G(m.code))}finally{n.value=!1}},o=t.value,u=o?.state==="ACTIVE",d=o?.state==="SUSPENDED",v=o?.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:a.value?e("span",{children:"Loading..."}):o?e(le,{children:[e("div",{class:"ks-state-card",style:{marginBottom:"var(--space-4)"},children:[e(Y,{variant:u?"success":v?"danger":"warning",children:o.state}),!u&&o.activatedAt&&e("span",{class:"ks-state-info",children:["Since ",ve(o.activatedAt),o.activatedBy?` by ${o.activatedBy}`:""]})]}),e("div",{style:{display:"flex",gap:"var(--space-2)",flexWrap:"wrap"},children:[u&&e(x,{variant:"danger",onClick:i,loading:n.value,children:"Activate Kill Switch"}),d&&e(le,{children:[e(x,{variant:"primary",onClick:s,loading:n.value,children:"Recover"}),e(x,{variant:"danger",onClick:r,loading:n.value,children:"Escalate to LOCKED"})]}),v&&e(x,{variant:"primary",onClick:s,loading:n.value,children:"Recover from LOCKED (5s wait)"})]}),d&&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 $o(){const t=c({}),a=c({}),n=c(!1),l=c(!0),i=async()=>{try{const{data:d}=await R.GET("/v1/admin/settings");t.value=d}catch(d){const v=d instanceof _?d:new _(0,"UNKNOWN","Unknown error");y("error",G(v.code))}finally{l.value=!1}};X(()=>{i()},[]);const r=(d,v)=>{const h=String(v);a.value={...a.value,[d]:h}},s=async()=>{n.value=!0;try{const d=Object.entries(a.value).filter(([h])=>h.startsWith("autostop.")).map(([h,m])=>({key:h,value:m})),{data:v}=await R.PUT("/v1/admin/settings",{body:{settings:d}});t.value=v.settings,a.value={},y("success","AutoStop settings saved and applied")}catch(d){const v=d instanceof _?d:new _(0,"UNKNOWN","Unknown error");y("error",G(v.code))}finally{n.value=!1}},o=()=>{a.value={}};X(()=>(ze({id:"security-autostop",isDirty:()=>Object.keys(a.value).filter(d=>d.startsWith("autostop.")).length>0,save:s,discard:o}),()=>Me("security-autostop")),[]);const u=Object.keys(a.value).filter(d=>d.startsWith("autostop.")).length;return l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(le,{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(x,{variant:"ghost",size:"sm",onClick:o,children:"Discard"}),e(x,{variant:"primary",size:"sm",onClick:s,loading:n.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(E,{label:ce("enabled"),name:"autostop.enabled",type:"checkbox",value:We(t.value,a.value,"autostop","enabled"),onChange:d=>r("autostop.enabled",d),description:"Enable or disable AutoStop protection rules"})}),e(va,{legend:"Activity Detection",description:"Detects failures and unusual transaction patterns",children:e("div",{class:"settings-fields-grid",children:[e(E,{label:ce("consecutive_failures_threshold"),name:"autostop.consecutive_failures_threshold",type:"number",value:Number(pe(t.value,a.value,"autostop","consecutive_failures_threshold"))||0,onChange:d=>r("autostop.consecutive_failures_threshold",d),min:1,max:100,description:"Suspend wallet after this many consecutive failed transactions"}),e(E,{label:ce("unusual_activity_threshold"),name:"autostop.unusual_activity_threshold",type:"number",value:Number(pe(t.value,a.value,"autostop","unusual_activity_threshold"))||0,onChange:d=>r("autostop.unusual_activity_threshold",d),min:5,max:1e3,description:"Max transactions within window before triggering unusual activity alert"}),e(E,{label:ce("unusual_activity_window_sec"),name:"autostop.unusual_activity_window_sec",type:"number",value:Number(pe(t.value,a.value,"autostop","unusual_activity_window_sec"))||0,onChange:d=>r("autostop.unusual_activity_window_sec",d),min:60,max:86400,description:"Time window for unusual activity detection"})]})}),e(va,{legend:"Idle Detection",description:"Monitors inactivity and revokes idle sessions",children:e("div",{class:"settings-fields-grid",children:[e(E,{label:ce("idle_timeout_sec"),name:"autostop.idle_timeout_sec",type:"number",value:Number(pe(t.value,a.value,"autostop","idle_timeout_sec"))||0,onChange:d=>r("autostop.idle_timeout_sec",d),min:60,max:604800,description:"Revoke sessions with no activity for this duration"}),e(E,{label:ce("idle_check_interval_sec"),name:"autostop.idle_check_interval_sec",type:"number",value:Number(pe(t.value,a.value,"autostop","idle_check_interval_sec"))||0,onChange:d=>r("autostop.idle_check_interval_sec",d),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 Fo(){const t=c(!1),a=c(!1),n=async()=>{a.value=!0;try{await R.POST("/v1/admin/rotate-secret"),t.value=!1,y("success","All session tokens invalidated. Old tokens remain valid for 5 minutes.")}catch(l){const i=l instanceof _?l:new _(0,"UNKNOWN","Unknown error");y("error",G(i.code))}finally{a.value=!1}};return e(le,{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(x,{variant:"secondary",onClick:()=>{t.value=!0},children:"Invalidate All Tokens"})})]}),e(he,{open:t.value,title:"Invalidate All Session Tokens",onCancel:()=>{t.value=!1},onConfirm:n,confirmText:"Invalidate",confirmVariant:"primary",loading:a.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 zo(){const t=c(""),a=c(""),n=c(""),l=c(!1),i=c(null),r=()=>a.value.length<8?(i.value="New password must be at least 8 characters.",!1):a.value!==n.value?(i.value="New password and confirmation do not match.",!1):(i.value=null,!0),s=async()=>{if(r()){l.value=!0;try{await R.PUT("/v1/admin/master-password",{body:{newPassword:a.value}}),y("success","Master password changed. Please log in again."),t.value="",a.value="",n.value="",setTimeout(()=>Ga(),500)}catch(o){const u=o instanceof _?o:new _(0,"UNKNOWN","Unknown error");y("error",G(u.code))}finally{l.value=!1}}};return e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Change Master Password"}),e("p",{class:"settings-description",children:"Update the master password used to authenticate with the Admin UI. You will be logged out after a successful change."})]}),e("div",{class:"settings-category-body",children:[i.value&&e("div",{class:"settings-info-box",style:{borderColor:"var(--color-danger)",color:"var(--color-danger)",marginBottom:"var(--space-3)"},children:i.value}),e("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-3)",maxWidth:"400px"},children:[e(E,{label:"Current Password",name:"current-password",type:"password",value:t.value,onChange:o=>{t.value=String(o)}}),e(E,{label:"New Password",name:"new-password",type:"password",value:a.value,onChange:o=>{a.value=String(o)},description:"Minimum 8 characters"}),e(E,{label:"Confirm New Password",name:"confirm-password",type:"password",value:n.value,onChange:o=>{n.value=String(o)}}),e("div",{children:e(x,{variant:"primary",onClick:s,loading:l.value,disabled:!t.value||!a.value||!n.value,children:"Change Password"})})]})]})]})}function _l(){const t=(()=>{const l=location.hash,i=l.indexOf("?");if(i>=0){const s=new URLSearchParams(l.slice(i+1)).get("tab");if(s&&rn.some(o=>o.key===s))return s}return"killswitch"})(),a=c(t);X(()=>{const l=me.value;l&&l.tab&&(a.value=l.tab,setTimeout(()=>{Pe.value=l.fieldName},100),me.value=null)},[me.value]);const n=rn.find(l=>l.key===a.value)?.label??"";return e("div",{class:"page",children:[e(fa,{pageName:"Security",tabName:n,onPageClick:()=>{a.value="killswitch"}}),e(Oe,{tabs:rn,activeTab:a.value,onTabChange:l=>{a.value=l}}),a.value==="killswitch"&&e(Mo,{}),a.value==="autostop"&&e($o,{}),a.value==="jwt"&&e(Fo,{}),a.value==="password"&&e(zo,{})]})}const pt=[{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 Ko({value:t,onChange:a,name:n}){const l=c(""),i=c(!1),r=c(null),s=c(!1),o=qe(null),u=Lt(()=>{const v=l.value.toLowerCase();return v?pt.filter(h=>h.code.toLowerCase().includes(v)||h.name.toLowerCase().includes(v)||h.symbol.includes(v)):pt});X(()=>{if(t==="USD"){r.value="1 USD = $1.00";return}s.value=!0,Se(`${Ha.ADMIN_FOREX_RATES}?currencies=${t}`).then(v=>{const h=v.rates[t];r.value=h?.preview??null}).catch(()=>{r.value=null}).finally(()=>{s.value=!1})},[t]),X(()=>{const v=h=>{o.current&&!o.current.contains(h.target)&&(i.value=!1,l.value="")};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[]);const d=pt.find(v=>v.code===t)??pt[0];return e("div",{class:"currency-select",ref:o,children:[n&&e("input",{type:"hidden",name:n,value:t}),e("button",{type:"button",class:"currency-select-trigger",onClick:()=>{i.value=!i.value},children:[e("span",{class:"currency-select-value",children:[d.code," - ",d.name," (",d.symbol,")"]}),e("span",{class:"currency-select-chevron",children:i.value?"▲":"▼"})]}),r.value&&e("div",{class:"currency-rate-preview",children:s.value?"...":r.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:[u.value.map(v=>e("button",{type:"button",class:`currency-select-option ${v.code===t?"currency-select-option--active":""}`,onClick:()=>{a(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)),u.value.length===0&&e("div",{class:"currency-select-empty",children:"No currencies found"})]})]})]})}const La="rpc_proxy";function Bo(){const t=c({}),a=c({}),n=c(!0),l=c(!1),i=c([]),r=c(!0),s=async()=>{try{const{data:p}=await R.GET("/v1/admin/settings");t.value=p}catch(p){const T=p instanceof _?p:new _(0,"UNKNOWN","Unknown error");y("error",G(T.code))}finally{n.value=!1}},o=async()=>{try{const{data:p}=await R.GET("/v1/audit-logs",{params:{query:{limit:20}}});i.value=p?.data??[]}catch{}finally{r.value=!1}};X(()=>{s(),o()},[]);const u=(p,T="")=>{const D=`${La}.${p}`;return a.value[D]!==void 0?a.value[D]:pe(t.value,a.value,La,p)||T},d=p=>{const T=`${La}.${p}`;return a.value[T]!==void 0?a.value[T]==="true":We(t.value,a.value,La,p)},v=(p,T)=>{const D=`${La}.${p}`;a.value={...a.value,[D]:T}},h=()=>Object.keys(a.value).length>0;X(()=>{const p="rpc-proxy-settings";return ze({id:p,isDirty:()=>h(),save:m,discard:()=>{a.value={}}}),()=>Me(p)},[]);const m=async()=>{l.value=!0;try{const p=Object.entries(a.value);for(const[T,D]of p)await R.PUT("/v1/admin/settings",{body:{settings:[{key:T,value:D}]}});a.value={},y("success","RPC proxy settings saved"),await s()}catch(p){const T=p instanceof _?p:new _(0,"UNKNOWN","Unknown error");y("error",G(T.code))}finally{l.value=!1}},b=async()=>{const T=d("enabled")?"false":"true";try{await R.PUT("/v1/admin/settings",{body:{settings:[{key:"rpc_proxy.enabled",value:T}]}}),y("success",`RPC proxy ${T==="true"?"enabled":"disabled"}`),await s()}catch(D){const M=D instanceof _?D:new _(0,"UNKNOWN","Unknown error");y("error",G(M.code))}},U=[{key:"timestamp",header:"Time",render:p=>ve(p.timestamp)},{key:"eventType",header:"Method",render:p=>String(p.details?.method??p.eventType)},{key:"walletId",header:"Wallet",render:p=>p.walletId?p.walletId.slice(0,8)+"...":"-"},{key:"details",header:"Status",render:p=>{const T=String(p.details?.status??"ok");return e(Y,{variant:T==="error"?"danger":T==="rejected"?"warning":"success",children:T})}}];if(n.value)return e("div",{class:"loading-spinner",children:"Loading..."});const W=d("enabled");return e("div",{class:"page-content",children:[e("div",{class:"card",children:[e("div",{class:"card-header",children:e("h3",{children:"Proxy Status"})}),e("div",{class:"card-body",children:e("div",{style:{display:"flex",alignItems:"center",gap:"1rem"},children:[e(Y,{variant:W?"success":"danger",children:W?"ENABLED":"DISABLED"}),e(x,{variant:W?"danger":"primary",onClick:b,children:W?"Disable Proxy":"Enable Proxy"})]})})]}),e("div",{class:"card",style:{marginTop:"1rem"},children:[e("div",{class:"card-header",children:e("h3",{children:"Configuration"})}),e("div",{class:"card-body",children:[e(E,{label:"Delay Timeout (seconds)",name:"rpc_proxy.delay_timeout_seconds",value:u("delay_timeout_seconds","300"),onChange:p=>v("delay_timeout_seconds",String(p)),type:"number",help:"Timeout for DELAY tier transactions (default: 300s)"}),e(E,{label:"Approval Timeout (seconds)",name:"rpc_proxy.approval_timeout_seconds",value:u("approval_timeout_seconds","600"),onChange:p=>v("approval_timeout_seconds",String(p)),type:"number",help:"Timeout for APPROVAL tier transactions (default: 600s)"}),e(E,{label:"Max Gas Limit",name:"rpc_proxy.max_gas_limit",value:u("max_gas_limit","30000000"),onChange:p=>v("max_gas_limit",String(p)),type:"number",help:"Maximum gas limit per transaction (default: 30,000,000)"}),e(E,{label:"Max Bytecode Size (bytes)",name:"rpc_proxy.max_bytecode_size",value:u("max_bytecode_size","49152"),onChange:p=>v("max_bytecode_size",String(p)),type:"number",help:"Maximum contract bytecode size for deploy (default: 48KB)"}),e(E,{label:"Deploy Default Tier",name:"rpc_proxy.deploy_default_tier",value:u("deploy_default_tier","APPROVAL"),onChange:p=>v("deploy_default_tier",String(p)),type:"select",options:[{label:"IMMEDIATE",value:"IMMEDIATE"},{label:"DELAY",value:"DELAY"},{label:"APPROVAL",value:"APPROVAL"}],help:"Default policy tier for CONTRACT_DEPLOY transactions"}),e(E,{label:"Allowed Methods (JSON array)",name:"rpc_proxy.allowed_methods",value:u("allowed_methods","[]"),onChange:p=>v("allowed_methods",String(p)),type:"textarea",help:'JSON array of allowed methods. Empty [] = all supported methods. Example: ["eth_sendTransaction","eth_call"]'}),h()&&e("div",{style:{marginTop:"1rem",display:"flex",gap:"0.5rem"},children:[e(x,{variant:"primary",onClick:m,disabled:l.value,children:l.value?"Saving...":"Save Changes"}),e(x,{variant:"secondary",onClick:()=>{a.value={}},children:"Cancel"})]})]})]}),e("div",{class:"card",style:{marginTop:"1rem"},children:[e("div",{class:"card-header",children:e("h3",{children:"Usage"})}),e("div",{class:"card-body",children:[e("p",{children:"RPC Proxy URL pattern:"}),e("code",{class:"code-block",style:{display:"block",padding:"0.75rem",background:"var(--bg-tertiary)",borderRadius:"4px",marginBottom:"1rem"},children:["<baseUrl>","/v1/rpc-evm/","<walletId>","/","<chainId>"]}),e("p",{style:{marginBottom:"0.5rem"},children:e("strong",{children:"Examples:"})}),e("ul",{style:{paddingLeft:"1.25rem",lineHeight:"1.8"},children:[e("li",{children:[e("strong",{children:"Forge:"})," ",e("code",{children:"forge script Deploy.s.sol --rpc-url http://localhost:3100/v1/rpc-evm/WALLET_ID/1"})]}),e("li",{children:[e("strong",{children:"Hardhat:"})," Set ",e("code",{children:"url"})," in hardhat.config.ts networks section"]}),e("li",{children:[e("strong",{children:"viem:"})," Use ",e("code",{children:"http('http://localhost:3100/v1/rpc-evm/WALLET_ID/1')"})," as transport"]})]}),e("p",{style:{marginTop:"0.75rem",color:"var(--text-secondary)"},children:"Requires session authentication (Authorization: Bearer wai_sess_...) on all requests."})]})]}),e("div",{class:"card",style:{marginTop:"1rem"},children:[e("div",{class:"card-header",children:e("h3",{children:"Recent Activity"})}),e("div",{class:"card-body",children:r.value?e("div",{class:"loading-spinner",children:"Loading..."}):i.value.length===0?e(Ue,{title:"No recent activity",description:"RPC proxy audit logs will appear here once requests are processed."}):e(Le,{columns:U,data:i.value})})]})]})}const Ho=["display.","daemon.","oracle.","gas_condition.","smart_account.","erc8128.","actions.nft_indexer_"],Vo=new Set(["security.rate_limit_global_ip_rpm"]);function sn(t){return Ho.some(a=>t.startsWith(a))||Vo.has(t)}const bl=[{key:"general",label:"General"},{key:"api-keys",label:"API Keys"},{key:"rpc-proxy",label:"RPC Proxy"}];function on(){const t=c("general"),a=c({}),n=c({}),l=c(!1),i=c(!0),r=c([]),s=c(!0),o=c(null),u=c(""),d=c(!1),v=c(!1),h=c(!1),m=c(""),b=c(!1),U=async()=>{try{const{data:L}=await R.GET("/v1/admin/settings");a.value=L}catch(L){const Q=L instanceof _?L:new _(0,"UNKNOWN","Unknown error");y("error",G(Q.code))}finally{i.value=!1}},W=async()=>{try{const{data:L}=await R.GET("/v1/admin/api-keys");r.value=L.keys}catch{}finally{s.value=!1}};X(()=>{U(),W()},[]),X(()=>{const L=me.value;L&&(L.tab&&(t.value=L.tab),setTimeout(()=>{Pe.value=L.fieldName},100),me.value=null)},[me.value]);const p=(L,Q)=>pe(a.value,n.value,L,Q),T=(L,Q)=>We(a.value,n.value,L,Q),D=(L,Q)=>Oa(a.value,n.value,L,Q),M=(L,Q)=>{const re=String(Q);n.value={...n.value,[L]:re}},O=async()=>{l.value=!0;try{const L=Object.entries(n.value).filter(([re])=>sn(re)).map(([re,ee])=>({key:re,value:ee})),{data:Q}=await R.PUT("/v1/admin/settings",{body:{settings:L}});a.value=Q.settings,n.value={},y("success","Settings saved and applied")}catch(L){const Q=L instanceof _?L:new _(0,"UNKNOWN","Unknown error");y("error",G(Q.code))}finally{l.value=!1}},q=()=>{n.value={}};X(()=>(ze({id:"system-settings",isDirty:()=>Object.keys(n.value).filter(L=>sn(L)).length>0,save:O,discard:q}),()=>Me("system-settings")),[]);const S=async L=>{d.value=!0;try{await R.PUT("/v1/admin/api-keys/{provider}",{params:{path:{provider:L}},body:{apiKey:u.value}}),y("success",`API key saved for ${L}`),o.value=null,u.value="",await W()}catch(Q){const re=Q instanceof _?Q:new _(0,"UNKNOWN","Unknown error");y("error",G(re.code))}finally{d.value=!1}},C=async L=>{try{await R.DELETE("/v1/admin/api-keys/{provider}",{params:{path:{provider:L}}}),y("success",`API key deleted for ${L}`),await W()}catch(Q){const re=Q instanceof _?Q:new _(0,"UNKNOWN","Unknown error");y("error",G(re.code))}},N=async()=>{h.value=!0;try{await R.POST("/v1/admin/shutdown"),v.value=!1,m.value="",y("info","Shutdown initiated"),b.value=!0}catch(L){const Q=L instanceof _?L:new _(0,"UNKNOWN","Unknown error");y("error",G(Q.code))}finally{h.value=!1}},k=Object.keys(n.value).filter(L=>sn(L)).length;function V(){return s.value?e("div",{class:"settings-loading",children:"Loading API keys..."}):r.value.length===0?null:e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"API Keys"}),e("p",{class:"settings-description",children:"Manage API keys for Action Providers"})]}),e("div",{class:"settings-category-body",children:r.value.map(L=>e("div",{class:"settings-field-row",children:[e("div",{class:"settings-field-label",children:[e("span",{children:L.providerName}),L.requiresApiKey&&!L.hasKey&&e(Y,{variant:"warning",children:"Required"})]}),e("div",{class:"settings-field-value",children:o.value===L.providerName?e("div",{class:"api-key-edit-row",children:[e(E,{label:"API Key",type:"password",name:`apikey-${L.providerName}`,value:u.value,onChange:Q=>{u.value=String(Q)},placeholder:"Enter API key"}),e(x,{onClick:()=>S(L.providerName),loading:d.value,size:"sm",children:"Save"}),e(x,{variant:"ghost",onClick:()=>{o.value=null,u.value=""},size:"sm",children:"Cancel"})]}):e("div",{class:"api-key-display-row",children:[e("span",{class:"api-key-masked",children:L.hasKey?L.maskedKey:"Not set"}),e(x,{variant:"ghost",onClick:()=>{o.value=L.providerName,u.value=""},size:"sm",children:L.hasKey?"Change":"Set"}),L.hasKey&&e(x,{variant:"danger",onClick:()=>C(L.providerName),size:"sm",children:"Delete"})]})})]},L.providerName))})]})}const w={alchemy_nft:{label:"Alchemy NFT",description:"EVM NFT indexing (ERC-721, ERC-1155)",dashboardUrl:"https://dashboard.alchemy.com"},helius_das:{label:"Helius",description:"Solana NFT indexing (Metaplex)",dashboardUrl:"https://dashboard.helius.dev"}};function H(){const L=r.value.filter(ee=>ee.providerName in w),re=Object.keys(w).map(ee=>L.find(K=>K.providerName===ee)??{providerName:ee,hasKey:!1,maskedKey:""});return e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"NFT Indexer"}),e("p",{class:"settings-description",children:"Configure API keys for NFT indexing (required for NFT query operations)"})]}),e("div",{class:"settings-category-body",children:[re.map(ee=>{const _e=w[ee.providerName];return e("div",{class:"settings-field-row",children:[e("div",{class:"settings-field-label",children:[e("span",{children:[_e.label," ",e("a",{href:_e.dashboardUrl,target:"_blank",rel:"noopener noreferrer",style:{fontWeight:400,fontSize:"0.8em"},children:"(Dashboard)"})]}),e("span",{style:{fontSize:"0.8em",color:"var(--color-text-secondary)"},children:_e.description}),ee.hasKey?e(Y,{variant:"success",children:"Configured"}):e(Y,{variant:"neutral",children:"Not configured"})]}),e("div",{class:"settings-field-value",children:o.value===ee.providerName?e("div",{class:"api-key-edit-row",children:[e(E,{label:"API Key",type:"password",name:`nft-apikey-${ee.providerName}`,value:u.value,onChange:K=>{u.value=String(K)},placeholder:"Enter API key"}),e(x,{onClick:()=>S(ee.providerName),loading:d.value,size:"sm",children:"Save"}),e(x,{variant:"ghost",onClick:()=>{o.value=null,u.value=""},size:"sm",children:"Cancel"})]}):e("div",{class:"api-key-display-row",children:[e("span",{class:"api-key-masked",children:ee.hasKey?ee.maskedKey:"Not set"}),e(x,{variant:"ghost",onClick:()=>{o.value=ee.providerName,u.value=""},size:"sm",children:ee.hasKey?"Change":"Set"}),ee.hasKey&&e(x,{variant:"danger",onClick:()=>C(ee.providerName),size:"sm",children:"Delete"})]})})]},ee.providerName)}),e("div",{style:{borderTop:"1px solid var(--border)",paddingTop:"var(--space-3)",marginTop:"var(--space-3)"},children:e(E,{label:"Cache TTL (seconds)",name:"actions.nft_indexer_cache_ttl_sec",type:"number",value:Number(p("actions","nft_indexer_cache_ttl_sec"))||300,onChange:ee=>M("actions.nft_indexer_cache_ttl_sec",ee),min:0,max:86400,description:"How long to cache NFT metadata and listings (seconds). Default: 300 (5 min)."})}),e("div",{class:"settings-info-box",children:"NFT indexer API keys enable NFT query operations. Alchemy is used for EVM chains (ERC-721, ERC-1155) and Helius for Solana (Metaplex). Without a configured key, NFT listing and metadata queries will fail for the respective chain family."})]})]})}function Z(){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(E,{label:"Cross Validation Threshold (%)",name:"oracle.cross_validation_threshold",type:"number",value:Number(p("oracle","cross_validation_threshold"))||5,onChange:L=>M("oracle.cross_validation_threshold",L),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(E,{label:"CoinGecko API Key",name:"oracle.coingecko_api_key",type:"password",value:p("oracle","coingecko_api_key"),onChange:L=>M("oracle.coingecko_api_key",L),placeholder:D("oracle","coingecko_api_key")?"(configured)":"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 A(){const L=Pe.value==="display.currency";return X(()=>{if(L){const Q=document.querySelector('[name="display.currency"]');Q&&Q.closest(".form-field")?.scrollIntoView({behavior:"smooth",block:"center"});const re=setTimeout(()=>{Pe.value=""},2500);return()=>clearTimeout(re)}},[L]),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${L?" form-field--highlight":""}`,children:[e("label",{children:ce("currency")}),e(Ko,{name:"display.currency",value:p("display","currency")||"USD",onChange:Q=>M("display.currency",Q)})]})}),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 B(){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(E,{label:ce("rate_limit_global_ip_rpm"),name:"security.rate_limit_global_ip_rpm",type:"number",value:Number(p("security","rate_limit_global_ip_rpm"))||0,onChange:L=>M("security.rate_limit_global_ip_rpm",L),min:10,description:"Maximum API requests per minute from a single IP address"})})})]})}function I(){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(E,{label:ce("log_level"),name:"daemon.log_level",type:"select",value:p("daemon","log_level")||"info",onChange:L=>M("daemon.log_level",L),options:[{label:"debug",value:"debug"},{label:"info",value:"info"},{label:"warn",value:"warn"},{label:"error",value:"error"}],description:"Daemon logging verbosity level"})})})]})}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(E,{label:"Gas Condition Enabled",name:"gas_condition.enabled",type:"select",value:p("gas_condition","enabled")||"true",onChange:L=>M("gas_condition.enabled",L),options:[{label:"Yes",value:"true"},{label:"No",value:"false"}],description:"Enable gas conditional execution for agents"}),e(E,{label:ce("poll_interval_sec"),name:"gas_condition.poll_interval_sec",type:"number",value:Number(p("gas_condition","poll_interval_sec"))||30,onChange:L=>M("gas_condition.poll_interval_sec",L),min:10,max:300,description:"How often to check gas prices (seconds)"}),e(E,{label:ce("default_timeout_sec"),name:"gas_condition.default_timeout_sec",type:"number",value:Number(p("gas_condition","default_timeout_sec"))||3600,onChange:L=>M("gas_condition.default_timeout_sec",L),min:60,max:86400,description:"Default wait timeout when not specified in request (seconds)"}),e(E,{label:ce("max_timeout_sec"),name:"gas_condition.max_timeout_sec",type:"number",value:Number(p("gas_condition","max_timeout_sec"))||86400,onChange:L=>M("gas_condition.max_timeout_sec",L),min:60,max:86400,description:"Maximum allowed timeout for gas conditions (seconds)"}),e(E,{label:ce("max_pending_count"),name:"gas_condition.max_pending_count",type:"number",value:Number(p("gas_condition","max_pending_count"))||100,onChange:L=>M("gas_condition.max_pending_count",L),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."})]})]})}function F(){return e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Smart Account (ERC-4337)"}),e("p",{class:"settings-description",children:"Global smart account feature toggle. Bundler and Paymaster are configured per-wallet."})]}),e("div",{class:"settings-category-body",children:[e("div",{class:"settings-fields-grid",children:[e(E,{label:"Enabled",name:"smart_account.enabled",type:"select",value:p("smart_account","enabled")||"false",onChange:L=>M("smart_account.enabled",L),options:[{label:"Yes",value:"true"},{label:"No",value:"false"}],description:"Enable smart account wallet creation. When disabled, only EOA wallets can be created.","data-field":"smart_account.enabled"}),e(E,{label:"EntryPoint Address",name:"smart_account.entry_point",value:p("smart_account","entry_point"),onChange:L=>M("smart_account.entry_point",L),placeholder:"0x0000000071727De22E5E9d8BAf0edAc6f37da032",description:"EntryPoint v0.7 contract address. Override only if using a custom deployment.","data-field":"smart_account.entry_point"})]}),e("div",{class:"settings-info-box",children:"Smart accounts enable gas-sponsored transactions via Paymaster, atomic batch execution, and lazy contract deployment. Bundler and Paymaster settings are configured individually on each wallet (Wallets → Edit → AA Provider)."}),e("div",{style:{borderTop:"1px solid var(--border)",paddingTop:"var(--space-3)",marginTop:"var(--space-3)"},children:[e("div",{style:{fontWeight:600,fontSize:"var(--font-size-sm)",marginBottom:"var(--space-2)",color:"var(--text-secondary)"},children:"Global AA Provider Defaults"}),e("p",{class:"settings-description",style:{marginBottom:"var(--space-3)"},children:"Global default API keys for ERC-4337 bundler providers. Per-wallet keys override these defaults."}),e("div",{class:"settings-subgroup",style:{marginBottom:"1rem"},children:[e("h4",{style:{margin:"0 0 0.5rem 0",fontSize:"0.875rem",fontWeight:600,color:"var(--text-secondary)"},children:["Pimlico"," ",e("a",{href:"https://dashboard.pimlico.io",target:"_blank",rel:"noopener noreferrer",style:{fontWeight:400,fontSize:"0.8rem"},children:"(Dashboard)"})]}),e("div",{class:"settings-fields-grid",children:[e(E,{label:"API Key",name:"smart_account.pimlico.api_key",type:"password",value:p("smart_account","pimlico.api_key"),onChange:L=>M("smart_account.pimlico.api_key",L),placeholder:D("smart_account","pimlico.api_key")?"(configured)":"Enter Pimlico API key","data-field":"smart_account.pimlico.api_key"}),e(E,{label:"Paymaster Policy ID",name:"smart_account.pimlico.paymaster_policy_id",type:"text",value:p("smart_account","pimlico.paymaster_policy_id"),onChange:L=>M("smart_account.pimlico.paymaster_policy_id",L),placeholder:"Optional sponsorship policy ID","data-field":"smart_account.pimlico.paymaster_policy_id"})]})]}),e("div",{class:"settings-subgroup",children:[e("h4",{style:{margin:"0 0 0.5rem 0",fontSize:"0.875rem",fontWeight:600,color:"var(--text-secondary)"},children:["Alchemy"," ",e("a",{href:"https://dashboard.alchemy.com",target:"_blank",rel:"noopener noreferrer",style:{fontWeight:400,fontSize:"0.8rem"},children:"(Dashboard)"})]}),e("div",{class:"settings-fields-grid",children:[e(E,{label:"API Key",name:"smart_account.alchemy.api_key",type:"password",value:p("smart_account","alchemy.api_key"),onChange:L=>M("smart_account.alchemy.api_key",L),placeholder:D("smart_account","alchemy.api_key")?"(configured)":"Enter Alchemy API key","data-field":"smart_account.alchemy.api_key"}),e(E,{label:"Paymaster Policy ID",name:"smart_account.alchemy.paymaster_policy_id",type:"text",value:p("smart_account","alchemy.paymaster_policy_id"),onChange:L=>M("smart_account.alchemy.paymaster_policy_id",L),placeholder:"Required for Alchemy paymaster","data-field":"smart_account.alchemy.paymaster_policy_id"})]})]}),e("div",{class:"settings-info-box",children:"Set global provider API keys here so you don't need to enter them for every smart account wallet. Per-wallet API keys always take priority over these global defaults."})]})]})]})}function j(){return e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"ERC-8128 Signed HTTP Requests"}),e("p",{class:"settings-description",children:"Configure ERC-8128 HTTP message signing (RFC 9421 + EIP-191). Enables wallets to authenticate API requests with cryptographic signatures."})]}),e("div",{class:"settings-category-body",children:[e("div",{class:"settings-fields-grid",children:[e(E,{label:"Enabled",name:"erc8128.enabled",type:"select",value:p("erc8128","enabled")||"false",onChange:L=>M("erc8128.enabled",L),options:[{label:"Yes",value:"true"},{label:"No",value:"false"}],description:"Enable ERC-8128 HTTP message signing. When disabled, sign/verify endpoints return 403.","data-field":"erc8128.enabled"}),e(E,{label:"Default Preset",name:"erc8128.default_preset",type:"select",value:p("erc8128","default_preset")||"standard",onChange:L=>M("erc8128.default_preset",L),options:[{label:"Minimal",value:"minimal"},{label:"Standard",value:"standard"},{label:"Strict",value:"strict"}],description:"Default covered components preset for signatures.","data-field":"erc8128.default_preset"}),e(E,{label:"Default TTL (seconds)",name:"erc8128.default_ttl_sec",value:p("erc8128","default_ttl_sec")||"300",onChange:L=>M("erc8128.default_ttl_sec",L),placeholder:"300",description:"Default signature TTL in seconds.","data-field":"erc8128.default_ttl_sec"}),e(E,{label:"Include Nonce",name:"erc8128.default_nonce",type:"checkbox",value:T("erc8128","default_nonce"),onChange:L=>M("erc8128.default_nonce",L),description:"Include a UUID v4 nonce in signatures by default for replay protection.","data-field":"erc8128.default_nonce"}),e(E,{label:"Algorithm",name:"erc8128.default_algorithm",value:p("erc8128","default_algorithm")||"ethereum-eip191",onChange:L=>M("erc8128.default_algorithm",L),placeholder:"ethereum-eip191",description:"Signing algorithm. Currently only ethereum-eip191 (personal_sign) is supported.","data-field":"erc8128.default_algorithm"}),e(E,{label:"Rate Limit (per minute)",name:"erc8128.default_rate_limit_rpm",value:p("erc8128","default_rate_limit_rpm")||"60",onChange:L=>M("erc8128.default_rate_limit_rpm",L),placeholder:"60",description:"Maximum signing requests per domain per minute.","data-field":"erc8128.default_rate_limit_rpm"})]}),e("div",{class:"settings-info-box",children:"ERC-8128 enables wallet-based HTTP API authentication using RFC 9421 message signatures signed with EIP-191 (personal_sign). Requires ERC8128_ALLOWED_DOMAINS policy for domain whitelisting."})]})]})}function J(){return e(le,{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(x,{variant:"ghost",size:"sm",onClick:q,children:"Discard"}),e(x,{variant:"primary",size:"sm",onClick:O,loading:l.value,children:"Save"})]})]}),i.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(le,{children:[e(H,{}),e(Z,{}),e(A,{}),e(B,{}),e(I,{}),e(g,{}),e(F,{}),e(j,{})]}),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(x,{variant:"danger",onClick:()=>{v.value=!0},children:"Shutdown Daemon"})})]})]})}return e("div",{class:"page",children:[b.value&&e("div",{class:"shutdown-overlay",children:[e("h2",{children:"Daemon is shutting down..."}),e("p",{children:"You can close this tab."})]}),e(fa,{pageName:"Settings",tabName:bl.find(L=>L.key===t.value)?.label??"",onPageClick:()=>{t.value="general"}}),e(Oe,{tabs:bl,activeTab:t.value,onTabChange:L=>{t.value=L}}),t.value==="general"&&e(J,{}),t.value==="api-keys"&&e(V,{}),t.value==="rpc-proxy"&&e(Bo,{}),e(he,{open:v.value,title:"Shutdown Daemon",onCancel:()=>{v.value=!1,m.value=""},onConfirm:N,confirmText:"Shutdown",confirmVariant:"danger",confirmDisabled:m.value!=="SHUTDOWN",loading:h.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:m.value,onInput:L=>{m.value=L.target.value},placeholder:"SHUTDOWN"})]})]})]})}const mt=["Swap","Bridge","Staking","Lending","Yield","Perp","Prediction","Other"],Go={jupiter_swap:["jupiter_swap_default_slippage_bps","jupiter_swap_max_slippage_bps"],zerox_swap:["zerox_swap_default_slippage_bps","zerox_swap_max_slippage_bps"],aave_v3:["aave_v3_health_factor_warning_threshold","aave_v3_position_sync_interval_sec","aave_v3_max_ltv_pct"],kamino:["kamino_market","kamino_hf_threshold"],drift:["drift_max_leverage","drift_max_position_usd","drift_margin_warning_threshold_pct","drift_position_sync_interval_sec"],pendle_yield:["pendle_yield_default_slippage_bps","pendle_yield_max_slippage_bps"],dcent_swap:["dcent_swap_api_url","dcent_swap_default_slippage_bps","dcent_swap_max_slippage_bps"],hyperliquid:["hyperliquid_network","hyperliquid_api_url","hyperliquid_rate_limit_weight_per_min","hyperliquid_default_leverage","hyperliquid_default_margin_mode","hyperliquid_builder_address","hyperliquid_builder_fee","hyperliquid_order_status_poll_interval_ms"],polymarket:["polymarket_default_fee_bps","polymarket_order_expiry_seconds","polymarket_max_position_usdc","polymarket_proxy_wallet","polymarket_neg_risk_enabled","polymarket_auto_approve_ctf"]};function wl(){const t=c([]),a=c({}),n=c([]),l=c(!0),i=c(""),r=c(null),s=c(""),o=c(!1),u=c(null),d=c({}),v=async()=>{try{const{data:A}=await R.GET("/v1/admin/settings");a.value=A}catch(A){const B=A instanceof _?A:new _(0,"UNKNOWN","Unknown error");y("error",G(B.code))}},h=async()=>{try{const{data:A}=await R.GET("/v1/admin/api-keys");n.value=A.keys}catch{}},m=async()=>{try{const{data:A}=await R.GET("/v1/actions/providers");t.value=A.providers??[]}catch{}},b=async()=>{l.value=!0,await Promise.all([v(),h(),m()]),l.value=!1};X(()=>{b()},[]);const U=async(A,B)=>{const I=`actions.${A.enabledKey}_enabled`;u.value=A.name;try{const{data:g}=await R.PUT("/v1/admin/settings",{body:{settings:[{key:I,value:String(B)}]}});a.value=g.settings,await m(),y("success",`${B?"Enabled":"Disabled"} ${A.name.replace(/_/g," ")}`)}catch(g){const F=g instanceof _?g:new _(0,"UNKNOWN","Unknown error");y("error",G(F.code))}finally{u.value=null}},W=async A=>{o.value=!0;try{await R.PUT("/v1/admin/api-keys/{provider}",{params:{path:{provider:A}},body:{apiKey:s.value}}),y("success",`API key saved for ${A}`),r.value=null,s.value="",await h()}catch(B){const I=B instanceof _?B:new _(0,"UNKNOWN","Unknown error");y("error",G(I.code))}finally{o.value=!1}},p=async A=>{try{await R.DELETE("/v1/admin/api-keys/{provider}",{params:{path:{provider:A}}}),y("success",`API key deleted for ${A}`),await h()}catch(B){const I=B instanceof _?B:new _(0,"UNKNOWN","Unknown error");y("error",G(I.code))}},T=async(A,B)=>{const I=`actions.${A}`,g=tl(A)?qr(B):B;try{const{data:F}=await R.PUT("/v1/admin/settings",{body:{settings:[{key:I,value:g}]}});a.value=F.settings;const j={...d.value};delete j[A],d.value=j,y("success","Setting updated")}catch(F){const j=F instanceof _?F:new _(0,"UNKNOWN","Unknown error");y("error",G(j.code))}};function D(A){return n.value.find(B=>B.providerName===A||B.providerName.toLowerCase().replace(/[\s-]/g,"_")===A)}function M(A,B){return a.value.actions?.[`${A}_${B}_tier`]||""}function O(A,B){const I=M(A,B);return I!==""&&I!==void 0}async function q(A,B,I){const g=`actions.${A}_${B}_tier`;try{const{data:F}=await R.PUT("/v1/admin/settings",{body:{settings:[{key:g,value:I}]}});a.value=F.settings,y("success",`Tier updated for ${A}/${B}`)}catch(F){const j=F instanceof _?F:new _(0,"UNKNOWN","Unknown error");y("error",G(j.code))}}async function S(A,B){const I=`actions.${A}_${B}_tier`;try{const{data:g}=await R.PUT("/v1/admin/settings",{body:{settings:[{key:I,value:""}]}});a.value=g.settings,y("success",`Tier reset to default for ${A}/${B}`)}catch(g){const F=g instanceof _?g:new _(0,"UNKNOWN","Unknown error");y("error",G(F.code))}}function C(A){const B=a.value.actions,I=d.value[A]??B?.[A]??"";return d.value[A]!==void 0?d.value[A]:tl(A)?Gr(I):I}function N(A){return A.isEnabled&&A.requiresApiKey&&!D(A.name)?.hasKey?{label:"Requires API Key",variant:"warning"}:A.isEnabled?{label:"Active",variant:"success"}:{label:"Inactive",variant:"neutral"}}if(l.value)return e("div",{class:"page",children:e("div",{class:"empty-state",children:e("p",{children:"Loading action providers..."})})});const V=[...new Set(t.value.map(A=>A.category))].sort((A,B)=>(mt.indexOf(A)!==-1?mt.indexOf(A):99)-(mt.indexOf(B)!==-1?mt.indexOf(B):99)),w=V.map(A=>({key:A,label:A})),H=i.value&&V.includes(i.value)?i.value:V[0]??"",Z=t.value.filter(A=>A.category===H);return e("div",{class:"page",children:[w.length>1&&e(Oe,{tabs:w,activeTab:H,onTabChange:A=>{i.value=A}}),Z.map(A=>{const B=N(A),I=D(A.name),g=u.value===A.name,F=Go[A.name];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:[A.name.replace(/_/g," ").replace(/\b\w/g,j=>j.toUpperCase()),e(Y,{variant:"info",children:A.version}),e(Y,{variant:"info",children:A.chains.length>1?"multi":A.chains[0]})]}),e("p",{class:"settings-description",style:{marginTop:"var(--space-1)"},children:A.description})]}),e(Y,{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(E,{label:"Enabled",name:`actions.${A.enabledKey}_enabled`,type:"checkbox",value:A.isEnabled,onChange:j=>U(A,!!j),disabled:g}),g&&e("span",{style:{fontSize:"var(--font-size-sm)",color:"var(--text-secondary)"},children:"Saving..."})]}),A.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)",display:"flex",alignItems:"center",gap:"var(--space-2)"},children:["API Key",A.apiKeyUrl&&e("a",{href:String(A.apiKeyUrl),target:"_blank",rel:"noopener noreferrer",style:{fontSize:"var(--font-size-xs)",fontWeight:400},children:"Get API key →"})]}),r.value===A.name?e("div",{style:{display:"flex",alignItems:"flex-end",gap:"var(--space-2)"},children:[e(E,{label:"API Key",type:"password",name:`apikey-${A.name}`,value:s.value,onChange:j=>{s.value=String(j)},placeholder:"Enter API key"}),e(x,{onClick:()=>W(A.name),loading:o.value,size:"sm",children:"Save"}),e(x,{variant:"ghost",onClick:()=>{r.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:I?.hasKey?I.maskedKey:"Not set"}),e(x,{variant:"ghost",onClick:()=>{r.value=A.name,s.value=""},size:"sm",children:I?.hasKey?"Update":"Set"}),I?.hasKey&&e(x,{variant:"danger",onClick:()=>p(A.name),size:"sm",children:"Delete"})]})]}),F&&A.isEnabled&&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:"Advanced Settings"}),F.map(j=>{const J=C(j);return e("div",{style:{marginBottom:"var(--space-2)"},onBlur:()=>{const L=d.value[j];L!==void 0&&T(j,L)},children:e(E,{label:ce(j),name:`actions.${j}`,type:"text",value:J,onChange:L=>{d.value={...d.value,[j]:String(L)}}})},j)})]}),A.isEnabled&&A.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:"Description"}),e("th",{children:"Chain"}),e("th",{children:"Risk Level"}),e("th",{children:"Tier"})]})}),e("tbody",{children:A.actions.map(j=>e("tr",{children:[e("td",{children:j.name}),e("td",{style:{fontSize:"var(--font-size-sm)",color:"var(--text-secondary)",maxWidth:"300px"},children:j.description}),e("td",{children:A.chains.length>1?A.chains.map(J=>e(Y,{variant:"info",children:J},J)):e(Y,{variant:"info",children:j.chain})}),e("td",{children:j.riskLevel}),e("td",{children:e("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)"},children:[e("select",{value:M(A.name,j.name)||j.defaultTier,onChange:J=>q(A.name,j.name,J.target.value),style:{padding:"2px 4px",fontSize:"var(--font-size-sm)",borderRadius:"var(--radius-sm)"},children:["INSTANT","NOTIFY","DELAY","APPROVAL"].map(J=>e("option",{value:J,children:J},J))}),O(A.name,j.name)&&e(le,{children:[e(Y,{variant:"warning",children:"customized"}),e("button",{onClick:()=>S(A.name,j.name),style:{background:"none",border:"none",cursor:"pointer",fontSize:"var(--font-size-xs)",color:"var(--text-secondary)",textDecoration:"underline"},title:"Reset to provider default",children:"reset"})]})]})})]},j.name))})]})]})]})]},A.name)}),t.value.length===0&&e("div",{class:"empty-state",children:e("p",{children:"No action providers available."})})]})}function qo(){const t=c([]),a=c(!0),n=c(!1),l=c(!1),i=c(!1),r=c(null),s=c(null),o=c({}),u=c({}),d=c({}),v=c(!1),h=c(""),m=c(""),b=c(""),U=c(""),W=c(!1),p=c({}),T=c(null),D=c({}),M=c(null),O=c({}),q=c(null),S=async()=>{try{const{data:g}=await R.GET("/v1/admin/wallet-apps");t.value=g.apps}catch{y("error","Failed to load wallet apps")}},C=async()=>{try{const{data:g}=await R.GET("/v1/admin/settings"),F=g?.signing_sdk;F&&(l.value=String(F.enabled)==="true",n.value=String(F.notifications_enabled)==="true")}catch{}};X(()=>{Promise.all([S(),C()]).finally(()=>{a.value=!1})},[]);const N=async()=>{i.value=!0;const g=!n.value;try{await R.PUT("/v1/admin/settings",{body:{settings:[{key:"signing_sdk.notifications_enabled",value:String(g)}]}}),n.value=g,y("success",`Wallet app notifications ${g?"enabled":"disabled"}`)}catch{y("error","Failed to update notification setting")}finally{i.value=!1}},k=async(g,F)=>{q.value=`${g.id}-${F}`;try{await R.PUT("/v1/admin/wallet-apps/{id}",{params:{path:{id:g.id}},body:{[F]:!g[F]}}),await S(),y("success",`${F==="signing_enabled"?"Signing":"Alerts"} ${g[F]?"disabled":"enabled"} for ${g.display_name}`)}catch{y("error","Failed to update toggle")}finally{q.value=null}},V=async g=>{r.value=g.id;const F={...O.value};delete F[g.id],O.value=F;try{const{data:j}=await R.POST("/v1/admin/wallet-apps/{id}/test-notification",{params:{path:{id:g.id}}});if(j.success)y("success","Test notification sent successfully");else{const J=j.error||"Test notification failed";O.value={...O.value,[g.id]:J}}}catch{O.value={...O.value,[g.id]:"Failed to send test notification"}}finally{r.value=null}},w=async g=>{s.value=g.id;const F={...o.value};delete F[g.id],o.value=F;const j={...u.value};delete j[g.id],u.value=j;try{const J=d.value[g.id]?.trim(),{data:L}=await R.POST("/v1/admin/wallet-apps/{id}/test-sign-request",{params:{path:{id:g.id}},...J?{body:{ownerAddress:J}}:{}});L.timeout?o.value={...o.value,[g.id]:"No response within 30 seconds. Check device connection."}:L.success&&L.result?(u.value={...u.value,[g.id]:L.result},y(L.result.action==="approve"?"success":"warning",`Sign request ${L.result.action==="approve"?"approved":"rejected"}`)):o.value={...o.value,[g.id]:L.error||"Test sign request failed"}}catch{o.value={...o.value,[g.id]:"Failed to send test sign request"}}finally{s.value=null}},H=async()=>{if(!h.value.trim()||!m.value.trim()){y("error","Name and display name are required");return}W.value=!0;try{const g={name:h.value.trim(),display_name:m.value.trim()};b.value.trim()&&(g.wallet_type=b.value.trim()),U.value.trim()&&(g.push_relay_url=U.value.trim()),await R.POST("/v1/admin/wallet-apps",{body:g}),v.value=!1,h.value="",m.value="",b.value="",U.value="",await S(),y("success","Wallet app registered")}catch(g){g instanceof _&&g.code==="WALLET_APP_DUPLICATE"?y("error","App already registered"):y("error","Failed to register app")}finally{W.value=!1}},Z=async(g,F)=>{T.value=g.id;try{await R.PUT("/v1/admin/wallet-apps/{id}",{params:{path:{id:g.id}},body:{subscription_token:F||""}});const j={...p.value};delete j[g.id],p.value=j,await S(),y("success",F?"Subscription token set":"Subscription token cleared")}catch{y("error","Failed to update subscription token")}finally{T.value=null}},A=async(g,F)=>{M.value=g.id;try{await R.PUT("/v1/admin/wallet-apps/{id}",{params:{path:{id:g.id}},body:{push_relay_url:F||""}});const j={...D.value};delete j[g.id],D.value=j,await S(),y("success",F?"Push Relay URL set":"Push Relay URL cleared")}catch{y("error","Failed to update Push Relay URL")}finally{M.value=null}},B=async g=>{if(confirm(`Remove "${g.display_name}"? Wallets using this app will no longer route signing requests to it.`))try{await R.DELETE("/v1/admin/wallet-apps/{id}",{params:{path:{id:g.id}}}),await S(),y("success",`${g.display_name} removed`)}catch{y("error","Failed to remove app")}},I=t.value.some(g=>g.alerts_enabled);return a.value?e("div",{class:"loading-container",children:"Loading..."}):e("div",{class:"human-wallet-apps-page",children:[e("div",{class:"settings-category",style:{marginBottom:"1.5rem"},children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Wallet App Notifications"}),e("p",{class:"settings-description",children:"Push event notifications (transaction alerts, balance changes) to registered wallet apps via Push Relay"})]}),e("div",{class:"settings-category-body",children:[e("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[e("input",{type:"checkbox",checked:n.value,onChange:N,disabled:i.value,"data-testid":"notif-toggle"}),e("span",{children:"Notifications"}),e(Y,{variant:n.value?"success":"muted",children:n.value?"ON":"OFF"})]}),i.value&&e("span",{style:{fontSize:"0.85rem",color:"var(--text-muted)"},children:"Saving..."})]}),!l.value&&e("div",{class:"settings-warning-box",style:{marginTop:"0.75rem",padding:"0.75rem",background:"var(--color-warning-bg)",border:"1px solid var(--color-warning)",borderRadius:"4px",fontSize:"0.85rem"},children:"Signing SDK is disabled. Enable it in System > Signing SDK to use wallet app notifications."}),!n.value&&I&&e("div",{class:"settings-warning-box",style:{marginTop:"0.75rem",padding:"0.75rem",background:"var(--color-warning-bg)",border:"1px solid var(--color-warning)",borderRadius:"4px",fontSize:"0.85rem"},children:"Notifications are disabled but some apps have alerts enabled. Enable notifications above for alerts to be delivered."})]})]}),e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e("div",{children:[e("h3",{children:"Registered Apps"}),e("p",{class:"settings-description",children:"Wallet apps registered for signing and notifications"})]}),e(x,{onClick:()=>{v.value=!0},children:"+ Register App"})]}),e("div",{class:"settings-category-body",children:t.value.length===0?e("div",{class:"settings-info-box",children:'No wallet apps registered. Use "+ Register App" to add one, or apply a wallet preset when setting up a wallet owner.'}):e("div",{style:{display:"grid",gap:"1rem"},children:t.value.map(g=>e("div",{class:"settings-category",style:{border:"1px solid var(--border)",padding:"1rem"},children:[e("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e("div",{children:[e("h4",{style:{margin:"0 0 0.25rem 0"},children:[g.display_name,g.wallet_type&&g.wallet_type!==g.name&&e(Y,{variant:"info",style:{marginLeft:"0.5rem",fontSize:"0.7rem"},children:g.wallet_type})]}),e("code",{style:{fontSize:"0.8rem",color:"var(--text-muted)"},children:g.name})]}),e(x,{variant:"danger",size:"sm",onClick:()=>B(g),children:"Remove"})]}),e("div",{style:{display:"flex",gap:"2rem",marginTop:"1rem",flexWrap:"wrap",alignItems:"center"},children:[e("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[e("input",{type:"checkbox",checked:g.signing_enabled,onChange:()=>k(g,"signing_enabled"),disabled:q.value===`${g.id}-signing_enabled`}),e("span",{children:"Signing"}),e(Y,{variant:g.signing_enabled?"success":"muted",children:g.signing_enabled?"ON":"OFF"})]}),e("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[e("input",{type:"checkbox",checked:g.alerts_enabled,onChange:()=>k(g,"alerts_enabled"),disabled:q.value===`${g.id}-alerts_enabled`}),e("span",{children:"Alerts"}),e(Y,{variant:g.alerts_enabled?"success":"muted",children:g.alerts_enabled?"ON":"OFF"})]}),g.alerts_enabled&&(()=>{const F=!!(g.subscription_token&&g.push_relay_url);return e("span",{title:F?void 0:"Set subscription token and Push Relay URL first",children:e(x,{variant:"secondary",size:"sm",onClick:()=>V(g),disabled:!F||r.value===g.id,children:r.value===g.id?"Sending...":"Test Notify"})})})(),g.signing_enabled&&(()=>{const F=!!(g.subscription_token&&g.push_relay_url);return e("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[e("input",{type:"text",placeholder:"Owner address (optional)",value:d.value[g.id]||"",onInput:j=>{d.value={...d.value,[g.id]:j.target.value}},disabled:!F||s.value===g.id,style:{fontSize:"0.8rem",padding:"0.25rem 0.5rem",width:"240px",fontFamily:"monospace"}}),e("span",{title:F?void 0:"Set subscription token and Push Relay URL first",children:e(x,{variant:"secondary",size:"sm",onClick:()=>w(g),disabled:!F||s.value===g.id,children:s.value===g.id?"Waiting...":"Test Sign"})})]})})()]}),O.value[g.id]&&e("div",{style:{marginTop:"0.5rem",fontSize:"0.85rem",color:"var(--color-danger, #e74c3c)"},children:O.value[g.id]}),o.value[g.id]&&e("div",{style:{marginTop:"0.5rem",fontSize:"0.85rem",color:"var(--color-danger, #e74c3c)"},children:o.value[g.id]}),s.value===g.id&&e("div",{style:{marginTop:"0.5rem",fontSize:"0.85rem",color:"var(--text-muted)"},children:"Waiting for response from wallet app... Check your device."}),u.value[g.id]&&e("div",{style:{marginTop:"0.5rem",padding:"0.75rem",background:"var(--bg-secondary)",border:"1px solid var(--border)",borderRadius:"4px",fontSize:"0.85rem"},children:[e("div",{children:[e("strong",{children:"Action:"})," ",e(Y,{variant:u.value[g.id].action==="approve"?"success":"warning",children:u.value[g.id].action})]}),e("div",{style:{marginTop:"0.25rem"},children:[e("strong",{children:"Signer:"})," ",e("code",{children:[u.value[g.id].signerAddress.slice(0,6),"...",u.value[g.id].signerAddress.slice(-4)]})]}),u.value[g.id].signature&&e("div",{style:{marginTop:"0.25rem"},children:[e("strong",{children:"Signature:"})," ",e("code",{style:{cursor:"pointer",wordBreak:"break-all"},title:"Click to copy",onClick:()=>{navigator.clipboard.writeText(u.value[g.id].signature),y("success","Signature copied")},children:[u.value[g.id].signature.slice(0,20),"..."]})]}),e("div",{style:{marginTop:"0.25rem"},children:[e("strong",{children:"Signed at:"})," ",u.value[g.id].signedAt]})]}),e("div",{style:{marginTop:"0.75rem"},children:[e("span",{style:{fontSize:"0.85rem",fontWeight:500},children:"Used by: "}),g.used_by.length===0?e("span",{style:{fontSize:"0.85rem",color:"var(--text-muted)"},children:"No wallets"}):e("span",{style:{fontSize:"0.85rem"},children:g.used_by.map((F,j)=>e("span",{children:[j>0&&", ",e("a",{href:`#/wallets/${F.id}`,style:{color:"var(--primary)"},children:F.label})]},F.id))})]}),e("div",{style:{marginTop:"0.75rem"},children:[e("span",{style:{fontSize:"0.85rem",fontWeight:500},children:"Subscription Token: "}),p.value[g.id]!==void 0?e("span",{style:{display:"inline-flex",gap:"0.5rem",alignItems:"center"},children:[e("input",{type:"text",value:p.value[g.id],onInput:F=>{p.value={...p.value,[g.id]:F.target.value}},placeholder:"e.g., a1b2c3d4",style:{padding:"0.25rem 0.5rem",fontSize:"0.85rem",width:"140px"}}),e(x,{size:"sm",onClick:()=>Z(g,p.value[g.id]),disabled:T.value===g.id,children:T.value===g.id?"Saving...":"Set"}),e(x,{variant:"secondary",size:"sm",onClick:()=>{const F={...p.value};delete F[g.id],p.value=F},children:"Cancel"})]}):g.subscription_token?e("span",{style:{fontSize:"0.85rem"},children:[e("code",{children:[g.subscription_token.slice(0,4),"****"]}),e(x,{variant:"secondary",size:"sm",onClick:()=>Z(g,""),disabled:T.value===g.id,style:{marginLeft:"0.5rem"},children:"Clear"})]}):e("span",{style:{fontSize:"0.85rem"},children:[e("span",{style:{color:"var(--text-muted)"},children:"Not set"}),e(x,{variant:"secondary",size:"sm",onClick:()=>{p.value={...p.value,[g.id]:""}},style:{marginLeft:"0.5rem"},children:"Set"})]})]}),e("div",{style:{marginTop:"0.75rem"},children:[e("span",{style:{fontSize:"0.85rem",fontWeight:500},children:"Push Relay URL: "}),D.value[g.id]!==void 0?e("span",{style:{display:"inline-flex",gap:"0.5rem",alignItems:"center"},children:[e("input",{type:"text",value:D.value[g.id],onInput:F=>{D.value={...D.value,[g.id]:F.target.value}},placeholder:"https://push-relay.example.com",style:{padding:"0.25rem 0.5rem",fontSize:"0.85rem",width:"260px"}}),e(x,{size:"sm",onClick:()=>A(g,D.value[g.id]),disabled:M.value===g.id,children:M.value===g.id?"Saving...":"Save"}),e(x,{variant:"secondary",size:"sm",onClick:()=>{const F={...D.value};delete F[g.id],D.value=F},children:"Cancel"})]}):g.push_relay_url?e("span",{style:{fontSize:"0.85rem"},children:[e("code",{children:g.push_relay_url}),e(x,{variant:"secondary",size:"sm",onClick:()=>{D.value={...D.value,[g.id]:g.push_relay_url||""}},style:{marginLeft:"0.5rem"},children:"Edit"}),e(x,{variant:"secondary",size:"sm",onClick:()=>A(g,""),disabled:M.value===g.id,style:{marginLeft:"0.25rem"},children:"Clear"})]}):e("span",{style:{fontSize:"0.85rem"},children:[e("span",{style:{color:"var(--text-muted)"},children:"Not configured"}),e(x,{variant:"secondary",size:"sm",onClick:()=>{D.value={...D.value,[g.id]:""}},style:{marginLeft:"0.5rem"},children:"Set"})]})]})]},g.id))})})]}),e(he,{open:v.value,title:"Register Wallet App",onCancel:()=>{v.value=!1},children:e("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[e(E,{label:"App Name",name:"register-app-name",type:"text",value:h.value,onChange:g=>{h.value=String(g)},placeholder:"my-custom-wallet",description:"Lowercase alphanumeric with hyphens (e.g., dcent, my-wallet)"}),e(E,{label:"Display Name",name:"register-app-display-name",type:"text",value:m.value,onChange:g=>{m.value=String(g)},placeholder:"My Custom Wallet",description:"Human-readable name shown in the UI"}),e("div",{class:"form-field",children:[e("label",{for:"field-register-app-wallet-type",children:"Wallet Type (optional)"}),e("input",{id:"field-register-app-wallet-type",type:"text",name:"register-app-wallet-type",list:"wallet-type-presets",value:b.value,onInput:g=>{const F=g.target.value;b.value=F;const J={dcent:"https://waiaas-push.dcentwallet.com"}[F];U.value=J??""},placeholder:"Select preset or enter custom"}),e("datalist",{id:"wallet-type-presets",children:e("option",{value:"dcent",children:"D'CENT Wallet"})}),e("span",{class:"form-description",children:"Group multiple devices under the same wallet type. Defaults to app name."})]}),e(E,{label:"Push Relay URL (optional)",name:"register-app-push-relay-url",type:"text",value:U.value,onChange:g=>{U.value=String(g)},placeholder:"https://push-relay.example.com",description:"Push Relay server URL for sign requests and notifications"}),e("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end"},children:[e(x,{variant:"secondary",onClick:()=>{v.value=!1},children:"Cancel"}),e(x,{onClick:H,disabled:W.value||!h.value.trim()||!m.value.trim(),children:W.value?"Registering...":"Register"})]})]})})]})}const Tl=[{key:"identity",label:"Identity"},{key:"registration",label:"Registration File"},{key:"reputation",label:"Reputation"}];function gn({data:t,depth:a=0}){if(t==null)return e("span",{style:{color:"var(--color-text-muted)"},children:"null"});if(typeof t=="string")return e("span",{style:{color:"var(--color-success)"},children:['"',t,'"']});if(typeof t=="number"||typeof t=="boolean")return e("span",{style:{color:"var(--color-primary)"},children:String(t)});if(Array.isArray(t))return t.length===0?e("span",{children:"[]"}):e("div",{style:{paddingLeft:a>0?"var(--space-3)":"0"},children:["[",t.map((n,l)=>e("div",{style:{paddingLeft:"var(--space-3)"},children:[e(gn,{data:n,depth:a+1}),l<t.length-1?",":""]},l)),"]"]});if(typeof t=="object"){const n=Object.entries(t);return n.length===0?e("span",{children:"{}"}):e("div",{style:{paddingLeft:a>0?"var(--space-3)":"0"},children:["{",n.map(([l,i],r)=>e("div",{style:{paddingLeft:"var(--space-3)"},children:[e("span",{style:{fontWeight:"bold"},children:['"',l,'"']}),": ",e(gn,{data:i,depth:a+1}),r<n.length-1?",":""]},l)),"}"]})}return e("span",{children:String(t)})}function Sl(){const t=c("identity"),a=c(!0),n=c(!1),l=c([]),i=c([]),r=c(!1),s=c(""),o=c(""),u=c(""),d=c(!1),v=c(""),h=c(null),m=c(!1),b=c(null),U=c(""),W=c(""),p=c(""),T=c(null),D=c(!1),M=c(null),O=c(""),q=c(!1);async function S(){a.value=!0;try{const{data:I}=await R.GET("/v1/admin/settings"),g=I.actions;n.value=g?.erc8004_agent_enabled==="true";const{data:F}=await R.GET("/v1/wallets"),j=F.items??[];l.value=j;const J=j.filter(Q=>Q.chain==="ethereum"),L=[];for(const Q of J)try{const{data:re}=await R.GET("/v1/erc8004/registration-file/{walletId}",{params:{path:{walletId:Q.id}}}),ee=re.agentId;L.push({walletId:Q.id,walletName:Q.name,agentId:ee??null,status:ee?"REGISTERED":"NOT_REGISTERED",registryAddress:re.registryAddress??""})}catch{L.push({walletId:Q.id,walletName:Q.name,agentId:null,status:"NOT_REGISTERED",registryAddress:""})}i.value=L}catch(I){I instanceof _&&y(G(I.code),"error")}finally{a.value=!1}}X(()=>{S()},[]);async function C(){if(!(!s.value||!o.value)){d.value=!0;try{await R.POST("/v1/admin/actions/{provider}/{action}",{params:{path:{provider:"erc8004_agent",action:"register_agent"}},body:{params:{name:o.value,...u.value?{description:u.value}:{}},walletId:s.value}}),y("Agent registration initiated","success"),r.value=!1,o.value="",u.value="",s.value="",await S()}catch(I){I instanceof _&&y(G(I.code),"error")}finally{d.value=!1}}}async function N(I,g){M.value=I,q.value=!1,O.value="";try{const{data:F}=await R.POST("/v1/wallets/{id}/wc/pair",{params:{path:{id:I}}});O.value=F.uri;const j=setInterval(async()=>{try{const{data:J}=await R.GET("/v1/wallets/{id}/wc/pair/status",{params:{path:{id:I}}});J.connected&&(clearInterval(j),q.value=!0,await R.POST("/v1/admin/actions/{provider}/{action}",{params:{path:{provider:"erc8004_agent",action:"set_agent_wallet"}},body:{params:{agentId:g},walletId:I}}),y("Wallet linking initiated via EIP-712","success"),M.value=null,await S())}catch{}},1e3);setTimeout(()=>{clearInterval(j),!q.value&&M.value&&(y("WalletConnect pairing timed out","error"),M.value=null)},6e4)}catch(F){F instanceof _&&y(G(F.code),"error"),M.value=null}}async function k(I,g){try{await R.POST("/v1/admin/actions/{provider}/{action}",{params:{path:{provider:"erc8004_agent",action:"unset_agent_wallet"}},body:{params:{agentId:g},walletId:I}}),y("Wallet unlinking initiated","success"),await S()}catch(F){F instanceof _&&y(G(F.code),"error")}}async function V(I){if(I){m.value=!0;try{const{data:g}=await R.GET("/v1/erc8004/registration-file/{walletId}",{params:{path:{walletId:I}}});h.value=g}catch(g){g instanceof _&&y(G(g.code),"error"),h.value=null}finally{m.value=!1}}}async function w(I,g,F){try{const J=new URLSearchParams().toString(),L={},{data:Q}=await R.GET("/v1/erc8004/agent/{agentId}/reputation",{params:{path:{agentId:I},query:L}});b.value=Q}catch{b.value=null}}async function H(){if(p.value){D.value=!0;try{const I=new URLSearchParams;U.value&&I.set("tag1",U.value),W.value&&I.set("tag2",W.value);const g=I.toString(),F={};U.value&&(F.tag1=U.value),W.value&&(F.tag2=W.value);const{data:j}=await R.GET("/v1/erc8004/agent/{agentId}/reputation",{params:{path:{agentId:p.value},query:F}});T.value=j}catch(I){I instanceof _&&y(G(I.code),"error"),T.value=null}finally{D.value=!1}}}function Z(I){return I>=50?"success":I>=20?"warning":"danger"}const A=n.value?Tl:Tl.filter(I=>I.key==="identity");A.some(I=>I.key===t.value)||(t.value="identity");const B=l.value.filter(I=>I.chain==="ethereum");return e("div",{children:[!a.value&&!n.value&&e("div",{style:{padding:"var(--space-3) var(--space-4)",marginBottom:"var(--space-4)",background:"var(--color-bg-secondary)",border:"1px solid var(--border)",borderRadius:"var(--radius-md)",fontSize:"var(--font-size-sm)",color:"var(--color-text-muted)"},children:["Agent Identity is currently disabled."," ",e("a",{href:"#/providers",style:{color:"var(--color-primary)"},children:"Enable this protocol in Providers settings"})]}),!a.value&&n.value&&e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--color-text-muted)",marginBottom:"var(--space-3)"},children:e("a",{href:"#/providers",style:{color:"var(--color-primary)"},children:"Configure in Protocols > Providers"})}),!a.value&&e(le,{children:[e(Oe,{tabs:A,activeTab:t.value,onTabChange:I=>{t.value=I}}),t.value==="identity"&&e("div",{children:[e("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"var(--space-3)"},children:[e("h3",{style:{margin:0},children:"Registered Agents"}),n.value&&e(x,{variant:"primary",onClick:()=>{r.value=!0},children:"Register Agent"})]}),i.value.length===0?e(Ue,{title:"No EVM wallets found",description:"Create an EVM wallet first to register agents."}):e("table",{class:"data-table",children:[e("thead",{children:e("tr",{children:[e("th",{children:"Wallet Name"}),e("th",{children:"Wallet ID"}),e("th",{children:"Status"}),e("th",{children:"Agent ID"}),e("th",{children:"Registry Address"}),n.value&&e("th",{children:"Actions"})]})}),e("tbody",{children:i.value.map(I=>e("tr",{children:[e("td",{children:I.walletName}),e("td",{title:I.walletId,children:[I.walletId.slice(0,8),"..."]}),e("td",{children:e(Y,{variant:I.status==="REGISTERED"?"success":I.status==="WALLET_LINKED"?"info":"default",children:I.status})}),e("td",{children:I.agentId??"-"}),e("td",{title:I.registryAddress,children:I.registryAddress?`${I.registryAddress.slice(0,10)}...`:"-"}),n.value&&e("td",{children:[I.agentId&&I.status==="REGISTERED"&&e(x,{variant:"secondary",onClick:()=>N(I.walletId,I.agentId),disabled:M.value===I.walletId,children:M.value===I.walletId?"Linking...":"Link Wallet"}),I.agentId&&I.status==="WALLET_LINKED"&&e(x,{variant:"danger",onClick:()=>k(I.walletId,I.agentId),children:"Unlink"})]})]},I.walletId))})]}),M.value&&O.value&&e("div",{style:{marginTop:"var(--space-3)",padding:"var(--space-3)",background:"var(--color-bg-secondary)",borderRadius:"var(--radius-md)"},children:[e("p",{style:{fontWeight:"bold"},children:"WalletConnect Pairing URI"}),e("code",{style:{wordBreak:"break-all",fontSize:"var(--font-sm)"},children:O.value}),e("div",{style:{marginTop:"var(--space-2)"},children:e(Ge,{value:O.value,label:"Copy URI"})})]})]}),n.value&&t.value==="registration"&&e("div",{children:[e("div",{class:"form-field",children:[e("label",{children:"Select Wallet"}),e("select",{value:v.value,onChange:I=>{const g=I.target.value;v.value=g,g&&V(g)},children:[e("option",{value:"",children:"-- Select wallet --"}),B.map(I=>e("option",{value:I.id,children:[I.name," (",I.id.slice(0,8),"...)"]},I.id))]})]}),v.value&&e("div",{style:{marginTop:"var(--space-3)"},children:[e("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)",marginBottom:"var(--space-2)"},children:[e("h4",{style:{margin:0},children:"Registration File"}),e(Ge,{value:`${window.location.origin}/v1/erc8004/registration-file/${v.value}`,label:"Copy URL"})]}),m.value?e("p",{class:"loading-text",children:"Loading..."}):h.value?e("div",{style:{fontFamily:"monospace",fontSize:"var(--font-sm)",background:"var(--color-bg-secondary)",padding:"var(--space-3)",borderRadius:"var(--radius-md)",overflow:"auto"},children:e(gn,{data:h.value})}):e("p",{children:"No registration file available for this wallet."})]})]}),n.value&&t.value==="reputation"&&e("div",{children:[e("h3",{children:"My Agent Score"}),i.value.filter(I=>I.agentId).length===0?e("p",{children:"No registered agents. Register an agent first."}):e("div",{children:i.value.filter(I=>I.agentId).map(I=>((!b.value||b.value.agentId!==I.agentId)&&w(I.agentId),e("div",{style:{padding:"var(--space-3)",background:"var(--color-bg-secondary)",borderRadius:"var(--radius-md)",marginBottom:"var(--space-2)"},children:e("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)"},children:[e("strong",{children:["Agent #",I.agentId]}),b.value&&b.value.agentId===I.agentId&&e(le,{children:[e("span",{style:{fontSize:"var(--font-xl)",fontWeight:"bold"},children:Number(b.value.score)/Math.pow(10,b.value.decimals)}),e(Y,{variant:Z(Number(b.value.score)/Math.pow(10,b.value.decimals)),children:[b.value.count," feedback(s)"]})]})]})},I.agentId)))}),e("div",{style:{display:"flex",gap:"var(--space-2)",marginTop:"var(--space-3)",marginBottom:"var(--space-3)"},children:[e("div",{class:"form-field",children:[e("label",{children:"Tag1 Filter"}),e("input",{type:"text",value:U.value,onInput:I=>{U.value=I.target.value},placeholder:"e.g. reliability"})]}),e("div",{class:"form-field",children:[e("label",{children:"Tag2 Filter"}),e("input",{type:"text",value:W.value,onInput:I=>{W.value=I.target.value},placeholder:"e.g. speed"})]})]}),e("h3",{children:"External Agent Lookup"}),e("div",{style:{display:"flex",gap:"var(--space-2)",alignItems:"flex-end"},children:[e("div",{class:"form-field",children:[e("label",{children:"Agent ID"}),e("input",{type:"text",value:p.value,onInput:I=>{p.value=I.target.value},placeholder:"Enter agent ID"})]}),e(x,{variant:"primary",onClick:H,loading:D.value,children:"Query"})]}),T.value&&e("div",{style:{marginTop:"var(--space-3)",padding:"var(--space-3)",background:"var(--color-bg-secondary)",borderRadius:"var(--radius-md)"},children:[e("p",{children:e("strong",{children:["Agent #",T.value.agentId]})}),e("p",{children:["Score: ",Number(T.value.score)/Math.pow(10,T.value.decimals)]}),e("p",{children:["Feedback count: ",T.value.count]}),T.value.tag1&&e("p",{children:["Tag1: ",T.value.tag1]}),T.value.tag2&&e("p",{children:["Tag2: ",T.value.tag2]}),e(Y,{variant:Z(Number(T.value.score)/Math.pow(10,T.value.decimals)),children:Number(T.value.score)/Math.pow(10,T.value.decimals)>=50?"Good":Number(T.value.score)/Math.pow(10,T.value.decimals)>=20?"Fair":"Low"})]})]})]}),a.value&&e("p",{class:"loading-text",children:"Loading..."}),e(he,{open:r.value,title:"Register Agent",onConfirm:C,onCancel:()=>{r.value=!1},confirmText:"Register",loading:d.value,confirmDisabled:!s.value||!o.value,children:[e("div",{class:"form-field",children:[e("label",{children:"EVM Wallet"}),e("select",{value:s.value,onChange:I=>{s.value=I.target.value},children:[e("option",{value:"",children:"-- Select wallet --"}),B.map(I=>e("option",{value:I.id,children:[I.name," (",I.id.slice(0,8),"...)"]},I.id))]})]}),e("div",{class:"form-field",children:[e("label",{children:"Name"}),e("input",{type:"text",value:o.value,onInput:I=>{o.value=I.target.value},placeholder:"Agent name"})]}),e("div",{class:"form-field",children:[e("label",{children:"Description (optional)"}),e("input",{type:"text",value:u.value,onInput:I=>{u.value=I.target.value},placeholder:"Description"})]})]})]})}const xe={grid:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"var(--space-3)",marginBottom:"var(--space-4)"},card:{padding:"var(--space-3)",background:"var(--color-bg-secondary)",borderRadius:"var(--radius)",border:"1px solid var(--color-border)"},label:{fontSize:"var(--font-size-sm)",color:"var(--color-text-muted)",marginBottom:"var(--space-1)"},value:{fontSize:"var(--font-size-lg)",fontWeight:"var(--font-weight-semibold)"}};function jo(t){return t<=.1?{label:"Safe",color:"var(--color-success)"}:t<=.3?{label:"Warning",color:"var(--color-warning)"}:{label:"Danger",color:"var(--color-danger)"}}function Yo({walletId:t}){const a=c(null),n=c(!1),l=c(null);if(X(()=>{t&&(n.value=!0,l.value=null,Se(`/v1/wallets/${t}/hyperliquid/account`).then(v=>{a.value=v.state}).catch(v=>{l.value=v instanceof Error?v.message:"Failed to load account state"}).finally(()=>{n.value=!1}))},[t]),!t)return e("p",{style:{color:"var(--color-text-muted)"},children:"Select a wallet to view Hyperliquid account"});if(n.value)return e("p",{children:"Loading account state..."});if(l.value)return e("p",{style:{color:"var(--color-danger)"},children:l.value});const i=a.value?.marginSummary??a.value?.crossMarginSummary;if(!i)return e("p",{style:{color:"var(--color-text-muted)"},children:"No account data available"});const r=parseFloat(i.accountValue??"0"),s=parseFloat(i.totalMarginUsed??"0"),o=r-s,u=r>0?s/r:0,d=jo(u);return e("div",{style:xe.grid,children:[e("div",{style:xe.card,children:[e("div",{style:xe.label,children:"Perp Equity"}),e("div",{style:xe.value,children:["$",r.toFixed(2)]})]}),e("div",{style:xe.card,children:[e("div",{style:xe.label,children:"Margin Used"}),e("div",{style:xe.value,children:["$",s.toFixed(2)]})]}),e("div",{style:xe.card,children:[e("div",{style:xe.label,children:"Available Margin"}),e("div",{style:xe.value,children:["$",o.toFixed(2)]})]}),e("div",{style:xe.card,children:[e("div",{style:xe.label,children:"Margin Ratio"}),e("div",{style:{...xe.value,color:d.color},children:[(u*100).toFixed(1),"% (",d.label,")"]})]})]})}const Be={padding:"var(--space-2) var(--space-3)",textAlign:"right",whiteSpace:"nowrap"},Qe={...Be,fontWeight:"var(--font-weight-semibold)",color:"var(--color-text-muted)",fontSize:"var(--font-size-sm)",borderBottom:"2px solid var(--color-border)"};function Xo({walletId:t}){const a=c([]),n=c(!1),l=c(null),i=qe(null),r=()=>{t&&Se(`/v1/wallets/${t}/hyperliquid/positions`).then(s=>{a.value=s.positions,l.value=null}).catch(s=>{l.value=s instanceof Error?s.message:"Failed to load positions"}).finally(()=>{n.value=!1})};return X(()=>{if(t)return n.value=!0,r(),i.current=setInterval(r,Ut),()=>{i.current&&clearInterval(i.current)}},[t]),t?n.value?e("p",{children:"Loading positions..."}):l.value?e("p",{style:{color:"var(--color-danger)"},children:l.value}):a.value.length===0?e("p",{style:{color:"var(--color-text-muted)"},children:"No open positions"}):e("div",{style:{overflowX:"auto"},children:e("table",{style:{width:"100%",borderCollapse:"collapse"},children:[e("thead",{children:e("tr",{children:[e("th",{style:{...Qe,textAlign:"left"},children:"Market"}),e("th",{style:Qe,children:"Side"}),e("th",{style:Qe,children:"Size"}),e("th",{style:Qe,children:"Entry Price"}),e("th",{style:Qe,children:"Position Value"}),e("th",{style:Qe,children:"PnL"}),e("th",{style:Qe,children:"Leverage"}),e("th",{style:Qe,children:"Liquidation"})]})}),e("tbody",{children:a.value.map(s=>{const o=parseFloat(s.szi),u=o>0?"LONG":"SHORT",d=o>0?"var(--color-success)":"var(--color-danger)",v=parseFloat(s.unrealizedPnl??"0"),h=v>=0?"var(--color-success)":"var(--color-danger)";return e("tr",{style:{borderBottom:"1px solid var(--color-border)"},children:[e("td",{style:{...Be,textAlign:"left",fontWeight:"var(--font-weight-semibold)"},children:s.coin}),e("td",{style:{...Be,color:d},children:u}),e("td",{style:Be,children:Math.abs(o).toFixed(4)}),e("td",{style:Be,children:s.entryPx?parseFloat(s.entryPx).toFixed(2):"-"}),e("td",{style:Be,children:["$",s.positionValue?parseFloat(s.positionValue).toFixed(2):"-"]}),e("td",{style:{...Be,color:h},children:[v>=0?"+":"",v.toFixed(2)]}),e("td",{style:Be,children:[s.leverage?.value??"-","x"]}),e("td",{style:Be,children:s.liquidationPx?parseFloat(s.liquidationPx).toFixed(2):"-"})]},s.coin)})})]})}):e("p",{style:{color:"var(--color-text-muted)"},children:"Select a wallet to view positions"})}const He={padding:"var(--space-2) var(--space-3)",textAlign:"right",whiteSpace:"nowrap"},Ze={...He,fontWeight:"var(--font-weight-semibold)",color:"var(--color-text-muted)",fontSize:"var(--font-size-sm)",borderBottom:"2px solid var(--color-border)"};function Jo({walletId:t}){const a=c([]),n=c(!1),l=c(null);return X(()=>{t&&(n.value=!0,l.value=null,Se(`/v1/wallets/${t}/hyperliquid/orders`).then(i=>{a.value=i.orders}).catch(i=>{l.value=i instanceof Error?i.message:"Failed to load orders"}).finally(()=>{n.value=!1}))},[t]),t?n.value?e("p",{children:"Loading orders..."}):l.value?e("p",{style:{color:"var(--color-danger)"},children:l.value}):a.value.length===0?e("p",{style:{color:"var(--color-text-muted)"},children:"No open orders"}):e("div",{style:{overflowX:"auto"},children:e("table",{style:{width:"100%",borderCollapse:"collapse"},children:[e("thead",{children:e("tr",{children:[e("th",{style:{...Ze,textAlign:"left"},children:"Market"}),e("th",{style:Ze,children:"Side"}),e("th",{style:Ze,children:"Type"}),e("th",{style:Ze,children:"Size"}),e("th",{style:Ze,children:"Price"}),e("th",{style:Ze,children:"Trigger"}),e("th",{style:Ze,children:"TIF"}),e("th",{style:Ze,children:"Created"})]})}),e("tbody",{children:a.value.map(i=>{const r=i.side==="B"||i.side==="BUY"?"var(--color-success)":"var(--color-danger)",s=i.side==="B"||i.side==="BUY"?"BUY":"SELL";return e("tr",{style:{borderBottom:"1px solid var(--color-border)"},children:[e("td",{style:{...He,textAlign:"left",fontWeight:"var(--font-weight-semibold)"},children:i.coin}),e("td",{style:{...He,color:r},children:s}),e("td",{style:He,children:i.orderType??"LIMIT"}),e("td",{style:He,children:parseFloat(i.sz).toFixed(4)}),e("td",{style:He,children:parseFloat(i.limitPx).toFixed(2)}),e("td",{style:He,children:i.triggerPx?parseFloat(i.triggerPx).toFixed(2):"-"}),e("td",{style:He,children:i.tif??"GTC"}),e("td",{style:He,children:i.timestamp?new Date(i.timestamp).toLocaleString():"-"})]},i.oid)})})]})}):e("p",{style:{color:"var(--color-text-muted)"},children:"Select a wallet to view orders"})}const Ua={padding:"var(--space-2) var(--space-3)",textAlign:"right",whiteSpace:"nowrap"},ft={...Ua,fontWeight:"var(--font-weight-semibold)",color:"var(--color-text-muted)",fontSize:"var(--font-size-sm)",borderBottom:"2px solid var(--color-border)"};function Qo({walletId:t}){const a=c([]),n=c(!1),l=c(null),i=qe(null),r=()=>{t&&Se(`/v1/wallets/${t}/hyperliquid/spot/balances`).then(s=>{const o=s.balances;a.value=o.filter(u=>parseFloat(u.total)!==0),l.value=null}).catch(s=>{l.value=s instanceof Error?s.message:"Failed to load spot balances"}).finally(()=>{n.value=!1})};return X(()=>{if(t)return n.value=!0,r(),i.current=setInterval(r,Ut),()=>{i.current&&clearInterval(i.current)}},[t]),t?n.value?e("p",{children:"Loading spot balances..."}):l.value?e("p",{style:{color:"var(--color-danger)"},children:l.value}):a.value.length===0?e("p",{style:{color:"var(--color-text-muted)"},children:"No spot balances"}):e("div",{style:{overflowX:"auto"},children:e("table",{style:{width:"100%",borderCollapse:"collapse"},children:[e("thead",{children:e("tr",{children:[e("th",{style:{...ft,textAlign:"left"},children:"Token"}),e("th",{style:ft,children:"Total"}),e("th",{style:ft,children:"Hold"}),e("th",{style:ft,children:"Available"})]})}),e("tbody",{children:a.value.map(s=>{const o=parseFloat(s.total),u=parseFloat(s.hold),d=o-u;return e("tr",{style:{borderBottom:"1px solid var(--color-border)"},children:[e("td",{style:{...Ua,textAlign:"left",fontWeight:"var(--font-weight-semibold)"},children:s.coin}),e("td",{style:Ua,children:o.toFixed(4)}),e("td",{style:Ua,children:u>0?u.toFixed(4):"-"}),e("td",{style:Ua,children:d.toFixed(4)})]},s.coin)})})]})}):e("p",{style:{color:"var(--color-text-muted)"},children:"Select a wallet to view spot balances"})}const ea={padding:"var(--space-2) var(--space-3)",textAlign:"right",whiteSpace:"nowrap"},ca={...ea,fontWeight:"var(--font-weight-semibold)",color:"var(--color-text-muted)",fontSize:"var(--font-size-sm)",borderBottom:"2px solid var(--color-border)"};function Zo({walletId:t}){const a=c([]),n=c(!1),l=c(null);return X(()=>{t&&(n.value=!0,l.value=null,Se(`/v1/wallets/${t}/hyperliquid/orders`).then(i=>{const r=i.orders;a.value=r.filter(s=>s.coin.includes("/"))}).catch(i=>{l.value=i instanceof Error?i.message:"Failed to load spot orders"}).finally(()=>{n.value=!1}))},[t]),t?n.value?e("p",{children:"Loading spot orders..."}):l.value?e("p",{style:{color:"var(--color-danger)"},children:l.value}):a.value.length===0?e("p",{style:{color:"var(--color-text-muted)"},children:"No spot orders"}):e("div",{style:{overflowX:"auto"},children:e("table",{style:{width:"100%",borderCollapse:"collapse"},children:[e("thead",{children:e("tr",{children:[e("th",{style:{...ca,textAlign:"left"},children:"Market"}),e("th",{style:ca,children:"Side"}),e("th",{style:ca,children:"Type"}),e("th",{style:ca,children:"Size"}),e("th",{style:ca,children:"Price"}),e("th",{style:ca,children:"TIF"}),e("th",{style:ca,children:"Created"})]})}),e("tbody",{children:a.value.map(i=>{const r=i.side==="B"||i.side==="BUY"?"var(--color-success)":"var(--color-danger)",s=i.side==="B"||i.side==="BUY"?"BUY":"SELL";return e("tr",{style:{borderBottom:"1px solid var(--color-border)"},children:[e("td",{style:{...ea,textAlign:"left",fontWeight:"var(--font-weight-semibold)"},children:i.coin}),e("td",{style:{...ea,color:r},children:s}),e("td",{style:ea,children:i.orderType??"LIMIT"}),e("td",{style:ea,children:parseFloat(i.sz).toFixed(4)}),e("td",{style:ea,children:parseFloat(i.limitPx).toFixed(2)}),e("td",{style:ea,children:i.tif??"GTC"}),e("td",{style:ea,children:i.timestamp?new Date(i.timestamp).toLocaleString():"-"})]},i.oid)})})]})}):e("p",{style:{color:"var(--color-text-muted)"},children:"Select a wallet to view spot orders"})}const _n={padding:"var(--space-2) var(--space-3)",textAlign:"left",whiteSpace:"nowrap"},kl={..._n,fontWeight:"var(--font-weight-semibold)",color:"var(--color-text-muted)",fontSize:"var(--font-size-sm)",borderBottom:"2px solid var(--color-border)"};function ec({walletId:t,onSelect:a}){const n=c([]),l=c(!1),i=c(null),r=qe(null),s=()=>{t&&Se(`/v1/wallets/${t}/hyperliquid/sub-accounts`).then(o=>{n.value=o.subAccounts??[],i.value=null}).catch(o=>{i.value=o instanceof Error?o.message:"Failed to load sub-accounts"}).finally(()=>{l.value=!1})};return X(()=>{if(t)return l.value=!0,s(),r.current=setInterval(s,Ut),()=>{r.current&&clearInterval(r.current)}},[t]),t?l.value?e("p",{children:"Loading sub-accounts..."}):i.value?e("p",{style:{color:"var(--color-danger)"},children:i.value}):n.value.length===0?e("p",{style:{color:"var(--color-text-muted)"},children:"No sub-accounts found"}):e("div",{style:{overflowX:"auto"},children:e("table",{style:{width:"100%",borderCollapse:"collapse"},children:[e("thead",{children:e("tr",{children:[e("th",{style:kl,children:"Name"}),e("th",{style:kl,children:"Address"})]})}),e("tbody",{children:n.value.map(o=>e("tr",{style:{borderBottom:"1px solid var(--color-border)",cursor:a?"pointer":"default"},onClick:()=>a?.(o.subAccountUser),children:[e("td",{style:{..._n,fontWeight:"var(--font-weight-semibold)"},children:o.name||"(unnamed)"}),e("td",{style:{..._n,fontFamily:"var(--font-mono)",fontSize:"var(--font-size-sm)"},children:[o.subAccountUser.slice(0,6),"...",o.subAccountUser.slice(-4)]})]},o.subAccountUser))})]})}):e("p",{style:{color:"var(--color-text-muted)"},children:"Select a wallet to view sub-accounts"})}const aa={padding:"var(--space-2) var(--space-3)",textAlign:"right",whiteSpace:"nowrap"},da={...aa,fontWeight:"var(--font-weight-semibold)",color:"var(--color-text-muted)",fontSize:"var(--font-size-sm)",borderBottom:"2px solid var(--color-border)"};function ac({walletId:t,subAccountAddress:a}){const n=c([]),l=c(!1),i=c(null),r=qe(null),s=()=>{!t||!a||Se(`/v1/wallets/${t}/hyperliquid/sub-accounts/${a}/positions`).then(o=>{n.value=o.positions??[],i.value=null}).catch(o=>{i.value=o instanceof Error?o.message:"Failed to load positions"}).finally(()=>{l.value=!1})};return X(()=>{if(!(!t||!a))return l.value=!0,s(),r.current=setInterval(s,Ut),()=>{r.current&&clearInterval(r.current)}},[t,a]),l.value?e("p",{children:"Loading positions..."}):i.value?e("p",{style:{color:"var(--color-danger)"},children:i.value}):n.value.length===0?e("p",{style:{color:"var(--color-text-muted)"},children:"No open positions for this sub-account"}):e("div",{style:{overflowX:"auto"},children:[e("h4",{style:{marginBottom:"var(--space-2)"},children:["Positions for ",a.slice(0,6),"...",a.slice(-4)]}),e("table",{style:{width:"100%",borderCollapse:"collapse"},children:[e("thead",{children:e("tr",{children:[e("th",{style:{...da,textAlign:"left"},children:"Market"}),e("th",{style:da,children:"Side"}),e("th",{style:da,children:"Size"}),e("th",{style:da,children:"Entry Price"}),e("th",{style:da,children:"PnL"}),e("th",{style:da,children:"Leverage"}),e("th",{style:da,children:"Liq. Price"})]})}),e("tbody",{children:n.value.map(o=>{const u=parseFloat(o.szi),d=u>0?"LONG":"SHORT",v=o.unrealizedPnl?parseFloat(o.unrealizedPnl):0;return e("tr",{style:{borderBottom:"1px solid var(--color-border)"},children:[e("td",{style:{...aa,textAlign:"left",fontWeight:"var(--font-weight-semibold)"},children:o.coin}),e("td",{style:{...aa,color:d==="LONG"?"var(--color-success)":"var(--color-danger)"},children:d}),e("td",{style:aa,children:Math.abs(u).toFixed(4)}),e("td",{style:aa,children:o.entryPx??"-"}),e("td",{style:{...aa,color:v>=0?"var(--color-success)":"var(--color-danger)"},children:[v>=0?"+":"",v.toFixed(2)]}),e("td",{style:aa,children:o.leverage?`${o.leverage.value}x`:"-"}),e("td",{style:aa,children:o.liquidationPx??"-"})]},o.coin)})})]})]})}const tc=[{key:"overview",label:"Overview"},{key:"orders",label:"Orders"},{key:"spot",label:"Spot"},{key:"subaccounts",label:"Sub-accounts"}];function nc(){const t=c([]),a=c(null),n=c("overview"),l=c(null),i=c(!0);return X(()=>{R.GET("/v1/wallets").then(({data:r})=>{const o=(r?.items??[]).filter(u=>u.chain==="ethereum");t.value=o,o.length>0&&!a.value&&(a.value=o[0].id)}).catch(()=>{}).finally(()=>{i.value=!1})},[]),i.value?e("p",{children:"Loading..."}):e("div",{children:[e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--color-text-muted)",marginBottom:"var(--space-3)"},children:e("a",{href:"#/providers",style:{color:"var(--color-primary)"},children:"Configure in Protocols > Providers"})}),e("div",{style:{marginBottom:"var(--space-4)"},children:[e("label",{style:{fontSize:"var(--font-size-sm)",color:"var(--color-text-muted)",marginRight:"var(--space-2)"},children:"Wallet:"}),e("select",{class:"form-input",style:{width:"auto",display:"inline-block",minWidth:"200px"},value:a.value??"",onChange:r=>{a.value=r.target.value||null},children:[t.value.length===0&&e("option",{value:"",children:"No EVM wallets available"}),t.value.map(r=>e("option",{value:r.id,children:[r.name," (",r.network,")"]},r.id))]})]}),e(Oe,{tabs:tc,activeTab:n.value,onTabChange:r=>{n.value=r,r==="subaccounts"&&(l.value=null)}}),n.value==="overview"&&e("div",{children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"Account Summary"}),e(Yo,{walletId:a.value}),e("h3",{style:{marginBottom:"var(--space-3)"},children:"Positions"}),e(Xo,{walletId:a.value})]}),n.value==="orders"&&e("div",{children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"Open Orders"}),e(Jo,{walletId:a.value})]}),n.value==="spot"&&e("div",{children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"Spot Balances"}),e(Qo,{walletId:a.value}),e("h3",{style:{marginTop:"var(--space-4)",marginBottom:"var(--space-3)"},children:"Spot Orders"}),e(Zo,{walletId:a.value})]}),n.value==="subaccounts"&&e("div",{children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"Sub-accounts"}),e(ec,{walletId:a.value,onSelect:r=>{l.value=r}}),l.value&&e("div",{style:{marginTop:"var(--space-4)"},children:e(ac,{walletId:a.value,subAccountAddress:l.value})})]})]})}function lc({walletId:t}){const a=c(null),n=c(null),l=c([]),i=c(!0);if(X(()=>{if(!t){i.value=!1;return}i.value=!0,Promise.all([Se(`/v1/wallets/${t}/polymarket/pnl`).catch(()=>null),Se(`/v1/wallets/${t}/polymarket/balance`).catch(()=>null),Se(`/v1/wallets/${t}/polymarket/orders`).catch(()=>({orders:[]}))]).then(([s,o,u])=>{a.value=s,n.value=o;const d=u;l.value=(d?.orders??[]).slice(0,5)}).finally(()=>{i.value=!1})},[t]),i.value)return e("p",{children:"Loading..."});if(!t)return e("p",{style:{color:"var(--color-text-muted)"},children:"Select a wallet to view overview."});const r=a.value?.pnl;return e("div",{children:[e("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"var(--space-3)",marginBottom:"var(--space-4)"},children:[e("div",{class:"card",style:{padding:"var(--space-3)"},children:[e("div",{style:{fontSize:"var(--font-size-sm)",color:"var(--color-text-muted)"},children:"Active Positions"}),e("div",{style:{fontSize:"var(--font-size-xl)",fontWeight:"var(--font-weight-semibold)"},children:r?.positionCount??0})]}),e("div",{class:"card",style:{padding:"var(--space-3)"},children:[e("div",{style:{fontSize:"var(--font-size-sm)",color:"var(--color-text-muted)"},children:"Unrealized PnL"}),e("div",{style:{fontSize:"var(--font-size-xl)",fontWeight:"var(--font-weight-semibold)"},children:r?.totalUnrealized??"0"})]}),e("div",{class:"card",style:{padding:"var(--space-3)"},children:[e("div",{style:{fontSize:"var(--font-size-sm)",color:"var(--color-text-muted)"},children:"CTF Tokens"}),e("div",{style:{fontSize:"var(--font-size-xl)",fontWeight:"var(--font-weight-semibold)"},children:n.value?.tokenCount??0})]})]}),e("h4",{style:{marginBottom:"var(--space-2)"},children:"Recent Orders"}),l.value.length===0?e("p",{style:{color:"var(--color-text-muted)"},children:"No Polymarket activity. Use pm_setup to create API keys."}):e("table",{class:"table",style:{width:"100%"},children:[e("thead",{children:e("tr",{children:[e("th",{children:"Side"}),e("th",{children:"Outcome"}),e("th",{children:"Price"}),e("th",{children:"Size"}),e("th",{children:"Status"})]})}),e("tbody",{children:l.value.map((s,o)=>{const u=s;return e("tr",{children:[e("td",{children:String(u.side??"")}),e("td",{children:String(u.outcome??"")}),e("td",{children:String(u.price??"")}),e("td",{children:String(u.size??"")}),e("td",{children:String(u.status??"")})]},o)})})]})]})}function ic(){const t=c([]),a=c(!0),n=c(""),l=c(""),i=c(null),r=(u,d)=>{a.value=!0;const v=new URLSearchParams;u&&v.set("keyword",u),d&&v.set("category",d);const h=v.toString(),m=`/v1/polymarket/markets${h?`?${h}`:""}`;Se(m).then(b=>{const U=b;t.value=U.markets??[]}).catch(()=>{t.value=[]}).finally(()=>{a.value=!1})};X(()=>{r()},[]);const s=u=>{n.value=u,i.value&&clearTimeout(i.value),i.value=setTimeout(()=>{r(u,l.value)},300)},o=u=>{l.value=u,r(n.value,u)};return a.value&&t.value.length===0?e("p",{children:"Loading markets..."}):e("div",{children:[e("div",{style:{display:"flex",gap:"var(--space-3)",marginBottom:"var(--space-3)"},children:[e("input",{type:"text",class:"form-input",placeholder:"Search markets...",value:n.value,onInput:u=>s(u.target.value),style:{flex:1}}),e("select",{class:"form-input",style:{width:"auto",minWidth:"150px"},value:l.value,onChange:u=>o(u.target.value),children:[e("option",{value:"",children:"All Categories"}),e("option",{value:"politics",children:"Politics"}),e("option",{value:"crypto",children:"Crypto"}),e("option",{value:"sports",children:"Sports"}),e("option",{value:"science",children:"Science"}),e("option",{value:"culture",children:"Culture"})]})]}),t.value.length===0?e("p",{style:{color:"var(--color-text-muted)"},children:"No markets found."}):e("table",{class:"table",style:{width:"100%"},children:[e("thead",{children:e("tr",{children:[e("th",{children:"Question"}),e("th",{children:"Volume"}),e("th",{children:"Liquidity"}),e("th",{children:"End Date"})]})}),e("tbody",{children:t.value.map(u=>e("tr",{children:[e("td",{style:{maxWidth:"400px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u.question}),e("td",{children:u.volume}),e("td",{children:u.liquidity}),e("td",{children:u.endDate})]},u.conditionId))})]})]})}function rc({walletId:t}){const a=c([]),n=c(!0),l=c("ALL"),i=s=>{if(!t){n.value=!1;return}n.value=!0;const o=s&&s!=="ALL"?`?status=${s}`:"";Se(`/v1/wallets/${t}/polymarket/orders${o}`).then(u=>{const d=u;a.value=d.orders??[]}).catch(()=>{a.value=[]}).finally(()=>{n.value=!1})};X(()=>{i(l.value)},[t]);const r=s=>{l.value=s,i(s)};return t?n.value?e("p",{children:"Loading orders..."}):e("div",{children:[e("div",{style:{marginBottom:"var(--space-3)"},children:[e("label",{style:{fontSize:"var(--font-size-sm)",color:"var(--color-text-muted)",marginRight:"var(--space-2)"},children:"Status:"}),e("select",{class:"form-input",style:{width:"auto",display:"inline-block",minWidth:"120px"},value:l.value,onChange:s=>r(s.target.value),children:[e("option",{value:"ALL",children:"All"}),e("option",{value:"LIVE",children:"Live"}),e("option",{value:"MATCHED",children:"Matched"}),e("option",{value:"CANCELLED",children:"Cancelled"})]})]}),a.value.length===0?e("p",{style:{color:"var(--color-text-muted)"},children:"No orders found."}):e("table",{class:"table",style:{width:"100%"},children:[e("thead",{children:e("tr",{children:[e("th",{children:"Market"}),e("th",{children:"Side"}),e("th",{children:"Type"}),e("th",{children:"Price"}),e("th",{children:"Size"}),e("th",{children:"Status"}),e("th",{children:"Created"})]})}),e("tbody",{children:a.value.map(s=>e("tr",{children:[e("td",{style:{maxWidth:"250px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s.market}),e("td",{children:s.side}),e("td",{children:s.type}),e("td",{children:s.price}),e("td",{children:s.size}),e("td",{children:s.status}),e("td",{children:s.createdAt})]},s.id))})]})]}):e("p",{style:{color:"var(--color-text-muted)"},children:"Select a wallet to view orders."})}function sc({walletId:t}){const a=c([]),n=c(!0);if(X(()=>{if(!t){n.value=!1;return}n.value=!0,Se(`/v1/wallets/${t}/polymarket/positions`).then(r=>{const s=r;a.value=s.positions??[]}).catch(()=>{a.value=[]}).finally(()=>{n.value=!1})},[t]),!t)return e("p",{style:{color:"var(--color-text-muted)"},children:"Select a wallet to view positions."});if(n.value)return e("p",{children:"Loading positions..."});const l=a.value.filter(r=>!r.resolved),i=a.value.filter(r=>r.resolved);return a.value.length===0?e("p",{style:{color:"var(--color-text-muted)"},children:"No positions."}):e("div",{children:[l.length>0&&e("div",{style:{marginBottom:"var(--space-4)"},children:[e("h4",{style:{marginBottom:"var(--space-2)"},children:"Active Positions"}),e("table",{class:"table",style:{width:"100%"},children:[e("thead",{children:e("tr",{children:[e("th",{children:"Market"}),e("th",{children:"Outcome"}),e("th",{children:"Size"}),e("th",{children:"Avg Price"}),e("th",{children:"Current"}),e("th",{children:"Unrealized PnL"})]})}),e("tbody",{children:l.map(r=>e("tr",{children:[e("td",{style:{maxWidth:"250px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.market}),e("td",{children:r.outcome}),e("td",{children:r.size}),e("td",{children:r.avgPrice}),e("td",{children:r.currentPrice}),e("td",{children:r.unrealizedPnl})]},`${r.conditionId}-${r.outcome}`))})]})]}),i.length>0&&e("div",{children:[e("h4",{style:{marginBottom:"var(--space-2)"},children:"Resolved Markets"}),e("table",{class:"table",style:{width:"100%"},children:[e("thead",{children:e("tr",{children:[e("th",{children:"Market"}),e("th",{children:"Outcome"}),e("th",{children:"Size"}),e("th",{children:"PnL"}),e("th",{children:"Redeemable"})]})}),e("tbody",{children:i.map(r=>e("tr",{children:[e("td",{style:{maxWidth:"250px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.market}),e("td",{children:r.outcome}),e("td",{children:r.size}),e("td",{children:r.unrealizedPnl}),e("td",{children:r.redeemable?"Yes":"No"})]},`${r.conditionId}-${r.outcome}`))})]})]})]})}const oc=[{key:"overview",label:"Overview"},{key:"markets",label:"Markets"},{key:"orders",label:"Orders"},{key:"positions",label:"Positions"}];function cc(){const t=c([]),a=c(null),n=c("overview"),l=c(!0);return X(()=>{R.GET("/v1/wallets").then(({data:i})=>{const s=(i?.items??[]).filter(o=>o.chain==="ethereum"&&o.network.includes("polygon"));t.value=s,s.length>0&&!a.value&&(a.value=s[0].id)}).catch(()=>{}).finally(()=>{l.value=!1})},[]),l.value?e("p",{children:"Loading..."}):e("div",{children:[e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--color-text-muted)",marginBottom:"var(--space-3)"},children:e("a",{href:"#/providers",style:{color:"var(--color-primary)"},children:"Configure in Protocols > Providers"})}),e("div",{style:{marginBottom:"var(--space-4)"},children:[e("label",{style:{fontSize:"var(--font-size-sm)",color:"var(--color-text-muted)",marginRight:"var(--space-2)"},children:"Wallet:"}),e("select",{class:"form-input",style:{width:"auto",display:"inline-block",minWidth:"200px"},value:a.value??"",onChange:i=>{a.value=i.target.value||null},children:[t.value.length===0&&e("option",{value:"",children:"No Polygon wallets available"}),t.value.map(i=>e("option",{value:i.id,children:[i.name," (",i.network,")"]},i.id))]})]}),e(Oe,{tabs:oc,activeTab:n.value,onTabChange:i=>{n.value=i}}),n.value==="overview"&&e("div",{children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"Overview"}),e(lc,{walletId:a.value})]}),n.value==="markets"&&e("div",{children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"Markets"}),e(ic,{})]}),n.value==="orders"&&e("div",{children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"Orders"}),e(rc,{walletId:a.value})]}),n.value==="positions"&&e("div",{children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"Positions"}),e(sc,{walletId:a.value})]})]})}const dc=50,uc=[{value:"WALLET_CREATED",label:"Wallet Created"},{value:"WALLET_SUSPENDED",label:"Wallet Suspended"},{value:"WALLET_PURGED",label:"Wallet Purged"},{value:"SESSION_CREATED",label:"Session Created"},{value:"SESSION_REVOKED",label:"Session Revoked"},{value:"SESSION_ISSUED_VIA_TELEGRAM",label:"Session Issued via Telegram"},{value:"TX_SUBMITTED",label:"TX Submitted"},{value:"TX_CONFIRMED",label:"TX Confirmed"},{value:"TX_FAILED",label:"TX Failed"},{value:"TX_APPROVED_VIA_TELEGRAM",label:"TX Approved via Telegram"},{value:"TX_REJECTED_VIA_TELEGRAM",label:"TX Rejected via Telegram"},{value:"TX_CANCELLED_VIA_TELEGRAM",label:"TX Cancelled via Telegram"},{value:"UNLISTED_TOKEN_TRANSFER",label:"Unlisted Token Transfer"},{value:"POLICY_DENIED",label:"Policy Denied"},{value:"KILL_SWITCH_ACTIVATED",label:"Kill Switch Activated"},{value:"KILL_SWITCH_ESCALATED",label:"Kill Switch Escalated"},{value:"KILL_SWITCH_RECOVERED",label:"Kill Switch Recovered"},{value:"AUTO_STOP_TRIGGERED",label:"Auto Stop Triggered"},{value:"MASTER_AUTH_FAILED",label:"Master Auth Failed"},{value:"OWNER_REGISTERED",label:"Owner Registered"},{value:"PROVIDER_UPDATED",label:"Provider Updated"},{value:"NOTIFICATION_TOTAL_FAILURE",label:"Notification Total Failure"},{value:"USEROP_BUILD",label:"UserOp Build"},{value:"USEROP_SIGNED",label:"UserOp Signed"}],vc=[{value:"info",label:"Info"},{value:"warning",label:"Warning"},{value:"critical",label:"Critical"}],hc=[{key:"event_type",label:"Event Type",type:"select",options:uc},{key:"severity",label:"Severity",type:"select",options:vc},{key:"from",label:"From",type:"date"},{key:"to",label:"To",type:"date"}];function El(t){return t==="critical"?"danger":t==="warning"?"warning":"info"}function pc(){const t=c([]),a=c(!0),n=c({event_type:"",severity:"",from:"",to:""}),l=c([]),i=c(void 0),r=c(null),s=c(!1),o=c(void 0),u=c(!1),d=c(null),v=async()=>{a.value=!0;try{const T=n.value,D={limit:dc,include_total:!0};i.value!==void 0&&(D.cursor=i.value),T.event_type&&(D.event_type=T.event_type),T.severity&&(D.severity=T.severity),T.from&&(D.from=Math.floor(new Date(T.from).getTime()/1e3)),T.to&&(D.to=Math.floor(new Date(T.to).getTime()/1e3)+86399);const{data:M}=await R.GET("/v1/audit-logs",{params:{query:D}});t.value=M.data,r.value=M.nextCursor,s.value=M.hasMore,M.total!==void 0&&(o.value=M.total)}catch(T){const D=T instanceof _?T:new _(0,"UNKNOWN","Unknown error");y("error",G(D.code))}finally{a.value=!1}};X(()=>{v()},[n.value,i.value]);const h=T=>{n.value=T,l.value=[],i.value=void 0,r.value=null},m=()=>{r.value!==null&&(l.value=[...l.value,i.value??0],i.value=r.value)},b=()=>{if(l.value.length===0)return;const T=[...l.value],D=T.pop();l.value=T,i.value=D===0?void 0:D},U=T=>{d.value=T,u.value=!0},W=l.value.length+1,p=[{key:"timestamp",header:"Time",render:T=>ve(T.timestamp)},{key:"eventType",header:"Event",render:T=>T.eventType.replace(/_/g," ")},{key:"severity",header:"Severity",render:T=>e(Y,{variant:El(T.severity),children:T.severity.toUpperCase()})},{key:"actor",header:"Actor",render:T=>T.actor},{key:"walletId",header:"Wallet",render:T=>T.walletId?T.walletId.slice(0,8)+"...":"-"},{key:"txId",header:"TX",render:T=>T.txId?T.txId.slice(0,8)+"...":"-"},{key:"ipAddress",header:"IP",render:T=>T.ipAddress??"-"}];return e("div",{class:"page",children:[e(ja,{fields:hc,values:n.value,onChange:h}),o.value!==void 0&&!a.value&&e("div",{style:{marginBottom:"var(--space-2)",color:"var(--color-text-secondary)",fontSize:"0.85rem"},children:[o.value," total log",o.value!==1?"s":""]}),e(Le,{columns:p,data:t.value,loading:a.value,emptyMessage:"No audit logs found",onRowClick:U}),!a.value&&t.value.length>0&&e("div",{class:"pagination-controls",style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"var(--space-3)"},children:[e(x,{variant:"secondary",size:"sm",disabled:l.value.length===0,onClick:b,children:"Previous"}),e("span",{style:{color:"var(--color-text-secondary)",fontSize:"0.85rem"},children:["Page ",W]}),e(x,{variant:"secondary",size:"sm",disabled:!s.value,onClick:m,children:"Next"})]}),e(he,{open:u.value,title:"Audit Log Detail",onCancel:()=>{u.value=!1},cancelText:"Close",children:d.value&&e("div",{class:"audit-detail",children:[e("div",{class:"audit-detail-fields",style:{display:"grid",gridTemplateColumns:"120px 1fr",gap:"var(--space-2)",marginBottom:"var(--space-3)"},children:[e("strong",{children:"Time"}),e("span",{children:ve(d.value.timestamp)}),e("strong",{children:"Event"}),e("span",{children:d.value.eventType}),e("strong",{children:"Severity"}),e("span",{children:e(Y,{variant:El(d.value.severity),children:d.value.severity.toUpperCase()})}),e("strong",{children:"Actor"}),e("span",{children:d.value.actor}),e("strong",{children:"Wallet ID"}),e("span",{children:d.value.walletId??"-"}),e("strong",{children:"Session ID"}),e("span",{children:d.value.sessionId??"-"}),e("strong",{children:"TX ID"}),e("span",{children:d.value.txId??"-"}),e("strong",{children:"IP Address"}),e("span",{children:d.value.ipAddress??"-"})]}),e("div",{children:[e("strong",{style:{display:"block",marginBottom:"var(--space-1)"},children:"Details"}),e("pre",{style:{background:"var(--color-bg-secondary)",padding:"var(--space-2)",borderRadius:"var(--radius-md)",overflow:"auto",maxHeight:"300px",fontSize:"0.8rem"},children:JSON.stringify(d.value.details,null,2)})]})]})})]})}const Nl=[{label:"API Key",value:"api-key"},{label:"HMAC Secret",value:"hmac-secret"},{label:"RSA Private Key",value:"rsa-private-key"},{label:"Session Token",value:"session-token"},{label:"Custom",value:"custom"}];function mc(t){switch(t){case"api-key":return"info";case"hmac-secret":return"success";case"rsa-private-key":return"warning";case"session-token":return"info";default:return"info"}}function fc(){const t=c([]),a=c(!0),n=c(!1),l=c("api-key"),i=c(""),r=c(""),s=c(""),o=c(""),u=c(!1),d=c(!1),v=c(null),h=c(""),m=c(!1),b=c(!1),U=c(null),W=c(""),p=c(""),T=c(!1),D=async()=>{a.value=!0;try{const{data:k}=await R.GET("/v1/admin/credentials");t.value=k.credentials}catch(k){const V=k instanceof _?k:new _(0,"UNKNOWN","Unknown error");y("error",G(V.code))}finally{a.value=!1}};X(()=>{D()},[]);const M=async()=>{if(!i.value.trim()){y("error","Name is required");return}if(!r.value.trim()){y("error","Value is required");return}u.value=!0;try{await R.POST("/v1/admin/credentials",{body:{type:l.value,name:i.value.trim(),value:r.value,...s.value.trim()?{metadata:JSON.parse(s.value)}:{},...o.value?{expiresAt:Math.floor(new Date(o.value).getTime()/1e3)}:{}}}),y("success","Credential created"),n.value=!1,l.value="api-key",i.value="",r.value="",s.value="",o.value="",await D()}catch(k){const V=k instanceof _?k:new _(0,"UNKNOWN","Unknown error");y("error",G(V.code))}finally{u.value=!1}},O=async()=>{if(v.value){m.value=!0;try{await R.DELETE("/v1/admin/credentials/{ref}",{params:{path:{ref:v.value}}}),y("success","Credential deleted"),d.value=!1,v.value=null,await D()}catch(k){const V=k instanceof _?k:new _(0,"UNKNOWN","Unknown error");y("error",G(V.code))}finally{m.value=!1}}},q=async()=>{if(!(!U.value||!p.value.trim())){T.value=!0;try{await R.PUT("/v1/admin/credentials/{ref}/rotate",{params:{path:{ref:U.value}},body:{value:p.value}}),y("success","Credential rotated"),b.value=!1,U.value=null,p.value="",await D()}catch(k){const V=k instanceof _?k:new _(0,"UNKNOWN","Unknown error");y("error",G(V.code))}finally{T.value=!1}}},S=k=>{v.value=k.name,h.value=k.name,d.value=!0},C=k=>{U.value=k.name,W.value=k.name,p.value="",b.value=!0},N=[{key:"name",header:"Name"},{key:"type",header:"Type",render:k=>e(Y,{variant:mc(k.type),children:k.type})},{key:"expiresAt",header:"Expires",render:k=>k.expiresAt?ve(k.expiresAt):"Never"},{key:"createdAt",header:"Created",render:k=>ve(k.createdAt)},{key:"actions",header:"Actions",render:k=>e("span",{style:{display:"flex",gap:"0.25rem"},children:[e(x,{size:"sm",variant:"ghost",onClick:()=>C(k),children:"Rotate"}),e(x,{size:"sm",variant:"danger",onClick:()=>S(k),children:"Delete"})]})}];return!a.value&&t.value.length===0?e("div",{class:"page",children:[e(Ue,{title:"No Credentials",description:"Add credentials for external service authentication.",actionLabel:"Add Credential",onAction:()=>{n.value=!0}}),e(he,{open:n.value,title:"Add Global Credential",onCancel:()=>{n.value=!1},onConfirm:M,confirmText:"Create",loading:u.value,children:[e(E,{label:"Type",name:"cred-type",type:"select",value:l.value,onChange:k=>{l.value=k},options:Nl}),e(E,{label:"Name",name:"cred-name",value:i.value,onChange:k=>{i.value=k},placeholder:"e.g. polymarket-api-key",required:!0}),e(E,{label:"Value",name:"cred-value",type:"password",value:r.value,onChange:k=>{r.value=k},placeholder:"Secret value",required:!0}),e(E,{label:"Metadata (JSON)",name:"cred-metadata",type:"textarea",value:s.value,onChange:k=>{s.value=k},placeholder:'{"key": "value"}'}),e(E,{label:"Expires At",name:"cred-expires",value:o.value,onChange:k=>{o.value=k},placeholder:"YYYY-MM-DDTHH:mm (optional)"})]})]}):e("div",{class:"page",children:[e("div",{class:"page-actions",style:{display:"flex",justifyContent:"flex-end",marginBottom:"1rem"},children:e(x,{onClick:()=>{n.value=!0},children:"Add Credential"})}),e(Le,{columns:N,data:t.value,loading:a.value,emptyMessage:"No credentials found"}),e(he,{open:n.value,title:"Add Global Credential",onCancel:()=>{n.value=!1},onConfirm:M,confirmText:"Create",loading:u.value,children:[e(E,{label:"Type",name:"cred-type",type:"select",value:l.value,onChange:k=>{l.value=k},options:Nl}),e(E,{label:"Name",name:"cred-name",value:i.value,onChange:k=>{i.value=k},placeholder:"e.g. polymarket-api-key",required:!0}),e(E,{label:"Value",name:"cred-value",type:"password",value:r.value,onChange:k=>{r.value=k},placeholder:"Secret value",required:!0}),e(E,{label:"Metadata (JSON)",name:"cred-metadata",type:"textarea",value:s.value,onChange:k=>{s.value=k},placeholder:'{"key": "value"}'}),e(E,{label:"Expires At",name:"cred-expires",value:o.value,onChange:k=>{o.value=k},placeholder:"YYYY-MM-DDTHH:mm (optional)"})]}),e(he,{open:d.value,title:"Delete Credential",onCancel:()=>{d.value=!1},onConfirm:O,confirmText:"Delete",confirmVariant:"danger",loading:m.value,children:e("p",{children:["Are you sure you want to delete credential ",e("strong",{children:h.value}),"? This action cannot be undone."]})}),e(he,{open:b.value,title:"Rotate Credential",onCancel:()=>{b.value=!1},onConfirm:q,confirmText:"Rotate",loading:T.value,children:[e("p",{children:["Enter a new value for credential ",e("strong",{children:W.value}),":"]}),e(E,{label:"New Value",name:"rotate-value",type:"password",value:p.value,onChange:k=>{p.value=k},placeholder:"New secret value",required:!0})]})]})}function pi(t){const a=t.slice(1)||"/dashboard",n=a.indexOf("?");return n>=0?a.slice(0,n):a}const ia=we(pi(window.location.hash)),yt=we(!1);window.addEventListener("hashchange",()=>{ia.value=pi(window.location.hash)});const yc={"/dashboard":"Dashboard","/wallets":"Wallets","/transactions":"Transactions","/sessions":"Sessions","/providers":"Providers","/hyperliquid":"Hyperliquid","/polymarket":"Polymarket","/agent-identity":"Agent Identity","/credentials":"Credentials","/policies":"Policies","/notifications":"Notifications","/protection":"Protection","/wallet-apps":"Wallet Apps","/audit-logs":"Audit Logs","/settings":"Settings"},gc={"/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","/providers":"Manage DeFi action providers and API keys","/hyperliquid":"Hyperliquid perpetual trading positions, orders, and settings","/polymarket":"Polymarket prediction market positions, orders, and settings","/agent-identity":"On-chain agent identity, reputation, and wallet linking","/credentials":"Manage encryption credentials for external service authentication","/policies":"Configure transaction policies and rules","/notifications":"Channel status, delivery logs, and settings","/protection":"Emergency controls and automatic protection rules","/wallet-apps":"Manage wallet apps for signing and notifications","/audit-logs":"View security and operational audit events","/settings":"API keys, display preferences, and daemon configuration"};function _c(t){return t.startsWith("/wallets/")?"Wallet Detail":yc[t]??"Dashboard"}function Al(t){return gc[t]}const bc={path:"/dashboard",label:"Dashboard"},wc=[{section:"Wallets",items:[{path:"/wallets",label:"Wallets"},{path:"/transactions",label:"Transactions"},{path:"/sessions",label:"Sessions"}]},{section:"Protocols",items:[{path:"/providers",label:"Providers"},{path:"/hyperliquid",label:"Hyperliquid"},{path:"/polymarket",label:"Polymarket"},{path:"/agent-identity",label:"Agent Identity"}]},{section:"Security",items:[{path:"/policies",label:"Policies"},{path:"/protection",label:"Protection"},{path:"/credentials",label:"Credentials"}]},{section:"Channels",items:[{path:"/notifications",label:"Notifications"},{path:"/wallet-apps",label:"Wallet Apps"}]},{section:"System",items:[{path:"/settings",label:"Settings"},{path:"/audit-logs",label:"Audit Logs"}]}];function Tc(){const t=ia.value,a=t.startsWith("/wallets/")?"/wallets/detail":t;let n;return t==="/transactions"?n=e(ol,{}):t==="/incoming"?(window.location.hash="#/transactions",n=e(ol,{})):t==="/tokens"?(me.value={tab:"tokens",fieldName:""},window.location.hash="#/wallets",n=e(Qt,{})):t==="/providers"?n=e(wl,{}):t==="/defi"||t==="/actions"?(window.location.hash="#/providers",n=e(wl,{})):t==="/hyperliquid"?n=e(nc,{}):t==="/polymarket"?n=e(cc,{}):t==="/sessions"?n=e(Xs,{}):t==="/credentials"?n=e(fc,{}):t==="/rpc-proxy"?(me.value={tab:"rpc-proxy",fieldName:""},window.location.hash="#/settings",n=e(on,{})):t==="/policies"?n=e(Ro,{}):t==="/notifications"?n=e(gl,{}):t==="/telegram-users"?(window.location.hash="#/notifications",n=e(gl,{})):t==="/settings"?n=e(on,{}):t==="/system"?(window.location.hash="#/settings",n=e(on,{})):t==="/walletconnect"?(window.location.hash="#/wallets",n=e(Qt,{})):t==="/protection"?n=e(_l,{}):t==="/security"?(window.location.hash="#/protection",n=e(_l,{})):t==="/wallet-apps"?n=e(qo,{}):t==="/agent-identity"?n=e(Sl,{}):t==="/erc8004"?(window.location.hash="#/agent-identity",n=e(Sl,{})):t==="/audit-logs"?n=e(pc,{}):t.startsWith("/wallets")?n=e(Qt,{}):n=e(Ts,{}),e("div",{children:n},a)}function Cl(t){const a=t.path==="/wallets"?ia.value.startsWith("/wallets"):ia.value===t.path;return e("a",{href:`#${t.path}`,class:`sidebar-link ${a?"active":""}`,onClick:n=>{ii.value&&(n.preventDefault(),ri({type:"nav",execute:()=>{window.location.hash=`#${t.path}`}}))},children:t.label},t.path)}function Sc(){return X(()=>{Hr()},[]),X(()=>{const t=a=>{(a.metaKey||a.ctrlKey)&&a.key==="k"&&(a.preventDefault(),yt.value=!yt.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:[Cl(bc),wc.map(t=>e("div",{children:[e("div",{style:{fontSize:"var(--font-size-xs)",fontWeight:"var(--font-weight-semibold)",color:"var(--color-text-muted)",textTransform:"uppercase",letterSpacing:"0.05em",padding:"var(--space-3) var(--space-4) var(--space-1)",marginTop:"var(--space-2)"},children:t.section}),t.items.map(a=>Cl(a))]},t.section))]})]}),e("main",{class:"main",children:[e("header",{class:"header",children:[e("div",{class:"header-left",children:[e("h1",{class:"header-title",children:_c(ia.value)}),Al(ia.value)&&e("p",{class:"header-subtitle",children:Al(ia.value)})]}),e("div",{class:"header-actions",children:[e("button",{class:"btn-search",onClick:()=>{yt.value=!0},title:"Search settings (Ctrl+K)",children:"🔍"}),e("button",{class:"btn-logout",onClick:()=>Ga(),children:"Logout"})]})]}),e("div",{class:"content",children:e(Tc,{})})]}),e(Cr,{open:yt}),e(Dr,{})]})}let cn=null;function kc(){return cn===null&&(cn=typeof window<"u"&&"__TAURI_INTERNALS__"in window),cn}const Il=we(!1),xl=we(!1),Dl=we(null),Rl=we(null),gt={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 Ec(){return e("div",{style:gt.overlay,children:e("div",{style:gt.content,children:[e("h1",{style:gt.title,children:"Daemon Shutting Down"}),e("p",{style:gt.message,children:"The daemon is shutting down. Please wait or restart."})]})})}function Nc(){if(X(()=>{kc()&&(async()=>{const{isFirstRun:a,wizardComplete:n}=await Gt(async()=>{const{isFirstRun:i,wizardComplete:r}=await import("./wizard-store-CZoifFis.js");return{isFirstRun:i,wizardComplete:r}},[]);if(a()){const{SetupWizard:i}=await Gt(async()=>{const{SetupWizard:s}=await import("./setup-wizard-CuTGFqla.js");return{SetupWizard:s}},__vite__mapDeps([0,1]));Dl.value=i,Il.value=!0;const r=n.subscribe(s=>{xl.value=s,s&&r()})}const{UpdateBanner:l}=await Gt(async()=>{const{UpdateBanner:i}=await import("./UpdateBanner-BfdJCibC.js");return{UpdateBanner:i}},[]);Rl.value=l})()},[]),gr.value)return e(Ec,{});if(Il.value&&!xl.value){const a=Dl.value;return a?e(a,{}):null}if(!yr.value)return e(Sr,{});const t=Rl.value;return e(le,{children:[t&&e(t,{}),e(Sc,{}),e(cs,{})]})}nr(e(Nc,{}),document.getElementById("app"));export{Ha as A,he as M,Gt as _,we as c,Cc as d,kc as i,le as k,wr as l,e as u,X as y};