@waiaas/daemon 2.10.0-rc → 2.10.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/README.md +1 -0
  2. package/dist/api/routes/actions.d.ts +4 -0
  3. package/dist/api/routes/actions.d.ts.map +1 -1
  4. package/dist/api/routes/actions.js +94 -1
  5. package/dist/api/routes/actions.js.map +1 -1
  6. package/dist/api/routes/connect-info.d.ts +5 -0
  7. package/dist/api/routes/connect-info.d.ts.map +1 -1
  8. package/dist/api/routes/connect-info.js +46 -1
  9. package/dist/api/routes/connect-info.js.map +1 -1
  10. package/dist/api/routes/erc8004.d.ts +28 -0
  11. package/dist/api/routes/erc8004.d.ts.map +1 -0
  12. package/dist/api/routes/erc8004.js +325 -0
  13. package/dist/api/routes/erc8004.js.map +1 -0
  14. package/dist/api/routes/index.d.ts +1 -0
  15. package/dist/api/routes/index.d.ts.map +1 -1
  16. package/dist/api/routes/index.js +1 -0
  17. package/dist/api/routes/index.js.map +1 -1
  18. package/dist/api/routes/openapi-schemas.d.ts +180 -5
  19. package/dist/api/routes/openapi-schemas.d.ts.map +1 -1
  20. package/dist/api/routes/openapi-schemas.js +43 -0
  21. package/dist/api/routes/openapi-schemas.js.map +1 -1
  22. package/dist/api/routes/transactions.d.ts +1 -0
  23. package/dist/api/routes/transactions.d.ts.map +1 -1
  24. package/dist/api/routes/transactions.js +6 -0
  25. package/dist/api/routes/transactions.js.map +1 -1
  26. package/dist/api/routes/wallets.d.ts +3 -0
  27. package/dist/api/routes/wallets.d.ts.map +1 -1
  28. package/dist/api/routes/wallets.js +78 -3
  29. package/dist/api/routes/wallets.js.map +1 -1
  30. package/dist/api/server.d.ts +4 -0
  31. package/dist/api/server.d.ts.map +1 -1
  32. package/dist/api/server.js +16 -0
  33. package/dist/api/server.js.map +1 -1
  34. package/dist/infrastructure/database/index.d.ts +1 -1
  35. package/dist/infrastructure/database/index.d.ts.map +1 -1
  36. package/dist/infrastructure/database/index.js +1 -1
  37. package/dist/infrastructure/database/index.js.map +1 -1
  38. package/dist/infrastructure/database/migrate.d.ts +1 -1
  39. package/dist/infrastructure/database/migrate.d.ts.map +1 -1
  40. package/dist/infrastructure/database/migrate.js +124 -5
  41. package/dist/infrastructure/database/migrate.js.map +1 -1
  42. package/dist/infrastructure/database/schema.d.ts +455 -1
  43. package/dist/infrastructure/database/schema.d.ts.map +1 -1
  44. package/dist/infrastructure/database/schema.js +44 -3
  45. package/dist/infrastructure/database/schema.js.map +1 -1
  46. package/dist/infrastructure/settings/hot-reload.d.ts.map +1 -1
  47. package/dist/infrastructure/settings/hot-reload.js +9 -0
  48. package/dist/infrastructure/settings/hot-reload.js.map +1 -1
  49. package/dist/infrastructure/settings/setting-keys.d.ts +1 -1
  50. package/dist/infrastructure/settings/setting-keys.d.ts.map +1 -1
  51. package/dist/infrastructure/settings/setting-keys.js +39 -0
  52. package/dist/infrastructure/settings/setting-keys.js.map +1 -1
  53. package/dist/infrastructure/smart-account/index.d.ts +5 -0
  54. package/dist/infrastructure/smart-account/index.d.ts.map +1 -0
  55. package/dist/infrastructure/smart-account/index.js +3 -0
  56. package/dist/infrastructure/smart-account/index.js.map +1 -0
  57. package/dist/infrastructure/smart-account/smart-account-clients.d.ts +40 -0
  58. package/dist/infrastructure/smart-account/smart-account-clients.d.ts.map +1 -0
  59. package/dist/infrastructure/smart-account/smart-account-clients.js +103 -0
  60. package/dist/infrastructure/smart-account/smart-account-clients.js.map +1 -0
  61. package/dist/infrastructure/smart-account/smart-account-service.d.ts +35 -0
  62. package/dist/infrastructure/smart-account/smart-account-service.d.ts.map +1 -0
  63. package/dist/infrastructure/smart-account/smart-account-service.js +45 -0
  64. package/dist/infrastructure/smart-account/smart-account-service.js.map +1 -0
  65. package/dist/lifecycle/daemon.d.ts.map +1 -1
  66. package/dist/lifecycle/daemon.js +35 -2
  67. package/dist/lifecycle/daemon.js.map +1 -1
  68. package/dist/pipeline/database-policy-engine.d.ts +45 -3
  69. package/dist/pipeline/database-policy-engine.d.ts.map +1 -1
  70. package/dist/pipeline/database-policy-engine.js +161 -12
  71. package/dist/pipeline/database-policy-engine.js.map +1 -1
  72. package/dist/pipeline/pipeline.d.ts.map +1 -1
  73. package/dist/pipeline/pipeline.js +1 -0
  74. package/dist/pipeline/pipeline.js.map +1 -1
  75. package/dist/pipeline/stages.d.ts +24 -0
  76. package/dist/pipeline/stages.d.ts.map +1 -1
  77. package/dist/pipeline/stages.js +479 -2
  78. package/dist/pipeline/stages.js.map +1 -1
  79. package/dist/services/erc8004/eip712-typed-data.d.ts +66 -0
  80. package/dist/services/erc8004/eip712-typed-data.d.ts.map +1 -0
  81. package/dist/services/erc8004/eip712-typed-data.js +53 -0
  82. package/dist/services/erc8004/eip712-typed-data.js.map +1 -0
  83. package/dist/services/erc8004/index.d.ts +8 -0
  84. package/dist/services/erc8004/index.d.ts.map +1 -0
  85. package/dist/services/erc8004/index.js +8 -0
  86. package/dist/services/erc8004/index.js.map +1 -0
  87. package/dist/services/erc8004/reputation-cache-service.d.ts +70 -0
  88. package/dist/services/erc8004/reputation-cache-service.d.ts.map +1 -0
  89. package/dist/services/erc8004/reputation-cache-service.js +221 -0
  90. package/dist/services/erc8004/reputation-cache-service.js.map +1 -0
  91. package/dist/services/signing-sdk/approval-channel-router.d.ts.map +1 -1
  92. package/dist/services/signing-sdk/approval-channel-router.js +9 -0
  93. package/dist/services/signing-sdk/approval-channel-router.js.map +1 -1
  94. package/dist/services/signing-sdk/sign-request-builder.d.ts +2 -0
  95. package/dist/services/signing-sdk/sign-request-builder.d.ts.map +1 -1
  96. package/dist/services/signing-sdk/sign-request-builder.js.map +1 -1
  97. package/dist/services/wc-signing-bridge.d.ts +8 -0
  98. package/dist/services/wc-signing-bridge.d.ts.map +1 -1
  99. package/dist/services/wc-signing-bridge.js +65 -1
  100. package/dist/services/wc-signing-bridge.js.map +1 -1
  101. package/dist/workflow/approval-workflow.d.ts +17 -0
  102. package/dist/workflow/approval-workflow.d.ts.map +1 -1
  103. package/dist/workflow/approval-workflow.js +31 -4
  104. package/dist/workflow/approval-workflow.js.map +1 -1
  105. package/package.json +5 -5
  106. package/public/admin/assets/index-C1XAaEL3.js +3 -0
  107. package/public/admin/index.html +1 -1
  108. package/public/admin/assets/index-RagPnRU1.js +0 -3
@@ -0,0 +1,3 @@
1
+ var $a,ee,ln,sn,Be,Nt,rn,on,cn,mt,rt,ot,fa={},dn=[],al=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Fa=Array.isArray;function Ce(t,a){for(var n in a)t[n]=a[n];return t}function ft(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function tl(t,a,n){var l,i,s,r={};for(s in a)s=="key"?l=a[s]:s=="ref"?i=a[s]:r[s]=a[s];if(arguments.length>2&&(r.children=arguments.length>3?$a.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(s in t.defaultProps)r[s]===void 0&&(r[s]=t.defaultProps[s]);return Oa(t,r,l,i,null)}function Oa(t,a,n,l,i){var s={type:t,props:a,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++ln,__i:-1,__u:0};return i==null&&ee.vnode!=null&&ee.vnode(s),s}function J(t){return t.children}function va(t,a){this.props=t,this.context=a}function ea(t,a){if(a==null)return t.__?ea(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"?ea(t):null}function un(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 un(t)}}function At(t){(!t.__d&&(t.__d=!0)&&Be.push(t)&&!xa.__r++||Nt!=ee.debounceRendering)&&((Nt=ee.debounceRendering)||rn)(xa)}function xa(){for(var t,a,n,l,i,s,r,c=1;Be.length;)Be.length>c&&Be.sort(on),t=Be.shift(),c=Be.length,t.__d&&(n=void 0,l=void 0,i=(l=(a=t).__v).__e,s=[],r=[],a.__P&&((n=Ce({},l)).__v=l.__v+1,ee.vnode&&ee.vnode(n),gt(a.__P,n,l,a.__n,a.__P.namespaceURI,32&l.__u?[i]:null,s,i??ea(l),!!(32&l.__u),r),n.__v=l.__v,n.__.__k[n.__i]=n,pn(s,n,r),l.__e=l.__=null,n.__e!=i&&un(n)));xa.__r=0}function vn(t,a,n,l,i,s,r,c,h,o,u){var v,f,N,x,W,y,A,w=l&&l.__k||dn,F=a.length;for(h=nl(n,a,w,h,F),v=0;v<F;v++)(N=n.__k[v])!=null&&(f=N.__i==-1?fa:w[N.__i]||fa,N.__i=v,y=gt(t,N,f,i,s,r,c,h,o,u),x=N.__e,N.ref&&f.ref!=N.ref&&(f.ref&&yt(f.ref,null,N),u.push(N.ref,N.__c||x,N)),W==null&&x!=null&&(W=x),(A=!!(4&N.__u))||f.__k===N.__k?h=hn(N,h,t,A):typeof N.type=="function"&&y!==void 0?h=y:x&&(h=x.nextSibling),N.__u&=-7);return n.__e=W,h}function nl(t,a,n,l,i){var s,r,c,h,o,u=n.length,v=u,f=0;for(t.__k=new Array(i),s=0;s<i;s++)(r=a[s])!=null&&typeof r!="boolean"&&typeof r!="function"?(typeof r=="string"||typeof r=="number"||typeof r=="bigint"||r.constructor==String?r=t.__k[s]=Oa(null,r,null,null,null):Fa(r)?r=t.__k[s]=Oa(J,{children:r},null,null,null):r.constructor===void 0&&r.__b>0?r=t.__k[s]=Oa(r.type,r.props,r.key,r.ref?r.ref:null,r.__v):t.__k[s]=r,h=s+f,r.__=t,r.__b=t.__b+1,c=null,(o=r.__i=ll(r,n,h,v))!=-1&&(v--,(c=n[o])&&(c.__u|=2)),c==null||c.__v==null?(o==-1&&(i>u?f--:i<u&&f++),typeof r.type!="function"&&(r.__u|=4)):o!=h&&(o==h-1?f--:o==h+1?f++:(o>h?f--:f++,r.__u|=4))):t.__k[s]=null;if(v)for(s=0;s<u;s++)(c=n[s])!=null&&(2&c.__u)==0&&(c.__e==l&&(l=ea(c)),fn(c,c));return l}function hn(t,a,n,l){var i,s;if(typeof t.type=="function"){for(i=t.__k,s=0;i&&s<i.length;s++)i[s]&&(i[s].__=t,a=hn(i[s],a,n,l));return a}t.__e!=a&&(l&&(a&&t.type&&!a.parentNode&&(a=ea(t)),n.insertBefore(t.__e,a||null)),a=t.__e);do a=a&&a.nextSibling;while(a!=null&&a.nodeType==8);return a}function ll(t,a,n,l){var i,s,r,c=t.key,h=t.type,o=a[n],u=o!=null&&(2&o.__u)==0;if(o===null&&c==null||u&&c==o.key&&h==o.type)return n;if(l>(u?1:0)){for(i=n-1,s=n+1;i>=0||s<a.length;)if((o=a[r=i>=0?i--:s++])!=null&&(2&o.__u)==0&&c==o.key&&h==o.type)return r}return-1}function Et(t,a,n){a[0]=="-"?t.setProperty(a,n??""):t[a]=n==null?"":typeof n!="number"||al.test(a)?n:n+"px"}function Ta(t,a,n,l,i){var s,r;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||Et(t.style,a,"");if(n)for(a in n)l&&n[a]==l[a]||Et(t.style,a,n[a])}else if(a[0]=="o"&&a[1]=="n")s=a!=(a=a.replace(cn,"$1")),r=a.toLowerCase(),a=r in t||a=="onFocusOut"||a=="onFocusIn"?r.slice(2):a.slice(2),t.l||(t.l={}),t.l[a+s]=n,n?l?n.u=l.u:(n.u=mt,t.addEventListener(a,s?ot:rt,s)):t.removeEventListener(a,s?ot:rt,s);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 Ct(t){return function(a){if(this.l){var n=this.l[a.type+t];if(a.t==null)a.t=mt++;else if(a.t<n.u)return;return n(ee.event?ee.event(a):a)}}}function gt(t,a,n,l,i,s,r,c,h,o){var u,v,f,N,x,W,y,A,w,F,D,H,O,k,_,m,R,g=a.type;if(a.constructor!==void 0)return null;128&n.__u&&(h=!!(32&n.__u),s=[c=a.__e=n.__e]),(u=ee.__b)&&u(a);e:if(typeof g=="function")try{if(A=a.props,w="prototype"in g&&g.prototype.render,F=(u=g.contextType)&&l[u.__c],D=u?F?F.props.value:u.__:l,n.__c?y=(v=a.__c=n.__c).__=v.__E:(w?a.__c=v=new g(A,D):(a.__c=v=new va(A,D),v.constructor=g,v.render=sl),F&&F.sub(v),v.state||(v.state={}),v.__n=l,f=v.__d=!0,v.__h=[],v._sb=[]),w&&v.__s==null&&(v.__s=v.state),w&&g.getDerivedStateFromProps!=null&&(v.__s==v.state&&(v.__s=Ce({},v.__s)),Ce(v.__s,g.getDerivedStateFromProps(A,v.__s))),N=v.props,x=v.state,v.__v=a,f)w&&g.getDerivedStateFromProps==null&&v.componentWillMount!=null&&v.componentWillMount(),w&&v.componentDidMount!=null&&v.__h.push(v.componentDidMount);else{if(w&&g.getDerivedStateFromProps==null&&A!==N&&v.componentWillReceiveProps!=null&&v.componentWillReceiveProps(A,D),a.__v==n.__v||!v.__e&&v.shouldComponentUpdate!=null&&v.shouldComponentUpdate(A,v.__s,D)===!1){for(a.__v!=n.__v&&(v.props=A,v.state=v.__s,v.__d=!1),a.__e=n.__e,a.__k=n.__k,a.__k.some(function(p){p&&(p.__=a)}),H=0;H<v._sb.length;H++)v.__h.push(v._sb[H]);v._sb=[],v.__h.length&&r.push(v);break e}v.componentWillUpdate!=null&&v.componentWillUpdate(A,v.__s,D),w&&v.componentDidUpdate!=null&&v.__h.push(function(){v.componentDidUpdate(N,x,W)})}if(v.context=D,v.props=A,v.__P=t,v.__e=!1,O=ee.__r,k=0,w){for(v.state=v.__s,v.__d=!1,O&&O(a),u=v.render(v.props,v.state,v.context),_=0;_<v._sb.length;_++)v.__h.push(v._sb[_]);v._sb=[]}else do v.__d=!1,O&&O(a),u=v.render(v.props,v.state,v.context),v.state=v.__s;while(v.__d&&++k<25);v.state=v.__s,v.getChildContext!=null&&(l=Ce(Ce({},l),v.getChildContext())),w&&!f&&v.getSnapshotBeforeUpdate!=null&&(W=v.getSnapshotBeforeUpdate(N,x)),m=u,u!=null&&u.type===J&&u.key==null&&(m=mn(u.props.children)),c=vn(t,Fa(m)?m:[m],a,n,l,i,s,r,c,h,o),v.base=a.__e,a.__u&=-161,v.__h.length&&r.push(v),y&&(v.__E=v.__=null)}catch(p){if(a.__v=null,h||s!=null)if(p.then){for(a.__u|=h?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;s[s.indexOf(c)]=null,a.__e=c}else{for(R=s.length;R--;)ft(s[R]);ct(a)}else a.__e=n.__e,a.__k=n.__k,p.then||ct(a);ee.__e(p,a,n)}else s==null&&a.__v==n.__v?(a.__k=n.__k,a.__e=n.__e):c=a.__e=il(n.__e,a,n,l,i,s,r,h,o);return(u=ee.diffed)&&u(a),128&a.__u?void 0:c}function ct(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(ct)}function pn(t,a,n){for(var l=0;l<n.length;l++)yt(n[l],n[++l],n[++l]);ee.__c&&ee.__c(a,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(s){s.call(i)})}catch(s){ee.__e(s,i.__v)}})}function mn(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:Fa(t)?t.map(mn):Ce({},t)}function il(t,a,n,l,i,s,r,c,h){var o,u,v,f,N,x,W,y=n.props||fa,A=a.props,w=a.type;if(w=="svg"?i="http://www.w3.org/2000/svg":w=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),s!=null){for(o=0;o<s.length;o++)if((N=s[o])&&"setAttribute"in N==!!w&&(w?N.localName==w:N.nodeType==3)){t=N,s[o]=null;break}}if(t==null){if(w==null)return document.createTextNode(A);t=document.createElementNS(i,w,A.is&&A),c&&(ee.__m&&ee.__m(a,s),c=!1),s=null}if(w==null)y===A||c&&t.data==A||(t.data=A);else{if(s=s&&$a.call(t.childNodes),!c&&s!=null)for(y={},o=0;o<t.attributes.length;o++)y[(N=t.attributes[o]).name]=N.value;for(o in y)if(N=y[o],o!="children"){if(o=="dangerouslySetInnerHTML")v=N;else if(!(o in A)){if(o=="value"&&"defaultValue"in A||o=="checked"&&"defaultChecked"in A)continue;Ta(t,o,null,N,i)}}for(o in A)N=A[o],o=="children"?f=N:o=="dangerouslySetInnerHTML"?u=N:o=="value"?x=N:o=="checked"?W=N:c&&typeof N!="function"||y[o]===N||Ta(t,o,N,y[o],i);if(u)c||v&&(u.__html==v.__html||u.__html==t.innerHTML)||(t.innerHTML=u.__html),a.__k=[];else if(v&&(t.innerHTML=""),vn(a.type=="template"?t.content:t,Fa(f)?f:[f],a,n,l,w=="foreignObject"?"http://www.w3.org/1999/xhtml":i,s,r,s?s[0]:n.__k&&ea(n,0),c,h),s!=null)for(o=s.length;o--;)ft(s[o]);c||(o="value",w=="progress"&&x==null?t.removeAttribute("value"):x!=null&&(x!==t[o]||w=="progress"&&!x||w=="option"&&x!=y[o])&&Ta(t,o,x,y[o],i),o="checked",W!=null&&W!=t[o]&&Ta(t,o,W,y[o],i))}return t}function yt(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){ee.__e(i,n)}}function fn(t,a,n){var l,i;if(ee.unmount&&ee.unmount(t),(l=t.ref)&&(l.current&&l.current!=t.__e||yt(l,null,a)),(l=t.__c)!=null){if(l.componentWillUnmount)try{l.componentWillUnmount()}catch(s){ee.__e(s,a)}l.base=l.__P=null}if(l=t.__k)for(i=0;i<l.length;i++)l[i]&&fn(l[i],a,n||typeof t.type!="function");n||ft(t.__e),t.__c=t.__=t.__e=void 0}function sl(t,a,n){return this.constructor(t,n)}function rl(t,a,n){var l,i,s,r;a==document&&(a=document.documentElement),ee.__&&ee.__(t,a),i=(l=!1)?null:a.__k,s=[],r=[],gt(a,t=a.__k=tl(J,null,[t]),i||fa,fa,a.namespaceURI,i?null:a.firstChild?$a.call(a.childNodes):null,s,i?i.__e:a.firstChild,l,r),pn(s,t,r)}$a=dn.slice,ee={__e:function(t,a,n,l){for(var i,s,r;a=a.__;)if((i=a.__c)&&!i.__)try{if((s=i.constructor)&&s.getDerivedStateFromError!=null&&(i.setState(s.getDerivedStateFromError(t)),r=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,l||{}),r=i.__d),r)return i.__E=i}catch(c){t=c}throw t}},ln=0,sn=function(t){return t!=null&&t.constructor===void 0},va.prototype.setState=function(t,a){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Ce({},this.state),typeof t=="function"&&(t=t(Ce({},n),this.props)),t&&Ce(n,t),t!=null&&this.__v&&(a&&this._sb.push(a),At(this))},va.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),At(this))},va.prototype.render=J,Be=[],rn=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,on=function(t,a){return t.__v.__b-a.__v.__b},xa.__r=0,cn=/(PointerCapture)$|Capture$/i,mt=0,rt=Ct(!1),ot=Ct(!0);var ol=0;function e(t,a,n,l,i,s){a||(a={});var r,c,h=a;if("ref"in h)for(c in h={},a)c=="ref"?r=a[c]:h[c]=a[c];var o={type:t,props:h,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ol,__i:-1,__u:0,__source:i,__self:s};if(typeof t=="function"&&(r=t.defaultProps))for(c in r)h[c]===void 0&&(h[c]=r[c]);return ee.vnode&&ee.vnode(o),o}var Ra,_e,Xa,It,dt=0,gn=[],ve=ee,Dt=ve.__b,Ot=ve.__r,Lt=ve.diffed,xt=ve.__c,Rt=ve.unmount,Pt=ve.__;function yn(t,a){ve.__h&&ve.__h(_e,t,dt||a),dt=0;var n=_e.__H||(_e.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function G(t,a){var n=yn(Ra++,3);!ve.__s&&_n(n.__H,a)&&(n.__=t,n.u=a,_e.__H.__h.push(n))}function _a(t){return dt=5,Ka(function(){return{current:t}},[])}function Ka(t,a){var n=yn(Ra++,7);return _n(n.__H,a)&&(n.__=t(),n.__H=a,n.__h=t),n.__}function cl(){for(var t;t=gn.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(La),t.__H.__h.forEach(ut),t.__H.__h=[]}catch(a){t.__H.__h=[],ve.__e(a,t.__v)}}ve.__b=function(t){_e=null,Dt&&Dt(t)},ve.__=function(t,a){t&&a.__k&&a.__k.__m&&(t.__m=a.__k.__m),Pt&&Pt(t,a)},ve.__r=function(t){Ot&&Ot(t),Ra=0;var a=(_e=t.__c).__H;a&&(Xa===_e?(a.__h=[],_e.__h=[],a.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(a.__h.forEach(La),a.__h.forEach(ut),a.__h=[],Ra=0)),Xa=_e},ve.diffed=function(t){Lt&&Lt(t);var a=t.__c;a&&a.__H&&(a.__H.__h.length&&(gn.push(a)!==1&&It===ve.requestAnimationFrame||((It=ve.requestAnimationFrame)||dl)(cl)),a.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),Xa=_e=null},ve.__c=function(t,a){a.some(function(n){try{n.__h.forEach(La),n.__h=n.__h.filter(function(l){return!l.__||ut(l)})}catch(l){a.some(function(i){i.__h&&(i.__h=[])}),a=[],ve.__e(l,n.__v)}}),xt&&xt(t,a)},ve.unmount=function(t){Rt&&Rt(t);var a,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(l){try{La(l)}catch(i){a=i}}),n.__H=void 0,a&&ve.__e(a,n.__v))};var Mt=typeof requestAnimationFrame=="function";function dl(t){var a,n=function(){clearTimeout(l),Mt&&cancelAnimationFrame(a),setTimeout(t)},l=setTimeout(n,35);Mt&&(a=requestAnimationFrame(n))}function La(t){var a=_e,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),_e=a}function ut(t){var a=_e;t.__c=t.__(),_e=a}function _n(t,a){return!t||t.length!==a.length||a.some(function(n,l){return n!==t[l]})}var ul=Symbol.for("preact-signals");function Ha(){if(Ue>1)Ue--;else{for(var t,a=!1;ha!==void 0;){var n=ha;for(ha=void 0,vt++;n!==void 0;){var l=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Sn(n))try{n.c()}catch(i){a||(t=i,a=!0)}n=l}}if(vt=0,Ue--,a)throw t}}function vl(t){if(Ue>0)return t();Ue++;try{return t()}finally{Ha()}}var Q=void 0;function bn(t){var a=Q;Q=void 0;try{return t()}finally{Q=a}}var ha=void 0,Ue=0,vt=0,Pa=0;function wn(t){if(Q!==void 0){var a=t.n;if(a===void 0||a.t!==Q)return a={i:0,S:t,p:Q.s,n:void 0,t:Q,e:void 0,x:void 0,r:a},Q.s!==void 0&&(Q.s.n=a),Q.s=a,t.n=a,32&Q.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=Q.s,a.n=void 0,Q.s.n=a,Q.s=a),a}}function fe(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}fe.prototype.brand=ul;fe.prototype.h=function(){return!0};fe.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:bn(function(){var l;(l=a.W)==null||l.call(a)}))};fe.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&&bn(function(){var i;(i=a.Z)==null||i.call(a)}))}};fe.prototype.subscribe=function(t){var a=this;return ba(function(){var n=a.value,l=Q;Q=void 0;try{t(n)}finally{Q=l}},{name:"sub"})};fe.prototype.valueOf=function(){return this.value};fe.prototype.toString=function(){return this.value+""};fe.prototype.toJSON=function(){return this.value};fe.prototype.peek=function(){var t=Q;Q=void 0;try{return this.value}finally{Q=t}};Object.defineProperty(fe.prototype,"value",{get:function(){var t=wn(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(vt>100)throw new Error("Cycle detected");this.v=t,this.i++,Pa++,Ue++;try{for(var a=this.t;a!==void 0;a=a.x)a.t.N()}finally{Ha()}}}});function ge(t,a){return new fe(t,a)}function Sn(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 Tn(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 kn(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 qe(t,a){fe.call(this,void 0),this.x=t,this.s=void 0,this.g=Pa-1,this.f=4,this.W=a?.watched,this.Z=a?.unwatched,this.name=a?.name}qe.prototype=new fe;qe.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Pa))return!0;if(this.g=Pa,this.f|=1,this.i>0&&!Sn(this))return this.f&=-2,!0;var t=Q;try{Tn(this),Q=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 Q=t,kn(this),this.f&=-2,!0};qe.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)}fe.prototype.S.call(this,t)};qe.prototype.U=function(t){if(this.t!==void 0&&(fe.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)}};qe.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(qe.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=wn(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function ga(t,a){return new qe(t,a)}function Nn(t){var a=t.u;if(t.u=void 0,typeof a=="function"){Ue++;var n=Q;Q=void 0;try{a()}catch(l){throw t.f&=-2,t.f|=8,_t(t),l}finally{Q=n,Ha()}}}function _t(t){for(var a=t.s;a!==void 0;a=a.n)a.S.U(a);t.x=void 0,t.s=void 0,Nn(t)}function hl(t){if(Q!==this)throw new Error("Out-of-order effect");kn(this),Q=t,this.f&=-2,8&this.f&&_t(this),Ha()}function ta(t,a){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=a?.name}ta.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()}};ta.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Nn(this),Tn(this),Ue++;var t=Q;return Q=this,hl.bind(this,t)};ta.prototype.N=function(){2&this.f||(this.f|=2,this.o=ha,ha=this)};ta.prototype.d=function(){this.f|=8,1&this.f||_t(this)};ta.prototype.dispose=function(){this.d()};function ba(t,a){var n=new ta(t,a);try{n.c()}catch(i){throw n.d(),i}var l=n.d.bind(n);return l[Symbol.dispose]=l,l}var An,Ba,ka,pl=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__,En=[];ba(function(){An=this.N})();function na(t,a){ee[t]=a.bind(null,ee[t]||function(){})}function Ma(t){if(ka){var a=ka;ka=void 0,a()}ka=t&&t.S()}function Cn(t){var a=this,n=t.data,l=d(n);l.value=n;var i=Ka(function(){for(var c=a,h=a.__v;h=h.__;)if(h.__c){h.__c.__$f|=4;break}var o=ga(function(){var N=l.value.value;return N===0?0:N===!0?"":N||""}),u=ga(function(){return!Array.isArray(o.value)&&!sn(o.value)}),v=ba(function(){if(this.N=In,u.value){var N=o.value;c.__v&&c.__v.__e&&c.__v.__e.nodeType===3&&(c.__v.__e.data=N)}}),f=a.__$u.d;return a.__$u.d=function(){v(),f.call(this)},[u,o]},[]),s=i[0],r=i[1];return s.value?r.peek():r.value}Cn.displayName="ReactiveTextNode";Object.defineProperties(fe.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Cn},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});na("__b",function(t,a){if(typeof a.type=="string"){var n,l=a.props;for(var i in l)if(i!=="children"){var s=l[i];s instanceof fe&&(n||(a.__np=n={}),n[i]=s,l[i]=s.peek())}}t(a)});na("__r",function(t,a){if(t(a),a.type!==J){Ma();var n,l=a.__c;l&&(l.__$f&=-2,(n=l.__$u)===void 0&&(l.__$u=n=(function(i,s){var r;return ba(function(){r=this},{name:s}),r.c=i,r})(function(){var i;pl&&((i=n.y)==null||i.call(n)),l.__$f|=1,l.setState({})},typeof a.type=="function"?a.type.displayName||a.type.name:""))),Ba=l,Ma(n)}});na("__e",function(t,a,n,l){Ma(),Ba=void 0,t(a,n,l)});na("diffed",function(t,a){Ma(),Ba=void 0;var n;if(typeof a.type=="string"&&(n=a.__e)){var l=a.__np,i=a.props;if(l){var s=n.U;if(s)for(var r in s){var c=s[r];c!==void 0&&!(r in l)&&(c.d(),s[r]=void 0)}else s={},n.U=s;for(var h in l){var o=s[h],u=l[h];o===void 0?(o=ml(n,h,u,i),s[h]=o):o.o(u,i)}}}t(a)});function ml(t,a,n,l){var i=a in t&&t.ownerSVGElement===void 0,s=ge(n);return{o:function(r,c){s.value=r,l=c},d:ba(function(){this.N=In;var r=s.value.value;l[a]!==r&&(l[a]=r,i?t[a]=r:r!=null&&(r!==!1||a[4]==="-")?t.setAttribute(a,r):t.removeAttribute(a))})}}na("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 s=l[i];s&&s.d()}}}}else{var r=a.__c;if(r){var c=r.__$u;c&&(r.__$u=void 0,c.d())}}t(a)});na("__h",function(t,a,n,l){(l<3||l===9)&&(a.__$f|=2),t(a,n,l)});va.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 s=2&this.__$f;if(!(l||s||4&this.__$f)||1&this.__$f)return!0}else if(!(l||4&this.__$f)||3&this.__$f)return!0;for(var r in t)if(r!=="__source"&&t[r]!==this.props[r])return!0;for(var c in this.props)if(!(c in t))return!0;return!1};function d(t,a){return Ka(function(){return ge(t,a)},[])}function Va(t,a){var n=_a(t);return n.current=t,Ba.__$f|=4,Ka(function(){return ga(function(){return n.current()},a)},[])}var fl=function(t){queueMicrotask(function(){queueMicrotask(t)})};function gl(){vl(function(){for(var t;t=En.shift();)An.call(t)})}function In(){En.push(this)===1&&(ee.requestAnimationFrame||fl)(gl)}const ya=ge(null),yl=ga(()=>ya.value!==null),Dn=ge(900),_l=ge(!1);let Ze=null;const Qe=()=>{bt()};function bl(){document.addEventListener("mousemove",Qe,{passive:!0}),document.addEventListener("keydown",Qe,{passive:!0}),document.addEventListener("click",Qe,{passive:!0}),bt()}function wl(){document.removeEventListener("mousemove",Qe),document.removeEventListener("keydown",Qe),document.removeEventListener("click",Qe),Ze!==null&&(clearTimeout(Ze),Ze=null)}function bt(){Ze!==null&&clearTimeout(Ze),Ze=setTimeout(()=>{za()},Dn.value*1e3)}function Sl(t,a){ya.value=t,a!==void 0&&(Dn.value=a),bl(),location.hash="#/dashboard"}function za(){ya.value=null,wl(),location.hash="#/login"}const L={ADMIN_STATUS:"/v1/admin/status",ADMIN_KILL_SWITCH:"/v1/admin/kill-switch",ADMIN_KILL_SWITCH_ESCALATE:"/v1/admin/kill-switch/escalate",ADMIN_RECOVER:"/v1/admin/recover",ADMIN_SHUTDOWN:"/v1/admin/shutdown",ADMIN_ROTATE_SECRET:"/v1/admin/rotate-secret",WALLETS:"/v1/wallets",WALLET:t=>`/v1/wallets/${t}`,SESSIONS:"/v1/sessions",SESSION:t=>`/v1/sessions/${t}`,POLICIES:"/v1/policies",POLICY:t=>`/v1/policies/${t}`,TOKENS:"/v1/tokens",ADMIN_NOTIFICATIONS_STATUS:"/v1/admin/notifications/status",ADMIN_NOTIFICATIONS_TEST:"/v1/admin/notifications/test",ADMIN_NOTIFICATIONS_LOG:"/v1/admin/notifications/log",MCP_TOKENS:"/v1/mcp/tokens",ADMIN_SETTINGS:"/v1/admin/settings",ADMIN_SETTINGS_TEST_RPC:"/v1/admin/settings/test-rpc",ADMIN_RPC_STATUS:"/v1/admin/rpc-status",WALLET_NETWORKS:t=>`/v1/wallets/${t}/networks`,ADMIN_WALLET_BALANCE:t=>`/v1/admin/wallets/${t}/balance`,ADMIN_WALLET_TRANSACTIONS:t=>`/v1/admin/wallets/${t}/transactions`,ADMIN_API_KEYS:"/v1/admin/api-keys",ADMIN_API_KEY:t=>`/v1/admin/api-keys/${t}`,ADMIN_FOREX_RATES:"/v1/admin/forex/rates",ADMIN_TELEGRAM_USERS:"/v1/admin/telegram-users",ADMIN_TELEGRAM_USER:t=>`/v1/admin/telegram-users/${t}`,WALLET_OWNER:t=>`/v1/wallets/${t}/owner`,WALLET_WITHDRAW:t=>`/v1/wallets/${t}/withdraw`,WALLET_WC_PAIR:t=>`/v1/wallets/${t}/wc/pair`,WALLET_WC_SESSION:t=>`/v1/wallets/${t}/wc/session`,WALLET_WC_PAIR_STATUS:t=>`/v1/wallets/${t}/wc/pair/status`,WALLET_OWNER_VERIFY:t=>`/v1/wallets/${t}/owner/verify`,WALLET_SUSPEND:t=>`/v1/wallets/${t}/suspend`,WALLET_RESUME:t=>`/v1/wallets/${t}/resume`,ADMIN_AGENT_PROMPT:"/v1/admin/agent-prompt",ADMIN_SESSION_REISSUE:t=>`/v1/admin/sessions/${t}/reissue`,ADMIN_TRANSACTIONS:"/v1/admin/transactions",ADMIN_TX_CANCEL:t=>`/v1/admin/transactions/${t}/cancel`,ADMIN_TX_REJECT:t=>`/v1/admin/transactions/${t}/reject`,ADMIN_INCOMING:"/v1/admin/incoming",WALLET_PATCH:t=>`/v1/wallets/${t}`,TOKENS_RESOLVE:"/v1/tokens/resolve",ACTIONS_PROVIDERS:"/v1/actions/providers",ADMIN_WALLET_STAKING:t=>`/v1/admin/wallets/${t}/staking`,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_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}`},pa=ge(""),Je=ge(null),ma=ge(!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:"white",border:"none",borderRadius:"var(--radius-md)",fontSize:"var(--font-size-base)",fontWeight:"var(--font-weight-medium)",marginTop:"var(--space-4)"},buttonDisabled:{opacity:.6,cursor:"not-allowed"},error:{color:"var(--color-danger)",fontSize:"var(--font-size-sm)",textAlign:"center",marginTop:"var(--space-3)"}},Tl=async t=>{if(t.preventDefault(),!!pa.value.trim()){ma.value=!0,Je.value=null;try{const a=await fetch(L.ADMIN_STATUS,{headers:{"X-Master-Password":pa.value},signal:AbortSignal.timeout(1e4)});if(a.status===401){Je.value="Invalid master password";return}if(!a.ok){Je.value="Cannot connect to daemon";return}const n=await a.json();Sl(pa.value,n.adminTimeout)}catch{Je.value="Cannot connect to daemon"}finally{ma.value=!1}}};function kl(){return e("div",{style:xe.wrapper,children:e("form",{style:xe.card,onSubmit:Tl,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:pa.value,onInput:t=>{pa.value=t.target.value},style:xe.input}),e("button",{type:"submit",disabled:ma.value,style:{...xe.button,...ma.value?xe.buttonDisabled:{}},children:ma.value?"Signing in...":"Sign in"}),Je.value&&e("p",{style:xe.error,children:Je.value})]})})}const Nl=[{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:"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:"notifications.settings.enabled",label:"Enabled",description:"Enable or disable notifications globally",page:"/notifications",tab:"settings",fieldName:"notifications.enabled",keywords:["notifications","enable","toggle","global"]},{id:"notifications.settings.telegram_bot_token",label:"Telegram Bot Token",description:"Bot token for Telegram notifications",page:"/notifications",tab:"settings",fieldName:"notifications.telegram_bot_token",keywords:["telegram","bot","token","notification","credential"]},{id:"notifications.settings.telegram_chat_id",label:"Telegram Chat ID",description:"Chat ID for Telegram notification delivery",page:"/notifications",tab:"settings",fieldName:"notifications.telegram_chat_id",keywords:["telegram","chat","notification"]},{id:"notifications.settings.locale",label:"Locale",description:"Language for notification messages",page:"/notifications",tab:"settings",fieldName:"notifications.locale",keywords:["locale","language","notification","i18n"]},{id:"notifications.settings.discord_webhook_url",label:"Discord Webhook URL",description:"Webhook URL for Discord notifications",page:"/notifications",tab:"settings",fieldName:"notifications.discord_webhook_url",keywords:["discord","webhook","notification","credential"]},{id:"notifications.settings.ntfy_server",label:"Ntfy Server",description:"Server URL for ntfy notifications",page:"/notifications",tab:"settings",fieldName:"notifications.ntfy_server",keywords:["ntfy","server","push","notification"]},{id:"notifications.settings.ntfy_topic",label:"Ntfy Topic",description:"Topic name for ntfy notifications",page:"/notifications",tab:"settings",fieldName:"notifications.ntfy_topic",keywords:["ntfy","topic","push","notification"]},{id:"notifications.settings.slack_webhook_url",label:"Slack Webhook URL",description:"Webhook URL for Slack notifications",page:"/notifications",tab:"settings",fieldName:"notifications.slack_webhook_url",keywords:["slack","webhook","notification","credential"]},{id:"notifications.settings.rate_limit_rpm",label:"Rate Limit (RPM)",description:"Max notifications per minute",page:"/notifications",tab:"settings",fieldName:"notifications.rate_limit_rpm",keywords:["rate","limit","rpm","notification","throttle"]},{id:"notifications.settings.notify_events",label:"Event Filter",description:"Per-event notification filter (choose which events are delivered)",page:"/notifications",tab:"settings",fieldName:"notifications.notify_events",keywords:["filter","event","category","notification","subscribe"]},{id:"notifications.settings.telegram_dedicated_bot_token",label:"Bot Token",description:"Dedicated bot token for Telegram bot (optional, uses notification token if empty)",page:"/notifications",tab:"settings",fieldName:"telegram.bot_token",keywords:["telegram","bot","token","credential"]},{id:"security.autostop.enabled",label:"Enabled",description:"Enable or disable AutoStop protection rules",page:"/security",tab:"autostop",fieldName:"autostop.enabled",keywords:["autostop","protection","enable","toggle","security"]},{id:"security.autostop.consecutive_failures_threshold",label:"Consecutive Failures Threshold",description:"Suspend wallet after this many consecutive failed transactions",page:"/security",tab:"autostop",fieldName:"autostop.consecutive_failures_threshold",keywords:["autostop","failure","threshold","suspend","security"]},{id:"security.autostop.unusual_activity_threshold",label:"Unusual Activity Threshold",description:"Max transactions within window before triggering unusual activity alert",page:"/security",tab:"autostop",fieldName:"autostop.unusual_activity_threshold",keywords:["autostop","unusual","activity","threshold","security"]},{id:"security.autostop.unusual_activity_window_sec",label:"Unusual Activity Window (seconds)",description:"Time window for unusual activity detection",page:"/security",tab:"autostop",fieldName:"autostop.unusual_activity_window_sec",keywords:["autostop","unusual","activity","window","time","security"]},{id:"security.autostop.idle_timeout_sec",label:"Idle Timeout (seconds)",description:"Revoke sessions with no activity for this duration",page:"/security",tab:"autostop",fieldName:"autostop.idle_timeout_sec",keywords:["autostop","idle","timeout","session","revoke","security"]},{id:"security.autostop.idle_check_interval_sec",label:"Idle Check Interval (seconds)",description:"How often to check for idle sessions",page:"/security",tab:"autostop",fieldName:"autostop.idle_check_interval_sec",keywords:["autostop","idle","check","interval","security"]},{id:"system..currency",label:"Display Currency",description:"Currency for USD amount conversion in dashboard and notifications",page:"/system",tab:"",fieldName:"display.currency",keywords:["currency","display","usd","conversion","fiat"]},{id:"system..rate_limit_global_ip_rpm",label:"Global IP Rate Limit (RPM)",description:"Maximum API requests per minute from a single IP address",page:"/system",tab:"",fieldName:"security.rate_limit_global_ip_rpm",keywords:["rate","limit","rpm","ip","global","throttle"]},{id:"system..log_level",label:"Log Level",description:"Daemon logging verbosity level",page:"/system",tab:"",fieldName:"daemon.log_level",keywords:["log","level","debug","info","warn","error","daemon"]},{id:"transactions.monitor.enabled",label:"Monitoring Enabled",description:"Enable or disable incoming transaction monitoring",page:"/transactions",tab:"monitor",fieldName:"incoming.enabled",keywords:["incoming","monitoring","enable","toggle"]},{id:"transactions.monitor.poll_interval",label:"Poll Interval (seconds)",description:"How often to poll for incoming transactions",page:"/transactions",tab:"monitor",fieldName:"incoming.poll_interval",keywords:["incoming","poll","interval","frequency"]},{id:"transactions.monitor.retention_days",label:"Retention Days",description:"How many days to retain incoming transaction records",page:"/transactions",tab:"monitor",fieldName:"incoming.retention_days",keywords:["incoming","retention","days","cleanup"]},{id:"transactions.monitor.suspicious_dust_usd",label:"Suspicious Dust USD Threshold",description:"USD threshold below which transactions are flagged as dust",page:"/transactions",tab:"monitor",fieldName:"incoming.suspicious_dust_usd",keywords:["incoming","suspicious","dust","threshold","usd"]},{id:"transactions.monitor.suspicious_amount_multiplier",label:"Suspicious Amount Multiplier",description:"Multiplier for detecting unusually large incoming amounts",page:"/transactions",tab:"monitor",fieldName:"incoming.suspicious_amount_multiplier",keywords:["incoming","suspicious","amount","multiplier","large"]},{id:"transactions.monitor.cooldown_minutes",label:"Notification Cooldown (minutes)",description:"Cooldown period between duplicate incoming TX notifications",page:"/transactions",tab:"monitor",fieldName:"incoming.cooldown_minutes",keywords:["incoming","cooldown","notification","minutes"]},{id:"transactions.monitor.wss_url",label:"WebSocket URL",description:"Custom WebSocket RPC URL for real-time incoming TX detection",page:"/transactions",tab:"monitor",fieldName:"incoming.wss_url",keywords:["incoming","websocket","wss","rpc","url"]},{id:"system..cross_validation_threshold",label:"Cross Validation Threshold (%)",description:"Maximum allowed deviation between price oracle sources",page:"/system",tab:"",fieldName:"oracle.cross_validation_threshold",keywords:["oracle","price","validation","threshold","deviation"]},{id:"system..signing_sdk_enabled",label:"SDK Enabled",description:"Enable Signing SDK for wallet app approval",page:"/system",tab:"",fieldName:"signing_sdk.enabled",keywords:["signing","sdk","wallet","app","enable"]},{id:"system..signing_sdk_request_expiry",label:"Request Expiry (min)",description:"Minutes before a sign request expires",page:"/system",tab:"",fieldName:"signing_sdk.request_expiry_min",keywords:["signing","sdk","expiry","timeout","request"]},{id:"system..signing_sdk_preferred_channel",label:"Preferred Channel",description:"Preferred signing channel for SDK requests",page:"/system",tab:"",fieldName:"signing_sdk.preferred_channel",keywords:["signing","sdk","channel","ntfy","telegram"]},{id:"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"]}],Se=ge(""),ue=ge(null),Al={"/wallets":"Wallets","/sessions":"Sessions","/transactions":"Transactions","/policies":"Policies","/notifications":"Notifications","/security":"Security","/system":"System"};function El(t){if(!t.trim())return[];const a=t.toLowerCase();return Nl.filter(n=>[n.label,n.description,n.keywords.join(" ")].join(" ").toLowerCase().includes(a)).slice(0,10)}function Cl(t){const a=Al[t.page]??t.page;return t.tab?`${a} > ${t.tab}`:a}function Il({open:t}){const a=d(""),n=d(0),l=_a(null),i=t.value?El(a.value):[];if(G(()=>{t.value&&(a.value="",n.value=0,requestAnimationFrame(()=>{l.current?.focus()}))},[t.value]),!t.value)return null;const s=()=>{t.value=!1,a.value="",n.value=0},r=o=>{o.target.classList.contains("search-overlay")&&s()},c=o=>{window.location.hash="#"+o.page,o.tab?ue.value={tab:o.tab,fieldName:o.fieldName}:setTimeout(()=>{Se.value=o.fieldName},100),s()};return e("div",{class:"search-overlay",onClick:r,children:e("div",{class:"search-popover",onKeyDown:o=>{if(o.key==="Escape"){s();return}if(o.key==="ArrowDown"){o.preventDefault(),n.value=Math.min(n.value+1,i.length-1);return}if(o.key==="ArrowUp"){o.preventDefault(),n.value=Math.max(n.value-1,0);return}if(o.key==="Enter"&&i.length>0){o.preventDefault(),c(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:o=>{a.value=o.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((o,u)=>e("button",{class:`search-result-item${u===n.value?" selected":""}`,onClick:()=>c(o),onMouseEnter:()=>{n.value=u},children:[e("div",{class:"search-result-label",children:o.label}),e("div",{class:"search-result-desc",children:o.description}),e("div",{class:"search-result-path",children:Cl(o)})]},o.id))]}),e("div",{class:"search-hint",children:[e("span",{children:[e("kbd",{children:"Esc"})," close"]}),e("span",{children:[e("kbd",{children:"↑"}),e("kbd",{children:"↓"})," navigate"]}),e("span",{children:[e("kbd",{children:"Enter"})," select"]})]})]})})}const ze=ge([]),On=ga(()=>ze.value.some(t=>typeof t.isDirty=="function"&&t.isDirty()));function De(t){ze.value=[...ze.value.filter(a=>a.id!==t.id),t]}function Ae(t){ze.value=ze.value.filter(a=>a.id!==t)}async function Dl(){const t=ze.value.filter(a=>typeof a.isDirty=="function"&&a.isDirty());try{for(const a of t)await a.save();return!0}catch{return!1}}function Ol(){const t=ze.value.filter(a=>typeof a.isDirty=="function"&&a.isDirty());for(const a of t)a.discard()}function I({label:t,name:a,type:n="text",value:l,onChange:i,options:s,error:r,required:c,disabled:h,placeholder:o,min:u,max:v,description:f}){const N=Se.value===a;if(G(()=>{if(N){const W=document.querySelector(`[name="${a}"]`);W&&W.closest(".form-field")?.scrollIntoView({behavior:"smooth",block:"center"});const y=setTimeout(()=>{Se.value=""},2500);return()=>clearTimeout(y)}},[N,a]),n==="checkbox")return e("div",{class:`form-field${N?" form-field--highlight":""}`,children:[e("label",{children:[e("input",{type:"checkbox",name:a,checked:!!l,onChange:W=>i(W.target.checked),disabled:h}),t,c&&e("span",{children:" *"})]}),f&&e("span",{class:"form-description",children:f}),r&&e("span",{class:"form-error",children:r})]});const x=`field-${a}`;return e("div",{class:`form-field${N?" form-field--highlight":""}`,children:[e("label",{for:x,children:[t,c&&e("span",{children:" *"})]}),n==="select"?e("select",{id:x,name:a,value:l,onChange:W=>i(W.target.value),disabled:h,children:s?.map(W=>e("option",{value:W.value,children:W.label},W.value))}):n==="textarea"?e("textarea",{id:x,name:a,value:l,onInput:W=>i(W.target.value),disabled:h,placeholder:o}):e("input",{id:x,type:n,name:a,value:l,onInput:W=>{const y=W.target;i(n==="number"?Number(y.value):y.value)},disabled:h,placeholder:o,min:u,max:v,required:c}),f&&e("span",{class:"form-description",children:f}),r&&e("span",{class:"form-error",children:r})]})}function P({variant:t="primary",size:a="md",loading:n=!1,disabled:l=!1,onClick:i,children:s,type:r="button"}){const c=["btn",`btn-${t}`,a==="sm"?"btn-sm":""].filter(Boolean).join(" ");return e("button",{type:r,class:c,disabled:l||n,onClick:i,children:n?"...":s})}function V({variant:t,children:a}){return e("span",{class:`badge badge-${t}`,children:a})}const da=ge(null),sa=ge(!1);function Ln(t){da.value=t}function Ll(){const t=da.value;if(!t)return null;const a=async()=>{sa.value=!0;const i=await Dl();sa.value=!1,i&&(da.value=null,t.execute())},n=()=>{Ol(),da.value=null,t.execute()},l=()=>{da.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(P,{variant:"secondary",onClick:l,disabled:sa.value,children:"Cancel"}),e(P,{variant:"ghost",onClick:n,disabled:sa.value,children:"Discard & Navigate"}),e(P,{variant:"primary",onClick:a,loading:sa.value,children:"Save & Navigate"})]})]})})}class T extends Error{constructor(a,n,l){super(`[${a}] ${n}: ${l}`),this.status=a,this.code=n,this.serverMessage=l,this.name="ApiError"}}async function wa(t,a){const n={"Content-Type":"application/json",...a?.headers};ya.value!==null&&(n["X-Master-Password"]=ya.value);let l;try{l=await fetch(t,{...a,headers:n,signal:AbortSignal.timeout(1e4)})}catch(i){const s=i;throw s.name==="AbortError"||s.name==="TimeoutError"?new T(0,"TIMEOUT","Request timed out"):new T(0,"NETWORK_ERROR","Cannot connect to daemon")}if(l.status===401)throw t.startsWith("/v1/admin/")&&za(),new T(401,"UNAUTHORIZED","Authentication failed");if(!l.ok){let i={};try{i=await l.json()}catch{}throw new T(l.status,i.code??"UNKNOWN",i.message??"Unknown error")}return bt(),await l.json()}const z=t=>wa(t,{method:"GET"}),se=(t,a)=>wa(t,{method:"POST",body:a?JSON.stringify(a):void 0}),de=(t,a)=>wa(t,{method:"PUT",body:a?JSON.stringify(a):void 0}),$e=(t,a)=>wa(t,{method:"DELETE",body:a?JSON.stringify(a):void 0}),xl=(t,a)=>wa(t,{method:"PATCH",body:a?JSON.stringify(a):void 0});function Rl(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 me(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 Wa(t){return t.length<=10?t:`${t.slice(0,4)}..${t.slice(-4)}`}const Pl=new Set(["KRW","JPY","VND","CLP","HUF","PKR"]),Ml=new Set(["KWD","BHD"]);function Wl(t){return Pl.has(t)?0:Ml.has(t)?3:2}function Ul(t,a,n){const l=t*n,i=Wl(a),s=new Intl.NumberFormat("en-US",{style:"currency",currency:a,minimumFractionDigits:i,maximumFractionDigits:i}).format(l);return a==="USD"?s:`≈${s}`}let Ye=null;const $l=300*1e3;async function wt(){if(Ye&&Date.now()-Ye.fetchedAt<$l)return{currency:Ye.currency,rate:Ye.rate};try{const a=(await z(L.ADMIN_SETTINGS)).display?.["display.currency"]??"USD";if(a==="USD")return Ye={currency:"USD",rate:1,fetchedAt:Date.now()},{currency:"USD",rate:1};const i=(await z(`${L.ADMIN_FOREX_RATES}?currencies=${a}`)).rates[a]?.rate??null;return Ye={currency:a,rate:i,fetchedAt:Date.now()},{currency:a,rate:i}}catch{return{currency:"USD",rate:1}}}function aa(t,a,n){return t==null?"":n==null?`$${t.toFixed(2)}`:Ul(t,a,n)}function Ie({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(s=>e("th",{style:s.width?{width:s.width}:void 0,children:s.header},s.key))})}),e("tbody",{children:i?e("tr",{children:e("td",{colSpan:t.length,class:"table-loading",children:"Loading..."})}):!a||a.length===0?e("tr",{children:e("td",{colSpan:t.length,class:"table-empty",children:l})}):a.map((s,r)=>e("tr",{class:n?"clickable":"",onClick:n?()=>n(s):void 0,children:t.map(c=>e("td",{children:c.render?c.render(s):s[c.key]},c.key))},r))})]})})}const Fl={INVALID_TOKEN:"Your authentication token is invalid. Please log in again.",TOKEN_EXPIRED:"Your session token has expired. Please log in again.",SESSION_REVOKED:"Your session has been revoked by an administrator.",INVALID_SIGNATURE:"The cryptographic signature is invalid.",INVALID_NONCE:"The authentication nonce is invalid or has expired.",INVALID_MASTER_PASSWORD:"Invalid master password. Please try again.",MASTER_PASSWORD_LOCKED:"Master password is locked due to too many failed attempts. Please wait.",SYSTEM_LOCKED:"The system is currently locked.",SESSION_NOT_FOUND:"Session not found.",SESSION_EXPIRED:"The session has expired.",SESSION_LIMIT_EXCEEDED:"Maximum number of sessions reached.",CONSTRAINT_VIOLATED:"A session constraint was violated.",RENEWAL_LIMIT_REACHED:"Session renewal limit has been reached. Create a new session.",SESSION_ABSOLUTE_LIFETIME_EXCEEDED:"Session has exceeded its maximum lifetime.",RENEWAL_TOO_EARLY:"Session renewal attempted too early. Please wait.",SESSION_RENEWAL_MISMATCH:"Session renewal count mismatch. The session may have been renewed elsewhere.",PIPELINE_HALTED:"Transaction is queued for delay or approval.",INSUFFICIENT_BALANCE:"Insufficient balance for this transaction.",INVALID_ADDRESS:"The blockchain address is invalid.",TX_NOT_FOUND:"Transaction not found.",TX_EXPIRED:"The transaction has expired.",TX_ALREADY_PROCESSED:"This transaction has already been processed.",CHAIN_ERROR:"A blockchain network error occurred. Please try again.",SIMULATION_FAILED:"Transaction simulation failed. The transaction may revert.",TOKEN_NOT_FOUND:"Token not found.",TOKEN_NOT_ALLOWED:"This token is not in the allowed list.",INSUFFICIENT_TOKEN_BALANCE:"Insufficient token balance.",CONTRACT_CALL_DISABLED:"Contract calls are disabled. Configure a CONTRACT_WHITELIST policy first.",CONTRACT_NOT_WHITELISTED:"This contract address is not whitelisted.",METHOD_NOT_WHITELISTED:"This contract method is not whitelisted.",APPROVE_DISABLED:"Token approvals are disabled. Configure an APPROVED_SPENDERS policy first.",SPENDER_NOT_APPROVED:"This spender address is not in the approved list.",APPROVE_AMOUNT_EXCEEDED:"The approve amount exceeds the configured limit.",UNLIMITED_APPROVE_BLOCKED:"Unlimited token approvals are blocked by policy.",BATCH_NOT_SUPPORTED:"Batch transactions are not supported on this chain.",BATCH_SIZE_EXCEEDED:"Batch contains too many instructions (maximum 20).",BATCH_POLICY_VIOLATION:"A policy violation occurred in the batch transaction.",POLICY_NOT_FOUND:"Policy not found.",POLICY_DENIED:"Transaction denied by policy.",SPENDING_LIMIT_EXCEEDED:"Spending limit has been exceeded.",RATE_LIMIT_EXCEEDED:"Rate limit exceeded. Please wait before retrying.",WHITELIST_DENIED:"The destination address is not in the whitelist.",OWNER_ALREADY_CONNECTED:"An owner wallet is already connected to this wallet.",OWNER_NOT_CONNECTED:"No owner wallet is connected to this wallet.",OWNER_NOT_FOUND:"Owner not found.",APPROVAL_TIMEOUT:"The approval request has timed out.",APPROVAL_NOT_FOUND:"Approval request not found.",OWNER_NOT_SET:"Owner address must be set before connecting WalletConnect.",OWNER_ADDRESS_MISMATCH:"Connected wallet address does not match registered owner.",KILL_SWITCH_ACTIVE:"Kill switch is active. All operations are suspended.",KILL_SWITCH_NOT_ACTIVE:"Kill switch is not currently active.",KEYSTORE_LOCKED:"The keystore is locked. Please try again.",CHAIN_NOT_SUPPORTED:"This blockchain is not supported.",SHUTTING_DOWN:"The daemon is shutting down.",ADAPTER_NOT_AVAILABLE:"Chain adapter is not available. Please try again.",WALLET_NOT_FOUND:"Wallet not found.",WALLET_SUSPENDED:"This wallet is currently suspended.",WALLET_TERMINATED:"This wallet has been terminated.",WC_NOT_CONFIGURED:"WalletConnect is not configured. Set the Project ID in Settings first.",WC_SESSION_NOT_FOUND:"No active WalletConnect session.",WC_SESSION_EXISTS:"A WalletConnect session already exists. Disconnect first.",WC_SIGNING_FAILED:"WalletConnect signing request failed.",NO_OWNER:"No owner connected. Withdrawal requires an owner wallet.",WITHDRAW_LOCKED_ONLY:"Withdrawal is only available when the owner state is LOCKED.",SWEEP_TOTAL_FAILURE:"All sweep operations failed. Please try again.",INSUFFICIENT_FOR_FEE:"Insufficient balance to cover transaction fees.",ACTION_NOT_FOUND:"Action not found.",ACTION_VALIDATION_FAILED:"Action input validation failed.",ACTION_RESOLVE_FAILED:"Action failed due to an external API error. Please try again.",ACTION_RETURN_INVALID:"Action returned an invalid result.",ACTION_PLUGIN_LOAD_FAILED:"Failed to load the action plugin.",ACTION_NAME_CONFLICT:"An action with this name already exists.",ACTION_CHAIN_MISMATCH:"The request chain does not match the action provider.",ROTATION_TOO_RECENT:"Key rotation was attempted too recently. Please wait.",NETWORK_ERROR:"Cannot connect to the daemon. Check if it is running.",TIMEOUT:"Request timed out. The daemon may be busy."},Kl=new Set(["ACTION_VALIDATION_FAILED","CONSTRAINT_VIOLATED","INVALID_ADDRESS","INVALID_SIGNATURE"]);function K(t,a){return a&&Kl.has(t)?a:Fl[t]??`An error occurred (${t}).`}const Me=ge([]);let Hl=0;function b(t,a){const n=Hl++;Me.value=[...Me.value,{id:n,type:t,message:a}],setTimeout(()=>{Me.value=Me.value.filter(l=>l.id!==n)},5e3)}function Bl(t){Me.value=Me.value.filter(a=>a.id!==t)}function Vl(){return Me.value.length===0?null:e("div",{class:"toast-container",children:Me.value.map(t=>e("div",{class:`toast toast-${t.type}`,onClick:()=>Bl(t.id),children:t.message},t.id))})}const zl={"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 Gl(t,a){const n=zl[t];return n?n.replace("{txHash}",a):null}function ql(t){return t.length<=16?t:t.slice(0,8)+"..."+t.slice(-6)}function St({network:t,txHash:a,label:n}){if(!a)return null;const l=Gl(t,a),i=n??ql(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})}function jl(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]}`}function he({label:t,value:a,loading:n,badge:l,href:i}){const s=e(J,{children:[e("div",{class:"stat-label",children:[t,i&&e("span",{class:"stat-link-arrow",children:" →"})]}),n?e("div",{class:"stat-skeleton"}):l?e(V,{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:s}):e("div",{class:"stat-card",children:s})}function Yl(t,a){return[{key:"createdAt",header:"Time",render:n=>n.createdAt?me(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=aa(n.amountUsd,t,a);return l?`${n.amount} (${l})`:n.amount}},{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(V,{variant:l,children:n.status})}},{key:"txHash",header:"Tx Hash",render:n=>e(St,{network:n.network??"",txHash:n.txHash})}]}function Xl(t,a){return[{key:"provider",header:"Provider"},{key:"category",header:"Category",render:n=>e(V,{variant:"info",children:n.category})},{key:"chain",header:"Chain",render:n=>e(V,{variant:"info",children:n.chain})},{key:"amount",header:"Amount"},{key:"amountUsd",header:"USD Value",render:n=>n.amountUsd===null?"—":aa(n.amountUsd,t,a)??`$${n.amountUsd.toFixed(2)}`}]}async function Jl(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 Wt(){const t=d(null),a=d(!0),n=d(null),l=d("USD"),i=d(1),s=d(!1),r=d(null),c=d(null),h=d(null),o=d(!0),u=d(null),v=d(!0),f=async()=>{try{const w=await z(L.ADMIN_STATS);u.value=w}catch{}finally{v.value=!1}},N=async()=>{o.value=!0;try{const w=await z(L.ADMIN_DEFI_POSITIONS);h.value=w}catch{}finally{o.value=!1}},x=async()=>{a.value=!0,n.value=null;try{const w=await z(L.ADMIN_STATUS);t.value=w}catch(w){w instanceof T?n.value=K(w.code):n.value="An unexpected error occurred."}finally{a.value=!1}},W=async()=>{s.value=!0;try{const w=await se(L.ADMIN_AGENT_PROMPT,{});if(w.walletCount===0){b("warning","No active wallets found");return}r.value=w.prompt,b("success",`Prompt generated for ${w.walletCount} wallet(s)`)}catch(w){w instanceof T?b("error",K(w.code)):b("error","Failed to generate agent prompt")}finally{s.value=!1}},y=async()=>{r.value&&(await Jl(r.value),b("success","Copied to clipboard!"))};G(()=>{x(),N(),f(),wt().then(({currency:F,rate:D})=>{l.value=F,i.value=D}).catch(()=>{}),z(L.ADMIN_TRANSACTIONS+"?status=APPROVED&limit=1").then(F=>{c.value=F.total}).catch(()=>{});const w=setInterval(()=>{x(),N(),f()},3e4);return()=>clearInterval(w)},[]);const A=a.value&&!t.value;return e("div",{class:"page",children:[n.value&&e("div",{class:"dashboard-error",children:[e("span",{children:n.value}),e(P,{variant:"secondary",size:"sm",onClick:x,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(he,{label:"Version",value:t.value?.version??"—",loading:A,badge:t.value&&t.value.updateAvailable?"warning":void 0}),e(he,{label:"Uptime",value:t.value?Rl(t.value.uptime):"—",loading:A}),e(he,{label:"Wallets",value:t.value?.walletCount?.toString()??"—",loading:A,href:"#/wallets"}),e(he,{label:"Active Sessions",value:t.value?.activeSessionCount?.toString()??"—",loading:A,href:"#/sessions"})]}),e("div",{class:"stat-grid",style:{marginTop:"var(--space-4)"},children:[e(he,{label:"Kill Switch",value:t.value?.killSwitchState==="ACTIVATED"?"ACTIVATED":"NORMAL",loading:A,badge:t.value?t.value.killSwitchState==="ACTIVATED"?"danger":"success":void 0}),e(he,{label:"Status",value:t.value?.status??"—",loading:A})]}),e("div",{class:"stat-grid",style:{marginTop:"var(--space-4)"},children:[e(he,{label:"Policies",value:t.value?.policyCount?.toString()??"—",loading:A,href:"#/policies"}),e(he,{label:"Recent Txns (24h)",value:t.value?.recentTxCount?.toString()??"—",loading:A,href:"#/transactions"}),e(he,{label:"Failed Txns (24h)",value:t.value?.failedTxCount?.toString()??"—",loading:A,badge:t.value?t.value.failedTxCount===0?"success":"danger":void 0,href:"#/transactions?status=FAILED"}),e(he,{label:"Approval Pending",value:c.value?.toString()??"—",loading:A,badge:c.value!=null&&c.value>0?"warning":void 0,href:"#/transactions?status=APPROVED"})]}),e("div",{class:"prompt-card",style:{marginTop:"var(--space-4)"},children:[e("h3",{style:{marginBottom:"var(--space-2)"},children:"Agent Connection Prompt"}),e("p",{class:"prompt-card-desc",children:"Generate a connection prompt for AI agents. Creates sessions for all active wallets."}),r.value?e(J,{children:[e("pre",{class:"prompt-preview",children:r.value}),e("div",{style:{display:"flex",gap:"var(--space-2)",marginTop:"var(--space-3)"},children:[e(P,{variant:"primary",size:"sm",onClick:y,children:"Copy to Clipboard"}),e(P,{variant:"secondary",size:"sm",onClick:W,loading:s.value,children:"Regenerate"})]})]}):e(P,{variant:"primary",size:"sm",onClick:W,loading:s.value,style:{marginTop:"var(--space-2)"},children:"Generate"})]}),h.value&&h.value.activeCount>0&&e("div",{style:{marginTop:"var(--space-4)"},children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"DeFi Positions"}),e("div",{class:"stat-grid",children:[e(he,{label:"Total DeFi Value",value:h.value.totalValueUsd!==null?aa(h.value.totalValueUsd,l.value,i.value)??`$${h.value.totalValueUsd.toFixed(2)}`:"—",loading:o.value}),e(he,{label:"Health Factor",value:h.value.worstHealthFactor!==null?h.value.worstHealthFactor.toFixed(2):"N/A",loading:o.value,badge:h.value.worstHealthFactor!==null?h.value.worstHealthFactor<1.2?"danger":h.value.worstHealthFactor<1.5?"warning":"success":void 0}),e(he,{label:"Active Positions",value:h.value.activeCount.toString(),loading:o.value})]}),e("div",{style:{marginTop:"var(--space-3)"},children:e(Ie,{columns:Xl(l.value,i.value),data:h.value.positions,loading:o.value,emptyMessage:"No active DeFi positions"})})]}),e("div",{style:{marginTop:"var(--space-4)"},children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"Recent Activity"}),e(Ie,{columns:Yl(l.value,i.value),data:t.value?.recentTransactions??[],loading:A,emptyMessage:"No recent transactions"})]}),u.value&&e(J,{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(Ie,{columns:[{key:"network",header:"Network"},{key:"calls",header:"Total Calls"},{key:"errors",header:"Errors"},{key:"avgLatencyMs",header:"Avg Latency (ms)",render:w=>w.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(Ie,{columns:[{key:"id",header:"Rule"},{key:"displayName",header:"Name"},{key:"enabled",header:"Status",render:w=>e(V,{variant:w.enabled?"success":"danger",children:w.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(he,{label:"Notifications Sent (24h)",value:String(u.value.notifications.sentLast24h)}),e(he,{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(he,{label:"DB Size",value:jl(u.value.system.dbSizeBytes)}),e(he,{label:"Schema Version",value:`v${u.value.system.schemaVersion}`}),e(he,{label:"Node.js",value:u.value.system.nodeVersion}),e(he,{label:"Platform",value:u.value.system.platform})]})]})]})}function be({open:t,title:a,children:n,onConfirm:l,onCancel:i,confirmText:s="Confirm",cancelText:r="Cancel",confirmVariant:c="primary",confirmDisabled:h=!1,loading:o=!1}){return G(()=>{if(!t)return;const u=v=>{v.key==="Escape"&&i()};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[t,i]),t?e("div",{class:"modal-overlay",onClick:i,children:e("div",{class:"modal-card",onClick:u=>u.stopPropagation(),children:[e("div",{class:"modal-header",children:a}),e("div",{class:"modal-body",children:n}),e("div",{class:"modal-footer",children:[e(P,{variant:"secondary",onClick:i,disabled:o,children:r}),l&&e(P,{variant:c,onClick:l,loading:o,disabled:h,children:s})]})]})}):null}function Ge({value:t,label:a}){const n=d(!1);return e("button",{class:"btn btn-ghost btn-sm",onClick:async()=>{try{await navigator.clipboard.writeText(t)}catch{const i=document.createElement("textarea");i.value=t,i.style.position="fixed",i.style.left="-9999px",document.body.appendChild(i),i.select(),document.execCommand("copy"),document.body.removeChild(i)}n.value=!0,setTimeout(()=>{n.value=!1},2e3)},children:n.value?"Copied!":a??"Copy"})}function Ua({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 Ke({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&&(On.value?Ln({type:"tab",execute:()=>n(l.key)}):n(l.key))},children:l.label},l.key))})}function la({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 xn({value:t,onSearch:a,placeholder:n="Search...",debounceMs:l=300}){const i=_a(null);function s(c){const h=c.target.value;i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>{a(h),i.current=null},l)}function r(){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:s}),t&&e("button",{class:"search-clear",type:"button",onClick:r,children:"x"})]})}function Zl(){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,s)=>{l[s]=i}),l}function Ut(t){const a=window.location.hash,n=a.indexOf("?"),l=n===-1?a:a.slice(0,n),i=new URLSearchParams;for(const[c,h]of Object.entries(t))h&&i.set(c,h);const s=i.toString(),r=s?`${l}?${s}`:l;window.history.replaceState(null,"",r)}function Ga({fields:t,values:a,onChange:n,syncUrl:l=!0}){G(()=>{if(!l)return;const r=Zl(),c={...a};let h=!1;for(const o of t){const u=r[o.key];u!==void 0&&u!==c[o.key]&&(c[o.key]=u,h=!0)}h&&n(c)},[]);function i(r,c){const h={...a,[r]:c};n(h),l&&Ut(h)}function s(){const r={};for(const c of t)r[c.key]="";n(r),l&&Ut(r)}return e("div",{class:"filter-bar",children:[t.map(r=>e("div",{class:"filter-field",children:[e("label",{children:r.label}),r.type==="select"?e("select",{value:a[r.key]??"",onChange:c=>i(r.key,c.target.value),children:[e("option",{value:"",children:"All"}),r.options?.map(c=>e("option",{value:c.value,children:c.label},c.value))]}):e("input",{type:"date",value:a[r.key]??"",placeholder:r.placeholder,onChange:c=>i(r.key,c.target.value)})]},r.key)),e("button",{class:"btn btn-secondary filter-clear",type:"button",onClick:s,children:"Clear"})]})}const Ql=new Set(["notifications.telegram_bot_token","notifications.discord_webhook_url","notifications.slack_webhook_url","telegram.bot_token"]);function ei(t){return Ql.has(t)}function Z(t){return{enabled:"Enabled",telegram_bot_token:"Telegram Bot Token",telegram_chat_id:"Telegram Chat ID",discord_webhook_url:"Discord Webhook URL",ntfy_server:"Ntfy Server",ntfy_topic:"Ntfy Topic",locale:"Locale",rate_limit_rpm:"Rate Limit (RPM)",solana_mainnet:"Solana Mainnet",solana_devnet:"Solana Devnet",solana_testnet:"Solana Testnet",evm_ethereum_mainnet:"Ethereum Mainnet",evm_ethereum_sepolia:"Ethereum Sepolia",evm_polygon_mainnet:"Polygon Mainnet",evm_polygon_amoy:"Polygon Amoy",evm_arbitrum_mainnet:"Arbitrum Mainnet",evm_arbitrum_sepolia:"Arbitrum Sepolia",evm_optimism_mainnet:"Optimism Mainnet",evm_optimism_sepolia:"Optimism Sepolia",evm_base_mainnet:"Base Mainnet",evm_base_sepolia:"Base Sepolia",max_sessions_per_wallet:"Max Sessions per Wallet",max_pending_tx:"Max Pending Transactions",rate_limit_global_ip_rpm:"Global IP Rate Limit (RPM)",rate_limit_session_rpm:"Session Rate Limit (RPM)",rate_limit_tx_rpm:"Transaction Rate Limit (RPM)",policy_defaults_delay_seconds:"Policy Delay (seconds)",policy_defaults_approval_timeout:"Approval Timeout (seconds)",default_deny_tokens:"Default Deny: Token Transfers",default_deny_contracts:"Default Deny: Contract Calls",default_deny_spenders:"Default Deny: Token Approvals",default_deny_x402_domains:"Default Deny: x402 Domains",project_id:"Project ID",log_level:"Log Level",currency:"Display Currency",consecutive_failures_threshold:"Consecutive Failures Threshold",unusual_activity_threshold:"Unusual Activity Threshold",unusual_activity_window_sec:"Unusual Activity Window (seconds)",idle_timeout_sec:"Idle Timeout (seconds)",idle_check_interval_sec:"Idle Check Interval (seconds)",check_interval_sec:"Check Interval (seconds)",low_balance_threshold_sol:"Low Balance Threshold (SOL)",low_balance_threshold_eth:"Low Balance Threshold (ETH)",cooldown_hours:"Alert Cooldown (hours)",relay_url:"Relay URL",bot_token:"Bot Token",request_expiry_min:"Request Expiry (minutes)",preferred_channel:"Preferred Channel",preferred_wallet:"Preferred Wallet",ntfy_request_topic_prefix:"Ntfy Request Topic Prefix",ntfy_response_topic_prefix:"Ntfy Response Topic Prefix",wallets:"Registered Wallets (JSON)",aave_v3_enabled:"Aave V3 Enabled",aave_v3_health_factor_warning_threshold:"HF Warning Threshold",aave_v3_position_sync_interval_sec:"Position Sync Interval (seconds)",aave_v3_max_ltv_pct:"Max LTV Percentage",kamino_enabled:"Kamino Enabled",kamino_market:"Market",kamino_hf_threshold:"HF Warning Threshold",drift_enabled:"Drift Perp Enabled",drift_max_leverage:"Max Leverage",drift_max_position_usd:"Max Position Size (USD)",drift_margin_warning_threshold_pct:"Margin Warning Threshold (%)",drift_position_sync_interval_sec:"Position Sync Interval (seconds)",poll_interval_sec:"Poll Interval (seconds)",default_timeout_sec:"Default Timeout (seconds)",max_timeout_sec:"Max Timeout (seconds)",max_pending_count:"Max Pending Count"}[t]??t.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function re(t,a,n,l){const i=`${n}.${l}`;if(a[i]!==void 0)return a[i];const s=t[n];if(!s)return"";const r=s[l];return typeof r=="boolean"?ei(i)?"":String(r):r??""}function Ve(t,a,n,l){const i=`${n}.${l}`;if(a[i]!==void 0)return a[i]==="true";const s=t[n];if(!s)return!1;const r=s[l];return typeof r=="boolean"?r:r==="true"}function ua(t,a,n,l){const i=`${n}.${l}`;if(a[i]!==void 0)return!1;const s=t[n];return s?s[l]===!0:!1}const Ee=[{value:"dcent",label:"D'CENT Wallet",description:"D'CENT hardware wallet with push notification signing"}],Na={dcent:"Wallet App (ntfy)"},ai={dcent:"sdk_ntfy"};function Rn(t){switch(t){case"NONE":return"neutral";case"GRACE":return"warning";case"LOCKED":return"success";default:return"neutral"}}function ce({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 $t=[{value:null,label:"Auto (Global Fallback)",description:"System decides based on configured channels: Wallet App (ntfy) > Wallet App (Telegram) > WalletConnect > Telegram Bot > REST"},{value:"sdk_ntfy",label:"Wallet App (ntfy)",description:"Push sign request to wallet app via ntfy server",warning:"Signing SDK is not enabled. Go to 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)"}],ti=[{key:"overview",label:"Overview"},{key:"transactions",label:"Transactions"},{key:"owner",label:"Owner"},{key:"staking",label:"Staking"},{key:"mcp",label:"MCP"}],ra=20,ni=[{value:"PENDING",label:"PENDING"},{value:"APPROVED",label:"APPROVED"},{value:"SUBMITTED",label:"SUBMITTED"},{value:"CONFIRMED",label:"CONFIRMED"},{value:"FAILED",label:"FAILED"}],li=[{value:"TRANSFER",label:"TRANSFER"},{value:"TOKEN_TRANSFER",label:"TOKEN_TRANSFER"},{value:"CONTRACT_CALL",label:"CONTRACT_CALL"},{value:"APPROVE",label:"APPROVE"},{value:"BATCH",label:"BATCH"}],ii=[{key:"status",label:"Status",type:"select",options:ni},{key:"type",label:"Type",type:"select",options:li}],Ja=["Time","Type","To","Amount","Network","Status","Tx Hash"];function si(t){return t==="CONFIRMED"?"success":t==="FAILED"?"danger":"warning"}function ri({id:t}){const a=d(null),n=d(!0),l=d(!1),i=d(""),s=d(!1),r=d(!1),c=d(!1),h=d(!1),o=d(null),u=d([]),v=d(!0),f=d(null),N=d(!0),x=d([]),W=d(!0),y=d(0),A=d(0),w=d({status:"",type:""}),F=d(!1),D=d(null),H=d(!1),O=d(null),k=d(!0),_=d(!1),m=d(null),R=d(!1),g=d(""),p=d(!1),U=d(""),B=d(!1),E=d(null),Y=d(!1),ae=d(!1),ie=d(""),te=d(!1),oe=d("overview"),Te=d("USD"),ke=d(1),Oe=d([]),Le=d(!0),Ne=async()=>{try{const S=await z(L.WALLET(t));a.value=S}catch(S){const q=S instanceof T?S:new T(0,"UNKNOWN","Unknown error");b("error",K(q.code))}finally{n.value=!1}},$=async()=>{s.value=!0;try{const S=await de(L.WALLET(t),{name:i.value});a.value=S,l.value=!1,b("success","Wallet name updated")}catch(S){const q=S instanceof T?S:new T(0,"UNKNOWN","Unknown error");b("error",K(q.code))}finally{s.value=!1}},ne=async()=>{c.value=!0;try{await $e(L.WALLET(t)),b("success","Wallet terminated"),window.location.hash="#/wallets"}catch(S){const q=S instanceof T?S:new T(0,"UNKNOWN","Unknown error");b("error",K(q.code))}finally{c.value=!1}},we=async()=>{ae.value=!0;try{await se(L.WALLET_SUSPEND(t),{reason:ie.value.trim()||void 0}),b("success","Wallet suspended"),Y.value=!1,ie.value="",await Ne()}catch(S){const q=S instanceof T?S:new T(0,"UNKNOWN","Unknown error");b("error",K(q.code))}finally{ae.value=!1}},qa=async()=>{te.value=!0;try{await se(L.WALLET_RESUME(t)),b("success","Wallet resumed"),await Ne()}catch(S){const q=S instanceof T?S:new T(0,"UNKNOWN","Unknown error");b("error",K(q.code))}finally{te.value=!1}},ja=()=>{i.value=a.value.name,l.value=!0},C=()=>{l.value=!1},M=async()=>{h.value=!0;try{const S=await se(L.MCP_TOKENS,{walletId:t});o.value=S,b("success","MCP token provisioned successfully")}catch(S){const q=S instanceof T?S:new T(0,"UNKNOWN","Unknown error");b("error",K(q.code))}finally{h.value=!1}},le=async()=>{v.value=!0;try{const S=await z(L.WALLET_NETWORKS(t));u.value=S.availableNetworks??[]}catch(S){const q=S instanceof T?S:new T(0,"UNKNOWN","Unknown error");b("error",K(q.code)),u.value=[]}finally{v.value=!1}},pe=async()=>{N.value=!0;try{f.value=await z(L.ADMIN_WALLET_BALANCE(t))}catch{f.value=null}finally{N.value=!1}},je=async S=>{W.value=!0;try{const j=(S??A.value)*ra,ye=await z(`${L.ADMIN_WALLET_TRANSACTIONS(t)}?offset=${j}&limit=${ra}`);x.value=ye.items,y.value=ye.total}catch{x.value=[],y.value=0}finally{W.value=!1}},He=Va(()=>{let S=x.value;const q=w.value;return q.status&&(S=S.filter(j=>j.status===q.status)),q.type&&(S=S.filter(j=>j.type===q.type)),S}),X=async()=>{Le.value=!0;try{const S=await z(L.ADMIN_WALLET_STAKING(t));Oe.value=S.positions??[]}catch{Oe.value=[]}finally{Le.value=!1}},ia=async()=>{k.value=!0;try{O.value=await z(L.WALLET_WC_SESSION(t))}catch{O.value=null}finally{k.value=!1}},Sa=()=>{m.value&&clearInterval(m.value),m.value=setInterval(async()=>{try{const S=await z(L.WALLET_WC_PAIR_STATUS(t));S.status==="connected"?(m.value&&clearInterval(m.value),m.value=null,F.value=!1,D.value=null,O.value=S.session??null,b("success","Wallet connected via WalletConnect")):(S.status==="expired"||S.status==="none")&&(m.value&&clearInterval(m.value),m.value=null,F.value=!1,D.value=null,b("error","Pairing expired. Try again."))}catch{}},3e3)},Wn=async()=>{H.value=!0;try{const S=await se(L.WALLET_WC_PAIR(t));D.value=S,F.value=!0,Sa()}catch(S){const q=S instanceof T?S:new T(0,"UNKNOWN","Unknown error");q.code==="WC_NOT_CONFIGURED"?(b("error","WalletConnect is not configured. Redirecting to settings..."),ue.value={tab:"walletconnect",fieldName:"walletconnect.project_id"},window.location.hash="#/wallets"):b("error",K(q.code))}finally{H.value=!1}},Un=async()=>{_.value=!0;try{await $e(L.WALLET_WC_SESSION(t)),O.value=null,b("success","WalletConnect session disconnected")}catch(S){const q=S instanceof T?S:new T(0,"UNKNOWN","Unknown error");b("error",K(q.code))}finally{_.value=!1}},Tt=()=>{g.value=a.value?.ownerAddress??"",U.value=a.value?.walletType??"",R.value=!0},$n=()=>{R.value=!1},Fn=async()=>{if(!g.value.trim()){b("error","Owner address is required");return}p.value=!0;try{const S={owner_address:g.value.trim()};U.value&&(S.wallet_type=U.value),await de(L.WALLET_OWNER(t),S),await Ne(),R.value=!1;const q=Ee.find(j=>j.value===U.value);q?b("success",`Owner set with ${q.label} auto-setup`):b("success","Owner address updated")}catch(S){const q=S instanceof T?S:new T(0,"UNKNOWN","Unknown error");b("error",K(q.code,q.serverMessage))}finally{p.value=!1}},Kn=async S=>{if(a.value?.ownerAddress){p.value=!0;try{const q={owner_address:a.value.ownerAddress};S&&(q.wallet_type=S),await de(L.WALLET_OWNER(t),q),await Ne(),B.value=!1;const j=Ee.find(ye=>ye.value===S);j?b("success",`Wallet Type changed to ${j.label}`):b("success","Wallet Type cleared")}catch(q){const j=q instanceof T?q:new T(0,"UNKNOWN","Unknown error");b("error",K(j.code,j.serverMessage))}finally{p.value=!1}}},Hn=async()=>{try{const S=await z(L.ADMIN_SETTINGS),q=S.signing_sdk?.enabled==="true",j=S.telegram?.bot_token===!0||S.notifications?.telegram_bot_token===!0,ye=!!S.walletconnect?.project_id&&S.walletconnect.project_id!=="";E.value={signingEnabled:q,telegramBotConfigured:j,wcConfigured:ye}}catch{}},Bn=async S=>{const q=a.value?.walletType;if(q){const j=Ee.find(Ya=>Ya.value===q),ye=j?ai[q]:void 0;if(ye&&S!==ye){const Ya=j.label,Qn=$t.find(el=>el.value===ye)?.label??ye;if(!confirm(`${Ya} preset default is "${Qn}". Changing the approval method may prevent sign requests from being delivered correctly.
2
+
3
+ Proceed with change?`))return}}try{await de(L.WALLET_OWNER(t),{owner_address:a.value.ownerAddress,approval_method:S??null}),await Ne(),b("success","Approval method updated")}catch(j){const ye=j instanceof T?j:new T(0,"UNKNOWN","Unknown error");b("error",K(ye.code,ye.serverMessage))}};G(()=>{Ne(),le(),pe(),je(),ia(),X(),Hn(),wt().then(({currency:S,rate:q})=>{Te.value=S,ke.value=q}).catch(()=>{})},[t]),G(()=>()=>{m.value&&clearInterval(m.value)},[]),G(()=>{je()},[A.value]);const kt=A.value*ra,Vn=y.value>0?kt+1:0,zn=Math.min(kt+ra,y.value),Gn=A.value>0,qn=(A.value+1)*ra<y.value;function jn(){return a.value?e(J,{children:[e("div",{class:"detail-grid",children:[e(ce,{label:"ID",value:a.value.id,copy:!0}),e(ce,{label:"Public Key",value:a.value.publicKey,copy:!0}),e(ce,{label:"Chain",value:a.value.chain}),e(ce,{label:"Environment",children:e(V,{variant:a.value.environment==="mainnet"?"warning":"info",children:a.value.environment})}),e(ce,{label:"Status",children:e(V,{variant:a.value.status==="ACTIVE"?"success":a.value.status==="SUSPENDED"?"warning":"danger",children:a.value.status})}),e(ce,{label:"Account Type",children:e(V,{variant:a.value.accountType==="smart"?"info":"default",children:a.value.accountType==="smart"?"Smart Account":"EOA"})}),a.value.accountType==="smart"&&e(J,{children:[e(ce,{label:"Signer Key",value:a.value.signerKey??"--",copy:!0}),e(ce,{label:"Deployed",children:e(V,{variant:a.value.deployed?"success":"warning",children:a.value.deployed?"Yes":"Not yet"})})]}),a.value.status==="SUSPENDED"&&e(J,{children:[e(ce,{label:"Suspended At",value:a.value.suspendedAt?me(a.value.suspendedAt):"--"}),e(ce,{label:"Suspension Reason",value:a.value.suspensionReason??"--"})]}),e(ce,{label:"Created",value:me(a.value.createdAt)}),e(ce,{label:"Updated",value:a.value.updatedAt?me(a.value.updatedAt):"Never"})]}),e("div",{class:"balance-section",style:{marginTop:"var(--space-6)"},children:[e("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-3)",marginBottom:"var(--space-3)"},children:[e("h3",{style:{margin:0},children:"Balances"}),e(P,{variant:"secondary",size:"sm",onClick:pe,loading:N.value,children:"Refresh"})]}),N.value?e("div",{class:"stat-skeleton",style:{height:"60px"}}):f.value?.balances?.length?e("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-3)"},children:f.value.balances.map(S=>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:S.network})}),S.error?e("p",{style:{color:"var(--color-text-secondary)",fontSize:"0.85rem"},children:S.error}):S.native?e("div",{children:[e(ce,{label:"Native",children:e("span",{children:[S.native.balance," ",S.native.symbol,S.native.usd!=null&&e("span",{style:{color:"var(--color-text-secondary)",marginLeft:"var(--space-2)",fontSize:"0.85rem"},children:["(",aa(S.native.usd,Te.value,ke.value),")"]})]})}),S.tokens.length>0?S.tokens.map(q=>e(ce,{label:q.symbol,value:q.balance},q.address)):null]}):e("p",{style:{color:"var(--color-text-secondary)",fontSize:"0.85rem"},children:"Balance unavailable"})]},S.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"}),v.value?e("div",{class:"stat-skeleton",style:{height:"80px"}}):e("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2)"},children:(u.value??[]).map(S=>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:S.name??S.network})},S.network))})]})]}):null}function Yn(){return e(J,{children:[e(Ga,{fields:ii,values:w.value,onChange:S=>{w.value=S},syncUrl:!1}),e("div",{class:"table-container",style:{marginTop:"var(--space-3)"},children:e("table",{children:[e("thead",{children:e("tr",{children:Ja.map(S=>e("th",{children:S},S))})}),e("tbody",{children:W.value&&He.value.length===0?e("tr",{children:e("td",{colSpan:Ja.length,class:"table-loading",children:"Loading..."})}):He.value.length===0?e("tr",{children:e("td",{colSpan:Ja.length,class:"table-empty",children:"No transactions yet"})}):He.value.map(S=>e("tr",{children:[e("td",{children:S.createdAt?me(S.createdAt):"—"}),e("td",{children:e(V,{variant:"info",children:S.type})}),e("td",{children:S.toAddress?Wa(S.toAddress):"—"}),e("td",{children:S.amount?S.formattedAmount??S.amount:"—"}),e("td",{children:S.network??"—"}),e("td",{children:e(V,{variant:si(S.status),children:S.status})}),e("td",{children:e(St,{network:S.network??"",txHash:S.txHash})})]},S.id))})]})}),e("div",{class:"pagination",style:{marginTop:"var(--space-3)"},children:[e("span",{class:"pagination-info",children:["Showing ",Vn,"-",zn," of ",y.value]}),e("div",{class:"pagination-buttons",children:[e(P,{variant:"secondary",size:"sm",disabled:!Gn,onClick:()=>{A.value=A.value-1},children:"Previous"}),e(P,{variant:"secondary",size:"sm",disabled:!qn,onClick:()=>{A.value=A.value+1},children:"Next"})]})]})]})}function Xn(){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(P,{size:"sm",onClick:Tt,children:"Set Owner Address"})]}),R.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:U.value,onChange:S=>{U.value=S.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)"}),Ee.map(S=>e("option",{value:S.value,children:S.label},S.value))]}),U.value&&e("p",{style:{marginTop:"var(--space-1)",fontSize:"0.8rem",color:"var(--color-text-secondary)"},children:Ee.find(S=>S.value===U.value)?.description}),U.value&&Na[U.value]&&e("p",{style:{marginTop:"var(--space-1)",fontSize:"0.8rem",color:"var(--color-primary)"},children:["Approval: ",Na[U.value]]})]}),e(ce,{label:"Address",children:R.value?e("div",{class:"inline-edit",children:[e("input",{value:g.value,onInput:S=>{g.value=S.target.value},class:"inline-edit-input",placeholder:"Enter owner wallet address"}),e(P,{size:"sm",onClick:Fn,loading:p.value,children:"Save"}),e(P,{size:"sm",variant:"secondary",onClick:$n,children:"Cancel"})]}):e("span",{children:[a.value.ownerAddress?e(J,{children:[Wa(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:Tt,title:"Set owner address",children:"✎"})]})}),e(ce,{label:"State",children:[e(V,{variant:Rn(a.value.ownerState),children:a.value.ownerState}),a.value.walletType&&e(V,{variant:"info",style:{marginLeft:"var(--space-2)"},children:Ee.find(S=>S.value===a.value.walletType)?.label??a.value.walletType})]}),a.value.ownerState==="GRACE"&&e("div",{style:{marginTop:"var(--space-3)"},children:[e(ce,{label:"Wallet Type",children:B.value?e("div",{class:"inline-edit",children:[e("select",{value:U.value,onChange:S=>{U.value=S.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)"}),Ee.map(S=>e("option",{value:S.value,children:S.label},S.value))]}),e(P,{size:"sm",onClick:()=>Kn(U.value),loading:p.value,children:"Save"}),e(P,{size:"sm",variant:"secondary",onClick:()=>{B.value=!1},children:"Cancel"})]}):e("span",{children:[Ee.find(S=>S.value===a.value.walletType)?.label??a.value.walletType??"Custom",e("button",{class:"btn btn-ghost btn-sm",onClick:()=>{U.value=a.value?.walletType??"",B.value=!0},title:"Change wallet type",children:"✎"})]})}),B.value&&U.value&&Na[U.value]&&e("p",{style:{fontSize:"0.8rem",color:"var(--color-primary)",marginTop:"var(--space-1)"},children:["Approval: ",Na[U.value]]})]}),a.value.ownerState==="LOCKED"&&a.value.walletType&&e(ce,{label:"Wallet Type",children:e("span",{children:Ee.find(S=>S.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:$t.map(S=>e("label",{style:{display:"flex",alignItems:"flex-start",gap:"var(--space-2)",padding:"var(--space-2) var(--space-3)",background:a.value?.approvalMethod===S.value?"var(--color-bg-secondary)":"transparent",borderRadius:"var(--radius-md)",cursor:"pointer"},children:[e("input",{type:"radio",name:"approval_method",value:S.value??"",checked:a.value?.approvalMethod===S.value,onChange:()=>Bn(S.value),style:{marginTop:"2px"},disabled:a.value?.ownerState==="LOCKED"}),e("div",{children:[e("div",{style:{fontWeight:500,fontSize:"0.9rem"},children:S.label}),e("div",{style:{color:"var(--color-text-secondary)",fontSize:"0.8rem"},children:S.description}),S.warning&&S.warningCondition?.(E.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:S.warning})]})]},S.value??"auto"))})]}),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"}}):O.value?e("div",{children:[e(ce,{label:"Status",children:e(V,{variant:"success",children:"Connected"})}),e(ce,{label:"Peer",value:O.value.peerName??"Unknown"}),e(ce,{label:"Chain ID",value:O.value.chainId}),e(ce,{label:"Expires",value:me(O.value.expiry)}),e("div",{style:{marginTop:"var(--space-3)"},children:e(P,{variant:"danger",onClick:Un,loading:_.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(P,{onClick:Wn,loading:H.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 Jn(){function S(j){return j==="lido"?"info":"neutral"}function q(j){return j==="COMPLETED"?"success":j==="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(P,{variant:"secondary",size:"sm",onClick:X,loading:Le.value,children:"Refresh"})]}),Le.value?e("div",{class:"stat-skeleton",style:{height:"80px"}}):Oe.value.length===0?e(Ua,{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(j=>e("tr",{children:[e("td",{children:e(V,{variant:S(j.protocol),children:j.protocol==="lido"?"Lido":"Jito"})}),e("td",{children:j.asset}),e("td",{children:j.chain==="ethereum"?`${(Number(j.balance)/1e18).toFixed(6)} stETH`:`${(Number(j.balance)/1e9).toFixed(6)} JitoSOL`}),e("td",{children:j.balanceUsd?aa(Number(j.balanceUsd),Te.value,ke.value):"—"}),e("td",{children:j.apy??"—"}),e("td",{children:j.pendingUnstake?e("span",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)"},children:[e(V,{variant:q(j.pendingUnstake.status),children:j.pendingUnstake.status}),e("span",{style:{fontSize:"0.85em",color:"var(--color-text-secondary)"},children:j.chain==="ethereum"?`${(Number(j.pendingUnstake.amount)/1e18).toFixed(4)} stETH`:`${(Number(j.pendingUnstake.amount)/1e9).toFixed(4)} JitoSOL`})]}):"—"})]},`${j.protocol}-${j.chain}`))})]})})]})}function Zn(){return e("div",{class:"mcp-setup-section",children:[e("h3",{style:{marginBottom:"var(--space-3)"},children:"MCP Setup"}),o.value?e("div",{children:[e("div",{class:"detail-grid",style:{marginBottom:"var(--space-4)"},children:[e(ce,{label:"Token Path",value:o.value.tokenPath}),e(ce,{label:"Expires At",value:me(o.value.expiresAt)})]}),e("div",{style:{marginBottom:"var(--space-2)"},children:e("strong",{children:"Claude Desktop Config"})}),e("div",{style:{position:"relative"},children:[e("pre",{children:e("code",{style:{display:"block",whiteSpace:"pre-wrap",wordBreak:"break-all",background:"var(--color-bg-secondary)",padding:"var(--space-3)",borderRadius:"var(--radius-md)",fontSize:"0.85rem",maxHeight:"300px",overflow:"auto"},children:JSON.stringify({mcpServers:o.value.claudeDesktopConfig},null,2)})}),e("div",{style:{marginTop:"var(--space-2)"},children:e(Ge,{value:JSON.stringify({mcpServers:o.value.claudeDesktopConfig},null,2),label:"Copy Config"})})]}),e("div",{style:{marginTop:"var(--space-3)"},children:e(P,{variant:"secondary",onClick:M,loading:h.value,children:"Re-provision"})})]}):e("div",{children:[e("p",{style:{marginBottom:"var(--space-3)",color:"var(--color-text-secondary)"},children:"Provision an MCP token for Claude Desktop integration."}),e(P,{onClick:M,loading:h.value,children:"Setup MCP"})]})]})}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:S=>{i.value=S.target.value},class:"inline-edit-input"}),e(P,{size:"sm",onClick:$,loading:s.value,children:"Save"}),e(P,{size:"sm",variant:"secondary",onClick:C,children:"Cancel"})]}):e("span",{children:[a.value.name,e("button",{class:"btn btn-ghost btn-sm",onClick:ja,title:"Edit name",children:"✎"})]})}),e("div",{style:{display:"flex",gap:"var(--space-2)"},children:[a.value.status==="ACTIVE"&&e(P,{variant:"secondary",onClick:()=>{Y.value=!0},children:"Suspend Wallet"}),a.value.status==="SUSPENDED"&&e(P,{variant:"primary",onClick:qa,loading:te.value,children:"Resume Wallet"}),a.value.status!=="TERMINATED"&&e(P,{variant:"danger",onClick:()=>{r.value=!0},children:"Terminate Wallet"})]})]}),e(Ke,{tabs:ti,activeTab:oe.value,onTabChange:S=>{oe.value=S}}),oe.value==="overview"&&e(jn,{}),oe.value==="transactions"&&e(Yn,{}),oe.value==="owner"&&e(Xn,{}),oe.value==="staking"&&e(Jn,{}),oe.value==="mcp"&&e(Zn,{}),e(be,{open:r.value,title:"Terminate Wallet",onCancel:()=>{r.value=!1},onConfirm:ne,confirmText:"Terminate",confirmVariant:"danger",loading:c.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(be,{open:F.value,title:"Scan QR Code",onCancel:()=>{F.value=!1,m.value&&clearInterval(m.value),m.value=null},children:D.value&&e("div",{style:{textAlign:"center"},children:[e("img",{src:D.value.qrCode,alt:"WalletConnect QR Code",style:{width:"280px",height:"280px",margin:"0 auto"}}),e("p",{style:{marginTop:"var(--space-3)",color:"var(--color-text-secondary)",fontSize:"0.85rem"},children:"Scan with D'CENT, MetaMask, Phantom, or any WalletConnect-compatible wallet"}),e("p",{style:{marginTop:"var(--space-2)",color:"var(--color-text-secondary)",fontSize:"0.75rem"},children:"Waiting for connection..."})]})}),e(be,{open:Y.value,title:"Suspend Wallet",onCancel:()=>{Y.value=!1,ie.value=""},onConfirm:we,confirmText:"Suspend",confirmVariant:"danger",loading:ae.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(I,{label:"Reason (optional)",name:"suspend-reason",value:ie.value,onChange:S=>{ie.value=S},placeholder:"e.g. suspicious activity"})]})]}):e(Ua,{title:"Wallet not found",description:"The wallet may have been deleted."})]})}const oi={"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"},Xe=["solana-mainnet","solana-devnet","solana-testnet"],oa=["ethereum-mainnet","ethereum-sepolia","polygon-mainnet","polygon-amoy","arbitrum-mainnet","arbitrum-sepolia","optimism-mainnet","optimism-sepolia","base-mainnet","base-sepolia"];function ci(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 di(t){return Xe.includes(t)?"solana":"evm"}function ui(){const t=d({}),a=d({}),n=d({}),l=d(!1),i=d(!0),s=d({}),r=d({}),c=d({}),h=d({}),o=d({}),u=d({}),v=(_,m)=>{const R={},g=[...Xe,...oa];for(const p of g){const U=[],B=_.rpc_pool;if(B){const ie=B[p];if(typeof ie=="string"&&ie!=="[]")try{const te=JSON.parse(ie);Array.isArray(te)&&U.push(...te.filter(oe=>typeof oe=="string"&&oe.length>0))}catch{}}const E=m[p]??[],Y=new Set(U),ae=[];for(const ie of U)ae.push({url:ie,isBuiltin:E.includes(ie),enabled:!0});for(const ie of E)Y.has(ie)||ae.push({url:ie,isBuiltin:!0,enabled:!0});R[p]=ae}return R},f=async()=>{try{try{const R=await z(L.ADMIN_RPC_STATUS);R.builtinUrls&&(h.value=R.builtinUrls),c.value=R.networks??{}}catch{}const _=await z(L.ADMIN_SETTINGS);t.value=_;const m=v(_,h.value);n.value=m,a.value=JSON.parse(JSON.stringify(m))}catch(_){const m=_ instanceof T?_:new T(0,"UNKNOWN","Unknown error");b("error",K(m.code))}finally{i.value=!1}};G(()=>{f()},[]),G(()=>{const _=async()=>{try{const R=await z(L.ADMIN_RPC_STATUS);c.value=R.networks??{},R.builtinUrls&&(h.value=R.builtinUrls)}catch{}};_();const m=setInterval(_,15e3);return()=>clearInterval(m)},[]);const N=async(_,m)=>{const R=`${_}:${m}`;o.value={...o.value,[R]:!0};try{const g=await se(L.ADMIN_SETTINGS_TEST_RPC,{url:m,chain:di(_)});u.value={...u.value,[R]:g}}catch{u.value={...u.value,[R]:{success:!1,latencyMs:0,error:"Request failed"}}}finally{o.value={...o.value,[R]:!1}}},x=()=>{for(const _ of[...Xe,...oa]){const m=n.value[_]??[],R=a.value[_]??[];if(m.length!==R.length)return!0;for(let g=0;g<m.length;g++)if(m[g].url!==R[g].url||m[g].enabled!==R[g].enabled)return!0}return!1},W=Va(()=>{let _=0;for(const m of[...Xe,...oa]){const R=n.value[m]??[],g=a.value[m]??[];if(R.length!==g.length){_++;continue}for(let p=0;p<R.length;p++)if(R[p].url!==g[p].url||R[p].enabled!==g[p].enabled){_++;break}}return _}),y=async()=>{l.value=!0;try{const _=[];for(const g of[...Xe,...oa]){const U=(a.value[g]??[]).filter(B=>!B.isBuiltin&&B.enabled).map(B=>B.url);_.push({key:`rpc_pool.${g}`,value:JSON.stringify(U)})}const m=await de(L.ADMIN_SETTINGS,{settings:_});t.value=m.settings;const R=v(m.settings);n.value=R,a.value=JSON.parse(JSON.stringify(R)),b("success","RPC settings saved and applied")}catch(_){const m=_ instanceof T?_:new T(0,"UNKNOWN","Unknown error");b("error",K(m.code))}finally{l.value=!1}},A=()=>{a.value=JSON.parse(JSON.stringify(n.value))};G(()=>(De({id:"wallets-rpc",isDirty:x,save:y,discard:A}),()=>Ae("wallets-rpc")),[]);const w=_=>{s.value={...s.value,[_]:!s.value[_]}},F=_=>{const m=(r.value[_]??"").trim();if(!m)return;if(!m.startsWith("https://")){b("warning","URL must start with https://");return}const R=a.value[_]??[];if(R.some(U=>U.url===m)){b("warning","URL already exists in this network");return}const g=[...R];g.findIndex(U=>U.isBuiltin&&!R.slice(0,R.indexOf(U)).some(B=>!B.isBuiltin));const p=g.reduce((U,B,E)=>B.isBuiltin?U:E+1,0);g.splice(p,0,{url:m,isBuiltin:!1,enabled:!0}),a.value={...a.value,[_]:g},r.value={...r.value,[_]:""}},D=(_,m)=>{const R=[...a.value[_]??[]];R[m]?.isBuiltin||(R.splice(m,1),a.value={...a.value,[_]:R})},H=(_,m,R)=>{const g=[...a.value[_]??[]],p=R==="up"?m-1:m+1;if(p<0||p>=g.length)return;const U=g[m],B=g[p];!U||!B||([g[m],g[p]]=[g[p],g[m]],a.value={...a.value,[_]:g})},O=(_,m)=>{const R=[...a.value[_]??[]],g=R[m];g?.isBuiltin&&(R[m]={...g,enabled:!g.enabled},a.value={...a.value,[_]:R})};function k({network:_}){const m=a.value[_]??[],R=s.value[_]??!1,g=m.filter(B=>B.enabled).length,p=c.value[_]??[],U=B=>p.find(E=>E.url===B);return e("details",{class:"rpc-pool-network",open:R,"data-testid":`rpc-network-${_}`,children:[e("summary",{class:"rpc-pool-network-header",onClick:B=>{B.preventDefault(),w(_)},children:[e("span",{children:oi[_]??_}),e("span",{class:"rpc-pool-url-count",children:[g," URL",g!==1?"s":""]})]}),R&&e("div",{class:"rpc-url-list",children:[m.map((B,E)=>{const Y=U(B.url),ae=`${_}:${B.url}`,ie=o.value[ae]??!1,te=u.value[ae];return e("div",{class:`rpc-url-item${B.isBuiltin?" rpc-url-item--builtin":""}${B.enabled?"":" rpc-url-disabled"}`,"data-testid":`rpc-url-${_}-${E}`,children:[e("span",{class:"rpc-url-priority",children:["#",E+1]}),e("span",{class:"rpc-url-item-url",title:B.url,children:B.url}),B.isBuiltin&&e("span",{class:"badge-builtin",children:"(built-in)"}),e("span",{class:"rpc-url-status","data-testid":`rpc-status-${_}-${E}`,children:Y?Y.status==="available"?e(J,{children:[e("span",{class:"rpc-url-status-dot rpc-url-status-dot--available"}),e("span",{children:"Available"})]}):e(J,{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:[ci(Y.cooldownRemainingMs)," remaining"]}),e(V,{variant:"warning",children:[Y.failureCount," fail",Y.failureCount!==1?"s":""]})]}):e(J,{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(P,{variant:"ghost",size:"sm",onClick:()=>N(_,B.url),loading:ie,children:"Test"}),te&&e("span",{class:`rpc-test-result ${te.success?"rpc-test-result--success":"rpc-test-result--failure"}`,children:[e(V,{variant:te.success?"success":"danger",children:te.success?"OK":"FAIL"}),te.success&&e(J,{children:[" ",te.latencyMs,"ms",te.blockNumber!==void 0&&` (block #${te.blockNumber.toLocaleString()})`]}),te.error&&` - ${te.error}`]})]}),e("span",{class:"rpc-url-actions",children:[e("button",{class:"btn btn-ghost btn-sm rpc-action-btn",onClick:()=>H(_,E,"up"),disabled:E===0,title:"Move up","aria-label":"Move up",children:"↑"}),e("button",{class:"btn btn-ghost btn-sm rpc-action-btn",onClick:()=>H(_,E,"down"),disabled:E===m.length-1,title:"Move down","aria-label":"Move down",children:"↓"}),B.isBuiltin?e("button",{class:`btn btn-ghost btn-sm rpc-action-btn${B.enabled?"":" rpc-toggle-off"}`,onClick:()=>O(_,E),title:B.enabled?"Disable":"Enable","aria-label":B.enabled?"Disable":"Enable",children:B.enabled?"On":"Off"}):e("button",{class:"btn btn-ghost btn-sm rpc-action-btn rpc-delete-btn",onClick:()=>D(_,E),title:"Remove","aria-label":"Remove",children:"×"})]})]},`${_}-${E}`)}),e("div",{class:"rpc-add-url",children:[e("input",{type:"text",class:"rpc-add-url-input",placeholder:"https://your-rpc-url.com",value:r.value[_]??"",onInput:B=>{r.value={...r.value,[_]:B.target.value}},onKeyDown:B=>{B.key==="Enter"&&F(_)}}),e(P,{variant:"secondary",size:"sm",onClick:()=>F(_),children:"Add"})]})]})]})}return i.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(J,{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(P,{variant:"ghost",size:"sm",onClick:A,children:"Discard"}),e(P,{variant:"primary",size:"sm",onClick:y,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"}),Xe.map(_=>e(k,{network:_},_))]}),e("div",{class:"settings-subgroup",children:[e("div",{class:"settings-subgroup-title",children:"EVM"}),oa.map(_=>e(k,{network:_},_))]})]})]})]})}function vi(){const t=d({}),a=d({}),n=d(!1),l=d(!0),i=async()=>{try{const o=await z(L.ADMIN_SETTINGS);t.value=o}catch(o){const u=o instanceof T?o:new T(0,"UNKNOWN","Unknown error");b("error",K(u.code))}finally{l.value=!1}};G(()=>{i()},[]);const s=(o,u)=>{const v=String(u);a.value={...a.value,[o]:v}},r=async()=>{n.value=!0;try{const o=Object.entries(a.value).filter(([v])=>v.startsWith("walletconnect.")).map(([v,f])=>({key:v,value:f})),u=await de(L.ADMIN_SETTINGS,{settings:o});t.value=u.settings,a.value={},b("success","Settings saved and applied")}catch(o){const u=o instanceof T?o:new T(0,"UNKNOWN","Unknown error");b("error",K(u.code))}finally{n.value=!1}},c=()=>{a.value={}};G(()=>(De({id:"wallets-walletconnect",isDirty:()=>Object.keys(a.value).filter(o=>o.startsWith("walletconnect.")).length>0,save:r,discard:c}),()=>Ae("wallets-walletconnect")),[]);const h=Object.keys(a.value).filter(o=>o.startsWith("walletconnect.")).length;return l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(J,{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(P,{variant:"ghost",size:"sm",onClick:c,children:"Discard"}),e(P,{variant:"primary",size:"sm",onClick:r,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(I,{label:Z("project_id"),name:"walletconnect.project_id",type:"text",value:re(t.value,a.value,"walletconnect","project_id"),onChange:o=>s("walletconnect.project_id",o),description:"WalletConnect Cloud project identifier"})}),e("div",{class:"settings-field-full",children:e(I,{label:Z("relay_url"),name:"walletconnect.relay_url",type:"text",value:re(t.value,a.value,"walletconnect","relay_url"),onChange:o=>s("walletconnect.relay_url",o),placeholder:"wss://relay.walletconnect.com",description:"WalletConnect relay server URL"})})]}),e("div",{class:"settings-info-box",children:["Get your project ID from"," ",e("a",{href:"https://cloud.walletconnect.com",target:"_blank",rel:"noopener noreferrer",children:"https://cloud.walletconnect.com"})," ","— Create a free account and project to obtain your project ID."]}),e("div",{class:"settings-info-box",children:"Relay URL defaults to wss://relay.walletconnect.com if not set."})]})]})]})}const hi=[{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 pi(){const t=d([]),a=d(!0),n=d(!1),l=d(""),i=d("solana"),s=d("testnet"),r=d("eoa"),c=d(null),h=d(!1),o=d(null),u=d(""),v=d({chain:"",environment:"",status:""}),f=async()=>{try{const w=await z(L.WALLETS);t.value=w.items}catch(w){const F=w instanceof T?w:new T(0,"UNKNOWN","Unknown error");b("error",K(F.code))}finally{a.value=!1}},N=Va(()=>{let w=t.value;const F=u.value.toLowerCase();F&&(w=w.filter(H=>H.name.toLowerCase().includes(F)||H.publicKey.toLowerCase().includes(F)));const D=v.value;return D.chain&&(w=w.filter(H=>H.chain===D.chain)),D.environment&&(w=w.filter(H=>H.environment===D.environment)),D.status&&(w=w.filter(H=>H.status===D.status)),w}),x=[{key:"name",header:"Name"},{key:"chain",header:"Chain"},{key:"environment",header:"Environment",render:w=>e(V,{variant:w.environment==="mainnet"?"warning":"info",children:w.environment})},{key:"publicKey",header:"Public Key",render:w=>e("span",{style:{display:"flex",alignItems:"center",gap:"0.25rem"},children:[Wa(w.publicKey)," ",e(Ge,{value:w.publicKey})]})},{key:"status",header:"Status",render:w=>e(V,{variant:w.status==="ACTIVE"?"success":w.status==="SUSPENDED"?"warning":"danger",children:w.status})},{key:"ownerState",header:"Owner",render:w=>e(V,{variant:Rn(w.ownerState),children:w.ownerState})},{key:"createdAt",header:"Created",render:w=>me(w.createdAt)}],W=async()=>{if(!l.value.trim()){c.value="Name is required";return}c.value=null,h.value=!0;try{const w={name:l.value.trim(),chain:i.value,environment:s.value};r.value==="smart"&&(w.accountType="smart");const F=await se(L.WALLETS,w);F.session?.token?(o.value=F.session.token,b("success","Wallet created with session")):b("success","Wallet created"),l.value="",i.value="solana",s.value="testnet",r.value="eoa",n.value=!1,a.value=!0,await f()}catch(w){const F=w instanceof T?w:new T(0,"UNKNOWN","Unknown error");c.value=K(F.code)}finally{h.value=!1}},y=w=>{window.location.hash="#/wallets/"+w.id},A=w=>{i.value=w,w==="solana"&&(r.value="eoa")};return G(()=>{f()},[]),e(J,{children:[e("div",{class:"page-actions",children:!n.value&&e(P,{onClick:()=>{n.value=!0},children:"Create Wallet"})}),n.value&&e("div",{class:"inline-form",children:[e(I,{label:"Name",name:"name",value:l.value,onChange:w=>{l.value=w},required:!0,placeholder:"e.g. trading-bot",error:c.value??void 0}),e(I,{label:"Chain",name:"chain",type:"select",value:i.value,onChange:A,options:[{label:"Solana",value:"solana"},{label:"Ethereum",value:"ethereum"}]}),i.value==="ethereum"&&e(I,{label:"Account Type",name:"accountType",type:"select",value:r.value,onChange:w=>{r.value=w},options:[{label:"EOA (Standard)",value:"eoa"},{label:"Smart Account (ERC-4337)",value:"smart"}]}),e(I,{label:"Environment",name:"environment",type:"select",value:s.value,onChange:w=>{s.value=w},options:[{label:"Testnet",value:"testnet"},{label:"Mainnet",value:"mainnet"}]}),e("div",{class:"inline-form-actions",children:[e(P,{onClick:W,loading:h.value,children:"Create"}),e(P,{variant:"secondary",onClick:()=>{n.value=!1,c.value=null},children:"Cancel"})]})]}),o.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:o.value,style:{flex:1,fontFamily:"monospace",fontSize:"0.85rem",padding:"0.5rem"},onClick:w=>w.target.select()}),e(P,{variant:"secondary",onClick:()=>{navigator.clipboard.writeText(o.value),b("success","Token copied")},children:"Copy"}),e(P,{variant:"secondary",onClick:()=>{o.value=null},children:"Dismiss"})]})]}),e(Ga,{fields:hi,values:v.value,onChange:w=>{v.value=w},syncUrl:!1}),e(xn,{value:u.value,onSearch:w=>{u.value=w},placeholder:"Search by name or public key..."}),e(Ie,{columns:x,data:N.value,loading:a.value,onRowClick:y,emptyMessage:"No wallets yet"})]})}const Ft=[{key:"wallets",label:"Wallets"},{key:"rpc",label:"RPC Endpoints"},{key:"walletconnect",label:"WalletConnect"}];function mi(){const t=d("wallets");return G(()=>{const a=ue.value;a&&a.tab&&(t.value=a.tab,setTimeout(()=>{Se.value=a.fieldName},100),ue.value=null)},[ue.value]),e("div",{class:"page",children:[e(la,{pageName:"Wallets",tabName:Ft.find(a=>a.key===t.value)?.label??"",onPageClick:()=>{t.value="wallets"}}),e(Ke,{tabs:Ft,activeTab:t.value,onTabChange:a=>{t.value=a}}),t.value==="wallets"&&e(pi,{}),t.value==="rpc"&&e(ui,{}),t.value==="walletconnect"&&e(vi,{})]})}function Kt(){const t=Pe.value,a=t.startsWith("/wallets/")?t.slice(9):null;return a?e(ri,{id:a}):e(mi,{})}const Ht=[{key:"transactions",label:"All Transactions"},{key:"monitor",label:"Monitor Settings"}],Re=20,fi=[{value:"all",label:"All"},{value:"outgoing",label:"Outgoing"},{value:"incoming",label:"Incoming"}],gi=[{value:"TRANSFER",label:"TRANSFER"},{value:"TOKEN_TRANSFER",label:"TOKEN_TRANSFER"},{value:"CONTRACT_CALL",label:"CONTRACT_CALL"},{value:"APPROVE",label:"APPROVE"},{value:"BATCH",label:"BATCH"}],yi=[{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"}],_i=[{value:"DETECTED",label:"DETECTED"},{value:"CONFIRMED",label:"CONFIRMED"}],bi=[{value:"solana",label:"Solana"},{value:"evm",label:"EVM"}],wi=[{value:"true",label:"Yes"},{value:"false",label:"No"}],Si=[{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"}],Aa=["Time","Direction","Wallet","Counterparty","Amount","Network","Status","Tx Hash"];function Ti(t){return t==="CONFIRMED"?"success":t==="FAILED"?"danger":"warning"}function Bt(t){return{id:`out-${t.id}`,direction:"outgoing",time:t.createdAt,walletId:t.walletId,walletName:t.walletName,counterparty:t.toAddress,amount:t.amount,formattedAmount:t.formattedAmount,amountUsd:t.amountUsd,network:t.network??t.chain,status:t.status,txHash:t.txHash,chain:t.chain,outgoing:t}}function Vt(t){return{id:`in-${t.id}`,direction:"incoming",time:t.detectedAt,walletId:t.walletId,walletName:t.walletName,counterparty:t.fromAddress,amount:t.amount,formattedAmount:t.formattedAmount,amountUsd:null,network:t.network,status:t.status,txHash:t.txHash,chain:t.chain,incoming:t}}function zt(){const t=d("transactions"),a=d([]),n=d(0),l=d(0),i=d(!0),s=d(null),r=d("all"),c=d({wallet_id:"",type:"",status:"",network:"",chain:"",suspicious:"",since:"",until:""}),h=d(""),o=d(0),u=d(null),v=d("USD"),f=d(1),N=d([]),x=d({}),W=d({}),y=d(!1),A=d(!0),w=d([]),F=d(!0),D=d({}),H=d(null),O=(C,M)=>{W.value={...W.value,[C]:String(M)}},k=(C,M)=>re(x.value,W.value,C,M),_=async()=>{y.value=!0;try{const C=Object.entries(W.value).filter(([le])=>le.startsWith("incoming.")).map(([le,pe])=>({key:le,value:pe}));if(C.length===0){b("info","No changes to save"),y.value=!1;return}const M=await de(L.ADMIN_SETTINGS,{settings:C});x.value=M.settings,W.value={},b("success","Settings saved and applied")}catch(C){const M=C instanceof T?C:new T(0,"UNKNOWN","Unknown error");b("error",K(M.code))}finally{y.value=!1}},m=()=>{W.value={}};G(()=>(Object.keys(W.value).filter(M=>M.startsWith("incoming.")).length>0?De({id:"transactions-monitor",isDirty:()=>Object.keys(W.value).filter(M=>M.startsWith("incoming.")).length>0,save:_,discard:m}):Ae("transactions-monitor"),()=>Ae("transactions-monitor")),[W.value]);function R(){const C=r.value,M=[{key:"wallet_id",label:"Wallet",type:"select",options:N.value}];return(C==="outgoing"||C==="all")&&M.push({key:"type",label:"Type",type:"select",options:gi}),C==="outgoing"?M.push({key:"status",label:"Status",type:"select",options:yi}):C==="incoming"&&M.push({key:"status",label:"Status",type:"select",options:_i}),M.push({key:"network",label:"Network",type:"select",options:Si}),(C==="incoming"||C==="all")&&(M.push({key:"chain",label:"Chain",type:"select",options:bi}),M.push({key:"suspicious",label:"Suspicious",type:"select",options:wi})),M.push({key:"since",label:"Since",type:"date"},{key:"until",label:"Until",type:"date"}),M}const g=async()=>{const C=new URLSearchParams,M=c.value;if(M.wallet_id&&C.set("wallet_id",M.wallet_id),M.type&&C.set("type",M.type),M.status&&r.value!=="all"&&C.set("status",M.status),M.network&&C.set("network",M.network),M.since){const le=new Date(M.since);isNaN(le.getTime())||C.set("since",String(Math.floor(le.getTime()/1e3)))}if(M.until){const le=new Date(M.until);isNaN(le.getTime())||(le.setHours(23,59,59,999),C.set("until",String(Math.floor(le.getTime()/1e3))))}return h.value&&C.set("search",h.value),C.set("offset",String(o.value*Re)),C.set("limit",String(Re)),z(`${L.ADMIN_TRANSACTIONS}?${C.toString()}`)},p=async()=>{const C=new URLSearchParams,M=c.value;return M.wallet_id&&C.set("wallet_id",M.wallet_id),M.chain&&C.set("chain",M.chain),M.status&&r.value!=="all"&&C.set("status",M.status),M.suspicious&&C.set("suspicious",M.suspicious),C.set("offset",String(o.value*Re)),C.set("limit",String(Re)),z(`${L.ADMIN_INCOMING}?${C.toString()}`)},U=async()=>{i.value=!0,s.value=null;try{const C=r.value;if(C==="outgoing"){const M=await g();a.value=M.items.map(Bt),n.value=M.total,l.value=0}else if(C==="incoming"){const M=await p();a.value=M.items.map(Vt),n.value=0,l.value=M.total}else{const[M,le]=await Promise.all([g(),p()]),pe=[...M.items.map(Bt),...le.items.map(Vt)];pe.sort((je,He)=>(He.time??0)-(je.time??0)),a.value=pe,n.value=M.total,l.value=le.total}}catch(C){C instanceof T?s.value=K(C.code):s.value="An unexpected error occurred."}finally{i.value=!1}},B=async()=>{try{const C=await z(L.WALLETS),M=Array.isArray(C)?C:C.items??[];N.value=M.map(pe=>({value:pe.id,label:pe.name||pe.id.slice(0,8)})),w.value=M;const le={};for(const pe of M)le[pe.id]=pe.monitorIncoming??!1;D.value=le}catch{}finally{F.value=!1}},E=async()=>{try{const C=await z(L.ADMIN_SETTINGS);x.value=C}catch(C){const M=C instanceof T?C:new T(0,"UNKNOWN","Unknown error");b("error",K(M.code))}finally{A.value=!1}};G(()=>{U(),B(),wt().then(({currency:C,rate:M})=>{v.value=C,f.value=M}).catch(()=>{}),E()},[]),G(()=>{U()},[c.value,h.value,o.value,r.value]),G(()=>{const C=ue.value;C&&C.tab&&(t.value=C.tab,ue.value=null,setTimeout(()=>{Se.value=C.fieldName},100))},[ue.value]);function Y(C){t.value=C}function ae(C){c.value=C,o.value=0}function ie(C){h.value=C,o.value=0}function te(C){r.value=C,o.value=0,c.value={...c.value,type:"",status:"",chain:"",suspicious:""}}function oe(C){u.value=u.value===C.id?null:C.id}function Te(){o.value>0&&(o.value=o.value-1)}function ke(){const C=n.value+l.value;(o.value+1)*Re<C&&(o.value=o.value+1)}async function Oe(C){if(window.confirm("Are you sure you want to cancel this transaction?"))try{await se(L.ADMIN_TX_CANCEL(C)),b("success","Transaction cancelled"),await U()}catch(M){const le=M instanceof T?M:new T(0,"UNKNOWN","Unknown error");b("error",K(le.code))}}async function Le(C){if(window.confirm("Are you sure you want to reject this transaction?"))try{await se(L.ADMIN_TX_REJECT(C)),b("success","Transaction rejected"),await U()}catch(M){const le=M instanceof T?M:new T(0,"UNKNOWN","Unknown error");b("error",K(le.code))}}async function Ne(C){const M=D.value[C]??!1;H.value=C;try{const le=await xl(L.WALLET_PATCH(C),{monitorIncoming:!M});D.value={...D.value,[C]:le.monitorIncoming}}catch(le){const pe=le instanceof T?le:new T(0,"UNKNOWN","Unknown error");b("error",K(pe.code))}finally{H.value=null}}function $(){const C=n.value+l.value,M=o.value*Re,le=C>0?M+1:0,pe=Math.min(M+Re,C),je=o.value>0,He=(o.value+1)*Re<C;return e(J,{children:[s.value&&e("div",{class:"dashboard-error",children:[e("span",{children:s.value}),e(P,{variant:"secondary",size:"sm",onClick:U,children:"Retry"})]}),e("div",{class:"filter-bar",style:{marginBottom:0},children:e("div",{class:"filter-field",children:[e("label",{children:"Direction"}),e("select",{value:r.value,onChange:X=>te(X.target.value),children:fi.map(X=>e("option",{value:X.value,children:X.label},X.value))})]})}),e(Ga,{fields:R(),values:c.value,onChange:ae}),r.value!=="incoming"&&e(xn,{value:h.value,onSearch:ie,placeholder:"Search by txHash or recipient address..."}),e("div",{class:"table-container",children:e("table",{children:[e("thead",{children:e("tr",{children:Aa.map(X=>e("th",{children:X},X))})}),e("tbody",{children:i.value&&a.value.length===0?e("tr",{children:e("td",{colSpan:Aa.length,class:"table-loading",children:"Loading..."})}):a.value.length===0?e("tr",{children:e("td",{colSpan:Aa.length,class:"table-empty",children:"No transactions found"})}):a.value.map(X=>e(J,{children:[e("tr",{class:`clickable${u.value===X.id?" row-expanded":""}`,style:{cursor:"pointer"},onClick:()=>oe(X),children:[e("td",{children:X.time?me(X.time):"—"}),e("td",{children:e(V,{variant:X.direction==="outgoing"?"info":"success",children:X.direction==="outgoing"?"Outgoing":"Incoming"})}),e("td",{children:X.walletName??X.walletId.slice(0,8)}),e("td",{children:X.counterparty?Wa(X.counterparty):"—"}),e("td",{children:X.amount?(()=>{const ia=X.formattedAmount??X.amount;if(X.amountUsd!=null){const Sa=aa(X.amountUsd,v.value,f.value);return Sa?`${ia} (${Sa})`:ia}return ia})():"—"}),e("td",{children:X.network}),e("td",{children:e(V,{variant:Ti(X.status),children:X.status})}),e("td",{children:e(St,{network:X.network,txHash:X.txHash})})]},X.id),u.value===X.id&&e("tr",{class:"row-expand",children:e("td",{colSpan:Aa.length,children:[X.outgoing?ne(X.outgoing):null,X.incoming?we(X.incoming):null]})},`${X.id}-expand`)]}))})]})}),e("div",{class:"pagination",children:[e("span",{class:"pagination-info",children:["Showing ",le,"-",pe," of ",C]}),e("div",{class:"pagination-buttons",children:[e(P,{variant:"secondary",size:"sm",disabled:!je,onClick:Te,children:"Previous"}),e(P,{variant:"secondary",size:"sm",disabled:!He,onClick:ke,children:"Next"})]})]})]})}function ne(C){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:C.id})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Wallet ID"}),e("span",{class:"detail-value",children:C.walletId})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Wallet Name"}),e("span",{class:"detail-value",children:C.walletName??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Type"}),e("span",{class:"detail-value",children:C.type})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Status"}),e("span",{class:"detail-value",children:C.status})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Tier"}),e("span",{class:"detail-value",children:C.tier??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"To Address"}),e("span",{class:"detail-value",children:C.toAddress??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Amount"}),e("span",{class:"detail-value",children:C.amount??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Amount USD"}),e("span",{class:"detail-value",children:C.amountUsd!=null?`$${C.amountUsd.toFixed(2)}`:"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Network"}),e("span",{class:"detail-value",children:C.network??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Chain"}),e("span",{class:"detail-value",children:C.chain})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Tx Hash"}),e("span",{class:"detail-value",children:C.txHash??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Created At"}),e("span",{class:"detail-value",children:C.createdAt?me(C.createdAt):"—"})]}),C.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(P,{variant:"danger",size:"sm",onClick:M=>{M.stopPropagation(),Oe(C.id)},children:"Cancel"}),e(P,{variant:"secondary",size:"sm",onClick:M=>{M.stopPropagation(),Le(C.id)},children:"Reject"})]})})]})}function we(C){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:C.id})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Tx Hash"}),e("span",{class:"detail-value",children:C.txHash})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Wallet ID"}),e("span",{class:"detail-value",children:C.walletId})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Wallet Name"}),e("span",{class:"detail-value",children:C.walletName??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"From Address"}),e("span",{class:"detail-value",children:C.fromAddress})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Amount"}),e("span",{class:"detail-value",children:C.amount})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Token Address"}),e("span",{class:"detail-value",children:C.tokenAddress??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Chain"}),e("span",{class:"detail-value",children:C.chain})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Network"}),e("span",{class:"detail-value",children:C.network})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Status"}),e("span",{class:"detail-value",children:C.status})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Block Number"}),e("span",{class:"detail-value",children:C.blockNumber??"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Detected At"}),e("span",{class:"detail-value",children:C.detectedAt?me(C.detectedAt):"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Confirmed At"}),e("span",{class:"detail-value",children:C.confirmedAt?me(C.confirmedAt):"—"})]}),e("div",{class:"detail-item",children:[e("span",{class:"detail-label",children:"Suspicious"}),e("span",{class:"detail-value",children:C.suspicious?"Yes":"No"})]})]})}function qa(){const C=Object.keys(W.value).filter(M=>M.startsWith("incoming.")).length;return e(J,{children:[C>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[C," unsaved change",C>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(P,{variant:"ghost",size:"sm",onClick:m,children:"Discard"}),e(P,{variant:"primary",size:"sm",onClick:_,loading:y.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:A.value?e("span",{children:"Loading settings..."}):e(J,{children:[e("div",{class:"settings-fields-grid",children:[e(I,{label:"Monitoring Enabled",name:"incoming.enabled",type:"select",value:k("incoming","enabled")||"false",onChange:M=>O("incoming.enabled",M),options:[{label:"Yes",value:"true"},{label:"No",value:"false"}]}),e(I,{label:"Poll Interval (seconds)",name:"incoming.poll_interval",type:"number",value:Number(k("incoming","poll_interval"))||30,onChange:M=>O("incoming.poll_interval",M),min:5,max:3600}),e(I,{label:"Retention Days",name:"incoming.retention_days",type:"number",value:Number(k("incoming","retention_days"))||90,onChange:M=>O("incoming.retention_days",M),min:1,max:365}),e(I,{label:"Suspicious Dust USD Threshold",name:"incoming.suspicious_dust_usd",type:"number",value:Number(k("incoming","suspicious_dust_usd"))||.01,onChange:M=>O("incoming.suspicious_dust_usd",M),min:0,max:1e3}),e(I,{label:"Suspicious Amount Multiplier",name:"incoming.suspicious_amount_multiplier",type:"number",value:Number(k("incoming","suspicious_amount_multiplier"))||10,onChange:M=>O("incoming.suspicious_amount_multiplier",M),min:1,max:1e3}),e(I,{label:"Notification Cooldown (minutes)",name:"incoming.cooldown_minutes",type:"number",value:Number(k("incoming","cooldown_minutes"))||5,onChange:M=>O("incoming.cooldown_minutes",M),min:1,max:1440}),e(I,{label:"WebSocket URL (optional)",name:"incoming.wss_url",type:"text",value:k("incoming","wss_url"),onChange:M=>O("incoming.wss_url",M),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:F.value?e("span",{children:"Loading wallets..."}):w.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:w.value.map(M=>e("tr",{children:[e("td",{children:M.name||M.id.slice(0,8)}),e("td",{children:M.chain}),e("td",{children:e(V,{variant:(M.status??"ACTIVE")==="ACTIVE"?"success":"warning",children:M.status??"ACTIVE"})}),e("td",{children:e(P,{variant:D.value[M.id]?"primary":"secondary",size:"sm",onClick:()=>Ne(M.id),loading:H.value===M.id,children:D.value[M.id]?"ON":"OFF"})})]},M.id))})]})})})]})]})}const ja=Ht.find(C=>C.key===t.value)?.label;return e("div",{class:"page",children:[e(la,{pageName:"Transactions",tabName:ja,onPageClick:()=>{t.value="transactions"}}),e(Ke,{tabs:Ht,activeTab:t.value,onTabChange:Y}),e("div",{style:{marginTop:"var(--space-4)"},children:t.value==="transactions"?$():qa()})]})}const ki=["ethereum-mainnet","ethereum-sepolia","polygon-mainnet","polygon-amoy","arbitrum-mainnet","arbitrum-sepolia","optimism-mainnet","optimism-sepolia","base-mainnet","base-sepolia"],Za=["Symbol","Name","Address","Decimals","Source","Actions"];function Ni(t){return t.length<=10?t:`${t.slice(0,6)}...${t.slice(-4)}`}function Ai(){const t=d("ethereum-mainnet"),a=d([]),n=d(!0),l=d(null),i=d(!1),s=d(""),r=d(""),c=d(""),h=d("18"),o=d(!1),u=d(!1),v=d(null),f=_a(null),N=async()=>{n.value=!0,l.value=null;try{const D=await z(`${L.TOKENS}?network=${encodeURIComponent(t.value)}`);a.value=D.tokens}catch(D){D instanceof T?l.value=K(D.code):l.value="An unexpected error occurred.",a.value=[]}finally{n.value=!1}};G(()=>{N()},[t.value]);function x(D){t.value=D.target.value}function W(){s.value="",r.value="",c.value="",h.value="18",u.value=!1,i.value=!1,f.current&&clearTimeout(f.current)}async function y(D){u.value=!0;try{const H=await z(`${L.TOKENS_RESOLVE}?network=${encodeURIComponent(t.value)}&address=${encodeURIComponent(D)}`);r.value=H.symbol,c.value=H.name,h.value=String(H.decimals),b("success",`Resolved: ${H.symbol} (${H.name})`)}catch{}finally{u.value=!1}}function A(D){const H=D.target.value;s.value=H,f.current&&clearTimeout(f.current),/^0x[a-fA-F0-9]{40}$/.test(H)&&(f.current=setTimeout(()=>y(H),500))}async function w(){if(!s.value||!r.value||!c.value){b("error","Please fill in all required fields.");return}o.value=!0;try{await se(L.TOKENS,{network:t.value,address:s.value,symbol:r.value,name:c.value,decimals:Number(h.value)}),b("success",`Token ${r.value} added successfully.`),W(),await N()}catch(D){D instanceof T?b("error",K(D.code)):b("error","Failed to add token.")}finally{o.value=!1}}async function F(D){v.value=D;try{await $e(L.TOKENS,{network:t.value,address:D}),b("success","Token removed successfully."),await N()}catch(H){H instanceof T?b("error",K(H.code)):b("error","Failed to remove token.")}finally{v.value=null}}return e("div",{class:"page",children:[l.value&&e("div",{class:"dashboard-error",children:[e("span",{children:l.value}),e(P,{variant:"secondary",size:"sm",onClick:N,children:"Retry"})]}),e("div",{class:"filter-bar",children:[e("div",{class:"filter-field",children:[e("label",{children:"Network"}),e("select",{value:t.value,onChange:x,children:ki.map(D=>e("option",{value:D,children:D},D))})]}),e("div",{style:{marginLeft:"auto"},children:e(P,{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 ",u.value&&e("span",{style:{color:"var(--warning)",fontSize:"0.85em"},children:"(resolving...)"})]}),e("input",{id:"token-address",type:"text",value:s.value,onInput:A,placeholder:"0x... (metadata auto-fetched)"})]}),e("div",{class:"form-field",children:[e("label",{for:"token-symbol",children:"Symbol"}),e("input",{id:"token-symbol",type:"text",value:r.value,onInput:D=>{r.value=D.target.value},placeholder:"e.g. USDC"})]}),e("div",{class:"form-field",children:[e("label",{for:"token-name",children:"Name"}),e("input",{id:"token-name",type:"text",value:c.value,onInput:D=>{c.value=D.target.value},placeholder:"e.g. USD Coin"})]}),e("div",{class:"form-field",children:[e("label",{for:"token-decimals",children:"Decimals"}),e("input",{id:"token-decimals",type:"number",value:h.value,onInput:D=>{h.value=D.target.value},placeholder:"18"})]})]}),e("div",{style:{marginTop:"var(--space-3)",display:"flex",gap:"var(--space-2)"},children:[e(P,{variant:"primary",size:"sm",loading:o.value,onClick:w,children:"Submit"}),e(P,{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:Za.map(D=>e("th",{children:D},D))})}),e("tbody",{children:n.value&&a.value.length===0?e("tr",{children:e("td",{colSpan:Za.length,class:"table-loading",children:"Loading..."})}):a.value.length===0?e("tr",{children:e("td",{colSpan:Za.length,class:"table-empty",children:"No tokens found for this network"})}):a.value.map(D=>e("tr",{children:[e("td",{children:D.symbol}),e("td",{children:D.name}),e("td",{title:D.address,children:Ni(D.address)}),e("td",{children:D.decimals}),e("td",{children:e(V,{variant:D.source==="builtin"?"neutral":"info",children:D.source==="builtin"?"Built-in":"Custom"})}),e("td",{children:D.source==="custom"?e(P,{variant:"danger",size:"sm",loading:v.value===D.address,onClick:()=>F(D.address),children:"Delete"}):"—"})]},D.address))})]})})]})}function We({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 Ei(t,a,n){a.value=t,n.value=!0}const Gt=[{key:"sessions",label:"Sessions"},{key:"settings",label:"Settings"}],Qa=["security.max_sessions_per_wallet","security.max_pending_tx","security.rate_limit_session_rpm","security.rate_limit_tx_rpm"];function Ci(){const t=d({}),a=d({}),n=d(!1),l=d(!0),i=async()=>{try{const o=await z(L.ADMIN_SETTINGS);t.value=o}catch(o){const u=o instanceof T?o:new T(0,"UNKNOWN","Unknown error");b("error",K(u.code))}finally{l.value=!1}};G(()=>{i()},[]);const s=(o,u)=>{const v=String(u);a.value={...a.value,[o]:v}},r=async()=>{n.value=!0;try{const o=Object.entries(a.value).filter(([v])=>Qa.includes(v)).map(([v,f])=>({key:v,value:f})),u=await de(L.ADMIN_SETTINGS,{settings:o});t.value=u.settings,a.value={},b("success","Session settings saved and applied")}catch(o){const u=o instanceof T?o:new T(0,"UNKNOWN","Unknown error");b("error",K(u.code))}finally{n.value=!1}},c=()=>{a.value={}};G(()=>(De({id:"sessions-settings",isDirty:()=>Object.keys(a.value).filter(o=>Qa.includes(o)).length>0,save:r,discard:c}),()=>Ae("sessions-settings")),[]);const h=Object.keys(a.value).filter(o=>Qa.includes(o)).length;return l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(J,{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(P,{variant:"ghost",size:"sm",onClick:c,children:"Discard"}),e(P,{variant:"primary",size:"sm",onClick:r,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(We,{legend:"Limits",description:"Session concurrency limits",children:e("div",{class:"settings-fields-grid",children:e(I,{label:Z("max_sessions_per_wallet"),name:"security.max_sessions_per_wallet",type:"number",value:Number(re(t.value,a.value,"security","max_sessions_per_wallet"))||0,onChange:o=>s("security.max_sessions_per_wallet",o),min:1,max:100,description:"Maximum concurrent sessions for a single wallet"})})}),e(We,{legend:"Rate Limits",description:"Request throttling per session and transaction",children:e("div",{class:"settings-fields-grid",children:[e(I,{label:Z("max_pending_tx"),name:"security.max_pending_tx",type:"number",value:Number(re(t.value,a.value,"security","max_pending_tx"))||0,onChange:o=>s("security.max_pending_tx",o),min:1,max:100,description:"Maximum in-flight transactions per session"}),e(I,{label:Z("rate_limit_session_rpm"),name:"security.rate_limit_session_rpm",type:"number",value:Number(re(t.value,a.value,"security","rate_limit_session_rpm"))||0,onChange:o=>s("security.rate_limit_session_rpm",o),min:10,description:"Max requests per minute per session"}),e(I,{label:Z("rate_limit_tx_rpm"),name:"security.rate_limit_tx_rpm",type:"number",value:Number(re(t.value,a.value,"security","rate_limit_tx_rpm"))||0,onChange:o=>s("security.rate_limit_tx_rpm",o),min:1,description:"Max transaction requests per minute per session"})]})})]})]})]})}function Ii(){const t=d("sessions");G(()=>{const g=ue.value;g&&g.tab&&(t.value=g.tab,setTimeout(()=>{Se.value=g.fieldName},100),ue.value=null)},[ue.value]);const a=d([]),n=d(""),l=d(""),i=d([]),s=d(!1),r=d(!0),c=d(!1),h=d(!1),o=d(""),u=d(!1),v=d(""),f=d(!1),N=d(null),x=d(!1),W=d(new Set),y=d(!1),A=d(""),w=d(""),F=d(""),D=async()=>{try{const g=await z(L.WALLETS);a.value=g.items.filter(p=>p.status==="ACTIVE")}catch(g){const p=g instanceof T?g:new T(0,"UNKNOWN","Unknown error");b("error",K(p.code))}finally{r.value=!1}},H=async()=>{s.value=!0;try{const g=n.value?`${L.SESSIONS}?walletId=${n.value}`:L.SESSIONS,p=await z(g);i.value=p}catch(g){const p=g instanceof T?g:new T(0,"UNKNOWN","Unknown error");b("error",K(p.code))}finally{s.value=!1}},O=g=>{const p=new Set(W.value);p.has(g)?p.delete(g):p.add(g),W.value=p},k=async()=>{c.value=!0;try{const g=Array.from(W.value),p=g.length===1?{walletId:g[0]}:{walletIds:g},U=Number(A.value);U>0&&(p.ttl=U*86400);const B=Number(w.value);w.value!==""&&B>=0&&(p.maxRenewals=B);const E=Number(F.value);E>0&&(p.absoluteLifetime=E*86400);const Y=await se(L.SESSIONS,p);o.value=Y.token,h.value=!0,x.value=!1,y.value=!1,A.value="",w.value="",F.value="",await H()}catch(g){const p=g instanceof T?g:new T(0,"UNKNOWN","Unknown error");b("error",K(p.code))}finally{c.value=!1}},_=async()=>{f.value=!0;try{await $e(L.SESSION(v.value)),b("success","Session revoked"),u.value=!1,await H()}catch(g){const p=g instanceof T?g:new T(0,"UNKNOWN","Unknown error");b("error",K(p.code))}finally{f.value=!1}},m=async g=>{N.value=g;try{const p=await se(L.ADMIN_SESSION_REISSUE(g),{});o.value=p.token,h.value=!0,await H()}catch(p){const U=p instanceof T?p:new T(0,"UNKNOWN","Unknown error");b("error",K(U.code))}finally{N.value=null}};G(()=>{D()},[]),G(()=>{i.value=[],H()},[n.value]);const R=[{key:"id",header:"ID",render:g=>g.id.slice(0,8)+"..."},{key:"walletName",header:"Wallet",render:g=>g.wallets&&g.wallets.length>0?e("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:g.wallets.map(p=>e("span",{children:p.name??p.id.slice(0,8)},p.id))}):g.walletName??g.walletId.slice(0,8)+"..."},{key:"source",header:"Source",render:g=>e(V,{variant:g.source==="mcp"?"info":"neutral",children:g.source==="mcp"?"MCP":"API"})},{key:"status",header:"Status",render:g=>e(V,{variant:g.status==="ACTIVE"?"success":g.status==="EXPIRED"?"warning":"danger",children:g.status})},{key:"expiresAt",header:"Expires At",render:g=>g.expiresAt===0?"Never":me(g.expiresAt)},{key:"renewals",header:"Renewals",render:g=>`${g.renewalCount}/${g.maxRenewals}`},{key:"tokenIssuedCount",header:"Tokens",render:g=>String(g.tokenIssuedCount??1)},{key:"createdAt",header:"Created",render:g=>me(g.createdAt)},{key:"actions",header:"Actions",render:g=>g.status==="ACTIVE"?e("div",{style:{display:"flex",gap:"var(--space-1)"},children:[e(P,{size:"sm",variant:"secondary",onClick:()=>m(g.id),loading:N.value===g.id,children:"Reissue"}),e(P,{size:"sm",variant:"danger",onClick:()=>Ei(g.id,v,u),children:"Revoke"})]}):null}];return e("div",{class:"page",children:[e(la,{pageName:"Sessions",tabName:Gt.find(g=>g.key===t.value)?.label??"",onPageClick:()=>{t.value="sessions"}}),e(Ke,{tabs:Gt,activeTab:t.value,onTabChange:g=>{t.value=g}}),t.value==="sessions"&&e(J,{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:g=>{n.value=g.target.value},disabled:r.value,children:[e("option",{value:"",children:"All Wallets"}),a.value.map(g=>e("option",{value:g.id,children:[g.name," (",g.chain,"/",g.network,")"]},g.id))]})]}),e("div",{class:"session-wallet-select",children:[e("label",{for:"source-select",children:"Source"}),e("select",{id:"source-select",value:l.value,onChange:g=>{l.value=g.target.value},children:[e("option",{value:"",children:"All"}),e("option",{value:"api",children:"API"}),e("option",{value:"mcp",children:"MCP"})]})]}),e(P,{onClick:()=>{W.value=new Set,x.value=!0},disabled:a.value.length===0,children:"Create Session"})]}),e(Ie,{columns:R,data:l.value?i.value.filter(g=>g.source===l.value):i.value,loading:s.value,emptyMessage:"No sessions"}),e(be,{open:h.value,title:"Session Created",onCancel:()=>{h.value=!1},cancelText:"Close",children:[e("p",{class:"token-warning",children:"Copy this token now. It will not be shown again."}),e("div",{class:"token-display",children:[e("code",{class:"token-value",children:o.value}),e(Ge,{value:o.value,label:"Copy Token"})]})]}),e(be,{open:u.value,title:"Revoke Session",onCancel:()=>{u.value=!1},onConfirm:_,confirmText:"Revoke",confirmVariant:"danger",loading:f.value,children:e("p",{children:"Are you sure you want to revoke this session? The associated token will be immediately invalidated."})}),e(be,{open:x.value,title:"Create Session",onCancel:()=>{x.value=!1},onConfirm:k,confirmText:`Create Session (${W.value.size} wallet${W.value.size!==1?"s":""})`,confirmDisabled:W.value.size===0,loading:c.value,children:[e("div",{children:[e("label",{style:{fontWeight:600,display:"block",marginBottom:"var(--space-2)"},children:"Select Wallets"}),e("div",{style:{maxHeight:"250px",overflow:"auto",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"var(--space-2)"},children:a.value.map(g=>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(g.id),onChange:()=>O(g.id)}),e("span",{children:g.name}),e("span",{style:{color:"var(--color-text-secondary)",fontSize:"0.8rem"},children:["(",g.chain,"/",g.network,")"]})]},g.id))})]}),e("div",{style:{marginTop:"var(--space-3)"},children:[e("button",{type:"button",onClick:()=>{y.value=!y.value},style:{background:"none",border:"none",color:"var(--color-primary)",cursor:"pointer",padding:0,fontSize:"0.85rem"},children:[y.value?"Hide":"Show"," Advanced Options"]}),y.value&&e("div",{style:{marginTop:"var(--space-2)",display:"grid",gap:"var(--space-2)"},children:[e(I,{label:"TTL (days)",name:"create-ttl",type:"number",value:A.value,onChange:g=>{A.value=String(g)},min:0,description:"Leave empty for unlimited session",placeholder:"Unlimited"}),e(I,{label:"Max Renewals",name:"create-max-renewals",type:"number",value:w.value,onChange:g=>{w.value=String(g)},min:0,description:"0 = unlimited renewals",placeholder:"Unlimited"}),e(I,{label:"Absolute Lifetime (days)",name:"create-lifetime",type:"number",value:F.value,onChange:g=>{F.value=String(g)},min:0,description:"Leave empty for unlimited lifetime",placeholder:"Unlimited"})]})]})]})]}),t.value==="settings"&&e(Ci,{})]})}const Di={"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"};function Oi(t){return t&&Di[t]||"Native"}const qt=["ethereum-mainnet","ethereum-sepolia","polygon-mainnet","polygon-amoy","arbitrum-mainnet","arbitrum-sepolia","optimism-mainnet","optimism-sepolia","base-mainnet","base-sepolia"];function Li({rules:t,onChange:a,errors:n,network:l}){const i=d([]),s=d(!1),r=y=>A=>{a({...t,[y]:A})},c=y=>A=>{const w=Number(A),F={...t};A===""||A===0||Number.isNaN(w)?delete F[y]:F[y]=w,a(F)},h=t.token_limits||{},o=y=>A=>{const w=String(A),D={...h.native||{instant_max:"",notify_max:"",delay_max:""},[y]:w};if(!D.instant_max&&!D.notify_max&&!D.delay_max){const H={...h};delete H.native,a({...t,token_limits:Object.keys(H).length>0?H:void 0})}else a({...t,token_limits:{...h,native:D}})},u=(y,A,w)=>{const D={...h[y]||{instant_max:"0",notify_max:"0",delay_max:"0"},[A]:w};a({...t,token_limits:{...h,[y]:D}})},v=y=>{const A={...h};delete A[y],a({...t,token_limits:Object.keys(A).length>0?A:void 0})},f=y=>{if(!y||h[y])return;const A={instant_max:"0",notify_max:"0",delay_max:"0"};a({...t,token_limits:{...h,[y]:A}})},N=()=>{const y=prompt("Enter CAIP-19 asset ID (e.g., eip155:1/erc20:0xa0b8...)");if(!y||h[y])return;const A={instant_max:"0",notify_max:"0",delay_max:"0"};a({...t,token_limits:{...h,[y]:A}})};G(()=>{if(!l){i.value=[];return}if(!qt.includes(l)){i.value=[];return}s.value=!0,z(`${L.TOKENS}?network=${l}`).then(y=>{i.value=y.tokens}).catch(()=>{i.value=[]}).finally(()=>{s.value=!1})},[l]);const x=Object.entries(h).filter(([y])=>y!=="native").map(([y,A])=>({assetId:y,symbol:i.value.find(w=>w.assetId===y)?.symbol||y.split("/").pop()?.split(":").pop()||y,instant_max:A.instant_max,notify_max:A.notify_max,delay_max:A.delay_max})),W=Oi(l);return e("div",{class:"policy-form-fields",children:[e("h4",{children:"USD Amount Tiers"}),e("div",{class:"policy-form-grid",children:[e(I,{label:"Instant Max USD",name:"instant_max_usd",type:"number",value:t.instant_max_usd??"",onChange:c("instant_max_usd"),placeholder:"Optional"}),e(I,{label:"Notify Max USD",name:"notify_max_usd",type:"number",value:t.notify_max_usd??"",onChange:c("notify_max_usd"),placeholder:"Optional"}),e(I,{label:"Delay Max USD",name:"delay_max_usd",type:"number",value:t.delay_max_usd??"",onChange:c("delay_max_usd"),placeholder:"Optional"})]}),e("h4",{children:"Token-Specific Limits"}),e("h5",{children:["Native Token (",W,")"]}),e("div",{class:"policy-form-grid",children:[e(I,{label:`Instant Max (${W})`,name:"native_instant_max",value:h.native?.instant_max??"",onChange:o("instant_max"),placeholder:"e.g. 0.5",error:n["token_limits.native.instant_max"]}),e(I,{label:`Notify Max (${W})`,name:"native_notify_max",value:h.native?.notify_max??"",onChange:o("notify_max"),placeholder:"e.g. 0.5",error:n["token_limits.native.notify_max"]}),e(I,{label:`Delay Max (${W})`,name:"native_delay_max",value:h.native?.delay_max??"",onChange:o("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"}),x.map((y,A)=>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:y.symbol}),e("span",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",flex:1,marginLeft:"0.5rem",overflow:"hidden",textOverflow:"ellipsis"},children:y.assetId}),e("button",{class:"btn btn-ghost btn-sm",onClick:()=>v(y.assetId),title:"Remove",children:"x"})]}),e("div",{class:"policy-form-grid",children:[e(I,{label:"Instant Max",name:`token-${A}-instant`,value:y.instant_max,onChange:w=>u(y.assetId,"instant_max",String(w)),placeholder:"e.g. 100",error:n[`token_limits.${y.assetId}.instant_max`]}),e(I,{label:"Notify Max",name:`token-${A}-notify`,value:y.notify_max,onChange:w=>u(y.assetId,"notify_max",String(w)),placeholder:"e.g. 500",error:n[`token_limits.${y.assetId}.notify_max`]}),e(I,{label:"Delay Max",name:`token-${A}-delay`,value:y.delay_max,onChange:w=>u(y.assetId,"delay_max",String(w)),placeholder:"e.g. 1000",error:n[`token_limits.${y.assetId}.delay_max`]})]})]},y.assetId)),l&&qt.includes(l)&&i.value.length>0&&e("div",{style:{display:"flex",gap:"0.5rem",alignItems:"flex-end",marginTop:"0.5rem"},children:e(I,{label:"Select Token",name:"add-token-select",type:"select",value:"",onChange:y=>f(y),options:[{label:s.value?"Loading...":"-- Select a token --",value:""},...i.value.filter(y=>y.assetId&&!h[y.assetId]).map(y=>({label:`${y.symbol} (${y.name})`,value:y.assetId}))]})}),e("button",{class:"btn btn-secondary btn-sm",style:{marginTop:"0.5rem"},onClick:N,children:"+ Add Token Limit (manual CAIP-19)"}),e("h4",{children:"Cumulative USD Limits (Optional)"}),e("div",{class:"policy-form-grid",children:[e(I,{label:"Daily Limit USD (24h rolling)",name:"daily_limit_usd",type:"number",value:t.daily_limit_usd??"",onChange:c("daily_limit_usd"),placeholder:"e.g. 500",error:n.daily_limit_usd}),e(I,{label:"Monthly Limit USD (30d rolling)",name:"monthly_limit_usd",type:"number",value:t.monthly_limit_usd??"",onChange:c("monthly_limit_usd"),placeholder:"e.g. 5000",error: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(I,{label:"Instant Max (lamports/wei)",name:"instant_max",value:t.instant_max||"",onChange:r("instant_max"),error:n.instant_max}),e(I,{label:"Notify Max (lamports/wei)",name:"notify_max",value:t.notify_max||"",onChange:r("notify_max"),error:n.notify_max}),e(I,{label:"Delay Max (lamports/wei)",name:"delay_max",value:t.delay_max||"",onChange:r("delay_max"),error:n.delay_max})]}),e(I,{label:"Delay Duration (seconds, min 60)",name:"delay_seconds",type:"number",value:t.delay_seconds??900,onChange:r("delay_seconds"),error:n.delay_seconds,required:!0,min:60})]})}function Fe({items:t,onAdd:a,onRemove:n,renderRow:l,onChange:i,addLabel:s="+ Add",minItems:r=0,error:c}){return e("div",{class:"dynamic-row-list",children:[t.map((h,o)=>e("div",{class:"dynamic-row",children:[e("div",{class:"dynamic-row-fields",children:l(h,o,i)}),e("button",{class:"btn btn-ghost btn-sm dynamic-row-remove",onClick:()=>n(o),disabled:t.length<=r,title:"Remove",children:"x"})]},o)),e("button",{class:"btn btn-secondary btn-sm",onClick:a,children:s}),c&&e("span",{class:"form-error",children:c})]})}function xi({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((s,r)=>r!==i)}),onChange:(i,s)=>{const r=[...l];r[i]=s,a({...t,allowed_addresses:r})},renderRow:(i,s,r)=>e(I,{label:`Address ${s+1}`,name:`address-${s}`,value:i,onChange:c=>r(s,c),placeholder:"Wallet address",error:n[`allowed_addresses.${s}`],required:!0}),addLabel:"+ Add Address",error:n.allowed_addresses})})}function Ri({rules:t,onChange:a,errors:n}){const l=i=>s=>{a({...t,[i]:s})};return e("div",{class:"policy-form-fields",children:[e(I,{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(I,{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 Pi({rules:t,onChange:a,errors:n}){const l=i=>{const s={...t};i===""||i===void 0?delete s.maxAmount:s.maxAmount=i,a(s)};return e("div",{class:"policy-form-fields",children:[e(I,{label:"Max Amount (lamports/wei, optional)",name:"maxAmount",value:t.maxAmount??"",onChange:l,error:n.maxAmount,placeholder:"Leave empty for no limit"}),e(I,{label:"Block Unlimited Approvals",name:"blockUnlimited",type:"checkbox",value:t.blockUnlimited??!0,onChange:i=>a({...t,blockUnlimited:i})})]})}const Mi=[{label:"Instant",value:"INSTANT"},{label:"Notify",value:"NOTIFY"},{label:"Delay",value:"DELAY"},{label:"Approval",value:"APPROVAL"}];function Wi({rules:t,onChange:a,errors:n}){return e("div",{class:"policy-form-fields",children:e(I,{label:"Override Tier",name:"tier",type:"select",value:t.tier??"DELAY",onChange:l=>a({...t,tier:l}),options:Mi,error:n.tier})})}const Ui=[{label:"All Chains",value:""},{label:"Solana",value:"solana"},{label:"Ethereum",value:"ethereum"}];function $i({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((s,r)=>r!==i)}),onChange:(i,s)=>{const r=[...l];r[i]=s,a({...t,tokens:r})},renderRow:(i,s,r)=>e("div",{class:"dynamic-row-fields",style:{display:"flex",gap:"0.5rem",flex:1},children:[e(I,{label:`Address ${s+1}`,name:`token-addr-${s}`,value:i.address,onChange:c=>r(s,{...i,address:c}),placeholder:"Token mint/contract address",error:n[`tokens.${s}.address`],required:!0}),e(I,{label:"Symbol",name:`token-symbol-${s}`,value:i.symbol,onChange:c=>r(s,{...i,symbol:c}),placeholder:"e.g. USDC"}),e(I,{label:"Chain",name:`token-chain-${s}`,type:"select",value:i.chain,onChange:c=>{const h={...i,chain:c};c||delete h.chain,r(s,h)},options:Ui})]}),addLabel:"+ Add Token",error:n.tokens})})}const Fi=[{label:"All Chains",value:""},{label:"Solana",value:"solana"},{label:"Ethereum",value:"ethereum"}];function Ki({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((s,r)=>r!==i)}),onChange:(i,s)=>{const r=[...l];r[i]=s,a({...t,contracts:r})},renderRow:(i,s,r)=>e("div",{class:"dynamic-row-fields",style:{display:"flex",gap:"0.5rem",flex:1},children:[e(I,{label:`Address ${s+1}`,name:`contract-addr-${s}`,value:i.address,onChange:c=>r(s,{...i,address:c}),placeholder:"Contract address",error:n[`contracts.${s}.address`],required:!0}),e(I,{label:"Name",name:`contract-name-${s}`,value:i.name,onChange:c=>r(s,{...i,name:c}),placeholder:"e.g. Uniswap Router"}),e(I,{label:"Chain",name:`contract-chain-${s}`,type:"select",value:i.chain,onChange:c=>{const h={...i,chain:c};c||delete h.chain,r(s,h)},options:Fi})]}),addLabel:"+ Add Contract",error:n.contracts})})}function Hi({rules:t,onChange:a,errors:n}){const l=t.methods||[],i=s=>{a({...t,methods:s})};return e("div",{class:"policy-form-fields",children:e(Fe,{items:l,onAdd:()=>i([...l,{contractAddress:"",selectors:[""]}]),onRemove:s=>i(l.filter((r,c)=>c!==s)),onChange:(s,r)=>{const c=[...l];c[s]=r,i(c)},renderRow:(s,r,c)=>e("div",{style:{flex:1},children:[e(I,{label:`Contract Address ${r+1}`,name:`method-addr-${r}`,value:s.contractAddress,onChange:h=>c(r,{...s,contractAddress:h}),placeholder:"Contract address",error:n[`methods.${r}.contractAddress`],required:!0}),e("div",{style:{marginTop:"0.5rem",marginLeft:"1rem"},children:[e("label",{style:{fontSize:"0.85rem",fontWeight:500},children:"Selectors"}),e(Fe,{items:s.selectors,onAdd:()=>c(r,{...s,selectors:[...s.selectors,""]}),onRemove:h=>c(r,{...s,selectors:s.selectors.filter((o,u)=>u!==h)}),onChange:(h,o)=>{const u=[...s.selectors];u[h]=o,c(r,{...s,selectors:u})},renderRow:(h,o,u)=>e(I,{label:`Selector ${o+1}`,name:`method-sel-${r}-${o}`,value:h,onChange:v=>u(o,v),placeholder:"e.g. 0xa9059cbb or transfer(address,uint256)",error:n[`methods.${r}.selectors.${o}`],required:!0}),addLabel:"+ Add Selector",error:n[`methods.${r}.selectors`]})]})]}),addLabel:"+ Add Method Entry",error:n.methods})})}function Bi({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((s,r)=>r!==i)}),onChange:(i,s)=>{const r=[...l];r[i]=s,s.maxAmount||delete r[i].maxAmount,a({...t,spenders:r})},renderRow:(i,s,r)=>e("div",{class:"dynamic-row-fields",style:{display:"flex",gap:"0.5rem",flex:1},children:[e(I,{label:`Address ${s+1}`,name:`spender-addr-${s}`,value:i.address,onChange:c=>r(s,{...i,address:c}),placeholder:"Spender address",error:n[`spenders.${s}.address`],required:!0}),e(I,{label:"Name",name:`spender-name-${s}`,value:i.name,onChange:c=>r(s,{...i,name:c}),placeholder:"e.g. Uniswap"}),e(I,{label:"Max Amount",name:`spender-max-${s}`,value:i.maxAmount||"",onChange:c=>r(s,{...i,maxAmount:c}),placeholder:"Leave empty for unlimited",error:n[`spenders.${s}.maxAmount`]})]}),addLabel:"+ Add Spender",error:n.spenders})})}const Vi=Array.from({length:24},(t,a)=>({label:`${String(a).padStart(2,"0")}:00`,value:String(a)})),zi=Array.from({length:24},(t,a)=>({label:`${String(a+1).padStart(2,"0")}:00`,value:String(a+1)})),Gi=[{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 qi({rules:t,onChange:a,errors:n}){const l=t.allowed_hours||{start:0,end:24},i=t.allowed_days||[],s=c=>h=>{const o={...l,[c]:Number(h)};a({...t,allowed_hours:o})},r=c=>{const h=i.includes(c)?i.filter(o=>o!==c):[...i,c].sort((o,u)=>o-u);a({...t,allowed_days:h})};return e("div",{class:"policy-form-fields",children:[e("h4",{children:"Allowed Hours"}),e("div",{class:"policy-form-grid",children:[e(I,{label:"Start Hour",name:"allowed_hours_start",type:"select",value:String(l.start),onChange:s("start"),options:Vi,error:n.allowed_hours}),e(I,{label:"End Hour",name:"allowed_hours_end",type:"select",value:String(l.end),onChange:s("end"),options:zi})]}),e("h4",{children:"Allowed Days"}),e("div",{style:{display:"flex",gap:"0.75rem",flexWrap:"wrap"},children:Gi.map(c=>e("label",{style:{display:"flex",alignItems:"center",gap:"0.25rem",cursor:"pointer"},children:[e("input",{type:"checkbox",checked:i.includes(c.value),onChange:()=>r(c.value)}),c.label]},c.value))}),n.allowed_days&&e("span",{class:"form-error",children:n.allowed_days})]})}const ji=[{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 Yi({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((s,r)=>r!==i)}),onChange:(i,s)=>{const r=[...l];r[i]=s,a({...t,networks:r})},renderRow:(i,s,r)=>e("div",{class:"dynamic-row-fields",style:{display:"flex",gap:"0.5rem",flex:1},children:[e(I,{label:`Network ${s+1}`,name:`network-sel-${s}`,type:"select",value:i.network,onChange:c=>r(s,{...i,network:c}),options:ji,error:n[`networks.${s}.network`],required:!0}),e(I,{label:"Label",name:`network-name-${s}`,value:i.name,onChange:c=>r(s,{...i,name:c}),placeholder:"Optional label"})]}),addLabel:"+ Add Network",error:n.networks})})}function Xi({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((s,r)=>r!==i)}),onChange:(i,s)=>{const r=[...l];r[i]=s,a({...t,domains:r})},renderRow:(i,s,r)=>e(I,{label:`Domain ${s+1}`,name:`domain-${s}`,value:i,onChange:c=>r(s,c),placeholder:"e.g. api.example.com or *.service.io",error:n[`domains.${s}`],required:!0}),addLabel:"+ Add Domain",error:n.domains})})}const jt=[{label:"Instant",value:"INSTANT"},{label:"Notify",value:"NOTIFY"},{label:"Delay",value:"DELAY"},{label:"Approval",value:"APPROVAL"}];function Ji({rules:t,onChange:a,errors:n}){return e("div",{class:"policy-form-fields",children:[e(I,{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(I,{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:jt,error:n.below_threshold_tier,description:"Security tier when counterparty score is below minimum"}),e(I,{label:"Unrated Agent Tier",name:"unrated_tier",type:"select",value:t.unrated_tier??"APPROVAL",onChange:l=>a({...t,unrated_tier:l}),options:jt,error:n.unrated_tier,description:"Security tier when counterparty has no reputation data"}),e(I,{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(I,{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(I,{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 Yt({type:t,rules:a,onChange:n,errors:l,network:i}){switch(t){case"SPENDING_LIMIT":return e(Li,{rules:a,onChange:n,errors:l,network:i});case"WHITELIST":return e(xi,{rules:a,onChange:n,errors:l});case"RATE_LIMIT":return e(Ri,{rules:a,onChange:n,errors:l});case"APPROVE_AMOUNT_LIMIT":return e(Pi,{rules:a,onChange:n,errors:l});case"APPROVE_TIER_OVERRIDE":return e(Wi,{rules:a,onChange:n,errors:l});case"ALLOWED_TOKENS":return e($i,{rules:a,onChange:n,errors:l});case"CONTRACT_WHITELIST":return e(Ki,{rules:a,onChange:n,errors:l});case"METHOD_WHITELIST":return e(Hi,{rules:a,onChange:n,errors:l});case"APPROVED_SPENDERS":return e(Bi,{rules:a,onChange:n,errors:l});case"TIME_RESTRICTION":return e(qi,{rules:a,onChange:n,errors:l});case"ALLOWED_NETWORKS":return e(Yi,{rules:a,onChange:n,errors:l});case"X402_ALLOWED_DOMAINS":return e(Xi,{rules:a,onChange:n,errors:l});case"REPUTATION_THRESHOLD":return e(Ji,{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 ht(t){const a=typeof t=="string"?Number(t):t;return Number.isNaN(a)?String(t):a.toLocaleString("en-US")}function Zi(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 et=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Qi(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?`${et[a[0]]}-${et[a[a.length-1]]}`:a.map(l=>et[l]??String(l)).join(", ")}function Xt(t){return String(t).padStart(2,"0")}function es({rules:t}){const a=Number(t.instant_max??0),n=Number(t.notify_max??0),l=Number(t.delay_max??0),i=Math.max(a,n,l,1),s=[{label:"Instant",value:t.instant_max,width:a/i*100,cls:"instant"},{label:"Notify",value:t.notify_max,width:n/i*100,cls:"notify"},{label:"Delay",value:t.delay_max,width:l/i*100,cls:"delay"},{label:"Approval",value:"",width:100,cls:"approval"}];return e("div",{class:"tier-bars",children:s.map(r=>e("div",{class:"tier-bar",children:[e("span",{class:"tier-bar-label",children:r.label}),e("div",{class:"tier-bar-track",children:e("div",{class:`tier-bar-fill tier-bar-fill--${r.cls}`,style:{width:`${r.width}%`}})}),e("span",{class:"tier-bar-value",children:r.value?ht(r.value):""})]},r.cls))})}function Jt(t){return t.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:2})}function as({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:["$",Jt(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:["$",Jt(n)]})]})]})}const ts={INSTANT:"success",NOTIFY:"info",DELAY:"warning",APPROVAL:"danger"};function ns({type:t,rules:a}){switch(t){case"SPENDING_LIMIT":return e("div",{class:"spending-limit-summary",children:[e(es,{rules:a}),e(as,{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(V,{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 / ",Zi(l)]})}case"WHITELIST":{const n=a.allowed_addresses||[];return e(V,{variant:"neutral",children:[n.length," addresses"]})}case"TIME_RESTRICTION":{const n=a.allowed_days||[],l=a.allowed_hours,i=Qi(n),s=l?`${Xt(l.start)}:00-${Xt(l.end)}:00`:"";return e("span",{class:"rules-vis-text",children:[i," ",s]})}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((s,r)=>e(V,{variant:"neutral",children:s.name||(s.address?s.address.slice(0,8)+"...":"?")},r)),i>0&&e(V,{variant:"neutral",children:["+",i," more"]})]})}case"METHOD_WHITELIST":{const n=a.methods||[],l=n.length,i=n.reduce((s,r)=>s+(r.selectors?.length||0),0);return e(V,{variant:"neutral",children:[l," contracts, ",i," methods"]})}case"APPROVED_SPENDERS":{const n=a.spenders||[];return e(V,{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: ",ht(n)," + Block unlimited"]}):n?e("span",{class:"rules-vis-text",children:["Max: ",ht(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=ts[n]||"neutral";return e(V,{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((s,r)=>e(V,{variant:"info",children:s.network},r)),i>0&&e(V,{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((s,r)=>e(V,{variant:"neutral",children:s},r)),i>0&&e(V,{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 Pn=[{label:"Spending Limit",value:"SPENDING_LIMIT"},{label:"Whitelist",value:"WHITELIST"},{label:"Time Restriction",value:"TIME_RESTRICTION"},{label:"Rate Limit",value:"RATE_LIMIT"},{label:"Allowed Tokens",value:"ALLOWED_TOKENS"},{label:"Contract Whitelist",value:"CONTRACT_WHITELIST"},{label:"Method Whitelist",value:"METHOD_WHITELIST"},{label:"Approved Spenders",value:"APPROVED_SPENDERS"},{label:"Approve Amount Limit",value:"APPROVE_AMOUNT_LIMIT"},{label:"Approve Tier Override",value:"APPROVE_TIER_OVERRIDE"},{label:"Allowed Networks",value:"ALLOWED_NETWORKS"},{label:"x402 Allowed Domains",value:"X402_ALLOWED_DOMAINS"},{label:"Reputation Threshold",value:"REPUTATION_THRESHOLD"}],at={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.",REPUTATION_THRESHOLD:"Adjust security tier based on counterparty agent on-chain reputation score (ERC-8004)."},ca={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:[]},REPUTATION_THRESHOLD:{min_score:50,below_threshold_tier:"APPROVAL",unrated_tier:"APPROVAL",check_counterparty:!1}};function Ea(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),s=a.token_limits,r=s&&Object.keys(s).length>0;if(!l&&!i&&!r&&(n.__form="At least one of USD limits, token limits, or raw limits required"),s){const u=/^\d+(\.\d+)?$/;for(const[v,f]of Object.entries(s)){const N=f;if(!N||typeof N!="object")continue;N.instant_max&&!u.test(N.instant_max)&&(n[`token_limits.${v}.instant_max`]="Must be a non-negative decimal"),N.notify_max&&!u.test(N.notify_max)&&(n[`token_limits.${v}.notify_max`]="Must be a non-negative decimal"),N.delay_max&&!u.test(N.delay_max)&&(n[`token_limits.${v}.delay_max`]="Must be a non-negative decimal");const x=parseFloat(N.instant_max||"0"),W=parseFloat(N.notify_max||"0"),y=parseFloat(N.delay_max||"0");x>W&&(n[`token_limits.${v}.instant_max`]="Must be <= Notify Max"),W>y&&(n[`token_limits.${v}.notify_max`]="Must be <= Delay Max")}}const c=Number(a.delay_seconds);(a.delay_seconds===void 0||a.delay_seconds===""||Number.isNaN(c)||c<60)&&(n.delay_seconds="Minimum 60 seconds");const h=a.daily_limit_usd;if(h!==void 0&&h!==""){const u=Number(h);(Number.isNaN(u)||u<=0)&&(n.daily_limit_usd="Must be a positive number")}const o=a.monthly_limit_usd;if(o!==void 0&&o!==""){const u=Number(o);(Number.isNaN(u)||u<=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,s)=>{(!i||i.trim()==="")&&(n[`allowed_addresses.${s}`]="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,s)=>{(!i.address||i.address.trim()==="")&&(n[`tokens.${s}.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,s)=>{(!i.address||i.address.trim()==="")&&(n[`contracts.${s}.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,s)=>{(!i.contractAddress||i.contractAddress.trim()==="")&&(n[`methods.${s}.contractAddress`]="Contract address required"),!i.selectors||i.selectors.length===0?n[`methods.${s}.selectors`]="At least one selector required":i.selectors.forEach((r,c)=>{(!r||r.trim()==="")&&(n[`methods.${s}.selectors.${c}`]="Selector required")})})}else if(t==="APPROVED_SPENDERS"){const l=a.spenders||[];l.length===0&&(n.spenders="At least one spender required"),l.forEach((i,s)=>{(!i.address||i.address.trim()==="")&&(n[`spenders.${s}.address`]="Address required"),i.maxAmount&&!/^\d+$/.test(i.maxAmount)&&(n[`spenders.${s}.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,s)=>{(!i.network||i.network.trim()==="")&&(n[`networks.${s}.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,s)=>{(!i||i.trim()==="")&&(n[`domains.${s}`]="Domain required")})}return n}function ls(t,a){if(!t)return"Global";const n=a.find(l=>l.id===t);return n?n.name:t.slice(0,8)+"..."}function tt(t){const a=Pn.find(n=>n.value===t);return a?a.label:t}const Zt=[{key:"policies",label:"Policies"},{key:"defaults",label:"Defaults"}],nt=["security.policy_defaults_delay_seconds","security.policy_defaults_approval_timeout","policy.default_deny_tokens","policy.default_deny_contracts","policy.default_deny_spenders","policy.default_deny_x402_domains"];function is(){const t=d({}),a=d({}),n=d(!1),l=d(!0),i=async()=>{try{const o=await z(L.ADMIN_SETTINGS);t.value=o}catch(o){const u=o instanceof T?o:new T(0,"UNKNOWN","Unknown error");b("error",K(u.code))}finally{l.value=!1}};G(()=>{i()},[]);const s=(o,u)=>{const v=String(u);a.value={...a.value,[o]:v}},r=async()=>{n.value=!0;try{const o=Object.entries(a.value).filter(([v])=>nt.includes(v)).map(([v,f])=>({key:v,value:f})),u=await de(L.ADMIN_SETTINGS,{settings:o});t.value=u.settings,a.value={},b("success","Policy defaults saved and applied")}catch(o){const u=o instanceof T?o:new T(0,"UNKNOWN","Unknown error");b("error",K(u.code))}finally{n.value=!1}},c=()=>{a.value={}};G(()=>(De({id:"policies-defaults",isDirty:()=>Object.keys(a.value).filter(o=>nt.includes(o)).length>0,save:r,discard:c}),()=>Ae("policies-defaults")),[]);const h=Object.keys(a.value).filter(o=>nt.includes(o)).length;return l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(J,{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(P,{variant:"ghost",size:"sm",onClick:c,children:"Discard"}),e(P,{variant:"primary",size:"sm",onClick:r,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(I,{label:Z("policy_defaults_delay_seconds"),name:"security.policy_defaults_delay_seconds",type:"number",value:Number(re(t.value,a.value,"security","policy_defaults_delay_seconds"))||0,onChange:o=>s("security.policy_defaults_delay_seconds",o),min:0,description:"Default delay before executing delayed-tier transactions"}),e(I,{label:Z("policy_defaults_approval_timeout"),name:"security.policy_defaults_approval_timeout",type:"number",value:Number(re(t.value,a.value,"security","policy_defaults_approval_timeout"))||0,onChange:o=>s("security.policy_defaults_approval_timeout",o),min:60,description:"How long to wait for owner approval before timeout"})]}),e("div",{class:"settings-subgroup",style:{marginTop:"1rem",borderTop:"1px solid var(--border)",paddingTop:"1rem"},children:[e("h4",{style:{margin:"0 0 0.5rem 0",fontSize:"0.875rem",fontWeight:600,color:"var(--text-secondary)"},children:"Default Deny Policies"}),e("div",{class:"settings-fields-grid",children:[e(I,{label:Z("default_deny_tokens"),name:"policy.default_deny_tokens",type:"checkbox",value:Ve(t.value,a.value,"policy","default_deny_tokens"),onChange:o=>s("policy.default_deny_tokens",o),description:"Deny token transfers unless a matching whitelist policy exists"}),e(I,{label:Z("default_deny_contracts"),name:"policy.default_deny_contracts",type:"checkbox",value:Ve(t.value,a.value,"policy","default_deny_contracts"),onChange:o=>s("policy.default_deny_contracts",o),description:"Deny contract calls unless a matching whitelist policy exists"}),e(I,{label:Z("default_deny_spenders"),name:"policy.default_deny_spenders",type:"checkbox",value:Ve(t.value,a.value,"policy","default_deny_spenders"),onChange:o=>s("policy.default_deny_spenders",o),description:"Deny token approvals unless a matching whitelist policy exists"}),e(I,{label:Z("default_deny_x402_domains"),name:"policy.default_deny_x402_domains",type:"checkbox",value:Ve(t.value,a.value,"policy","default_deny_x402_domains"),onChange:o=>s("policy.default_deny_x402_domains",o),description:"Deny x402 payments unless a matching domain whitelist policy exists"})]})]}),e("div",{class:"settings-info-box",children:"When enabled, transactions are denied if no matching whitelist policy exists. Disable to allow all transactions of that type when no policy is configured."})]})]})]})}function ss(){const t=d("policies");G(()=>{const $=ue.value;$&&$.tab&&(t.value=$.tab,setTimeout(()=>{Se.value=$.fieldName},100),ue.value=null)},[ue.value]);const a=d([]),n=d([]),l=d("__all__"),i=d(!1),s=d(!0),r=d(!1),c=d("SPENDING_LIMIT"),h=d(""),o=d(JSON.stringify(ca.SPENDING_LIMIT,null,2)),u=d(ca.SPENDING_LIMIT),v=d({}),f=d(!1),N=d(0),x=d(!0),W=d(""),y=d(null),A=d(!1),w=d(!1),F=d(null),D=d(""),H=d({}),O=d(!1),k=d({}),_=d(0),m=d(!0),R=d(null),g=d(!1),p=d(!1),U=d(null),B=d(!1),E=async()=>{try{const $=await z(L.WALLETS);a.value=$.items}catch($){const ne=$ instanceof T?$:new T(0,"UNKNOWN","Unknown error");b("error",K(ne.code))}finally{s.value=!1}},Y=async()=>{i.value=!0;try{let $=L.POLICIES;l.value!=="__all__"&&l.value!=="__global__"&&($=`${L.POLICIES}?walletId=${l.value}`);const ne=await z($);l.value==="__global__"?n.value=ne.filter(we=>we.walletId===null):n.value=ne}catch($){const ne=$ instanceof T?$:new T(0,"UNKNOWN","Unknown error");b("error",K(ne.code))}finally{i.value=!1}},ae=async()=>{y.value=null;let $;if(f.value)try{$=JSON.parse(o.value)}catch{y.value="Invalid JSON in rules field";return}else{const ne=Ea(c.value,u.value);if(Object.keys(ne).length>0){v.value=ne;return}v.value={},$=u.value}A.value=!0;try{await se(L.POLICIES,{walletId:h.value||void 0,type:c.value,rules:$,priority:N.value,enabled:x.value,network:W.value||void 0}),b("success","Policy created"),r.value=!1,c.value="SPENDING_LIMIT",h.value="",W.value="",o.value=JSON.stringify(ca.SPENDING_LIMIT,null,2),u.value=ca.SPENDING_LIMIT,v.value={},f.value=!1,N.value=0,x.value=!0,y.value=null,await Y()}catch(ne){const we=ne instanceof T?ne:new T(0,"UNKNOWN","Unknown error");b("error",K(we.code))}finally{A.value=!1}},ie=$=>{F.value=$,D.value=JSON.stringify($.rules,null,2),H.value={...$.rules},O.value=!1,k.value={},_.value=$.priority,m.value=$.enabled,R.value=null,w.value=!0},te=async()=>{R.value=null;let $;if(O.value)try{$=JSON.parse(D.value)}catch{R.value="Invalid JSON in rules field";return}else{const ne=Ea(F.value.type,H.value);if(Object.keys(ne).length>0){k.value=ne;return}k.value={},$=H.value}g.value=!0;try{await de(L.POLICY(F.value.id),{rules:$,priority:_.value,enabled:m.value}),b("success","Policy updated"),w.value=!1,await Y()}catch(ne){const we=ne instanceof T?ne:new T(0,"UNKNOWN","Unknown error");b("error",K(we.code))}finally{g.value=!1}},oe=()=>{if(!O.value)D.value=JSON.stringify(H.value,null,2);else try{H.value=JSON.parse(D.value),R.value=null}catch{R.value="Invalid JSON — cannot switch to form mode";return}O.value=!O.value},Te=$=>{U.value=$,p.value=!0},ke=async()=>{B.value=!0;try{await $e(L.POLICY(U.value.id)),b("success","Policy deleted"),p.value=!1,await Y()}catch($){const ne=$ instanceof T?$:new T(0,"UNKNOWN","Unknown error");b("error",K(ne.code))}finally{B.value=!1}},Oe=$=>{const ne=$;c.value=ne;const we=ca[ne];we&&(o.value=JSON.stringify(we,null,2),u.value={...we}),v.value={},f.value=!1},Le=()=>{if(!f.value)o.value=JSON.stringify(u.value,null,2);else try{u.value=JSON.parse(o.value),y.value=null}catch{y.value="Invalid JSON — cannot switch to form mode";return}f.value=!f.value};G(()=>{E()},[]),G(()=>{Y()},[l.value]);const Ne=[{key:"type",header:"Type",render:$=>e(V,{variant:$.type==="SPENDING_LIMIT"?"success":"info",children:tt($.type)})},{key:"walletId",header:"Wallet",render:$=>ls($.walletId,a.value)},{key:"network",header:"Network",render:$=>$.network??"All"},{key:"rules",header:"Rules",render:$=>e(ns,{type:$.type,rules:$.rules})},{key:"priority",header:"Priority"},{key:"enabled",header:"Enabled",render:$=>e(V,{variant:$.enabled?"success":"danger",children:$.enabled?"ON":"OFF"})},{key:"actions",header:"Actions",render:$=>e("span",{style:{display:"flex",gap:"0.25rem"},children:[e("button",{class:"btn btn-ghost btn-sm",onClick:ne=>{ne.stopPropagation(),ie($)},children:"Edit"}),e(P,{size:"sm",variant:"danger",onClick:()=>Te($),children:"Delete"})]})}];return e("div",{class:"page",children:[e(la,{pageName:"Policies",tabName:Zt.find($=>$.key===t.value)?.label??"",onPageClick:()=>{t.value="policies"}}),e(Ke,{tabs:Zt,activeTab:t.value,onTabChange:$=>{t.value=$}}),t.value==="policies"&&e(J,{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:$=>{l.value=$.target.value},disabled:s.value,children:[e("option",{value:"__all__",children:"All Policies"}),e("option",{value:"__global__",children:"Global Only"}),a.value.map($=>e("option",{value:$.id,children:[$.name," (",$.chain,"/",$.network,")"]},$.id))]})]}),!r.value&&e(P,{onClick:()=>{r.value=!0},children:"Create Policy"})]}),r.value&&e("div",{class:"inline-form",children:[e(I,{label:"Type",name:"type",type:"select",value:c.value,onChange:Oe,options:Pn,description:at[c.value]??""}),e(I,{label:"Wallet",name:"walletId",type:"select",value:h.value,onChange:$=>{h.value=$},options:[{label:"Global (no wallet)",value:""},...a.value.map($=>({label:`${$.name} (${$.chain}/${$.network})`,value:$.id}))]}),e(I,{label:"Network Scope",name:"network",value:W.value,onChange:$=>{W.value=$},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:Le,children:f.value?"Switch to Form":"JSON Direct Edit"})]}),f.value?e(I,{label:"",name:"rules",type:"textarea",value:o.value,onChange:$=>{o.value=$},error:y.value??void 0}):e(Yt,{type:c.value,rules:u.value,onChange:$=>{u.value=$,Object.keys(v.value).length>0&&(v.value=Ea(c.value,$))},errors:v.value,network:W.value})]}),e(I,{label:"Priority",name:"priority",type:"number",value:N.value,onChange:$=>{N.value=$},min:0,max:999}),e(I,{label:"Enabled",name:"enabled",type:"checkbox",value:x.value,onChange:$=>{x.value=$}}),e("div",{class:"inline-form-actions",children:[e(P,{onClick:ae,loading:A.value,children:"Create"}),e(P,{variant:"secondary",onClick:()=>{r.value=!1,y.value=null},children:"Cancel"})]})]}),e(Ie,{columns:Ne,data:n.value,loading:i.value,emptyMessage:"No policies found"}),e(be,{open:w.value,title:"Edit Policy",onCancel:()=>{w.value=!1},onConfirm:te,confirmText:"Save",loading:g.value,children:F.value&&e("div",{children:[e("div",{class:"policy-type-readonly",children:["Type: ",tt(F.value.type),at[F.value.type]&&e("span",{class:"form-description",children:at[F.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:oe,children:O.value?"Switch to Form":"JSON Direct Edit"})]}),O.value?e("div",{class:"edit-rules-textarea",children:e(I,{label:"",name:"edit-rules",type:"textarea",value:D.value,onChange:$=>{D.value=$},error:R.value??void 0})}):e(Yt,{type:F.value.type,rules:H.value,onChange:$=>{H.value=$,Object.keys(k.value).length>0&&(k.value=Ea(F.value.type,$))},errors:k.value,network:F.value.network??""})]}),e(I,{label:"Priority",name:"edit-priority",type:"number",value:_.value,onChange:$=>{_.value=$},min:0,max:999}),e(I,{label:"Enabled",name:"edit-enabled",type:"checkbox",value:m.value,onChange:$=>{m.value=$}})]})}),e(be,{open:p.value,title:"Delete Policy",onCancel:()=>{p.value=!1},onConfirm:ke,confirmText:"Delete",confirmVariant:"danger",loading:B.value,children:U.value&&e("p",{children:["Are you sure you want to delete this"," ",e("strong",{children:tt(U.value.type)})," policy? This action cannot be undone."]})})]}),t.value==="defaults"&&e(is,{})]})}function rs(){return e(os,{})}function os(){const t=d([]),a=d(!0),n=d(!1),l=d(null),i=d("ADMIN"),s=d(!1),r=d(!1),c=d(null),h=d(!1),o=async()=>{a.value=!0;try{const y=await z(L.ADMIN_TELEGRAM_USERS);t.value=y.users}catch(y){const A=y instanceof T?y:new T(0,"UNKNOWN","Unknown error");b("error",K(A.code))}finally{a.value=!1}};G(()=>{o()},[]);const u=y=>{l.value=y,i.value="ADMIN",n.value=!0},v=async()=>{if(l.value){s.value=!0;try{await de(L.ADMIN_TELEGRAM_USER(l.value.chat_id),{role:i.value}),b("success",`User approved as ${i.value}`),n.value=!1,l.value=null,await o()}catch(y){const A=y instanceof T?y:new T(0,"UNKNOWN","Unknown error");b("error",K(A.code))}finally{s.value=!1}}},f=y=>{c.value=y,r.value=!0},N=async()=>{if(c.value){h.value=!0;try{await $e(L.ADMIN_TELEGRAM_USER(c.value.chat_id)),b("success","User deleted"),r.value=!1,c.value=null,await o()}catch(y){const A=y instanceof T?y:new T(0,"UNKNOWN","Unknown error");b("error",K(A.code))}finally{h.value=!1}}},x=y=>y==="PENDING"?"warning":y==="ADMIN"?"success":"info";return e("div",{class:"page",children:[e(Ie,{columns:[{key:"chat_id",header:"Chat ID",render:y=>String(y.chat_id)},{key:"username",header:"Username",render:y=>y.username??"-"},{key:"role",header:"Role",render:y=>e(V,{variant:x(y.role),children:y.role})},{key:"registered_at",header:"Registered",render:y=>me(y.registered_at)},{key:"approved_at",header:"Approved",render:y=>y.approved_at?me(y.approved_at):"-"},{key:"actions",header:"Actions",render:y=>e("div",{style:{display:"flex",gap:"var(--space-1)"},children:[y.role==="PENDING"&&e(P,{size:"sm",variant:"primary",onClick:()=>u(y),children:"Approve"}),e(P,{size:"sm",variant:"danger",onClick:()=>f(y),children:"Delete"})]})}],data:t.value,loading:a.value,emptyMessage:"No Telegram users registered. Users appear here after sending /start to the bot."}),e(be,{open:n.value,title:"Approve Telegram User",onCancel:()=>{n.value=!1,l.value=null},onConfirm:v,confirmText:"Approve",confirmVariant:"primary",loading:s.value,children:l.value&&e("div",{children:[e("p",{children:[e("strong",{children:"Chat ID:"})," ",l.value.chat_id,l.value.username&&e("span",{children:[" (",e("strong",{children:["@",l.value.username]}),")"]})]}),e("div",{class:"form-field",style:{marginTop:"var(--space-3)"},children:[e("label",{for:"approve-role",children:"Role"}),e("select",{id:"approve-role",value:i.value,onChange:y=>{i.value=y.target.value},children:[e("option",{value:"ADMIN",children:"ADMIN"}),e("option",{value:"READONLY",children:"READONLY"})]})]})]})}),e(be,{open:r.value,title:"Delete Telegram User",onCancel:()=>{r.value=!1,c.value=null},onConfirm:N,confirmText:"Delete",confirmVariant:"danger",loading:h.value,children:e("p",{children:"Are you sure you want to remove this user? They will need to /start again to re-register."})})]})}const lt=20,Qt=[{key:"channels",label:"Channels & Logs"},{key:"telegram",label:"Telegram Users"},{key:"settings",label:"Settings"},{key:"balance",label:"Balance Monitor"}],cs=[{key:"eventType",label:"Event Type",type:"select",options:[{value:"tx.submitted",label:"tx.submitted"},{value:"tx.confirmed",label:"tx.confirmed"},{value:"tx.failed",label:"tx.failed"},{value:"policy.violation",label:"policy.violation"},{value:"security.kill_switch",label:"security.kill_switch"},{value:"security.auto_stop",label:"security.auto_stop"},{value:"security.suspicious_tx",label:"security.suspicious_tx"},{value:"session.created",label:"session.created"},{value:"session.expired",label:"session.expired"},{value:"owner.registered",label:"owner.registered"},{value:"owner.verified",label:"owner.verified"},{value:"incoming.detected",label:"incoming.detected"},{value:"incoming.suspicious",label:"incoming.suspicious"}]},{key:"channel",label:"Channel",type:"select",options:[{value:"telegram",label:"Telegram"},{value:"discord",label:"Discord"},{value:"ntfy",label:"ntfy"},{value:"slack",label:"Slack"},{value:"wallet_app",label:"Wallet App"}]},{key:"status",label:"Status",type:"select",options:[{value:"sent",label:"Sent"},{value:"failed",label:"Failed"}]},{key:"since",label:"Since",type:"date"},{key:"until",label:"Until",type:"date"}];function ds(){const t=d({}),a=d({}),n=d(!1),l=d(!0),i=d([]),s=d(!1),r=async()=>{try{const f=await z(L.ADMIN_SETTINGS);t.value=f}catch(f){const N=f instanceof T?f:new T(0,"UNKNOWN","Unknown error");b("error",K(N.code))}finally{l.value=!1}};G(()=>{r()},[]);const c=(f,N)=>{const x=String(N);a.value={...a.value,[f]:x}},h=async()=>{n.value=!0;try{const f=Object.entries(a.value).filter(([x])=>x.startsWith("notifications.")||x.startsWith("telegram.")).map(([x,W])=>({key:x,value:W})),N=await de(L.ADMIN_SETTINGS,{settings:f});t.value=N.settings,a.value={},b("success","Notification settings saved and applied")}catch(f){const N=f instanceof T?f:new T(0,"UNKNOWN","Unknown error");b("error",K(N.code))}finally{n.value=!1}},o=()=>{a.value={}};G(()=>(De({id:"notifications-settings",isDirty:()=>Object.keys(a.value).filter(f=>f.startsWith("notifications.")||f.startsWith("telegram.")).length>0,save:h,discard:o}),()=>Ae("notifications-settings")),[]);const u=async()=>{s.value=!0,i.value=[];try{const f=await se(L.ADMIN_NOTIFICATIONS_TEST,{});if(i.value=f.results,f.results.length===0)b("info","No notification channels configured");else{const N=f.results.every(x=>x.success);b(N?"success":"warning",N?"All test notifications sent":"Some channels failed")}}catch(f){const N=f instanceof T?f:new T(0,"UNKNOWN","Unknown error");b("error",K(N.code))}finally{s.value=!1}},v=Object.keys(a.value).filter(f=>f.startsWith("notifications.")||f.startsWith("telegram.")).length;return l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(J,{children:[v>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[v," unsaved change",v>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(P,{variant:"ghost",size:"sm",onClick:o,children:"Discard"}),e(P,{variant:"primary",size:"sm",onClick:h,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(I,{label:"Enabled",name:"notifications.enabled",type:"checkbox",value:Ve(t.value,a.value,"notifications","enabled"),onChange:f=>c("notifications.enabled",f),description:"Enable or disable notifications globally"})}),e(I,{label:Z("locale"),name:"notifications.locale",type:"select",value:re(t.value,a.value,"notifications","locale")||"en",onChange:f=>c("notifications.locale",f),options:[{label:"English",value:"en"},{label:"Korean",value:"ko"}],description:"Language for notification messages"})]}),e(We,{legend:"Telegram",description:"Telegram notification channel and bot configuration",children:[e("div",{class:"settings-info-box",style:{marginBottom:"0.75rem"},children:["Get your bot token from"," ",e("a",{href:"https://t.me/BotFather",target:"_blank",rel:"noopener noreferrer",children:"@BotFather"})," ","— send /newbot and follow the instructions. To get your Chat ID, send a message to your bot then visit"," ",e("a",{href:"https://api.telegram.org",target:"_blank",rel:"noopener noreferrer",children:"Telegram Bot API"}),"."]}),e("div",{class:"settings-fields-grid",children:[e(I,{label:Z("telegram_bot_token"),name:"notifications.telegram_bot_token",type:"password",value:re(t.value,a.value,"notifications","telegram_bot_token"),onChange:f=>c("notifications.telegram_bot_token",f),placeholder:ua(t.value,a.value,"notifications","telegram_bot_token")?"(configured)":"",description:"Bot token for Telegram notifications"}),e(I,{label:Z("telegram_chat_id"),name:"notifications.telegram_chat_id",type:"text",value:re(t.value,a.value,"notifications","telegram_chat_id"),onChange:f=>c("notifications.telegram_chat_id",f),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(I,{label:Z("bot_token"),name:"telegram.bot_token",type:"password",value:re(t.value,a.value,"telegram","bot_token"),onChange:f=>c("telegram.bot_token",f),placeholder:ua(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(I,{label:"Locale",name:"telegram.locale",type:"select",value:re(t.value,a.value,"telegram","locale")||"en",onChange:f=>c("telegram.locale",f),options:[{label:"English",value:"en"},{label:"한국어",value:"ko"}],description:"Language for Telegram bot messages"})]})]})]}),e(We,{legend:"ntfy",description:"Push notification channel for Human Wallet Apps (signing requests and activity alerts)",children:[e("div",{class:"settings-info-box",style:{marginBottom:"0.75rem"},children:["ntfy is the push notification infrastructure used by Human Wallet Apps for signing requests and activity alerts. Per-wallet ntfy topics (sign topic, notify topic) are managed in"," ",e("a",{href:"#/wallet-apps",children:"Human Wallet Apps"}),". The server URL below is shared across all wallet apps."]}),e("div",{class:"settings-fields-grid",children:e(I,{label:Z("ntfy_server"),name:"notifications.ntfy_server",type:"text",value:re(t.value,a.value,"notifications","ntfy_server"),onChange:f=>c("notifications.ntfy_server",f),description:"Server URL for ntfy push notifications"})})]}),e(We,{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(I,{label:Z("discord_webhook_url"),name:"notifications.discord_webhook_url",type:"password",value:re(t.value,a.value,"notifications","discord_webhook_url"),onChange:f=>c("notifications.discord_webhook_url",f),placeholder:ua(t.value,a.value,"notifications","discord_webhook_url")?"(configured)":"",description:"Webhook URL for Discord notifications"}),e(I,{label:"Slack Webhook URL",name:"notifications.slack_webhook_url",type:"password",value:re(t.value,a.value,"notifications","slack_webhook_url"),onChange:f=>c("notifications.slack_webhook_url",f),placeholder:ua(t.value,a.value,"notifications","slack_webhook_url")?"(configured)":"",description:"Webhook URL for Slack notifications"}),e(I,{label:Z("rate_limit_rpm"),name:"notifications.rate_limit_rpm",type:"number",value:Number(re(t.value,a.value,"notifications","rate_limit_rpm"))||20,onChange:f=>c("notifications.rate_limit_rpm",f),min:1,max:1e3,description:"Max notifications per minute"})]})]}),e(We,{legend:"Event Filter",description:"Choose which notification events are delivered. All checked = receive all.",children:[(()=>{const f=new Set(["KILL_SWITCH_ACTIVATED","KILL_SWITCH_RECOVERED","AUTO_STOP_TRIGGERED","TX_INCOMING_SUSPICIOUS"]),N=[{category:"transaction",label:"Transaction Events",events:[{event:"TX_REQUESTED",desc:"Transaction request received"},{event:"TX_QUEUED",desc:"Waiting in time-delay queue"},{event:"TX_SUBMITTED",desc:"Submitted to blockchain"},{event:"TX_CONFIRMED",desc:"Confirmed on-chain"},{event:"TX_FAILED",desc:"Transaction failed"},{event:"TX_CANCELLED",desc:"Cancelled by user or policy"},{event:"TX_DOWNGRADED_DELAY",desc:"Auto-approved demoted to time-delay"},{event:"TX_APPROVAL_REQUIRED",desc:"Owner approval required"},{event:"TX_APPROVAL_EXPIRED",desc:"Approval wait timed out"},{event:"TX_INCOMING",desc:"Incoming transaction detected"}]},{category:"policy",label:"Policy",events:[{event:"POLICY_VIOLATION",desc:"Blocked by policy rule"},{event:"CUMULATIVE_LIMIT_WARNING",desc:"Cumulative spend limit warning"}]},{category:"security_alert",label:"Security Alerts",events:[{event:"WALLET_SUSPENDED",desc:"Wallet suspended"},{event:"KILL_SWITCH_ACTIVATED",desc:"Emergency lock activated"},{event:"KILL_SWITCH_RECOVERED",desc:"Emergency lock released"},{event:"KILL_SWITCH_ESCALATED",desc:"Kill switch escalated"},{event:"AUTO_STOP_TRIGGERED",desc:"Auto-stop triggered"},{event:"TX_INCOMING_SUSPICIOUS",desc:"Suspicious incoming transaction"}]},{category:"session",label:"Session Events",events:[{event:"SESSION_EXPIRING_SOON",desc:"Session expiring soon"},{event:"SESSION_EXPIRED",desc:"Session expired"},{event:"SESSION_CREATED",desc:"Session created"},{event:"SESSION_WALLET_ADDED",desc:"Wallet added to session"},{event:"SESSION_WALLET_REMOVED",desc:"Wallet removed from session"}]},{category:"owner",label:"Owner Events",events:[{event:"OWNER_SET",desc:"Owner address registered"},{event:"OWNER_REMOVED",desc:"Owner address removed"},{event:"OWNER_VERIFIED",desc:"Owner address verified"}]},{category:"system",label:"System Notifications",events:[{event:"DAILY_SUMMARY",desc:"Daily summary report"},{event:"LOW_BALANCE",desc:"Low balance warning"},{event:"APPROVAL_CHANNEL_SWITCHED",desc:"Approval channel changed"},{event:"UPDATE_AVAILABLE",desc:"Daemon update available"}]}],x=N.flatMap(D=>D.events.map(H=>H.event)).filter(D=>!f.has(D)),W=re(t.value,a.value,"notifications","notify_events")||"[]";let y=[];try{const D=JSON.parse(W);Array.isArray(D)&&(y=D)}catch{}const A=y.length===0?x:y,w=(D,H)=>{const O=H?[...A,D]:A.filter(_=>_!==D),k=O.length===x.length&&x.every(_=>O.includes(_))?[]:O;c("notifications.notify_events",JSON.stringify(k))},F=(D,H)=>{const O=D.events.filter(m=>!f.has(m.event)).map(m=>m.event);let k;if(H)k=[...new Set([...A,...O])];else{const m=new Set(O);k=A.filter(R=>!m.has(R))}const _=k.length===x.length&&x.every(m=>k.includes(m))?[]:k;c("notifications.notify_events",JSON.stringify(_))};return e("div",{class:"event-filter-groups",children:N.map(D=>{const H=D.events.filter(_=>!f.has(_.event)),O=H.every(_=>A.includes(_.event)),k=H.some(_=>A.includes(_.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:D.label}),e("label",{class:"event-filter-group-all",onClick:_=>_.stopPropagation(),children:[e("input",{type:"checkbox",checked:O,ref:_=>{_&&(_.indeterminate=k&&!O)},onChange:_=>F(D,_.target.checked)})," All"]})]}),e("div",{class:"event-filter-events",children:D.events.map(_=>{const m=f.has(_.event);return e("label",{class:`event-filter-event ${m?"event-broadcast":""}`,children:[e("input",{type:"checkbox",checked:m||A.includes(_.event),disabled:m,onChange:R=>w(_.event,R.target.checked)}),e("code",{children:_.event}),e("span",{class:"event-desc",children:_.desc}),m&&e("span",{class:"event-broadcast-badge",children:"Always sent"})]},_.event)})})]},D.category)})})})(),e("div",{class:"settings-info-box",style:{marginTop:"0.5rem"},children:"Applies to all notification channels (Telegram, Discord, ntfy, Slack) and wallet app side channel. Broadcast events (Kill Switch, Auto Stop, Suspicious TX) always bypass the filter."})]}),e("div",{class:"notif-test-section",children:[e(P,{variant:"secondary",size:"sm",onClick:u,loading:s.value,children:"Test Notification"}),i.value.length>0&&e("div",{class:"test-results",children:i.value.map(f=>e("div",{class:`test-result-item ${f.success?"test-result-success":"test-result-failure"}`,children:[e(V,{variant:f.success?"success":"danger",children:f.success?"OK":"FAIL"}),e("span",{children:f.channel}),f.error&&e("span",{style:"font-size: var(--font-size-xs); color: var(--color-danger);",children:[" - ",f.error]})]},f.channel))})]})]})]})]})}const en={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 us(){const t=d({}),a=d({}),n=d(!1),l=d(!0),i=async()=>{try{const u=await z(L.ADMIN_SETTINGS);t.value=u}catch(u){const v=u instanceof T?u:new T(0,"UNKNOWN","Unknown error");b("error",K(v.code))}finally{l.value=!1}};G(()=>{i()},[]);const s=(u,v)=>{const f=String(v);a.value={...a.value,[u]:f}},r=async()=>{n.value=!0;try{const u=Object.entries(a.value).filter(([f])=>f.startsWith("monitoring.")).map(([f,N])=>({key:f,value:N})),v=await de(L.ADMIN_SETTINGS,{settings:u});t.value=v.settings,a.value={},b("success","Settings saved and applied")}catch(u){const v=u instanceof T?u:new T(0,"UNKNOWN","Unknown error");b("error",K(v.code))}finally{n.value=!1}},c=()=>{a.value={}};G(()=>(De({id:"notifications-balance",isDirty:()=>Object.keys(a.value).filter(u=>u.startsWith("monitoring.")).length>0,save:r,discard:c}),()=>Ae("notifications-balance")),[]);const h=[{key:"enabled",type:"checkbox"},{key:"check_interval_sec",type:"number",min:60,max:86400},{key:"low_balance_threshold_sol",type:"number",min:0},{key:"low_balance_threshold_eth",type:"number",min:0},{key:"cooldown_hours",type:"number",min:1,max:168}],o=Object.keys(a.value).filter(u=>u.startsWith("monitoring.")).length;return l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(J,{children:[o>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[o," unsaved change",o>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(P,{variant:"ghost",size:"sm",onClick:c,children:"Discard"}),e(P,{variant:"primary",size:"sm",onClick:r,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:h.map(u=>u.type==="checkbox"?e("div",{class:"settings-field-full",children:e(I,{label:Z(u.key),name:`monitoring.${u.key}`,type:"checkbox",value:Ve(t.value,a.value,"monitoring",u.key),onChange:v=>s(`monitoring.${u.key}`,v),description:en[u.key]})},u.key):e(I,{label:Z(u.key),name:`monitoring.${u.key}`,type:"number",value:Number(re(t.value,a.value,"monitoring",u.key))||0,onChange:v=>s(`monitoring.${u.key}`,v),min:u.min,max:u.max,description:en[u.key]},u.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 an(){const t=d("channels");G(()=>{const k=ue.value;k&&k.tab&&(t.value=k.tab,setTimeout(()=>{Se.value=k.fieldName},100),ue.value=null)},[ue.value]);const a=d(null),n=d(!0),l=d(!1),i=d(null),s=d(null),r=d(null),c=d(!0),h=d(1),o=d(null),u=d({eventType:"",channel:"",status:"",since:"",until:""}),v=async()=>{try{const k=await z(L.ADMIN_NOTIFICATIONS_STATUS);a.value=k}catch(k){const _=k instanceof T?k:new T(0,"UNKNOWN","Unknown error");b("error",K(_.code))}finally{n.value=!1}},f=async k=>{c.value=!0;try{const _=new URLSearchParams;_.set("page",String(k)),_.set("pageSize",String(lt));const m=u.value;if(m.eventType&&_.set("eventType",m.eventType),m.channel&&_.set("channel",m.channel),m.status&&_.set("status",m.status),m.since){const g=new Date(m.since);isNaN(g.getTime())||_.set("since",String(Math.floor(g.getTime()/1e3)))}if(m.until){const g=new Date(m.until);isNaN(g.getTime())||(g.setHours(23,59,59,999),_.set("until",String(Math.floor(g.getTime()/1e3))))}const R=await z(`${L.ADMIN_NOTIFICATIONS_LOG}?${_.toString()}`);r.value=R}catch(_){const m=_ instanceof T?_:new T(0,"UNKNOWN","Unknown error");b("error",K(m.code))}finally{c.value=!1}},N=async()=>{l.value=!0,s.value=null;try{const _=(await se(L.ADMIN_NOTIFICATIONS_TEST,{})).results;s.value=_,_.every(R=>R.success)?b("success","Test sent successfully"):b("warning","Some channels failed")}catch(k){const _=k instanceof T?k:new T(0,"UNKNOWN","Unknown error");b("error",K(_.code))}finally{l.value=!1}},x=async k=>{i.value=k,s.value=null;try{const m=(await se(L.ADMIN_NOTIFICATIONS_TEST,{channel:k})).results;s.value=m,m.every(g=>g.success)?b("success",`Test sent to ${k}`):b("warning",`${k} test failed`)}catch(_){const m=_ instanceof T?_:new T(0,"UNKNOWN","Unknown error");b("error",K(m.code))}finally{i.value=null}},W=()=>{h.value>1&&(h.value-=1,f(h.value))},y=()=>{const k=r.value?Math.ceil(r.value.total/lt):1;h.value<k&&(h.value+=1,f(h.value))},A=k=>{o.value=o.value?.id===k.id?null:k},w=k=>{u.value=k,h.value=1,f(1)};G(()=>{v(),f(1);const k=setInterval(()=>f(h.value),3e4);return()=>clearInterval(k)},[]);const F=n.value&&!a.value,D=a.value?.channels.some(k=>k.enabled)??!1,H=r.value?Math.max(1,Math.ceil(r.value.total/lt)):1,O=[{key:"eventType",header:"Event Type"},{key:"walletId",header:"Wallet ID",render:k=>k.walletId?e("a",{href:`#/wallets/${k.walletId}`,class:"wallet-link",onClick:_=>_.stopPropagation(),title:k.walletId,children:[k.walletId.slice(0,8),"..."]}):"—"},{key:"channel",header:"Channel",render:k=>e("span",{style:{textTransform:"capitalize"},children:k.channel})},{key:"status",header:"Status",render:k=>e(V,{variant:k.status==="sent"?"success":"danger",children:k.status})},{key:"createdAt",header:"Time",render:k=>me(k.createdAt)}];return e("div",{class:"page",children:[e(la,{pageName:"Notifications",tabName:Qt.find(k=>k.key===t.value)?.label??"",onPageClick:()=>{t.value="channels"}}),e(Ke,{tabs:Qt,activeTab:t.value,onTabChange:k=>{t.value=k}}),t.value==="telegram"?e(rs,{}):t.value==="settings"?e(ds,{}):t.value==="balance"?e(us,{}):e(J,{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:k=>{k.preventDefault(),t.value="settings"},children:"Enable them in the Settings tab"})]}),F?e("div",{class:"channel-grid",children:[1,2,3].map(k=>e("div",{class:"channel-card",children:e("div",{class:"stat-skeleton"})},k))}):e("div",{class:"channel-grid",children:a.value?.channels.map(k=>e("div",{class:"channel-card",children:e("div",{class:"channel-card-header",children:[e("span",{class:"channel-card-name",children:k.name}),e("div",{class:"channel-card-actions",children:[e(V,{variant:k.enabled?"success":"neutral",children:k.enabled?k.configuredWallets!=null?`${k.configuredWallets} wallet${k.configuredWallets!==1?"s":""} configured`:"Connected":"Not Configured"}),k.enabled&&e(P,{variant:"secondary",size:"sm",onClick:()=>x(k.name),loading:i.value===k.name,children:"Test"})]})]})},k.name))}),e("div",{style:{marginTop:"var(--space-4)",marginBottom:"var(--space-6)"},children:[e(P,{onClick:N,loading:l.value,disabled:!D,children:"Test All Channels"}),s.value&&e("div",{class:"test-results",children:s.value.map(k=>e("div",{class:"test-result-item",children:[e("span",{class:k.success?"test-result-success":"test-result-failure",children:k.success?"✓":"✗"}),e("span",{style:{textTransform:"capitalize"},children:k.channel}),!k.success&&k.error&&e("span",{class:"test-result-failure",children:[" - ",k.error]})]},k.channel))})]}),e("h2",{children:"Delivery Log"}),e(Ga,{fields:cs,values:u.value,onChange:w,syncUrl:!1}),e(Ie,{columns:O,data:r.value?.logs??[],loading:c.value,emptyMessage:"No notification logs",onRowClick:A}),o.value&&e("div",{class:"log-message-detail",children:[e("div",{class:"log-message-detail-header",children:[e("strong",{children:o.value.eventType})," via ",e("span",{style:{textTransform:"capitalize"},children:o.value.channel}),e(P,{variant:"ghost",size:"sm",onClick:()=>{o.value=null},children:"Close"})]}),e("div",{class:"log-message-detail-body",children:o.value.message?e("pre",{style:{whiteSpace:"pre-wrap",margin:0,fontSize:"var(--font-size-sm)"},children:o.value.message}):e("span",{class:"text-muted",children:"(No message recorded)"})})]}),e("div",{class:"pagination",children:[e("span",{class:"pagination-info",children:["Page ",h.value," of ",H,r.value?` (${r.value.total} total)`:""]}),e("div",{class:"pagination-buttons",children:[e(P,{variant:"secondary",size:"sm",onClick:W,disabled:h.value<=1,children:"Previous"}),e(P,{variant:"secondary",size:"sm",onClick:y,disabled:h.value>=H,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 it=[{key:"killswitch",label:"Kill Switch"},{key:"autostop",label:"AutoStop Rules"},{key:"jwt",label:"Invalidate Sessions"},{key:"password",label:"Master Password"}];function vs(){const t=d(null),a=d(!0),n=d(!1),l=async()=>{try{const v=await z(L.ADMIN_KILL_SWITCH);t.value=v}catch(v){const f=v instanceof T?v:new T(0,"UNKNOWN","Unknown error");b("error",K(f.code))}finally{a.value=!1}};G(()=>{l()},[]);const i=async()=>{n.value=!0;try{await se(L.ADMIN_KILL_SWITCH),b("success","Kill switch activated - all operations suspended"),await l()}catch(v){const f=v instanceof T?v:new T(0,"UNKNOWN","Unknown error");b("error",K(f.code))}finally{n.value=!1}},s=async()=>{n.value=!0;try{await se(L.ADMIN_KILL_SWITCH_ESCALATE),b("success","Kill switch escalated to LOCKED"),await l()}catch(v){const f=v instanceof T?v:new T(0,"UNKNOWN","Unknown error");b("error",K(f.code))}finally{n.value=!1}},r=async()=>{n.value=!0;try{await se(L.ADMIN_RECOVER),b("success","Kill switch recovered - operations resumed"),await l()}catch(v){const f=v instanceof T?v:new T(0,"UNKNOWN","Unknown error");b("error",K(f.code))}finally{n.value=!1}},c=t.value,h=c?.state==="ACTIVE",o=c?.state==="SUSPENDED",u=c?.state==="LOCKED";return e("div",{class:"settings-category",children:[e("div",{class:"settings-category-header",children:[e("h3",{children:"Kill Switch"}),e("p",{class:"settings-description",children:"Emergency stop - suspends all wallet operations immediately. 3-state: ACTIVE (normal) → SUSPENDED (paused) → LOCKED (permanent)."})]}),e("div",{class:"settings-category-body",children:a.value?e("span",{children:"Loading..."}):c?e(J,{children:[e("div",{class:"ks-state-card",style:{marginBottom:"var(--space-4)"},children:[e(V,{variant:h?"success":u?"danger":"warning",children:c.state}),!h&&c.activatedAt&&e("span",{class:"ks-state-info",children:["Since ",me(c.activatedAt),c.activatedBy?` by ${c.activatedBy}`:""]})]}),e("div",{style:{display:"flex",gap:"var(--space-2)",flexWrap:"wrap"},children:[h&&e(P,{variant:"danger",onClick:i,loading:n.value,children:"Activate Kill Switch"}),o&&e(J,{children:[e(P,{variant:"primary",onClick:r,loading:n.value,children:"Recover"}),e(P,{variant:"danger",onClick:s,loading:n.value,children:"Escalate to LOCKED"})]}),u&&e(P,{variant:"primary",onClick:r,loading:n.value,children:"Recover from LOCKED (5s wait)"})]}),o&&e("div",{class:"settings-info-box",style:{marginTop:"var(--space-3)"},children:"All wallet operations are suspended. Sessions revoked, transactions cancelled. You can Recover to resume operations, or Escalate to LOCKED for permanent lockdown."}),u&&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 hs(){const t=d({}),a=d({}),n=d(!1),l=d(!0),i=async()=>{try{const o=await z(L.ADMIN_SETTINGS);t.value=o}catch(o){const u=o instanceof T?o:new T(0,"UNKNOWN","Unknown error");b("error",K(u.code))}finally{l.value=!1}};G(()=>{i()},[]);const s=(o,u)=>{const v=String(u);a.value={...a.value,[o]:v}},r=async()=>{n.value=!0;try{const o=Object.entries(a.value).filter(([v])=>v.startsWith("autostop.")).map(([v,f])=>({key:v,value:f})),u=await de(L.ADMIN_SETTINGS,{settings:o});t.value=u.settings,a.value={},b("success","AutoStop settings saved and applied")}catch(o){const u=o instanceof T?o:new T(0,"UNKNOWN","Unknown error");b("error",K(u.code))}finally{n.value=!1}},c=()=>{a.value={}};G(()=>(De({id:"security-autostop",isDirty:()=>Object.keys(a.value).filter(o=>o.startsWith("autostop.")).length>0,save:r,discard:c}),()=>Ae("security-autostop")),[]);const h=Object.keys(a.value).filter(o=>o.startsWith("autostop.")).length;return l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(J,{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(P,{variant:"ghost",size:"sm",onClick:c,children:"Discard"}),e(P,{variant:"primary",size:"sm",onClick:r,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(I,{label:Z("enabled"),name:"autostop.enabled",type:"checkbox",value:Ve(t.value,a.value,"autostop","enabled"),onChange:o=>s("autostop.enabled",o),description:"Enable or disable AutoStop protection rules"})}),e(We,{legend:"Activity Detection",description:"Detects failures and unusual transaction patterns",children:e("div",{class:"settings-fields-grid",children:[e(I,{label:Z("consecutive_failures_threshold"),name:"autostop.consecutive_failures_threshold",type:"number",value:Number(re(t.value,a.value,"autostop","consecutive_failures_threshold"))||0,onChange:o=>s("autostop.consecutive_failures_threshold",o),min:1,max:100,description:"Suspend wallet after this many consecutive failed transactions"}),e(I,{label:Z("unusual_activity_threshold"),name:"autostop.unusual_activity_threshold",type:"number",value:Number(re(t.value,a.value,"autostop","unusual_activity_threshold"))||0,onChange:o=>s("autostop.unusual_activity_threshold",o),min:5,max:1e3,description:"Max transactions within window before triggering unusual activity alert"}),e(I,{label:Z("unusual_activity_window_sec"),name:"autostop.unusual_activity_window_sec",type:"number",value:Number(re(t.value,a.value,"autostop","unusual_activity_window_sec"))||0,onChange:o=>s("autostop.unusual_activity_window_sec",o),min:60,max:86400,description:"Time window for unusual activity detection"})]})}),e(We,{legend:"Idle Detection",description:"Monitors inactivity and revokes idle sessions",children:e("div",{class:"settings-fields-grid",children:[e(I,{label:Z("idle_timeout_sec"),name:"autostop.idle_timeout_sec",type:"number",value:Number(re(t.value,a.value,"autostop","idle_timeout_sec"))||0,onChange:o=>s("autostop.idle_timeout_sec",o),min:60,max:604800,description:"Revoke sessions with no activity for this duration"}),e(I,{label:Z("idle_check_interval_sec"),name:"autostop.idle_check_interval_sec",type:"number",value:Number(re(t.value,a.value,"autostop","idle_check_interval_sec"))||0,onChange:o=>s("autostop.idle_check_interval_sec",o),min:10,max:3600,description:"How often to check for idle sessions"})]})}),e("div",{class:"settings-info-box",children:[e("strong",{children:"Consecutive Failures:"})," Suspends wallet after N consecutive failed transactions.",e("br",{}),e("strong",{children:"Unusual Activity:"})," Suspends wallet if transaction count exceeds threshold within the time window.",e("br",{}),e("strong",{children:"Idle Timeout:"})," Revokes sessions with no activity for the configured duration."]})]})]})]})}function ps(){const t=d(!1),a=d(!1),n=async()=>{a.value=!0;try{await se(L.ADMIN_ROTATE_SECRET),t.value=!1,b("success","All session tokens invalidated. Old tokens remain valid for 5 minutes.")}catch(l){const i=l instanceof T?l:new T(0,"UNKNOWN","Unknown error");b("error",K(i.code))}finally{a.value=!1}};return e(J,{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(P,{variant:"secondary",onClick:()=>{t.value=!0},children:"Invalidate All Tokens"})})]}),e(be,{open:t.value,title:"Invalidate All Session Tokens",onCancel:()=>{t.value=!1},onConfirm: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 ms(){const t=d(""),a=d(""),n=d(""),l=d(!1),i=d(null),s=()=>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),r=async()=>{if(s()){l.value=!0;try{await de(L.ADMIN_MASTER_PASSWORD,{newPassword:a.value}),b("success","Master password changed. Please log in again."),t.value="",a.value="",n.value="",setTimeout(()=>za(),500)}catch(c){const h=c instanceof T?c:new T(0,"UNKNOWN","Unknown error");b("error",K(h.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(I,{label:"Current Password",name:"current-password",type:"password",value:t.value,onChange:c=>{t.value=String(c)}}),e(I,{label:"New Password",name:"new-password",type:"password",value:a.value,onChange:c=>{a.value=String(c)},description:"Minimum 8 characters"}),e(I,{label:"Confirm New Password",name:"confirm-password",type:"password",value:n.value,onChange:c=>{n.value=String(c)}}),e("div",{children:e(P,{variant:"primary",onClick:r,loading:l.value,disabled:!t.value||!a.value||!n.value,children:"Change Password"})})]})]})]})}function fs(){const t=(()=>{const l=location.hash,i=l.indexOf("?");if(i>=0){const r=new URLSearchParams(l.slice(i+1)).get("tab");if(r&&it.some(c=>c.key===r))return r}return"killswitch"})(),a=d(t);G(()=>{const l=ue.value;l&&l.tab&&(a.value=l.tab,setTimeout(()=>{Se.value=l.fieldName},100),ue.value=null)},[ue.value]);const n=it.find(l=>l.key===a.value)?.label??"";return e("div",{class:"page",children:[e(la,{pageName:"Security",tabName:n,onPageClick:()=>{a.value="killswitch"}}),e(Ke,{tabs:it,activeTab:a.value,onTabChange:l=>{a.value=l}}),a.value==="killswitch"&&e(vs,{}),a.value==="autostop"&&e(hs,{}),a.value==="jwt"&&e(ps,{}),a.value==="password"&&e(ms,{})]})}const Ca=[{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 gs({value:t,onChange:a,name:n}){const l=d(""),i=d(!1),s=d(null),r=d(!1),c=_a(null),h=Va(()=>{const u=l.value.toLowerCase();return u?Ca.filter(v=>v.code.toLowerCase().includes(u)||v.name.toLowerCase().includes(u)||v.symbol.includes(u)):Ca});G(()=>{if(t==="USD"){s.value="1 USD = $1.00";return}r.value=!0,z(`${L.ADMIN_FOREX_RATES}?currencies=${t}`).then(u=>{const v=u.rates[t];s.value=v?.preview??null}).catch(()=>{s.value=null}).finally(()=>{r.value=!1})},[t]),G(()=>{const u=v=>{c.current&&!c.current.contains(v.target)&&(i.value=!1,l.value="")};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[]);const o=Ca.find(u=>u.code===t)??Ca[0];return e("div",{class:"currency-select",ref:c,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:[o.code," - ",o.name," (",o.symbol,")"]}),e("span",{class:"currency-select-chevron",children:i.value?"▲":"▼"})]}),s.value&&e("div",{class:"currency-rate-preview",children:r.value?"...":s.value}),i.value&&e("div",{class:"currency-select-dropdown",children:[e("input",{type:"text",class:"currency-select-search",placeholder:"Search currency...",value:l.value,onInput:u=>{l.value=u.target.value},autoFocus:!0}),e("div",{class:"currency-select-list",children:[h.value.map(u=>e("button",{type:"button",class:`currency-select-option ${u.code===t?"currency-select-option--active":""}`,onClick:()=>{a(u.code),i.value=!1,l.value=""},children:[e("span",{class:"currency-option-code",children:u.code}),e("span",{class:"currency-option-name",children:u.name}),e("span",{class:"currency-option-symbol",children:u.symbol})]},u.code)),h.value.length===0&&e("div",{class:"currency-select-empty",children:"No currencies found"})]})]})]})}const ys=["display.","daemon.","oracle.","gas_condition.","smart_account."],_s=new Set(["security.rate_limit_global_ip_rpm"]);function st(t){return ys.some(a=>t.startsWith(a))||_s.has(t)}function bs(){const t=d({}),a=d({}),n=d(!1),l=d(!0),i=d([]),s=d(!0);d(null),d(""),d(!1);const r=d(!1),c=d(!1),h=d(""),o=d(!1),u=async()=>{try{const m=await z(L.ADMIN_SETTINGS);t.value=m}catch(m){const R=m instanceof T?m:new T(0,"UNKNOWN","Unknown error");b("error",K(R.code))}finally{l.value=!1}},v=async()=>{try{const m=await z(L.ADMIN_API_KEYS);i.value=m.keys}catch{}finally{s.value=!1}};G(()=>{u(),v()},[]),G(()=>{const m=ue.value;m&&(setTimeout(()=>{Se.value=m.fieldName},100),ue.value=null)},[ue.value]);const f=(m,R)=>re(t.value,a.value,m,R),N=(m,R)=>ua(t.value,a.value,m,R),x=(m,R)=>{const g=String(R);a.value={...a.value,[m]:g}},W=async()=>{n.value=!0;try{const m=Object.entries(a.value).filter(([g])=>st(g)).map(([g,p])=>({key:g,value:p})),R=await de(L.ADMIN_SETTINGS,{settings:m});t.value=R.settings,a.value={},b("success","Settings saved and applied")}catch(m){const R=m instanceof T?m:new T(0,"UNKNOWN","Unknown error");b("error",K(R.code))}finally{n.value=!1}},y=()=>{a.value={}};G(()=>(De({id:"system-settings",isDirty:()=>Object.keys(a.value).filter(m=>st(m)).length>0,save:W,discard:y}),()=>Ae("system-settings")),[]);const A=async()=>{c.value=!0;try{await se(L.ADMIN_SHUTDOWN),r.value=!1,h.value="",b("info","Shutdown initiated"),o.value=!0}catch(m){const R=m instanceof T?m:new T(0,"UNKNOWN","Unknown error");b("error",K(R.code))}finally{c.value=!1}},w=Object.keys(a.value).filter(m=>st(m)).length;function F(){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(I,{label:"Cross Validation Threshold (%)",name:"oracle.cross_validation_threshold",type:"number",value:Number(f("oracle","cross_validation_threshold"))||5,onChange:m=>x("oracle.cross_validation_threshold",m),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(I,{label:"CoinGecko API Key",name:"oracle.coingecko_api_key",type:"password",value:N("oracle","coingecko_api_key")?"••••••••":"",onChange:m=>x("oracle.coingecko_api_key",m),placeholder:"Enter CoinGecko Pro API key (optional)",description:"Pro API key for higher rate limits. Free tier: ~30 req/min."})}),e("div",{class:"settings-info-box",children:["Maximum allowed deviation between price sources before flagging a discrepancy. Default is 5%. CoinGecko Pro API key increases rate limits for reliable price data. Get your API key from"," ",e("a",{href:"https://www.coingecko.com/en/api",target:"_blank",rel:"noopener noreferrer",children:"CoinGecko API Dashboard"}),"."]})]})]})}function D(){const m=Se.value==="display.currency";return G(()=>{if(m){const R=document.querySelector('[name="display.currency"]');R&&R.closest(".form-field")?.scrollIntoView({behavior:"smooth",block:"center"});const g=setTimeout(()=>{Se.value=""},2500);return()=>clearTimeout(g)}},[m]),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${m?" form-field--highlight":""}`,children:[e("label",{children:Z("currency")}),e(gs,{name:"display.currency",value:f("display","currency")||"USD",onChange:R=>x("display.currency",R)})]})}),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 H(){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(I,{label:Z("rate_limit_global_ip_rpm"),name:"security.rate_limit_global_ip_rpm",type:"number",value:Number(f("security","rate_limit_global_ip_rpm"))||0,onChange:m=>x("security.rate_limit_global_ip_rpm",m),min:10,description:"Maximum API requests per minute from a single IP address"})})})]})}function O(){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(I,{label:Z("log_level"),name:"daemon.log_level",type:"select",value:f("daemon","log_level")||"info",onChange:m=>x("daemon.log_level",m),options:[{label:"debug",value:"debug"},{label:"info",value:"info"},{label:"warn",value:"warn"},{label:"error",value:"error"}],description:"Daemon logging verbosity level"})})})]})}function k(){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(I,{label:"Gas Condition Enabled",name:"gas_condition.enabled",type:"select",value:f("gas_condition","enabled")||"true",onChange:m=>x("gas_condition.enabled",m),options:[{label:"Yes",value:"true"},{label:"No",value:"false"}],description:"Enable gas conditional execution for agents"}),e(I,{label:Z("poll_interval_sec"),name:"gas_condition.poll_interval_sec",type:"number",value:Number(f("gas_condition","poll_interval_sec"))||30,onChange:m=>x("gas_condition.poll_interval_sec",m),min:10,max:300,description:"How often to check gas prices (seconds)"}),e(I,{label:Z("default_timeout_sec"),name:"gas_condition.default_timeout_sec",type:"number",value:Number(f("gas_condition","default_timeout_sec"))||3600,onChange:m=>x("gas_condition.default_timeout_sec",m),min:60,max:86400,description:"Default wait timeout when not specified in request (seconds)"}),e(I,{label:Z("max_timeout_sec"),name:"gas_condition.max_timeout_sec",type:"number",value:Number(f("gas_condition","max_timeout_sec"))||86400,onChange:m=>x("gas_condition.max_timeout_sec",m),min:60,max:86400,description:"Maximum allowed timeout for gas conditions (seconds)"}),e(I,{label:Z("max_pending_count"),name:"gas_condition.max_pending_count",type:"number",value:Number(f("gas_condition","max_pending_count"))||100,onChange:m=>x("gas_condition.max_pending_count",m),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 _(){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:"Configure ERC-4337 smart account infrastructure. Requires an external Bundler service (e.g., Pimlico, Stackup, Alchemy)."})]}),e("div",{class:"settings-category-body",children:[e("div",{class:"settings-fields-grid",children:[e(I,{label:"Enabled",name:"smart_account.enabled",type:"select",value:f("smart_account","enabled")||"false",onChange:m=>x("smart_account.enabled",m),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(I,{label:"Bundler URL",name:"smart_account.bundler_url",value:f("smart_account","bundler_url"),onChange:m=>x("smart_account.bundler_url",m),placeholder:"https://api.pimlico.io/v2/...",description:"Bundler RPC endpoint URL. Required for smart account transactions.","data-field":"smart_account.bundler_url"}),e(I,{label:"Paymaster URL",name:"smart_account.paymaster_url",value:f("smart_account","paymaster_url"),onChange:m=>x("smart_account.paymaster_url",m),placeholder:"https://api.pimlico.io/v2/...",description:"Paymaster RPC endpoint URL. Optional -- when set, gas fees are sponsored.","data-field":"smart_account.paymaster_url"}),e(I,{label:"Paymaster API Key",name:"smart_account.paymaster_api_key",type:"password",value:f("smart_account","paymaster_api_key"),onChange:m=>x("smart_account.paymaster_api_key",m),placeholder:"Enter API key",description:"Paymaster API key. Stored encrypted (AES-256-GCM).","data-field":"smart_account.paymaster_api_key"}),e(I,{label:"EntryPoint Address",name:"smart_account.entry_point",value:f("smart_account","entry_point"),onChange:m=>x("smart_account.entry_point",m),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. Requires an ERC-4337 Bundler and optionally a Paymaster service."})]})]})}return e("div",{class:"page",children:[o.value&&e("div",{class:"shutdown-overlay",children:[e("h2",{children:"Daemon is shutting down..."}),e("p",{children:"You can close this tab."})]}),w>0&&e("div",{class:"settings-save-bar",children:[e("span",{children:[w," unsaved change",w>1?"s":""]}),e("div",{class:"settings-save-bar-actions",children:[e(P,{variant:"ghost",size:"sm",onClick:y,children:"Discard"}),e(P,{variant:"primary",size:"sm",onClick:W,loading:n.value,children:"Save"})]})]}),l.value?e("div",{class:"empty-state",children:e("p",{children:"Loading settings..."})}):e(J,{children:[e(F,{}),e(D,{}),e(H,{}),e(O,{}),e(k,{}),e(_,{})]}),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(P,{variant:"danger",onClick:()=>{r.value=!0},children:"Shutdown Daemon"})})]}),e(be,{open:r.value,title:"Shutdown Daemon",onCancel:()=>{r.value=!1,h.value=""},onConfirm:A,confirmText:"Shutdown",confirmVariant:"danger",confirmDisabled:h.value!=="SHUTDOWN",loading:c.value,children:[e("p",{children:"This will gracefully stop the daemon process. All active connections will be terminated."}),e("div",{class:"shutdown-confirm-input",children:[e("label",{children:["Type ",e("strong",{children:"SHUTDOWN"})," to confirm"]}),e("input",{type:"text",value:h.value,onInput:m=>{h.value=m.target.value},placeholder:"SHUTDOWN"})]})]})]})}const tn=[{key:"jupiter_swap",name:"Jupiter Swap",description:"Solana DEX aggregator",chain:"solana",requiresApiKey:!1,docsUrl:"https://station.jup.ag/docs"},{key:"zerox_swap",name:"0x Swap",description:"EVM DEX aggregator (AllowanceHolder)",chain:"evm",requiresApiKey:!0,docsUrl:"https://dashboard.0x.org"},{key:"lifi",name:"LI.FI",description:"Multi-chain DEX/bridge aggregator",chain:"multi",requiresApiKey:!1,docsUrl:"https://docs.li.fi"},{key:"lido_staking",name:"Lido Staking",description:"ETH liquid staking (stETH/wstETH)",chain:"evm",requiresApiKey:!1,docsUrl:"https://docs.lido.fi"},{key:"jito_staking",name:"Jito Staking",description:"SOL liquid staking (JitoSOL)",chain:"solana",requiresApiKey:!1,docsUrl:"https://www.jito.network/docs"},{key:"aave_v3",name:"Aave V3 Lending",description:"EVM lending protocol (supply, borrow, repay, withdraw)",chain:"evm",requiresApiKey:!1,docsUrl:"https://docs.aave.com/developers"},{key:"kamino",name:"Kamino Lending",description:"Solana lending protocol (supply, borrow, repay, withdraw)",chain:"solana",requiresApiKey:!1,docsUrl:"https://docs.kamino.finance"},{key:"pendle_yield",name:"Pendle Yield",description:"EVM yield trading: buy/sell PT/YT, redeem at maturity, add/remove LP",chain:"evm",requiresApiKey:!1,docsUrl:"https://docs.pendle.finance"},{key:"drift_perp",name:"Drift Perp",description:"Solana perpetual futures trading (open, close, modify positions with leverage)",chain:"solana",requiresApiKey:!1,docsUrl:"https://docs.drift.trade"},{key:"erc8004_agent",name:"ERC-8004 Agent",description:"On-chain agent identity, reputation, and validation (ERC-8004 Trustless Agents)",chain:"evm",requiresApiKey:!1,docsUrl:"https://eips.ethereum.org/EIPS/eip-8004"}];function ws(){const t=d([]),a=d({}),n=d([]),l=d(!0),i=d(null),s=d(""),r=d(!1),c=d(null),h=d({}),o=async()=>{try{const O=await z(L.ADMIN_SETTINGS);a.value=O}catch(O){const k=O instanceof T?O:new T(0,"UNKNOWN","Unknown error");b("error",K(k.code))}},u=async()=>{try{const O=await z(L.ADMIN_API_KEYS);n.value=O.keys}catch{}},v=async()=>{try{const O=await z(L.ACTIONS_PROVIDERS);t.value=O.providers??[]}catch{}},f=async()=>{l.value=!0,await Promise.all([o(),u(),v()]),l.value=!1};G(()=>{f()},[]);const N=async(O,k)=>{const _=`actions.${O}_enabled`;c.value=O;try{const m=await de(L.ADMIN_SETTINGS,{settings:[{key:_,value:String(k)}]});a.value=m.settings,b("success",`${k?"Enabled":"Disabled"} ${O.replace(/_/g," ")}`)}catch(m){const R=m instanceof T?m:new T(0,"UNKNOWN","Unknown error");b("error",K(R.code))}finally{c.value=null}},x=async O=>{r.value=!0;try{await de(L.ADMIN_API_KEY(O),{apiKey:s.value}),b("success",`API key saved for ${O}`),i.value=null,s.value="",await u()}catch(k){const _=k instanceof T?k:new T(0,"UNKNOWN","Unknown error");b("error",K(_.code))}finally{r.value=!1}},W=async O=>{try{await $e(L.ADMIN_API_KEY(O)),b("success",`API key deleted for ${O}`),await u()}catch(k){const _=k instanceof T?k:new T(0,"UNKNOWN","Unknown error");b("error",K(_.code))}},y=async(O,k)=>{const _=`actions.${O}`;try{const m=await de(L.ADMIN_SETTINGS,{settings:[{key:_,value:k}]});a.value=m.settings;const R={...h.value};delete R[O],h.value=R,b("success","Setting updated")}catch(m){const R=m instanceof T?m:new T(0,"UNKNOWN","Unknown error");b("error",K(R.code))}};function A(O){const k=a.value.actions;return k?k[`${O}_enabled`]==="true":!1}function w(O){return t.value.some(k=>k.name.toLowerCase().replace(/[\s-]/g,"_")===O||k.name.toLowerCase().includes(O.replace(/_/g," ")))}function F(O){return n.value.find(k=>k.providerName===O||k.providerName.toLowerCase().replace(/[\s-]/g,"_")===O)}function D(O){return t.value.find(k=>k.name.toLowerCase().replace(/[\s-]/g,"_")===O||k.name.toLowerCase().includes(O.replace(/_/g," ")))}function H(O){const k=A(O.key),_=w(O.key);return k&&O.requiresApiKey&&!F(O.key)?.hasKey?{label:"Requires API Key",variant:"warning"}:k&&_?{label:"Active",variant:"success"}:{label:"Inactive",variant:"neutral"}}return l.value?e("div",{class:"page",children:e("div",{class:"empty-state",children:e("p",{children:"Loading action providers..."})})}):e("div",{class:"page",children:[tn.map(O=>{const k=H(O),_=A(O.key),m=D(O.key),R=F(O.key),g=c.value===O.key;return e("div",{class:"settings-category",style:{marginBottom:"var(--space-4)"},children:[e("div",{class:"settings-category-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e("div",{children:[e("h3",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)",margin:0},children:[O.name,m&&e(V,{variant:"info",children:m.version}),e(V,{variant:(O.chain==="solana","info"),children:O.chain})]}),e("p",{class:"settings-description",style:{marginTop:"var(--space-1)"},children:[O.description,O.docsUrl&&e(J,{children:[" ","—"," ",e("a",{href:O.docsUrl,target:"_blank",rel:"noopener noreferrer",children:"Docs"})]})]})]}),e(V,{variant:k.variant,children:k.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(I,{label:"Enabled",name:`actions.${O.key}_enabled`,type:"checkbox",value:_,onChange:p=>N(O.key,!!p),disabled:g}),g&&e("span",{style:{fontSize:"var(--font-size-sm)",color:"var(--text-secondary)"},children:"Saving..."})]}),O.requiresApiKey&&e("div",{style:{borderTop:"1px solid var(--border)",paddingTop:"var(--space-3)",marginBottom:"var(--space-3)"},children:[e("div",{style:{fontWeight:600,fontSize:"var(--font-size-sm)",marginBottom:"var(--space-2)",color:"var(--text-secondary)"},children:"API Key"}),i.value===O.key?e("div",{style:{display:"flex",alignItems:"flex-end",gap:"var(--space-2)"},children:[e(I,{label:"API Key",type:"password",name:`apikey-${O.key}`,value:s.value,onChange:p=>{s.value=String(p)},placeholder:"Enter API key"}),e(P,{onClick:()=>x(O.key),loading:r.value,size:"sm",children:"Save"}),e(P,{variant:"ghost",onClick:()=>{i.value=null,s.value=""},size:"sm",children:"Cancel"})]}):e("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)"},children:[e("span",{style:{fontFamily:"monospace",fontSize:"var(--font-size-sm)",color:"var(--text-secondary)"},children:R?.hasKey?R.maskedKey:"Not set"}),e(P,{variant:"ghost",onClick:()=>{i.value=O.key,s.value=""},size:"sm",children:R?.hasKey?"Update":"Set"}),R?.hasKey&&e(P,{variant:"danger",onClick:()=>W(O.key),size:"sm",children:"Delete"})]})]}),O.key==="aave_v3"&&_&&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"}),["aave_v3_health_factor_warning_threshold","aave_v3_position_sync_interval_sec","aave_v3_max_ltv_pct"].map(p=>{const U=a.value.actions,B=h.value[p]??U?.[p]??"";return e("div",{style:{marginBottom:"var(--space-2)"},onBlur:()=>{const E=h.value[p];E!==void 0&&y(p,E)},children:e(I,{label:Z(p),name:`actions.${p}`,type:"text",value:B,onChange:E=>{h.value={...h.value,[p]:String(E)}}})},p)})]}),O.key==="kamino"&&_&&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"}),["kamino_market","kamino_hf_threshold"].map(p=>{const U=a.value.actions,B=h.value[p]??U?.[p]??"";return e("div",{style:{marginBottom:"var(--space-2)"},onBlur:()=>{const E=h.value[p];E!==void 0&&y(p,E)},children:e(I,{label:Z(p),name:`actions.${p}`,type:"text",value:B,onChange:E=>{h.value={...h.value,[p]:String(E)}}})},p)})]}),O.key==="drift_perp"&&_&&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"}),["drift_max_leverage","drift_max_position_usd","drift_margin_warning_threshold_pct","drift_position_sync_interval_sec"].map(p=>{const U=a.value.actions,B=h.value[p]??U?.[p]??"";return e("div",{style:{marginBottom:"var(--space-2)"},onBlur:()=>{const E=h.value[p];E!==void 0&&y(p,E)},children:e(I,{label:Z(p),name:`actions.${p}`,type:"text",value:B,onChange:E=>{h.value={...h.value,[p]:String(E)}}})},p)})]}),_&&m&&m.actions.length>0&&e("div",{style:{borderTop:"1px solid var(--border)",paddingTop:"var(--space-3)"},children:[e("div",{style:{fontWeight:600,fontSize:"var(--font-size-sm)",marginBottom:"var(--space-2)",color:"var(--text-secondary)"},children:"Registered Actions"}),e("table",{class:"table",children:[e("thead",{children:e("tr",{children:[e("th",{children:"Name"}),e("th",{children:"Chain"}),e("th",{children:"Risk Level"}),e("th",{children:"Default Tier"})]})}),e("tbody",{children:m.actions.map(p=>e("tr",{children:[e("td",{children:p.name}),e("td",{children:e(V,{variant:"info",children:p.chain})}),e("td",{children:p.riskLevel}),e("td",{children:p.defaultTier})]},p.name))})]})]})]})]},O.key)}),tn.length===0&&e("div",{class:"empty-state",children:e("p",{children:"No action providers available."})})]})}function Ss(){const t=d([]),a=d(!0),n=d(!1),l=d(!1),i=d(!1),s=d(null),r=d(!1),c=d(""),h=d(""),o=d(""),u=d(!1),v=d({}),f=d(null),N=d(null),x=d({}),W=d(null),y=async()=>{try{const p=await z(L.ADMIN_WALLET_APPS);t.value=p.apps}catch{b("Failed to load wallet apps","error")}},A=async()=>{try{const U=(await z(L.ADMIN_SETTINGS)).signing_sdk;U&&(l.value=String(U.enabled)==="true",n.value=String(U.notifications_enabled)==="true")}catch{}};G(()=>{Promise.all([y(),A()]).finally(()=>{a.value=!1})},[]);const w=async()=>{i.value=!0;const p=!n.value;try{await de(L.ADMIN_SETTINGS,{settings:[{key:"signing_sdk.notifications_enabled",value:String(p)}]}),n.value=p,b(`Wallet app notifications ${p?"enabled":"disabled"}`,"success")}catch{b("Failed to update notification setting","error")}finally{i.value=!1}},F=async(p,U)=>{N.value=`${p.id}-${U}`;try{await de(L.ADMIN_WALLET_APP(p.id),{[U]:!p[U]}),await y(),b(`${U==="signing_enabled"?"Signing":"Alerts"} ${p[U]?"disabled":"enabled"} for ${p.display_name}`,"success")}catch{b("Failed to update toggle","error")}finally{N.value=null}},D=async p=>{s.value=p.id;try{const U=await se(L.ADMIN_WALLET_APP_TEST_NOTIFICATION(p.id));U.success?b(`Test notification sent to ${U.topic}`,"success"):b(U.error||"Test notification failed","error")}catch{b("Failed to send test notification","error")}finally{s.value=null}},H=async()=>{if(!c.value.trim()||!h.value.trim()){b("Name and display name are required","error");return}u.value=!0;try{const p={name:c.value.trim(),display_name:h.value.trim()};o.value.trim()&&(p.wallet_type=o.value.trim()),await se(L.ADMIN_WALLET_APPS,p),r.value=!1,c.value="",h.value="",o.value="",await y(),b("Wallet app registered","success")}catch(p){p instanceof T&&p.code==="WALLET_APP_DUPLICATE"?b("App already registered","error"):b("Failed to register app","error")}finally{u.value=!1}},O=async(p,U)=>{f.value=p.id;try{await de(L.ADMIN_WALLET_APP(p.id),{subscription_token:U||""});const B={...v.value};delete B[p.id],v.value=B,await y(),b(U?"Subscription token set":"Subscription token cleared","success")}catch{b("Failed to update subscription token","error")}finally{f.value=null}},k=async p=>{if(confirm(`Remove "${p.display_name}"? Wallets using this app will no longer route signing requests to it.`))try{await $e(L.ADMIN_WALLET_APP(p.id)),await y(),b(`${p.display_name} removed`,"success")}catch{b("Failed to remove app","error")}},_=p=>{x.value={...x.value,[p.id]:{signTopic:p.sign_topic??"",notifyTopic:p.notify_topic??""}}},m=p=>{const U={...x.value};delete U[p],x.value=U},R=async p=>{const U=x.value[p.id];if(U){W.value=p.id;try{await de(L.ADMIN_WALLET_APP(p.id),{sign_topic:U.signTopic||null,notify_topic:U.notifyTopic||null}),m(p.id),await y(),b("Topics updated","success")}catch{b("Failed to update topics","error")}finally{W.value=null}}},g=t.value.some(p=>p.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 ntfy"})]}),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:w,disabled:i.value,"data-testid":"notif-toggle"}),e("span",{children:"Notifications"}),e(V,{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(--warning-bg, #fff3cd)",border:"1px solid var(--warning-border, #ffc107)",borderRadius:"4px",fontSize:"0.85rem"},children:"Signing SDK is disabled. Enable it in System > Signing SDK to use wallet app notifications."}),!n.value&&g&&e("div",{class:"settings-warning-box",style:{marginTop:"0.75rem",padding:"0.75rem",background:"var(--warning-bg, #fff3cd)",border:"1px solid var(--warning-border, #ffc107)",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(P,{onClick:()=>{r.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(p=>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:[p.display_name,p.wallet_type&&p.wallet_type!==p.name&&e(V,{variant:"info",style:{marginLeft:"0.5rem",fontSize:"0.7rem"},children:p.wallet_type})]}),e("code",{style:{fontSize:"0.8rem",color:"var(--text-muted)"},children:p.name})]}),e(P,{variant:"danger",size:"sm",onClick:()=>k(p),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:p.signing_enabled,onChange:()=>F(p,"signing_enabled"),disabled:N.value===`${p.id}-signing_enabled`}),e("span",{children:"Signing"}),e(V,{variant:p.signing_enabled?"success":"muted",children:p.signing_enabled?"ON":"OFF"})]}),e("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[e("input",{type:"checkbox",checked:p.alerts_enabled,onChange:()=>F(p,"alerts_enabled"),disabled:N.value===`${p.id}-alerts_enabled`}),e("span",{children:"Alerts"}),e(V,{variant:p.alerts_enabled?"success":"muted",children:p.alerts_enabled?"ON":"OFF"})]}),p.alerts_enabled&&e(P,{variant:"secondary",size:"sm",onClick:()=>D(p),disabled:s.value===p.id,children:s.value===p.id?"Sending...":"Test"})]}),e("div",{style:{marginTop:"0.75rem"},children:[e("span",{style:{fontSize:"0.85rem",fontWeight:500},children:"Used by: "}),p.used_by.length===0?e("span",{style:{fontSize:"0.85rem",color:"var(--text-muted)"},children:"No wallets"}):e("span",{style:{fontSize:"0.85rem"},children:p.used_by.map((U,B)=>e("span",{children:[B>0&&", ",e("a",{href:`#/wallets/${U.id}`,style:{color:"var(--primary)"},children:U.label})]},U.id))})]}),e("div",{style:{marginTop:"0.75rem"},children:[e("span",{style:{fontSize:"0.85rem",fontWeight:500},children:"Subscription Token: "}),v.value[p.id]!==void 0?e("span",{style:{display:"inline-flex",gap:"0.5rem",alignItems:"center"},children:[e("input",{type:"text",value:v.value[p.id],onInput:U=>{v.value={...v.value,[p.id]:U.target.value}},placeholder:"e.g., a1b2c3d4",style:{padding:"0.25rem 0.5rem",fontSize:"0.85rem",width:"140px"}}),e(P,{size:"sm",onClick:()=>O(p,v.value[p.id]),disabled:f.value===p.id,children:f.value===p.id?"Saving...":"Set"}),e(P,{variant:"secondary",size:"sm",onClick:()=>{const U={...v.value};delete U[p.id],v.value=U},children:"Cancel"})]}):p.subscription_token?e("span",{style:{fontSize:"0.85rem"},children:[e("code",{children:[p.subscription_token.slice(0,4),"****"]}),e(P,{variant:"secondary",size:"sm",onClick:()=>O(p,""),disabled:f.value===p.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(P,{variant:"secondary",size:"sm",onClick:()=>{v.value={...v.value,[p.id]:""}},style:{marginLeft:"0.5rem"},children:"Set"})]})]}),x.value[p.id]?e("div",{style:{marginTop:"0.75rem",borderTop:"1px solid var(--border)",paddingTop:"0.75rem"},children:[e("span",{style:{fontSize:"0.85rem",fontWeight:500,display:"block",marginBottom:"0.5rem"},children:"ntfy Topics"}),e("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.5rem"},children:[e(I,{label:"Sign Topic",name:`sign-topic-${p.id}`,type:"text",value:x.value[p.id].signTopic,onChange:U=>{x.value={...x.value,[p.id]:{...x.value[p.id],signTopic:String(U)}}},placeholder:`waiaas-sign-${p.name}`,description:"ntfy topic for signing requests"}),e(I,{label:"Notify Topic",name:`notify-topic-${p.id}`,type:"text",value:x.value[p.id].notifyTopic,onChange:U=>{x.value={...x.value,[p.id]:{...x.value[p.id],notifyTopic:String(U)}}},placeholder:`waiaas-notify-${p.name}`,description:"ntfy topic for activity alerts"})]}),e("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end",marginTop:"0.5rem"},children:[e(P,{variant:"secondary",size:"sm",onClick:()=>m(p.id),children:"Cancel"}),e(P,{size:"sm",onClick:()=>R(p),disabled:W.value===p.id,children:W.value===p.id?"Saving...":"Save Topics"})]})]}):e("div",{style:{marginTop:"0.75rem",borderTop:"1px solid var(--border)",paddingTop:"0.75rem"},children:[e("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"0.5rem"},children:[e("span",{style:{fontSize:"0.85rem",fontWeight:500},children:"ntfy Topics"}),e(P,{variant:"secondary",size:"sm",onClick:()=>_(p),children:"Edit"})]}),e("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.5rem",fontSize:"0.85rem"},children:[e("div",{children:[e("span",{style:{color:"var(--text-muted)"},children:"Sign Topic: "}),e("code",{children:p.sign_topic??"(default)"})]}),e("div",{children:[e("span",{style:{color:"var(--text-muted)"},children:"Notify Topic: "}),e("code",{children:p.notify_topic??"(default)"})]})]})]})]},p.id))})})]}),e(be,{open:r.value,title:"Register Wallet App",onCancel:()=>{r.value=!1},children:e("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[e(I,{label:"App Name",name:"register-app-name",type:"text",value:c.value,onChange:p=>{c.value=String(p)},placeholder:"my-custom-wallet",description:"Lowercase alphanumeric with hyphens (e.g., dcent, my-wallet)"}),e(I,{label:"Display Name",name:"register-app-display-name",type:"text",value:h.value,onChange:p=>{h.value=String(p)},placeholder:"My Custom Wallet",description:"Human-readable name shown in the UI"}),e(I,{label:"Wallet Type (optional)",name:"register-app-wallet-type",type:"text",value:o.value,onChange:p=>{o.value=String(p)},placeholder:"dcent, ledger, or custom",description:"Group multiple devices under the same wallet type. Defaults to app name."}),e("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end"},children:[e(P,{variant:"secondary",onClick:()=>{r.value=!1},children:"Cancel"}),e(P,{onClick:H,disabled:u.value||!c.value.trim()||!h.value.trim(),children:u.value?"Registering...":"Register"})]})]})})]})}const Ts=[{key:"identity",label:"Identity"},{key:"registration",label:"Registration File"},{key:"reputation",label:"Reputation"}];function pt({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(pt,{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],s)=>e("div",{style:{paddingLeft:"var(--space-3)"},children:[e("span",{style:{fontWeight:"bold"},children:['"',l,'"']}),": ",e(pt,{data:i,depth:a+1}),s<n.length-1?",":""]},l)),"}"]})}return e("span",{children:String(t)})}function ks(){const t=d("identity"),a=d(!0),n=d(!1),l=d([]),i=d([]),s=d(!1),r=d(""),c=d(""),h=d(""),o=d(!1),u=d(""),v=d(null),f=d(!1),N=d(null),x=d(""),W=d(""),y=d(""),A=d(null),w=d(!1),F=d(null),D=d(""),H=d(!1);async function O(){a.value=!0;try{const Y=(await z(L.ADMIN_SETTINGS))["actions.erc8004_agent_enabled"];if(n.value=Y?.value==="true",!n.value){a.value=!1;return}const ae=await z(L.WALLETS);l.value=ae;const ie=ae.filter(oe=>oe.chain==="ethereum"),te=[];for(const oe of ie)try{const Te=await z(L.ERC8004_REGISTRATION_FILE(oe.id)),ke=Te.agentId;te.push({walletId:oe.id,walletName:oe.name,agentId:ke??null,status:ke?"REGISTERED":"NOT_REGISTERED",registryAddress:Te.registryAddress??""})}catch{te.push({walletId:oe.id,walletName:oe.name,agentId:null,status:"NOT_REGISTERED",registryAddress:""})}i.value=te}catch(E){E instanceof T&&b(K(E.code),"error")}finally{a.value=!1}}G(()=>{O()},[]);async function k(){if(!(!r.value||!c.value)){o.value=!0;try{await se(`${L.ACTIONS_PROVIDERS}/erc8004_agent/register_agent`,{params:{name:c.value,...h.value?{description:h.value}:{}},walletId:r.value}),b("Agent registration initiated","success"),s.value=!1,c.value="",h.value="",r.value="",await O()}catch(E){E instanceof T&&b(K(E.code),"error")}finally{o.value=!1}}}async function _(E,Y){F.value=E,H.value=!1,D.value="";try{const ae=await se(L.WALLET_WC_PAIR(E),{});D.value=ae.uri;const ie=setInterval(async()=>{try{(await z(L.WALLET_WC_PAIR_STATUS(E))).connected&&(clearInterval(ie),H.value=!0,await se(`${L.ACTIONS_PROVIDERS}/erc8004_agent/set_agent_wallet`,{params:{agentId:Y},walletId:E}),b("Wallet linking initiated via EIP-712","success"),F.value=null,await O())}catch{}},1e3);setTimeout(()=>{clearInterval(ie),!H.value&&F.value&&(b("WalletConnect pairing timed out","error"),F.value=null)},6e4)}catch(ae){ae instanceof T&&b(K(ae.code),"error"),F.value=null}}async function m(E,Y){try{await se(`${L.ACTIONS_PROVIDERS}/erc8004_agent/unset_agent_wallet`,{params:{agentId:Y},walletId:E}),b("Wallet unlinking initiated","success"),await O()}catch(ae){ae instanceof T&&b(K(ae.code),"error")}}async function R(E){if(E){f.value=!0;try{const Y=await z(L.ERC8004_REGISTRATION_FILE(E));v.value=Y}catch(Y){Y instanceof T&&b(K(Y.code),"error"),v.value=null}finally{f.value=!1}}}async function g(E,Y,ae){try{const te=new URLSearchParams().toString(),oe=await z(`${L.ERC8004_REPUTATION(E)}${te?`?${te}`:""}`);N.value=oe}catch{N.value=null}}async function p(){if(y.value){w.value=!0;try{const E=new URLSearchParams;x.value&&E.set("tag1",x.value),W.value&&E.set("tag2",W.value);const Y=E.toString(),ae=await z(`${L.ERC8004_REPUTATION(y.value)}${Y?`?${Y}`:""}`);A.value=ae}catch(E){E instanceof T&&b(K(E.code),"error"),A.value=null}finally{w.value=!1}}}function U(E){return E>=50?"success":E>=20?"warning":"danger"}if(!a.value&&!n.value)return e(Ua,{title:"ERC-8004 Agent feature is disabled",description:"Enable it in Settings > Actions > erc8004_agent_enabled",actionLabel:"Go to System Settings",onAction:()=>{window.location.hash="#/system"}});const B=l.value.filter(E=>E.chain==="ethereum");return e("div",{children:[e(Ke,{tabs:Ts,activeTab:t.value,onTabChange:E=>{t.value=E}}),a.value&&e("p",{class:"loading-text",children:"Loading..."}),!a.value&&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"}),e(P,{variant:"primary",onClick:()=>{s.value=!0},children:"Register Agent"})]}),i.value.length===0?e(Ua,{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"}),e("th",{children:"Actions"})]})}),e("tbody",{children:i.value.map(E=>e("tr",{children:[e("td",{children:E.walletName}),e("td",{title:E.walletId,children:[E.walletId.slice(0,8),"..."]}),e("td",{children:e(V,{variant:E.status==="REGISTERED"?"success":E.status==="WALLET_LINKED"?"info":"default",children:E.status})}),e("td",{children:E.agentId??"-"}),e("td",{title:E.registryAddress,children:E.registryAddress?`${E.registryAddress.slice(0,10)}...`:"-"}),e("td",{children:[E.agentId&&E.status==="REGISTERED"&&e(P,{variant:"secondary",onClick:()=>_(E.walletId,E.agentId),disabled:F.value===E.walletId,children:F.value===E.walletId?"Linking...":"Link Wallet"}),E.agentId&&E.status==="WALLET_LINKED"&&e(P,{variant:"danger",onClick:()=>m(E.walletId,E.agentId),children:"Unlink"})]})]},E.walletId))})]}),F.value&&D.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:D.value}),e("div",{style:{marginTop:"var(--space-2)"},children:e(Ge,{value:D.value,label:"Copy URI"})})]})]}),!a.value&&t.value==="registration"&&e("div",{children:[e("div",{class:"form-field",children:[e("label",{children:"Select Wallet"}),e("select",{value:u.value,onChange:E=>{const Y=E.target.value;u.value=Y,Y&&R(Y)},children:[e("option",{value:"",children:"-- Select wallet --"}),B.map(E=>e("option",{value:E.id,children:[E.name," (",E.id.slice(0,8),"...)"]},E.id))]})]}),u.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/${u.value}`,label:"Copy URL"})]}),f.value?e("p",{class:"loading-text",children:"Loading..."}):v.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(pt,{data:v.value})}):e("p",{children:"No registration file available for this wallet."})]})]}),!a.value&&t.value==="reputation"&&e("div",{children:[e("h3",{children:"My Agent Score"}),i.value.filter(E=>E.agentId).length===0?e("p",{children:"No registered agents. Register an agent first."}):e("div",{children:i.value.filter(E=>E.agentId).map(E=>((!N.value||N.value.agentId!==E.agentId)&&g(E.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 #",E.agentId]}),N.value&&N.value.agentId===E.agentId&&e(J,{children:[e("span",{style:{fontSize:"var(--font-xl)",fontWeight:"bold"},children:Number(N.value.score)/Math.pow(10,N.value.decimals)}),e(V,{variant:U(Number(N.value.score)/Math.pow(10,N.value.decimals)),children:[N.value.count," feedback(s)"]})]})]})},E.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:x.value,onInput:E=>{x.value=E.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:E=>{W.value=E.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:y.value,onInput:E=>{y.value=E.target.value},placeholder:"Enter agent ID"})]}),e(P,{variant:"primary",onClick:p,loading:w.value,children:"Query"})]}),A.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 #",A.value.agentId]})}),e("p",{children:["Score: ",Number(A.value.score)/Math.pow(10,A.value.decimals)]}),e("p",{children:["Feedback count: ",A.value.count]}),A.value.tag1&&e("p",{children:["Tag1: ",A.value.tag1]}),A.value.tag2&&e("p",{children:["Tag2: ",A.value.tag2]}),e(V,{variant:U(Number(A.value.score)/Math.pow(10,A.value.decimals)),children:Number(A.value.score)/Math.pow(10,A.value.decimals)>=50?"Good":Number(A.value.score)/Math.pow(10,A.value.decimals)>=20?"Fair":"Low"})]})]}),e(be,{open:s.value,title:"Register Agent",onConfirm:k,onCancel:()=>{s.value=!1},confirmText:"Register",loading:o.value,confirmDisabled:!r.value||!c.value,children:[e("div",{class:"form-field",children:[e("label",{children:"EVM Wallet"}),e("select",{value:r.value,onChange:E=>{r.value=E.target.value},children:[e("option",{value:"",children:"-- Select wallet --"}),B.map(E=>e("option",{value:E.id,children:[E.name," (",E.id.slice(0,8),"...)"]},E.id))]})]}),e("div",{class:"form-field",children:[e("label",{children:"Name"}),e("input",{type:"text",value:c.value,onInput:E=>{c.value=E.target.value},placeholder:"Agent name"})]}),e("div",{class:"form-field",children:[e("label",{children:"Description (optional)"}),e("input",{type:"text",value:h.value,onInput:E=>{h.value=E.target.value},placeholder:"Description"})]})]})]})}function Mn(t){const a=t.slice(1)||"/dashboard",n=a.indexOf("?");return n>=0?a.slice(0,n):a}const Pe=ge(Mn(window.location.hash)),Ia=ge(!1);window.addEventListener("hashchange",()=>{Pe.value=Mn(window.location.hash)});const Ns={"/dashboard":"Dashboard","/wallets":"Wallets","/transactions":"Transactions","/sessions":"Sessions","/tokens":"Token Registry","/actions":"Actions","/policies":"Policies","/notifications":"Notifications","/security":"Security","/wallet-apps":"Human Wallet Apps","/erc8004":"ERC-8004 Agents","/system":"System"},As={"/dashboard":"System overview and key metrics","/wallets":"Manage wallets, balances, and connections","/transactions":"View all transactions and configure incoming monitoring","/sessions":"View and manage active sessions","/tokens":"Manage EVM token registry per network","/actions":"Manage DeFi action providers and API keys","/policies":"Configure transaction policies and rules","/notifications":"Channel status, delivery logs, and settings","/security":"Emergency controls and automatic protection rules","/wallet-apps":"Manage wallet apps for signing and notifications","/erc8004":"On-chain agent identity, reputation, and wallet linking","/system":"API keys, display preferences, and daemon configuration"};function Es(t){return t.startsWith("/wallets/")?"Wallet Detail":Ns[t]??"Dashboard"}function nn(t){return As[t]}const Cs=[{path:"/dashboard",label:"Dashboard"},{path:"/wallets",label:"Wallets"},{path:"/transactions",label:"Transactions"},{path:"/sessions",label:"Sessions"},{path:"/tokens",label:"Tokens"},{path:"/actions",label:"Actions"},{path:"/policies",label:"Policies"},{path:"/notifications",label:"Notifications"},{path:"/wallet-apps",label:"Human Wallet Apps"},{path:"/erc8004",label:"ERC-8004"},{path:"/security",label:"Security"},{path:"/system",label:"System"}];function Is(){const t=Pe.value;return t==="/transactions"?e(zt,{}):t==="/incoming"?(window.location.hash="#/transactions",e(zt,{})):t==="/tokens"?e(Ai,{}):t==="/actions"?e(ws,{}):t==="/sessions"?e(Ii,{}):t==="/policies"?e(ss,{}):t==="/notifications"?e(an,{}):t==="/telegram-users"?(window.location.hash="#/notifications",e(an,{})):t==="/settings"?(window.location.hash="#/dashboard",e(Wt,{})):t==="/walletconnect"?(window.location.hash="#/wallets",e(Kt,{})):t==="/security"?e(fs,{}):t==="/wallet-apps"?e(Ss,{}):t==="/erc8004"?e(ks,{}):t==="/system"?e(bs,{}):t.startsWith("/wallets")?e(Kt,{}):e(Wt,{})}function Ds(){return G(()=>{const t=a=>{(a.metaKey||a.ctrlKey)&&a.key==="k"&&(a.preventDefault(),Ia.value=!Ia.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:Cs.map(t=>{const a=t.path==="/wallets"?Pe.value.startsWith("/wallets"):Pe.value===t.path;return e("a",{href:`#${t.path}`,class:`sidebar-link ${a?"active":""}`,onClick:n=>{On.value&&(n.preventDefault(),Ln({type:"nav",execute:()=>{window.location.hash=`#${t.path}`}}))},children:t.label})})})]}),e("main",{class:"main",children:[e("header",{class:"header",children:[e("div",{class:"header-left",children:[e("h1",{class:"header-title",children:Es(Pe.value)}),nn(Pe.value)&&e("p",{class:"header-subtitle",children:nn(Pe.value)})]}),e("div",{class:"header-actions",children:[e("button",{class:"btn-search",onClick:()=>{Ia.value=!0},title:"Search settings (Ctrl+K)",children:"🔍"}),e("button",{class:"btn-logout",onClick:()=>za(),children:"Logout"})]})]}),e("div",{class:"content",children:e(Is,{})})]}),e(Il,{open:Ia}),e(Ll,{})]})}const Da={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 Os(){return e("div",{style:Da.overlay,children:e("div",{style:Da.content,children:[e("h1",{style:Da.title,children:"Daemon Shutting Down"}),e("p",{style:Da.message,children:"The daemon is shutting down. Please wait or restart."})]})})}function Ls(){return _l.value?e(Os,{}):yl.value?e(J,{children:[e(Ds,{}),e(Vl,{})]}):e(kl,{})}rl(e(Ls,{}),document.getElementById("app"));