rigscope 0.1.3 → 0.1.5

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 (118) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-path-routes-manifest.json +3 -3
  3. package/.next/build-manifest.json +2 -2
  4. package/.next/prerender-manifest.json +6 -6
  5. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  6. package/.next/server/app/_global-error.html +1 -1
  7. package/.next/server/app/_global-error.rsc +1 -1
  8. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  11. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  12. package/.next/server/app/_not-found.html +1 -1
  13. package/.next/server/app/_not-found.rsc +2 -2
  14. package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  15. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  16. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  17. package/.next/server/app/administration/page_client-reference-manifest.js +1 -1
  18. package/.next/server/app/administration.html +1 -1
  19. package/.next/server/app/administration.rsc +3 -3
  20. package/.next/server/app/administration.segments/_full.segment.rsc +3 -3
  21. package/.next/server/app/administration.segments/_tree.segment.rsc +2 -2
  22. package/.next/server/app/administration.segments/administration/__PAGE__.segment.rsc +3 -3
  23. package/.next/server/app/alerts/page.js +1 -1
  24. package/.next/server/app/alerts/page_client-reference-manifest.js +1 -1
  25. package/.next/server/app/alerts.html +1 -1
  26. package/.next/server/app/alerts.rsc +4 -4
  27. package/.next/server/app/alerts.segments/_full.segment.rsc +4 -4
  28. package/.next/server/app/alerts.segments/_tree.segment.rsc +2 -2
  29. package/.next/server/app/alerts.segments/alerts/__PAGE__.segment.rsc +4 -4
  30. package/.next/server/app/connections/page.js +1 -1
  31. package/.next/server/app/connections/page.js.nft.json +1 -1
  32. package/.next/server/app/connections/page_client-reference-manifest.js +1 -1
  33. package/.next/server/app/connections.html +1 -1
  34. package/.next/server/app/connections.rsc +6 -6
  35. package/.next/server/app/connections.segments/_full.segment.rsc +6 -6
  36. package/.next/server/app/connections.segments/_tree.segment.rsc +2 -2
  37. package/.next/server/app/connections.segments/connections/__PAGE__.segment.rsc +6 -6
  38. package/.next/server/app/history/page_client-reference-manifest.js +1 -1
  39. package/.next/server/app/history.html +1 -1
  40. package/.next/server/app/history.rsc +4 -4
  41. package/.next/server/app/history.segments/_full.segment.rsc +4 -4
  42. package/.next/server/app/history.segments/_tree.segment.rsc +2 -2
  43. package/.next/server/app/history.segments/history/__PAGE__.segment.rsc +4 -4
  44. package/.next/server/app/index.html +1 -1
  45. package/.next/server/app/index.rsc +6 -6
  46. package/.next/server/app/index.segments/__PAGE__.segment.rsc +6 -6
  47. package/.next/server/app/index.segments/_full.segment.rsc +6 -6
  48. package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  49. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  50. package/.next/server/app/login.html +1 -1
  51. package/.next/server/app/login.rsc +2 -2
  52. package/.next/server/app/login.segments/_full.segment.rsc +2 -2
  53. package/.next/server/app/login.segments/_tree.segment.rsc +2 -2
  54. package/.next/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
  55. package/.next/server/app/machines/[machineId]/page.js +1 -1
  56. package/.next/server/app/machines/[machineId]/page.js.nft.json +1 -1
  57. package/.next/server/app/machines/[machineId]/page_client-reference-manifest.js +1 -1
  58. package/.next/server/app/page.js +1 -1
  59. package/.next/server/app/page.js.nft.json +1 -1
  60. package/.next/server/app/page_client-reference-manifest.js +1 -1
  61. package/.next/server/app/processes/page.js +1 -1
  62. package/.next/server/app/processes/page_client-reference-manifest.js +1 -1
  63. package/.next/server/app/processes.html +1 -1
  64. package/.next/server/app/processes.rsc +4 -4
  65. package/.next/server/app/processes.segments/_full.segment.rsc +4 -4
  66. package/.next/server/app/processes.segments/_tree.segment.rsc +2 -2
  67. package/.next/server/app/processes.segments/processes/__PAGE__.segment.rsc +4 -4
  68. package/.next/server/app-paths-manifest.json +3 -3
  69. package/.next/server/chunks/168.js +1 -1
  70. package/.next/server/chunks/364.js +1 -0
  71. package/.next/server/chunks/751.js +1 -1
  72. package/.next/server/middleware-build-manifest.js +1 -1
  73. package/.next/server/pages/404.html +1 -1
  74. package/.next/server/pages/500.html +1 -1
  75. package/.next/static/chunks/103-13ec30dcc059b9d3.js +1 -0
  76. package/.next/static/chunks/{227-417939c480f50747.js → 130-e940915010276f88.js} +1 -1
  77. package/.next/static/chunks/408-29f55984738967db.js +1 -0
  78. package/.next/static/chunks/app/alerts/{page-fe0e877778c60af8.js → page-2548b2ab0c057953.js} +1 -1
  79. package/.next/static/chunks/app/connections/{page-99cd54d6929b3f1f.js → page-07113bf16cb352e7.js} +1 -1
  80. package/.next/static/chunks/app/machines/[machineId]/page-0b89e4393a137c4d.js +1 -0
  81. package/.next/static/chunks/app/{page-1ae9fc94c897785b.js → page-c68554c93016dd13.js} +1 -1
  82. package/.next/static/chunks/app/processes/{page-0e98a4a64e829c5f.js → page-b6d97d119f10e2a1.js} +3 -3
  83. package/.next/static/css/fb3ad9534f4681e6.css +1 -0
  84. package/CHANGELOG.md +35 -0
  85. package/DESIGN.md +27 -16
  86. package/README.md +2 -0
  87. package/dist/cli.cjs +2366 -1930
  88. package/dist/collector.cjs +18 -7
  89. package/dist/hub.cjs +1 -1
  90. package/docs/installation.md +77 -25
  91. package/docs/operations.md +13 -7
  92. package/docs/releasing.md +12 -12
  93. package/package.json +1 -1
  94. package/.next/server/chunks/877.js +0 -1
  95. package/.next/server/route-cache/APP_PAGE/16d1ab46157a868f438fa01e04bf53e805c71cddec593ea1535905c59625cd42/$/login.html +0 -1
  96. package/.next/server/route-cache/APP_PAGE/16d1ab46157a868f438fa01e04bf53e805c71cddec593ea1535905c59625cd42/$/login.meta +0 -1
  97. package/.next/server/route-cache/APP_PAGE/16d1ab46157a868f438fa01e04bf53e805c71cddec593ea1535905c59625cd42/$/login.rsc +0 -26
  98. package/.next/server/route-cache/APP_PAGE/16d1ab46157a868f438fa01e04bf53e805c71cddec593ea1535905c59625cd42/$/login.segments/_full.segment.rsc +0 -26
  99. package/.next/server/route-cache/APP_PAGE/16d1ab46157a868f438fa01e04bf53e805c71cddec593ea1535905c59625cd42/$/login.segments/_tree.segment.rsc +0 -4
  100. package/.next/server/route-cache/APP_PAGE/16d1ab46157a868f438fa01e04bf53e805c71cddec593ea1535905c59625cd42/$/login.segments/login/__PAGE__.segment.rsc +0 -32
  101. package/.next/server/route-cache/APP_PAGE/41da0ef926a63354a29f601d8e8d0a5951196c45ebcd28b7d4708fb7f56f3bf1/$/_not-found.html +0 -1
  102. package/.next/server/route-cache/APP_PAGE/41da0ef926a63354a29f601d8e8d0a5951196c45ebcd28b7d4708fb7f56f3bf1/$/_not-found.meta +0 -1
  103. package/.next/server/route-cache/APP_PAGE/41da0ef926a63354a29f601d8e8d0a5951196c45ebcd28b7d4708fb7f56f3bf1/$/_not-found.rsc +0 -24
  104. package/.next/server/route-cache/APP_PAGE/41da0ef926a63354a29f601d8e8d0a5951196c45ebcd28b7d4708fb7f56f3bf1/$/_not-found.segments/_full.segment.rsc +0 -24
  105. package/.next/server/route-cache/APP_PAGE/41da0ef926a63354a29f601d8e8d0a5951196c45ebcd28b7d4708fb7f56f3bf1/$/_not-found.segments/_not-found/__PAGE__.segment.rsc +0 -30
  106. package/.next/server/route-cache/APP_PAGE/41da0ef926a63354a29f601d8e8d0a5951196c45ebcd28b7d4708fb7f56f3bf1/$/_not-found.segments/_tree.segment.rsc +0 -4
  107. package/.next/server/route-cache/APP_PAGE/c6377dd9ce6a1c2cd100eb4344e843eb4639b9ed26f84643f77680e9eb454c4b/$/index.html +0 -1
  108. package/.next/server/route-cache/APP_PAGE/c6377dd9ce6a1c2cd100eb4344e843eb4639b9ed26f84643f77680e9eb454c4b/$/index.meta +0 -1
  109. package/.next/server/route-cache/APP_PAGE/c6377dd9ce6a1c2cd100eb4344e843eb4639b9ed26f84643f77680e9eb454c4b/$/index.rsc +0 -26
  110. package/.next/server/route-cache/APP_PAGE/c6377dd9ce6a1c2cd100eb4344e843eb4639b9ed26f84643f77680e9eb454c4b/$/index.segments/__PAGE__.segment.rsc +0 -31
  111. package/.next/server/route-cache/APP_PAGE/c6377dd9ce6a1c2cd100eb4344e843eb4639b9ed26f84643f77680e9eb454c4b/$/index.segments/_full.segment.rsc +0 -26
  112. package/.next/server/route-cache/APP_PAGE/c6377dd9ce6a1c2cd100eb4344e843eb4639b9ed26f84643f77680e9eb454c4b/$/index.segments/_tree.segment.rsc +0 -3
  113. package/.next/static/chunks/103-c47318242b24e9ac.js +0 -1
  114. package/.next/static/chunks/408-4fe7147e38981ee1.js +0 -1
  115. package/.next/static/chunks/app/machines/[machineId]/page-916ee73de5eb067d.js +0 -1
  116. package/.next/static/css/3fbf75e4c471c6a8.css +0 -1
  117. /package/.next/static/{xjSDCOO8Gpm5iPO9tyRG5 → oxwySrJXqXq8O6_7AzZGe}/_buildManifest.js +0 -0
  118. /package/.next/static/{xjSDCOO8Gpm5iPO9tyRG5 → oxwySrJXqXq8O6_7AzZGe}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[484],{438:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},1461:(e,t,r)=>{"use strict";r.d(t,{AlertsView:()=>L});var s=r(5155),n=r(2115),l=r(5798),a=r(7241),i=r(828),o=r(7422);let d=(0,r(8698).A)("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);var u=r(257),c=r(4173),m=r(3440),x=r(940),h=r(802),p=r(6582),b=r(7586),f=r(9939),g=r(7348);let y=[{value:"above",label:"At or above threshold",needsThreshold:!0},{value:"below",label:"At or below threshold",needsThreshold:!0},{value:"stale",label:"No receipt within cadence threshold",needsThreshold:!1},{value:"unavailable",label:"Reading unavailable",needsThreshold:!1}],v={"cpu.usage":{label:"CPU usage",unit:"percent",resource:"none"},"cpu.core":{label:"CPU core usage",unit:"percent",resource:"required"},"cpu.temperature":{label:"CPU temperature",unit:"celsius",resource:"none"},"cpu.power":{label:"CPU package power",unit:"watts",resource:"none"},"cpu.iowait":{label:"CPU I/O wait",unit:"percent",resource:"none"},"cpu.pressure":{label:"CPU pressure",unit:"percent",resource:"none"},"memory.used":{label:"Memory used",unit:"bytes",resource:"none"},"memory.total":{label:"Memory total",unit:"bytes",resource:"none"},"memory.usage":{label:"Memory usage",unit:"percent",resource:"none"},"memory.pressure.some":{label:"Memory pressure (some)",unit:"percent",resource:"none"},"memory.pressure.full":{label:"Memory pressure (full)",unit:"percent",resource:"none"},"swap.used":{label:"Swap used",unit:"bytes",resource:"none"},"swap.total":{label:"Swap total",unit:"bytes",resource:"none"},"gpu.utilization":{label:"GPU utilization",unit:"percent",resource:"required"},"gpu.memory.used":{label:"GPU memory used",unit:"bytes",resource:"required"},"gpu.memory.total":{label:"GPU memory total",unit:"bytes",resource:"required"},"gpu.temperature":{label:"GPU temperature",unit:"celsius",resource:"required"},"gpu.power":{label:"GPU power",unit:"watts",resource:"required"},"io.pressure.some":{label:"I/O pressure (some)",unit:"percent",resource:"none"},"io.pressure.full":{label:"I/O pressure (full)",unit:"percent",resource:"none"},"fs.used":{label:"Filesystem used",unit:"bytes",resource:"required"},"fs.total":{label:"Filesystem total",unit:"bytes",resource:"required"},"fs.usage":{label:"Filesystem usage",unit:"percent",resource:"required"},"fs.inodes.usage":{label:"Filesystem inode usage",unit:"percent",resource:"required"},"disk.read":{label:"Disk read",unit:"bytes_per_second",resource:"required"},"disk.write":{label:"Disk write",unit:"bytes_per_second",resource:"required"},"disk.read.latency":{label:"Disk read latency",unit:"milliseconds",resource:"required"},"disk.write.latency":{label:"Disk write latency",unit:"milliseconds",resource:"required"},"disk.utilization":{label:"Disk utilization",unit:"percent",resource:"required"},"net.rx":{label:"Network receive",unit:"bytes_per_second",resource:"required"},"net.tx":{label:"Network transmit",unit:"bytes_per_second",resource:"required"}};function j(e){return"required"===v[e].resource}function w(e){let t=["B","KiB","MiB","GiB","TiB"],r=Math.max(0,e),s=0;for(;r>=1024&&s<t.length-1;)r/=1024,s+=1;return 0===s?`${Math.round(r)} ${t[s]}`:`${r.toFixed(1)} ${t[s]}`}function N(e,t){if(null===t||!Number.isFinite(t))return"—";switch(v[e].unit){case"percent":return`${Math.round(100*t)/100}%`;case"bytes":return w(t);case"bytes_per_second":return`${w(t)}/s`;case"celsius":return`${Math.round(t)} \xb0C`;case"watts":return`${Math.round(t)} W`;case"milliseconds":return`${Math.round(10*t)/10} ms`}}function k(e){return y.find(t=>t.value===e)?.label??e}function C(e,t){return`${v[e].label}${t?` (${t})`:""}`}let S=[{id:"sustained-high-cpu",label:"Sustained high CPU",ruleName:"Sustained high CPU",metric:"cpu.usage",condition:"above",threshold:90,durationMs:3e5,resourceKind:"none",description:"Suggests CPU at or above 90% for 5 minutes."},{id:"memory-nearly-full",label:"Memory nearly full",ruleName:"Memory nearly full",metric:"memory.usage",condition:"above",threshold:90,durationMs:3e5,resourceKind:"none",description:"Suggests memory usage at or above 90% for 5 minutes."},{id:"disk-nearly-full",label:"Disk nearly full",ruleName:"Disk nearly full",metric:"fs.usage",condition:"above",threshold:90,durationMs:3e5,resourceKind:"filesystem",description:"Suggests filesystem usage at or above 90% for 5 minutes."},{id:"inode-capacity-low",label:"Inode capacity low",ruleName:"Inode capacity low",metric:"fs.inodes.usage",condition:"above",threshold:90,durationMs:3e5,resourceKind:"filesystem",description:"Suggests inode usage at or above 90% for 5 minutes."},{id:"gpu-hot",label:"GPU hot",ruleName:"GPU hot",metric:"gpu.temperature",condition:"above",threshold:85,durationMs:6e4,resourceKind:"gpu",description:"Suggests GPU temperature at or above 85 \xb0C for 1 minute."},{id:"cpu-hot",label:"CPU hot",ruleName:"CPU hot",metric:"cpu.temperature",condition:"above",threshold:90,durationMs:6e4,resourceKind:"none",description:"Suggests CPU temperature at or above 90 \xb0C for 1 minute."},{id:"collector-offline",label:"Collector offline",ruleName:"Collector offline",metric:"cpu.usage",condition:"stale",threshold:null,durationMs:0,resourceKind:"none",description:"Uses the existing stale condition and the collector's advertised cadence."},{id:"memory-pressure",label:"Memory pressure",ruleName:"Memory pressure",metric:"memory.pressure.some",condition:"above",threshold:10,durationMs:6e4,resourceKind:"none",description:"Suggests memory pressure at or above 10% for 1 minute."},{id:"io-pressure",label:"I/O pressure",ruleName:"I/O pressure",metric:"io.pressure.some",condition:"above",threshold:10,durationMs:6e4,resourceKind:"none",description:"Suggests I/O pressure at or above 10% for 1 minute."},{id:"cpu-pressure",label:"CPU pressure",ruleName:"CPU pressure",metric:"cpu.pressure",condition:"above",threshold:10,durationMs:6e4,resourceKind:"none",description:"Suggests CPU pressure at or above 10% for 1 minute."},{id:"high-io-wait",label:"High I/O wait",ruleName:"High I/O wait",metric:"cpu.iowait",condition:"above",threshold:20,durationMs:3e5,resourceKind:"none",description:"Suggests CPU I/O wait at or above 20% for 5 minutes."},{id:"disk-busy",label:"Disk busy",ruleName:"Disk busy",metric:"disk.utilization",condition:"above",threshold:90,durationMs:3e5,resourceKind:"disk",description:"Suggests disk utilization at or above 90% for 5 minutes."},{id:"slow-disk-reads",label:"Slow disk reads",ruleName:"Slow disk reads",metric:"disk.read.latency",condition:"above",threshold:100,durationMs:3e5,resourceKind:"disk",description:"Suggests read latency at or above 100 ms for 5 minutes."}],M={cpu:"CPU",memory:"Memory",swap:"Swap",gpus:"GPU",disks:"Disk",network:"Network"};function P(e){return{kind:"unavailable",reason:e}}function T(){return{kind:"waiting",reason:"Waiting for the first metrics sample."}}function U(e,t){if(null===e||"object"!=typeof e)return null;let r=e[t];return"number"==typeof r&&Number.isFinite(r)?r:null}function $(e,t){return"ok"===e.disks.status?e.disks.filesystems.find(e=>e.id===t):void 0}function I(e,t){return"ok"===e.disks.status?e.disks.devices.find(e=>e.id===t):void 0}function A(e,t,r){return null===U(e,t)?P(`${r} is not reported by this collector.`):{kind:"ready"}}function E(e,t,r,s,n){let l="ready"===r.kind&&void 0!==t?{name:e.ruleName,machineId:t.machineId,metric:e.metric,resourceId:n,condition:e.condition,threshold:e.threshold,durationMs:e.durationMs,enabled:!0}:null;return{preset:e,status:r,resourceId:n,resources:s,input:l}}function F(e,t){if(!t||!j(e))return[];let r=t.inventory;return void 0===r?[]:"cpu.core"===e?Array.from({length:Math.min(r.cpu.logicalCores,256)},(e,t)=>({value:`core:${t}`,label:`Core ${t}`})):e.startsWith("gpu.")?r.gpus.filter(e=>"supported"===e.telemetry).map(e=>({value:e.id,label:e.name})):e.startsWith("fs.")?r.filesystems.map(e=>({value:e.id,label:`${e.mountPoint} (${e.fsType})`})):e.startsWith("disk.")?r.disks.map(e=>({value:e.id,label:e.name})):e.startsWith("net.")?r.network.map(e=>({value:e.id,label:e.name})):[]}function D({machines:e,rule:t,busy:r,onSave:l,onCancel:a}){let i=e[0]?.machineId??"",[o,d]=(0,n.useState)(""),[u,c]=(0,n.useState)(i),[m,x]=(0,n.useState)("cpu.usage"),[h,p]=(0,n.useState)(""),[b,f]=(0,n.useState)("above"),[g,w]=(0,n.useState)("80"),[N,k]=(0,n.useState)("0"),[C,O]=(0,n.useState)(!0),[R,W]=(0,n.useState)(""),[q,_]=(0,n.useState)(""),[K,L]=(0,n.useState)(null),[G,Z]=(0,n.useState)(!1);(0,n.useEffect)(()=>{if(null===t){d(""),c(e[0]?.machineId??""),x("cpu.usage"),p(""),f("above"),w("80"),k("0"),O(!0),W(""),_(""),L(null);return}d(t.name),c(t.machineId),x(t.metric),p(t.resourceId),f(t.condition),w(null===t.threshold?"":String(t.threshold)),k(String(t.durationMs/1e3)),O(t.enabled),W(function(e){if(null===e)return"";let t=new Date(e);if(!Number.isFinite(t.getTime()))return"";let r=e=>String(e).padStart(2,"0");return`${t.getFullYear()}-${r(t.getMonth()+1)}-${r(t.getDate())}T${r(t.getHours())}:${r(t.getMinutes())}`}(t.maintenanceUntil)),_(""),L(null)},[t]),(0,n.useEffect)(()=>{null===t&&""===u&&void 0!==e[0]&&c(e[0].machineId)},[e,t,u]);let z=e.find(e=>e.machineId===u),H=void 0!==z&&void 0===z.metrics,B=null===t?S.map(e=>(function(e,t){let{resources:r,resourceId:s}=function(e,t){if("none"===e||void 0===t)return{resources:[],resourceId:""};if("filesystem"===e){let e=t.filesystems.map(e=>({value:e.id,label:`${e.mountPoint} (${e.fsType})`})),r=t.filesystems.find(e=>"/"===e.mountPoint)??t.filesystems[0];return{resources:e,resourceId:r?.id??""}}if("gpu"===e){let e=t.gpus.filter(e=>"supported"===e.telemetry);return{resources:e.map(e=>({value:e.id,label:e.name})),resourceId:e[0]?.id??""}}return{resources:t.disks.map(e=>({value:e.id,label:e.name})),resourceId:t.disks[0]?.id??""}}(e.resourceKind,t?.inventory);return void 0===t?E(e,t,P("Choose a machine."),r,s):"none"!==e.resourceKind&&""===s?E(e,t,P(function(e){switch(e){case"filesystem":return"No filesystems are reported by this machine.";case"gpu":return"No telemetry-capable GPU is reported by this machine.";case"disk":return"No disks are reported by this machine.";case"none":return"No resource is available."}}(e.resourceKind)),r,s):E(e,t,function(e,t,r){var s;if("stale"===e.condition)return{kind:"ready"};let n=function(e,t){let r=e.inventory?.capabilities[t];if(r?.status==="unsupported"||r?.status==="withheld")return P(`${M[t]} metrics are not shared with this hub.`);let s=e.metrics?.payload;return void 0===s?T():"unavailable"===function(e,t){switch(t){case"cpu":return e.cpu;case"memory":return e.memory;case"swap":return e.swap;case"gpus":return e.gpus;case"disks":return e.disks;case"network":return e.network}}(s,t).status?P(`${M[t]} readings are unavailable on this machine.`):null}(t,(s=e.metric).startsWith("cpu.")?"cpu":s.startsWith("memory.")?"memory":s.startsWith("swap.")?"swap":s.startsWith("gpu.")?"gpus":s.startsWith("io.")||s.startsWith("fs.")||s.startsWith("disk.")?"disks":"network");if(null!==n)return n;let l=t.metrics?.payload;if(void 0===l)return T();switch(e.metric){case"cpu.usage":default:return{kind:"ready"};case"cpu.temperature":return A(l.cpu,"temperatureC","CPU temperature");case"cpu.power":return A(l.cpu,"powerWatts","CPU package power");case"cpu.iowait":return A(l.cpu,"iowaitPercent","CPU I/O wait");case"cpu.pressure":return A(l.cpu,"pressureSomePercent","CPU pressure");case"memory.usage":{let e=l.memory;if("ok"!==e.status||!(e.totalBytes>0))return P("Memory total is not reported by this machine.");return{kind:"ready"}}case"memory.pressure.some":return A(l.memory,"pressureSomePercent","Memory pressure");case"memory.pressure.full":return A(l.memory,"pressureFullPercent","Memory full pressure");case"io.pressure.some":return A(l.disks,"pressureSomePercent","I/O pressure");case"io.pressure.full":return A(l.disks,"pressureFullPercent","I/O full pressure");case"fs.usage":{let e=$(l,r);if(void 0===e)return P("The latest sample does not include this filesystem.");if("ok"!==e.status||!(e.totalBytes>0))return P("Filesystem size is not reported for this filesystem.");return{kind:"ready"}}case"fs.inodes.usage":{let e=$(l,r);if(void 0===e)return P("The latest sample does not include this filesystem.");if("ok"!==e.status)return P("This filesystem is unavailable in the latest sample.");let t=U(e,"inodesUsed"),s=U(e,"inodesTotal");if(null===t||null===s||s<=0)return P("Inode usage is not reported for this filesystem.");return{kind:"ready"}}case"gpu.temperature":{let e="ok"===l.gpus.status?l.gpus.devices.find(e=>e.id===r):void 0;if(void 0===e)return P("The latest sample does not include this GPU.");if("ok"!==e.status)return P("This GPU is unavailable in the latest sample.");return A(e,"temperatureC","GPU temperature")}case"disk.utilization":{let e=I(l,r);if(void 0===e)return P("The latest sample does not include this disk.");if("ok"!==e.status)return P("This disk is unavailable in the latest sample.");return A(e,"ioUtilizationPercent","Disk utilization")}case"disk.read.latency":{let e=I(l,r);if(void 0===e)return P("The latest sample does not include this disk.");if("ok"!==e.status)return P("This disk is unavailable in the latest sample.");return A(e,"readLatencyMs","Disk read latency")}case"disk.write.latency":{let e=I(l,r);if(void 0===e)return P("The latest sample does not include this disk.");if("ok"!==e.status)return P("This disk is unavailable in the latest sample.");return A(e,"writeLatencyMs","Disk write latency")}}}(e,t,s),r,s)})(e,z)):[],J=""===q?null:B.find(e=>e.preset.id===q)??null;(0,n.useEffect)(()=>{H&&null===t&&"stale"!==b&&f("stale")},[H,t,b]);let V=F(m,z),Y="above"===b||"below"===b,Q=j(m),X=r||G||0===e.length,ee=async e=>{if(e.preventDefault(),L(null),""===o.trim())return void L("Give the rule a name.");if(""===u)return void L("Choose a machine.");if(H&&"stale"!==b)return void L("No metrics have been received from this machine yet, so value and unavailable rules cannot be evaluated against it. Use a stale rule, or wait until the machine reports metrics.");if(Q&&""===h.trim())return void L("Choose or enter the metric's resource.");let r=Number(N);if(""===N.trim()||!Number.isInteger(r)||r<0||1e3*r>864e5)return void L("Duration must be a whole number of seconds from 0 to 86400.");let s=null;if(Y&&(""===g.trim()||!Number.isFinite(s=Number(g))))return void L("Enter a numeric threshold.");let n=function(e){if(""===e.trim())return null;let t=new Date(e);return Number.isFinite(t.getTime())?t.toISOString():null}(R);Z(!0);try{await l({...null===t?{}:{id:t.id},name:o.trim(),machineId:u,metric:m,resourceId:Q?h.trim():"",condition:b,threshold:Y?s:null,durationMs:1e3*r,enabled:C,maintenanceUntil:n})}catch(e){L(e instanceof Error?e.message:"Could not save the rule.")}finally{Z(!1)}};return(0,s.jsxs)("form",{onSubmit:e=>void ee(e),"aria-busy":G,className:"flex flex-col gap-4",children:[0===e.length?(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"No machines available."}):null,null===t?(0,s.jsxs)("div",{className:"border-b border-border pb-4",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-end",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("label",{htmlFor:"alert-rule-preset",className:"text-xs text-muted-foreground",children:"Warning preset"}),(0,s.jsxs)("select",{id:"alert-rule-preset",value:q,onChange:e=>_(e.target.value),disabled:X,"aria-describedby":"alert-rule-preset-note",className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground",children:[(0,s.jsx)("option",{value:"",children:"Choose a preset…"}),B.map(e=>(0,s.jsxs)("option",{value:e.preset.id,children:[e.preset.label,"ready"===e.status.kind?"":"waiting"===e.status.kind?" — waiting for metrics":" — unavailable"]},e.preset.id))]})]}),(0,s.jsx)("button",{type:"button",onClick:()=>{if(null===J||null===J.input)return;let e=J.input;d(e.name),c(e.machineId),x(e.metric),p(e.resourceId??""),f(e.condition),w(null===e.threshold||void 0===e.threshold?"":String(e.threshold)),k(String(e.durationMs/1e3)),L(null)},disabled:X||J?.status.kind!=="ready",className:"rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Use preset"})]}),(0,s.jsx)("p",{id:"alert-rule-preset-note","aria-live":"polite",className:"mt-1.5 text-xs text-muted-foreground",children:null!==J&&"ready"!==J.status.kind?J.status.reason:""})]}):null,(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,s.jsxs)("div",{className:"sm:col-span-2",children:[(0,s.jsx)("label",{htmlFor:"alert-rule-name",className:"text-xs text-muted-foreground",children:"Rule name"}),(0,s.jsx)("input",{id:"alert-rule-name",value:o,onChange:e=>d(e.target.value),maxLength:128,disabled:X,placeholder:"CPU sustained high",className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground placeholder:text-muted-foreground"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-rule-machine",className:"text-xs text-muted-foreground",children:"Machine"}),(0,s.jsxs)("select",{id:"alert-rule-machine",value:u,onChange:r=>{var s;let n,l;return s=r.target.value,_(""),c(s),void 0!==(n=e.find(e=>e.machineId===s))&&void 0===n.metrics&&null===t&&f("stale"),l=F(m,n),void(j(m)&&p(l[0]?.value??""))},disabled:X,className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground",children:[""===u||e.some(e=>e.machineId===u)?null:(0,s.jsxs)("option",{value:u,children:[u," (current)"]}),e.map(e=>(0,s.jsx)("option",{value:e.machineId,children:e.displayName?.trim()||e.hostname||e.machineId},e.machineId))]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-rule-metric",className:"text-xs text-muted-foreground",children:"Metric"}),(0,s.jsx)("select",{id:"alert-rule-metric",value:m,onChange:e=>{var t;let r;return x(t=e.target.value),r=F(t,z),void p(j(t)?r[0]?.value??"":"")},disabled:X,className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground",children:Object.keys(v).map(e=>({value:e,label:v[e].label})).map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))})]}),Q?(0,s.jsxs)("div",{className:"sm:col-span-2",children:[(0,s.jsx)("label",{htmlFor:"alert-rule-resource",className:"text-xs text-muted-foreground",children:"Resource"}),V.length>0?(0,s.jsxs)("select",{id:"alert-rule-resource",value:h,onChange:e=>p(e.target.value),disabled:X,className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground",children:[""===h||V.some(e=>e.value===h)?null:(0,s.jsxs)("option",{value:h,children:[h," (current)"]}),V.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))]}):(0,s.jsx)("input",{id:"alert-rule-resource",value:h,onChange:e=>p(e.target.value),maxLength:256,disabled:X,placeholder:"cpu.core"===m?"core:0":m.startsWith("gpu.")?"gpu:GPU-…":m.startsWith("fs.")?"fs:/":m.startsWith("disk.")?"disk:sda":m.startsWith("net.")?"net:eno1":"Resource id",className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground placeholder:text-muted-foreground"})]}):null,(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-rule-condition",className:"text-xs text-muted-foreground",children:"Condition"}),(0,s.jsx)("select",{id:"alert-rule-condition",value:b,onChange:e=>f(e.target.value),disabled:X,className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground",children:y.map(e=>(0,s.jsx)("option",{value:e.value,disabled:H&&"stale"!==e.value,children:e.label},e.value))}),H?(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Waiting for metrics."}):null]}),Y?(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{htmlFor:"alert-rule-threshold",className:"text-xs text-muted-foreground",children:["Threshold (",function(e){switch(v[e].unit){case"percent":return"percent (0–100)";case"bytes":return"bytes";case"bytes_per_second":return"bytes per second";case"celsius":return"degrees Celsius";case"watts":return"watts";case"milliseconds":return"milliseconds"}}(m),")"]}),(0,s.jsx)("input",{id:"alert-rule-threshold",type:"number",step:"any",value:g,onChange:e=>w(e.target.value),disabled:X,className:"tnum mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground"})]}):null,(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-rule-duration",className:"text-xs text-muted-foreground",children:"Must hold for (seconds)"}),(0,s.jsx)("input",{id:"alert-rule-duration",type:"number",min:0,max:86400,step:1,value:N,onChange:e=>k(e.target.value),disabled:X,className:"tnum mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-rule-maintenance",className:"text-xs text-muted-foreground",children:"Maintenance until (optional)"}),(0,s.jsx)("input",{id:"alert-rule-maintenance",type:"datetime-local",value:R,onChange:e=>W(e.target.value),disabled:X,className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground"})]}),(0,s.jsxs)("label",{className:"flex items-center gap-2 text-xs text-foreground sm:col-span-2",children:[(0,s.jsx)("input",{type:"checkbox",checked:C,onChange:e=>O(e.target.checked),disabled:X,className:"h-4 w-4 rounded border-border accent-[var(--accent)]"}),"Rule enabled"]})]}),K?(0,s.jsx)("p",{role:"alert",className:"rounded-md bg-crit-soft px-3 py-2 text-xs text-foreground",children:K}):null,(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("button",{type:"submit",disabled:X,className:"rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-accent-foreground transition-colors hover:bg-accent/90 disabled:opacity-50",children:G?"Saving…":null===t?"Create rule":"Save rule"}),null!==t?(0,s.jsx)("button",{type:"button",onClick:a,disabled:G,className:"rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Cancel"}):null]})]})}function O({status:e,busy:t,onConfigure:r,onClear:l,onTest:a}){let[i,o]=(0,n.useState)(""),[d,u]=(0,n.useState)(""),[c,m]=(0,n.useState)(""),[x,h]=(0,n.useState)(!0),[p,b]=(0,n.useState)(null),[f,g]=(0,n.useState)(null),[y,v]=(0,n.useState)(!1),[j,w]=(0,n.useState)(null),[N,k]=(0,n.useState)(null),C=(0,n.useRef)(null),S=(0,n.useRef)(null),M=(0,n.useRef)(null);(0,n.useEffect)(()=>{null!==j&&C.current?.focus()},[j]),(0,n.useEffect)(()=>{e.configured||(w(null),k(null))},[e.configured]);let P=async e=>{v(!0),b(null),w(null),k(null);try{await r(e),o(""),u(""),m(""),h(!0)}catch(e){b(e instanceof Error?e.message:"Could not configure the webhook.")}finally{v(!1)}},T=async t=>{t.preventDefault();let r=(()=>{let e;b(null),g(null);let t=i.trim();if(""===t)return b("Enter the webhook URL."),null;if(""!==d.trim())try{let t=JSON.parse(d);if(null===t||"object"!=typeof t||Array.isArray(t))throw Error("not an object");for(let[r,s]of(e={},Object.entries(t))){if("string"!=typeof s)throw Error("header values must be strings");e[r]=s}}catch{return b("Headers must be a JSON object with string values."),null}return{url:t,...void 0===e?{}:{headers:e},secret:""===c.trim()?null:c,enabled:x}})();if(null!==r){if(e.configured){k(r),w("replace");return}await P(r)}},U=async()=>{v(!0),b(null),g(null),w(null);try{await l(),o(""),u(""),m("")}catch(e){b(e instanceof Error?e.message:"Could not clear the webhook.")}finally{v(!1)}},$=async()=>{"clear"===j?await U():"replace"===j&&null!==N&&await P(N)},I=async()=>{b(null),v(!0);try{g(await a())}catch(e){b(e instanceof Error?e.message:"Could not test the webhook.")}finally{v(!1)}},A=t||y||null!==j,E=e.configured&&"loopback-http"===e.transport;return(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-xs",children:[(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Configured"}),(0,s.jsx)("dd",{className:"text-foreground",children:e.configured?e.enabled?"Enabled":"Disabled":"Not configured"}),(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Transport"}),(0,s.jsx)("dd",{className:"text-foreground",children:"https"===e.transport?"HTTPS":"loopback-http"===e.transport?"Loopback HTTP test sink":"—"}),(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Last test"}),(0,s.jsx)("dd",{className:"text-foreground",children:null===e.lastTestAt?"Never":`${!0===e.lastTestOk?"Passed":"Failed"} \xb7 ${new Date(e.lastTestAt).toLocaleString()}`}),e.lastError?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Last error"}),(0,s.jsx)("dd",{className:"text-warn",children:e.lastError})]}):null]}),(0,s.jsxs)("form",{onSubmit:e=>void T(e),className:"flex flex-col gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-webhook-url",className:"text-xs text-muted-foreground",children:e.configured?"Replace webhook URL":"Webhook URL"}),(0,s.jsx)("input",{id:"alert-webhook-url",type:"url",required:!0,value:i,onChange:e=>o(e.target.value),maxLength:2048,disabled:A,placeholder:"https://receiver.example/alerts",className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground placeholder:text-muted-foreground"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-webhook-headers",className:"text-xs text-muted-foreground",children:"Headers (JSON, optional)"}),(0,s.jsx)("textarea",{id:"alert-webhook-headers",value:d,onChange:e=>u(e.target.value),rows:2,disabled:A,placeholder:'{"x-channel": "monitoring"}',className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 font-mono text-xs text-foreground placeholder:text-muted-foreground"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-webhook-secret",className:"text-xs text-muted-foreground",children:"Signing secret (optional)"}),(0,s.jsx)("input",{id:"alert-webhook-secret",type:"password",value:c,onChange:e=>m(e.target.value),maxLength:256,disabled:A,placeholder:"Blank clears the signature",autoComplete:"new-password",className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground"})]}),(0,s.jsxs)("label",{className:"flex items-center gap-2 text-xs text-foreground",children:[(0,s.jsx)("input",{type:"checkbox",checked:x,onChange:e=>h(e.target.checked),disabled:A,className:"h-4 w-4 rounded border-border accent-[var(--accent)]"}),"Webhook enabled"]}),p?(0,s.jsx)("p",{role:"alert",className:"rounded-md bg-crit-soft px-3 py-2 text-xs text-foreground",children:p}):null,(0,s.jsx)("p",{role:"status",className:f?`rounded-md px-3 py-2 text-xs ${f.ok?"bg-ok-soft text-foreground":"bg-warn-soft text-foreground"}`:"sr-only",children:f?`Test ${f.ok?"delivered":"failed"}${null!==f.status?` (HTTP ${f.status})`:""}${f.error?` — ${f.error}`:""}.`:""}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("button",{ref:S,type:"submit",disabled:A||""===i.trim(),className:"rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-accent-foreground transition-colors hover:bg-accent/90 disabled:opacity-50",children:e.configured?"Replace webhook":"Configure webhook"}),(0,s.jsx)("button",{ref:M,type:"button",onClick:()=>{b(null),w("clear")},disabled:A||!e.configured,className:"rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Clear webhook"}),(0,s.jsx)("button",{type:"button",onClick:()=>void I(),disabled:A||!E,title:E?"Send one explicit test message to the configured loopback sink":"Test delivery is available only for a configured loopback HTTP sink",className:"rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Send test"})]}),null!==j?(0,s.jsxs)("div",{role:"group","aria-label":"Confirm webhook change",className:"rounded-md bg-warn-soft px-3 py-3",children:[(0,s.jsx)("p",{className:"text-xs text-foreground",children:"clear"===j?"Clear the configured webhook? Future incidents will not be delivered until a webhook is configured again.":"Replace the configured webhook? The stored URL, headers and secret will be overwritten."}),(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,s.jsx)("button",{ref:C,type:"button",onClick:()=>void $(),disabled:y,className:`rounded-md px-3 py-1.5 text-xs font-medium text-accent-foreground transition-colors disabled:opacity-50 ${"clear"===j?"bg-crit":"bg-accent hover:bg-accent/90"}`,children:"clear"===j?"Confirm clear":"Confirm replace"}),(0,s.jsx)("button",{type:"button",onClick:()=>{let e="clear"===j?M.current:S.current;w(null),k(null),e?.focus()},disabled:y,className:"rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Cancel"})]})]}):null]})]})}function R(e){if(null===e)return"—";let t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleString():e}function W({tone:e,children:t}){return(0,s.jsx)("span",{className:`tnum inline-flex items-center rounded-full px-2 py-0.5 text-xs ${"ok"===e?"bg-ok-soft text-ok":"warn"===e?"bg-warn-soft text-warn":"crit"===e?"bg-crit-soft text-crit":"border border-border text-muted-foreground"}`,children:t})}function q({incident:e,now:t}){let r="open"===e.status;return(0,s.jsx)("li",{className:"border-b border-border py-3 last:border-b-0",children:(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-x-4 gap-y-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(W,{tone:r?"crit":"ok",children:r?"Open":"Recovered"}),(0,s.jsx)("span",{className:"truncate text-sm font-medium",children:e.ruleName}),(0,s.jsx)("span",{className:"tnum text-xs text-muted-foreground",children:e.machineId})]}),(0,s.jsx)("p",{className:"mt-1 max-w-2xl text-sm",children:e.message}),(0,s.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:[C(e.metric,e.resourceId)," \xb7 started"," ",(0,b.nV)((0,b.A4)(e.startedAt,t)),null!==e.resolvedAt?` \xb7 recovered ${(0,b.nV)((0,b.A4)(e.resolvedAt,t))}`:""]})]}),(0,s.jsxs)("dl",{className:"tnum grid shrink-0 grid-cols-2 gap-x-4 gap-y-1 text-xs text-muted-foreground",children:[(0,s.jsx)("dt",{children:"Started value"}),(0,s.jsx)("dd",{className:"text-right text-foreground",children:N(e.metric,e.startedValue)}),(0,s.jsx)("dt",{children:"Recovered value"}),(0,s.jsx)("dd",{className:"text-right text-foreground",children:N(e.metric,e.resolvedValue)})]})]})})}function _({rule:e,admin:t,busy:r,confirmingDelete:n,onEdit:i,onRequestDelete:o,onCancelDelete:d,onConfirmDelete:u}){var c,m;let x=(c=e.condition,y.find(e=>e.value===c)?.needsThreshold)?`${k(e.condition)} ${N(e.metric,e.threshold)}`:k(e.condition),h=e.enabled?"firing"===e.state?"crit":"pending"===e.state?"warn":"ok":"muted",p=e.enabled?"firing"===e.state?"Firing":"pending"===e.state?"Pending":"OK":"Disabled";return(0,s.jsxs)("li",{className:"border-b border-border py-3 last:border-b-0",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-x-4 gap-y-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"truncate text-sm font-medium",children:e.name}),(0,s.jsx)(W,{tone:h,children:p})]}),(0,s.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:[e.machineId," \xb7 ",C(e.metric,e.resourceId)]}),(0,s.jsxs)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:[x," \xb7 holds ",!Number.isFinite(m=e.durationMs)||m<=0?"Immediately":m<6e4?`${Math.round(m/1e3)} s`:m<36e5?`${Math.round(m/6e4)} min`:`${Math.round(m/36e5)} h`,e.pendingSince?` \xb7 pending since ${R(e.pendingSince)}`:""]}),e.maintenanceUntil?(0,s.jsxs)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:["Maintenance until ",R(e.maintenanceUntil)]}):null]}),t?(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[(0,s.jsxs)("button",{type:"button",onClick:i,disabled:r||n,className:"inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:[(0,s.jsx)(l.A,{className:"h-3 w-3","aria-hidden":!0}),"Edit"]}),(0,s.jsxs)("button",{type:"button",onClick:o,disabled:r||n,className:"inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs text-crit transition-colors hover:bg-crit-soft disabled:opacity-50",children:[(0,s.jsx)(a.A,{className:"h-3 w-3","aria-hidden":!0}),"Delete"]})]}):null]}),n?(0,s.jsxs)("div",{role:"group","aria-label":"Confirm rule deletion",className:"mt-3 rounded-md bg-warn-soft px-3 py-2.5",children:[(0,s.jsxs)("p",{className:"text-xs text-foreground",children:["Delete “",e.name,"”? Its incident history stays, but the rule stops evaluating."]}),(0,s.jsxs)("div",{className:"mt-2 flex flex-wrap gap-2",children:[(0,s.jsx)("button",{type:"button",autoFocus:!0,onClick:()=>void u(),disabled:r,className:"rounded-md bg-crit px-2.5 py-1 text-xs font-medium text-accent-foreground transition-colors disabled:opacity-50",children:"Confirm delete"}),(0,s.jsx)("button",{type:"button",onClick:d,disabled:r,className:"rounded-md border border-border px-2.5 py-1 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Cancel"})]})]}):null]})}function K({notification:e}){let t="failed"===e.status?"crit":"delivered"===e.status?"ok":"warn";return(0,s.jsxs)("li",{className:"border-b border-border py-2 last:border-b-0",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1 text-xs",children:[(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsx)(W,{tone:t,children:e.status}),(0,s.jsx)("span",{className:"text-foreground",children:e.event}),(0,s.jsxs)("span",{className:"tnum text-muted-foreground",children:["attempt ",e.attempts,"/",e.maxAttempts]})]}),(0,s.jsx)("span",{className:"tnum text-muted-foreground",children:R(e.createdAt)})]}),e.lastError?(0,s.jsx)("p",{className:"mt-1 text-xs text-warn",children:e.lastError}):null,(0,s.jsx)("p",{className:"tnum mt-0.5 truncate font-mono text-xs text-muted-foreground",children:e.id})]})}function L(){let{session:e,machines:t}=(0,f.M)(),r=(0,p.x)(),l=(0,g.c)(),a="signed-in"===e.kind?e.user.csrfToken:null,b="signed-in"===e.kind&&!0===e.user.admin,[y,v]=(0,n.useState)(null),[j,w]=(0,n.useState)(!0),[N,k]=(0,n.useState)(null),[C,S]=(0,n.useState)(null),[M,P]=(0,n.useState)(null),[T,U]=(0,n.useState)(null),[$,I]=(0,n.useState)(!1),A=b&&(null===y||y.canAdmin),E=(0,n.useCallback)(async()=>{if(null!==a){w(!0),k(null);try{let e=await fetch("/api/alerts",{headers:{Accept:"application/json"},cache:"no-store",credentials:"same-origin"}),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error??`Could not load alerts (${e.status}).`);v(t)}catch(e){k(e instanceof Error?e.message:"Could not load alerts.")}finally{w(!1)}}},[a]);(0,n.useEffect)(()=>{null!==a&&E()},[a,E]);let F=(0,n.useCallback)(async(e,t)=>{if(null===a)throw Error("Sign in required.");I(!0),k(null);try{let r=await fetch(e,{...t,cache:"no-store",credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json","x-csrf-token":a,...t.headers??{}}}),s=await r.json().catch(()=>({}));if(!r.ok)throw Error(s.error??`Request failed (${r.status}).`);return s}finally{I(!1)}},[a]),R=async e=>{await F("/api/alerts/rules",{method:"POST",body:JSON.stringify(e)}),P(null),S(e.id?"Rule saved.":"Rule created."),await E()},W=async e=>{try{await F(`/api/alerts/rules?id=${encodeURIComponent(e.id)}`,{method:"DELETE"}),M?.id===e.id&&P(null),U(null),S("Rule deleted."),await E()}catch(e){k(e instanceof Error?e.message:"Could not delete the rule.")}},L=async e=>{await F("/api/alerts/webhook",{method:"POST",body:JSON.stringify({action:"configure",...e})}),S("Webhook configured."),await E()},G=async()=>{await F("/api/alerts/webhook",{method:"POST",body:JSON.stringify({action:"clear"})}),S("Webhook cleared."),await E()},Z=async()=>{let e=await F("/api/alerts/webhook",{method:"POST",body:JSON.stringify({action:"test"})});return v(t=>null===t?t:{...t,webhook:e.status}),S(e.result.ok?"Webhook test delivered.":"Webhook test failed."),e.result},z=y?.incidents??[],H=z.filter(e=>"open"===e.status).length,B=y?.rules??[],J=y?.notifications,V=j&&null===y;return(0,s.jsx)(c.G,{title:"Alerts",headerRight:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(x.$E,{}),(0,s.jsx)(h.B,{})]}),children:r||(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(p.E,{}),(0,s.jsx)("div",{className:"mb-4 flex flex-wrap items-center justify-end gap-3",children:(0,s.jsxs)("button",{type:"button",onClick:()=>void E(),disabled:j,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:[(0,s.jsx)(i.A,{className:`h-3.5 w-3.5 ${j?"animate-spin":""}`,"aria-hidden":!0}),"Refresh"]})}),(0,s.jsx)("p",{role:"status",className:C?"mb-4 text-xs text-muted-foreground":"sr-only",children:C??""}),N?(0,s.jsx)("p",{role:"alert",className:"mb-4 rounded-lg bg-crit-soft px-4 py-2.5 text-xs text-foreground",children:N}):null,V?(0,s.jsx)(m.Z,{title:"Alerts",className:"mt-8",children:(0,s.jsx)(m.p,{icon:i.A,note:"Loading alert rules and incidents…"})}):null===y?(0,s.jsx)(m.Z,{title:"Alerts unavailable",className:"mt-8",children:(0,s.jsx)(m.p,{icon:o.A,note:"Alert state could not be loaded."})}):(0,s.jsxs)("div",{className:A?"grid gap-5 xl:grid-cols-[minmax(0,1fr)_24rem]":"flex flex-col gap-5",children:[(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-5",children:[(0,s.jsx)(m.Z,{title:"Incidents and recoveries",action:(0,s.jsxs)("span",{children:[H," open \xb7 ",z.length," recent"]}),children:0===z.length?(0,s.jsx)(m.p,{icon:d,note:"No incidents."}):(0,s.jsx)("ul",{className:"flex flex-col",children:z.map(e=>(0,s.jsx)(q,{incident:e,now:l},e.id))})}),(0,s.jsx)(m.Z,{title:"Rules",action:(0,s.jsxs)("span",{children:[B.length," configured"]}),children:0===B.length?(0,s.jsx)(m.p,{icon:u.A,note:"No rules."}):(0,s.jsx)("ul",{className:"flex flex-col",children:B.map(e=>(0,s.jsx)(_,{rule:e,admin:A,busy:$,confirmingDelete:T===e.id,onEdit:()=>{U(null),P(e)},onRequestDelete:()=>U(e.id),onCancelDelete:()=>U(null),onConfirmDelete:()=>W(e)},e.id))})}),(0,s.jsx)(m.Z,{title:"Notifications",action:(0,s.jsxs)("span",{children:[J?.pending??0," pending \xb7 ",J?.failed??0," failed"]}),children:void 0===J||0===J.recent.length?(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"No notifications."}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("dl",{className:"grid grid-cols-3 gap-3 border-b border-border pb-3 text-xs",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Pending"}),(0,s.jsx)("dd",{className:"tnum text-foreground",children:J.pending})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Delivered"}),(0,s.jsx)("dd",{className:"tnum text-foreground",children:J.delivered})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Failed"}),(0,s.jsx)("dd",{className:"tnum text-foreground",children:J.failed})]})]}),(0,s.jsx)("ul",{className:"mt-1 flex flex-col",children:J.recent.slice(0,10).map(e=>(0,s.jsx)(K,{notification:e},e.id))})]})})]}),A?(0,s.jsxs)("aside",{className:"flex min-w-0 flex-col gap-5",children:[(0,s.jsx)(m.Z,{title:null===M?"New rule":"Edit rule",action:null===M?null:(0,s.jsx)("button",{type:"button",onClick:()=>P(null),className:"text-xs text-muted-foreground hover:text-foreground",children:"New instead"}),children:(0,s.jsx)(D,{machines:t,rule:M,busy:$,onSave:R,onCancel:()=>P(null)})}),(0,s.jsx)(m.Z,{title:"Webhook",children:(0,s.jsx)(O,{status:y.webhook,busy:$,onConfigure:L,onClear:G,onTest:Z})})]}):null]})]})})}},2865:(e,t,r)=>{Promise.resolve().then(r.bind(r,1461))},5798:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]])},6582:(e,t,r)=>{"use strict";r.d(t,{E:()=>f,x:()=>b});var s=r(5155),n=r(8500),l=r.n(n),a=r(828),i=r(6914),o=r(7029),d=r(438),u=r(7422),c=r(1735),m=r(3440),x=r(9939);function h(e){return(0,s.jsxs)("button",{type:"button",onClick:e.onClick,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:[(0,s.jsx)(a.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.children]})}function p(e){return(0,s.jsx)(l(),{href:e.href,className:e.primary?"inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-accent-foreground transition-colors hover:bg-accent/90":"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:e.children})}function b(){let{session:e,phase:t,retryConnection:r}=(0,x.M)();switch(e.kind){case"restoring":return(0,s.jsx)(m.Z,{title:"Checking session",className:"mx-auto my-12 max-w-md",children:(0,s.jsx)(m.p,{icon:i.A,note:"Checking your session…"})});case"restore-failed":return(0,s.jsxs)(m.Z,{title:"Hub unreachable",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(m.p,{icon:o.A,note:"The hub is unreachable right now."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(h,{onClick:r,children:"Check again"})})]});case"signed-out":if("expired"===t)return(0,s.jsxs)(m.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(m.p,{icon:d.A,note:"Your session ended."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(p,{href:"/login",primary:!0,children:"Sign in"})})]});return(0,s.jsxs)(m.Z,{title:"Sign in required",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(m.p,{icon:i.A,note:"Sign in required."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(p,{href:"/login",primary:!0,children:"Sign in"})})]});case"auth-unavailable":return(0,s.jsx)(m.Z,{title:"Sign-in unavailable",className:"mx-auto my-12 max-w-md",children:(0,s.jsx)(m.p,{icon:u.A,note:"Browser sign-in is not configured on this hub."})})}return"expired"===t?(0,s.jsxs)(m.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(m.p,{icon:d.A,note:"Your session ended."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(p,{href:"/login",primary:!0,children:"Sign in"})})]}):"no-permission"===t?(0,s.jsxs)(m.Z,{title:"No permission",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(m.p,{icon:u.A,note:`You are signed in as ${e.user.username}, but this hub grants no machine view to this account.`}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(h,{onClick:r,children:"Check again"})})]}):null}function f(){let{phase:e,retryConnection:t}=(0,x.M)();return"reconnecting"!==e&&"disconnected"!==e&&"connecting"!==e?null:"connecting"===e?(0,s.jsxs)("div",{role:"status",className:"mb-5 flex items-center gap-2 rounded-lg border border-border bg-card px-4 py-2.5 text-xs text-muted-foreground",children:[(0,s.jsx)(a.A,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),"Connecting to the live feed — waiting for the first snapshot."]}):(0,s.jsxs)("div",{role:"status",className:"mb-5 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border border-border bg-card px-4 py-2.5 text-xs text-muted-foreground",children:[(0,s.jsx)(c.A,{className:"h-3.5 w-3.5 shrink-0 text-warn","aria-hidden":!0}),(0,s.jsxs)("span",{children:["Connection lost — values below are ",(0,s.jsx)("strong",{className:"font-medium text-foreground",children:"last known"}),", not live measurements","reconnecting"===e?" — retrying with backoff…":" — retries stopped."]}),"disconnected"===e?(0,s.jsx)(h,{onClick:t,children:"Retry now"}):null]})}},7241:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},7348:(e,t,r)=>{"use strict";r.d(t,{c:()=>n});var s=r(2115);function n(e=1e3){let[t,r]=(0,s.useState)(()=>Date.now());return(0,s.useEffect)(()=>{r(Date.now());let t=setInterval(()=>r(Date.now()),e);return()=>clearInterval(t)},[e]),t}}},e=>{e.O(0,[157,939,103,441,794,358],()=>e(e.s=2865)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[484],{438:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},1461:(e,t,r)=>{"use strict";r.d(t,{AlertsView:()=>L});var s=r(5155),n=r(2115),l=r(5798),a=r(7241),i=r(828),o=r(7422);let d=(0,r(8698).A)("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);var u=r(257),c=r(4173),m=r(3440),x=r(940),h=r(802),p=r(6582),b=r(7586),f=r(9939),g=r(7348);let y=[{value:"above",label:"At or above threshold",needsThreshold:!0},{value:"below",label:"At or below threshold",needsThreshold:!0},{value:"stale",label:"No receipt within cadence threshold",needsThreshold:!1},{value:"unavailable",label:"Reading unavailable",needsThreshold:!1}],v={"cpu.usage":{label:"CPU usage",unit:"percent",resource:"none"},"cpu.core":{label:"CPU core usage",unit:"percent",resource:"required"},"cpu.temperature":{label:"CPU temperature",unit:"celsius",resource:"none"},"cpu.power":{label:"CPU package power",unit:"watts",resource:"none"},"cpu.iowait":{label:"CPU I/O wait",unit:"percent",resource:"none"},"cpu.pressure":{label:"CPU pressure",unit:"percent",resource:"none"},"memory.used":{label:"Memory used",unit:"bytes",resource:"none"},"memory.total":{label:"Memory total",unit:"bytes",resource:"none"},"memory.usage":{label:"Memory usage",unit:"percent",resource:"none"},"memory.pressure.some":{label:"Memory pressure (some)",unit:"percent",resource:"none"},"memory.pressure.full":{label:"Memory pressure (full)",unit:"percent",resource:"none"},"swap.used":{label:"Swap used",unit:"bytes",resource:"none"},"swap.total":{label:"Swap total",unit:"bytes",resource:"none"},"gpu.utilization":{label:"GPU utilization",unit:"percent",resource:"required"},"gpu.memory.used":{label:"GPU memory used",unit:"bytes",resource:"required"},"gpu.memory.total":{label:"GPU memory total",unit:"bytes",resource:"required"},"gpu.temperature":{label:"GPU temperature",unit:"celsius",resource:"required"},"gpu.power":{label:"GPU power",unit:"watts",resource:"required"},"io.pressure.some":{label:"I/O pressure (some)",unit:"percent",resource:"none"},"io.pressure.full":{label:"I/O pressure (full)",unit:"percent",resource:"none"},"fs.used":{label:"Filesystem used",unit:"bytes",resource:"required"},"fs.total":{label:"Filesystem total",unit:"bytes",resource:"required"},"fs.usage":{label:"Filesystem usage",unit:"percent",resource:"required"},"fs.inodes.usage":{label:"Filesystem inode usage",unit:"percent",resource:"required"},"disk.read":{label:"Disk read",unit:"bytes_per_second",resource:"required"},"disk.write":{label:"Disk write",unit:"bytes_per_second",resource:"required"},"disk.read.latency":{label:"Disk read latency",unit:"milliseconds",resource:"required"},"disk.write.latency":{label:"Disk write latency",unit:"milliseconds",resource:"required"},"disk.utilization":{label:"Disk utilization",unit:"percent",resource:"required"},"net.rx":{label:"Network receive",unit:"bytes_per_second",resource:"required"},"net.tx":{label:"Network transmit",unit:"bytes_per_second",resource:"required"}};function j(e){return"required"===v[e].resource}function w(e){let t=["B","KiB","MiB","GiB","TiB"],r=Math.max(0,e),s=0;for(;r>=1024&&s<t.length-1;)r/=1024,s+=1;return 0===s?`${Math.round(r)} ${t[s]}`:`${r.toFixed(1)} ${t[s]}`}function N(e,t){if(null===t||!Number.isFinite(t))return"—";switch(v[e].unit){case"percent":return`${Math.round(100*t)/100}%`;case"bytes":return w(t);case"bytes_per_second":return`${w(t)}/s`;case"celsius":return`${Math.round(t)} \xb0C`;case"watts":return`${Math.round(t)} W`;case"milliseconds":return`${Math.round(10*t)/10} ms`}}function k(e){return y.find(t=>t.value===e)?.label??e}function C(e,t){return`${v[e].label}${t?` (${t})`:""}`}let S=[{id:"sustained-high-cpu",label:"Sustained high CPU",ruleName:"Sustained high CPU",metric:"cpu.usage",condition:"above",threshold:90,durationMs:3e5,resourceKind:"none",description:"Suggests CPU at or above 90% for 5 minutes."},{id:"memory-nearly-full",label:"Memory nearly full",ruleName:"Memory nearly full",metric:"memory.usage",condition:"above",threshold:90,durationMs:3e5,resourceKind:"none",description:"Suggests memory usage at or above 90% for 5 minutes."},{id:"disk-nearly-full",label:"Disk nearly full",ruleName:"Disk nearly full",metric:"fs.usage",condition:"above",threshold:90,durationMs:3e5,resourceKind:"filesystem",description:"Suggests filesystem usage at or above 90% for 5 minutes."},{id:"inode-capacity-low",label:"Inode capacity low",ruleName:"Inode capacity low",metric:"fs.inodes.usage",condition:"above",threshold:90,durationMs:3e5,resourceKind:"filesystem",description:"Suggests inode usage at or above 90% for 5 minutes."},{id:"gpu-hot",label:"GPU hot",ruleName:"GPU hot",metric:"gpu.temperature",condition:"above",threshold:85,durationMs:6e4,resourceKind:"gpu",description:"Suggests GPU temperature at or above 85 \xb0C for 1 minute."},{id:"cpu-hot",label:"CPU hot",ruleName:"CPU hot",metric:"cpu.temperature",condition:"above",threshold:90,durationMs:6e4,resourceKind:"none",description:"Suggests CPU temperature at or above 90 \xb0C for 1 minute."},{id:"collector-offline",label:"Collector offline",ruleName:"Collector offline",metric:"cpu.usage",condition:"stale",threshold:null,durationMs:0,resourceKind:"none",description:"Uses the existing stale condition and the collector's advertised cadence."},{id:"memory-pressure",label:"Memory pressure",ruleName:"Memory pressure",metric:"memory.pressure.some",condition:"above",threshold:10,durationMs:6e4,resourceKind:"none",description:"Suggests memory pressure at or above 10% for 1 minute."},{id:"io-pressure",label:"I/O pressure",ruleName:"I/O pressure",metric:"io.pressure.some",condition:"above",threshold:10,durationMs:6e4,resourceKind:"none",description:"Suggests I/O pressure at or above 10% for 1 minute."},{id:"cpu-pressure",label:"CPU pressure",ruleName:"CPU pressure",metric:"cpu.pressure",condition:"above",threshold:10,durationMs:6e4,resourceKind:"none",description:"Suggests CPU pressure at or above 10% for 1 minute."},{id:"high-io-wait",label:"High I/O wait",ruleName:"High I/O wait",metric:"cpu.iowait",condition:"above",threshold:20,durationMs:3e5,resourceKind:"none",description:"Suggests CPU I/O wait at or above 20% for 5 minutes."},{id:"disk-busy",label:"Disk busy",ruleName:"Disk busy",metric:"disk.utilization",condition:"above",threshold:90,durationMs:3e5,resourceKind:"disk",description:"Suggests disk utilization at or above 90% for 5 minutes."},{id:"slow-disk-reads",label:"Slow disk reads",ruleName:"Slow disk reads",metric:"disk.read.latency",condition:"above",threshold:100,durationMs:3e5,resourceKind:"disk",description:"Suggests read latency at or above 100 ms for 5 minutes."}],M={cpu:"CPU",memory:"Memory",swap:"Swap",gpus:"GPU",disks:"Disk",network:"Network"};function P(e){return{kind:"unavailable",reason:e}}function T(){return{kind:"waiting",reason:"Waiting for the first metrics sample."}}function U(e,t){if(null===e||"object"!=typeof e)return null;let r=e[t];return"number"==typeof r&&Number.isFinite(r)?r:null}function $(e,t){return"ok"===e.disks.status?e.disks.filesystems.find(e=>e.id===t):void 0}function A(e,t){return"ok"===e.disks.status?e.disks.devices.find(e=>e.id===t):void 0}function I(e,t,r){return null===U(e,t)?P(`${r} is not reported by this collector.`):{kind:"ready"}}function E(e,t,r,s,n){let l="ready"===r.kind&&void 0!==t?{name:e.ruleName,machineId:t.machineId,metric:e.metric,resourceId:n,condition:e.condition,threshold:e.threshold,durationMs:e.durationMs,enabled:!0}:null;return{preset:e,status:r,resourceId:n,resources:s,input:l}}function F(e,t){if(!t||!j(e))return[];let r=t.inventory;return void 0===r?[]:"cpu.core"===e?Array.from({length:Math.min(r.cpu.logicalCores,256)},(e,t)=>({value:`core:${t}`,label:`Core ${t}`})):e.startsWith("gpu.")?r.gpus.filter(e=>"supported"===e.telemetry).map(e=>({value:e.id,label:e.name})):e.startsWith("fs.")?r.filesystems.map(e=>({value:e.id,label:`${e.mountPoint} (${e.fsType})`})):e.startsWith("disk.")?r.disks.map(e=>({value:e.id,label:e.name})):e.startsWith("net.")?r.network.map(e=>({value:e.id,label:e.name})):[]}function D({machines:e,rule:t,busy:r,onSave:l,onCancel:a}){let i=e[0]?.machineId??"",[o,d]=(0,n.useState)(""),[u,c]=(0,n.useState)(i),[m,x]=(0,n.useState)("cpu.usage"),[h,p]=(0,n.useState)(""),[b,f]=(0,n.useState)("above"),[g,w]=(0,n.useState)("80"),[N,k]=(0,n.useState)("0"),[C,O]=(0,n.useState)(!0),[R,W]=(0,n.useState)(""),[q,_]=(0,n.useState)(""),[K,L]=(0,n.useState)(null),[G,Z]=(0,n.useState)(!1);(0,n.useEffect)(()=>{if(null===t){d(""),c(e[0]?.machineId??""),x("cpu.usage"),p(""),f("above"),w("80"),k("0"),O(!0),W(""),_(""),L(null);return}d(t.name),c(t.machineId),x(t.metric),p(t.resourceId),f(t.condition),w(null===t.threshold?"":String(t.threshold)),k(String(t.durationMs/1e3)),O(t.enabled),W(function(e){if(null===e)return"";let t=new Date(e);if(!Number.isFinite(t.getTime()))return"";let r=e=>String(e).padStart(2,"0");return`${t.getFullYear()}-${r(t.getMonth()+1)}-${r(t.getDate())}T${r(t.getHours())}:${r(t.getMinutes())}`}(t.maintenanceUntil)),_(""),L(null)},[t]),(0,n.useEffect)(()=>{null===t&&""===u&&void 0!==e[0]&&c(e[0].machineId)},[e,t,u]);let z=e.find(e=>e.machineId===u),H=void 0!==z&&void 0===z.metrics,B=null===t?S.map(e=>(function(e,t){let{resources:r,resourceId:s}=function(e,t){if("none"===e||void 0===t)return{resources:[],resourceId:""};if("filesystem"===e){let e=t.filesystems.map(e=>({value:e.id,label:`${e.mountPoint} (${e.fsType})`})),r=t.filesystems.find(e=>"/"===e.mountPoint)??t.filesystems[0];return{resources:e,resourceId:r?.id??""}}if("gpu"===e){let e=t.gpus.filter(e=>"supported"===e.telemetry);return{resources:e.map(e=>({value:e.id,label:e.name})),resourceId:e[0]?.id??""}}return{resources:t.disks.map(e=>({value:e.id,label:e.name})),resourceId:t.disks[0]?.id??""}}(e.resourceKind,t?.inventory);return void 0===t?E(e,t,P("Choose a machine."),r,s):"none"!==e.resourceKind&&""===s?E(e,t,P(function(e){switch(e){case"filesystem":return"No filesystems are reported by this machine.";case"gpu":return"No telemetry-capable GPU is reported by this machine.";case"disk":return"No disks are reported by this machine.";case"none":return"No resource is available."}}(e.resourceKind)),r,s):E(e,t,function(e,t,r){var s;if("stale"===e.condition)return{kind:"ready"};let n=function(e,t){let r=e.inventory?.capabilities[t];if(r?.status==="unsupported"||r?.status==="withheld")return P(`${M[t]} metrics are not shared with this hub.`);let s=e.metrics?.payload;return void 0===s?T():"unavailable"===function(e,t){switch(t){case"cpu":return e.cpu;case"memory":return e.memory;case"swap":return e.swap;case"gpus":return e.gpus;case"disks":return e.disks;case"network":return e.network}}(s,t).status?P(`${M[t]} readings are unavailable on this machine.`):null}(t,(s=e.metric).startsWith("cpu.")?"cpu":s.startsWith("memory.")?"memory":s.startsWith("swap.")?"swap":s.startsWith("gpu.")?"gpus":s.startsWith("io.")||s.startsWith("fs.")||s.startsWith("disk.")?"disks":"network");if(null!==n)return n;let l=t.metrics?.payload;if(void 0===l)return T();switch(e.metric){case"cpu.usage":default:return{kind:"ready"};case"cpu.temperature":return I(l.cpu,"temperatureC","CPU temperature");case"cpu.power":return I(l.cpu,"powerWatts","CPU package power");case"cpu.iowait":return I(l.cpu,"iowaitPercent","CPU I/O wait");case"cpu.pressure":return I(l.cpu,"pressureSomePercent","CPU pressure");case"memory.usage":{let e=l.memory;if("ok"!==e.status||!(e.totalBytes>0))return P("Memory total is not reported by this machine.");return{kind:"ready"}}case"memory.pressure.some":return I(l.memory,"pressureSomePercent","Memory pressure");case"memory.pressure.full":return I(l.memory,"pressureFullPercent","Memory full pressure");case"io.pressure.some":return I(l.disks,"pressureSomePercent","I/O pressure");case"io.pressure.full":return I(l.disks,"pressureFullPercent","I/O full pressure");case"fs.usage":{let e=$(l,r);if(void 0===e)return P("The latest sample does not include this filesystem.");if("ok"!==e.status||!(e.totalBytes>0))return P("Filesystem size is not reported for this filesystem.");return{kind:"ready"}}case"fs.inodes.usage":{let e=$(l,r);if(void 0===e)return P("The latest sample does not include this filesystem.");if("ok"!==e.status)return P("This filesystem is unavailable in the latest sample.");let t=U(e,"inodesUsed"),s=U(e,"inodesTotal");if(null===t||null===s||s<=0)return P("Inode usage is not reported for this filesystem.");return{kind:"ready"}}case"gpu.temperature":{let e="ok"===l.gpus.status?l.gpus.devices.find(e=>e.id===r):void 0;if(void 0===e)return P("The latest sample does not include this GPU.");if("ok"!==e.status)return P("This GPU is unavailable in the latest sample.");return I(e,"temperatureC","GPU temperature")}case"disk.utilization":{let e=A(l,r);if(void 0===e)return P("The latest sample does not include this disk.");if("ok"!==e.status)return P("This disk is unavailable in the latest sample.");return I(e,"ioUtilizationPercent","Disk utilization")}case"disk.read.latency":{let e=A(l,r);if(void 0===e)return P("The latest sample does not include this disk.");if("ok"!==e.status)return P("This disk is unavailable in the latest sample.");return I(e,"readLatencyMs","Disk read latency")}case"disk.write.latency":{let e=A(l,r);if(void 0===e)return P("The latest sample does not include this disk.");if("ok"!==e.status)return P("This disk is unavailable in the latest sample.");return I(e,"writeLatencyMs","Disk write latency")}}}(e,t,s),r,s)})(e,z)):[],J=""===q?null:B.find(e=>e.preset.id===q)??null;(0,n.useEffect)(()=>{H&&null===t&&"stale"!==b&&f("stale")},[H,t,b]);let V=F(m,z),Y="above"===b||"below"===b,Q=j(m),X=r||G||0===e.length,ee=async e=>{if(e.preventDefault(),L(null),""===o.trim())return void L("Give the rule a name.");if(""===u)return void L("Choose a machine.");if(H&&"stale"!==b)return void L("No metrics have been received from this machine yet, so value and unavailable rules cannot be evaluated against it. Use a stale rule, or wait until the machine reports metrics.");if(Q&&""===h.trim())return void L("Choose or enter the metric's resource.");let r=Number(N);if(""===N.trim()||!Number.isInteger(r)||r<0||1e3*r>864e5)return void L("Duration must be a whole number of seconds from 0 to 86400.");let s=null;if(Y&&(""===g.trim()||!Number.isFinite(s=Number(g))))return void L("Enter a numeric threshold.");let n=function(e){if(""===e.trim())return null;let t=new Date(e);return Number.isFinite(t.getTime())?t.toISOString():null}(R);Z(!0);try{await l({...null===t?{}:{id:t.id},name:o.trim(),machineId:u,metric:m,resourceId:Q?h.trim():"",condition:b,threshold:Y?s:null,durationMs:1e3*r,enabled:C,maintenanceUntil:n})}catch(e){L(e instanceof Error?e.message:"Could not save the rule.")}finally{Z(!1)}};return(0,s.jsxs)("form",{onSubmit:e=>void ee(e),"aria-busy":G,className:"flex flex-col gap-4",children:[0===e.length?(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"No machines available."}):null,null===t?(0,s.jsxs)("div",{className:"border-b border-border pb-4",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-end",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("label",{htmlFor:"alert-rule-preset",className:"text-xs text-muted-foreground",children:"Warning preset"}),(0,s.jsxs)("select",{id:"alert-rule-preset",value:q,onChange:e=>_(e.target.value),disabled:X,"aria-describedby":"alert-rule-preset-note",className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground",children:[(0,s.jsx)("option",{value:"",children:"Choose a preset…"}),B.map(e=>(0,s.jsxs)("option",{value:e.preset.id,children:[e.preset.label,"ready"===e.status.kind?"":"waiting"===e.status.kind?" — waiting for metrics":" — unavailable"]},e.preset.id))]})]}),(0,s.jsx)("button",{type:"button",onClick:()=>{if(null===J||null===J.input)return;let e=J.input;d(e.name),c(e.machineId),x(e.metric),p(e.resourceId??""),f(e.condition),w(null===e.threshold||void 0===e.threshold?"":String(e.threshold)),k(String(e.durationMs/1e3)),L(null)},disabled:X||J?.status.kind!=="ready",className:"rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Use preset"})]}),(0,s.jsx)("p",{id:"alert-rule-preset-note","aria-live":"polite",className:"mt-1.5 text-xs text-muted-foreground",children:null!==J&&"ready"!==J.status.kind?J.status.reason:""})]}):null,(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,s.jsxs)("div",{className:"sm:col-span-2",children:[(0,s.jsx)("label",{htmlFor:"alert-rule-name",className:"text-xs text-muted-foreground",children:"Rule name"}),(0,s.jsx)("input",{id:"alert-rule-name",value:o,onChange:e=>d(e.target.value),maxLength:128,disabled:X,placeholder:"CPU sustained high",className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground placeholder:text-muted-foreground"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-rule-machine",className:"text-xs text-muted-foreground",children:"Machine"}),(0,s.jsxs)("select",{id:"alert-rule-machine",value:u,onChange:r=>{var s;let n,l;return s=r.target.value,_(""),c(s),void 0!==(n=e.find(e=>e.machineId===s))&&void 0===n.metrics&&null===t&&f("stale"),l=F(m,n),void(j(m)&&p(l[0]?.value??""))},disabled:X,className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground",children:[""===u||e.some(e=>e.machineId===u)?null:(0,s.jsxs)("option",{value:u,children:[u," (current)"]}),e.map(e=>(0,s.jsx)("option",{value:e.machineId,children:e.displayName?.trim()||e.hostname||e.machineId},e.machineId))]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-rule-metric",className:"text-xs text-muted-foreground",children:"Metric"}),(0,s.jsx)("select",{id:"alert-rule-metric",value:m,onChange:e=>{var t;let r;return x(t=e.target.value),r=F(t,z),void p(j(t)?r[0]?.value??"":"")},disabled:X,className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground",children:Object.keys(v).map(e=>({value:e,label:v[e].label})).map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))})]}),Q?(0,s.jsxs)("div",{className:"sm:col-span-2",children:[(0,s.jsx)("label",{htmlFor:"alert-rule-resource",className:"text-xs text-muted-foreground",children:"Resource"}),V.length>0?(0,s.jsxs)("select",{id:"alert-rule-resource",value:h,onChange:e=>p(e.target.value),disabled:X,className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground",children:[""===h||V.some(e=>e.value===h)?null:(0,s.jsxs)("option",{value:h,children:[h," (current)"]}),V.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))]}):(0,s.jsx)("input",{id:"alert-rule-resource",value:h,onChange:e=>p(e.target.value),maxLength:256,disabled:X,placeholder:"cpu.core"===m?"core:0":m.startsWith("gpu.")?"gpu:GPU-…":m.startsWith("fs.")?"fs:/":m.startsWith("disk.")?"disk:sda":m.startsWith("net.")?"net:eno1":"Resource id",className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground placeholder:text-muted-foreground"})]}):null,(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-rule-condition",className:"text-xs text-muted-foreground",children:"Condition"}),(0,s.jsx)("select",{id:"alert-rule-condition",value:b,onChange:e=>f(e.target.value),disabled:X,className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground",children:y.map(e=>(0,s.jsx)("option",{value:e.value,disabled:H&&"stale"!==e.value,children:e.label},e.value))}),H?(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Waiting for metrics."}):null]}),Y?(0,s.jsxs)("div",{children:[(0,s.jsxs)("label",{htmlFor:"alert-rule-threshold",className:"text-xs text-muted-foreground",children:["Threshold (",function(e){switch(v[e].unit){case"percent":return"percent (0–100)";case"bytes":return"bytes";case"bytes_per_second":return"bytes per second";case"celsius":return"degrees Celsius";case"watts":return"watts";case"milliseconds":return"milliseconds"}}(m),")"]}),(0,s.jsx)("input",{id:"alert-rule-threshold",type:"number",step:"any",value:g,onChange:e=>w(e.target.value),disabled:X,className:"tnum mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground"})]}):null,(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-rule-duration",className:"text-xs text-muted-foreground",children:"Must hold for (seconds)"}),(0,s.jsx)("input",{id:"alert-rule-duration",type:"number",min:0,max:86400,step:1,value:N,onChange:e=>k(e.target.value),disabled:X,className:"tnum mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-rule-maintenance",className:"text-xs text-muted-foreground",children:"Maintenance until (optional)"}),(0,s.jsx)("input",{id:"alert-rule-maintenance",type:"datetime-local",value:R,onChange:e=>W(e.target.value),disabled:X,className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground"})]}),(0,s.jsxs)("label",{className:"flex items-center gap-2 text-xs text-foreground sm:col-span-2",children:[(0,s.jsx)("input",{type:"checkbox",checked:C,onChange:e=>O(e.target.checked),disabled:X,className:"h-4 w-4 rounded border-border accent-[var(--accent)]"}),"Rule enabled"]})]}),K?(0,s.jsx)("p",{role:"alert",className:"rounded-md bg-crit-soft px-3 py-2 text-xs text-foreground",children:K}):null,(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("button",{type:"submit",disabled:X,className:"rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-accent-foreground transition-colors hover:bg-accent/90 disabled:opacity-50",children:G?"Saving…":null===t?"Create rule":"Save rule"}),null!==t?(0,s.jsx)("button",{type:"button",onClick:a,disabled:G,className:"rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Cancel"}):null]})]})}function O({status:e,busy:t,onConfigure:r,onClear:l,onTest:a}){let[i,o]=(0,n.useState)(""),[d,u]=(0,n.useState)(""),[c,m]=(0,n.useState)(""),[x,h]=(0,n.useState)(!0),[p,b]=(0,n.useState)(null),[f,g]=(0,n.useState)(null),[y,v]=(0,n.useState)(!1),[j,w]=(0,n.useState)(null),[N,k]=(0,n.useState)(null),C=(0,n.useRef)(null),S=(0,n.useRef)(null),M=(0,n.useRef)(null);(0,n.useEffect)(()=>{null!==j&&C.current?.focus()},[j]),(0,n.useEffect)(()=>{e.configured||(w(null),k(null))},[e.configured]);let P=async e=>{v(!0),b(null),w(null),k(null);try{await r(e),o(""),u(""),m(""),h(!0)}catch(e){b(e instanceof Error?e.message:"Could not configure the webhook.")}finally{v(!1)}},T=async t=>{t.preventDefault();let r=(()=>{let e;b(null),g(null);let t=i.trim();if(""===t)return b("Enter the webhook URL."),null;if(""!==d.trim())try{let t=JSON.parse(d);if(null===t||"object"!=typeof t||Array.isArray(t))throw Error("not an object");for(let[r,s]of(e={},Object.entries(t))){if("string"!=typeof s)throw Error("header values must be strings");e[r]=s}}catch{return b("Headers must be a JSON object with string values."),null}return{url:t,...void 0===e?{}:{headers:e},secret:""===c.trim()?null:c,enabled:x}})();if(null!==r){if(e.configured){k(r),w("replace");return}await P(r)}},U=async()=>{v(!0),b(null),g(null),w(null);try{await l(),o(""),u(""),m("")}catch(e){b(e instanceof Error?e.message:"Could not clear the webhook.")}finally{v(!1)}},$=async()=>{"clear"===j?await U():"replace"===j&&null!==N&&await P(N)},A=async()=>{b(null),v(!0);try{g(await a())}catch(e){b(e instanceof Error?e.message:"Could not test the webhook.")}finally{v(!1)}},I=t||y||null!==j,E=e.configured&&"loopback-http"===e.transport;return(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-2 text-xs",children:[(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Configured"}),(0,s.jsx)("dd",{className:"text-foreground",children:e.configured?e.enabled?"Enabled":"Disabled":"Not configured"}),(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Transport"}),(0,s.jsx)("dd",{className:"text-foreground",children:"https"===e.transport?"HTTPS":"loopback-http"===e.transport?"Loopback HTTP test sink":"—"}),(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Last test"}),(0,s.jsx)("dd",{className:"text-foreground",children:null===e.lastTestAt?"Never":`${!0===e.lastTestOk?"Passed":"Failed"} \xb7 ${new Date(e.lastTestAt).toLocaleString()}`}),e.lastError?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Last error"}),(0,s.jsx)("dd",{className:"text-warn",children:e.lastError})]}):null]}),(0,s.jsxs)("form",{onSubmit:e=>void T(e),className:"flex flex-col gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-webhook-url",className:"text-xs text-muted-foreground",children:e.configured?"Replace webhook URL":"Webhook URL"}),(0,s.jsx)("input",{id:"alert-webhook-url",type:"url",required:!0,value:i,onChange:e=>o(e.target.value),maxLength:2048,disabled:I,placeholder:"https://receiver.example/alerts",className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground placeholder:text-muted-foreground"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-webhook-headers",className:"text-xs text-muted-foreground",children:"Headers (JSON, optional)"}),(0,s.jsx)("textarea",{id:"alert-webhook-headers",value:d,onChange:e=>u(e.target.value),rows:2,disabled:I,placeholder:'{"x-channel": "monitoring"}',className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 font-mono text-xs text-foreground placeholder:text-muted-foreground"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"alert-webhook-secret",className:"text-xs text-muted-foreground",children:"Signing secret (optional)"}),(0,s.jsx)("input",{id:"alert-webhook-secret",type:"password",value:c,onChange:e=>m(e.target.value),maxLength:256,disabled:I,placeholder:"Blank clears the signature",autoComplete:"new-password",className:"mt-1 w-full rounded-md border border-border bg-card px-2.5 py-1.5 text-sm text-foreground"})]}),(0,s.jsxs)("label",{className:"flex items-center gap-2 text-xs text-foreground",children:[(0,s.jsx)("input",{type:"checkbox",checked:x,onChange:e=>h(e.target.checked),disabled:I,className:"h-4 w-4 rounded border-border accent-[var(--accent)]"}),"Webhook enabled"]}),p?(0,s.jsx)("p",{role:"alert",className:"rounded-md bg-crit-soft px-3 py-2 text-xs text-foreground",children:p}):null,(0,s.jsx)("p",{role:"status",className:f?`rounded-md px-3 py-2 text-xs ${f.ok?"bg-ok-soft text-foreground":"bg-warn-soft text-foreground"}`:"sr-only",children:f?`Test ${f.ok?"delivered":"failed"}${null!==f.status?` (HTTP ${f.status})`:""}${f.error?` — ${f.error}`:""}.`:""}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("button",{ref:S,type:"submit",disabled:I||""===i.trim(),className:"rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-accent-foreground transition-colors hover:bg-accent/90 disabled:opacity-50",children:e.configured?"Replace webhook":"Configure webhook"}),(0,s.jsx)("button",{ref:M,type:"button",onClick:()=>{b(null),w("clear")},disabled:I||!e.configured,className:"rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Clear webhook"}),(0,s.jsx)("button",{type:"button",onClick:()=>void A(),disabled:I||!E,title:E?"Send one explicit test message to the configured loopback sink":"Test delivery is available only for a configured loopback HTTP sink",className:"rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Send test"})]}),null!==j?(0,s.jsxs)("div",{role:"group","aria-label":"Confirm webhook change",className:"rounded-md bg-warn-soft px-3 py-3",children:[(0,s.jsx)("p",{className:"text-xs text-foreground",children:"clear"===j?"Clear the configured webhook? Future incidents will not be delivered until a webhook is configured again.":"Replace the configured webhook? The stored URL, headers and secret will be overwritten."}),(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,s.jsx)("button",{ref:C,type:"button",onClick:()=>void $(),disabled:y,className:`rounded-md px-3 py-1.5 text-xs font-medium text-accent-foreground transition-colors disabled:opacity-50 ${"clear"===j?"bg-crit":"bg-accent hover:bg-accent/90"}`,children:"clear"===j?"Confirm clear":"Confirm replace"}),(0,s.jsx)("button",{type:"button",onClick:()=>{let e="clear"===j?M.current:S.current;w(null),k(null),e?.focus()},disabled:y,className:"rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Cancel"})]})]}):null]})]})}function R(e){if(null===e)return"—";let t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleString():e}function W({tone:e,children:t}){return(0,s.jsx)("span",{className:`tnum inline-flex items-center rounded-full px-2 py-0.5 text-xs ${"ok"===e?"bg-ok-soft text-ok":"warn"===e?"bg-warn-soft text-warn":"crit"===e?"bg-crit-soft text-crit":"border border-border text-muted-foreground"}`,children:t})}function q({incident:e,now:t}){let r="open"===e.status;return(0,s.jsx)("li",{className:"border-b border-border py-3 last:border-b-0",children:(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-x-4 gap-y-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(W,{tone:r?"crit":"ok",children:r?"Open":"Recovered"}),(0,s.jsx)("span",{className:"truncate text-sm font-medium",children:e.ruleName}),(0,s.jsx)("span",{className:"tnum text-xs text-muted-foreground",children:e.machineId})]}),(0,s.jsx)("p",{className:"mt-1 max-w-2xl text-sm",children:e.message}),(0,s.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:[C(e.metric,e.resourceId)," \xb7 started"," ",(0,b.nV)((0,b.A4)(e.startedAt,t)),null!==e.resolvedAt?` \xb7 recovered ${(0,b.nV)((0,b.A4)(e.resolvedAt,t))}`:""]})]}),(0,s.jsxs)("dl",{className:"tnum grid shrink-0 grid-cols-2 gap-x-4 gap-y-1 text-xs text-muted-foreground",children:[(0,s.jsx)("dt",{children:"Started value"}),(0,s.jsx)("dd",{className:"text-right text-foreground",children:N(e.metric,e.startedValue)}),(0,s.jsx)("dt",{children:"Recovered value"}),(0,s.jsx)("dd",{className:"text-right text-foreground",children:N(e.metric,e.resolvedValue)})]})]})})}function _({rule:e,admin:t,busy:r,confirmingDelete:n,onEdit:i,onRequestDelete:o,onCancelDelete:d,onConfirmDelete:u}){var c,m;let x=(c=e.condition,y.find(e=>e.value===c)?.needsThreshold)?`${k(e.condition)} ${N(e.metric,e.threshold)}`:k(e.condition),h=e.enabled?"firing"===e.state?"crit":"pending"===e.state?"warn":"ok":"muted",p=e.enabled?"firing"===e.state?"Firing":"pending"===e.state?"Pending":"OK":"Disabled";return(0,s.jsxs)("li",{className:"border-b border-border py-3 last:border-b-0",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-x-4 gap-y-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"truncate text-sm font-medium",children:e.name}),(0,s.jsx)(W,{tone:h,children:p})]}),(0,s.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:[e.machineId," \xb7 ",C(e.metric,e.resourceId)]}),(0,s.jsxs)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:[x," \xb7 holds ",!Number.isFinite(m=e.durationMs)||m<=0?"Immediately":m<6e4?`${Math.round(m/1e3)} s`:m<36e5?`${Math.round(m/6e4)} min`:`${Math.round(m/36e5)} h`,e.pendingSince?` \xb7 pending since ${R(e.pendingSince)}`:""]}),e.maintenanceUntil?(0,s.jsxs)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:["Maintenance until ",R(e.maintenanceUntil)]}):null]}),t?(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[(0,s.jsxs)("button",{type:"button",onClick:i,disabled:r||n,className:"inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:[(0,s.jsx)(l.A,{className:"h-3 w-3","aria-hidden":!0}),"Edit"]}),(0,s.jsxs)("button",{type:"button",onClick:o,disabled:r||n,className:"inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs text-crit transition-colors hover:bg-crit-soft disabled:opacity-50",children:[(0,s.jsx)(a.A,{className:"h-3 w-3","aria-hidden":!0}),"Delete"]})]}):null]}),n?(0,s.jsxs)("div",{role:"group","aria-label":"Confirm rule deletion",className:"mt-3 rounded-md bg-warn-soft px-3 py-2.5",children:[(0,s.jsxs)("p",{className:"text-xs text-foreground",children:["Delete “",e.name,"”? Its incident history stays, but the rule stops evaluating."]}),(0,s.jsxs)("div",{className:"mt-2 flex flex-wrap gap-2",children:[(0,s.jsx)("button",{type:"button",autoFocus:!0,onClick:()=>void u(),disabled:r,className:"rounded-md bg-crit px-2.5 py-1 text-xs font-medium text-accent-foreground transition-colors disabled:opacity-50",children:"Confirm delete"}),(0,s.jsx)("button",{type:"button",onClick:d,disabled:r,className:"rounded-md border border-border px-2.5 py-1 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Cancel"})]})]}):null]})}function K({notification:e}){let t="failed"===e.status?"crit":"delivered"===e.status?"ok":"warn";return(0,s.jsxs)("li",{className:"border-b border-border py-2 last:border-b-0",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1 text-xs",children:[(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsx)(W,{tone:t,children:e.status}),(0,s.jsx)("span",{className:"text-foreground",children:e.event}),(0,s.jsxs)("span",{className:"tnum text-muted-foreground",children:["attempt ",e.attempts,"/",e.maxAttempts]})]}),(0,s.jsx)("span",{className:"tnum text-muted-foreground",children:R(e.createdAt)})]}),e.lastError?(0,s.jsx)("p",{className:"mt-1 text-xs text-warn",children:e.lastError}):null,(0,s.jsx)("p",{className:"tnum mt-0.5 truncate font-mono text-xs text-muted-foreground",children:e.id})]})}function L(){let{session:e,machines:t}=(0,f.M)(),r=(0,p.x)(),l=(0,g.c)(),a="signed-in"===e.kind?e.user.csrfToken:null,b="signed-in"===e.kind&&!0===e.user.admin,[y,v]=(0,n.useState)(null),[j,w]=(0,n.useState)(!0),[N,k]=(0,n.useState)(null),[C,S]=(0,n.useState)(null),[M,P]=(0,n.useState)(null),[T,U]=(0,n.useState)(null),[$,A]=(0,n.useState)(!1),I=b&&(null===y||y.canAdmin),E=(0,n.useCallback)(async()=>{if(null!==a){w(!0),k(null);try{let e=await fetch("/api/alerts",{headers:{Accept:"application/json"},cache:"no-store",credentials:"same-origin"}),t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error??`Could not load alerts (${e.status}).`);v(t)}catch(e){k(e instanceof Error?e.message:"Could not load alerts.")}finally{w(!1)}}},[a]);(0,n.useEffect)(()=>{null!==a&&E()},[a,E]);let F=(0,n.useCallback)(async(e,t)=>{if(null===a)throw Error("Sign in required.");A(!0),k(null);try{let r=await fetch(e,{...t,cache:"no-store",credentials:"same-origin",headers:{Accept:"application/json","Content-Type":"application/json","x-csrf-token":a,...t.headers??{}}}),s=await r.json().catch(()=>({}));if(!r.ok)throw Error(s.error??`Request failed (${r.status}).`);return s}finally{A(!1)}},[a]),R=async e=>{await F("/api/alerts/rules",{method:"POST",body:JSON.stringify(e)}),P(null),S(e.id?"Rule saved.":"Rule created."),await E()},W=async e=>{try{await F(`/api/alerts/rules?id=${encodeURIComponent(e.id)}`,{method:"DELETE"}),M?.id===e.id&&P(null),U(null),S("Rule deleted."),await E()}catch(e){k(e instanceof Error?e.message:"Could not delete the rule.")}},L=async e=>{await F("/api/alerts/webhook",{method:"POST",body:JSON.stringify({action:"configure",...e})}),S("Webhook configured."),await E()},G=async()=>{await F("/api/alerts/webhook",{method:"POST",body:JSON.stringify({action:"clear"})}),S("Webhook cleared."),await E()},Z=async()=>{let e=await F("/api/alerts/webhook",{method:"POST",body:JSON.stringify({action:"test"})});return v(t=>null===t?t:{...t,webhook:e.status}),S(e.result.ok?"Webhook test delivered.":"Webhook test failed."),e.result},z=y?.incidents??[],H=z.filter(e=>"open"===e.status).length,B=y?.rules??[],J=y?.notifications,V=j&&null===y;return(0,s.jsx)(c.G,{title:"Alerts",headerRight:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(x.$E,{}),(0,s.jsx)(h.B,{})]}),children:r||(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(p.E,{}),(0,s.jsx)("div",{className:"mb-4 flex flex-wrap items-center justify-end gap-3",children:(0,s.jsxs)("button",{type:"button",onClick:()=>void E(),disabled:j,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:[(0,s.jsx)(i.A,{className:`h-3.5 w-3.5 ${j?"animate-spin":""}`,"aria-hidden":!0}),"Refresh"]})}),(0,s.jsx)("p",{role:"status",className:C?"mb-4 text-xs text-muted-foreground":"sr-only",children:C??""}),N?(0,s.jsx)("p",{role:"alert",className:"mb-4 rounded-lg bg-crit-soft px-4 py-2.5 text-xs text-foreground",children:N}):null,V?(0,s.jsx)(m.Z,{title:"Alerts",className:"mt-8",children:(0,s.jsx)(m.p,{icon:i.A,note:"Loading alert rules and incidents…"})}):null===y?(0,s.jsx)(m.Z,{title:"Alerts unavailable",className:"mt-8",children:(0,s.jsx)(m.p,{icon:o.A,note:"Alert state could not be loaded."})}):(0,s.jsxs)("div",{className:I?"grid gap-5 xl:grid-cols-[minmax(0,1fr)_24rem]":"flex flex-col gap-5",children:[(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-5",children:[(0,s.jsx)(m.Z,{title:"Incidents and recoveries",action:(0,s.jsxs)("span",{children:[H," open \xb7 ",z.length," recent"]}),children:0===z.length?(0,s.jsx)(m.p,{icon:d,note:"No incidents."}):(0,s.jsx)("ul",{className:"flex flex-col",children:z.map(e=>(0,s.jsx)(q,{incident:e,now:l},e.id))})}),(0,s.jsx)(m.Z,{title:"Rules",action:(0,s.jsxs)("span",{children:[B.length," configured"]}),children:0===B.length?(0,s.jsx)(m.p,{icon:u.A,note:"No rules."}):(0,s.jsx)("ul",{className:"flex flex-col",children:B.map(e=>(0,s.jsx)(_,{rule:e,admin:I,busy:$,confirmingDelete:T===e.id,onEdit:()=>{U(null),P(e)},onRequestDelete:()=>U(e.id),onCancelDelete:()=>U(null),onConfirmDelete:()=>W(e)},e.id))})}),(0,s.jsx)(m.Z,{title:"Notifications",action:(0,s.jsxs)("span",{children:[J?.pending??0," pending \xb7 ",J?.failed??0," failed"]}),children:void 0===J||0===J.recent.length?(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"No notifications."}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("dl",{className:"grid grid-cols-3 gap-3 border-b border-border pb-3 text-xs",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Pending"}),(0,s.jsx)("dd",{className:"tnum text-foreground",children:J.pending})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Delivered"}),(0,s.jsx)("dd",{className:"tnum text-foreground",children:J.delivered})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("dt",{className:"text-muted-foreground",children:"Failed"}),(0,s.jsx)("dd",{className:"tnum text-foreground",children:J.failed})]})]}),(0,s.jsx)("ul",{className:"mt-1 flex flex-col",children:J.recent.slice(0,10).map(e=>(0,s.jsx)(K,{notification:e},e.id))})]})})]}),I?(0,s.jsxs)("aside",{className:"flex min-w-0 flex-col gap-5",children:[(0,s.jsx)(m.Z,{title:null===M?"New rule":"Edit rule",action:null===M?null:(0,s.jsx)("button",{type:"button",onClick:()=>P(null),className:"text-xs text-muted-foreground hover:text-foreground",children:"New instead"}),children:(0,s.jsx)(D,{machines:t,rule:M,busy:$,onSave:R,onCancel:()=>P(null)})}),(0,s.jsx)(m.Z,{title:"Webhook",children:(0,s.jsx)(O,{status:y.webhook,busy:$,onConfigure:L,onClear:G,onTest:Z})})]}):null]})]})})}},2865:(e,t,r)=>{Promise.resolve().then(r.bind(r,1461))},5798:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]])},6582:(e,t,r)=>{"use strict";r.d(t,{E:()=>f,x:()=>b});var s=r(5155),n=r(8500),l=r.n(n),a=r(828),i=r(6914),o=r(7029),d=r(438),u=r(7422),c=r(1735),m=r(3440),x=r(9939);function h(e){return(0,s.jsxs)("button",{type:"button",onClick:e.onClick,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:[(0,s.jsx)(a.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.children]})}function p(e){return(0,s.jsx)(l(),{href:e.href,className:e.primary?"inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-accent-foreground transition-colors hover:bg-accent/90":"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:e.children})}function b(){let{session:e,phase:t,retryConnection:r}=(0,x.M)();switch(e.kind){case"restoring":return(0,s.jsx)(m.Z,{title:"Checking session",className:"mx-auto my-12 max-w-md",children:(0,s.jsx)(m.p,{icon:i.A,note:"Checking your session…"})});case"restore-failed":return(0,s.jsxs)(m.Z,{title:"Hub unreachable",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(m.p,{icon:o.A,note:"The hub is unreachable right now."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(h,{onClick:r,children:"Check again"})})]});case"signed-out":if("expired"===t)return(0,s.jsxs)(m.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(m.p,{icon:d.A,note:"Your session ended."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(p,{href:"/login",primary:!0,children:"Sign in"})})]});return(0,s.jsxs)(m.Z,{title:"Sign in required",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(m.p,{icon:i.A,note:"Sign in required."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(p,{href:"/login",primary:!0,children:"Sign in"})})]});case"auth-unavailable":return(0,s.jsx)(m.Z,{title:"Sign-in unavailable",className:"mx-auto my-12 max-w-md",children:(0,s.jsx)(m.p,{icon:u.A,note:"Browser sign-in is not configured on this hub."})})}return"expired"===t?(0,s.jsxs)(m.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(m.p,{icon:d.A,note:"Your session ended."}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(p,{href:"/login",primary:!0,children:"Sign in"})})]}):"no-permission"===t?(0,s.jsxs)(m.Z,{title:"No permission",className:"mx-auto my-12 max-w-md",children:[(0,s.jsx)(m.p,{icon:u.A,note:`You are signed in as ${e.user.username}, but this hub grants no machine view to this account.`}),(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(h,{onClick:r,children:"Check again"})})]}):null}function f(){let{phase:e,retryConnection:t}=(0,x.M)();return"reconnecting"!==e&&"disconnected"!==e&&"connecting"!==e?null:"connecting"===e?(0,s.jsxs)("div",{role:"status",className:"mb-5 flex items-center gap-2 rounded-lg border border-border bg-card px-4 py-2.5 text-xs text-muted-foreground",children:[(0,s.jsx)(a.A,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),"Connecting to the live feed — waiting for the first snapshot."]}):(0,s.jsxs)("div",{role:"status",className:"mb-5 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border border-border bg-card px-4 py-2.5 text-xs text-muted-foreground",children:[(0,s.jsx)(c.A,{className:"h-3.5 w-3.5 shrink-0 text-warn","aria-hidden":!0}),(0,s.jsxs)("span",{children:["Connection lost — values below are ",(0,s.jsx)("strong",{className:"font-medium text-foreground",children:"last known"}),", not live measurements","reconnecting"===e?" — retrying with backoff…":" — retries stopped."]}),"disconnected"===e?(0,s.jsx)(h,{onClick:t,children:"Retry now"}):null]})}},7241:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(8698).A)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])}},e=>{e.O(0,[157,939,103,441,794,358],()=>e(e.s=2865)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[572],{3092:(e,s,t)=>{"use strict";t.d(s,{A:()=>n});let n=(0,t(8698).A)("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]])},3612:(e,s,t)=>{"use strict";t.d(s,{A:()=>n});let n=(0,t(8698).A)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},5773:(e,s,t)=>{"use strict";t.d(s,{ConnectionsView:()=>A});var n=t(5155),a=t(8500),l=t.n(a),r=t(438),d=t(3092),i=t(3612),c=t(7233),x=t(4173),o=t(3440),m=t(940),u=t(802),h=t(6576),g=t(6582),f=t(7586),p=t(9939),j=t(7348),N=t(2241);function b(e){if(null===e)return"—";let s=new Date(e);return Number.isFinite(s.getTime())?s.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"}):e}function v({capability:e}){var s;return(0,n.jsxs)("li",{className:"rounded-md border border-border bg-card-strong/30 px-2 py-1.5",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,n.jsx)("span",{className:"text-xs text-foreground",children:e.label}),(0,n.jsx)("span",{className:`tnum rounded-full px-1.5 py-0.5 text-xs ${"supported"===(s=e.status)?"bg-ok-soft text-ok":"unsupported"===s?"bg-warn-soft text-warn":"border border-border text-muted-foreground"}`,children:e.status})]}),e.reason?(0,n.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:e.reason}):null]})}function y({view:e,now:s}){return(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[(0,n.jsxs)("span",{className:"tnum inline-flex items-center gap-1.5 text-sm",children:[(0,n.jsx)("span",{"aria-hidden":!0,className:`inline-block h-2 w-2 shrink-0 rounded-full ${e.connected?"bg-ok":"bg-crit"}`}),e.connected?"Connected":"Disconnected"]}),(0,n.jsxs)("span",{className:"tnum text-xs text-muted-foreground",children:["Interval ",null===e.cadenceMs?"unknown":(0,f.$)(e.cadenceMs)]}),(0,n.jsxs)("span",{className:"tnum text-xs text-muted-foreground",children:["Updated ",(0,f.nV)((0,f.A4)(e.lastReceivedAt,s))]}),"stale"===e.freshness?(0,n.jsx)(h.vw,{text:"stale",title:`No update for over ${(0,f.$)(e.thresholdMs)}`}):"unknown"===e.freshness?(0,n.jsx)(h.vw,{text:"no sample",title:"No receipt timestamp is available yet"}):null]})}function w({view:e}){if(null===e.delivery)return(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Delivery status unavailable."});let s=e.delivery;return(0,n.jsxs)("dl",{className:"grid gap-x-6 gap-y-2 sm:grid-cols-2",children:[(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Backlog records"}),(0,n.jsx)("dd",{className:"tnum text-xs text-foreground",children:s.pendingRecords})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Backlog bytes"}),(0,n.jsx)("dd",{className:"tnum text-xs text-foreground",children:(0,f.z3)(s.pendingBytes)})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"In-flight records"}),(0,n.jsx)("dd",{className:"tnum text-xs text-foreground",children:s.inFlightRecords})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Oldest pending"}),(0,n.jsx)("dd",{className:"tnum text-right text-xs text-foreground",children:b(s.oldestPendingCapturedAt)})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Last acknowledgment"}),(0,n.jsx)("dd",{className:"tnum text-right text-xs text-foreground",children:null===s.lastAckAt?"No acknowledgment yet":b(s.lastAckAt)})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Dropped / gap records"}),(0,n.jsx)("dd",{className:"tnum text-xs text-foreground",children:s.droppedRecords})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Replaying"}),(0,n.jsx)("dd",{className:"tnum text-xs text-foreground",children:s.replaying?"Yes":"No"})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Status captured"}),(0,n.jsx)("dd",{className:"tnum text-right text-xs text-foreground",children:b(e.deliveryCapturedAt)})]})]})}function k({view:e,now:s}){return(0,n.jsx)(o.Z,{title:e.name,action:(0,n.jsx)(l(),{href:`/machines/${encodeURIComponent(e.machineId)}`,className:"text-xs text-accent hover:underline",children:"Open machine"}),children:(0,n.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,n.jsx)(y,{view:e,now:s}),(0,n.jsxs)("section",{"aria-label":`${e.name} delivery`,children:[(0,n.jsxs)("h3",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground",children:[(0,n.jsx)(r.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Delivery"]}),(0,n.jsx)("div",{className:"mt-2",children:(0,n.jsx)(w,{view:e})})]}),(0,n.jsxs)("section",{"aria-label":`${e.name} collection failures`,className:"border-t border-border pt-4",children:[(0,n.jsx)("h3",{className:"text-xs font-medium text-muted-foreground",children:"Collection failures"}),null===e.delivery?(0,n.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Failure status unavailable."}):0===e.failures.length?(0,n.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"None"}):(0,n.jsx)("ul",{className:"mt-2 flex flex-col gap-1.5",children:e.failures.map((e,s)=>(0,n.jsxs)("li",{className:"text-xs",children:[(0,n.jsx)("span",{className:"text-foreground",children:e.metric}),e.resourceId?(0,n.jsxs)("span",{className:"tnum font-mono text-xs text-muted-foreground",children:[" \xb7 ",e.resourceId]}):null,(0,n.jsxs)("span",{className:"text-muted-foreground",children:[" — ",e.reason]})]},`${e.metric}\0${e.resourceId??""}\0${e.reason}\0${s}`))})]}),(0,n.jsxs)("section",{"aria-label":`${e.name} capabilities`,className:"border-t border-border pt-4",children:[(0,n.jsxs)("h3",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground",children:[(0,n.jsx)(d.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Capabilities"]}),null===e.capabilities?(0,n.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Capabilities unavailable."}):(0,n.jsx)("ul",{className:"mt-2 grid gap-1.5 sm:grid-cols-2 xl:grid-cols-3",children:e.capabilities.map(e=>(0,n.jsx)(v,{capability:e},e.key))})]})]})})}function A(){let{phase:e,machines:s,session:t}=(0,p.M)(),a=(0,g.x)(),r=(0,j.c)(),d=(0,N.cy)(s,r);return(0,n.jsx)(x.G,{title:"Connections",headerRight:(0,n.jsxs)(n.Fragment,{children:["signed-in"===t.kind&&t.user.admin?(0,n.jsxs)(l(),{href:"/administration#collectors",className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs hover:bg-card-strong",children:[(0,n.jsx)(i.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Add machine"]}):null,(0,n.jsx)(m.$E,{}),(0,n.jsx)(u.B,{})]}),children:a||(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(g.E,{}),("live"===e||"reconnecting"===e||"disconnected"===e)&&0===s.length?(0,n.jsx)(o.Z,{title:"No collectors",className:"mt-8",children:(0,n.jsx)(o.p,{icon:c.A,note:"No collectors are connected to this hub in your authorized scope."})}):null,0===d.length&&"connecting"===e?(0,n.jsx)(o.Z,{title:"Waiting for collector status",className:"mt-8",children:(0,n.jsx)(o.p,{icon:c.A,note:"Waiting for the first snapshot…"})}):null,d.length>0?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("h2",{className:"mb-4 text-sm font-medium tracking-tight",children:"Collectors"}),(0,n.jsx)("div",{className:"grid gap-5 xl:grid-cols-[repeat(auto-fit,minmax(30rem,1fr))]",children:d.map(e=>(0,n.jsx)(k,{view:e,now:r},e.machineId))})]}):null]})})}},6351:(e,s,t)=>{Promise.resolve().then(t.bind(t,5773))}},e=>{e.O(0,[157,939,103,227,441,794,358],()=>e(e.s=6351)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[572],{3092:(e,s,t)=>{"use strict";t.d(s,{A:()=>n});let n=(0,t(8698).A)("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]])},3612:(e,s,t)=>{"use strict";t.d(s,{A:()=>n});let n=(0,t(8698).A)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},5773:(e,s,t)=>{"use strict";t.d(s,{ConnectionsView:()=>A});var n=t(5155),a=t(8500),l=t.n(a),r=t(438),d=t(3092),i=t(3612),c=t(7233),x=t(4173),o=t(3440),m=t(940),u=t(802),h=t(6576),g=t(6582),f=t(7586),p=t(9939),j=t(7348),N=t(2241);function b(e){if(null===e)return"—";let s=new Date(e);return Number.isFinite(s.getTime())?s.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"medium"}):e}function v({capability:e}){var s;return(0,n.jsxs)("li",{className:"rounded-md border border-border bg-card-strong/30 px-2 py-1.5",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,n.jsx)("span",{className:"text-xs text-foreground",children:e.label}),(0,n.jsx)("span",{className:`tnum rounded-full px-1.5 py-0.5 text-xs ${"supported"===(s=e.status)?"bg-ok-soft text-ok":"unsupported"===s?"bg-warn-soft text-warn":"border border-border text-muted-foreground"}`,children:e.status})]}),e.reason?(0,n.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:e.reason}):null]})}function y({view:e,now:s}){return(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[(0,n.jsxs)("span",{className:"tnum inline-flex items-center gap-1.5 text-sm",children:[(0,n.jsx)("span",{"aria-hidden":!0,className:`inline-block h-2 w-2 shrink-0 rounded-full ${e.connected?"bg-ok":"bg-crit"}`}),e.connected?"Connected":"Disconnected"]}),(0,n.jsxs)("span",{className:"tnum text-xs text-muted-foreground",children:["Interval ",null===e.cadenceMs?"unknown":(0,f.$)(e.cadenceMs)]}),(0,n.jsxs)("span",{className:"tnum text-xs text-muted-foreground",children:["Updated ",(0,f.nV)((0,f.A4)(e.lastReceivedAt,s))]}),"stale"===e.freshness?(0,n.jsx)(h.vw,{text:"stale",title:`No update for over ${(0,f.$)(e.thresholdMs)}`}):"unknown"===e.freshness?(0,n.jsx)(h.vw,{text:"no sample",title:"No receipt timestamp is available yet"}):null]})}function w({view:e}){if(null===e.delivery)return(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"Delivery status unavailable."});let s=e.delivery;return(0,n.jsxs)("dl",{className:"grid gap-x-6 gap-y-2 sm:grid-cols-2",children:[(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Backlog records"}),(0,n.jsx)("dd",{className:"tnum text-xs text-foreground",children:s.pendingRecords})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Backlog bytes"}),(0,n.jsx)("dd",{className:"tnum text-xs text-foreground",children:(0,f.z3)(s.pendingBytes)})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"In-flight records"}),(0,n.jsx)("dd",{className:"tnum text-xs text-foreground",children:s.inFlightRecords})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Oldest pending"}),(0,n.jsx)("dd",{className:"tnum text-right text-xs text-foreground",children:b(s.oldestPendingCapturedAt)})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Last acknowledgment"}),(0,n.jsx)("dd",{className:"tnum text-right text-xs text-foreground",children:null===s.lastAckAt?"No acknowledgment yet":b(s.lastAckAt)})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Dropped / gap records"}),(0,n.jsx)("dd",{className:"tnum text-xs text-foreground",children:s.droppedRecords})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Replaying"}),(0,n.jsx)("dd",{className:"tnum text-xs text-foreground",children:s.replaying?"Yes":"No"})]}),(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Status captured"}),(0,n.jsx)("dd",{className:"tnum text-right text-xs text-foreground",children:b(e.deliveryCapturedAt)})]})]})}function k({view:e,now:s}){return(0,n.jsx)(o.Z,{title:e.name,action:(0,n.jsx)(l(),{href:`/machines/${encodeURIComponent(e.machineId)}`,className:"text-xs text-accent hover:underline",children:"Open machine"}),children:(0,n.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,n.jsx)(y,{view:e,now:s}),(0,n.jsxs)("section",{"aria-label":`${e.name} delivery`,children:[(0,n.jsxs)("h3",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground",children:[(0,n.jsx)(r.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Delivery"]}),(0,n.jsx)("div",{className:"mt-2",children:(0,n.jsx)(w,{view:e})})]}),(0,n.jsxs)("section",{"aria-label":`${e.name} collection failures`,className:"border-t border-border pt-4",children:[(0,n.jsx)("h3",{className:"text-xs font-medium text-muted-foreground",children:"Collection failures"}),null===e.delivery?(0,n.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Failure status unavailable."}):0===e.failures.length?(0,n.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"None"}):(0,n.jsx)("ul",{className:"mt-2 flex flex-col gap-1.5",children:e.failures.map((e,s)=>(0,n.jsxs)("li",{className:"text-xs",children:[(0,n.jsx)("span",{className:"text-foreground",children:e.metric}),e.resourceId?(0,n.jsxs)("span",{className:"tnum font-mono text-xs text-muted-foreground",children:[" \xb7 ",e.resourceId]}):null,(0,n.jsxs)("span",{className:"text-muted-foreground",children:[" — ",e.reason]})]},`${e.metric}\0${e.resourceId??""}\0${e.reason}\0${s}`))})]}),(0,n.jsxs)("section",{"aria-label":`${e.name} capabilities`,className:"border-t border-border pt-4",children:[(0,n.jsxs)("h3",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground",children:[(0,n.jsx)(d.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Capabilities"]}),null===e.capabilities?(0,n.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Capabilities unavailable."}):(0,n.jsx)("ul",{className:"mt-2 grid gap-1.5 sm:grid-cols-2 xl:grid-cols-3",children:e.capabilities.map(e=>(0,n.jsx)(v,{capability:e},e.key))})]})]})})}function A(){let{phase:e,machines:s,session:t}=(0,p.M)(),a=(0,g.x)(),r=(0,j.c)(),d=(0,N.cy)(s,r);return(0,n.jsx)(x.G,{title:"Connections",headerRight:(0,n.jsxs)(n.Fragment,{children:["signed-in"===t.kind&&t.user.admin?(0,n.jsxs)(l(),{href:"/administration#collectors",className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs hover:bg-card-strong",children:[(0,n.jsx)(i.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Add machine"]}):null,(0,n.jsx)(m.$E,{}),(0,n.jsx)(u.B,{})]}),children:a||(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(g.E,{}),("live"===e||"reconnecting"===e||"disconnected"===e)&&0===s.length?(0,n.jsx)(o.Z,{title:"No collectors",className:"mt-8",children:(0,n.jsx)(o.p,{icon:c.A,note:"No collectors are connected to this hub in your authorized scope."})}):null,0===d.length&&"connecting"===e?(0,n.jsx)(o.Z,{title:"Waiting for collector status",className:"mt-8",children:(0,n.jsx)(o.p,{icon:c.A,note:"Waiting for the first snapshot…"})}):null,d.length>0?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("h2",{className:"mb-4 text-sm font-medium tracking-tight",children:"Collectors"}),(0,n.jsx)("div",{className:"grid gap-5 xl:grid-cols-[repeat(auto-fit,minmax(30rem,1fr))]",children:d.map(e=>(0,n.jsx)(k,{view:e,now:r},e.machineId))})]}):null]})})}},6351:(e,s,t)=>{Promise.resolve().then(t.bind(t,5773))}},e=>{e.O(0,[157,939,103,130,441,794,358],()=>e(e.s=6351)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[900],{4546:(e,s,t)=>{Promise.resolve().then(t.bind(t,8887))},8528:(e,s,t)=>{"use strict";t.d(s,{A:()=>l});let l=(0,t(8698).A)("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]])},8887:(e,s,t)=>{"use strict";t.d(s,{MachineView:()=>ee});var l=t(5155),a=t(8500),n=t.n(a),r=t(8698);let i=(0,r.A)("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]),d=(0,r.A)("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]),o=(0,r.A)("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);var c=t(4173),x=t(3440),m=t(940),u=t(802),h=t(2115),p=t(8528),j=t(4567),g=t(7726),f=t(9429),v=t(7284),N=t(4150);let y=new Set,b=new Set(["cpu.usage","memory.used","gpu.utilization","gpu.memory.used"]);function w({machine:e}){let[s,t]=(0,h.useState)(y),a=(0,j.er)(e).filter(e=>b.has(e)).join(","),{data:r,error:i}=(0,f.n)({machineId:e.machineId,metricsKey:a,range:"10m"}),d=e=>t(s=>{let t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t}),o=(0,j.ue)(e,r?.result.series??[]),c=(r?.result.series??[]).map(e=>{let s=(0,j.oB)(e.metric),t=e.metric.startsWith("gpu.")?Math.max(1,o.findIndex(s=>s.id===e.resourceId)+1):0,l=(0,j.Lf)(s,t);return{key:`${e.metric}\0${e.resourceId}`,metric:e.metric,resourceId:e.resourceId,label:"cpu.usage"===e.metric?"CPU":"memory.used"===e.metric?"RAM":`GPU ${t}`,color:l.color,dash:l.dash,points:e.points}});return(0,l.jsxs)(x.Z,{title:"Recent usage \xb7 10m",action:(0,l.jsxs)(n(),{href:`/history?machineId=${encodeURIComponent(e.machineId)}`,className:"inline-flex min-h-8 items-center gap-1 text-xs text-accent hover:underline",children:["History",(0,l.jsx)(p.A,{className:"h-3.5 w-3.5","aria-hidden":!0})]}),children:[i?(0,l.jsx)("p",{role:"status",className:"mb-2 text-xs text-warn",children:r?"Refresh failed \xb7 showing saved readings":i.message}):null,r?.result.truncated?(0,l.jsx)("p",{className:"mb-2 text-xs text-warn",children:"Partial history"}):null,r?(0,l.jsx)(N._C,{children:(0,l.jsx)("div",{className:"grid gap-5 lg:grid-cols-2",children:[{title:"CPU & GPU",unit:"percent"},{title:"RAM & VRAM",unit:"bytes"}].map(({title:t,unit:a})=>(0,l.jsx)(v.t,{title:t,unit:a,series:c.filter(e=>(0,j.oB)(e.metric)?.unit===a),fromMs:r.result.fromMs,toMs:r.result.toMs,stepMs:(0,g.jl)(r.result.stepMs,r.result.tier,e.expectedIntervalMs),gaps:r.result.gaps,hiddenKeys:s,onToggleSeries:d,emptyMessage:"No readings"},a))})},e.machineId):(0,l.jsx)("div",{className:"flex min-h-48 items-center justify-center text-xs text-muted-foreground",role:"status",children:i?"History unavailable":"Loading history…"})]})}var k=t(8664),B=t(6582),$=t(6576),M=t(7586),P=t(2241);function z({label:e,valueLabel:s,percent:t,tone:a,ariaLabel:n,note:r}){let i=null===t?null:Math.min(100,Math.max(0,t));return(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex flex-wrap items-baseline justify-between gap-x-2 gap-y-0.5",children:[(0,l.jsx)("span",{className:"text-xs text-muted-foreground",children:e}),(0,l.jsx)("span",{className:"tnum text-xs text-foreground",children:s})]}),(0,l.jsx)("div",{role:"img","aria-label":n,className:"mt-1.5 h-1.5 w-full overflow-hidden rounded-full bg-card-strong",children:null===i?(0,l.jsx)("div",{className:"h-full w-full rounded-full border border-dashed border-border"}):(0,l.jsx)("div",{className:"h-full rounded-full",style:{width:`${i}%`,backgroundColor:"cpu"===a?"var(--cpu)":"mem"===a?"var(--mem)":"swap"===a?"var(--swap)":"gpu"===a?"var(--accent)":"var(--mem)"}})}),r?(0,l.jsx)("p",{className:"mt-1.5 text-xs text-muted-foreground",children:r}):null]})}function C({label:e,value:s}){return(0,l.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,l.jsx)("dt",{className:"text-xs text-muted-foreground",children:e}),(0,l.jsx)("dd",{className:"tnum min-w-0 truncate text-right text-xs text-foreground",children:s})]})}function L({children:e}){return(0,l.jsx)("p",{className:"text-xs text-muted-foreground",children:e})}function U({reason:e}){return(0,l.jsxs)("p",{className:"text-xs text-warn",children:["Unavailable — ",e]})}function I({children:e}){return(0,l.jsx)("h3",{className:"text-xs font-medium text-muted-foreground",children:e})}function S({stale:e}){return e?(0,l.jsx)($.vw,{text:"last known",title:"Retained from the last accepted sample"}):null}function T(e,s){return Number.isFinite(e)&&Number.isFinite(s)&&!(s<=0)?e/s*100:null}function A(e,s){return"available"===e.state?s:e.reason}function R({readings:e,className:s=""}){let t=new Map;for(let s of e){if("value"===s.reading.state)continue;let e=t.get(s.reading.reason)??[];e.push(s.label),t.set(s.reading.reason,e)}return(0,l.jsxs)("div",{className:s,children:[(0,l.jsx)("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-2 sm:grid-cols-4",children:e.map(({label:e,reading:s,format:t})=>{let a="value"===s.state;return(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsx)("dt",{className:"text-xs text-muted-foreground",children:e}),(0,l.jsxs)("dd",{className:"tnum text-xs text-foreground",title:a?void 0:s.reason,children:[a?t(s.value):"—",a&&s.stale?(0,l.jsx)("span",{className:"ml-1 text-muted-foreground",children:"last known"}):null]})]},e)})}),t.size>0?(0,l.jsx)("p",{className:"mt-1.5 text-xs leading-relaxed text-muted-foreground",children:[...t].map(([e,s])=>`${s.join(", ")} — ${e}`).join(" \xb7 ")}):null]})}function F({view:e,ageLabel:s,held:t,className:a}){var n;let r=e.cpu.perCore;return(0,l.jsxs)(x.Z,{title:"CPU",className:a,action:(0,l.jsx)(S,{stale:e.stale}),children:[(0,l.jsxs)("div",{className:"grid gap-6 lg:grid-cols-[minmax(0,13rem)_minmax(0,1fr)] lg:items-start",children:[(0,l.jsx)("div",{className:"flex flex-col items-center",children:(0,l.jsx)($.iL,{metricName:"CPU",field:"value"===(n=e.cpu.total).state?n.stale?{out:"stale",value:n.value}:{out:"value",value:n.value}:"unavailable"===n.state?{out:"unavailable",reason:n.reason}:{out:"absent"},ageLabel:s,isHeld:t,thresholdMs:e.thresholdMs})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,l.jsx)(I,{children:"Per logical core"}),"value"===r.state?(0,l.jsxs)("span",{className:"tnum text-xs text-muted-foreground",children:[(0,P.B4)(r.value.length)," cores"]}):null]}),"value"===r.state?(0,l.jsx)(l.Fragment,{children:(0,l.jsx)("ul",{className:"mt-2 grid grid-cols-[repeat(auto-fit,minmax(3.5rem,1fr))] gap-1.5",children:r.value.map((e,s)=>{let t=null!==e,a=t?Math.min(100,Math.max(0,e)):0;return(0,l.jsxs)("li",{className:"rounded-md border border-border bg-card-strong/40 px-1.5 py-1",title:t?`Core ${s}: ${(0,M.l9)(e)}`:`Core ${s}: counter regressed or was missing for this interval`,children:[(0,l.jsxs)("div",{className:"flex flex-col items-start gap-0.5",children:[(0,l.jsxs)("span",{className:"tnum text-xs text-muted-foreground",children:["C",s]}),(0,l.jsx)("span",{className:"tnum text-xs text-foreground",children:t?(0,M.l9)(e):"—"})]}),(0,l.jsx)("div",{"aria-hidden":!0,className:"mt-1 h-0.5 w-full overflow-hidden rounded-full bg-border",children:t?(0,l.jsx)("div",{className:"h-full rounded-full",style:{width:`${a}%`,backgroundColor:"var(--cpu)"}}):null}),(0,l.jsx)("span",{className:"sr-only",children:t?`Core ${s} at ${(0,M.l9)(e)}`:`Core ${s} unavailable this interval`})]},s)})})}):"unavailable"===r.state?(0,l.jsx)("div",{className:"mt-2",children:(0,l.jsx)(U,{reason:r.reason})}):(0,l.jsx)("div",{className:"mt-2",children:(0,l.jsx)(L,{children:r.reason})})]})]}),(0,l.jsxs)("div",{className:"mt-4 border-t border-border pt-3",children:[(0,l.jsx)(I,{children:"Heat, power and stalls"}),(0,l.jsx)(R,{className:"mt-1",readings:[{label:"Temperature",reading:e.bottlenecks.cpuTemperature,format:P.cH},{label:"Package power",reading:e.bottlenecks.cpuPower,format:P.d5},{label:"I/O wait",reading:e.bottlenecks.cpuIowait,format:M.l9},{label:"Pressure",reading:e.bottlenecks.cpuPressure,format:M.l9}]})]})]})}function Z({view:e,ageLabel:s,held:t,className:a}){var n;let r=e.swap;return(0,l.jsx)(x.Z,{title:"Memory and swap",className:a,action:(0,l.jsx)(S,{stale:e.stale}),children:(0,l.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(I,{children:"Memory"}),(0,l.jsx)("div",{className:"mt-2",children:(0,l.jsx)($.jB,{field:"value"===(n=e.memory).state?n.stale?{out:"stale",usedBytes:n.value.usedBytes,totalBytes:n.value.totalBytes}:{out:"value",usedBytes:n.value.usedBytes,totalBytes:n.value.totalBytes}:"unavailable"===n.state?{out:"unavailable",reason:n.reason}:{out:"absent"},ageLabel:s,isHeld:t,thresholdMs:e.thresholdMs})})]}),(0,l.jsxs)("div",{className:"border-t border-border pt-4",children:[(0,l.jsx)(I,{children:"Pressure"}),(0,l.jsx)(R,{className:"mt-1",readings:[{label:"Some tasks",reading:e.bottlenecks.memoryPressureSome,format:M.l9},{label:"Full",reading:e.bottlenecks.memoryPressureFull,format:M.l9}]})]}),(0,l.jsxs)("div",{className:"border-t border-border pt-4",children:[(0,l.jsx)(I,{children:"Swap"}),"value"===r.state?0===r.value.totalBytes?(0,l.jsxs)("div",{className:"mt-2 flex flex-col gap-1",children:[(0,l.jsx)("p",{className:"text-sm",children:"No swap configured."}),(0,l.jsx)(L,{children:"SwapTotal is zero; this is a valid configuration, not a missing reading."})]}):(0,l.jsxs)("div",{className:"mt-2 flex flex-col gap-2",children:[(0,l.jsx)(z,{label:"Used",valueLabel:`${(0,M.z3)(r.value.usedBytes)} / ${(0,M.z3)(r.value.totalBytes)}`,percent:T(r.value.usedBytes,r.value.totalBytes),tone:"swap",ariaLabel:`Swap ${(0,M.z3)(r.value.usedBytes)} of ${(0,M.z3)(r.value.totalBytes)}`}),(0,l.jsxs)("p",{className:"tnum text-xs text-muted-foreground",children:[(0,M.l9)(T(r.value.usedBytes,r.value.totalBytes))," used",r.stale?" \xb7 last known":""]})]}):"unavailable"===r.state?(0,l.jsx)("div",{className:"mt-2",children:(0,l.jsx)(U,{reason:r.reason})}):(0,l.jsx)("div",{className:"mt-2",children:(0,l.jsx)(L,{children:r.reason})})]})]})})}function H({card:e}){let s="supported"===e.telemetry;return(0,l.jsxs)("article",{className:"flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-card-strong/25 p-3",children:[(0,l.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsx)("h3",{className:"truncate text-sm font-medium",children:e.name}),(0,l.jsxs)("p",{className:"tnum truncate text-xs text-muted-foreground",children:[e.vendor,e.pciBusId?` \xb7 ${e.pciBusId}`:""]})]}),(0,l.jsxs)("div",{className:"flex shrink-0 flex-wrap items-center gap-1.5",children:[s?null:(0,l.jsx)($.vw,{text:"no telemetry",title:e.reason??"Management adapter"}),e.stale&&"ok"===e.state?(0,l.jsx)($.vw,{text:"last known",title:"Retained from the last accepted sample"}):null]})]}),"ok"===e.state?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(z,{label:"GPU utilization",valueLabel:null===e.utilizationPercent?"Not reported":(0,M.l9)(e.utilizationPercent),percent:e.utilizationPercent,tone:"gpu",ariaLabel:null===e.utilizationPercent?`${e.name} utilization not reported`:`${e.name} utilization ${(0,M.l9)(e.utilizationPercent)}`}),(0,l.jsx)(z,{label:"VRAM",valueLabel:null===e.memoryUsedBytes||null===e.memoryTotalBytes?"Not reported":`${(0,M.z3)(e.memoryUsedBytes)} / ${(0,M.z3)(e.memoryTotalBytes)}`,percent:null!==e.memoryUsedBytes&&null!==e.memoryTotalBytes?T(e.memoryUsedBytes,e.memoryTotalBytes):null,tone:"gpu",ariaLabel:null===e.memoryUsedBytes||null===e.memoryTotalBytes?`${e.name} VRAM not reported`:`${e.name} VRAM ${(0,M.z3)(e.memoryUsedBytes)} of ${(0,M.z3)(e.memoryTotalBytes)}`}),(0,l.jsxs)("dl",{className:"grid grid-cols-2 gap-x-4 gap-y-1",children:[(0,l.jsx)(C,{label:"Temperature",value:null===e.temperatureC?"Not reported":(0,P.cH)(e.temperatureC)}),(0,l.jsx)(C,{label:"Power",value:null===e.powerWatts?"Not reported":(0,P.d5)(e.powerWatts)})]})]}):(0,l.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,l.jsx)("p",{className:"text-xs text-muted-foreground",children:"unsupported"===e.state?"No telemetry.":"No readings for this device."}),e.reason?(0,l.jsx)("p",{className:"text-xs text-warn",children:e.reason}):null,null!==e.memoryTotalBytes?(0,l.jsx)("dl",{className:"mt-1",children:(0,l.jsx)(C,{label:"VRAM total",value:(0,M.z3)(e.memoryTotalBytes)})}):null]})]})}function V({view:e,className:s}){let t=e.gpus.cards;return(0,l.jsx)(x.Z,{title:"GPUs",className:s,action:(0,l.jsxs)("span",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"tnum",children:0===t.length?"0 devices":`${t.length} device${1===t.length?"":"s"}`}),(0,l.jsx)(S,{stale:e.stale})]}),children:0===t.length?"unavailable"===e.gpus.family.state?(0,l.jsx)(U,{reason:e.gpus.family.reason}):(0,l.jsx)(L,{children:A(e.gpus.family,"No GPU devices were reported.")}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:t.map(e=>(0,l.jsx)(H,{card:e},e.id))}),"unavailable"===e.gpus.family.state?(0,l.jsxs)("p",{className:"mt-3 text-xs text-warn",children:["GPU unavailable \xb7 ",e.gpus.family.reason]}):e.gpus.partial?(0,l.jsx)("p",{className:"mt-3 text-xs text-warn",children:"Some GPUs are not reporting."}):null]})})}function E({filesystem:e}){let s="ok"===e.state&&null!==e.usedBytes&&null!==e.totalBytes?T(e.usedBytes,e.totalBytes):null,t="ok"===e.state&&null!==e.usedBytes&&null!==e.totalBytes?`${(0,M.z3)(e.usedBytes)} / ${(0,M.z3)(e.totalBytes)}`:null!==e.totalBytes?`${(0,M.z3)(e.totalBytes)} total`:"Unavailable",a="ok"===e.state&&null!==e.inodesUsed&&null!==e.inodesTotal&&e.inodesTotal>0?T(e.inodesUsed,e.inodesTotal):null;return(0,l.jsxs)("li",{className:"py-2.5",children:[(0,l.jsxs)("div",{className:"flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1",children:[(0,l.jsx)("span",{className:"break-all font-mono text-xs text-foreground",children:e.mountPoint}),(0,l.jsxs)("span",{className:"tnum break-all text-xs text-muted-foreground",children:[e.fsType,e.device?` \xb7 ${e.device}`:""]})]}),(0,l.jsx)("div",{className:"mt-2",children:(0,l.jsx)(z,{label:"Capacity",valueLabel:t,percent:s,tone:"disk",ariaLabel:`${e.mountPoint} ${t}`})}),"ok"===e.state?(0,l.jsx)("p",{className:"tnum mt-1 text-xs text-muted-foreground",title:null===a?"Inode usage was not reported for this filesystem.":void 0,children:null===a?"Inodes not reported":`Inodes ${(0,M.l9)(a)} used \xb7 ${(0,P.B4)(e.inodesUsed)} / ${(0,P.B4)(e.inodesTotal)}`}):null,"unavailable"===e.state&&e.reason?(0,l.jsx)("p",{className:"mt-1.5 text-xs text-warn",children:e.reason}):"inventory"===e.state&&e.reason?(0,l.jsx)("p",{className:"mt-1.5 text-xs text-muted-foreground",children:e.reason}):e.stale?(0,l.jsx)("p",{className:"mt-1.5 text-xs text-muted-foreground",children:"Last known usage."}):null]})}function G({disk:e}){let s=null===e.rotational?"Unknown media":e.rotational?"Rotational":"Solid state",t=[null===e.readLatencyMs?"read latency":null,null===e.writeLatencyMs?"write latency":null,null===e.ioUtilizationPercent?"utilization":null].filter(e=>null!==e);return(0,l.jsxs)("li",{className:"py-2.5",children:[(0,l.jsxs)("div",{className:"flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1",children:[(0,l.jsx)("span",{className:"font-mono text-xs text-foreground",children:e.name}),(0,l.jsxs)("span",{className:"tnum text-xs text-muted-foreground",children:[s,null!==e.sizeBytes?` \xb7 ${(0,M.z3)(e.sizeBytes)}`:""]})]}),e.model?(0,l.jsx)("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:e.model}):null,"ok"===e.state?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("dl",{className:"mt-1.5 grid grid-cols-2 gap-x-4 gap-y-1 sm:grid-cols-4",children:[(0,l.jsx)(C,{label:"Read",value:(0,P.CE)(e.readBytesPerSec)}),(0,l.jsx)(C,{label:"Write",value:(0,P.CE)(e.writeBytesPerSec)}),(0,l.jsx)(C,{label:"Read latency",value:(0,P.YL)(e.readLatencyMs)}),(0,l.jsx)(C,{label:"Write latency",value:(0,P.YL)(e.writeLatencyMs)}),(0,l.jsx)(C,{label:"Utilization",value:null===e.ioUtilizationPercent?"—":(0,M.l9)(e.ioUtilizationPercent)})]}),t.length>0?(0,l.jsxs)("p",{className:"mt-1 text-xs text-muted-foreground",children:["Not reported: ",t.join(", "),"."]}):null]}):(0,l.jsx)("p",{className:`mt-1.5 text-xs ${"unavailable"===e.state?"text-warn":"text-muted-foreground"}`,children:e.reason??"No current I/O reading."}),"ok"===e.state&&e.stale?(0,l.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Last known rates."}):null]})}function _({view:e,className:s}){let t=e.filesystems.items,a=e.disks.items;return(0,l.jsxs)(x.Z,{title:"Disks",className:s,action:(0,l.jsx)(S,{stale:e.stale}),children:[0===t.length&&0===a.length?"unavailable"===e.disks.family.state?(0,l.jsx)(U,{reason:e.disks.family.reason}):(0,l.jsx)(L,{children:A(e.disks.family,"No disks or filesystems were reported.")}):null,(0,l.jsxs)("div",{className:"mt-5 flex flex-col gap-5",children:[t.length>0?(0,l.jsxs)("div",{children:[(0,l.jsx)(I,{children:"Filesystems"}),(0,l.jsx)("ul",{className:"mt-1 divide-y divide-border",children:t.map(e=>(0,l.jsx)(E,{filesystem:e},e.id))})]}):null,a.length>0?(0,l.jsxs)("div",{className:t.length>0?"border-t border-border pt-4":"",children:[(0,l.jsx)(I,{children:"Devices"}),(0,l.jsx)("ul",{className:"mt-1 divide-y divide-border",children:a.map(e=>(0,l.jsx)(G,{disk:e},e.id))})]}):null,"unavailable"!==e.disks.family.state?(0,l.jsxs)("div",{className:t.length>0||a.length>0?"border-t border-border pt-4":"",children:[(0,l.jsx)(I,{children:"I/O pressure"}),(0,l.jsx)(R,{className:"mt-1",readings:[{label:"Some tasks",reading:e.bottlenecks.ioPressureSome,format:M.l9},{label:"Full",reading:e.bottlenecks.ioPressureFull,format:M.l9}]})]}):null]})]})}function D({iface:e}){let s="up"===e.linkState?"Link up":"down"===e.linkState?"Link down":"Link state unknown";return(0,l.jsxs)("li",{className:"py-3",children:[(0,l.jsxs)("div",{className:"flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1",children:[(0,l.jsx)("span",{className:"font-mono text-xs text-foreground",children:e.name}),(0,l.jsxs)("span",{className:"flex flex-wrap items-center gap-1.5",children:[e.virtual?(0,l.jsx)($.vw,{text:"virtual",title:"Virtual interface, not physical hardware"}):null,(0,l.jsx)("span",{className:"tnum text-xs text-muted-foreground",children:s}),null!==e.speedMbps?(0,l.jsx)("span",{className:"tnum text-xs text-muted-foreground",children:(0,P.Zf)(e.speedMbps)}):null]})]}),e.addresses.length>0?(0,l.jsx)("ul",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-1",children:e.addresses.map((e,s)=>(0,l.jsxs)("li",{className:"tnum break-all font-mono text-xs text-muted-foreground",children:[e.address,"/",e.prefix,(0,l.jsx)("span",{className:"ml-1 font-sans text-xs uppercase tracking-wide",children:"ipv4"===e.family?"v4":"v6"})]},`${e.family}:${e.address}/${e.prefix}:${s}`))}):(0,l.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"No addresses reported."}),"ok"===e.state?(0,l.jsxs)("dl",{className:"mt-1.5 grid grid-cols-2 gap-x-4 gap-y-1",children:[(0,l.jsx)(C,{label:"Receive",value:(0,P.CE)(e.rxBytesPerSec)}),(0,l.jsx)(C,{label:"Transmit",value:(0,P.CE)(e.txBytesPerSec)})]}):(0,l.jsx)("p",{className:`mt-1.5 text-xs ${"unavailable"===e.state?"text-warn":"text-muted-foreground"}`,children:e.reason??"No current rate reading."}),"ok"===e.state&&e.stale?(0,l.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Last known rates."}):null]})}function O({view:e,className:s}){let t=e.network.items;return(0,l.jsx)(x.Z,{title:"Network",className:s,action:(0,l.jsx)(S,{stale:e.stale}),children:0===t.length?"unavailable"===e.network.family.state?(0,l.jsx)(U,{reason:e.network.family.reason}):(0,l.jsx)(L,{children:A(e.network.family,"No network interfaces were reported.")}):(0,l.jsx)("ul",{className:"divide-y divide-border",children:t.map(e=>(0,l.jsx)(D,{iface:e},e.id))})})}var W=t(9939),q=t(7348);function Y(e){let s,t,{iso:a}=e;return null===a?(0,l.jsx)("span",{className:"text-xs text-muted-foreground",children:"—"}):(0,l.jsxs)("span",{className:"tnum text-sm",children:[Number.isFinite((s=new Date(a)).getTime())?s.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}):a,(0,l.jsx)("span",{className:"ml-2 text-xs text-muted-foreground",children:Number.isFinite((t=new Date(a)).getTime())?t.toLocaleDateString(void 0,{dateStyle:"medium"}):""})]})}function J({state:e}){var s;let t=(0,M.L_)(e);return"ahead"!==t.kind&&"behind"!==t.kind?null:(0,l.jsxs)("p",{role:"status",className:"tnum flex items-start gap-2 rounded-lg bg-warn-soft px-3 py-2 text-xs text-foreground",children:[(0,l.jsx)(i,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-warn","aria-hidden":!0}),(0,l.jsxs)("span",{children:["Collector clock:"," ",(0,l.jsx)("strong",{className:"font-medium",children:Math.abs(s=t.skewMs)>=6e4?`${Math.abs(Math.round(s/6e4))} min`:`${Math.abs(Math.round(s/1e3))} s`})," ","ahead"===t.kind?"ahead of":"behind"," hub time."]})]})}function K({state:e}){return(0,l.jsx)(x.Z,{title:"Collector",children:(0,l.jsxs)("div",{className:"flex flex-col gap-3 py-1",children:[(0,l.jsxs)("p",{className:"flex items-center gap-2 text-sm",children:[(0,l.jsx)("span",{"aria-hidden":!0,className:`inline-block h-2 w-2 shrink-0 rounded-full ${e.connected?"bg-ok":"bg-crit"}`}),e.connected?"Connected to the hub":"Not connected to the hub"]}),(0,l.jsxs)("dl",{className:"flex flex-col gap-1 text-xs",children:[(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsx)("dt",{className:"shrink-0 text-muted-foreground",children:"Collector"}),(0,l.jsx)("dd",{className:"tnum truncate",children:e.collectorId})]}),(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsx)("dt",{className:"shrink-0 text-muted-foreground",children:"Machine"}),(0,l.jsx)("dd",{className:"tnum truncate",children:e.machineId})]})]}),(0,l.jsx)(n(),{href:"/connections",className:"w-fit rounded-md text-xs text-accent transition-colors hover:underline",children:"Connections"})]})})}function Q({state:e,now:s}){let t=e.metrics,a=t?.capturedAt??null,n=t?.receivedAt??e.lastReceivedAt,r=null!=e.expectedIntervalMs,i=r?e.expectedIntervalMs:null,d=(0,M.Cj)(e.expectedIntervalMs);return(0,l.jsx)(x.Z,{title:"Sample times",children:(0,l.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,l.jsxs)("dl",{className:"grid gap-x-8 gap-y-3 sm:grid-cols-2",children:[(0,l.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Captured"}),(0,l.jsx)("dd",{children:(0,l.jsx)(Y,{iso:a})}),(0,l.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Received"}),(0,l.jsx)("dd",{children:(0,l.jsxs)("span",{className:"flex flex-wrap items-baseline gap-2",children:[(0,l.jsx)(Y,{iso:n}),null!==n?(0,l.jsxs)("span",{className:"tnum text-xs text-muted-foreground",children:["\xb7 updated ",(0,M.nV)((0,M.A4)(n,s))]}):null]})}),(0,l.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Sample interval"}),(0,l.jsx)("dd",{children:r?(0,l.jsx)("span",{className:"tnum text-sm",children:(0,M.$)(i)}):(0,l.jsx)("span",{className:"text-sm text-muted-foreground",children:"Unknown"})}),(0,l.jsx)("dt",{className:"text-xs text-muted-foreground",children:"Stale after"}),(0,l.jsx)("dd",{children:(0,l.jsxs)("span",{className:"tnum text-sm",children:[(0,M.$)(d),r?null:(0,l.jsx)("span",{className:"text-muted-foreground",children:" (fallback)"})]})})]}),(0,l.jsx)(J,{state:e})]})})}function X({machineId:e,machineCount:s}){return 0===s?(0,l.jsx)(x.Z,{title:"No machines",className:"mt-8",children:(0,l.jsx)(x.p,{icon:d,note:"No machines are available in your authorized fleet."})}):(0,l.jsxs)(x.Z,{title:"Machine not found",className:"mt-8",children:[(0,l.jsx)(x.p,{icon:d,note:"This machine is unavailable or outside your access."}),(0,l.jsxs)("p",{className:"tnum mt-2 text-center text-xs text-muted-foreground",children:["Requested identifier: ",e]}),(0,l.jsx)("div",{className:"flex justify-center",children:(0,l.jsxs)(n(),{href:"/",className:"mt-2 inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:[(0,l.jsx)(o,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Back to fleet"]})})]})}function ee({machineId:e}){let{phase:s,machines:t}=(0,W.M)(),{machine:a}=(0,k.JG)("overview",e),n=(0,B.x)(),r=(0,q.c)(),i="live"===s||"reconnecting"===s||"disconnected"===s,d=i?a:void 0,o="reconnecting"===s||"disconnected"===s,x=d?(0,P.hL)(d,r):null,h=d?d.metrics?.receivedAt??d.lastReceivedAt:null,p=h?(0,M.nV)((0,M.A4)(h,r)):null;return(0,l.jsx)(c.G,{title:"Overview",machineId:e,machineView:"overview",headerRight:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(m.$E,{}),(0,l.jsx)(u.B,{})]}),children:n||(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(B.E,{}),d&&x?(0,l.jsxs)(l.Fragment,{children:[x.tags.length>0?(0,l.jsx)("ul",{className:"mb-4 flex flex-wrap gap-1.5","aria-label":"Machine tags",children:x.tags.map(e=>(0,l.jsx)("li",{className:"rounded-full border border-border px-2 py-0.5 text-xs text-muted-foreground",children:e},e))}):null,(0,l.jsxs)("section",{"aria-label":`${x.displayName} live overview`,className:"grid grid-cols-1 gap-5 xl:grid-cols-3",children:[(0,l.jsx)(F,{view:x,ageLabel:p,held:o,className:"xl:col-span-2"}),(0,l.jsx)(Z,{view:x,ageLabel:p,held:o}),(0,l.jsx)("div",{className:"min-w-0 xl:col-span-3",children:(0,l.jsx)(w,{machine:d},e)}),(0,l.jsx)(V,{view:x,className:"xl:col-span-3"}),(0,l.jsx)(_,{view:x,className:"xl:col-span-2"}),(0,l.jsx)(O,{view:x})]}),(0,l.jsxs)("details",{className:"mt-5 max-w-4xl text-xs text-muted-foreground",children:[(0,l.jsx)("summary",{className:"inline-flex min-h-9 cursor-pointer items-center rounded-md hover:text-foreground",children:"Collector details"}),(0,l.jsxs)("div",{className:"mt-3 grid gap-4 lg:grid-cols-2",children:[(0,l.jsx)(K,{state:d}),(0,l.jsx)(Q,{state:d,now:r})]})]})]}):i?(0,l.jsx)(X,{machineId:e,machineCount:t.length}):null]})})}}},e=>{e.O(0,[157,939,103,130,408,441,794,358],()=>e(e.s=4546)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{3381:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(8698).A)("CloudOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]])},3612:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(8698).A)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},7281:(e,s,t)=>{"use strict";t.d(s,{FleetView:()=>L});var a=t(5155),l=t(8500),n=t.n(l),r=t(3612),d=t(9926),o=t(3381),c=t(9664),i=t(2115),m=t(4173),u=t(3440),x=t(940),h=t(802),p=t(6576),j=t(6582),f=t(7586),b=t(9939),v=t(4334),N=t(7348),g=t(2241);let y={ok:"bg-ok-soft text-ok",degraded:"bg-warn-soft text-warn",stale:"bg-warn-soft text-warn",disconnected:"bg-crit-soft text-crit",unseen:"border border-border text-muted-foreground"};function w(e){return"value"===e.state?e.stale?{out:"stale",usedBytes:e.value.usedBytes,totalBytes:e.value.totalBytes}:{out:"value",usedBytes:e.value.usedBytes,totalBytes:e.value.totalBytes}:"unavailable"===e.state?{out:"unavailable",reason:e.reason}:{out:"absent"}}function k({level:e}){return(0,a.jsxs)("span",{className:`tnum inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs ${y[e]}`,children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"inline-block h-1.5 w-1.5 rounded-full bg-current opacity-70"}),(0,f.fv)(e)]})}function A(e){return`No update for over ${(0,f.$)(e)} (judged by hub receipt time)`}function C({field:e,isHeld:s,thresholdMs:t}){return"value"===e.out?(0,a.jsxs)("span",{className:"tnum text-sm",children:[(0,f.l9)(e.value),s?(0,a.jsx)(U,{}):null]}):"stale"===e.out?(0,a.jsxs)("span",{className:"tnum text-sm",children:[(0,f.l9)(e.value),(0,a.jsx)("span",{className:"ml-1.5",children:(0,a.jsx)(p.vw,{text:"stale",title:A(t)})})]}):"unavailable"===e.out?(0,a.jsx)("span",{className:"text-xs text-warn",title:e.reason,children:"Unavailable"}):(0,a.jsx)("span",{className:"tnum text-sm text-muted-foreground",children:"—"})}function U(){return(0,a.jsx)("span",{className:"ml-1.5",children:(0,a.jsx)(p.vw,{text:"held",title:"Last known value, kept while the connection is down"})})}function M(e){return"value"===e.out||"stale"===e.out?`${(0,f.z3)(e.usedBytes)} / ${(0,f.z3)(e.totalBytes)}`:"unavailable"===e.out?"Unavailable":"—"}function P({summary:e}){if(null===e)return(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:"No GPU data"});if(0===e.supportedCount)return(0,a.jsxs)("span",{className:"text-xs text-muted-foreground",title:e.reason??"No supported telemetry",children:[e.count," adapter",1===e.count?"":"s"," \xb7 no telemetry"]});if(e.reason)return(0,a.jsxs)("span",{className:"text-xs text-warn",title:e.reason,children:[e.supportedCount," GPU",1===e.supportedCount?"":"s"," \xb7 unavailable"]});let s=null===e.maxUtilizationPercent?"util —":`util ${(0,f.l9)(e.maxUtilizationPercent)}`,t=null!==e.memoryUsedBytes&&null!==e.memoryTotalBytes?`${(0,f.z3)(e.memoryUsedBytes)} / ${(0,f.z3)(e.memoryTotalBytes)}`:"VRAM —";return(0,a.jsx)("span",{className:"tnum text-xs",children:e.partial?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("span",{className:"text-warn",children:[e.okCount,"/",e.supportedCount," GPUs reporting"]}),(0,a.jsxs)("span",{className:"text-muted-foreground",children:[" \xb7 ",s," \xb7 ",t," "]}),(0,a.jsx)(p.vw,{text:"partial",title:"At least one supported GPU has no current reading"}),e.stale?(0,a.jsx)("span",{className:"ml-1.5",children:(0,a.jsx)(p.vw,{text:"last known",title:"Retained from the last accepted sample"})}):null]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-foreground",children:e.supportedCount}),(0,a.jsxs)("span",{className:"text-muted-foreground",children:[" ","GPU",1===e.supportedCount?"":"s"," \xb7 ",s," \xb7 ",t]}),e.stale?(0,a.jsx)("span",{className:"ml-1.5",children:(0,a.jsx)(p.vw,{text:"last known",title:"Retained from the last accepted sample"})}):null]})})}function B({state:e}){let s=(0,g.V5)(e);return 0===s.length?null:(0,a.jsx)("ul",{className:"mt-1 flex flex-wrap gap-1",children:s.map(e=>(0,a.jsx)("li",{className:"rounded-full border border-border px-1.5 py-0.5 text-xs text-muted-foreground",children:e},e))})}function $({state:e}){let s=(0,g.v4)(e),t=[e.hostname!==s?e.hostname:null].filter(e=>!!(e&&e!==s)).join(" \xb7 ");return(0,a.jsxs)("div",{className:"flex min-w-0 flex-col",children:[(0,a.jsx)("span",{className:"truncate text-sm font-medium",children:s}),t?(0,a.jsx)("span",{className:"tnum truncate text-xs text-muted-foreground",children:t}):null,(0,a.jsx)(B,{state:e})]})}function F({points:e}){let s=(e.at(-1)?.receivedAtLocal??0)-6e5,t=e.filter(e=>e.receivedAtLocal>=s),l=(0,v.K)(t,160,40),n=(0,v.K)(t.map(e=>({...e,cpuPercent:e.memoryPercent})),160,40);return(0,a.jsxs)("div",{className:"w-40 max-w-full",title:"CPU and memory since sign-in",children:[(0,a.jsxs)("svg",{viewBox:"0 0 160 40",className:"h-10 w-full",role:"img","aria-label":"Recent CPU and memory usage since sign-in",children:[(0,a.jsx)("line",{x1:"4",x2:"156",y1:"36",y2:"36",stroke:"var(--border)"}),l?(0,a.jsx)("path",{d:l,fill:"none",stroke:"var(--cpu)",strokeWidth:"1.5"}):null,n?(0,a.jsx)("path",{d:n,fill:"none",stroke:"var(--mem)",strokeWidth:"1.5"}):null]}),(0,a.jsxs)("div",{className:"flex gap-3 text-xs text-muted-foreground",children:[(0,a.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,a.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-cpu"}),"CPU"]}),(0,a.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,a.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-mem"}),"RAM"]})]})]})}function R({state:e,now:s,held:t,points:l}){var r;let d=(0,g.hL)(e,s),o=(0,g.fp)(e,s),c=(0,f.F2)(e,s),i="stale"===d.freshness,m=A(d.thresholdMs),u=w(o.memory),x="unavailable"===d.cpu.total.state||"unavailable"===d.memory.state||"unavailable"===d.gpus.family.state||d.gpus.partial||"unavailable"===d.disks.family.state||"unavailable"===d.network.family.state,h="ok"===c.attention&&x?"degraded":c.attention;return(0,a.jsxs)("tr",{className:"transition-colors hover:bg-card-strong/60",children:[(0,a.jsx)("td",{className:"border-b border-border py-2.5 pr-4",children:(0,a.jsx)(n(),{href:`/machines/${encodeURIComponent(e.machineId)}`,className:"inline-flex min-w-0 flex-col rounded-sm transition-colors hover:underline",children:(0,a.jsx)($,{state:e})})}),(0,a.jsx)("td",{className:"border-b border-border py-2.5 pr-4",children:(0,a.jsxs)("span",{className:"tnum inline-flex items-center gap-1.5 text-xs",children:[(0,a.jsx)("span",{"aria-hidden":!0,className:`inline-block h-1.5 w-1.5 shrink-0 rounded-full ${e.connected?"bg-ok":"bg-crit"}`}),e.connected?"Connected":"Disconnected"]})}),(0,a.jsx)("td",{className:"border-b border-border py-2.5 pr-4",children:(0,a.jsx)(C,{field:"value"===(r=o.cpu).state?r.stale?{out:"stale",value:r.value}:{out:"value",value:r.value}:"unavailable"===r.state?{out:"unavailable",reason:r.reason}:{out:"absent"},isHeld:t,thresholdMs:d.thresholdMs})}),(0,a.jsx)("td",{className:"border-b border-border py-2.5 pr-4",children:(0,a.jsxs)("span",{className:"tnum text-sm",children:[M(u),"stale"===u.out?(0,a.jsx)("span",{className:"ml-1.5",children:(0,a.jsx)(p.vw,{text:"stale",title:m})}):"value"===u.out&&t?(0,a.jsx)(U,{}):null]})}),(0,a.jsx)("td",{className:"border-b border-border py-2.5 pr-4",children:(0,a.jsx)(P,{summary:o.gpu})}),(0,a.jsx)("td",{className:"border-b border-border py-2.5 pr-4",children:(0,a.jsxs)("span",{className:"tnum text-sm",children:[(0,f.nV)((0,f.A4)(e.lastReceivedAt,s)),i?(0,a.jsx)("span",{className:"ml-1.5",children:(0,a.jsx)(p.vw,{text:"stale",title:m})}):t?(0,a.jsx)(U,{}):null]})}),(0,a.jsx)("td",{className:"border-b border-border py-2.5 pr-4",children:(0,a.jsx)(F,{points:l})}),(0,a.jsx)("td",{className:"border-b border-border py-2.5",children:(0,a.jsx)(k,{level:h})})]})}function G({state:e,now:s,held:t,points:l}){let r=(0,g.hL)(e,s),d=(0,g.fp)(e,s),o=(0,f.F2)(e,s),c="stale"===r.freshness,i=A(r.thresholdMs),m=w(d.memory),u="unavailable"===r.cpu.total.state||"unavailable"===r.memory.state||"unavailable"===r.gpus.family.state||r.gpus.partial||"unavailable"===r.disks.family.state||"unavailable"===r.network.family.state,x="ok"===o.attention&&u?"degraded":o.attention;return(0,a.jsx)("li",{children:(0,a.jsxs)(n(),{href:`/machines/${encodeURIComponent(e.machineId)}`,className:"block rounded-xl border border-border bg-card p-4 transition-colors hover:border-muted-foreground/40",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,a.jsx)($,{state:e}),(0,a.jsx)(k,{level:x})]}),(0,a.jsxs)("dl",{className:"mt-3 grid grid-cols-2 gap-x-4 gap-y-2 text-xs",children:[(0,a.jsx)("dt",{className:"text-muted-foreground",children:"Collector"}),(0,a.jsx)("dd",{className:"tnum",children:e.connected?"Connected":"Disconnected"}),(0,a.jsx)("dt",{className:"text-muted-foreground",children:"CPU"}),(0,a.jsx)("dd",{className:"tnum",children:"value"===d.cpu.state?`${(0,f.l9)(d.cpu.value)}${d.cpu.stale?" \xb7 last known":""}`:"unavailable"===d.cpu.state?"Unavailable":"—"}),(0,a.jsx)("dt",{className:"text-muted-foreground",children:"Memory"}),(0,a.jsxs)("dd",{className:"tnum",children:[M(m),"stale"===m.out?(0,a.jsx)("span",{className:"ml-1.5",children:(0,a.jsx)(p.vw,{text:"stale",title:i})}):null]}),(0,a.jsx)("dt",{className:"text-muted-foreground",children:"GPU"}),(0,a.jsx)("dd",{children:(0,a.jsx)(P,{summary:d.gpu})}),(0,a.jsx)("dt",{className:"text-muted-foreground",children:"Last received"}),(0,a.jsxs)("dd",{className:"tnum",children:[(0,f.nV)((0,f.A4)(e.lastReceivedAt,s)),c?(0,a.jsx)("span",{className:"ml-1.5",children:(0,a.jsx)(p.vw,{text:"stale",title:i})}):null]})]}),(0,a.jsx)("div",{className:"mt-3",children:(0,a.jsx)(F,{points:l})})]})})}function L(){let{phase:e,machines:s,history:t,session:l}=(0,b.M)(),p=(0,j.x)(),f=(0,N.c)(),[v,y]=(0,i.useState)(""),w=s.length,k="reconnecting"===e||"disconnected"===e,A=(0,g.rn)(s,v),C=w>0&&("live"===e||k);return(0,a.jsx)(m.G,{title:"Fleet",headerRight:(0,a.jsxs)(a.Fragment,{children:["signed-in"===l.kind&&l.user.admin?(0,a.jsxs)(n(),{href:"/administration#collectors",className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs hover:bg-card-strong",children:[(0,a.jsx)(r.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Add machine"}),(0,a.jsx)("span",{className:"sr-only sm:hidden",children:"Add machine"})]}):null,(0,a.jsx)(x.$E,{}),(0,a.jsx)(h.B,{})]}),children:p||(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(j.E,{}),"connecting"===e&&0===w?(0,a.jsx)(u.Z,{title:"Waiting for the first snapshot",className:"mt-10",children:(0,a.jsx)(u.p,{icon:d.A,note:"Waiting for the first snapshot…"})}):null,("live"===e||k)&&0===w?(0,a.jsx)(u.Z,{title:"No machines",className:"mt-10",children:(0,a.jsx)(u.p,{icon:o.A,note:"No machines are available in your authorized fleet."})}):null,C?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-wrap items-end justify-between gap-3",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("label",{htmlFor:"fleet-search",className:"sr-only",children:"Search machines by name or tag"}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(c.A,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground","aria-hidden":!0}),(0,a.jsx)("input",{id:"fleet-search",type:"search",value:v,onChange:e=>y(e.target.value),placeholder:"Search name or tag",className:"w-64 max-w-full rounded-md border border-border bg-card py-1.5 pl-8 pr-3 text-sm text-foreground placeholder:text-muted-foreground"})]})]}),(0,a.jsxs)("p",{className:"tnum text-xs text-muted-foreground",role:"status",children:[A.length," of ",w," machine",1===w?"":"s",v.trim()?` matching “${v.trim()}”`:""]})]}),0===A.length?(0,a.jsx)(u.Z,{title:"No matching machines",children:(0,a.jsx)(u.p,{icon:c.A,note:`No machines match “${v.trim()}”.`})}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"hidden md:block",children:(0,a.jsx)(u.Z,{title:"Machines",action:(0,a.jsxs)("span",{children:[w," machine",1===w?"":"s"]}),children:(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"w-full border-separate border-spacing-0 text-left",children:[(0,a.jsx)("caption",{className:"sr-only",children:"Fleet machines with collector connection, CPU, memory, GPU summary, and sample freshness"}),(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"text-xs text-muted-foreground",children:[(0,a.jsx)("th",{scope:"col",className:"pb-2 pr-4 font-normal",children:"Machine"}),(0,a.jsx)("th",{scope:"col",className:"pb-2 pr-4 font-normal",children:"Collector"}),(0,a.jsx)("th",{scope:"col",className:"pb-2 pr-4 font-normal",children:"CPU"}),(0,a.jsx)("th",{scope:"col",className:"pb-2 pr-4 font-normal",children:"Memory"}),(0,a.jsx)("th",{scope:"col",className:"pb-2 pr-4 font-normal",children:"GPU"}),(0,a.jsx)("th",{scope:"col",className:"pb-2 pr-4 font-normal",children:"Last received"}),(0,a.jsx)("th",{scope:"col",className:"pb-2 pr-4 font-normal",children:"Recent load"}),(0,a.jsx)("th",{scope:"col",className:"pb-2 font-normal",children:"State"})]})}),(0,a.jsx)("tbody",{children:A.map(e=>(0,a.jsx)(R,{state:e,now:f,held:k,points:t.get(e.machineId)??[]},e.machineId))})]})})})}),(0,a.jsx)("div",{className:"md:hidden",children:(0,a.jsx)(u.Z,{title:"Machines",action:(0,a.jsxs)("span",{className:"tnum",children:[A.length," machine",1===A.length?"":"s"]}),children:(0,a.jsx)("ul",{className:"flex flex-col gap-3",children:A.map(e=>(0,a.jsx)(G,{state:e,now:f,held:k,points:t.get(e.machineId)??[]},e.machineId))})})})]})]}):null]})})}},9664:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(8698).A)("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]])},9858:(e,s,t)=>{Promise.resolve().then(t.bind(t,7281))},9926:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(8698).A)("Hourglass",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]])}},e=>{e.O(0,[157,939,103,227,441,794,358],()=>e(e.s=9858)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{3381:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(8698).A)("CloudOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]])},3612:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(8698).A)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},7281:(e,s,t)=>{"use strict";t.d(s,{FleetView:()=>L});var a=t(5155),l=t(8500),n=t.n(l),r=t(3612),d=t(9926),o=t(3381),c=t(9664),i=t(2115),m=t(4173),u=t(3440),x=t(940),h=t(802),p=t(6576),j=t(6582),f=t(7586),b=t(9939),v=t(4334),N=t(7348),g=t(2241);let y={ok:"bg-ok-soft text-ok",degraded:"bg-warn-soft text-warn",stale:"bg-warn-soft text-warn",disconnected:"bg-crit-soft text-crit",unseen:"border border-border text-muted-foreground"};function w(e){return"value"===e.state?e.stale?{out:"stale",usedBytes:e.value.usedBytes,totalBytes:e.value.totalBytes}:{out:"value",usedBytes:e.value.usedBytes,totalBytes:e.value.totalBytes}:"unavailable"===e.state?{out:"unavailable",reason:e.reason}:{out:"absent"}}function k({level:e}){return(0,a.jsxs)("span",{className:`tnum inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs ${y[e]}`,children:[(0,a.jsx)("span",{"aria-hidden":!0,className:"inline-block h-1.5 w-1.5 rounded-full bg-current opacity-70"}),(0,f.fv)(e)]})}function A(e){return`No update for over ${(0,f.$)(e)} (judged by hub receipt time)`}function C({field:e,isHeld:s,thresholdMs:t}){return"value"===e.out?(0,a.jsxs)("span",{className:"tnum text-sm",children:[(0,f.l9)(e.value),s?(0,a.jsx)(U,{}):null]}):"stale"===e.out?(0,a.jsxs)("span",{className:"tnum text-sm",children:[(0,f.l9)(e.value),(0,a.jsx)("span",{className:"ml-1.5",children:(0,a.jsx)(p.vw,{text:"stale",title:A(t)})})]}):"unavailable"===e.out?(0,a.jsx)("span",{className:"text-xs text-warn",title:e.reason,children:"Unavailable"}):(0,a.jsx)("span",{className:"tnum text-sm text-muted-foreground",children:"—"})}function U(){return(0,a.jsx)("span",{className:"ml-1.5",children:(0,a.jsx)(p.vw,{text:"held",title:"Last known value, kept while the connection is down"})})}function M(e){return"value"===e.out||"stale"===e.out?`${(0,f.z3)(e.usedBytes)} / ${(0,f.z3)(e.totalBytes)}`:"unavailable"===e.out?"Unavailable":"—"}function P({summary:e}){if(null===e)return(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:"No GPU data"});if(0===e.supportedCount)return(0,a.jsxs)("span",{className:"text-xs text-muted-foreground",title:e.reason??"No supported telemetry",children:[e.count," adapter",1===e.count?"":"s"," \xb7 no telemetry"]});if(e.reason)return(0,a.jsxs)("span",{className:"text-xs text-warn",title:e.reason,children:[e.supportedCount," GPU",1===e.supportedCount?"":"s"," \xb7 unavailable"]});let s=null===e.maxUtilizationPercent?"util —":`util ${(0,f.l9)(e.maxUtilizationPercent)}`,t=null!==e.memoryUsedBytes&&null!==e.memoryTotalBytes?`${(0,f.z3)(e.memoryUsedBytes)} / ${(0,f.z3)(e.memoryTotalBytes)}`:"VRAM —";return(0,a.jsx)("span",{className:"tnum text-xs",children:e.partial?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("span",{className:"text-warn",children:[e.okCount,"/",e.supportedCount," GPUs reporting"]}),(0,a.jsxs)("span",{className:"text-muted-foreground",children:[" \xb7 ",s," \xb7 ",t," "]}),(0,a.jsx)(p.vw,{text:"partial",title:"At least one supported GPU has no current reading"}),e.stale?(0,a.jsx)("span",{className:"ml-1.5",children:(0,a.jsx)(p.vw,{text:"last known",title:"Retained from the last accepted sample"})}):null]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-foreground",children:e.supportedCount}),(0,a.jsxs)("span",{className:"text-muted-foreground",children:[" ","GPU",1===e.supportedCount?"":"s"," \xb7 ",s," \xb7 ",t]}),e.stale?(0,a.jsx)("span",{className:"ml-1.5",children:(0,a.jsx)(p.vw,{text:"last known",title:"Retained from the last accepted sample"})}):null]})})}function B({state:e}){let s=(0,g.V5)(e);return 0===s.length?null:(0,a.jsx)("ul",{className:"mt-1 flex flex-wrap gap-1",children:s.map(e=>(0,a.jsx)("li",{className:"rounded-full border border-border px-1.5 py-0.5 text-xs text-muted-foreground",children:e},e))})}function $({state:e}){let s=(0,g.v4)(e),t=[e.hostname!==s?e.hostname:null].filter(e=>!!(e&&e!==s)).join(" \xb7 ");return(0,a.jsxs)("div",{className:"flex min-w-0 flex-col",children:[(0,a.jsx)("span",{className:"truncate text-sm font-medium",children:s}),t?(0,a.jsx)("span",{className:"tnum truncate text-xs text-muted-foreground",children:t}):null,(0,a.jsx)(B,{state:e})]})}function F({points:e}){let s=(e.at(-1)?.receivedAtLocal??0)-6e5,t=e.filter(e=>e.receivedAtLocal>=s),l=(0,v.K)(t,160,40),n=(0,v.K)(t.map(e=>({...e,cpuPercent:e.memoryPercent})),160,40);return(0,a.jsxs)("div",{className:"w-40 max-w-full",title:"CPU and memory since sign-in",children:[(0,a.jsxs)("svg",{viewBox:"0 0 160 40",className:"h-10 w-full",role:"img","aria-label":"Recent CPU and memory usage since sign-in",children:[(0,a.jsx)("line",{x1:"4",x2:"156",y1:"36",y2:"36",stroke:"var(--border)"}),l?(0,a.jsx)("path",{d:l,fill:"none",stroke:"var(--cpu)",strokeWidth:"1.5"}):null,n?(0,a.jsx)("path",{d:n,fill:"none",stroke:"var(--mem)",strokeWidth:"1.5"}):null]}),(0,a.jsxs)("div",{className:"flex gap-3 text-xs text-muted-foreground",children:[(0,a.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,a.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-cpu"}),"CPU"]}),(0,a.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,a.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-mem"}),"RAM"]})]})]})}function R({state:e,now:s,held:t,points:l}){var r;let d=(0,g.hL)(e,s),o=(0,g.fp)(e,s),c=(0,f.F2)(e,s),i="stale"===d.freshness,m=A(d.thresholdMs),u=w(o.memory),x="unavailable"===d.cpu.total.state||"unavailable"===d.memory.state||"unavailable"===d.gpus.family.state||d.gpus.partial||"unavailable"===d.disks.family.state||"unavailable"===d.network.family.state,h="ok"===c.attention&&x?"degraded":c.attention;return(0,a.jsxs)("tr",{className:"transition-colors hover:bg-card-strong/60",children:[(0,a.jsx)("td",{className:"border-b border-border py-2.5 pr-4",children:(0,a.jsx)(n(),{href:`/machines/${encodeURIComponent(e.machineId)}`,className:"inline-flex min-w-0 flex-col rounded-sm transition-colors hover:underline",children:(0,a.jsx)($,{state:e})})}),(0,a.jsx)("td",{className:"border-b border-border py-2.5 pr-4",children:(0,a.jsxs)("span",{className:"tnum inline-flex items-center gap-1.5 text-xs",children:[(0,a.jsx)("span",{"aria-hidden":!0,className:`inline-block h-1.5 w-1.5 shrink-0 rounded-full ${e.connected?"bg-ok":"bg-crit"}`}),e.connected?"Connected":"Disconnected"]})}),(0,a.jsx)("td",{className:"border-b border-border py-2.5 pr-4",children:(0,a.jsx)(C,{field:"value"===(r=o.cpu).state?r.stale?{out:"stale",value:r.value}:{out:"value",value:r.value}:"unavailable"===r.state?{out:"unavailable",reason:r.reason}:{out:"absent"},isHeld:t,thresholdMs:d.thresholdMs})}),(0,a.jsx)("td",{className:"border-b border-border py-2.5 pr-4",children:(0,a.jsxs)("span",{className:"tnum text-sm",children:[M(u),"stale"===u.out?(0,a.jsx)("span",{className:"ml-1.5",children:(0,a.jsx)(p.vw,{text:"stale",title:m})}):"value"===u.out&&t?(0,a.jsx)(U,{}):null]})}),(0,a.jsx)("td",{className:"border-b border-border py-2.5 pr-4",children:(0,a.jsx)(P,{summary:o.gpu})}),(0,a.jsx)("td",{className:"border-b border-border py-2.5 pr-4",children:(0,a.jsxs)("span",{className:"tnum text-sm",children:[(0,f.nV)((0,f.A4)(e.lastReceivedAt,s)),i?(0,a.jsx)("span",{className:"ml-1.5",children:(0,a.jsx)(p.vw,{text:"stale",title:m})}):t?(0,a.jsx)(U,{}):null]})}),(0,a.jsx)("td",{className:"border-b border-border py-2.5 pr-4",children:(0,a.jsx)(F,{points:l})}),(0,a.jsx)("td",{className:"border-b border-border py-2.5",children:(0,a.jsx)(k,{level:h})})]})}function G({state:e,now:s,held:t,points:l}){let r=(0,g.hL)(e,s),d=(0,g.fp)(e,s),o=(0,f.F2)(e,s),c="stale"===r.freshness,i=A(r.thresholdMs),m=w(d.memory),u="unavailable"===r.cpu.total.state||"unavailable"===r.memory.state||"unavailable"===r.gpus.family.state||r.gpus.partial||"unavailable"===r.disks.family.state||"unavailable"===r.network.family.state,x="ok"===o.attention&&u?"degraded":o.attention;return(0,a.jsx)("li",{children:(0,a.jsxs)(n(),{href:`/machines/${encodeURIComponent(e.machineId)}`,className:"block rounded-xl border border-border bg-card p-4 transition-colors hover:border-muted-foreground/40",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,a.jsx)($,{state:e}),(0,a.jsx)(k,{level:x})]}),(0,a.jsxs)("dl",{className:"mt-3 grid grid-cols-2 gap-x-4 gap-y-2 text-xs",children:[(0,a.jsx)("dt",{className:"text-muted-foreground",children:"Collector"}),(0,a.jsx)("dd",{className:"tnum",children:e.connected?"Connected":"Disconnected"}),(0,a.jsx)("dt",{className:"text-muted-foreground",children:"CPU"}),(0,a.jsx)("dd",{className:"tnum",children:"value"===d.cpu.state?`${(0,f.l9)(d.cpu.value)}${d.cpu.stale?" \xb7 last known":""}`:"unavailable"===d.cpu.state?"Unavailable":"—"}),(0,a.jsx)("dt",{className:"text-muted-foreground",children:"Memory"}),(0,a.jsxs)("dd",{className:"tnum",children:[M(m),"stale"===m.out?(0,a.jsx)("span",{className:"ml-1.5",children:(0,a.jsx)(p.vw,{text:"stale",title:i})}):null]}),(0,a.jsx)("dt",{className:"text-muted-foreground",children:"GPU"}),(0,a.jsx)("dd",{children:(0,a.jsx)(P,{summary:d.gpu})}),(0,a.jsx)("dt",{className:"text-muted-foreground",children:"Last received"}),(0,a.jsxs)("dd",{className:"tnum",children:[(0,f.nV)((0,f.A4)(e.lastReceivedAt,s)),c?(0,a.jsx)("span",{className:"ml-1.5",children:(0,a.jsx)(p.vw,{text:"stale",title:i})}):null]})]}),(0,a.jsx)("div",{className:"mt-3",children:(0,a.jsx)(F,{points:l})})]})})}function L(){let{phase:e,machines:s,history:t,session:l}=(0,b.M)(),p=(0,j.x)(),f=(0,N.c)(),[v,y]=(0,i.useState)(""),w=s.length,k="reconnecting"===e||"disconnected"===e,A=(0,g.rn)(s,v),C=w>0&&("live"===e||k);return(0,a.jsx)(m.G,{title:"Fleet",headerRight:(0,a.jsxs)(a.Fragment,{children:["signed-in"===l.kind&&l.user.admin?(0,a.jsxs)(n(),{href:"/administration#collectors",className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs hover:bg-card-strong",children:[(0,a.jsx)(r.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Add machine"}),(0,a.jsx)("span",{className:"sr-only sm:hidden",children:"Add machine"})]}):null,(0,a.jsx)(x.$E,{}),(0,a.jsx)(h.B,{})]}),children:p||(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(j.E,{}),"connecting"===e&&0===w?(0,a.jsx)(u.Z,{title:"Waiting for the first snapshot",className:"mt-10",children:(0,a.jsx)(u.p,{icon:d.A,note:"Waiting for the first snapshot…"})}):null,("live"===e||k)&&0===w?(0,a.jsx)(u.Z,{title:"No machines",className:"mt-10",children:(0,a.jsx)(u.p,{icon:o.A,note:"No machines are available in your authorized fleet."})}):null,C?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"mb-4 flex flex-wrap items-end justify-between gap-3",children:[(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("label",{htmlFor:"fleet-search",className:"sr-only",children:"Search machines by name or tag"}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(c.A,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground","aria-hidden":!0}),(0,a.jsx)("input",{id:"fleet-search",type:"search",value:v,onChange:e=>y(e.target.value),placeholder:"Search name or tag",className:"w-64 max-w-full rounded-md border border-border bg-card py-1.5 pl-8 pr-3 text-sm text-foreground placeholder:text-muted-foreground"})]})]}),(0,a.jsxs)("p",{className:"tnum text-xs text-muted-foreground",role:"status",children:[A.length," of ",w," machine",1===w?"":"s",v.trim()?` matching “${v.trim()}”`:""]})]}),0===A.length?(0,a.jsx)(u.Z,{title:"No matching machines",children:(0,a.jsx)(u.p,{icon:c.A,note:`No machines match “${v.trim()}”.`})}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"hidden md:block",children:(0,a.jsx)(u.Z,{title:"Machines",action:(0,a.jsxs)("span",{children:[w," machine",1===w?"":"s"]}),children:(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"w-full border-separate border-spacing-0 text-left",children:[(0,a.jsx)("caption",{className:"sr-only",children:"Fleet machines with collector connection, CPU, memory, GPU summary, and sample freshness"}),(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"text-xs text-muted-foreground",children:[(0,a.jsx)("th",{scope:"col",className:"pb-2 pr-4 font-normal",children:"Machine"}),(0,a.jsx)("th",{scope:"col",className:"pb-2 pr-4 font-normal",children:"Collector"}),(0,a.jsx)("th",{scope:"col",className:"pb-2 pr-4 font-normal",children:"CPU"}),(0,a.jsx)("th",{scope:"col",className:"pb-2 pr-4 font-normal",children:"Memory"}),(0,a.jsx)("th",{scope:"col",className:"pb-2 pr-4 font-normal",children:"GPU"}),(0,a.jsx)("th",{scope:"col",className:"pb-2 pr-4 font-normal",children:"Last received"}),(0,a.jsx)("th",{scope:"col",className:"pb-2 pr-4 font-normal",children:"Recent load"}),(0,a.jsx)("th",{scope:"col",className:"pb-2 font-normal",children:"State"})]})}),(0,a.jsx)("tbody",{children:A.map(e=>(0,a.jsx)(R,{state:e,now:f,held:k,points:t.get(e.machineId)??[]},e.machineId))})]})})})}),(0,a.jsx)("div",{className:"md:hidden",children:(0,a.jsx)(u.Z,{title:"Machines",action:(0,a.jsxs)("span",{className:"tnum",children:[A.length," machine",1===A.length?"":"s"]}),children:(0,a.jsx)("ul",{className:"flex flex-col gap-3",children:A.map(e=>(0,a.jsx)(G,{state:e,now:f,held:k,points:t.get(e.machineId)??[]},e.machineId))})})})]})]}):null]})})}},9664:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(8698).A)("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]])},9858:(e,s,t)=>{Promise.resolve().then(t.bind(t,7281))},9926:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(8698).A)("Hourglass",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]])}},e=>{e.O(0,[157,939,103,130,441,794,358],()=>e(e.s=9858)),_N_E=e.O()}]);