@hivemagnus/magnus-ui 1.1.2 → 1.1.4

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 (147) hide show
  1. package/dist/app/apps/dashboard/.next/BUILD_ID +1 -1
  2. package/dist/app/apps/dashboard/.next/build-manifest.json +3 -3
  3. package/dist/app/apps/dashboard/.next/prerender-manifest.json +3 -3
  4. package/dist/app/apps/dashboard/.next/required-server-files.json +2 -2
  5. package/dist/app/apps/dashboard/.next/server/app/_global-error.html +1 -1
  6. package/dist/app/apps/dashboard/.next/server/app/_global-error.rsc +1 -1
  7. package/dist/app/apps/dashboard/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  8. package/dist/app/apps/dashboard/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  9. package/dist/app/apps/dashboard/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  10. package/dist/app/apps/dashboard/.next/server/app/_not-found/page.js.nft.json +1 -1
  11. package/dist/app/apps/dashboard/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  12. package/dist/app/apps/dashboard/.next/server/app/anomalies/[anomalyId]/page.js.nft.json +1 -1
  13. package/dist/app/apps/dashboard/.next/server/app/anomalies/[anomalyId]/page_client-reference-manifest.js +1 -1
  14. package/dist/app/apps/dashboard/.next/server/app/anomalies/page.js.nft.json +1 -1
  15. package/dist/app/apps/dashboard/.next/server/app/anomalies/page_client-reference-manifest.js +1 -1
  16. package/dist/app/apps/dashboard/.next/server/app/anomalies/remediation/page.js.nft.json +1 -1
  17. package/dist/app/apps/dashboard/.next/server/app/anomalies/remediation/page_client-reference-manifest.js +1 -1
  18. package/dist/app/apps/dashboard/.next/server/app/api-docs/page.js.nft.json +1 -1
  19. package/dist/app/apps/dashboard/.next/server/app/api-docs/page_client-reference-manifest.js +1 -1
  20. package/dist/app/apps/dashboard/.next/server/app/application-operations/page.js.nft.json +1 -1
  21. package/dist/app/apps/dashboard/.next/server/app/application-operations/page_client-reference-manifest.js +1 -1
  22. package/dist/app/apps/dashboard/.next/server/app/ardent/installations/page.js.nft.json +1 -1
  23. package/dist/app/apps/dashboard/.next/server/app/ardent/installations/page_client-reference-manifest.js +1 -1
  24. package/dist/app/apps/dashboard/.next/server/app/ardent/page.js.nft.json +1 -1
  25. package/dist/app/apps/dashboard/.next/server/app/ardent/page_client-reference-manifest.js +1 -1
  26. package/dist/app/apps/dashboard/.next/server/app/ardent/profiles/[id]/page.js.nft.json +1 -1
  27. package/dist/app/apps/dashboard/.next/server/app/ardent/profiles/[id]/page_client-reference-manifest.js +1 -1
  28. package/dist/app/apps/dashboard/.next/server/app/ardent/profiles/page.js.nft.json +1 -1
  29. package/dist/app/apps/dashboard/.next/server/app/ardent/profiles/page_client-reference-manifest.js +1 -1
  30. package/dist/app/apps/dashboard/.next/server/app/audit/page.js.nft.json +1 -1
  31. package/dist/app/apps/dashboard/.next/server/app/audit/page_client-reference-manifest.js +1 -1
  32. package/dist/app/apps/dashboard/.next/server/app/codex/installations/page.js.nft.json +1 -1
  33. package/dist/app/apps/dashboard/.next/server/app/codex/installations/page_client-reference-manifest.js +1 -1
  34. package/dist/app/apps/dashboard/.next/server/app/codex/page.js.nft.json +1 -1
  35. package/dist/app/apps/dashboard/.next/server/app/codex/page_client-reference-manifest.js +1 -1
  36. package/dist/app/apps/dashboard/.next/server/app/commands/page.js.nft.json +1 -1
  37. package/dist/app/apps/dashboard/.next/server/app/commands/page_client-reference-manifest.js +1 -1
  38. package/dist/app/apps/dashboard/.next/server/app/cron/page/server-reference-manifest.json +1 -1
  39. package/dist/app/apps/dashboard/.next/server/app/cron/page.js.nft.json +1 -1
  40. package/dist/app/apps/dashboard/.next/server/app/cron/page_client-reference-manifest.js +1 -1
  41. package/dist/app/apps/dashboard/.next/server/app/files/page.js.nft.json +1 -1
  42. package/dist/app/apps/dashboard/.next/server/app/files/page_client-reference-manifest.js +1 -1
  43. package/dist/app/apps/dashboard/.next/server/app/fleet-map/page.js.nft.json +1 -1
  44. package/dist/app/apps/dashboard/.next/server/app/fleet-map/page_client-reference-manifest.js +1 -1
  45. package/dist/app/apps/dashboard/.next/server/app/fleet-readiness/page.js.nft.json +1 -1
  46. package/dist/app/apps/dashboard/.next/server/app/fleet-readiness/page_client-reference-manifest.js +1 -1
  47. package/dist/app/apps/dashboard/.next/server/app/fleet-timeline/page.js.nft.json +1 -1
  48. package/dist/app/apps/dashboard/.next/server/app/fleet-timeline/page_client-reference-manifest.js +1 -1
  49. package/dist/app/apps/dashboard/.next/server/app/governor/operations/page.js.nft.json +1 -1
  50. package/dist/app/apps/dashboard/.next/server/app/governor/operations/page_client-reference-manifest.js +1 -1
  51. package/dist/app/apps/dashboard/.next/server/app/governor/share/[token]/page.js.nft.json +1 -1
  52. package/dist/app/apps/dashboard/.next/server/app/governor/share/[token]/page_client-reference-manifest.js +1 -1
  53. package/dist/app/apps/dashboard/.next/server/app/hermes-drift/page.js.nft.json +1 -1
  54. package/dist/app/apps/dashboard/.next/server/app/hermes-drift/page_client-reference-manifest.js +1 -1
  55. package/dist/app/apps/dashboard/.next/server/app/hermes-security/page.js.nft.json +1 -1
  56. package/dist/app/apps/dashboard/.next/server/app/hermes-security/page_client-reference-manifest.js +1 -1
  57. package/dist/app/apps/dashboard/.next/server/app/incidents/page.js.nft.json +1 -1
  58. package/dist/app/apps/dashboard/.next/server/app/incidents/page_client-reference-manifest.js +1 -1
  59. package/dist/app/apps/dashboard/.next/server/app/library/page.js.nft.json +1 -1
  60. package/dist/app/apps/dashboard/.next/server/app/library/page_client-reference-manifest.js +1 -1
  61. package/dist/app/apps/dashboard/.next/server/app/login/page.js.nft.json +1 -1
  62. package/dist/app/apps/dashboard/.next/server/app/login/page_client-reference-manifest.js +1 -1
  63. package/dist/app/apps/dashboard/.next/server/app/logs/page.js.nft.json +1 -1
  64. package/dist/app/apps/dashboard/.next/server/app/logs/page_client-reference-manifest.js +1 -1
  65. package/dist/app/apps/dashboard/.next/server/app/mission-control/page.js.nft.json +1 -1
  66. package/dist/app/apps/dashboard/.next/server/app/mission-control/page_client-reference-manifest.js +1 -1
  67. package/dist/app/apps/dashboard/.next/server/app/nodes/[nodeId]/page.js.nft.json +1 -1
  68. package/dist/app/apps/dashboard/.next/server/app/nodes/[nodeId]/page_client-reference-manifest.js +1 -1
  69. package/dist/app/apps/dashboard/.next/server/app/nodes/page.js.nft.json +1 -1
  70. package/dist/app/apps/dashboard/.next/server/app/nodes/page_client-reference-manifest.js +1 -1
  71. package/dist/app/apps/dashboard/.next/server/app/notifications/page.js.nft.json +1 -1
  72. package/dist/app/apps/dashboard/.next/server/app/notifications/page_client-reference-manifest.js +1 -1
  73. package/dist/app/apps/dashboard/.next/server/app/orchestra/installations/page.js.nft.json +1 -1
  74. package/dist/app/apps/dashboard/.next/server/app/orchestra/installations/page_client-reference-manifest.js +1 -1
  75. package/dist/app/apps/dashboard/.next/server/app/orchestra/page.js.nft.json +1 -1
  76. package/dist/app/apps/dashboard/.next/server/app/orchestra/page_client-reference-manifest.js +1 -1
  77. package/dist/app/apps/dashboard/.next/server/app/orchestra/profiles/page.js.nft.json +1 -1
  78. package/dist/app/apps/dashboard/.next/server/app/orchestra/profiles/page_client-reference-manifest.js +1 -1
  79. package/dist/app/apps/dashboard/.next/server/app/orchestra/web-gateway/page.js.nft.json +1 -1
  80. package/dist/app/apps/dashboard/.next/server/app/orchestra/web-gateway/page_client-reference-manifest.js +1 -1
  81. package/dist/app/apps/dashboard/.next/server/app/page.js.nft.json +1 -1
  82. package/dist/app/apps/dashboard/.next/server/app/page_client-reference-manifest.js +1 -1
  83. package/dist/app/apps/dashboard/.next/server/app/retention/page.js.nft.json +1 -1
  84. package/dist/app/apps/dashboard/.next/server/app/retention/page_client-reference-manifest.js +1 -1
  85. package/dist/app/apps/dashboard/.next/server/app/roles/page.js.nft.json +1 -1
  86. package/dist/app/apps/dashboard/.next/server/app/roles/page_client-reference-manifest.js +1 -1
  87. package/dist/app/apps/dashboard/.next/server/app/rollouts/page.js.nft.json +1 -1
  88. package/dist/app/apps/dashboard/.next/server/app/rollouts/page_client-reference-manifest.js +1 -1
  89. package/dist/app/apps/dashboard/.next/server/app/security-fusion/cases/[caseId]/page.js.nft.json +1 -1
  90. package/dist/app/apps/dashboard/.next/server/app/security-fusion/cases/[caseId]/page_client-reference-manifest.js +1 -1
  91. package/dist/app/apps/dashboard/.next/server/app/security-fusion/cases/page.js.nft.json +1 -1
  92. package/dist/app/apps/dashboard/.next/server/app/security-fusion/cases/page_client-reference-manifest.js +1 -1
  93. package/dist/app/apps/dashboard/.next/server/app/security-fusion/entities/page.js.nft.json +1 -1
  94. package/dist/app/apps/dashboard/.next/server/app/security-fusion/entities/page_client-reference-manifest.js +1 -1
  95. package/dist/app/apps/dashboard/.next/server/app/security-fusion/events/page.js.nft.json +1 -1
  96. package/dist/app/apps/dashboard/.next/server/app/security-fusion/events/page_client-reference-manifest.js +1 -1
  97. package/dist/app/apps/dashboard/.next/server/app/security-fusion/evidence/page.js.nft.json +1 -1
  98. package/dist/app/apps/dashboard/.next/server/app/security-fusion/evidence/page_client-reference-manifest.js +1 -1
  99. package/dist/app/apps/dashboard/.next/server/app/security-fusion/page.js.nft.json +1 -1
  100. package/dist/app/apps/dashboard/.next/server/app/security-fusion/page_client-reference-manifest.js +1 -1
  101. package/dist/app/apps/dashboard/.next/server/app/security-fusion/policies/page.js.nft.json +1 -1
  102. package/dist/app/apps/dashboard/.next/server/app/security-fusion/policies/page_client-reference-manifest.js +1 -1
  103. package/dist/app/apps/dashboard/.next/server/app/security-fusion/sources/page.js.nft.json +1 -1
  104. package/dist/app/apps/dashboard/.next/server/app/security-fusion/sources/page_client-reference-manifest.js +1 -1
  105. package/dist/app/apps/dashboard/.next/server/app/skills/page/server-reference-manifest.json +1 -1
  106. package/dist/app/apps/dashboard/.next/server/app/skills/page.js.nft.json +1 -1
  107. package/dist/app/apps/dashboard/.next/server/app/skills/page_client-reference-manifest.js +1 -1
  108. package/dist/app/apps/dashboard/.next/server/app/webhooks/[id]/page.js.nft.json +1 -1
  109. package/dist/app/apps/dashboard/.next/server/app/webhooks/[id]/page_client-reference-manifest.js +1 -1
  110. package/dist/app/apps/dashboard/.next/server/app/webhooks/new/page.js.nft.json +1 -1
  111. package/dist/app/apps/dashboard/.next/server/app/webhooks/new/page_client-reference-manifest.js +1 -1
  112. package/dist/app/apps/dashboard/.next/server/app/webhooks/page.js.nft.json +1 -1
  113. package/dist/app/apps/dashboard/.next/server/app/webhooks/page_client-reference-manifest.js +1 -1
  114. package/dist/app/apps/dashboard/.next/server/chunks/ssr/[root-of-the-server]__08sgyyf_y8ab8._.js +1 -1
  115. package/dist/app/apps/dashboard/.next/server/chunks/ssr/[root-of-the-server]__11pe-l2-ko65_._.js +1 -1
  116. package/dist/app/apps/dashboard/.next/server/chunks/ssr/[root-of-the-server]__1xjrbdi2jn6ud._.js +1 -1
  117. package/dist/app/apps/dashboard/.next/server/chunks/ssr/apps_dashboard_src_0gs_s688kgg1i._.js +1 -1
  118. package/dist/app/apps/dashboard/.next/server/chunks/ssr/apps_dashboard_src_app_cron_page_tsx_1i3duyygc0_tg._.js +1 -1
  119. package/dist/app/apps/dashboard/.next/server/chunks/ssr/apps_dashboard_src_app_nodes_[nodeId]_page_tsx_1q7fqu18oklzc._.js +1 -1
  120. package/dist/app/apps/dashboard/.next/server/chunks/ssr/apps_dashboard_src_app_nodes_nodes-client_tsx_0pt4iarhpqbgn._.js +1 -1
  121. package/dist/app/apps/dashboard/.next/server/chunks/ssr/apps_dashboard_src_app_skills_page_tsx_0n5zp4xad38in._.js +1 -1
  122. package/dist/app/apps/dashboard/.next/server/chunks/ssr/apps_dashboard_src_lib_api-client_ts_0tho-kkk5ez7h._.js +1 -1
  123. package/dist/app/apps/dashboard/.next/server/chunks/ssr/{node_modules_@xterm_1wjdgthvv3w9h._.js → node_modules_@xterm_0b-c6-qudh_kd._.js} +1 -1
  124. package/dist/app/apps/dashboard/.next/server/chunks/ssr/node_modules_lucide-react_dist_esm_icons_refresh-ccw-dot_mjs_0v31ayeyeyyf8._.js +1 -1
  125. package/dist/app/apps/dashboard/.next/server/middleware-build-manifest.js +3 -3
  126. package/dist/app/apps/dashboard/.next/server/pages/500.html +1 -1
  127. package/dist/app/apps/dashboard/.next/server/preview-props.json +3 -3
  128. package/dist/app/apps/dashboard/.next/server/server-reference-manifest.js +1 -1
  129. package/dist/app/apps/dashboard/.next/server/server-reference-manifest.json +3 -3
  130. package/dist/app/apps/dashboard/.next/static/chunks/{1_dc7qj6cn34y.js → 05cz-n3dflda8.js} +1 -1
  131. package/dist/app/apps/dashboard/.next/static/chunks/0a3qf_gj8th4c.js +1 -0
  132. package/dist/app/apps/dashboard/.next/static/chunks/{0lt-ikcy1lvod.js → 16_8wa1m1ffmd.js} +1 -1
  133. package/dist/app/apps/dashboard/.next/static/chunks/{1u_ran46erfqh.js → 17p8kp_-gsxp0.js} +1 -1
  134. package/dist/app/apps/dashboard/.next/static/chunks/{260f1oy-xd4cg.js → 2b5d1hl5rnwmi.js} +1 -1
  135. package/dist/app/apps/dashboard/.next/static/chunks/{3vb0dg3il6-rb.js → 2yfl6coqli4y3.js} +2 -2
  136. package/dist/app/apps/dashboard/.next/static/chunks/{26rmh4jb1a3nq.js → 39c6t_gt5j746.js} +1 -1
  137. package/dist/app/apps/dashboard/.next/static/chunks/3kbm-1q4uj4zs.js +15 -0
  138. package/dist/app/apps/dashboard/.next/static/chunks/{2ksz5ltjd7lss.js → 422r_9lx6bvwu.js} +1 -1
  139. package/dist/app/apps/dashboard/.next/static/chunks/{1v4hz3-8oktml.js → 43f5keprbd6za.js} +1 -1
  140. package/dist/app/apps/dashboard/package.json +2 -2
  141. package/dist/app/apps/dashboard/server.js +1 -1
  142. package/package.json +2 -2
  143. package/dist/app/apps/dashboard/.next/static/chunks/0qfvdc54-_wls.js +0 -15
  144. package/dist/app/apps/dashboard/.next/static/chunks/3q0oq5yy3hszn.js +0 -1
  145. /package/dist/app/apps/dashboard/.next/static/{RJzcgsvLiZvGVu7o2g_Hd → yoKjJcLs0SBAslui78EBu}/_buildManifest.js +0 -0
  146. /package/dist/app/apps/dashboard/.next/static/{RJzcgsvLiZvGVu7o2g_Hd → yoKjJcLs0SBAslui78EBu}/_clientMiddlewareManifest.js +0 -0
  147. /package/dist/app/apps/dashboard/.next/static/{RJzcgsvLiZvGVu7o2g_Hd → yoKjJcLs0SBAslui78EBu}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- (()=>{"use strict";(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,89458,e=>{var s=e.i(43476),a=e.i(71645),t=e.i(82983),r=e.i(4050),l=e.i(93999),n=e.i(68759),i=e.i(46670),c=e.i(31624),o=e.i(32568),d=e.i(84026),x=e.i(32781),m=e.i(77071),p=e.i(59659);function h({open:e,mode:r,role:l,onClose:i,onSaved:c}){let[u,g]=(0,a.useState)(""),[f,b]=(0,a.useState)(""),[j,v]=(0,a.useState)("active"),[N,y]=(0,a.useState)([]),[w,k]=(0,a.useState)(""),[_,C]=(0,a.useState)(""),[S,E]=(0,a.useState)([]),[A,I]=(0,a.useState)(!1),[D,M]=(0,a.useState)(!1),[F,z]=(0,a.useState)(""),[P,R]=(0,a.useState)(""),[L,$]=(0,a.useState)(!1),[O,T]=(0,a.useState)("restrictive"),[G,U]=(0,a.useState)(""),[K,W]=(0,a.useState)(!1),[H,V]=(0,a.useState)(""),[q,B]=(0,a.useState)([]),[J,Y]=(0,a.useState)("basic"),Z=(0,a.useCallback)(async()=>{try{let e=await t.f.library.files.list({pageSize:200});B((e.data??[]).map(e=>({id:e.id,name:e.name,fileName:e.fileName,mimeType:e.mimeType??""})))}catch{}},[]);(0,a.useEffect)(()=>{e&&Z()},[e,Z]),(0,a.useEffect)(()=>{"edit"===r&&l?(g(l.name),b(l.description),v(l.status),y(l.libraryFileIds),k(l.aptPackages.join(", ")),C(l.npmPackages.join(", ")),E(Object.entries(l.envConfig).map(([e,s])=>({key:e,value:s}))),I(l.dockerEnabled),M(l.dockerNonRoot),z(l.dockerImage??""),R((l.dockerVolumes??[]).join("\n")),$(l.firewallEnabled),T(l.firewallMode),U(l.firewallAllowRules.join(", "))):"create"===r&&(g(""),b(""),v("active"),y([]),k(""),C(""),E([{key:"OPENROUTER_API_KEY",value:""}]),I(!1),M(!1),z(""),R(""),$(!1),T("restrictive"),U("")),V(""),Y("basic")},[r,l]);let Q=e=>e.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean),X=async()=>{if(!u.trim())return;W(!0),V("");let e={};for(let s of S)s.key.trim()&&(e[s.key.trim()]=s.value);let s={name:u.trim(),description:f.trim(),status:j,libraryFileIds:N,aptPackages:Q(w),npmPackages:Q(_),envConfig:e,dockerEnabled:A,dockerNonRoot:D,dockerImage:F.trim()||null,dockerVolumes:P.split(/[\n,]+/).map(e=>e.trim()).filter(Boolean),firewallEnabled:L,firewallMode:O,firewallAllowRules:Q(G)};try{"create"===r?await t.f.roles.create(s):l&&await t.f.roles.update(l.id,s),c(),ee()}catch(e){V(e instanceof Error?e.message:"Failed to save role")}finally{W(!1)}},ee=()=>{V(""),W(!1),i()},es=(e,s,a)=>{let t=[...S],r=t[e];r&&(t[e]={key:"key"===s?a:r.key,value:"value"===s?a:r.value}),E(t)},ea=e=>{y(s=>s.includes(e)?s.filter(s=>s!==e):[...s,e])},et=q.filter(e=>"application/x-magnus-skill"===e.mimeType),er=q.filter(e=>"application/x-magnus-cronjob"===e.mimeType);return(0,s.jsxs)(o.n,{open:e,onClose:ee,title:"create"===r?"Create Role":"Edit Role",description:"create"===r?"Define a reusable configuration for nodes":`Editing ${l?.name??""}`,icon:(0,s.jsx)(d.f,{className:"h-5 w-5 text-primary"}),className:"max-w-2xl",children:[(0,s.jsx)("div",{className:"flex gap-1 mb-4 border-b border-border pb-2",children:[{key:"basic",label:"Basic"},{key:"packages",label:"Packages & Env"},{key:"files",label:"Skills & Jobs"},{key:"docker",label:"Docker"},{key:"firewall",label:"Firewall"}].map(e=>(0,s.jsx)("button",{onClick:()=>Y(e.key),className:`px-3 py-1.5 text-xs font-bold rounded transition-all ${J===e.key?"bg-primary/10 text-primary border border-primary/50":"text-text-muted hover:text-text hover:bg-surface-hover border border-transparent"}`,children:e.label},e.key))}),(0,s.jsxs)("div",{className:"space-y-4 max-h-[60vh] overflow-y-auto pr-1",children:["basic"===J&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.G,{label:"Role Name",required:!0,children:(0,s.jsx)("input",{type:"text",value:u,onChange:e=>g(e.target.value),placeholder:"web-server",className:o.W,autoFocus:!0})}),(0,s.jsx)(o.G,{label:"Description",children:(0,s.jsx)("textarea",{value:f,onChange:e=>b(e.target.value),placeholder:"Standard web server role with Nginx and monitoring...",rows:3,className:o.M})}),(0,s.jsx)(o.G,{label:"Status",children:(0,s.jsxs)("select",{value:j,onChange:e=>v(e.target.value),className:o.N,children:[(0,s.jsx)("option",{value:"active",children:"Active"}),(0,s.jsx)("option",{value:"draft",children:"Draft"})]})})]}),"packages"===J&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(o.G,{label:"APT Packages",children:[(0,s.jsx)("input",{type:"text",value:w,onChange:e=>k(e.target.value),placeholder:"nginx, curl, htop, jq",className:o.W}),(0,s.jsx)("p",{className:"mt-1 text-xs text-text-muted",children:"Comma-separated package names"})]}),(0,s.jsxs)(o.G,{label:"NPM Global Packages",children:[(0,s.jsx)("input",{type:"text",value:_,onChange:e=>C(e.target.value),placeholder:"pm2, tsx",className:o.W}),(0,s.jsx)("p",{className:"mt-1 text-xs text-text-muted",children:"Comma-separated package names"})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,s.jsx)("label",{className:"text-[11px] font-bold uppercase tracking-wider text-text-muted",children:"Environment Variables"}),(0,s.jsxs)("button",{onClick:()=>{E([...S,{key:"",value:""}])},className:"flex items-center gap-1 text-xs text-primary hover:text-primary-hover",children:[(0,s.jsx)(m.f,{className:"h-3 w-3"})," Add"]})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[S.map((e,a)=>(0,s.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,s.jsx)("input",{type:"text",value:e.key,onChange:e=>es(a,"key",e.target.value),placeholder:"KEY_NAME",className:`${o.W} flex-1`}),(0,s.jsx)("input",{type:"password",value:e.value,onChange:e=>es(a,"value",e.target.value),placeholder:"value",className:`${o.W} flex-1`}),(0,s.jsx)("button",{onClick:()=>{E(S.filter((e,s)=>s!==a))},className:"text-text-muted hover:text-danger p-1",children:(0,s.jsx)(p.f,{className:"h-3.5 w-3.5"})})]},a)),0===S.length&&(0,s.jsx)("p",{className:"text-xs text-text-muted py-2",children:"No environment variables configured"})]})]})]}),"files"===J&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-[11px] font-bold uppercase tracking-wider text-text-muted mb-1.5",children:"Skills from Library"}),(0,s.jsx)("div",{className:"max-h-40 overflow-y-auto rounded border border-border bg-bg p-2 space-y-1",children:0===et.length?(0,s.jsx)("p",{className:"px-2 py-1 text-xs text-text-muted",children:"No skills in library — publish skills from the Skills page"}):et.map(e=>(0,s.jsxs)("label",{className:"flex items-center gap-2 rounded px-2 py-1.5 hover:bg-surface-hover hover:shadow-[0_0_20px_var(--color-glow)] cursor-pointer transition-all",children:[(0,s.jsx)("input",{type:"checkbox",checked:N.includes(e.id),onChange:()=>ea(e.id),className:"accent-primary"}),(0,s.jsx)("span",{className:"text-xs",children:e.name}),(0,s.jsx)("span",{className:"text-xs text-text-muted ml-auto",children:e.fileName})]},e.id))})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-[11px] font-bold uppercase tracking-wider text-text-muted mb-1.5",children:"Cron Jobs from Library"}),(0,s.jsx)("div",{className:"max-h-40 overflow-y-auto rounded border border-border bg-bg p-2 space-y-1",children:0===er.length?(0,s.jsx)("p",{className:"px-2 py-1 text-xs text-text-muted",children:"No cron jobs in library — publish jobs from the Cron page"}):er.map(e=>(0,s.jsxs)("label",{className:"flex items-center gap-2 rounded px-2 py-1.5 hover:bg-surface-hover hover:shadow-[0_0_20px_var(--color-glow)] cursor-pointer transition-all",children:[(0,s.jsx)("input",{type:"checkbox",checked:N.includes(e.id),onChange:()=>ea(e.id),className:"accent-primary"}),(0,s.jsx)("span",{className:"text-xs",children:e.name}),(0,s.jsx)("span",{className:"text-xs text-text-muted ml-auto",children:e.fileName})]},e.id))})]})]}),"docker"===J&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.G,{label:"Docker Sandboxing",children:(0,s.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,s.jsx)("input",{type:"checkbox",checked:A,onChange:e=>I(e.target.checked),className:"accent-primary h-4 w-4"}),(0,s.jsx)("span",{className:"text-xs",children:"Run workload inside Docker container"})]})}),A&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.G,{label:"Non-Root User",children:(0,s.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,s.jsx)("input",{type:"checkbox",checked:D,onChange:e=>M(e.target.checked),className:"accent-primary h-4 w-4"}),(0,s.jsx)("span",{className:"text-xs",children:"Run as non-root user inside container"})]})}),(0,s.jsxs)(o.G,{label:"Custom Docker Image",children:[(0,s.jsx)("input",{type:"text",value:F,onChange:e=>z(e.target.value),placeholder:"node:22-slim (default)",className:o.W}),(0,s.jsx)("p",{className:"mt-1 text-xs text-text-muted",children:"Leave empty for default node:22-slim"})]}),(0,s.jsxs)(o.G,{label:"Volume Mounts",children:[(0,s.jsx)("textarea",{value:P,onChange:e=>R(e.target.value),placeholder:"/host/path:/container/path (one per line)",rows:3,className:o.W}),(0,s.jsx)("p",{className:"mt-1 text-xs text-text-muted",children:"One volume mount per line, e.g. /mnt/data/output:/mnt/data/output"})]})]}),!A&&(0,s.jsx)("div",{className:"rounded border border-border bg-bg/50 p-4 text-center",children:(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Enable Docker sandboxing to run workloads in an isolated container with optional non-root user."})})]}),"firewall"===J&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.G,{label:"UFW Firewall",children:(0,s.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,s.jsx)("input",{type:"checkbox",checked:L,onChange:e=>$(e.target.checked),className:"accent-primary h-4 w-4"}),(0,s.jsx)("span",{className:"text-xs",children:"Enable UFW firewall on the node"})]})}),L&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.G,{label:"Firewall Mode",children:(0,s.jsxs)("select",{value:O,onChange:e=>T(e.target.value),className:o.N,children:[(0,s.jsx)("option",{value:"restrictive",children:"Restrictive — Block private LAN, allow SSH + Magnus"}),(0,s.jsx)("option",{value:"permissive",children:"Permissive — Allow SSH + Magnus only"}),(0,s.jsx)("option",{value:"custom",children:"Custom — Define your own rules"})]})}),"restrictive"===O&&(0,s.jsxs)("div",{className:"rounded border border-warning/20 bg-warning/10 px-3 py-2 text-[11px] text-warning",children:[(0,s.jsx)("p",{className:"font-bold text-[10px] uppercase tracking-wider",children:"Auto-configured rules:"}),(0,s.jsxs)("ul",{className:"text-xs mt-1 space-y-0.5 text-warning/80",children:[(0,s.jsx)("li",{children:"• Allow SSH (port 22)"}),(0,s.jsx)("li",{children:"• Allow Magnus agent port (4100)"}),(0,s.jsx)("li",{children:"• Allow from control-api IP"}),(0,s.jsx)("li",{children:"• Deny 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16"})]})]}),"custom"===O&&(0,s.jsxs)(o.G,{label:"Custom Allow Rules",children:[(0,s.jsx)("input",{type:"text",value:G,onChange:e=>U(e.target.value),placeholder:"80/tcp, 443/tcp, 10.0.0.5",className:o.W}),(0,s.jsx)("p",{className:"mt-1 text-xs text-text-muted",children:"Comma-separated. Port rules (80/tcp) or IP allow rules (10.0.0.5). SSH + Magnus agent are always allowed."})]})]}),!L&&(0,s.jsx)("div",{className:"rounded border border-border bg-bg/50 p-4 text-center",children:(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Enable UFW to firewall the node away from local networks while preserving Magnus agent communication."})})]})]}),H&&(0,s.jsx)("div",{className:"mt-4 rounded border border-danger/30 bg-danger/10 px-3 py-2 text-[11px] text-danger",children:H}),(0,s.jsxs)("div",{className:"flex justify-end gap-2 pt-4 mt-4 border-t border-border",children:[(0,s.jsx)(n.K,{variant:"secondary",size:"sm",onClick:ee,children:"Cancel"}),(0,s.jsx)(n.K,{size:"sm",onClick:()=>void X(),disabled:K||!u.trim(),icon:K?(0,s.jsx)(x.f,{className:"h-3.5 w-3.5 animate-spin"}):void 0,children:K?"Saving…":"create"===r?"Create Role":"Save Changes"})]})]})}var u=e.i(63376),g=e.i(15281),f=e.i(21357),b=e.i(56420);let j={name:"user-minus",size:24,node:[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]};j.node;let v=(0,b.f)(j);var N=e.i(41220),y=e.i(79258),w=e.i(26091);let k={name:"container",size:24,node:[["path",{d:"M22 7.7c0-.6-.4-1.2-.8-1.5l-6.3-3.9a1.72 1.72 0 0 0-1.7 0l-10.3 6c-.5.2-.9.8-.9 1.4v6.6c0 .5.4 1.2.8 1.5l6.3 3.9a1.72 1.72 0 0 0 1.7 0l10.3-6c.5-.3.9-1 .9-1.5Z",key:"1t2lqe"}],["path",{d:"M10 21.9V14L2.1 9.1",key:"o7czzq"}],["path",{d:"m10 14 11.9-6.9",key:"zm5e20"}],["path",{d:"M14 19.8v-8.1",key:"159ecu"}],["path",{d:"M18 17.5V9.4",key:"11uown"}]]};k.node;let _=(0,b.f)(k);var C=e.i(82954),S=e.i(41120),E=e.i(67927),A=e.i(51757),I=e.i(83967),D=e.i(74544),M=e.i(99847);let F={name:"skip-forward",size:24,node:[["path",{d:"M21 4v16",key:"7j8fe9"}],["path",{d:"M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z",key:"zs4d6"}]]};F.node;let z=(0,b.f)(F);e.s(["default",0,function({initialRoles:e}){let{activeNode:o}=(0,r.l)(),[b,j]=(0,a.useState)(e),[k,F]=(0,a.useState)(null),[P,R]=(0,a.useState)([]),[L,$]=(0,a.useState)(!e.length),[O,T]=(0,a.useState)(e.length>0),[G,U]=(0,a.useState)(!1),[K,W]=(0,a.useState)("create"),[H,V]=(0,a.useState)(null),[q,B]=(0,a.useState)(!1),[J,Y]=(0,a.useState)([]),[Z,Q]=(0,a.useState)(!1),[X,ee]=(0,a.useState)(!1),es=(0,a.useCallback)(async()=>{try{let e=await t.f.roles.list();j(e.data??[])}catch{}finally{$(!1)}},[]),ea=(0,a.useCallback)(async e=>{try{let[s,a]=await Promise.all([t.f.roles.get(e),t.f.roles.applications.list({roleId:e})]),r=s.data;F(r),R(a.data??[])}catch{}},[]);(0,a.useEffect)(()=>{O?T(!1):es()},[es,o.id]),(0,a.useEffect)(()=>{if(!k)return;let e=setInterval(()=>{ea(k.id)},5e3);return()=>clearInterval(e)},[k,ea]);let et=()=>{W("create"),V(null),U(!0)},er=async e=>{if(confirm(`Delete role "${e.name}"? This will unassign all nodes.`))try{await t.f.roles.delete(e.id),k?.id===e.id&&F(null),await es()}catch{}},el=async()=>{await es(),k&&await ea(k.id)},en=async()=>{if(k&&0!==J.length){ee(!0);try{await t.f.roles.assign(k.id,{nodeIds:J,defer:Z}),B(!1),Y([]),await ea(k.id),await es()}catch{}finally{ee(!1)}}},ei=async e=>{if(k&&confirm("Unassign this node? This will remove the role configuration."))try{await t.f.roles.unassign(k.id,{nodeIds:[e]}),await ea(k.id),await es()}catch{}},ec=async()=>{if(k)try{await t.f.roles.apply(k.id),await ea(k.id)}catch{}};return(0,s.jsxs)(u.U,{className:"space-y-6",children:[(0,s.jsx)(u.z,{children:(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"text-lg font-bold uppercase tracking-wider",children:"Roles"}),(0,s.jsx)("p",{className:"mt-1 text-[11px] text-text-muted uppercase tracking-wider",children:"Define reusable node configurations with packages, files, Docker sandboxing, and firewall rules"})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(n.K,{variant:"secondary",size:"sm",onClick:()=>void es(),icon:(0,s.jsx)(S.f,{className:"h-3.5 w-3.5"}),children:"Refresh"}),(0,s.jsx)(n.K,{size:"sm",onClick:et,icon:(0,s.jsx)(m.f,{className:"h-3.5 w-3.5"}),children:"New Role"})]})]})}),(0,s.jsx)(u.z,{children:(0,s.jsxs)("div",{className:"grid grid-cols-12 gap-6",children:[(0,s.jsx)("div",{className:"col-span-4",children:(0,s.jsx)(l.N,{children:L?(0,s.jsx)("div",{className:"flex justify-center py-8",children:(0,s.jsx)(x.f,{className:"h-6 w-6 animate-spin text-text-muted"})}):0===b.length?(0,s.jsxs)("div",{className:"text-center py-8",children:[(0,s.jsx)(d.f,{className:"mx-auto h-10 w-10 text-text-muted mb-2"}),(0,s.jsx)("p",{className:"text-[11px] text-text-muted",children:"No roles yet"}),(0,s.jsx)(n.K,{size:"sm",className:"mt-3",onClick:et,icon:(0,s.jsx)(m.f,{className:"h-3.5 w-3.5"}),children:"Create First Role"})]}):(0,s.jsx)("div",{className:"space-y-1",children:b.map(e=>(0,s.jsxs)("button",{onClick:()=>{F(e),ea(e.id)},className:`w-full text-left rounded px-3 py-3 transition-all ${k?.id===e.id?"bg-primary/10 border border-primary/50":"hover:bg-surface-hover hover:border-primary/30 hover:shadow-[0_0_20px_var(--color-glow)] border border-transparent"}`,children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,s.jsx)("span",{className:"text-[11px] font-bold",children:e.name}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)(i.t,{variant:"active"===e.status?"success":"warning",children:e.status}),(0,s.jsx)(E.f,{className:"h-3.5 w-3.5 text-text-muted"})]})]}),e.description&&(0,s.jsx)("p",{className:"text-xs text-text-muted truncate mb-1.5",children:e.description}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex flex-wrap gap-1",children:[e.aptPackages.length>0&&(0,s.jsxs)("span",{className:"inline-flex items-center rounded bg-success/10 px-1.5 py-0.5 text-[10px] text-success",children:[e.aptPackages.length," apt"]}),e.npmPackages.length>0&&(0,s.jsxs)("span",{className:"inline-flex items-center rounded bg-warning/10 px-1.5 py-0.5 text-[10px] text-warning",children:[e.npmPackages.length," npm"]}),e.libraryFileIds.length>0&&(0,s.jsxs)("span",{className:"inline-flex items-center rounded bg-primary/10 px-1.5 py-0.5 text-[10px] text-primary",children:[e.libraryFileIds.length," library"]}),e.dockerEnabled&&(0,s.jsx)("span",{className:"inline-flex items-center rounded bg-primary/10 px-1.5 py-0.5 text-[10px] text-primary",children:"Docker"}),e.firewallEnabled&&(0,s.jsx)("span",{className:"inline-flex items-center rounded bg-warning/10 px-1.5 py-0.5 text-[10px] text-warning",children:"UFW"})]}),(0,s.jsxs)("span",{className:"text-xs text-text-muted flex items-center gap-1",children:[(0,s.jsx)(N.f,{className:"h-3 w-3"}),e._count?.nodes??0]})]})]},e.id))})})}),(0,s.jsx)("div",{className:"col-span-8",children:k?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)(l.N,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("h2",{className:"text-lg font-bold",children:k.name}),(0,s.jsx)(i.t,{variant:"active"===k.status?"success":"warning",children:k.status})]}),k.description&&(0,s.jsx)("p",{className:"text-[11px] text-text-muted mt-1",children:k.description})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(n.K,{variant:"secondary",size:"sm",onClick:()=>{W("edit"),V(k),U(!0)},icon:(0,s.jsx)(g.f,{className:"h-3.5 w-3.5"}),children:"Edit"}),(0,s.jsx)(n.K,{variant:"danger",size:"sm",onClick:()=>void er(k),icon:(0,s.jsx)(p.f,{className:"h-3.5 w-3.5"}),children:"Delete"})]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsxs)("div",{className:"rounded border border-border bg-bg p-3 hover:border-primary/30 hover:shadow-[0_0_20px_var(--color-glow)] transition-all",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,s.jsx)(y.f,{className:"h-4 w-4 text-success"}),(0,s.jsx)("span",{className:"text-[11px] font-bold uppercase tracking-wider",children:"Packages"})]}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:k.aptPackages.length>0?`apt: ${k.aptPackages.join(", ")}`:"No apt packages"}),(0,s.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:k.npmPackages.length>0?`npm: ${k.npmPackages.join(", ")}`:"No npm packages"}),Object.keys(k.envConfig).length>0&&(0,s.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:[Object.keys(k.envConfig).length," env var(s): ",Object.keys(k.envConfig).join(", ")]})]}),(0,s.jsxs)("div",{className:"rounded border border-border bg-bg p-3 hover:border-primary/30 hover:shadow-[0_0_20px_var(--color-glow)] transition-all",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,s.jsx)(w.f,{className:"h-4 w-4 text-primary"}),(0,s.jsx)("span",{className:"text-[11px] font-bold uppercase tracking-wider",children:"Skills & Jobs"})]}),(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:[k.libraryFileIds.length," library item(s) assigned"]})]}),(0,s.jsxs)("div",{className:"rounded border border-border bg-bg p-3 hover:border-primary/30 hover:shadow-[0_0_20px_var(--color-glow)] transition-all",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,s.jsxs)("div",{className:"flex gap-1.5",children:[(0,s.jsx)(_,{className:"h-4 w-4 text-primary"}),(0,s.jsx)(C.f,{className:"h-4 w-4 text-warning"})]}),(0,s.jsx)("span",{className:"text-[11px] font-bold uppercase tracking-wider",children:"Sandbox & Firewall"})]}),(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["Docker: ",k.dockerEnabled?`Enabled${k.dockerNonRoot?" (non-root)":""}`:"Disabled"]}),(0,s.jsxs)("p",{className:"text-xs text-text-muted mt-0.5",children:["Firewall: ",k.firewallEnabled?`${k.firewallMode} mode`:"Disabled"]})]})]})]}),(0,s.jsxs)(l.N,{title:"Assigned Nodes",action:(0,s.jsxs)("div",{className:"flex gap-2",children:[(k.nodes?.length??0)>0&&(0,s.jsx)(n.K,{variant:"secondary",size:"sm",onClick:()=>void ec(),icon:(0,s.jsx)(S.f,{className:"h-3.5 w-3.5"}),children:"Re-apply All"}),(0,s.jsx)(n.K,{size:"sm",onClick:()=>B(!0),icon:(0,s.jsx)(m.f,{className:"h-3.5 w-3.5"}),children:"Assign Nodes"})]}),children:[k.nodes&&0!==k.nodes.length?(0,s.jsx)("div",{className:"space-y-1",children:k.nodes.map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between rounded border border-border bg-bg px-3 py-2 hover:border-primary/30 hover:shadow-[0_0_20px_var(--color-glow)] transition-all",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(N.f,{className:"h-4 w-4 text-text-muted"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-[11px] font-bold",children:e.name}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:e.hostname})]}),(0,s.jsx)(i.t,{variant:(0,i.k)(e.status),children:e.status})]}),(0,s.jsx)(n.K,{variant:"ghost",size:"sm",onClick:()=>void ei(e.id),icon:(0,s.jsx)(v,{className:"h-3.5 w-3.5"}),children:"Unassign"})]},e.id))}):(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)(N.f,{className:"mx-auto h-8 w-8 text-text-muted mb-2"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"No nodes assigned to this role"})]}),q&&(0,s.jsxs)("div",{className:"mt-4 rounded border border-primary/30 bg-primary/5 p-4",children:[(0,s.jsxs)("h4",{className:"text-[11px] font-bold uppercase tracking-wider mb-3",children:['Assign Nodes to "',k.name,'"']}),(0,s.jsx)(c.f,{value:J,onChange:e=>Y(e),multi:!0,showAll:!0,label:"Select nodes"}),(0,s.jsxs)("label",{className:"flex items-center gap-2 mt-3 cursor-pointer",children:[(0,s.jsx)("input",{type:"checkbox",checked:Z,onChange:e=>Q(e.target.checked),className:"accent-primary"}),(0,s.jsx)("span",{className:"text-xs text-text-muted",children:"Defer application (assign only, don't apply yet)"})]}),(0,s.jsxs)("div",{className:"flex justify-end gap-2 mt-3",children:[(0,s.jsx)(n.K,{variant:"secondary",size:"sm",onClick:()=>{B(!1),Y([])},children:"Cancel"}),(0,s.jsx)(n.K,{size:"sm",onClick:()=>void en(),disabled:X||0===J.length,icon:X?(0,s.jsx)(x.f,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(f.f,{className:"h-3.5 w-3.5"}),children:X?"Assigning…":`Assign ${J.length} Node(s)`})]})]})]}),(0,s.jsx)(l.N,{title:"Application History",description:"Recent role apply/remove operations",children:0===P.length?(0,s.jsx)("p",{className:"text-xs text-text-muted py-4 text-center",children:"No applications yet"}):(0,s.jsx)("div",{className:"space-y-3",children:P.slice(0,10).map(e=>(0,s.jsxs)("div",{className:"rounded border border-border bg-bg p-3 hover:border-primary/30 transition-all",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(i.t,{variant:"apply"===e.action?"info":"warning",children:e.action}),(0,s.jsx)("span",{className:"text-xs text-text-muted",children:e.node?.name??e.nodeId})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(i.t,{variant:(0,i.k)(e.status),children:e.status}),(0,s.jsx)("span",{className:"text-xs text-text-muted",children:new Date(e.createdAt).toLocaleString()})]})]}),e.steps.length>0&&(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:e.steps.map((e,a)=>(0,s.jsxs)("div",{className:"flex items-center gap-1.5 rounded bg-surface px-2 py-1",title:e.error??e.name,children:[(e=>{switch(e){case"completed":return(0,s.jsx)(A.f,{className:"h-3.5 w-3.5 text-success"});case"failed":return(0,s.jsx)(I.f,{className:"h-3.5 w-3.5 text-danger"});case"running":return(0,s.jsx)(x.f,{className:"h-3.5 w-3.5 text-primary animate-spin"});case"skipped":return(0,s.jsx)(z,{className:"h-3.5 w-3.5 text-text-muted"});default:return(0,s.jsx)(D.f,{className:"h-3.5 w-3.5 text-text-muted"})}})(e.status),(0,s.jsx)("span",{className:"text-[11px] text-text-muted",children:e.name})]},a))}),e.error&&(0,s.jsxs)("div",{className:"mt-2 flex items-start gap-1.5 text-xs text-danger",children:[(0,s.jsx)(M.f,{className:"h-3.5 w-3.5 mt-0.5 flex-shrink-0"}),(0,s.jsx)("span",{className:"truncate",children:e.error})]})]},e.id))})})]}):(0,s.jsx)(l.N,{children:(0,s.jsxs)("div",{className:"text-center py-16",children:[(0,s.jsx)(d.f,{className:"mx-auto h-12 w-12 text-text-muted mb-3"}),(0,s.jsx)("p",{className:"text-[11px] text-text-muted",children:"Select a role to view details"})]})})})]})}),(0,s.jsx)(h,{open:G,mode:K,role:H,onClose:()=>U(!1),onSaved:()=>void el()})]})}],89458)},46670,e=>{var s=e.i(43476),a=e.i(78571);let t={default:"border-border text-text-muted",success:"border-success/40 text-success bg-success/5 shadow-[0_0_6px_rgba(0,255,65,0.15)]",warning:"border-warning/40 text-warning bg-warning/5 shadow-[0_0_6px_rgba(255,179,0,0.15)]",danger:"border-danger/40 text-danger bg-danger/5 shadow-[0_0_6px_rgba(255,23,68,0.15)]",info:"border-info/40 text-info bg-info/5 shadow-[0_0_6px_rgba(0,176,255,0.15)]"},r={default:"bg-text-muted",success:"bg-success",warning:"bg-warning",danger:"bg-danger",info:"bg-info"};e.s(["t",0,function({children:e,variant:l="default",className:n,dot:i=!1,pulse:c=!1}){return(0,s.jsxs)("span",{className:(0,a.f)("inline-flex items-center gap-1.5 rounded-chip border px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider",t[l],n),children:[i&&(0,s.jsxs)("span",{"aria-hidden":"true",className:"relative inline-flex h-1.5 w-1.5",children:[c&&(0,s.jsx)("span",{className:(0,a.f)("absolute inset-0 rounded-full animate-halo",r[l])}),(0,s.jsx)("span",{className:(0,a.f)("relative inline-flex h-1.5 w-1.5 rounded-full",r[l])})]}),e]})},"k",0,function(e){switch(e.toUpperCase()){case"ONLINE":case"COMPLETED":case"ACTIVE":case"RUNNING":case"INSTALLED":case"HEALTHY":return"success";case"DEGRADED":case"PAUSED":case"QUEUED":case"PENDING":case"INSTALLING":return"warning";case"OFFLINE":case"FAILED":case"ERROR":case"TIMEOUT":case"CANCELLED":case"DECOMMISSIONED":case"CRITICAL":return"danger";case"PROVISIONING":case"UPDATING":return"info";default:return"default"}}])},93999,51196,55427,e=>{var s=e.i(43476),a=e.i(56420);let t={name:"arrow-down-right",size:24,node:[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]]};t.node;let r=(0,a.f)(t);var l=e.i(75775),n=e.i(78571),i=e.i(3062),c=e.i(35084);let o={warning:"shadow-[0_0_6px_var(--color-warning)]",danger:"shadow-[0_0_8px_var(--color-danger)]",accent:"shadow-[0_0_6px_var(--color-accent)]",primary:"shadow-[0_0_6px_var(--color-primary)]"},d={xs:"h-1",sm:"h-1.5",md:"h-2"};function x({value:e,max:a=100,tone:t,thresholds:r=c.q,label:l,size:i="xs",showValue:m=!1,valueLabel:p,glow:h,className:u,testId:g}){let f="number"==typeof e&&Number.isFinite(e),b=f?Math.max(0,Math.min(100,e/(a||1)*100)):0,j=t??(f?(0,c.Z)(b,r):"muted"),v=h||!t&&f&&b>=r.warn,N=p??(f?`${b.toFixed(+(b<10&&b>0))}%`:"—");return(0,s.jsxs)("div",{className:(0,n.f)("flex min-w-0 items-center gap-2",u),"data-testid":g,children:[(0,s.jsx)("div",{role:"meter","aria-label":l,"aria-valuemin":0,"aria-valuemax":a,"aria-valuenow":f?e:void 0,"aria-valuetext":N,className:(0,n.f)("relative flex-1 overflow-hidden rounded-full bg-border/70",d[i]),children:(0,s.jsx)("div",{style:{"--meter":`${b}%`},className:(0,n.f)("h-full w-(--meter) rounded-full transition-[width] duration-700 ease-out-expo starting:w-0",c.H[j],v&&o[j])})}),m&&(0,s.jsx)("span",{className:(0,n.f)("num w-11 shrink-0 text-right text-[11px]",f?c.T[j]:"text-text-muted"),children:N})]})}e.s(["f",0,x],51196);var m=e.i(71645);function p({values:e,tone:a="primary",width:t=160,height:r=32,area:l=!0,max:i,percent:o=!1,threshold:d,live:x=!0,emptyLabel:h="not enough data",className:u,testId:g,label:f,stretch:b=!1}){let j=`spark${(0,m.useId)().replace(/:/g,"")}`;if(e.length<2)return(0,s.jsx)("div",{className:(0,n.f)("flex h-8 items-center text-xs italic text-text-muted",u),"data-testid":g,children:h});let v=c.v[a],N=i??(o?Math.max(100,...e):Math.max(...e,d??0)||1),y=r-4,w=t/(e.length-1),k=e=>2+y-Math.max(0,e)/N*y,_=e.map((e,s)=>[s*w,k(e)]),C=_.map(([e,s])=>`${e.toFixed(1)},${s.toFixed(1)}`).join(" "),S=_[_.length-1];return(0,s.jsxs)("svg",{width:b?"100%":t,height:r,viewBox:`0 0 ${t} ${r}`,preserveAspectRatio:b?"none":void 0,className:(0,n.f)("block overflow-visible",u),"data-testid":g,role:f?"img":void 0,"aria-label":f,"aria-hidden":!f||void 0,children:[l&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("defs",{children:(0,s.jsxs)("linearGradient",{id:j,x1:"0",x2:"0",y1:"0",y2:"1",children:[(0,s.jsx)("stop",{offset:"0%",stopColor:v,stopOpacity:.35}),(0,s.jsx)("stop",{offset:"100%",stopColor:v,stopOpacity:0})]})}),(0,s.jsx)("polygon",{points:`0,${r} ${C} ${t},${r}`,fill:`url(#${j})`})]}),void 0!==d&&(0,s.jsx)("line",{x1:0,x2:t,y1:k(d),y2:k(d),stroke:"var(--color-warning)",strokeOpacity:.5,strokeDasharray:"3 3",strokeWidth:1}),(0,s.jsx)("polyline",{fill:"none",stroke:v,strokeWidth:1.5,vectorEffect:"non-scaling-stroke",strokeLinejoin:"round",strokeLinecap:"round",points:C}),x&&!b&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("circle",{cx:S[0],cy:S[1],r:2.5,fill:v,className:"origin-center animate-halo [transform-box:fill-box]"}),(0,s.jsx)("circle",{cx:S[0],cy:S[1],r:2,fill:v})]})]})}e.s(["f",0,p],55427),e.s(["N",0,function({title:e,description:a,children:t,className:r,action:l,tone:n,corners:c=!1,...o}){return(0,s.jsx)(i.f,{...o,tone:n,corners:c,title:e,description:a,action:l,className:r,children:t})},"n",0,function({label:e,value:a,icon:t,trend:o,spark:d,meter:m,delta:h,tone:u="primary",className:g,testId:f}){let b=!h||h.value>=0===(h.positiveIsGood??!0);return(0,s.jsxs)(i.f,{tone:u,className:(0,n.f)("overflow-hidden",g),testId:f,children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-[10px] font-medium uppercase tracking-[0.15em] text-text-muted",children:e}),t&&(0,s.jsx)("span",{className:"text-primary/60",children:t})]}),(0,s.jsxs)("div",{className:"mt-2 flex items-end justify-between gap-2",children:[(0,s.jsx)("div",{className:(0,n.f)("num text-2xl font-bold","primary"===u?"text-primary neon-text":c.T[u]),children:a}),h&&0!==h.value&&(0,s.jsxs)("span",{className:(0,n.f)("num mb-1 inline-flex items-center gap-0.5 text-[11px]",b?"text-success":"text-danger"),children:[h.value>0?(0,s.jsx)(l.f,{className:"h-3 w-3"}):(0,s.jsx)(r,{className:"h-3 w-3"}),Math.abs(h.value).toFixed(+!Number.isInteger(h.value)),h.unit]})]}),o&&(0,s.jsx)("div",{className:(0,n.f)("mt-1 text-[11px]",o.positive?"text-success":"text-danger"),children:o.value}),void 0!==m&&(0,s.jsx)(x,{value:m,className:"mt-3",label:e}),d&&d.length>1&&(0,s.jsx)("div",{className:"-mx-5 -mb-5 mt-3 opacity-80",children:(0,s.jsx)(p,{values:d,tone:u,width:240,height:28,stretch:!0,live:!1})})]})}],93999)},3062,e=>{var s=e.i(43476),a=e.i(78571),t=e.i(35084);let r={primary:"[--panel-corner-color:color-mix(in_srgb,var(--color-primary)_60%,transparent)]",accent:"[--panel-corner-color:color-mix(in_srgb,var(--color-accent)_70%,transparent)]",success:"[--panel-corner-color:color-mix(in_srgb,var(--color-success)_60%,transparent)]",warning:"[--panel-corner-color:color-mix(in_srgb,var(--color-warning)_70%,transparent)]",danger:"[--panel-corner-color:color-mix(in_srgb,var(--color-danger)_70%,transparent)]",info:"[--panel-corner-color:color-mix(in_srgb,var(--color-info)_60%,transparent)]",muted:"[--panel-corner-color:var(--color-border-strong)]"},l={primary:"[--glow-hover-color:var(--color-glow)]",accent:"[--glow-hover-color:var(--color-glow-accent)]",success:"[--glow-hover-color:var(--color-glow-success)]",warning:"[--glow-hover-color:var(--color-glow-warning)]",danger:"[--glow-hover-color:var(--color-glow-danger)]",info:"[--glow-hover-color:var(--color-glow)]",muted:"[--glow-hover-color:var(--color-glow)]"},n={primary:"hover:border-primary/30",accent:"hover:border-accent/40",success:"hover:border-success/30",warning:"hover:border-warning/40",danger:"hover:border-danger/40",info:"hover:border-info/30",muted:"hover:border-border-strong"},i={none:"",sm:"p-3",md:"p-5",lg:"p-6"};e.s(["f",0,function({tone:e="primary",corners:c=!0,interactive:o=!0,hero:d=!1,title:x,description:m,icon:p,action:h,as:u="div",padding:g="md",testId:f,className:b,children:j,...v}){return(0,s.jsxs)(u,{...v,"data-testid":f??v["data-testid"],className:(0,a.f)("relative rounded-panel border border-border bg-surface transition-colors duration-300",i[g],c&&"panel-corners",c&&r[e],o&&"glow-hover",o&&l[e],o&&n[e],d&&"grid-bg overflow-hidden bg-surface/80",b),children:[(x||h||p)&&(0,s.jsxs)("div",{className:"mb-4 flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-start gap-2",children:[p&&(0,s.jsx)("span",{className:(0,a.f)("mt-0.5 shrink-0",t.T[e]),children:p}),(0,s.jsxs)("div",{className:"min-w-0",children:[x&&(0,s.jsx)("h3",{className:"text-xs font-bold uppercase tracking-wider",children:x}),m&&(0,s.jsx)("p",{className:"mt-0.5 text-[11px] text-text-muted",children:m})]})]}),h]}),j]})}])},31624,e=>{var s=e.i(43476),a=e.i(71645),t=e.i(82983),r=e.i(41220);e.s(["f",0,function({value:e,onChange:l,multi:n=!1,showAll:i=!1,label:c="Node",placeholder:o="Select a node…",className:d="",disabled:x=!1}){let[m,p]=(0,a.useState)([]),[h,u]=(0,a.useState)(!0);if((0,a.useEffect)(()=>{(async()=>{try{let e=(await t.f.nodes.list({pageSize:100})).data??[];p(e)}catch{}finally{u(!1)}})()},[]),n){let a=Array.isArray(e)?e:e?[e]:[],t=a.length===m.length&&m.length>0,n=m.filter(e=>"ONLINE"===e.status);return(0,s.jsxs)("div",{className:d,children:[c&&(0,s.jsx)("label",{className:"mb-1 block text-[11px] font-bold uppercase tracking-wider text-text-muted",children:c}),(0,s.jsx)("div",{className:"max-h-48 overflow-y-auto rounded border border-border bg-bg p-2 space-y-1",children:h?(0,s.jsx)("p",{className:"px-2 py-1 text-xs text-text-muted",children:"Loading nodes…"}):0===m.length?(0,s.jsx)("p",{className:"px-2 py-1 text-xs text-text-muted",children:"No nodes found"}):(0,s.jsxs)(s.Fragment,{children:[i&&n.length>0&&(0,s.jsxs)("label",{className:"flex items-center gap-2 rounded px-2 py-1.5 hover:border-primary/30 hover:shadow-[0_0_20px_var(--color-glow)] hover:bg-surface-hover cursor-pointer border-b border-border mb-1 pb-2 transition-all",children:[(0,s.jsx)("input",{type:"checkbox",checked:t,onChange:()=>{t?l([]):l(n.map(e=>e.id))},disabled:x,className:"accent-primary"}),(0,s.jsx)(r.f,{className:"h-3.5 w-3.5 text-primary"}),(0,s.jsx)("span",{className:"text-xs font-bold",children:"All Nodes"}),(0,s.jsxs)("span",{className:"ml-auto text-[11px] text-text-muted",children:[n.length," online"]})]}),m.map(e=>(0,s.jsxs)("label",{className:"flex items-center gap-2 rounded px-2 py-1.5 hover:border-primary/30 hover:shadow-[0_0_20px_var(--color-glow)] hover:bg-surface-hover cursor-pointer transition-all",children:[(0,s.jsx)("input",{type:"checkbox",checked:a.includes(e.id),onChange:()=>{var s;return s=e.id,void l(a.includes(s)?a.filter(e=>e!==s):[...a,s])},disabled:x||"ONLINE"!==e.status,className:"accent-primary"}),(0,s.jsx)("span",{className:`inline-block h-2 w-2 rounded-full ${"ONLINE"===e.status?"bg-success":"DEGRADED"===e.status?"bg-warning":"bg-text-muted"}`}),(0,s.jsx)("span",{className:`text-xs ${"ONLINE"!==e.status?"text-text-muted":""}`,children:e.name}),(0,s.jsx)("span",{className:"ml-auto text-[11px] text-text-muted",children:e.hostname})]},e.id))]})})]})}let g=Array.isArray(e)?e[0]??"":e;return(0,s.jsxs)("div",{className:d,children:[c&&(0,s.jsx)("label",{className:"mb-1 block text-[11px] font-bold uppercase tracking-wider text-text-muted",children:c}),(0,s.jsxs)("select",{value:g,onChange:e=>l(e.target.value),disabled:x||h,className:"w-full rounded border border-border bg-bg px-3 py-2 text-xs outline-none focus:border-primary focus:shadow-[0_0_8px_var(--color-glow)] hover:border-primary/30 hover:shadow-[0_0_20px_var(--color-glow)] transition-all",children:[(0,s.jsx)("option",{value:"",children:h?"Loading nodes…":o}),m.map(e=>(0,s.jsxs)("option",{value:e.id,disabled:"ONLINE"!==e.status,children:[e.name," — ",e.hostname," (",e.status,")"]},e.id))]})]})}])},63376,e=>{var s=e.i(43476);e.s(["z",0,function({children:e,className:a}){return(0,s.jsx)("div",{className:`animate-page-in${a?` ${a}`:""}`,children:e})},"U",0,function({children:e,className:a}){return(0,s.jsx)("div",{className:a,children:e})}])},75775,e=>{var s=e.i(56420);let a={name:"arrow-up-right",size:24,node:[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]};a.node;let t=(0,s.f)(a);e.s(["f",0,t],75775)},79258,e=>{var s=e.i(56420);let a={name:"package",size:24,node:[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]};a.node;let t=(0,s.f)(a);e.s(["f",0,t],79258)},21357,e=>{var s=e.i(56420);let a={name:"play",size:24,node:[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]};a.node;let t=(0,s.f)(a);e.s(["f",0,t],21357)}])})();
1
+ (()=>{"use strict";(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,89458,e=>{var s=e.i(43476),a=e.i(71645),t=e.i(82983),r=e.i(4050),l=e.i(93999),n=e.i(68759),i=e.i(46670),c=e.i(31624),o=e.i(32568),d=e.i(84026),x=e.i(32781),m=e.i(77071),p=e.i(59659);function h({open:e,mode:r,role:l,onClose:i,onSaved:c}){let[u,g]=(0,a.useState)(""),[f,b]=(0,a.useState)(""),[j,v]=(0,a.useState)("active"),[N,y]=(0,a.useState)([]),[w,k]=(0,a.useState)(""),[_,C]=(0,a.useState)(""),[S,E]=(0,a.useState)([]),[A,I]=(0,a.useState)(!1),[D,M]=(0,a.useState)(!1),[F,z]=(0,a.useState)(""),[P,R]=(0,a.useState)(""),[L,$]=(0,a.useState)(!1),[O,T]=(0,a.useState)("restrictive"),[G,U]=(0,a.useState)(""),[K,W]=(0,a.useState)(!1),[H,V]=(0,a.useState)(""),[q,B]=(0,a.useState)([]),[J,Y]=(0,a.useState)("basic"),Z=(0,a.useCallback)(async()=>{try{let e=await t.f.library.files.list({pageSize:200});B((e.data??[]).map(e=>({id:e.id,name:e.name,fileName:e.fileName,mimeType:e.mimeType??""})))}catch{}},[]);(0,a.useEffect)(()=>{e&&Z()},[e,Z]),(0,a.useEffect)(()=>{"edit"===r&&l?(g(l.name),b(l.description),v(l.status),y(l.libraryFileIds),k(l.aptPackages.join(", ")),C(l.npmPackages.join(", ")),E(Object.entries(l.envConfig).map(([e,s])=>({key:e,value:s}))),I(l.dockerEnabled),M(l.dockerNonRoot),z(l.dockerImage??""),R((l.dockerVolumes??[]).join("\n")),$(l.firewallEnabled),T(l.firewallMode),U(l.firewallAllowRules.join(", "))):"create"===r&&(g(""),b(""),v("active"),y([]),k(""),C(""),E([{key:"OPENROUTER_API_KEY",value:""}]),I(!1),M(!1),z(""),R(""),$(!1),T("restrictive"),U("")),V(""),Y("basic")},[r,l]);let Q=e=>e.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean),X=async()=>{if(!u.trim())return;W(!0),V("");let e={};for(let s of S)s.key.trim()&&(e[s.key.trim()]=s.value);let s={name:u.trim(),description:f.trim(),status:j,libraryFileIds:N,aptPackages:Q(w),npmPackages:Q(_),envConfig:e,dockerEnabled:A,dockerNonRoot:D,dockerImage:F.trim()||null,dockerVolumes:P.split(/[\n,]+/).map(e=>e.trim()).filter(Boolean),firewallEnabled:L,firewallMode:O,firewallAllowRules:Q(G)};try{"create"===r?await t.f.roles.create(s):l&&await t.f.roles.update(l.id,s),c(),ee()}catch(e){V(e instanceof Error?e.message:"Failed to save role")}finally{W(!1)}},ee=()=>{V(""),W(!1),i()},es=(e,s,a)=>{let t=[...S],r=t[e];r&&(t[e]={key:"key"===s?a:r.key,value:"value"===s?a:r.value}),E(t)},ea=e=>{y(s=>s.includes(e)?s.filter(s=>s!==e):[...s,e])},et=q.filter(e=>"application/x-magnus-skill"===e.mimeType),er=q.filter(e=>"application/x-magnus-cronjob"===e.mimeType);return(0,s.jsxs)(o.n,{open:e,onClose:ee,title:"create"===r?"Create Role":"Edit Role",description:"create"===r?"Define a reusable configuration for nodes":`Editing ${l?.name??""}`,icon:(0,s.jsx)(d.f,{className:"h-5 w-5 text-primary"}),className:"max-w-2xl",children:[(0,s.jsx)("div",{className:"flex gap-1 mb-4 border-b border-border pb-2",children:[{key:"basic",label:"Basic"},{key:"packages",label:"Packages & Env"},{key:"files",label:"Skills & Jobs"},{key:"docker",label:"Docker"},{key:"firewall",label:"Firewall"}].map(e=>(0,s.jsx)("button",{onClick:()=>Y(e.key),className:`px-3 py-1.5 text-xs font-bold rounded transition-all ${J===e.key?"bg-primary/10 text-primary border border-primary/50":"text-text-muted hover:text-text hover:bg-surface-hover border border-transparent"}`,children:e.label},e.key))}),(0,s.jsxs)("div",{className:"space-y-4 max-h-[60vh] overflow-y-auto pr-1",children:["basic"===J&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.G,{label:"Role Name",required:!0,children:(0,s.jsx)("input",{type:"text",value:u,onChange:e=>g(e.target.value),placeholder:"web-server",className:o.W,autoFocus:!0})}),(0,s.jsx)(o.G,{label:"Description",children:(0,s.jsx)("textarea",{value:f,onChange:e=>b(e.target.value),placeholder:"Standard web server role with Nginx and monitoring...",rows:3,className:o.M})}),(0,s.jsx)(o.G,{label:"Status",children:(0,s.jsxs)("select",{value:j,onChange:e=>v(e.target.value),className:o.N,children:[(0,s.jsx)("option",{value:"active",children:"Active"}),(0,s.jsx)("option",{value:"draft",children:"Draft"})]})})]}),"packages"===J&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(o.G,{label:"APT Packages",children:[(0,s.jsx)("input",{type:"text",value:w,onChange:e=>k(e.target.value),placeholder:"nginx, curl, htop, jq",className:o.W}),(0,s.jsx)("p",{className:"mt-1 text-xs text-text-muted",children:"Comma-separated package names"})]}),(0,s.jsxs)(o.G,{label:"NPM Global Packages",children:[(0,s.jsx)("input",{type:"text",value:_,onChange:e=>C(e.target.value),placeholder:"pm2, tsx",className:o.W}),(0,s.jsx)("p",{className:"mt-1 text-xs text-text-muted",children:"Comma-separated package names"})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,s.jsx)("label",{className:"text-[11px] font-bold uppercase tracking-wider text-text-muted",children:"Environment Variables"}),(0,s.jsxs)("button",{onClick:()=>{E([...S,{key:"",value:""}])},className:"flex items-center gap-1 text-xs text-primary hover:text-primary-hover",children:[(0,s.jsx)(m.f,{className:"h-3 w-3"})," Add"]})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[S.map((e,a)=>(0,s.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,s.jsx)("input",{type:"text",value:e.key,onChange:e=>es(a,"key",e.target.value),placeholder:"KEY_NAME",className:`${o.W} flex-1`}),(0,s.jsx)("input",{type:"password",value:e.value,onChange:e=>es(a,"value",e.target.value),placeholder:"value",className:`${o.W} flex-1`}),(0,s.jsx)("button",{onClick:()=>{E(S.filter((e,s)=>s!==a))},className:"text-text-muted hover:text-danger p-1",children:(0,s.jsx)(p.f,{className:"h-3.5 w-3.5"})})]},a)),0===S.length&&(0,s.jsx)("p",{className:"text-xs text-text-muted py-2",children:"No environment variables configured"})]})]})]}),"files"===J&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-[11px] font-bold uppercase tracking-wider text-text-muted mb-1.5",children:"Skills from Library"}),(0,s.jsx)("div",{className:"max-h-40 overflow-y-auto rounded border border-border bg-bg p-2 space-y-1",children:0===et.length?(0,s.jsx)("p",{className:"px-2 py-1 text-xs text-text-muted",children:"No skills in library — publish skills from the Skills page"}):et.map(e=>(0,s.jsxs)("label",{className:"flex items-center gap-2 rounded px-2 py-1.5 hover:bg-surface-hover hover:shadow-[0_0_20px_var(--color-glow)] cursor-pointer transition-all",children:[(0,s.jsx)("input",{type:"checkbox",checked:N.includes(e.id),onChange:()=>ea(e.id),className:"accent-primary"}),(0,s.jsx)("span",{className:"text-xs",children:e.name}),(0,s.jsx)("span",{className:"text-xs text-text-muted ml-auto",children:e.fileName})]},e.id))})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-[11px] font-bold uppercase tracking-wider text-text-muted mb-1.5",children:"Cron Jobs from Library"}),(0,s.jsx)("div",{className:"max-h-40 overflow-y-auto rounded border border-border bg-bg p-2 space-y-1",children:0===er.length?(0,s.jsx)("p",{className:"px-2 py-1 text-xs text-text-muted",children:"No cron jobs in library — publish jobs from the Cron page"}):er.map(e=>(0,s.jsxs)("label",{className:"flex items-center gap-2 rounded px-2 py-1.5 hover:bg-surface-hover hover:shadow-[0_0_20px_var(--color-glow)] cursor-pointer transition-all",children:[(0,s.jsx)("input",{type:"checkbox",checked:N.includes(e.id),onChange:()=>ea(e.id),className:"accent-primary"}),(0,s.jsx)("span",{className:"text-xs",children:e.name}),(0,s.jsx)("span",{className:"text-xs text-text-muted ml-auto",children:e.fileName})]},e.id))})]})]}),"docker"===J&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.G,{label:"Docker Sandboxing",children:(0,s.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,s.jsx)("input",{type:"checkbox",checked:A,onChange:e=>I(e.target.checked),className:"accent-primary h-4 w-4"}),(0,s.jsx)("span",{className:"text-xs",children:"Run workload inside Docker container"})]})}),A&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.G,{label:"Non-Root User",children:(0,s.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,s.jsx)("input",{type:"checkbox",checked:D,onChange:e=>M(e.target.checked),className:"accent-primary h-4 w-4"}),(0,s.jsx)("span",{className:"text-xs",children:"Run as non-root user inside container"})]})}),(0,s.jsxs)(o.G,{label:"Custom Docker Image",children:[(0,s.jsx)("input",{type:"text",value:F,onChange:e=>z(e.target.value),placeholder:"node:22-slim (default)",className:o.W}),(0,s.jsx)("p",{className:"mt-1 text-xs text-text-muted",children:"Leave empty for default node:22-slim"})]}),(0,s.jsxs)(o.G,{label:"Volume Mounts",children:[(0,s.jsx)("textarea",{value:P,onChange:e=>R(e.target.value),placeholder:"/host/path:/container/path (one per line)",rows:3,className:o.W}),(0,s.jsx)("p",{className:"mt-1 text-xs text-text-muted",children:"One volume mount per line, e.g. /mnt/data/output:/mnt/data/output"})]})]}),!A&&(0,s.jsx)("div",{className:"rounded border border-border bg-bg/50 p-4 text-center",children:(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Enable Docker sandboxing to run workloads in an isolated container with optional non-root user."})})]}),"firewall"===J&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.G,{label:"UFW Firewall",children:(0,s.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,s.jsx)("input",{type:"checkbox",checked:L,onChange:e=>$(e.target.checked),className:"accent-primary h-4 w-4"}),(0,s.jsx)("span",{className:"text-xs",children:"Enable UFW firewall on the node"})]})}),L&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o.G,{label:"Firewall Mode",children:(0,s.jsxs)("select",{value:O,onChange:e=>T(e.target.value),className:o.N,children:[(0,s.jsx)("option",{value:"restrictive",children:"Restrictive — Block private LAN, allow SSH + Magnus"}),(0,s.jsx)("option",{value:"permissive",children:"Permissive — Allow SSH + Magnus only"}),(0,s.jsx)("option",{value:"custom",children:"Custom — Define your own rules"})]})}),"restrictive"===O&&(0,s.jsxs)("div",{className:"rounded border border-warning/20 bg-warning/10 px-3 py-2 text-[11px] text-warning",children:[(0,s.jsx)("p",{className:"font-bold text-[10px] uppercase tracking-wider",children:"Auto-configured rules:"}),(0,s.jsxs)("ul",{className:"text-xs mt-1 space-y-0.5 text-warning/80",children:[(0,s.jsx)("li",{children:"• Allow SSH (port 22)"}),(0,s.jsx)("li",{children:"• Allow Magnus agent port (4100)"}),(0,s.jsx)("li",{children:"• Allow from control-api IP"}),(0,s.jsx)("li",{children:"• Deny 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16"})]})]}),"custom"===O&&(0,s.jsxs)(o.G,{label:"Custom Allow Rules",children:[(0,s.jsx)("input",{type:"text",value:G,onChange:e=>U(e.target.value),placeholder:"80/tcp, 443/tcp, 10.0.0.5",className:o.W}),(0,s.jsx)("p",{className:"mt-1 text-xs text-text-muted",children:"Comma-separated. Port rules (80/tcp) or IP allow rules (10.0.0.5). SSH + Magnus agent are always allowed."})]})]}),!L&&(0,s.jsx)("div",{className:"rounded border border-border bg-bg/50 p-4 text-center",children:(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Enable UFW to firewall the node away from local networks while preserving Magnus agent communication."})})]})]}),H&&(0,s.jsx)("div",{className:"mt-4 rounded border border-danger/30 bg-danger/10 px-3 py-2 text-[11px] text-danger",children:H}),(0,s.jsxs)("div",{className:"flex justify-end gap-2 pt-4 mt-4 border-t border-border",children:[(0,s.jsx)(n.K,{variant:"secondary",size:"sm",onClick:ee,children:"Cancel"}),(0,s.jsx)(n.K,{size:"sm",onClick:()=>void X(),disabled:K||!u.trim(),icon:K?(0,s.jsx)(x.f,{className:"h-3.5 w-3.5 animate-spin"}):void 0,children:K?"Saving…":"create"===r?"Create Role":"Save Changes"})]})]})}var u=e.i(63376),g=e.i(15281),f=e.i(21357),b=e.i(56420);let j={name:"user-minus",size:24,node:[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]};j.node;let v=(0,b.f)(j);var N=e.i(41220),y=e.i(63230),w=e.i(26091);let k={name:"container",size:24,node:[["path",{d:"M22 7.7c0-.6-.4-1.2-.8-1.5l-6.3-3.9a1.72 1.72 0 0 0-1.7 0l-10.3 6c-.5.2-.9.8-.9 1.4v6.6c0 .5.4 1.2.8 1.5l6.3 3.9a1.72 1.72 0 0 0 1.7 0l10.3-6c.5-.3.9-1 .9-1.5Z",key:"1t2lqe"}],["path",{d:"M10 21.9V14L2.1 9.1",key:"o7czzq"}],["path",{d:"m10 14 11.9-6.9",key:"zm5e20"}],["path",{d:"M14 19.8v-8.1",key:"159ecu"}],["path",{d:"M18 17.5V9.4",key:"11uown"}]]};k.node;let _=(0,b.f)(k);var C=e.i(82954),S=e.i(41120),E=e.i(67927),A=e.i(51757),I=e.i(83967),D=e.i(74544),M=e.i(99847);let F={name:"skip-forward",size:24,node:[["path",{d:"M21 4v16",key:"7j8fe9"}],["path",{d:"M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z",key:"zs4d6"}]]};F.node;let z=(0,b.f)(F);e.s(["default",0,function({initialRoles:e}){let{activeNode:o}=(0,r.l)(),[b,j]=(0,a.useState)(e),[k,F]=(0,a.useState)(null),[P,R]=(0,a.useState)([]),[L,$]=(0,a.useState)(!e.length),[O,T]=(0,a.useState)(e.length>0),[G,U]=(0,a.useState)(!1),[K,W]=(0,a.useState)("create"),[H,V]=(0,a.useState)(null),[q,B]=(0,a.useState)(!1),[J,Y]=(0,a.useState)([]),[Z,Q]=(0,a.useState)(!1),[X,ee]=(0,a.useState)(!1),es=(0,a.useCallback)(async()=>{try{let e=await t.f.roles.list();j(e.data??[])}catch{}finally{$(!1)}},[]),ea=(0,a.useCallback)(async e=>{try{let[s,a]=await Promise.all([t.f.roles.get(e),t.f.roles.applications.list({roleId:e})]),r=s.data;F(r),R(a.data??[])}catch{}},[]);(0,a.useEffect)(()=>{O?T(!1):es()},[es,o.id]),(0,a.useEffect)(()=>{if(!k)return;let e=setInterval(()=>{ea(k.id)},5e3);return()=>clearInterval(e)},[k,ea]);let et=()=>{W("create"),V(null),U(!0)},er=async e=>{if(confirm(`Delete role "${e.name}"? This will unassign all nodes.`))try{await t.f.roles.delete(e.id),k?.id===e.id&&F(null),await es()}catch{}},el=async()=>{await es(),k&&await ea(k.id)},en=async()=>{if(k&&0!==J.length){ee(!0);try{await t.f.roles.assign(k.id,{nodeIds:J,defer:Z}),B(!1),Y([]),await ea(k.id),await es()}catch{}finally{ee(!1)}}},ei=async e=>{if(k&&confirm("Unassign this node? This will remove the role configuration."))try{await t.f.roles.unassign(k.id,{nodeIds:[e]}),await ea(k.id),await es()}catch{}},ec=async()=>{if(k)try{await t.f.roles.apply(k.id),await ea(k.id)}catch{}};return(0,s.jsxs)(u.U,{className:"space-y-6",children:[(0,s.jsx)(u.z,{children:(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"text-lg font-bold uppercase tracking-wider",children:"Roles"}),(0,s.jsx)("p",{className:"mt-1 text-[11px] text-text-muted uppercase tracking-wider",children:"Define reusable node configurations with packages, files, Docker sandboxing, and firewall rules"})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(n.K,{variant:"secondary",size:"sm",onClick:()=>void es(),icon:(0,s.jsx)(S.f,{className:"h-3.5 w-3.5"}),children:"Refresh"}),(0,s.jsx)(n.K,{size:"sm",onClick:et,icon:(0,s.jsx)(m.f,{className:"h-3.5 w-3.5"}),children:"New Role"})]})]})}),(0,s.jsx)(u.z,{children:(0,s.jsxs)("div",{className:"grid grid-cols-12 gap-6",children:[(0,s.jsx)("div",{className:"col-span-4",children:(0,s.jsx)(l.N,{children:L?(0,s.jsx)("div",{className:"flex justify-center py-8",children:(0,s.jsx)(x.f,{className:"h-6 w-6 animate-spin text-text-muted"})}):0===b.length?(0,s.jsxs)("div",{className:"text-center py-8",children:[(0,s.jsx)(d.f,{className:"mx-auto h-10 w-10 text-text-muted mb-2"}),(0,s.jsx)("p",{className:"text-[11px] text-text-muted",children:"No roles yet"}),(0,s.jsx)(n.K,{size:"sm",className:"mt-3",onClick:et,icon:(0,s.jsx)(m.f,{className:"h-3.5 w-3.5"}),children:"Create First Role"})]}):(0,s.jsx)("div",{className:"space-y-1",children:b.map(e=>(0,s.jsxs)("button",{onClick:()=>{F(e),ea(e.id)},className:`w-full text-left rounded px-3 py-3 transition-all ${k?.id===e.id?"bg-primary/10 border border-primary/50":"hover:bg-surface-hover hover:border-primary/30 hover:shadow-[0_0_20px_var(--color-glow)] border border-transparent"}`,children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,s.jsx)("span",{className:"text-[11px] font-bold",children:e.name}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)(i.t,{variant:"active"===e.status?"success":"warning",children:e.status}),(0,s.jsx)(E.f,{className:"h-3.5 w-3.5 text-text-muted"})]})]}),e.description&&(0,s.jsx)("p",{className:"text-xs text-text-muted truncate mb-1.5",children:e.description}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex flex-wrap gap-1",children:[e.aptPackages.length>0&&(0,s.jsxs)("span",{className:"inline-flex items-center rounded bg-success/10 px-1.5 py-0.5 text-[10px] text-success",children:[e.aptPackages.length," apt"]}),e.npmPackages.length>0&&(0,s.jsxs)("span",{className:"inline-flex items-center rounded bg-warning/10 px-1.5 py-0.5 text-[10px] text-warning",children:[e.npmPackages.length," npm"]}),e.libraryFileIds.length>0&&(0,s.jsxs)("span",{className:"inline-flex items-center rounded bg-primary/10 px-1.5 py-0.5 text-[10px] text-primary",children:[e.libraryFileIds.length," library"]}),e.dockerEnabled&&(0,s.jsx)("span",{className:"inline-flex items-center rounded bg-primary/10 px-1.5 py-0.5 text-[10px] text-primary",children:"Docker"}),e.firewallEnabled&&(0,s.jsx)("span",{className:"inline-flex items-center rounded bg-warning/10 px-1.5 py-0.5 text-[10px] text-warning",children:"UFW"})]}),(0,s.jsxs)("span",{className:"text-xs text-text-muted flex items-center gap-1",children:[(0,s.jsx)(N.f,{className:"h-3 w-3"}),e._count?.nodes??0]})]})]},e.id))})})}),(0,s.jsx)("div",{className:"col-span-8",children:k?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)(l.N,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("h2",{className:"text-lg font-bold",children:k.name}),(0,s.jsx)(i.t,{variant:"active"===k.status?"success":"warning",children:k.status})]}),k.description&&(0,s.jsx)("p",{className:"text-[11px] text-text-muted mt-1",children:k.description})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(n.K,{variant:"secondary",size:"sm",onClick:()=>{W("edit"),V(k),U(!0)},icon:(0,s.jsx)(g.f,{className:"h-3.5 w-3.5"}),children:"Edit"}),(0,s.jsx)(n.K,{variant:"danger",size:"sm",onClick:()=>void er(k),icon:(0,s.jsx)(p.f,{className:"h-3.5 w-3.5"}),children:"Delete"})]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,s.jsxs)("div",{className:"rounded border border-border bg-bg p-3 hover:border-primary/30 hover:shadow-[0_0_20px_var(--color-glow)] transition-all",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,s.jsx)(y.f,{className:"h-4 w-4 text-success"}),(0,s.jsx)("span",{className:"text-[11px] font-bold uppercase tracking-wider",children:"Packages"})]}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:k.aptPackages.length>0?`apt: ${k.aptPackages.join(", ")}`:"No apt packages"}),(0,s.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:k.npmPackages.length>0?`npm: ${k.npmPackages.join(", ")}`:"No npm packages"}),Object.keys(k.envConfig).length>0&&(0,s.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:[Object.keys(k.envConfig).length," env var(s): ",Object.keys(k.envConfig).join(", ")]})]}),(0,s.jsxs)("div",{className:"rounded border border-border bg-bg p-3 hover:border-primary/30 hover:shadow-[0_0_20px_var(--color-glow)] transition-all",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,s.jsx)(w.f,{className:"h-4 w-4 text-primary"}),(0,s.jsx)("span",{className:"text-[11px] font-bold uppercase tracking-wider",children:"Skills & Jobs"})]}),(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:[k.libraryFileIds.length," library item(s) assigned"]})]}),(0,s.jsxs)("div",{className:"rounded border border-border bg-bg p-3 hover:border-primary/30 hover:shadow-[0_0_20px_var(--color-glow)] transition-all",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,s.jsxs)("div",{className:"flex gap-1.5",children:[(0,s.jsx)(_,{className:"h-4 w-4 text-primary"}),(0,s.jsx)(C.f,{className:"h-4 w-4 text-warning"})]}),(0,s.jsx)("span",{className:"text-[11px] font-bold uppercase tracking-wider",children:"Sandbox & Firewall"})]}),(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["Docker: ",k.dockerEnabled?`Enabled${k.dockerNonRoot?" (non-root)":""}`:"Disabled"]}),(0,s.jsxs)("p",{className:"text-xs text-text-muted mt-0.5",children:["Firewall: ",k.firewallEnabled?`${k.firewallMode} mode`:"Disabled"]})]})]})]}),(0,s.jsxs)(l.N,{title:"Assigned Nodes",action:(0,s.jsxs)("div",{className:"flex gap-2",children:[(k.nodes?.length??0)>0&&(0,s.jsx)(n.K,{variant:"secondary",size:"sm",onClick:()=>void ec(),icon:(0,s.jsx)(S.f,{className:"h-3.5 w-3.5"}),children:"Re-apply All"}),(0,s.jsx)(n.K,{size:"sm",onClick:()=>B(!0),icon:(0,s.jsx)(m.f,{className:"h-3.5 w-3.5"}),children:"Assign Nodes"})]}),children:[k.nodes&&0!==k.nodes.length?(0,s.jsx)("div",{className:"space-y-1",children:k.nodes.map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between rounded border border-border bg-bg px-3 py-2 hover:border-primary/30 hover:shadow-[0_0_20px_var(--color-glow)] transition-all",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(N.f,{className:"h-4 w-4 text-text-muted"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-[11px] font-bold",children:e.name}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:e.hostname})]}),(0,s.jsx)(i.t,{variant:(0,i.k)(e.status),children:e.status})]}),(0,s.jsx)(n.K,{variant:"ghost",size:"sm",onClick:()=>void ei(e.id),icon:(0,s.jsx)(v,{className:"h-3.5 w-3.5"}),children:"Unassign"})]},e.id))}):(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)(N.f,{className:"mx-auto h-8 w-8 text-text-muted mb-2"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"No nodes assigned to this role"})]}),q&&(0,s.jsxs)("div",{className:"mt-4 rounded border border-primary/30 bg-primary/5 p-4",children:[(0,s.jsxs)("h4",{className:"text-[11px] font-bold uppercase tracking-wider mb-3",children:['Assign Nodes to "',k.name,'"']}),(0,s.jsx)(c.f,{value:J,onChange:e=>Y(e),multi:!0,showAll:!0,label:"Select nodes"}),(0,s.jsxs)("label",{className:"flex items-center gap-2 mt-3 cursor-pointer",children:[(0,s.jsx)("input",{type:"checkbox",checked:Z,onChange:e=>Q(e.target.checked),className:"accent-primary"}),(0,s.jsx)("span",{className:"text-xs text-text-muted",children:"Defer application (assign only, don't apply yet)"})]}),(0,s.jsxs)("div",{className:"flex justify-end gap-2 mt-3",children:[(0,s.jsx)(n.K,{variant:"secondary",size:"sm",onClick:()=>{B(!1),Y([])},children:"Cancel"}),(0,s.jsx)(n.K,{size:"sm",onClick:()=>void en(),disabled:X||0===J.length,icon:X?(0,s.jsx)(x.f,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(f.f,{className:"h-3.5 w-3.5"}),children:X?"Assigning…":`Assign ${J.length} Node(s)`})]})]})]}),(0,s.jsx)(l.N,{title:"Application History",description:"Recent role apply/remove operations",children:0===P.length?(0,s.jsx)("p",{className:"text-xs text-text-muted py-4 text-center",children:"No applications yet"}):(0,s.jsx)("div",{className:"space-y-3",children:P.slice(0,10).map(e=>(0,s.jsxs)("div",{className:"rounded border border-border bg-bg p-3 hover:border-primary/30 transition-all",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(i.t,{variant:"apply"===e.action?"info":"warning",children:e.action}),(0,s.jsx)("span",{className:"text-xs text-text-muted",children:e.node?.name??e.nodeId})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(i.t,{variant:(0,i.k)(e.status),children:e.status}),(0,s.jsx)("span",{className:"text-xs text-text-muted",children:new Date(e.createdAt).toLocaleString()})]})]}),e.steps.length>0&&(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:e.steps.map((e,a)=>(0,s.jsxs)("div",{className:"flex items-center gap-1.5 rounded bg-surface px-2 py-1",title:e.error??e.name,children:[(e=>{switch(e){case"completed":return(0,s.jsx)(A.f,{className:"h-3.5 w-3.5 text-success"});case"failed":return(0,s.jsx)(I.f,{className:"h-3.5 w-3.5 text-danger"});case"running":return(0,s.jsx)(x.f,{className:"h-3.5 w-3.5 text-primary animate-spin"});case"skipped":return(0,s.jsx)(z,{className:"h-3.5 w-3.5 text-text-muted"});default:return(0,s.jsx)(D.f,{className:"h-3.5 w-3.5 text-text-muted"})}})(e.status),(0,s.jsx)("span",{className:"text-[11px] text-text-muted",children:e.name})]},a))}),e.error&&(0,s.jsxs)("div",{className:"mt-2 flex items-start gap-1.5 text-xs text-danger",children:[(0,s.jsx)(M.f,{className:"h-3.5 w-3.5 mt-0.5 flex-shrink-0"}),(0,s.jsx)("span",{className:"truncate",children:e.error})]})]},e.id))})})]}):(0,s.jsx)(l.N,{children:(0,s.jsxs)("div",{className:"text-center py-16",children:[(0,s.jsx)(d.f,{className:"mx-auto h-12 w-12 text-text-muted mb-3"}),(0,s.jsx)("p",{className:"text-[11px] text-text-muted",children:"Select a role to view details"})]})})})]})}),(0,s.jsx)(h,{open:G,mode:K,role:H,onClose:()=>U(!1),onSaved:()=>void el()})]})}],89458)},46670,e=>{var s=e.i(43476),a=e.i(78571);let t={default:"border-border text-text-muted",success:"border-success/40 text-success bg-success/5 shadow-[0_0_6px_rgba(0,255,65,0.15)]",warning:"border-warning/40 text-warning bg-warning/5 shadow-[0_0_6px_rgba(255,179,0,0.15)]",danger:"border-danger/40 text-danger bg-danger/5 shadow-[0_0_6px_rgba(255,23,68,0.15)]",info:"border-info/40 text-info bg-info/5 shadow-[0_0_6px_rgba(0,176,255,0.15)]"},r={default:"bg-text-muted",success:"bg-success",warning:"bg-warning",danger:"bg-danger",info:"bg-info"};e.s(["t",0,function({children:e,variant:l="default",className:n,dot:i=!1,pulse:c=!1}){return(0,s.jsxs)("span",{className:(0,a.f)("inline-flex items-center gap-1.5 rounded-chip border px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider",t[l],n),children:[i&&(0,s.jsxs)("span",{"aria-hidden":"true",className:"relative inline-flex h-1.5 w-1.5",children:[c&&(0,s.jsx)("span",{className:(0,a.f)("absolute inset-0 rounded-full animate-halo",r[l])}),(0,s.jsx)("span",{className:(0,a.f)("relative inline-flex h-1.5 w-1.5 rounded-full",r[l])})]}),e]})},"k",0,function(e){switch(e.toUpperCase()){case"ONLINE":case"COMPLETED":case"ACTIVE":case"RUNNING":case"INSTALLED":case"HEALTHY":return"success";case"DEGRADED":case"PAUSED":case"QUEUED":case"PENDING":case"INSTALLING":return"warning";case"OFFLINE":case"FAILED":case"ERROR":case"TIMEOUT":case"CANCELLED":case"DECOMMISSIONED":case"CRITICAL":return"danger";case"PROVISIONING":case"UPDATING":return"info";default:return"default"}}])},93999,51196,55427,e=>{var s=e.i(43476),a=e.i(56420);let t={name:"arrow-down-right",size:24,node:[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]]};t.node;let r=(0,a.f)(t);var l=e.i(75775),n=e.i(78571),i=e.i(3062),c=e.i(35084);let o={warning:"shadow-[0_0_6px_var(--color-warning)]",danger:"shadow-[0_0_8px_var(--color-danger)]",accent:"shadow-[0_0_6px_var(--color-accent)]",primary:"shadow-[0_0_6px_var(--color-primary)]"},d={xs:"h-1",sm:"h-1.5",md:"h-2"};function x({value:e,max:a=100,tone:t,thresholds:r=c.q,label:l,size:i="xs",showValue:m=!1,valueLabel:p,glow:h,className:u,testId:g}){let f="number"==typeof e&&Number.isFinite(e),b=f?Math.max(0,Math.min(100,e/(a||1)*100)):0,j=t??(f?(0,c.Z)(b,r):"muted"),v=h||!t&&f&&b>=r.warn,N=p??(f?`${b.toFixed(+(b<10&&b>0))}%`:"—");return(0,s.jsxs)("div",{className:(0,n.f)("flex min-w-0 items-center gap-2",u),"data-testid":g,children:[(0,s.jsx)("div",{role:"meter","aria-label":l,"aria-valuemin":0,"aria-valuemax":a,"aria-valuenow":f?e:void 0,"aria-valuetext":N,className:(0,n.f)("relative flex-1 overflow-hidden rounded-full bg-border/70",d[i]),children:(0,s.jsx)("div",{style:{"--meter":`${b}%`},className:(0,n.f)("h-full w-(--meter) rounded-full transition-[width] duration-700 ease-out-expo starting:w-0",c.H[j],v&&o[j])})}),m&&(0,s.jsx)("span",{className:(0,n.f)("num w-11 shrink-0 text-right text-[11px]",f?c.T[j]:"text-text-muted"),children:N})]})}e.s(["f",0,x],51196);var m=e.i(71645);function p({values:e,tone:a="primary",width:t=160,height:r=32,area:l=!0,max:i,percent:o=!1,threshold:d,live:x=!0,emptyLabel:h="not enough data",className:u,testId:g,label:f,stretch:b=!1}){let j=`spark${(0,m.useId)().replace(/:/g,"")}`;if(e.length<2)return(0,s.jsx)("div",{className:(0,n.f)("flex h-8 items-center text-xs italic text-text-muted",u),"data-testid":g,children:h});let v=c.v[a],N=i??(o?Math.max(100,...e):Math.max(...e,d??0)||1),y=r-4,w=t/(e.length-1),k=e=>2+y-Math.max(0,e)/N*y,_=e.map((e,s)=>[s*w,k(e)]),C=_.map(([e,s])=>`${e.toFixed(1)},${s.toFixed(1)}`).join(" "),S=_[_.length-1];return(0,s.jsxs)("svg",{width:b?"100%":t,height:r,viewBox:`0 0 ${t} ${r}`,preserveAspectRatio:b?"none":void 0,className:(0,n.f)("block overflow-visible",u),"data-testid":g,role:f?"img":void 0,"aria-label":f,"aria-hidden":!f||void 0,children:[l&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("defs",{children:(0,s.jsxs)("linearGradient",{id:j,x1:"0",x2:"0",y1:"0",y2:"1",children:[(0,s.jsx)("stop",{offset:"0%",stopColor:v,stopOpacity:.35}),(0,s.jsx)("stop",{offset:"100%",stopColor:v,stopOpacity:0})]})}),(0,s.jsx)("polygon",{points:`0,${r} ${C} ${t},${r}`,fill:`url(#${j})`})]}),void 0!==d&&(0,s.jsx)("line",{x1:0,x2:t,y1:k(d),y2:k(d),stroke:"var(--color-warning)",strokeOpacity:.5,strokeDasharray:"3 3",strokeWidth:1}),(0,s.jsx)("polyline",{fill:"none",stroke:v,strokeWidth:1.5,vectorEffect:"non-scaling-stroke",strokeLinejoin:"round",strokeLinecap:"round",points:C}),x&&!b&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("circle",{cx:S[0],cy:S[1],r:2.5,fill:v,className:"origin-center animate-halo [transform-box:fill-box]"}),(0,s.jsx)("circle",{cx:S[0],cy:S[1],r:2,fill:v})]})]})}e.s(["f",0,p],55427),e.s(["N",0,function({title:e,description:a,children:t,className:r,action:l,tone:n,corners:c=!1,...o}){return(0,s.jsx)(i.f,{...o,tone:n,corners:c,title:e,description:a,action:l,className:r,children:t})},"n",0,function({label:e,value:a,icon:t,trend:o,spark:d,meter:m,delta:h,tone:u="primary",className:g,testId:f}){let b=!h||h.value>=0===(h.positiveIsGood??!0);return(0,s.jsxs)(i.f,{tone:u,className:(0,n.f)("overflow-hidden",g),testId:f,children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-[10px] font-medium uppercase tracking-[0.15em] text-text-muted",children:e}),t&&(0,s.jsx)("span",{className:"text-primary/60",children:t})]}),(0,s.jsxs)("div",{className:"mt-2 flex items-end justify-between gap-2",children:[(0,s.jsx)("div",{className:(0,n.f)("num text-2xl font-bold","primary"===u?"text-primary neon-text":c.T[u]),children:a}),h&&0!==h.value&&(0,s.jsxs)("span",{className:(0,n.f)("num mb-1 inline-flex items-center gap-0.5 text-[11px]",b?"text-success":"text-danger"),children:[h.value>0?(0,s.jsx)(l.f,{className:"h-3 w-3"}):(0,s.jsx)(r,{className:"h-3 w-3"}),Math.abs(h.value).toFixed(+!Number.isInteger(h.value)),h.unit]})]}),o&&(0,s.jsx)("div",{className:(0,n.f)("mt-1 text-[11px]",o.positive?"text-success":"text-danger"),children:o.value}),void 0!==m&&(0,s.jsx)(x,{value:m,className:"mt-3",label:e}),d&&d.length>1&&(0,s.jsx)("div",{className:"-mx-5 -mb-5 mt-3 opacity-80",children:(0,s.jsx)(p,{values:d,tone:u,width:240,height:28,stretch:!0,live:!1})})]})}],93999)},3062,e=>{var s=e.i(43476),a=e.i(78571),t=e.i(35084);let r={primary:"[--panel-corner-color:color-mix(in_srgb,var(--color-primary)_60%,transparent)]",accent:"[--panel-corner-color:color-mix(in_srgb,var(--color-accent)_70%,transparent)]",success:"[--panel-corner-color:color-mix(in_srgb,var(--color-success)_60%,transparent)]",warning:"[--panel-corner-color:color-mix(in_srgb,var(--color-warning)_70%,transparent)]",danger:"[--panel-corner-color:color-mix(in_srgb,var(--color-danger)_70%,transparent)]",info:"[--panel-corner-color:color-mix(in_srgb,var(--color-info)_60%,transparent)]",muted:"[--panel-corner-color:var(--color-border-strong)]"},l={primary:"[--glow-hover-color:var(--color-glow)]",accent:"[--glow-hover-color:var(--color-glow-accent)]",success:"[--glow-hover-color:var(--color-glow-success)]",warning:"[--glow-hover-color:var(--color-glow-warning)]",danger:"[--glow-hover-color:var(--color-glow-danger)]",info:"[--glow-hover-color:var(--color-glow)]",muted:"[--glow-hover-color:var(--color-glow)]"},n={primary:"hover:border-primary/30",accent:"hover:border-accent/40",success:"hover:border-success/30",warning:"hover:border-warning/40",danger:"hover:border-danger/40",info:"hover:border-info/30",muted:"hover:border-border-strong"},i={none:"",sm:"p-3",md:"p-5",lg:"p-6"};e.s(["f",0,function({tone:e="primary",corners:c=!0,interactive:o=!0,hero:d=!1,title:x,description:m,icon:p,action:h,as:u="div",padding:g="md",testId:f,className:b,children:j,...v}){return(0,s.jsxs)(u,{...v,"data-testid":f??v["data-testid"],className:(0,a.f)("relative rounded-panel border border-border bg-surface transition-colors duration-300",i[g],c&&"panel-corners",c&&r[e],o&&"glow-hover",o&&l[e],o&&n[e],d&&"grid-bg overflow-hidden bg-surface/80",b),children:[(x||h||p)&&(0,s.jsxs)("div",{className:"mb-4 flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-start gap-2",children:[p&&(0,s.jsx)("span",{className:(0,a.f)("mt-0.5 shrink-0",t.T[e]),children:p}),(0,s.jsxs)("div",{className:"min-w-0",children:[x&&(0,s.jsx)("h3",{className:"text-xs font-bold uppercase tracking-wider",children:x}),m&&(0,s.jsx)("p",{className:"mt-0.5 text-[11px] text-text-muted",children:m})]})]}),h]}),j]})}])},31624,e=>{var s=e.i(43476),a=e.i(71645),t=e.i(82983),r=e.i(41220);e.s(["f",0,function({value:e,onChange:l,multi:n=!1,showAll:i=!1,label:c="Node",placeholder:o="Select a node…",className:d="",disabled:x=!1}){let[m,p]=(0,a.useState)([]),[h,u]=(0,a.useState)(!0);if((0,a.useEffect)(()=>{(async()=>{try{let e=(await t.f.nodes.list({pageSize:100})).data??[];p(e)}catch{}finally{u(!1)}})()},[]),n){let a=Array.isArray(e)?e:e?[e]:[],t=a.length===m.length&&m.length>0,n=m.filter(e=>"ONLINE"===e.status);return(0,s.jsxs)("div",{className:d,children:[c&&(0,s.jsx)("label",{className:"mb-1 block text-[11px] font-bold uppercase tracking-wider text-text-muted",children:c}),(0,s.jsx)("div",{className:"max-h-48 overflow-y-auto rounded border border-border bg-bg p-2 space-y-1",children:h?(0,s.jsx)("p",{className:"px-2 py-1 text-xs text-text-muted",children:"Loading nodes…"}):0===m.length?(0,s.jsx)("p",{className:"px-2 py-1 text-xs text-text-muted",children:"No nodes found"}):(0,s.jsxs)(s.Fragment,{children:[i&&n.length>0&&(0,s.jsxs)("label",{className:"flex items-center gap-2 rounded px-2 py-1.5 hover:border-primary/30 hover:shadow-[0_0_20px_var(--color-glow)] hover:bg-surface-hover cursor-pointer border-b border-border mb-1 pb-2 transition-all",children:[(0,s.jsx)("input",{type:"checkbox",checked:t,onChange:()=>{t?l([]):l(n.map(e=>e.id))},disabled:x,className:"accent-primary"}),(0,s.jsx)(r.f,{className:"h-3.5 w-3.5 text-primary"}),(0,s.jsx)("span",{className:"text-xs font-bold",children:"All Nodes"}),(0,s.jsxs)("span",{className:"ml-auto text-[11px] text-text-muted",children:[n.length," online"]})]}),m.map(e=>(0,s.jsxs)("label",{className:"flex items-center gap-2 rounded px-2 py-1.5 hover:border-primary/30 hover:shadow-[0_0_20px_var(--color-glow)] hover:bg-surface-hover cursor-pointer transition-all",children:[(0,s.jsx)("input",{type:"checkbox",checked:a.includes(e.id),onChange:()=>{var s;return s=e.id,void l(a.includes(s)?a.filter(e=>e!==s):[...a,s])},disabled:x||"ONLINE"!==e.status,className:"accent-primary"}),(0,s.jsx)("span",{className:`inline-block h-2 w-2 rounded-full ${"ONLINE"===e.status?"bg-success":"DEGRADED"===e.status?"bg-warning":"bg-text-muted"}`}),(0,s.jsx)("span",{className:`text-xs ${"ONLINE"!==e.status?"text-text-muted":""}`,children:e.name}),(0,s.jsx)("span",{className:"ml-auto text-[11px] text-text-muted",children:e.hostname})]},e.id))]})})]})}let g=Array.isArray(e)?e[0]??"":e;return(0,s.jsxs)("div",{className:d,children:[c&&(0,s.jsx)("label",{className:"mb-1 block text-[11px] font-bold uppercase tracking-wider text-text-muted",children:c}),(0,s.jsxs)("select",{value:g,onChange:e=>l(e.target.value),disabled:x||h,className:"w-full rounded border border-border bg-bg px-3 py-2 text-xs outline-none focus:border-primary focus:shadow-[0_0_8px_var(--color-glow)] hover:border-primary/30 hover:shadow-[0_0_20px_var(--color-glow)] transition-all",children:[(0,s.jsx)("option",{value:"",children:h?"Loading nodes…":o}),m.map(e=>(0,s.jsxs)("option",{value:e.id,disabled:"ONLINE"!==e.status,children:[e.name," — ",e.hostname," (",e.status,")"]},e.id))]})]})}])},63376,e=>{var s=e.i(43476);e.s(["z",0,function({children:e,className:a}){return(0,s.jsx)("div",{className:`animate-page-in${a?` ${a}`:""}`,children:e})},"U",0,function({children:e,className:a}){return(0,s.jsx)("div",{className:a,children:e})}])},75775,e=>{var s=e.i(56420);let a={name:"arrow-up-right",size:24,node:[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]};a.node;let t=(0,s.f)(a);e.s(["f",0,t],75775)},63230,e=>{var s=e.i(56420);let a={name:"package",size:24,node:[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]};a.node;let t=(0,s.f)(a);e.s(["f",0,t],63230)},21357,e=>{var s=e.i(56420);let a={name:"play",size:24,node:[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]};a.node;let t=(0,s.f)(a);e.s(["f",0,t],21357)}])})();
@@ -0,0 +1 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,5525,e=>{"use strict";var t=e.i(43476),s=e.i(71645),a=e.i(18566),n=e.i(93999),r=e.i(3062),i=e.i(54149),l=e.i(51196),d=e.i(75723),c=e.i(2067),o=e.i(65369),m=e.i(56420);let x={name:"chart-line",size:24,node:[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],aliases:["line-chart"]};x.node;let u=(0,m.f)(x);var p=e.i(82983),h=e.i(78571),g=e.i(21176);let f=["1h","6h","24h"];function j({nodeId:e,height:a=180}){let[n,r]=(0,s.useState)("1h"),[i,l]=(0,s.useState)(null),[d,o]=(0,s.useState)(!1);return(0,s.useEffect)(()=>{let t=!1;o(!1);let s=async()=>{try{let[s,a]=await Promise.all([p.f.get(`nodes/${e}/health/timeseries?metric=cpu&period=${n}`),p.f.get(`nodes/${e}/health/timeseries?metric=memory&period=${n}`)]);if(t)return;let r=s.data??{timestamps:[],values:[]},i=a.data??{timestamps:[],values:[]},d=new Map;r.timestamps.forEach((e,t)=>{let s=Date.parse(e);d.set(s,{t:s,cpu:r.values[t]??null,mem:null})}),i.timestamps.forEach((e,t)=>{let s=Date.parse(e),a=d.get(s)??{t:s,cpu:null,mem:null};a.mem=i.values[t]??null,d.set(s,a)}),l([...d.values()].sort((e,t)=>e.t-t.t))}catch{t||(l([]),o(!0))}};s();let a=setInterval(()=>void s(),6e4);return()=>{t=!0,clearInterval(a)}},[e,n]),(0,t.jsxs)("div",{className:"flex min-w-0 flex-col","data-testid":"node-metrics-chart",children:[(0,t.jsxs)("div",{className:"mb-2 flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-[0.2em] text-text-muted",children:"CPU / memory history"}),(0,t.jsx)("div",{role:"group","aria-label":"History period",className:"flex rounded-chip border border-border bg-bg p-0.5",children:f.map(e=>(0,t.jsx)("button",{type:"button",onClick:()=>r(e),"aria-pressed":n===e,className:(0,h.f)("rounded-chip px-2 py-0.5 text-[10px] uppercase tracking-wider transition-colors",n===e?"bg-primary/15 text-primary shadow-[0_0_8px_var(--color-glow)]":"text-text-muted hover:text-text"),children:e},e))})]}),null===i?(0,t.jsx)("div",{className:"skeleton w-full",style:{height:a}}):i.length<2?(0,t.jsx)(c.f,{compact:!0,icon:(0,t.jsx)(u,{className:"h-4 w-4"}),title:d?"History unavailable":"Not enough samples yet",description:d?"The health timeseries endpoint did not answer.":`No health snapshots in the last ${n}.`,tone:d?"warning":"muted",className:"flex-1"}):(0,t.jsx)(g.f,{data:i,xKey:"t",percent:!0,height:a,formatX:e=>new Date(Number(e)).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit"}),series:[{key:"cpu",label:"CPU",tone:"primary"},{key:"mem",label:"Memory",tone:"accent"}]})]})}var N=e.i(95925);let v={name:"shield-off",size:24,node:[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]]};v.node;let y=(0,m.f)(v);var b=e.i(46670);function w({metadata:e}){let s=function(e){let t=e;if("string"==typeof e)try{t=JSON.parse(e)}catch{return}return t?.agentSelfUpgrade}(e);return s?s.upgrade?.state==="reverted"?(0,t.jsx)("span",{title:s.upgrade.reason??void 0,children:(0,t.jsxs)(b.t,{variant:"danger",children:[(0,t.jsx)(N.f,{className:"mr-1 inline h-3 w-3"}),"Upgrade to ",s.upgrade.to," reverted"]})}):s.upgrade?.state==="failed"?(0,t.jsx)("span",{title:s.upgrade.reason??void 0,children:(0,t.jsxs)(b.t,{variant:"danger",children:[(0,t.jsx)(N.f,{className:"mr-1 inline h-3 w-3"}),"Upgrade to ",s.upgrade.to," failed"]})}):s.enabled?null:(0,t.jsx)("span",{title:s.reason??void 0,"data-testid":"agent-self-upgrade-off",children:(0,t.jsxs)(b.t,{variant:"default",children:[(0,t.jsx)(y,{className:"mr-1 inline h-3 w-3"}),"Self-upgrade off"]})}):null}var k=e.i(57108),S=e.i(68759),$=e.i(32568),C=e.i(71417),A=e.i(15281),P=e.i(59659),U=e.i(9347),I=e.i(25398),_=e.i(99847),E=e.i(32781),M=e.i(82022),D=e.i(84026),F=e.i(71567),R=e.i(94371),O=e.i(20851),L=e.i(66595);let z={name:"mouse-pointer-click",size:24,node:[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]};z.node;let T=(0,m.f)(z);var H=e.i(86207),B=e.i(57665),q=e.i(41220),K=e.i(14098),G=e.i(4139),J=e.i(41120),V=e.i(82954),W=e.i(79432),Q=e.i(62368),Z=e.i(53138),X=e.i(51757),Y=e.i(83967),ee=e.i(74544);let et=[{id:"apt-update",label:"apt update",command:"sudo",args:["apt","update"],icon:(0,t.jsx)(Q.f,{className:"h-3.5 w-3.5"}),variant:"secondary",timeoutSeconds:120},{id:"apt-upgrade",label:"apt upgrade",command:"sudo",args:["apt","upgrade","-y"],icon:(0,t.jsx)(J.f,{className:"h-3.5 w-3.5"}),variant:"secondary",confirm:"This will upgrade all packages on the node. Continue?",timeoutSeconds:300},{id:"magnus-status",label:"magnus status",command:"systemctl",args:["status","magnus-agent","--no-pager"],icon:(0,t.jsx)(W.f,{className:"h-3.5 w-3.5"}),variant:"primary",timeoutSeconds:15},{id:"magnus-update",label:"magnus update",command:"sudo",args:["systemctl","restart","magnus-agent"],icon:(0,t.jsx)(V.f,{className:"h-3.5 w-3.5"}),variant:"secondary",confirm:"This will restart the Magnus agent. Continue?",timeoutSeconds:30},{id:"dmesg",label:"dmesg",command:"sudo",args:["dmesg","--time-format=reltime","-T"],icon:(0,t.jsx)(Z.f,{className:"h-3.5 w-3.5"}),variant:"secondary",timeoutSeconds:15},{id:"reboot",label:"Reboot",command:"sudo",args:["reboot"],icon:(0,t.jsx)(B.f,{className:"h-3.5 w-3.5"}),variant:"danger",confirm:"Are you sure you want to REBOOT this node? It will go offline temporarily.",timeoutSeconds:10}];function es({nodeId:e,nodeStatus:a}){let[n,r]=(0,s.useState)(!1),[i,l]=(0,s.useState)(!1),[d,c]=(0,s.useState)(null),[o,m]=(0,s.useState)(null),[x,u]=(0,s.useState)(null),h="ONLINE"!==a,g=async t=>{if(!t.confirm||confirm(t.confirm)){c(t),m(null),u(null),l(!0),r(!0);try{let s=await p.f.quickCommand.exec(e,{command:t.command,args:t.args,timeoutSeconds:t.timeoutSeconds});m(s.data)}catch(e){u(e instanceof Error?e.message:"Command execution failed")}finally{l(!1)}}};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"rounded border border-border bg-surface p-3",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-[11px] text-text-muted mr-2",children:[(0,t.jsx)(G.f,{className:"h-4 w-4"}),(0,t.jsx)("span",{className:"font-bold uppercase tracking-wider",children:"Quick Commands"})]}),et.map(e=>(0,t.jsx)(S.K,{variant:e.variant,size:"sm",icon:e.icon,disabled:h,onClick:()=>void g(e),children:e.label},e.id)),h&&(0,t.jsx)("span",{className:"ml-2 text-xs text-text-muted",children:"Node must be ONLINE to run commands"})]})}),(0,t.jsx)($.n,{open:n,onClose:()=>r(!1),title:d?.label??"Command",description:d?`${d.command} ${(d.args??[]).join(" ")}`:void 0,icon:(0,t.jsx)(G.f,{className:"h-5 w-5 text-primary"}),className:"max-w-3xl",children:(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("div",{className:"flex items-center gap-2",children:i?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(E.f,{className:"h-4 w-4 animate-spin text-primary"}),(0,t.jsx)("span",{className:"text-xs text-primary",children:"Executing…"})]}):x?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Y.f,{className:"h-4 w-4 text-danger"}),(0,t.jsx)("span",{className:"text-xs text-danger",children:"Error"})]}):o?(0,t.jsxs)(t.Fragment,{children:[0===o.exitCode?(0,t.jsx)(X.f,{className:"h-4 w-4 text-success"}):(0,t.jsx)(Y.f,{className:"h-4 w-4 text-danger"}),(0,t.jsxs)("span",{className:`text-xs ${0===o.exitCode?"text-success":"text-danger"}`,children:["Exit code: ",o.exitCode]}),(0,t.jsxs)("span",{className:"text-xs text-text-muted flex items-center gap-1 ml-auto",children:[(0,t.jsx)(ee.f,{className:"h-3 w-3"}),(o.durationMs/1e3).toFixed(2),"s"]})]}):null}),x&&(0,t.jsx)("div",{className:"rounded bg-danger/10 border border-danger/30 p-3",children:(0,t.jsx)("p",{className:"text-xs text-danger",children:x})}),o&&(0,t.jsxs)("div",{className:"space-y-3",children:[o.stdout&&(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-[11px] font-bold uppercase tracking-wider text-text-muted mb-1",children:"stdout"}),(0,t.jsx)("pre",{className:"max-h-80 overflow-auto rounded bg-bg border border-border p-3 text-xs text-success whitespace-pre-wrap",children:o.stdout})]}),o.stderr&&(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-[11px] font-bold uppercase tracking-wider text-text-muted mb-1",children:"stderr"}),(0,t.jsx)("pre",{className:"max-h-40 overflow-auto rounded bg-bg border border-danger/20 p-3 text-xs text-danger whitespace-pre-wrap",children:o.stderr})]}),!o.stdout&&!o.stderr&&(0,t.jsx)("p",{className:"text-xs text-text-muted italic",children:"No output captured"}),o.truncated&&(0,t.jsx)("p",{className:"text-xs text-warning",children:"⚠ Output was truncated (exceeded 1MB)"})]}),i&&(0,t.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)(E.f,{className:"h-8 w-8 animate-spin text-primary mx-auto mb-2"}),(0,t.jsx)("p",{className:"text-xs text-text-muted",children:"Executing command on remote node…"})]})}),(0,t.jsx)("div",{className:"flex justify-end pt-2",children:(0,t.jsx)(S.K,{variant:"ghost",size:"sm",onClick:()=>r(!1),children:"Close"})})]})})]})}var ea=e.i(55427),en=e.i(28623);let er={workhorse:{name:"Workhorse",emoji:"🐴",description:"Steady, reliable, never complains.",accent:"success"},"drama-queen":{name:"Drama Queen",emoji:"🎭",description:"High variance, loves spiking CPU for attention.",accent:"warning"},"zen-master":{name:"Zen Master",emoji:"🧘",description:"Low usage, mind always clear, never stressed.",accent:"info"},sprinter:{name:"Sprinter",emoji:"⚡",description:"Bursts of intense activity followed by calm recovery.",accent:"info"},groundhog:{name:"Groundhog",emoji:"🌀",description:"Keeps rebooting — might see its own shadow again.",accent:"warning"},ghost:{name:"Ghost",emoji:"👻",description:"Often unreachable. Is it even there?",accent:"danger"},marathoner:{name:"Marathoner",emoji:"🏃",description:"Long uptime, steady pace, built to last.",accent:"success"},rookie:{name:"Rookie",emoji:"🌱",description:"Not enough history yet — still finding its rhythm.",accent:"default"}};function ei(e){return 0===e.length?0:e.reduce((e,t)=>e+t,0)/e.length}function el({node:e}){let[a,r]=(0,s.useState)([]),[i,l]=(0,s.useState)(!0),[d,c]=(0,s.useState)(null),[o,m]=(0,s.useState)(0);(0,s.useEffect)(()=>{let t=!1;return(async()=>{l(!0),c(null);try{let s=await p.f.get(`nodes/${e.id}/health/history?limit=100`);if(t)return;let a=s.data,n=[];Array.isArray(a)?n=a:a?.items&&(n=a.items),r([...n].reverse())}catch(e){t||(r([]),c(e instanceof Error?e.message:"Failed to load history"))}finally{t||l(!1)}})(),()=>{t=!0}},[e.id,o]);let x=(0,s.useMemo)(()=>{let t,s,n,r,i,l,d,c,o;return t=a.map(e=>e.cpuUsagePercent).filter(e=>Number.isFinite(e)),s=a.map(e=>e.memoryPercent).filter(e=>Number.isFinite(e)),n=ei(t),r=function(e){if(e.length<2)return 0;let t=ei(e);return Math.sqrt(e.reduce((e,s)=>e+(s-t)*(s-t),0)/(e.length-1))}(t),i=ei(s),l=t.filter(e=>e>80).length,d="rookie",c=er[d="OFFLINE"===e.status||e.lastHeartbeatAt&&Date.now()-new Date(e.lastHeartbeatAt).getTime()>6e5?"ghost":a.length<3?"rookie":r>25||l/Math.max(1,t.length)>.25?l/Math.max(1,t.length)>.4?"drama-queen":"sprinter":n<15&&r<10?"zen-master":n>40&&n<75&&r<15?"workhorse":n<40&&r<15&&a.length>20?"marathoner":"workhorse"]??er.rookie??{name:"Rookie",emoji:"🌱",description:"",accent:"default"},o=function(e,t,s){var a;let n,r=Math.floor(Date.now()/6048e5);for(let t=0;t<e.id.length;t++)r=31*r+e.id.charCodeAt(t)|0;let i={workhorse:[`Steady as they come — averaging ${s.cpuAvg.toFixed(0)}% CPU without a single complaint this week.`,`The dependable one. ${e.hostname} just keeps grinding through the workload.`,`Quietly productive at ~${s.cpuAvg.toFixed(0)}% CPU. Gets the job done and asks for nothing.`],"drama-queen":[`Lives for the spotlight — ${s.spikes} CPU spikes this week and counting.`,`${e.hostname} likes to keep things interesting with a \xb1${s.cpuSD.toFixed(0)}% swing.`,"A connoisseur of chaos. Never a dull moment with this one."],"zen-master":[`Practices minimalism. Barely breaks a sweat at ${s.cpuAvg.toFixed(0)}% CPU.`,`${e.hostname} is in its happy place — calm, cool, collected.`,"Achieving enlightenment one idle cycle at a time."],sprinter:[`Bursts of energy, then recovery. ${s.spikes} sprints logged this week.`,`${e.hostname} runs hot, then cools down. Classic sprinter cadence.`,"Lives in intervals — full throttle, then full zen."],groundhog:["Déjà vu all over again. Might want to check the uptime.",`${e.hostname} keeps hitting the reset button.`],ghost:["Hasn't been seen in a while. Anyone home?",`${e.hostname} is currently out of contact. Check the heartbeat.`],marathoner:[`In it for the long haul — ${s.samples} data points of pure consistency.`,`${e.hostname} doesn't sprint. It endures.`],rookie:["Still new around here — gathering experience.",`${e.hostname} is just getting started. Check back soon.`]};return n=Math.abs(r)%(a=i[t.name.toLowerCase().replace(" ","-")]??i.rookie??["…"]).length,a[n]}(e,c,{cpuAvg:n,cpuSD:r,memAvg:i,samples:t.length,spikes:l}),{archetype:c,archetypeKey:d,bio:o,stats:{cpuAvg:n,cpuStdDev:r,memAvg:i,samples:t.length,spikes:l}}},[e,a]),u=a.map(e=>e.cpuUsagePercent).slice(-40),h=a.map(e=>e.memoryPercent).slice(-40);return(0,t.jsx)(n.N,{title:"Personality",action:(0,t.jsx)("button",{onClick:()=>m(e=>e+1),className:"text-text-muted hover:text-text transition p-1",title:"Refresh personality","data-testid":"node-personality-refresh",children:(0,t.jsx)(J.f,{className:"h-3.5 w-3.5"})}),children:(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"node-personality-card","data-archetype":x.archetypeKey,children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("span",{className:"flex h-12 w-12 items-center justify-center rounded-full border border-accent/40 bg-bg text-2xl shadow-[0_0_16px_var(--color-glow-accent)]","aria-hidden":"true",children:x.archetype.emoji}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{"data-testid":"node-archetype-badge",children:(0,t.jsx)(b.t,{variant:x.archetype.accent,children:x.archetype.name})}),i&&(0,t.jsx)("span",{className:"text-xs text-text-muted italic",children:"analyzing…"})]}),(0,t.jsx)("p",{className:"mt-1 text-xs text-text-muted",children:x.archetype.description})]})]}),(0,t.jsx)(en.f,{className:"h-4 w-4 text-accent mt-1"})]}),(0,t.jsxs)("blockquote",{className:"border-l-2 border-accent/40 pl-3 text-sm italic text-text","data-testid":"node-personality-bio",children:["“",x.bio,"”"]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4 pt-2 border-t border-border/30",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,t.jsx)("span",{className:"text-xs uppercase tracking-wider text-text-muted",children:"CPU trend"}),(0,t.jsxs)("span",{className:"text-xs tabular-nums text-text-muted",children:["avg ",x.stats.cpuAvg.toFixed(0),"%"]})]}),(0,t.jsx)(ea.f,{values:u,tone:"primary",percent:!0,stretch:!0,threshold:80,testId:"node-personality-cpu-sparkline",label:`CPU trend, average ${x.stats.cpuAvg.toFixed(0)}%`})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,t.jsx)("span",{className:"text-xs uppercase tracking-wider text-text-muted",children:"Memory trend"}),(0,t.jsxs)("span",{className:"text-xs tabular-nums text-text-muted",children:["avg ",x.stats.memAvg.toFixed(0),"%"]})]}),(0,t.jsx)(ea.f,{values:h,tone:"accent",percent:!0,stretch:!0,threshold:80,testId:"node-personality-mem-sparkline",label:`Memory trend, average ${x.stats.memAvg.toFixed(0)}%`})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-4 text-[11px] text-text-muted",children:[(0,t.jsxs)("span",{children:[x.stats.samples," samples"]}),(0,t.jsxs)("span",{children:["σ ",x.stats.cpuStdDev.toFixed(1),"%"]}),(0,t.jsxs)("span",{children:[x.stats.spikes," spikes"]}),d&&(0,t.jsxs)("span",{className:"text-warning",children:["· ",d]})]})]})})}let ed={name:"fan",size:24,node:[["path",{d:"M10.827 16.379a6.082 6.082 0 0 1-8.618-7.002l5.412 1.45a6.082 6.082 0 0 1 7.002-8.618l-1.45 5.412a6.082 6.082 0 0 1 8.618 7.002l-5.412-1.45a6.082 6.082 0 0 1-7.002 8.618l1.45-5.412Z",key:"484a7f"}],["path",{d:"M12 12v.01",key:"u5ubse"}]]};ed.node;let ec=(0,m.f)(ed);var eo=e.i(71028);let em={name:"thermometer",size:24,node:[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]]};em.node;let ex=(0,m.f)(em);function eu(e,t){let s=e.map(e=>({timestamp:new Date(e.sampledAt).getTime(),value:t(e)})).filter(e=>null!==e.value);if(0===s.length)return"";let a=s[0].timestamp,n=Math.max(1,s.at(-1).timestamp-a);return s.map(({timestamp:e,value:t})=>{let s=104-.88*Math.max(0,Math.min(100,t));return`${((e-a)/n*600).toFixed(1)},${s.toFixed(1)}`}).join(" ")}function ep(e,t="%"){return null===e?"not reported":`${e.toFixed(1)}${t}`}function eh({telemetry:e}){let s=e?.latest??null,a=s?.devices??[],r=eu(e?.history??[],e=>e.maxUtilizationPercent),i=eu(e?.history??[],e=>e.maxFanPercent);return(0,t.jsx)(n.N,{title:"GPU telemetry",description:"30-second load and cooling history",action:s?(0,t.jsxs)(b.t,{variant:"default",children:["sampled ",(0,C.C)(s.sampledAt)]}):void 0,children:s&&0!==a.length?(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("div",{className:"grid gap-2 sm:grid-cols-2 xl:grid-cols-3",children:a.map(e=>(0,t.jsxs)("div",{className:"rounded-panel border border-border/70 bg-surface-raised/60 p-3 transition-colors hover:border-primary/30",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"truncate text-xs font-medium text-text",children:e.name}),(0,t.jsxs)("p",{className:"mt-0.5 text-[10px] uppercase tracking-wide text-text-muted",children:[e.vendor," · gpu ",e.index]})]}),100===e.fanPercent&&(0,t.jsx)(b.t,{variant:"danger",children:"fan saturated"})]}),(0,t.jsxs)("dl",{className:"mt-3 grid grid-cols-3 gap-2",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("dt",{className:"flex items-center gap-1 text-[10px] uppercase text-text-muted",children:[(0,t.jsx)(eo.f,{className:"h-3 w-3"}),"Load"]}),(0,t.jsx)("dd",{className:"mt-1 num text-sm text-primary",children:ep(e.utilizationPercent)})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("dt",{className:"flex items-center gap-1 text-[10px] uppercase text-text-muted",children:[(0,t.jsx)(ec,{className:"h-3 w-3"}),"Fan"]}),(0,t.jsx)("dd",{className:`mt-1 num text-sm ${100===e.fanPercent?"text-danger glow-text-danger":"text-warning"}`,children:ep(e.fanPercent)})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("dt",{className:"flex items-center gap-1 text-[10px] uppercase text-text-muted",children:[(0,t.jsx)(ex,{className:"h-3 w-3"}),"Temp"]}),(0,t.jsx)("dd",{className:"mt-1 num text-sm text-text",children:ep(e.temperatureCelsius,"°C")})]})]}),(0,t.jsxs)("div",{className:"mt-2 space-y-1",children:[(0,t.jsx)(l.f,{value:e.utilizationPercent,tone:"primary",label:`${e.name} load`}),(0,t.jsx)(l.f,{value:e.fanPercent,thresholds:{warn:80,crit:100},label:`${e.name} fan`})]})]},`${e.vendor}-${e.uuid??e.index}`))}),(0,t.jsxs)("div",{className:"panel-corners rounded-panel border border-border/70 bg-bg/60 p-3",children:[(0,t.jsxs)("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsx)("p",{className:"text-[10px] font-medium uppercase tracking-[0.16em] text-text-muted",children:"Host maximum · last 24 hours"}),(0,t.jsxs)("div",{className:"flex items-center gap-3 text-[10px] text-text-muted",children:[(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)("span",{className:"h-0.5 w-3 bg-primary shadow-[0_0_4px_var(--color-primary)]"}),"load"]}),(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)("span",{className:"h-0.5 w-3 bg-warning"}),"fan"]})]})]}),(0,t.jsxs)("svg",{viewBox:"0 0 600 112",className:"h-28 w-full",role:"img","aria-label":"GPU load and fan percentage over the last 24 hours",children:[(0,t.jsx)("line",{x1:"0",y1:"16",x2:"600",y2:"16",stroke:"var(--color-danger)",strokeOpacity:"0.45",strokeDasharray:"5 5"}),(0,t.jsx)("line",{x1:"0",y1:"60",x2:"600",y2:"60",stroke:"currentColor",strokeOpacity:"0.12"}),(0,t.jsx)("line",{x1:"0",y1:"104",x2:"600",y2:"104",stroke:"currentColor",strokeOpacity:"0.2"}),(0,t.jsx)("defs",{children:(0,t.jsxs)("linearGradient",{id:"gpu-load-fill",x1:"0",x2:"0",y1:"0",y2:"1",children:[(0,t.jsx)("stop",{offset:"0%",stopColor:"var(--color-primary)",stopOpacity:"0.35"}),(0,t.jsx)("stop",{offset:"100%",stopColor:"var(--color-primary)",stopOpacity:"0"})]})}),r&&(0,t.jsx)("polygon",{points:`0,104 ${r} 600,104`,fill:"url(#gpu-load-fill)"}),r&&(0,t.jsx)("polyline",{points:r,fill:"none",stroke:"var(--color-primary)",strokeWidth:"2",vectorEffect:"non-scaling-stroke"}),i&&(0,t.jsx)("polyline",{points:i,fill:"none",stroke:"var(--color-warning)",strokeWidth:"2",vectorEffect:"non-scaling-stroke"})]}),(0,t.jsxs)("div",{className:"mt-1 flex justify-between num text-[9px] text-text-muted",children:[(0,t.jsx)("span",{children:"24h ago"}),(0,t.jsx)("span",{children:"100% saturation line"}),(0,t.jsx)("span",{children:"now"})]})]})]}):(0,t.jsx)("div",{className:"rounded-panel border border-dashed border-border px-4 py-6 text-center text-xs text-text-muted",children:s?.status==="error"?"The GPU probe did not complete. Magnus will retry on the next heartbeat.":"No supported NVIDIA or AMD GPU was detected in the latest sample."})})}function eg(e){if("string"==typeof e)try{return JSON.parse(e)}catch{return[]}return e??[]}function ef(e){if(!e)return[];if("string"==typeof e)try{return JSON.parse(e)}catch{return[]}return e}function ej(e){return!!(e&&"not_installed"!==e.status)}function eN(e){let t=e.status.toLowerCase();return t.includes("enabled")&&!t.includes("not enabled")&&!t.includes("disabled")}function ev(e,t){let s=e.filter(eN).find(e=>{let s=`${e.slug} ${e.pluginType} ${e.metadata?.description??""}`.toLowerCase();return"search"===t?/\b(search|web)\b/.test(s):/\b(crawl|browser|firecrawl|browserbase|browser-use)\b/.test(s)});return s?`${s.slug}${s.version?` ${s.version}`:""}`:"none enabled"}e.s(["default",0,function(){var e,m;let x,u,h,g=(0,a.useParams)(),f=(0,a.useRouter)(),[N,v]=(0,s.useState)(null),[y,z]=(0,s.useState)(null),[G,J]=(0,s.useState)([]),[V,W]=(0,s.useState)(null),[Q,Z]=(0,s.useState)(!0),[X,Y]=(0,s.useState)(!1),[ee,et]=(0,s.useState)(!1),[ea,en]=(0,s.useState)([]),[er,ei]=(0,s.useState)({}),[ed,ec]=(0,s.useState)(null),[eo,em]=(0,s.useState)(!1),[ex,eu]=(0,s.useState)(null),[ep,eN]=(0,s.useState)(null),[ey,eb]=(0,s.useState)(null),[ew,ek]=(0,s.useState)(!1),[eS,e$]=(0,s.useState)(null),[eC,eA]=(0,s.useState)(!1),[eP,eU]=(0,s.useState)(!1),[eI,e_]=(0,s.useState)(null),[eE,eM]=(0,s.useState)(!1),[eD,eF]=(0,s.useState)(null),[eR,eO]=(0,s.useState)(null),[eL,ez]=(0,s.useState)(!1),eT=(0,s.useRef)(null),eH=(0,s.useRef)(void 0),eB=(0,s.useCallback)(async(e=!1)=>{try{e||Z(!0);let[t,s,a,n,r]=await Promise.all([p.f.nodes.get(g.nodeId),p.f.nodes.health(g.nodeId).catch(()=>null),p.f.nodes.forecast(g.nodeId).catch(()=>null),p.f.hermes.installations().catch(()=>null),p.f.nodes.gpu(g.nodeId).catch(()=>null)]),i=t.data;i.role||void 0===eH.current?i.role&&(eH.current=i.role):i.role=eH.current,v(i),s&&z(s.data),J(a?.data?.forecasts??[]),W(r?.data??null);let l=n?.data??[];ec(l.find(e=>e.nodeId===i.id)??l.find(e=>e.hostname===i.hostname||e.hostname===i.ipAddress)??null);try{let e=await p.f.roles.applications.list({nodeId:g.nodeId});en(e.data??[])}catch{}}catch{}finally{e||Z(!1)}},[g.nodeId]);(0,s.useEffect)(()=>{eB()},[eB]);let eq=async()=>{if(N&&confirm(`Deploy Hermes Agent to "${N.name}"?`)){eM(!0),eF(null),eO(null);try{let e,t=await p.f.hermes.deploy({nodeId:N.id,hermesHome:"~/.hermes",hermesBin:"hermes",installMethod:"official-script",dashboardPort:9119,enableDashboard:!0,enableDashboardTui:!0,startGateway:!0},(e="u">typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).slice(2),`hermes-node-deploy-${Date.now()}-${e}`));eF(`Hermes Agent deployment started. Job ${t.data?.id.slice(0,10)}...`),eB(!0)}catch(e){eO(e instanceof Error?e.message:"Hermes Agent deployment failed")}finally{eM(!1)}}};(0,s.useEffect)(()=>{let e=N?.status==="PROVISIONING"||N?.agent?.status==="UPDATING"||!!(eD&&!ej(ed));return e&&!eT.current?eT.current=setInterval(()=>{eB(!0)},4e3):!e&&eT.current&&(clearInterval(eT.current),eT.current=null),()=>{eT.current&&(clearInterval(eT.current),eT.current=null)}},[N?.status,N?.agent?.status,N?.agent?.version,eB,eD,ed]);let eK=async()=>{if(N&&confirm(`Delete node "${N.name}"? This will permanently remove it and all associated data.`))try{await p.f.nodes.delete(N.id),f.push("/nodes")}catch{}},eG=(0,s.useCallback)(async()=>{if(N?.status==="ONLINE"){em(!0),eu(null);try{let e='version_or_na() { local cmd="$1"; shift; if command -v "$cmd" >/dev/null 2>&1; then ("$@" 2>/dev/null || "$cmd" --version 2>/dev/null || "$cmd" -v 2>/dev/null || echo "unknown") | head -n 1; else echo "not installed"; fi; }; echo "node=$(version_or_na node node --version)"; echo "npm=$(version_or_na npm npm --version)"; echo "python3=$(version_or_na python3 python3 --version)"; echo "redis=$(version_or_na redis-cli redis-cli --version)"; echo "docker=$(version_or_na docker docker --version)"; echo "tailscale=$(version_or_na tailscale tailscale version)"; agent_manifest=/opt/magnus-agent/node_modules/@hivemagnus/magnus-agent/package.json; [ -f "$agent_manifest" ] || agent_manifest=/opt/magnus-agent/package.json; if [ -f "$agent_manifest" ]; then echo "magnus-agent=$(node -e \'process.stdout.write(require(process.argv[1]).version)\' "$agent_manifest" 2>/dev/null || echo unknown)"; else echo "magnus-agent=not installed"; fi'.replace(/'/g,"'\\''"),t=((await p.f.quickCommand.exec(N.id,{command:`bash -lc '${e}'`,args:[],timeoutSeconds:60})).data.stdout??"").trim(),s=Object.fromEntries(t.split("\n").map(e=>e.trim()).filter(e=>e.includes("=")).map(e=>{let[t,...s]=e.split("=");return[t,s.join("=").trim()||"unknown"]}));ei(s)}catch(e){eu(e instanceof Error?e.message:"Failed to load software revisions")}finally{em(!1)}}},[N?.id,N?.status]),eJ=(0,s.useCallback)(async()=>{if(N?.status==="ONLINE"){ek(!0),e$(null);try{let e="set -euo pipefail; (sudo apt-get update -qq || apt-get update -qq) >/dev/null 2>&1; apt list --upgradable 2>/dev/null | sed '1d' | sed '/^Listing/d' | wc -l".replace(/'/g,"'\\''"),t=((await p.f.quickCommand.exec(N.id,{command:`bash -lc '${e}'`,args:[],timeoutSeconds:180})).data.stdout??"").trim(),s=Number.parseInt(t.split("\n").at(-1)??"",10);eN(Number.isFinite(s)?s:null),eb(new Date().toISOString())}catch(e){e$(e instanceof Error?e.message:"Failed to refresh apt updates")}finally{ek(!1)}}},[N?.id,N?.status]),eV=async()=>{if(N&&confirm(`Run apt upgrade on "${N.name}"?`)){eA(!0);try{let e=`apt-upgrade-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,t=(await p.f.commands.dispatch({nodeIds:[N.id],command:"sudo",args:["apt","upgrade","-y"],timeoutSeconds:1800,idempotencyKey:e},e)).data,s=t.commands?.[0]?.id;alert(s?`APT Upgrade dispatched (command ${s.slice(0,12)}…). Check Commands for progress.`:"APT Upgrade dispatched. Check Commands for progress."),await eJ()}catch(e){alert(`APT Upgrade failed to dispatch: ${e instanceof Error?e.message:String(e)}`)}finally{eA(!1)}}},eW=async()=>{if(N&&confirm(`Enable unattended apt update and apt upgrade on "${N.name}"? Magnus will install unattended-upgrades and enable the apt timers.`)){eU(!0),e_(null);try{await p.f.nodes.enableSystemUpdates(N.id),await eB(!0)}catch(e){e_(e instanceof Error?e.message:"Failed to enable automatic updates")}finally{eU(!1)}}};if((0,s.useEffect)(()=>{eG(),eJ()},[eG,eJ]),(0,s.useEffect)(()=>{if(!N||"ONLINE"!==N.status)return;let e=setInterval(()=>{eJ()},36e5);return()=>clearInterval(e)},[N,eJ]),Q)return(0,t.jsxs)("div",{className:"space-y-6","aria-busy":"true",children:[(0,t.jsx)("div",{className:"skeleton h-56 w-full rounded-panel opacity-70"}),(0,t.jsx)(o.g,{}),(0,t.jsx)("span",{className:"sr-only",children:"Loading node details…"})]});if(!N)return(0,t.jsx)(c.f,{tone:"accent",icon:(0,t.jsx)(q.f,{className:"h-5 w-5"}),title:"Node not found",description:"It may have been decommissioned or belong to another control node.",action:(0,t.jsx)(S.K,{variant:"secondary",size:"sm",onClick:()=>f.push("/nodes"),children:"Back to nodes"}),className:"mt-12"});let eQ=ej(ed)?Array.isArray(ed.rawStatus?.skills)?ed.rawStatus.skills:[]:[],eZ=ej(ed)?Array.isArray(ed.rawStatus?.plugins)?ed.rawStatus.plugins:[]:[],eX=eQ.filter(e=>e.enabled),eY=ed?.configuration?.modelProvider??"unknown",e0=ed?.configuration?.modelName??"unknown",e1=ev(eZ,"search"),e2=ev(eZ,"crawl"),e3=function(e){if(!e)return null;try{let t="string"==typeof e?JSON.parse(e):e;if("boolean"!=typeof t.installed||!["active","inactive","failed","not_installed","unknown"].includes(t.serviceStatus)||!["enabled","disabled","static","unknown"].includes(t.enabled)||null!==t.version&&"string"!=typeof t.version||!Array.isArray(t.managerAddresses))return null;return t}catch{return null}}(y?.wazuh),e5=function(e){if(!e)return null;try{let t="string"==typeof e?JSON.parse(e):e;if("boolean"!=typeof t.supported||"string"!=typeof t.platform||!["enabled","disabled","partial","unsupported","unknown"].includes(t.automaticUpdates??"")||"boolean"!=typeof t.rebootRequired||!Array.isArray(t.timers)||!Array.isArray(t.rebootRequiredPackages))return null;return{...t,fullUpgradePolicyEnabled:!0===t.fullUpgradePolicyEnabled}}catch{return null}}(y?.systemUpdates);return(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)(r.f,{hero:!0,padding:"lg",tone:"ONLINE"===N.status?"primary":"OFFLINE"===N.status?"danger":"warning",testId:"node-cockpit",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,t.jsx)(S.K,{variant:"ghost",size:"sm",onClick:()=>f.push("/nodes"),"aria-label":"Back to nodes",children:(0,t.jsx)(U.f,{className:"h-4 w-4"})}),(0,t.jsx)(d.f,{status:N.status}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("h1",{className:"truncate text-2xl font-bold text-primary glow-text-primary",children:N.name}),(0,t.jsxs)("p",{className:"num mt-1 truncate text-xs text-text-muted",children:[N.hostname,":",N.port,N.agent&&(0,t.jsxs)("span",{className:"ml-3 text-primary/70",children:["agent v",N.agent.version]}),y?.source&&(0,t.jsxs)("span",{className:"ml-3 uppercase tracking-wider",children:["source: ",y.source]})]})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(b.t,{variant:(0,b.k)(N.status),children:N.status}),N.agent?.status==="UPDATING"&&(0,t.jsxs)(b.t,{variant:"info",children:[(0,t.jsx)(E.f,{className:"h-3 w-3 animate-spin mr-1 inline"}),"Upgrading…"]}),(0,t.jsx)(w,{metadata:N.metadata}),(0,t.jsx)(S.K,{variant:"secondary",size:"sm",icon:(0,t.jsx)(A.f,{className:"h-3.5 w-3.5"}),onClick:()=>Y(!0),children:"Edit"}),(0,t.jsx)(S.K,{variant:"danger",size:"sm",icon:(0,t.jsx)(P.f,{className:"h-3.5 w-3.5"}),onClick:()=>void eK(),children:"Delete"})]})]}),(0,t.jsxs)("div",{className:"mt-6 grid gap-6 xl:grid-cols-[auto_minmax(0,1fr)]",children:[(0,t.jsxs)("div",{className:"flex flex-wrap justify-center gap-4 sm:justify-start",children:[(0,t.jsx)(i.f,{value:y?.cpuUsagePercent??null,label:"CPU Usage",size:128,testId:"node-gauge-cpu"}),(0,t.jsx)(i.f,{value:y?.memoryPercent??null,label:"Memory",size:128,sublabel:y?`${(0,C.L)(y.memoryUsedBytes)}`:void 0,testId:"node-gauge-memory"}),(h=(y?eg(y.disks):[]).reduce((e,t)=>!e||t.usagePercent>e.usagePercent?t:e,null),(0,t.jsx)(i.f,{value:h?.usagePercent??null,label:"Disk",size:128,thresholds:{warn:80,crit:90},sublabel:h?.mountPoint,testId:"node-gauge-disk"}))]}),(0,t.jsx)(j,{nodeId:N.id,height:170})]})]}),("DEGRADED"===N.status||N.agent?.status==="ERROR")&&(()=>{try{let e=JSON.parse(N.metadata),s="string"==typeof e.deployError?e.deployError:null,a="string"==typeof e.upgradeError?e.upgradeError:null,n=s??a;if(n)return(0,t.jsx)("div",{className:"rounded-panel border border-danger/40 bg-danger/5 p-4 shadow-[inset_3px_0_0_var(--color-danger),0_0_20px_var(--color-glow-danger)]",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)(_.f,{className:"h-5 w-5 text-danger shrink-0 mt-0.5"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium text-danger",children:s?"Deploy Failed":"Agent Upgrade Failed"}),(0,t.jsx)("pre",{className:"mt-1 text-xs text-text-muted whitespace-pre-wrap font-mono",children:n})]})]})})}catch{}return null})(),"PROVISIONING"===N.status&&(0,t.jsx)("div",{className:"rounded-panel border border-info/40 bg-info/5 p-4 shadow-[inset_3px_0_0_var(--color-info)]",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(E.f,{className:"h-5 w-5 text-info animate-spin"}),(0,t.jsx)("p",{className:"text-xs uppercase tracking-wider text-info",children:"Deploying agent… Status will update automatically."})]})}),N.agent?.status==="UPDATING"&&(0,t.jsx)("div",{className:"rounded-panel border border-info/40 bg-info/5 p-4 shadow-[inset_3px_0_0_var(--color-info)]",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(E.f,{className:"h-5 w-5 text-info animate-spin"}),(0,t.jsx)("p",{className:"text-xs uppercase tracking-wider text-info",children:"Agent upgrade in progress… Status will update automatically."})]})}),(0,t.jsx)(es,{nodeId:N.id,nodeStatus:N.status}),(0,t.jsx)(eh,{telemetry:V}),(0,t.jsx)(el,{node:{id:N.id,name:N.name,hostname:N.hostname,status:N.status,lastHeartbeatAt:N.lastHeartbeatAt}}),(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]",children:[(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsx)(n.N,{title:"Node Information",children:(0,t.jsxs)("dl",{className:"space-y-2 text-sm",children:[[["OS",N.os],["Architecture",N.arch],["Address",`${N.ipAddress}:${N.port}`],["Tags",(()=>{try{let e=JSON.parse(N.tags);return e.length?e.join(", "):"—"}catch{return"—"}})()]].map(([e,s])=>(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("dt",{className:"text-text-muted",children:e}),(0,t.jsx)("dd",{className:"font-medium",children:s})]},e)),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("dt",{className:"text-text-muted",children:"Agent Version"}),(0,t.jsx)("dd",{className:"font-medium flex items-center gap-1.5",children:N.agent?.version??"—"})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("dt",{className:"text-text-muted",children:"Role"}),(0,t.jsx)("dd",{className:"font-medium",children:N.role?(0,t.jsxs)("button",{className:"inline-flex items-center gap-1 rounded-md bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary hover:bg-primary/20 transition-colors cursor-pointer",onClick:()=>et(!0),title:"Change role",children:[(0,t.jsx)(D.f,{className:"h-3 w-3"}),N.role.name]}):(0,t.jsx)("button",{className:"text-xs text-text-muted hover:text-primary transition-colors cursor-pointer",onClick:()=>et(!0),children:"+ Assign Role"})})]}),[["Agent Status",N.agent?.status??"—"],["Last Heartbeat",(0,C.C)(N.lastHeartbeatAt)]].map(([e,s])=>(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("dt",{className:"text-text-muted",children:e}),(0,t.jsx)("dd",{className:"font-medium",children:s})]},e)),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("dt",{className:"text-text-muted",children:"Cockpit"}),(0,t.jsx)("dd",{className:"font-medium",children:y?.cockpitAvailable?(0,t.jsxs)("a",{href:`https://${N.ipAddress}:9090`,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline flex items-center gap-1",children:["Available",(0,t.jsx)(M.f,{className:"h-3 w-3"})]}):(0,t.jsx)("span",{className:"text-text-muted",children:"Not Available"})})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("dt",{className:"text-text-muted",children:"CPU Cores"}),(0,t.jsx)("dd",{className:"font-medium",children:y?.cpuCores??"—"})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("dt",{className:"text-text-muted",children:"Memory Used"}),(0,t.jsx)("dd",{className:"font-medium",children:y?`${(0,C.L)(y.memoryUsedBytes)} / ${(0,C.L)(y.memoryTotalBytes)}`:"—"})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("dt",{className:"text-text-muted",children:"Swap Used"}),(0,t.jsx)("dd",{className:"font-medium",children:y&&y.swapTotalBytes?`${(0,C.L)(y.swapUsedBytes??0)} / ${(0,C.L)(y.swapTotalBytes)}`:"—"})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("dt",{className:"text-text-muted",children:"Last Health Sample"}),(0,t.jsx)("dd",{className:"font-medium",children:y?(0,C.C)(y.timestamp):"—"})]})]})}),(0,t.jsx)(n.N,{title:"Hermes Agent",description:ej(ed)?ed.displayName??ed.hostname:"No Hermes Agent installed or found",action:ej(ed)?(0,t.jsx)(b.t,{variant:(0,b.k)(ed.status),children:ed.status}):void 0,children:ej(ed)?(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("dl",{className:"grid gap-2 text-sm sm:grid-cols-2",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs uppercase tracking-wide text-text-muted",children:"Version"}),(0,t.jsx)("dd",{className:"font-mono text-xs",children:ed.version??"unknown"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs uppercase tracking-wide text-text-muted",children:"Home"}),(0,t.jsx)("dd",{className:"font-mono text-xs break-all",children:ed.hermesHome})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs uppercase tracking-wide text-text-muted",children:"Dashboard"}),(0,t.jsxs)("dd",{className:"mt-1 flex items-center gap-2",children:[(0,t.jsx)(b.t,{variant:(0,b.k)(ed.dashboardStatus),children:ed.dashboardStatus}),(0,t.jsx)("span",{className:"font-mono text-xs",children:(u=""===(x=(m=ed).dashboardHost.trim().toLowerCase().replace(/^\[|\]$/g,""))||"0.0.0.0"===x||"127.0.0.1"===x||"localhost"===x||"::"===x||"::1"===x?m.hostname:m.dashboardHost,`${u}:${m.dashboardPort}`)})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs uppercase tracking-wide text-text-muted",children:"Gateway"}),(0,t.jsx)("dd",{className:"mt-1",children:(0,t.jsx)(b.t,{variant:(0,b.k)(ed.gatewayStatus),children:ed.gatewayStatus})})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs uppercase tracking-wide text-text-muted",children:"API Server"}),(0,t.jsx)("dd",{className:"font-mono text-xs",children:ed.apiServerEnabled?`${ed.apiServerHost}:${ed.apiServerPort??"—"}`:"disabled"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs uppercase tracking-wide text-text-muted",children:"Primary Provider"}),(0,t.jsxs)("dd",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[(0,t.jsx)(b.t,{variant:"unknown"===eY?"warning":"success",children:eY}),ed.configuration?.magnusRouterConfigured&&(0,t.jsx)(b.t,{variant:"success",children:"Magnus routed"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs uppercase tracking-wide text-text-muted",children:"Default Model"}),(0,t.jsx)("dd",{className:"font-mono text-xs break-all",children:e0})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs uppercase tracking-wide text-text-muted",children:"OpenAI Runtime"}),(0,t.jsx)("dd",{className:"mt-1",children:(0,t.jsx)(b.t,{variant:ed.configuration?.openaiRuntime==="codex_app_server"?"success":"warning",children:ed.configuration?.openaiRuntime==="codex_app_server"?"Codex app-server":"Hermes default"})})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs uppercase tracking-wide text-text-muted",children:"Web Search"}),(0,t.jsxs)("dd",{className:"mt-1 flex items-center gap-2 text-xs",children:[(0,t.jsx)(L.f,{className:"h-3.5 w-3.5 text-text-muted"}),(0,t.jsx)("span",{className:"font-mono break-all",children:e1})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs uppercase tracking-wide text-text-muted",children:"Crawling"}),(0,t.jsxs)("dd",{className:"mt-1 flex items-center gap-2 text-xs",children:[(0,t.jsx)(T,{className:"h-3.5 w-3.5 text-text-muted"}),(0,t.jsx)("span",{className:"font-mono break-all",children:e2})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs uppercase tracking-wide text-text-muted",children:"Memory"}),(0,t.jsxs)("dd",{className:"mt-1",children:[(0,t.jsx)(b.t,{variant:ed.configuration?.hiveMemConfigured?"success":"warning",children:ed.configuration?.memoryProvider??"not configured"}),(0,t.jsx)(k.f,{configuration:ed.configuration})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs uppercase tracking-wide text-text-muted",children:"Skills"}),(0,t.jsx)("dd",{className:"mt-1",children:(0,t.jsxs)("button",{type:"button",onClick:()=>ez(!0),className:"inline-flex items-center gap-1.5 rounded border border-border px-2 py-1 text-xs text-text hover:border-primary/60 hover:text-primary disabled:cursor-not-allowed disabled:opacity-50",disabled:0===eQ.length,children:[(0,t.jsx)(O.f,{className:"h-3.5 w-3.5"}),function(e){if(0===e.length)return"0 synced";let t=e.filter(e=>e.enabled).length;return`${t} enabled / ${e.length} total`}(eQ)]})})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-xs uppercase tracking-wide text-text-muted",children:"Last Sync"}),(0,t.jsx)("dd",{className:"text-xs",children:(0,C.C)(ed.lastSyncedAt)})]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[ed.configuration?.modelBaseUrl&&(0,t.jsxs)("p",{className:"text-xs text-text-muted",children:["Base URL: ",(0,t.jsx)("span",{className:"font-mono",children:ed.configuration.modelBaseUrl})]}),ed.configuration?.configPath&&(0,t.jsxs)("p",{className:"text-xs text-text-muted",children:["Config: ",(0,t.jsx)("span",{className:"font-mono",children:ed.configuration.configPath})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(ed.profiles??[]).slice(0,6).map(e=>(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[10px] text-text-muted",children:[(0,t.jsx)(F.f,{className:"h-3 w-3"}),e.name]},e.id)),(ed.profiles?.length??0)===0&&(0,t.jsx)("span",{className:"text-xs text-text-muted",children:"No profiles synced"})]}),(0,t.jsx)(S.K,{size:"sm",variant:"secondary",icon:(0,t.jsx)(M.f,{className:"h-3.5 w-3.5"}),onClick:()=>f.push(`/orchestra/web-gateway?installationId=${encodeURIComponent(ed.id)}`),children:"Open Dashboard"})]}):(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("p",{className:"text-sm text-text-muted",children:"No Hermes Agent is installed or currently detected on this node."}),eD&&(0,t.jsx)("p",{className:"text-xs text-success",children:eD}),eR&&(0,t.jsx)("p",{className:"text-xs text-danger",children:eR}),(0,t.jsx)(S.K,{size:"sm",variant:"secondary",icon:eE?(0,t.jsx)(E.f,{className:"h-3.5 w-3.5 animate-spin"}):(0,t.jsx)(R.f,{className:"h-3.5 w-3.5"}),disabled:!N||"ONLINE"!==N.status||eE,onClick:()=>void eq(),children:eE?"Starting Deployment...":"Deploy Hermes Agent"}),N?.status!=="ONLINE"&&(0,t.jsx)("p",{className:"text-xs text-text-muted",children:"Bring the Magnus agent online before starting automated Hermes deployment."})]})}),(0,t.jsx)(n.N,{title:"Service Checks",children:y&&ef(y.services).length>0?(0,t.jsx)("div",{className:"space-y-2 text-sm",children:ef(y.services).slice(0,8).map(e=>(0,t.jsxs)("div",{className:"flex items-center justify-between rounded border border-border px-2 py-1.5",children:[(0,t.jsx)("span",{className:"font-medium",children:e.name}),(0,t.jsx)(b.t,{variant:"active"===e.status?"success":"failed"===e.status?"danger":"default",children:e.status})]},e.name))}):(0,t.jsx)("p",{className:"text-sm text-text-muted",children:"No service checks available from this node yet."})})]}),(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsx)(n.N,{title:"System Update Readiness",description:"Automatic apt policy and reboot state from the latest heartbeat",action:e5?(0,t.jsx)(b.t,{variant:e5.rebootRequired?"danger":"enabled"===e5.automaticUpdates?"success":"warning",children:e5.rebootRequired?"reboot required":e5.automaticUpdates.replace("_"," ")}):void 0,children:e5?(0,t.jsxs)("div",{className:"space-y-4",children:[e5.rebootRequired&&(0,t.jsxs)("div",{className:"flex gap-3 rounded border border-danger/30 bg-danger/10 p-3",children:[(0,t.jsx)(B.f,{className:"mt-0.5 h-4 w-4 shrink-0 text-danger"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium text-danger",children:"Restart needed to finish installed updates"}),(0,t.jsx)("p",{className:"mt-1 text-xs text-text-muted",children:e5.rebootRequiredPackages.length?e5.rebootRequiredPackages.slice(0,5).join(", "):"The operating system has set the reboot-required marker."})]})]}),(0,t.jsxs)("dl",{className:"space-y-2 text-sm",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("dt",{className:"text-text-muted",children:"Platform"}),(0,t.jsx)("dd",{className:"font-mono text-xs",children:e5.platform})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("dt",{className:"text-text-muted",children:"Automatic updates"}),(0,t.jsx)("dd",{children:(0,t.jsx)(b.t,{variant:"enabled"===e5.automaticUpdates?"success":"warning",children:e5.automaticUpdates})})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("dt",{className:"text-text-muted",children:"unattended-upgrades"}),(0,t.jsx)("dd",{children:e5.unattendedUpgradesInstalled?"installed":"not installed"})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("dt",{className:"text-text-muted",children:"full apt upgrade policy"}),(0,t.jsx)("dd",{children:e5.fullUpgradePolicyEnabled?"enabled":"not enabled"})]}),e5.timers.map(e=>(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("dt",{className:"font-mono text-[11px] text-text-muted",children:e.name}),(0,t.jsx)("dd",{className:"font-mono text-[11px]",children:e.state})]},e.name))]}),e5.supported&&"enabled"!==e5.automaticUpdates&&(0,t.jsxs)(S.K,{size:"sm",variant:"primary",disabled:"ONLINE"!==N.status||eP,onClick:()=>void eW(),children:[eP?(0,t.jsx)(E.f,{className:"h-3.5 w-3.5 animate-spin"}):(0,t.jsx)(H.f,{className:"h-3.5 w-3.5"}),eP?"Enabling…":"Enable automatic updates"]}),eI&&(0,t.jsx)("p",{className:"text-xs text-danger",children:eI})]}):(0,t.jsx)("p",{className:"text-sm text-text-muted",children:"Update posture will appear after agent v1.6.0 reports its first heartbeat."})}),(0,t.jsx)(n.N,{title:"Wazuh Agent",description:"Endpoint-security posture from the latest node heartbeat",action:e3?(0,t.jsx)(b.t,{variant:"active"===(e=e3.serviceStatus)?"success":"failed"===e?"danger":"inactive"===e?"warning":"default",children:e3.serviceStatus.replace("_"," ")}):void 0,children:e3?(0,t.jsxs)("dl",{className:"space-y-2 text-sm",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("dt",{className:"text-text-muted",children:"Installation"}),(0,t.jsx)("dd",{children:(0,t.jsx)(b.t,{variant:e3.installed?"success":"default",children:e3.installed?"installed":"not installed"})})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("dt",{className:"text-text-muted",children:"Startup"}),(0,t.jsx)("dd",{className:"font-medium",children:e3.enabled})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("dt",{className:"text-text-muted",children:"Version"}),(0,t.jsx)("dd",{className:"font-mono text-xs",children:e3.version??"—"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("dt",{className:"text-text-muted",children:"Managers"}),(0,t.jsx)("dd",{className:"mt-1 font-mono text-xs break-all",children:e3.managerAddresses.length?e3.managerAddresses.join(", "):"—"})]})]}):(0,t.jsx)("p",{className:"text-sm text-text-muted",children:"Wazuh posture will appear after this host reports a current Magnus agent heartbeat."})}),(0,t.jsx)(n.N,{title:"Disk Usage",children:y&&eg(y.disks).length?(0,t.jsx)("div",{className:"space-y-3",children:eg(y.disks).map(e=>(0,t.jsxs)("div",{className:"text-sm",children:[(0,t.jsxs)("div",{className:"flex justify-between text-xs",children:[(0,t.jsx)("span",{className:"text-text-muted",children:e.mountPoint}),(0,t.jsxs)("span",{className:"num",children:[(0,C.L)(e.usedBytes)," / ",(0,C.L)(e.totalBytes)]})]}),(0,t.jsx)(l.f,{value:e.usagePercent,thresholds:{warn:80,crit:90},size:"sm",label:`${e.mountPoint} disk usage`,showValue:!0,className:"mt-1"})]},e.mountPoint))}):(0,t.jsx)("p",{className:"text-sm text-text-muted",children:"No disk data available"})}),(0,t.jsx)(n.N,{title:"Capacity Forecast",description:"Per-volume 30-day growth trend and estimated time to full",children:G.length?(0,t.jsx)("div",{className:"space-y-3",children:G.map(e=>(0,t.jsxs)("div",{className:"rounded border border-border/50 p-3 text-xs",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("span",{className:"font-mono text-text",children:e.mountPoint}),(0,t.jsx)(b.t,{variant:null!==e.daysUntilFull&&e.daysUntilFull<=14?"danger":null!==e.daysUntilFull&&e.daysUntilFull<=30?"warning":"default",children:null===e.daysUntilFull?e.growthRatePerDay>0?"trend uncertain":"stable/shrinking":`${e.daysUntilFull}d to full`})]}),(0,t.jsxs)("div",{className:"mt-2 text-text-muted",children:[e.currentUsagePercent.toFixed(1),"% used · ",(0,C.L)(Math.abs(e.growthRatePerDay)),"/day ",e.growthRatePerDay>=0?"growth":"reclaimed"," · confidence ",(100*e.confidence).toFixed(0),"%"]}),(0,t.jsx)("p",{className:"mt-2 text-text-muted",children:e.recommendation})]},e.mountPoint))}):(0,t.jsx)("p",{className:"text-sm text-text-muted",children:"At least three retained samples are needed for a capacity forecast."})}),(0,t.jsxs)(n.N,{title:"Software Revisions",description:"Major runtime versions and package update status",action:(0,t.jsx)(S.K,{variant:"ghost",size:"sm",onClick:()=>void eG(),children:(0,t.jsx)(I.f,{className:`h-3.5 w-3.5 ${eo?"animate-spin":""}`})}),children:[(0,t.jsxs)("div",{className:"space-y-2 text-sm",children:[["node","npm","python3","redis","docker","tailscale","magnus-agent"].map(e=>(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsx)("dt",{className:"text-text-muted uppercase text-xs tracking-wide",children:e}),(0,t.jsx)("dd",{className:"font-mono text-right text-xs break-all",children:er[e]??(eo?"Loading…":"—")})]},e)),ex&&(0,t.jsx)("p",{className:"text-xs text-danger",children:ex})]}),(0,t.jsxs)("div",{className:"mt-4 border-t border-border pt-4 space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-xs uppercase tracking-wide text-text-muted",children:"APT Updates"}),(0,t.jsx)(b.t,{variant:ep&&ep>0?"warning":"success",children:ew?"Checking…":`${ep??"—"} pending`})]}),(0,t.jsxs)("p",{className:"text-xs text-text-muted",children:["Refreshed hourly via apt update",ey?` • Last check: ${(0,C.C)(ey)}`:""]}),eS&&(0,t.jsx)("p",{className:"text-xs text-danger",children:eS}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsxs)(S.K,{size:"sm",variant:"secondary",disabled:"ONLINE"!==N.status||ew,onClick:()=>void eJ(),children:[(0,t.jsx)(I.f,{className:`h-3.5 w-3.5 ${ew?"animate-spin":""}`}),"Refresh"]}),(0,t.jsxs)(S.K,{size:"sm",variant:"primary",disabled:"ONLINE"!==N.status||eC,onClick:()=>void eV(),children:[eC?(0,t.jsx)(E.f,{className:"h-3.5 w-3.5 animate-spin"}):null,eC?"Dispatching…":"APT Upgrade"]})]})]})]})]})]}),ea.length>0&&(0,t.jsx)(n.N,{title:"Role Applications",children:(0,t.jsx)("div",{className:"space-y-4",children:ea.map(e=>(0,t.jsxs)("div",{className:"rounded-lg border border-border p-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(D.f,{className:"h-4 w-4 text-primary"}),(0,t.jsxs)("span",{className:"text-sm font-medium",children:["apply"===e.action?"Apply":"Remove",": ",e.role?.name??"Unknown"]})]}),(0,t.jsx)(b.t,{variant:"completed"===e.status?"success":"failed"===e.status?"danger":"running"===e.status?"info":"default",children:e.status})]}),e.error&&(0,t.jsx)("div",{className:"mb-2 rounded border border-danger/30 bg-danger/10 px-2 py-1 text-xs text-danger font-mono",children:e.error}),(0,t.jsx)("div",{className:"space-y-1",children:e.steps.map(e=>(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,t.jsxs)("span",{className:"completed"===e.status?"text-success":"failed"===e.status?"text-danger":"running"===e.status?"text-info":"skipped"===e.status?"text-text-muted/50":"text-text-muted",children:["completed"===e.status&&"✓","failed"===e.status&&"✗","running"===e.status&&"⟳","skipped"===e.status&&"—","pending"===e.status&&"○"]}),(0,t.jsx)("span",{className:"skipped"===e.status?"text-text-muted/50 line-through":"",children:e.name}),e.error&&(0,t.jsx)("span",{className:"text-danger ml-2 truncate max-w-xs",title:e.error,children:e.error})]},e.name))}),(0,t.jsxs)("div",{className:"mt-2 text-[10px] text-text-muted",children:[e.startedAt?`Started: ${(0,C.C)(e.startedAt)}`:"",e.completedAt?` — Completed: ${(0,C.C)(e.completedAt)}`:""]})]},e.id))})}),(0,t.jsx)($.n,{open:eL,onClose:()=>ez(!1),title:"Hermes Skills",description:`${eX.length} enabled on ${N.name}`,icon:(0,t.jsx)(O.f,{className:"h-5 w-5 text-primary"}),className:"max-w-3xl",children:(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"grid gap-3 sm:grid-cols-3",children:[(0,t.jsxs)("div",{className:"rounded border border-border bg-bg/50 p-3",children:[(0,t.jsx)("p",{className:"text-[10px] uppercase tracking-wide text-text-muted",children:"Enabled"}),(0,t.jsx)("p",{className:"mt-1 text-lg font-semibold",children:eX.length})]}),(0,t.jsxs)("div",{className:"rounded border border-border bg-bg/50 p-3",children:[(0,t.jsx)("p",{className:"text-[10px] uppercase tracking-wide text-text-muted",children:"Total"}),(0,t.jsx)("p",{className:"mt-1 text-lg font-semibold",children:eQ.length})]}),(0,t.jsxs)("div",{className:"rounded border border-border bg-bg/50 p-3",children:[(0,t.jsx)("p",{className:"text-[10px] uppercase tracking-wide text-text-muted",children:"Sources"}),(0,t.jsx)("p",{className:"mt-1 text-sm font-mono",children:Array.from(new Set(eQ.map(e=>e.source))).filter(Boolean).join(", ")||"unknown"})]})]}),(0,t.jsxs)("div",{className:"max-h-[55vh] overflow-auto rounded border border-border",children:[(0,t.jsxs)("table",{className:"w-full text-left text-xs",children:[(0,t.jsx)("thead",{className:"sticky top-0 bg-surface text-[10px] uppercase tracking-wide text-text-muted",children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{className:"px-3 py-2 font-medium",children:"Skill"}),(0,t.jsx)("th",{className:"px-3 py-2 font-medium",children:"Category"}),(0,t.jsx)("th",{className:"px-3 py-2 font-medium",children:"Source"}),(0,t.jsx)("th",{className:"px-3 py-2 font-medium",children:"Status"})]})}),(0,t.jsx)("tbody",{className:"divide-y divide-border",children:eQ.slice().sort((e,t)=>Number(t.enabled)-Number(e.enabled)||e.slug.localeCompare(t.slug)).map(e=>(0,t.jsxs)("tr",{className:"bg-bg/20",children:[(0,t.jsx)("td",{className:"px-3 py-2 font-mono",children:e.slug}),(0,t.jsx)("td",{className:"px-3 py-2 text-text-muted",children:e.category??"uncategorized"}),(0,t.jsx)("td",{className:"px-3 py-2 text-text-muted",children:e.source}),(0,t.jsx)("td",{className:"px-3 py-2",children:(0,t.jsx)(b.t,{variant:e.enabled?"success":"default",children:e.enabled?"enabled":"disabled"})})]},`${e.slug}-${e.source}`))})]}),0===eQ.length&&(0,t.jsx)("div",{className:"p-6 text-sm text-text-muted",children:"No synced Hermes skills were reported for this node."})]})]})}),(0,t.jsx)(K.F,{open:X,node:N,onClose:()=>Y(!1),onSaved:()=>void eB()}),(0,t.jsx)(K.E,{open:ee,node:N?{id:N.id,name:N.name,role:N.role}:null,onClose:()=>et(!1),onSaved:e=>{eH.current=e,N&&v({...N,role:e}),eB()}})]})}],5525)}]);