rigscope 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +2 -2
- package/.next/build-manifest.json +2 -2
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +2 -2
- package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/administration/page_client-reference-manifest.js +1 -1
- package/.next/server/app/administration.html +1 -1
- package/.next/server/app/administration.rsc +2 -2
- package/.next/server/app/administration.segments/_full.segment.rsc +2 -2
- package/.next/server/app/administration.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/administration.segments/administration/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/alerts/page_client-reference-manifest.js +1 -1
- package/.next/server/app/alerts.html +1 -1
- package/.next/server/app/alerts.rsc +2 -2
- package/.next/server/app/alerts.segments/_full.segment.rsc +2 -2
- package/.next/server/app/alerts.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/alerts.segments/alerts/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/connections/page_client-reference-manifest.js +1 -1
- package/.next/server/app/connections.html +1 -1
- package/.next/server/app/connections.rsc +2 -2
- package/.next/server/app/connections.segments/_full.segment.rsc +2 -2
- package/.next/server/app/connections.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/connections.segments/connections/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/history/page.js +1 -1
- package/.next/server/app/history/page_client-reference-manifest.js +1 -1
- package/.next/server/app/history.html +1 -1
- package/.next/server/app/history.rsc +4 -4
- package/.next/server/app/history.segments/_full.segment.rsc +4 -4
- package/.next/server/app/history.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/history.segments/history/__PAGE__.segment.rsc +4 -4
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +2 -2
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/index.segments/_full.segment.rsc +2 -2
- package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/.next/server/app/login.html +1 -1
- package/.next/server/app/login.rsc +2 -2
- package/.next/server/app/login.segments/_full.segment.rsc +2 -2
- package/.next/server/app/login.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/machines/[machineId]/page.js +1 -1
- package/.next/server/app/machines/[machineId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/processes/page.js +1 -1
- package/.next/server/app/processes/page_client-reference-manifest.js +1 -1
- package/.next/server/app/processes.html +1 -1
- package/.next/server/app/processes.rsc +3 -3
- package/.next/server/app/processes.segments/_full.segment.rsc +3 -3
- package/.next/server/app/processes.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/processes.segments/processes/__PAGE__.segment.rsc +3 -3
- package/.next/server/app-paths-manifest.json +2 -2
- package/.next/server/chunks/161.js +1 -1
- package/.next/server/chunks/168.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/static/chunks/408-29f55984738967db.js +1 -0
- package/.next/static/chunks/939-514e554087419c71.js +1 -0
- package/.next/static/chunks/app/history/{page-22be927a4c3a9c76.js → page-69ea64476ee5db85.js} +1 -1
- package/.next/static/chunks/app/machines/[machineId]/page-1a25a267563c18c0.js +1 -0
- package/.next/static/chunks/app/processes/{page-e471ed23a1d5632f.js → page-0e98a4a64e829c5f.js} +1 -1
- package/ARCHITECTURE.md +30 -4
- package/CHANGELOG.md +53 -2
- package/README.md +2 -0
- package/dist/cli.cjs +3575 -2555
- package/dist/collector.cjs +155 -232
- package/dist/hub.cjs +5 -18
- package/dist/ops.cjs +158 -31
- package/dist/system.cjs +869 -450
- package/docs/bottlenecks.md +4 -6
- package/docs/configuration.md +2 -0
- package/docs/installation.md +107 -23
- package/docs/operations.md +44 -22
- package/docs/releasing.md +21 -17
- package/docs/system-installation.md +11 -2
- package/package.json +1 -2
- package/.next/static/chunks/408-4fe7147e38981ee1.js +0 -1
- package/.next/static/chunks/939-2600d7c8e583d5ef.js +0 -1
- package/.next/static/chunks/app/machines/[machineId]/page-916ee73de5eb067d.js +0 -1
- /package/.next/static/{npHoP6NSY976Yaye-xi86 → -mNveXe-cHv8irQe97wI_}/_buildManifest.js +0 -0
- /package/.next/static/{npHoP6NSY976Yaye-xi86 → -mNveXe-cHv8irQe97wI_}/_ssgManifest.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[939],{592:(e,t,r)=>{r.d(t,{U8:()=>n,Q_:()=>l,FZ:()=>T});let n=1024,i=Date.parse("2000-01-01T00:00:00Z"),s=Date.parse("2200-01-01T00:00:00Z"),a=["metrics","inventory","processes"],o=["cpu","memory","swap","gpus","disks","network"],u=["outbox-age","outbox-bytes","disk-budget","write-failure","rejected"];function l(e){let t=b(e,"collector message");switch(t.type){case"hello":{k(t,["type","collectorId","runId","bootId","hostname","capabilities","expectedIntervalMs"],"hello");let e=$(t.capabilities,"hello.capabilities",1,a.length).map(e=>A(e,a,"hello.capabilities"));if(new Set(e).size!==e.length||!e.includes("metrics"))throw Error("invalid hello: capabilities must be unique and include metrics");return{type:"hello",collectorId:E(t.collectorId,"collectorId"),runId:E(t.runId,"runId"),bootId:B(t.bootId,"bootId",0,128),hostname:B(t.hostname,"hostname",0,255),capabilities:e,expectedIntervalMs:P(t.expectedIntervalMs,"expectedIntervalMs",100,72e5)}}case"samples":{k(t,["type","mode","records"],"samples");let e=A(t.mode,["live","replay"],"samples.mode"),r=$(t.records,"samples.records",1,32).map((e,t)=>d(e,`records[${t}]`)),n=new Set;for(let e of r){let t=`${e.runId}\0${e.sequence}`;if(n.has(t))throw Error("invalid samples: duplicate record in batch");n.add(t)}return{type:"samples",mode:e,records:r}}case"inventory":return k(t,["type","capturedAt","inventory"],"inventory"),{type:"inventory",capturedAt:x(t.capturedAt,"capturedAt"),inventory:c(t.inventory)};case"status":return k(t,["type","capturedAt","delivery","failures"],"status"),{type:"status",capturedAt:x(t.capturedAt,"capturedAt"),delivery:function(e){let t=b(e,"delivery");if(k(t,["pendingRecords","pendingBytes","oldestPendingCapturedAt","inFlightRecords","droppedRecords","replaying","lastAckAt"],"delivery"),"boolean"!=typeof t.replaying)throw Error("invalid delivery: replaying");let r=(e,t)=>P(e,t,0,Number.MAX_SAFE_INTEGER);return{pendingRecords:r(t.pendingRecords,"pendingRecords"),pendingBytes:r(t.pendingBytes,"pendingBytes"),oldestPendingCapturedAt:v(t.oldestPendingCapturedAt,e=>x(e,"oldestPendingCapturedAt")),inFlightRecords:r(t.inFlightRecords,"inFlightRecords"),droppedRecords:r(t.droppedRecords,"droppedRecords"),replaying:t.replaying,lastAckAt:v(t.lastAckAt,e=>x(e,"lastAckAt"))}}(t.delivery),failures:$(t.failures,"failures",0,32).map(e=>{let t=b(e,"failure");return k(t,["metric","resourceId","reason"],"failure"),{metric:B(t.metric,"metric",1,64),resourceId:null===t.resourceId?null:I(t.resourceId),reason:B(t.reason,"reason",0,256)}})};case"detail.result":return k(t,["type","subscriptionId","capturedAt","snapshot"],"detail.result"),{type:"detail.result",subscriptionId:E(t.subscriptionId,"subscriptionId"),capturedAt:x(t.capturedAt,"capturedAt"),snapshot:function(e){let t=b(e,"process snapshot");if(k(t,["totalProcesses","truncated","inaccessible","processes"],"process snapshot"),"boolean"!=typeof t.truncated)throw Error("invalid process snapshot: truncated");let r=(e,t,r)=>v(e,e=>S(e,t,0,r));return{totalProcesses:P(t.totalProcesses,"totalProcesses",0,1e7),truncated:t.truncated,inaccessible:P(t.inaccessible,"inaccessible",0,1e7),processes:$(t.processes,"processes",0,6e3).map(e=>{let t=b(e,"process");k(t,["pid","ppid","startTicks","name","user","state","cpuPercent","memoryRssBytes","gpuMemoryBytes","ioReadBytesPerSec","ioWriteBytesPerSec","threads","unit"],"process",["command"]);let i={pid:P(t.pid,"pid",0,0x80000000),ppid:P(t.ppid,"ppid",0,0x80000000),startTicks:P(t.startTicks,"startTicks",0,Number.MAX_SAFE_INTEGER),name:B(t.name,"name",0,256),user:v(t.user,e=>B(e,"user",0,64)),state:B(t.state,"state",0,16),cpuPercent:r(t.cpuPercent,"cpuPercent",100*n),memoryRssBytes:v(t.memoryRssBytes,e=>P(e,"memoryRssBytes",0,Number.MAX_SAFE_INTEGER)),gpuMemoryBytes:v(t.gpuMemoryBytes,e=>P(e,"gpuMemoryBytes",0,Number.MAX_SAFE_INTEGER)),ioReadBytesPerSec:r(t.ioReadBytesPerSec,"ioReadBytesPerSec",1e13),ioWriteBytesPerSec:r(t.ioWriteBytesPerSec,"ioWriteBytesPerSec",1e13),threads:v(t.threads,e=>P(e,"threads",0,1e7)),unit:v(t.unit,e=>B(e,"unit",1,256))};return w(t,"command")&&(i.command=B(t.command,"command",0,4096)),i})}}(t.snapshot)};case"detail.ended":return k(t,["type","subscriptionId","reason"],"detail.ended"),{type:"detail.ended",subscriptionId:E(t.subscriptionId,"subscriptionId"),reason:A(t.reason,["expired","cancelled","withheld","unsupported","busy","failed"],"detail.ended.reason")};default:throw Error(`invalid collector message: unsupported type ${M(t.type)}`)}}function d(e,t="record"){let r=b(e,t);k(r,["collectorId","runId","bootId","sequence","capturedAt","kind","payload"],t);let i={collectorId:E(r.collectorId,"collectorId"),runId:E(r.runId,"runId"),bootId:B(r.bootId,"bootId",0,128),sequence:P(r.sequence,"sequence",0,Number.MAX_SAFE_INTEGER),capturedAt:x(r.capturedAt,"capturedAt")};if("metrics"===r.kind){let e;return{...i,kind:"metrics",payload:(k(e=b(r.payload,"metrics payload"),[...o],"metrics payload"),{cpu:y(e.cpu,"cpu",e=>{k(e,["status","usagePercent","perCore"],"cpu",["temperatureC","powerWatts","iowaitPercent","pressureSomePercent"]);let t={status:"ok",usagePercent:S(e.usagePercent,"usagePercent",0,100),perCore:$(e.perCore,"perCore",0,n).map(e=>null===e?null:S(e,"perCore",0,100))},r=g(e,"temperatureC",e=>S(e,"temperatureC",-50,200));void 0!==r&&(t.temperatureC=r);let i=g(e,"powerWatts",e=>S(e,"powerWatts",0,1e4));void 0!==i&&(t.powerWatts=i);let s=g(e,"iowaitPercent",e=>S(e,"iowaitPercent",0,100));void 0!==s&&(t.iowaitPercent=s);let a=g(e,"pressureSomePercent",e=>S(e,"pressureSomePercent",0,100));return void 0!==a&&(t.pressureSomePercent=a),t}),memory:y(e.memory,"memory",m),swap:y(e.swap,"swap",p),gpus:y(e.gpus,"gpus",e=>(k(e,["status","devices"],"gpus"),{status:"ok",devices:h($(e.devices,"gpus.devices",0,16).map(e=>f(e,"gpu",(e,t)=>{k(e,["id","status","utilizationPercent","memoryUsedBytes","memoryTotalBytes","temperatureC","powerWatts"],"gpu");let r=v(e.memoryUsedBytes,e=>P(e,"memoryUsedBytes",0,Number.MAX_SAFE_INTEGER)),n=v(e.memoryTotalBytes,e=>P(e,"memoryTotalBytes",0,Number.MAX_SAFE_INTEGER));if(null!==r&&null!==n&&r>n)throw Error("invalid gpu: memoryUsedBytes exceeds total");return{id:t,status:"ok",utilizationPercent:v(e.utilizationPercent,e=>S(e,"utilizationPercent",0,100)),memoryUsedBytes:r,memoryTotalBytes:n,temperatureC:v(e.temperatureC,e=>S(e,"temperatureC",-50,200)),powerWatts:v(e.powerWatts,e=>S(e,"powerWatts",0,1e4))}})))})),disks:y(e.disks,"disks",e=>{k(e,["status","filesystems","devices"],"disks",["pressureSomePercent","pressureFullPercent"]);let t={status:"ok",filesystems:h($(e.filesystems,"filesystems",0,64).map(e=>f(e,"filesystem",(e,t)=>{k(e,["id","status","usedBytes","totalBytes"],"filesystem",["inodesUsed","inodesTotal"]);let r=p({status:"ok",usedBytes:e.usedBytes,totalBytes:e.totalBytes}),n={id:t,status:"ok",usedBytes:r.usedBytes,totalBytes:r.totalBytes},i=g(e,"inodesUsed",e=>P(e,"inodesUsed",0,Number.MAX_SAFE_INTEGER));void 0!==i&&(n.inodesUsed=i);let s=g(e,"inodesTotal",e=>P(e,"inodesTotal",0,Number.MAX_SAFE_INTEGER));if(void 0!==s&&(n.inodesTotal=s),null!=i&&null!=s&&i>s)throw Error("invalid filesystem: inodesUsed exceeds inodesTotal");return n}))),devices:h($(e.devices,"disk devices",0,64).map(e=>f(e,"disk",(e,t)=>{k(e,["id","status","readBytesPerSec","writeBytesPerSec"],"disk",["readLatencyMs","writeLatencyMs","ioUtilizationPercent"]);let r={id:t,status:"ok",readBytesPerSec:S(e.readBytesPerSec,"readBytesPerSec",0,1e13),writeBytesPerSec:S(e.writeBytesPerSec,"writeBytesPerSec",0,1e13)},n=g(e,"readLatencyMs",e=>S(e,"readLatencyMs",0,864e5));void 0!==n&&(r.readLatencyMs=n);let i=g(e,"writeLatencyMs",e=>S(e,"writeLatencyMs",0,864e5));void 0!==i&&(r.writeLatencyMs=i);let s=g(e,"ioUtilizationPercent",e=>S(e,"ioUtilizationPercent",0,100));return void 0!==s&&(r.ioUtilizationPercent=s),r})))},r=g(e,"pressureSomePercent",e=>S(e,"pressureSomePercent",0,100));void 0!==r&&(t.pressureSomePercent=r);let n=g(e,"pressureFullPercent",e=>S(e,"pressureFullPercent",0,100));return void 0!==n&&(t.pressureFullPercent=n),t}),network:y(e.network,"network",e=>(k(e,["status","interfaces"],"network"),{status:"ok",interfaces:h($(e.interfaces,"interfaces",0,64).map(e=>f(e,"interface",(e,t)=>(k(e,["id","status","rxBytesPerSec","txBytesPerSec"],"interface"),{id:t,status:"ok",rxBytesPerSec:S(e.rxBytesPerSec,"rxBytesPerSec",0,1e13),txBytesPerSec:S(e.txBytesPerSec,"txBytesPerSec",0,1e13)}))))}))})}}if("gap"===r.kind){let e=b(r.payload,`${t}.payload`);k(e,["fromCapturedAt","toCapturedAt","droppedRecords","reason"],"gap payload");let n=x(e.fromCapturedAt,"fromCapturedAt"),s=x(e.toCapturedAt,"toCapturedAt");if(Date.parse(n)>Date.parse(s))throw Error("invalid gap: fromCapturedAt after toCapturedAt");return{...i,kind:"gap",payload:{fromCapturedAt:n,toCapturedAt:s,droppedRecords:P(e.droppedRecords,"droppedRecords",1,Number.MAX_SAFE_INTEGER),reason:A(e.reason,u,"gap.reason")}}}throw Error(`invalid ${t}: unsupported kind ${M(r.kind)}`)}function c(e){let t=b(e,"inventory");k(t,["os","cpu","memory","gpus","filesystems","disks","network","capabilities"],"inventory");let r=b(t.os,"inventory.os");k(r,["platform","release","distro","arch"],"inventory.os");let i=b(t.cpu,"inventory.cpu");k(i,["model","logicalCores"],"inventory.cpu");let s=b(t.memory,"inventory.memory");k(s,["totalBytes","swapTotalBytes"],"inventory.memory");let a=b(t.capabilities,"inventory.capabilities"),u=[...o,"processes"];k(a,[...u],"inventory.capabilities");let l={};for(let e of u){let t=b(a[e],`capability ${e}`);k(t,["status"],`capability ${e}`,["reason"]);let r={status:A(t.status,["supported","unsupported","withheld"],`capability ${e}`)};w(t,"reason")&&(r.reason=B(t.reason,"reason",0,256)),l[e]=r}let d=(e,t)=>v(e,e=>P(e,t,0,Number.MAX_SAFE_INTEGER));return{os:{platform:B(r.platform,"platform",0,64),release:B(r.release,"release",0,256),distro:v(r.distro,e=>B(e,"distro",0,256)),arch:B(r.arch,"arch",0,64)},cpu:{model:v(i.model,e=>B(e,"model",0,256)),logicalCores:P(i.logicalCores,"logicalCores",0,n)},memory:{totalBytes:d(s.totalBytes,"totalBytes"),swapTotalBytes:d(s.swapTotalBytes,"swapTotalBytes")},gpus:h($(t.gpus,"inventory.gpus",0,16).map(e=>{let t=b(e,"gpu inventory");k(t,["id","name","vendor","pciBusId","telemetry","memoryTotalBytes"],"gpu inventory",["reason"]);let r={id:I(t.id),name:B(t.name,"name",0,256),vendor:A(t.vendor,["nvidia","amd","intel","aspeed","other"],"vendor"),pciBusId:v(t.pciBusId,e=>B(e,"pciBusId",1,64)),telemetry:A(t.telemetry,["supported","unsupported"],"telemetry"),memoryTotalBytes:d(t.memoryTotalBytes,"memoryTotalBytes")};return w(t,"reason")&&(r.reason=B(t.reason,"reason",0,256)),r})),filesystems:h($(t.filesystems,"inventory.filesystems",0,64).map(e=>{let t=b(e,"filesystem inventory");return k(t,["id","mountPoint","device","fsType","totalBytes"],"filesystem inventory"),{id:I(t.id),mountPoint:B(t.mountPoint,"mountPoint",1,256),device:B(t.device,"device",0,256),fsType:B(t.fsType,"fsType",0,64),totalBytes:d(t.totalBytes,"totalBytes")}})),disks:h($(t.disks,"inventory.disks",0,64).map(e=>{let t=b(e,"disk inventory");if(k(t,["id","name","model","rotational","sizeBytes"],"disk inventory"),null!==t.rotational&&"boolean"!=typeof t.rotational)throw Error("invalid disk inventory: rotational");return{id:I(t.id),name:B(t.name,"name",1,64),model:v(t.model,e=>B(e,"model",0,256)),rotational:t.rotational,sizeBytes:d(t.sizeBytes,"sizeBytes")}})),network:h($(t.network,"inventory.network",0,64).map(e=>{let t=b(e,"interface inventory");if(k(t,["id","name","mac","addresses","virtual","state","speedMbps"],"interface inventory"),"boolean"!=typeof t.virtual)throw Error("invalid interface inventory: virtual");return{id:I(t.id),name:B(t.name,"name",1,64),mac:v(t.mac,e=>B(e,"mac",1,64)),addresses:$(t.addresses,"addresses",0,32).map(e=>{let t=b(e,"address");k(t,["family","address","prefix"],"address");let r=A(t.family,["ipv4","ipv6"],"family");return{family:r,address:B(t.address,"address",2,64),prefix:P(t.prefix,"prefix",0,"ipv4"===r?32:128)}}),virtual:t.virtual,state:A(t.state,["up","down","unknown"],"state"),speedMbps:v(t.speedMbps,e=>P(e,"speedMbps",0,1e7))}})),capabilities:l}}function p(e){k(e,["status","usedBytes","totalBytes"],"usage");let t=P(e.totalBytes,"totalBytes",0,Number.MAX_SAFE_INTEGER),r=P(e.usedBytes,"usedBytes",0,Number.MAX_SAFE_INTEGER);if(r>t)throw Error("invalid usage: usedBytes exceeds totalBytes");return{status:"ok",usedBytes:r,totalBytes:t}}function m(e){k(e,["status","usedBytes","totalBytes"],"memory",["pressureSomePercent","pressureFullPercent"]);let t=P(e.totalBytes,"totalBytes",0,Number.MAX_SAFE_INTEGER),r=P(e.usedBytes,"usedBytes",0,Number.MAX_SAFE_INTEGER);if(r>t)throw Error("invalid memory: usedBytes exceeds totalBytes");let n={status:"ok",usedBytes:r,totalBytes:t},i=g(e,"pressureSomePercent",e=>S(e,"pressureSomePercent",0,100));void 0!==i&&(n.pressureSomePercent=i);let s=g(e,"pressureFullPercent",e=>S(e,"pressureFullPercent",0,100));return void 0!==s&&(n.pressureFullPercent=s),n}function y(e,t,r){let n=b(e,t);if("ok"===n.status)return r(n);if("unavailable"===n.status)return k(n,["status","reason"],t),{status:"unavailable",reason:B(n.reason,"reason",0,256)};throw Error(`invalid ${t}: unsupported status ${M(n.status)}`)}function f(e,t,r){let n=b(e,t),i=I(n.id);if("ok"===n.status)return r(n,i);if("unavailable"===n.status)return k(n,["id","status","reason"],t),{id:i,status:"unavailable",reason:B(n.reason,"reason",0,256)};throw Error(`invalid ${t}: unsupported status ${M(n.status)}`)}function h(e){let t=new Set;for(let r of e){if(t.has(r.id))throw Error(`invalid resource list: duplicate id ${M(r.id)}`);t.add(r.id)}return e}function v(e,t){return null===e?null:t(e)}function g(e,t,r){if(w(e,t))return v(e[t],r)}function b(e,t){if(null===e||"object"!=typeof e||Array.isArray(e))throw Error(`invalid ${t}: expected object, got ${M(e)}`);return e}function k(e,t,r,n=[]){let i=new Set([...t,...n]);for(let t of Object.keys(e))if(!i.has(t))throw Error(`invalid ${r}: unexpected field "${t}"`);for(let n of t)if(void 0===e[n])throw Error(`invalid ${r}: missing field "${n}"`);for(let t of n)if(w(e,t)&&void 0===e[t])throw Error(`invalid ${r}: ${t} must not be undefined`)}function w(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function $(e,t,r,n){if(!Array.isArray(e))throw Error(`invalid ${t}: expected array`);if(e.length<r||e.length>n)throw Error(`invalid ${t}: length ${e.length} outside ${r}..${n}`);return e}function A(e,t,r){if("string"!=typeof e||!t.includes(e))throw Error(`invalid ${r}: unexpected value ${M(e)}`);return e}function B(e,t,r,n){if("string"!=typeof e)throw Error(`invalid ${t}: expected string, got ${M(e)}`);if(e.length<r||e.length>n)throw Error(`invalid ${t}: length ${e.length} outside ${r}..${n}`);return e}function E(e,t){return B(e,t,1,128)}function I(e){return B(e,"resource id",1,256)}function P(e,t,r,n){if("number"!=typeof e||!Number.isSafeInteger(e))throw Error(`invalid ${t}: expected safe integer, got ${M(e)}`);if(e<r||e>n)throw Error(`invalid ${t}: ${e} outside ${r}..${n}`);return e}function S(e,t,r,n){if("number"!=typeof e||!Number.isFinite(e))throw Error(`invalid ${t}: expected finite number, got ${M(e)}`);if(e<r||e>n)throw Error(`invalid ${t}: ${e} outside ${r}..${n}`);return e}function x(e,t){let r=B(e,t,1,64),n=Date.parse(r);if(!Number.isFinite(n)||n<i||n>s)throw Error(`invalid ${t}: not a parseable timestamp`);return r}function M(e){try{let t=JSON.stringify(e);if("string"==typeof t)return t.length<=80?t:`${t.slice(0,77)}...`}catch{}return String(e)}function T(e){let t=C(e,"hub snapshot");_(t,["hubRunId","machines"],"hub snapshot");let r=j(t.hubRunId,"hubRunId","hub snapshot");if(!Array.isArray(t.machines))throw Error("invalid snapshot machines");let n=new Set;return{hubRunId:r,machines:t.machines.map(e=>{let t=C(e,"machine");_(t,["machineId","collectorId","hostname","connected","lastReceivedAt"],"machine",["expectedIntervalMs","metrics","inventory","delivery","displayName","tags"]);let r=j(t.machineId,"machineId","machine");if(n.has(r))throw Error("duplicate snapshot machine");n.add(r);let i=j(t.collectorId,"collectorId","machine"),s=z(t.hostname,"hostname","machine",0,N);if("boolean"!=typeof t.connected)throw Error("invalid machine connection state");let a=null===t.lastReceivedAt?null:D(t.lastReceivedAt,"lastReceivedAt","machine"),o={},u=L(t,"expectedIntervalMs")?function(e,t,r){if(null===e)return null;if(void 0===e)throw Error(`invalid ${r}: ${t} must not be undefined`);var n=e,i=t,s=r;if("number"!=typeof n||!Number.isSafeInteger(n))throw Error(`invalid ${s}: ${i} must be a safe integer, got ${G(n)}`);if(n<100||n>72e5)throw Error(`invalid ${s}: ${i} ${n} outside ${100}..${72e5}`);return n}(t.expectedIntervalMs,"expectedIntervalMs","machine"):void 0;if(L(t,"metrics")){let{receivedAt:e,...r}=C(t.metrics,"received metrics"),n=d(r);if("metrics"!==n.kind||n.collectorId!==i)throw Error("conflicting machine metrics");if(o.metrics={...n,receivedAt:D(e,"receivedAt","metrics")},o.metrics.receivedAt!==a)throw Error("conflicting metrics receipt time")}if(L(t,"inventory")&&(o.inventory=c(t.inventory)),L(t,"delivery")){let e=l(t.delivery);if("status"!==e.type)throw Error("invalid delivery status");o.delivery=e}if(L(t,"displayName")&&(o.displayName=null===t.displayName?null:z(t.displayName,"displayName","machine",0,128)),L(t,"tags")){if(!Array.isArray(t.tags)||t.tags.length>32)throw Error("invalid machine tags");o.tags=t.tags.map(e=>z(e,"tag","machine",1,64))}return{machineId:r,collectorId:i,hostname:s,connected:t.connected,lastReceivedAt:a,...void 0===u?{}:{expectedIntervalMs:u},...o}})}}let N=255,R=Date.parse("2000-01-01T00:00:00Z"),F=Date.parse("2200-01-01T00:00:00Z");function C(e,t){if(null===e||"object"!=typeof e||Array.isArray(e))throw Error(`invalid ${t}: expected object, got ${G(e)}`);return e}function _(e,t,r,n=[]){let i=new Set([...t,...n]);for(let t of Object.keys(e))if(!i.has(t))throw Error(`invalid ${r}: unexpected field "${t}"`);for(let n of t)if(void 0===e[n])throw Error(`invalid ${r}: missing field "${n}"`);for(let t of n)if(L(e,t)&&void 0===e[t])throw Error(`invalid ${r}: ${t} must not be undefined`)}function L(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function j(e,t,r){return z(e,t,r,1,128)}function z(e,t,r,n,i){if("string"!=typeof e)throw Error(`invalid ${r}: ${t} must be a string, got ${G(e)}`);if(e.length<n||e.length>i)throw Error(`invalid ${r}: ${t} length ${e.length} outside ${n}..${i}`);return e}function D(e,t,r){let n=z(e,t,r,1,64),i=Date.parse(n);if(!Number.isFinite(i)||i<R||i>F)throw Error(`invalid ${r}: ${t} is not a parseable timestamp`);return n}function G(e){try{let t=JSON.stringify(e);if("string"==typeof t)return t.length<=80?t:`${t.slice(0,77)}...`}catch{}return String(e)}},4334:(e,t,r)=>{r.d(t,{K:()=>o,g:()=>s});var n=r(5887),i=r(7586);function s(e,t){let r=new Map;for(let s of t.machines){let a=s.metrics;if(!a)continue;let o=`${t.hubRunId}\0${a.collectorId}\0${a.runId}\0${a.sequence}`,u=e.get(s.machineId)??[],l=u.at(-1);if(l?.sampleId===o){r.set(s.machineId,u);continue}let d=o.slice(0,o.lastIndexOf("\0")+1),c=l?.sampleId.startsWith(d)?u:[],p=a.payload.memory;r.set(s.machineId,[...c,{sampleId:o,receivedAtLocal:Date.parse(a.receivedAt),cpuPercent:"ok"===a.payload.cpu.status?a.payload.cpu.usagePercent:null,memoryPercent:"ok"===p.status&&p.totalBytes>0?100*p.usedBytes/p.totalBytes:null,gapThresholdMs:(0,i.Cj)(s.expectedIntervalMs)}].slice(-n.yY))}return r}function a(e){return"number"==typeof e.gapThresholdMs&&Number.isFinite(e.gapThresholdMs)&&e.gapThresholdMs>0?e.gapThresholdMs:n.vz}function o(e,t=600,r=140){let i;if(e.length<2)return null;let s=e[0].receivedAtLocal,u=Math.max(1e3,e.at(-1).receivedAtLocal-s),l="";for(let o of e){if(null===o.cpuPercent){i=void 0;continue}let e=4+(o.receivedAtLocal-s)/u*(t-8),d=r-4-o.cpuPercent/100*(r-8),c=i?Math.min(a(i),a(o)):n.vz,p=i&&o.receivedAtLocal>=i.receivedAtLocal&&o.receivedAtLocal-i.receivedAtLocal<c;l+=`${p?"L":"M"}${e.toFixed(2)},${d.toFixed(2)} `,i=o}return l.trim()||null}},5887:(e,t,r)=>{r.d(t,{mq:()=>i,vz:()=>n,yY:()=>s});let n=15e3,i=9e4,s=180},7586:(e,t,r)=>{r.d(t,{$:()=>s,A4:()=>d,Cj:()=>i,F2:()=>m,L_:()=>p,fv:()=>c,l9:()=>u,nV:()=>l,vj:()=>a,z3:()=>o});var n=r(5887);function i(e){return null==e||"number"!=typeof e||!Number.isFinite(e)||e<=0?n.vz:Math.max(n.vz,3*e)}function s(e){if(null==e||!Number.isFinite(e)||e<0)return"—";if(e<6e4){let t=e/1e3;return Number.isInteger(t)?`${t} s`:`${t.toFixed(1)} s`}if(e<36e5){let t=e/6e4;return Number.isInteger(t)?`${t} min`:`${t.toFixed(1)} min`}let t=e/36e5;return Number.isInteger(t)?`${t} h`:`${t.toFixed(1)} h`}function a(e,t,r=i(e.expectedIntervalMs)){return function(e,t,r=n.vz){if(null===e)return"unknown";let i=Date.parse(e);return Number.isFinite(i)?t-i>=r?"stale":"live":"unknown"}(e.lastReceivedAt,t,r)}function o(e){if(null==e||!Number.isFinite(e)||e<0)return"—";let t=["B","KiB","MiB","GiB","TiB"],r=e,n=0;for(;r>=1024&&n<t.length-1;)r/=1024,n+=1;return 0===n?`${Math.round(r)} B`:`${r.toFixed(1)} ${t[n]}`}function u(e){return null!=e&&Number.isFinite(e)?`${e.toFixed(1)}%`:"—"}function l(e){if(null===e||!Number.isFinite(e))return"—";let t=Math.round(Math.max(0,e)/1e3);if(t<60)return`${t}s ago`;let r=Math.floor(t/60);if(r<60){let e=t%60;return 0===e?`${r}m ago`:`${r}m ${e}s ago`}let n=Math.floor(r/60);if(n<24){let e=r%60;return 0===e?`${n}h ago`:`${n}h ${e}m ago`}let i=Math.floor(n/24),s=n%24;return 0===s?`${i}d ago`:`${i}d ${s}h ago`}function d(e,t){if(null===e)return null;let r=Date.parse(e);return Number.isFinite(r)?t-r:null}function c(e){switch(e){case"ok":return"Live";case"degraded":return"Degraded";case"stale":return"Stale";case"disconnected":return"Disconnected";case"unseen":return"No sample yet"}}function p(e,t=n.mq){let r=e.metrics;if(!r)return{kind:"unknown"};let i=Date.parse(r.capturedAt),s=Date.parse(r.receivedAt);if(!Number.isFinite(i)||!Number.isFinite(s))return{kind:"unknown"};let a=i-s;return a>t?{kind:"ahead",skewMs:a}:a<-t?{kind:"behind",skewMs:-a}:{kind:"none"}}function m(e,t,r=i(e.expectedIntervalMs)){return{freshness:a(e,t,r),attention:function(e,t,r=i(e.expectedIntervalMs)){var n;let s=a(e,t,r);return e.metrics&&"unknown"!==s?"stale"===s?"stale":(n=e.metrics)&&("unavailable"===n.payload.cpu.status||"unavailable"===n.payload.memory.status)?"degraded":e.connected?"ok":"disconnected":"unseen"}(e,t,r),connection:e.connected?"connected":"disconnected",skew:p(e),thresholdMs:r}}},9939:(e,t,r)=>{r.d(t,{LiveProvider:()=>g,M:()=>v});var n=r(5155),i=r(2115);async function s(e){try{let t=await e.json();if(t&&"object"==typeof t&&"error"in t){let e=t.error;if("string"==typeof e)return e}}catch{}return e.statusText||null}function a(e){if(!e||"object"!=typeof e)return null;let t=e.username,r=e.csrfToken;if("string"!=typeof t||0===t.length||"string"!=typeof r||0===r.length)return null;let n=e.admin;return void 0!==n&&"boolean"!=typeof n?null:{username:t,csrfToken:r,...!0===n?{admin:!0}:{}}}async function o(){try{let e=await fetch("/api/auth/session",{cache:"no-store",signal:AbortSignal.timeout(5e3),headers:{Accept:"application/json"}});if(e.ok){try{let t=a(await e.json());if(t)return{kind:"signed-in",user:t}}catch{}return{kind:"error",detail:"unexpected session response"}}if(401===e.status)return{kind:"signed-out"};if(503===e.status)return{kind:"auth-unavailable",detail:await s(e)};return{kind:"error",detail:`unexpected status ${e.status}`}}catch{return{kind:"unreachable"}}}async function u(e,t){try{let r=await fetch("/api/auth/login",{method:"POST",cache:"no-store",signal:AbortSignal.timeout(5e3),headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({username:e,password:t})});if(r.ok){try{let e=a(await r.json());if(e)return{kind:"signed-in",user:e}}catch{}return{kind:"error",detail:"unexpected sign-in response"}}if(401===r.status)return{kind:"invalid-credentials",detail:await s(r)};if(429===r.status)return{kind:"error",detail:"too many attempts — wait a moment and try again"};if(503===r.status)return{kind:"auth-unavailable",detail:await s(r)};return{kind:"error",detail:`unexpected status ${r.status}`}}catch{return{kind:"unreachable"}}}async function l(e){try{let t=await fetch("/api/auth/logout",{method:"POST",cache:"no-store",signal:AbortSignal.timeout(5e3),headers:{"X-CSRF-Token":e,Accept:"application/json"}});if(t.ok||401===t.status)return"ok";return t.status,{kind:"error",detail:`unexpected status ${t.status}`}}catch{return"unreachable"}}async function d(e=5e3){let t=new AbortController,r=setTimeout(()=>t.abort(),e);try{let e=await fetch("/api/live",{cache:"no-store",signal:t.signal,headers:{Accept:"text/event-stream"}});if(200===e.status)return{kind:"ok"};if(401===e.status)return{kind:"unauthorized"};if(403===e.status)return{kind:"forbidden"};return{kind:"error",detail:`unexpected status ${e.status}`}}catch{return{kind:"unreachable"}}finally{clearTimeout(r);try{t.abort()}catch{}}}var c=r(592);let p=["snapshot","update","reset"];class m{source=null;lastId=null;get lastEventId(){return this.lastId}get isOpen(){return null!==this.source&&2!==this.source.readyState}start(e,t){this.close();let r=new EventSource(e);this.source=r;let n=e=>n=>{if(this.source!==r||null===this.source)return;let i=n.lastEventId;"string"==typeof i&&i.length>0&&(this.lastId=i);try{t.onSnapshot((0,c.FZ)(JSON.parse(n.data)),e,i??"")}catch{this.close(),t.onError()}};for(let e of p)r.addEventListener(e,n(e));r.onerror=()=>{this.source===r&&(this.close(),t.onError())}}close(){this.source?.close(),this.source=null}}var y=r(4334);let f=[1e3,2e3,4e3,8e3,15e3],h=(0,i.createContext)(null);function v(){let e=(0,i.useContext)(h);if(!e)throw Error("useLive must be used inside <LiveProvider>");return e}function g({children:e}){let[t,r]=(0,i.useState)({kind:"restoring"}),[s,a]=(0,i.useState)("idle"),[c,p]=(0,i.useState)(null),[v,b]=(0,i.useState)([]),[k,w]=(0,i.useState)(null),[$,A]=(0,i.useState)(null),[B,E]=(0,i.useState)(null),[I,P]=(0,i.useState)(null),[S,x]=(0,i.useState)(new Map),M=(0,i.useRef)(!0),T=(0,i.useRef)(0),N=(0,i.useRef)(null),R=(0,i.useRef)(null),F=(0,i.useRef)(0),C=(0,i.useRef)(t),_=(0,i.useRef)(0),L=(0,i.useRef)(!1),j=(0,i.useRef)(!1),z=e=>{C.current=e,r(e)},D=()=>{null!==R.current&&(clearTimeout(R.current),R.current=null)},G=()=>{_.current+=1,T.current+=1,N.current?.close(),N.current=null,D()},X=()=>{L.current=!1,b([]),x(new Map),p(null),A(null),E(null),w(null)},O=e=>{let t=C.current;("signed-in"!==t.kind||t.user.csrfToken!==e.csrfToken)&&X(),z({kind:"signed-in",user:e})},U=()=>{if("signed-in"!==C.current.kind)return;G(),a(L.current?"reconnecting":"connecting");let e=new m;N.current=e,e.start("/api/live",{onSnapshot:(t,r,n)=>{M.current&&N.current===e&&(F.current=0,L.current=!0,p(t.hubRunId),b(t.machines),w(Date.now()),A(n||null),E(r),x(e=>(0,y.g)(e,t)),a("live"))},onError:()=>{M.current&&N.current===e&&W()}})},W=async()=>{G();let e=_.current;a("reconnecting");let t=await o();if(!M.current||e!==_.current)return;if("signed-in"===t.kind)O(t.user);else if("signed-out"===t.kind){z({kind:"signed-out"}),X(),a("expired");return}else if("auth-unavailable"===t.kind){z({kind:"auth-unavailable",detail:t.detail}),X(),a("idle");return}let r=Math.min(F.current+1,f.length+1);if(F.current=r,r>f.length){a("disconnected"),Z();return}a("reconnecting"),R.current=setTimeout(()=>{q()},f[r-1])},q=async()=>{if(!M.current||j.current)return;G();let e=_.current,t=await d();if(M.current&&e===_.current){if("forbidden"===t.kind){X(),a("no-permission");return}if("unauthorized"===t.kind){let t=await o();if(!M.current||e!==_.current)return;if("signed-in"===t.kind){O(t.user),U();return}if("signed-out"===t.kind){z({kind:"signed-out"}),X(),a("expired");return}if("auth-unavailable"===t.kind){z({kind:"auth-unavailable",detail:t.detail}),X(),a("idle");return}}U()}},Z=()=>{D(),R.current=setTimeout(()=>{J()},3e4)},J=async()=>{if(!M.current||j.current)return;G();let e=_.current,t=await o();if(M.current&&e===_.current){if("signed-in"===t.kind){O(t.user),U();return}if("signed-out"===t.kind){z({kind:"signed-out"}),X(),a("expired");return}if("auth-unavailable"===t.kind){z({kind:"auth-unavailable",detail:t.detail}),X(),a("idle");return}Z()}},K=async e=>{let t=_.current,r=await o();if(M.current&&T.current===e&&t===_.current){if("signed-in"===r.kind){O(r.user),F.current=0,U();return}if("signed-out"===r.kind){z({kind:"signed-out"}),a("idle");return}if("auth-unavailable"===r.kind){z({kind:"auth-unavailable",detail:r.detail}),a("idle");return}z({kind:"restore-failed",detail:"error"===r.kind?r.detail:null}),a("idle")}},Y=async(e,t)=>{G();let r=_.current,n=await u(e,t);return M.current&&r===_.current?("signed-in"===n.kind&&M.current&&(O(n.user),P(null),F.current=0,U()),n):{kind:"error",detail:"Session request superseded. Try again."}},Q=async()=>{let e=C.current;if("signed-in"!==e.kind||j.current)return;j.current=!0,G();let t=_.current;X(),a("idle");let r=await l(e.user.csrfToken);if(j.current=!1,!M.current||t!==_.current)return;if("ok"===r){z({kind:"signed-out"}),X(),a("idle"),P("Signed out.");return}let n=await o();if(M.current&&t===_.current){if("signed-in"===n.kind){O(n.user),P("Sign out failed — try again."),U();return}if("signed-out"===n.kind){z({kind:"signed-out"}),X(),a("idle"),P(null);return}if("auth-unavailable"===n.kind){z({kind:"auth-unavailable",detail:n.detail}),a("idle");return}z({kind:"restore-failed",detail:"error"===n.kind?n.detail:null}),a("idle")}};return(0,i.useEffect)(()=>(M.current=!0,T.current+=1,K(T.current),()=>{M.current=!1,G()}),[]),(0,n.jsx)(h.Provider,{value:{session:t,phase:s,hubRunId:c,machines:v,lastReceivedLocalMs:k,lastEventId:$,lastEventKind:B,notice:I,history:S,login:Y,signOut:Q,retryConnection:()=>{if(M.current&&!j.current){if("signed-in"===C.current.kind){F.current=0,q();return}T.current+=1,K(T.current)}},dismissNotice:()=>P(null)},children:e})}}}]);
|
package/.next/static/chunks/app/history/{page-22be927a4c3a9c76.js → page-69ea64476ee5db85.js}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[429],{1:(e,t,s)=>{"use strict";s.d(t,{PE:()=>o,UR:()=>d,kg:()=>l,uW:()=>c});let r=/^[\u0009\u000a\u000d ]*[=+\-@]/,n=/^[\u0009\u000a\u000d]/;function i(e){if(null==e)return"";if("number"==typeof e)return Number.isFinite(e)?String(e):"";if("boolean"==typeof e)return e?"true":"false";let t=0===e.length?e:r.test(e)||n.test(e)?`'${e}`:e;return/[",\t\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function a(e){return e.map(i).join(",")}function l(e){return`${e.map(a).join("\r\n")}\r
|
|
2
|
-
`}function o(e,t,s){if("u"<typeof document)return;let r=new Blob([t],{type:s}),n=URL.createObjectURL(r),i=document.createElement("a");i.href=n,i.download=e,i.rel="noopener",i.style.display="none",document.body.append(i),i.click(),i.remove(),globalThis.setTimeout(()=>URL.revokeObjectURL(n),0)}let d="text/csv;charset=utf-8",c="application/json;charset=utf-8"},438:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(8698).A)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},2910:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(8698).A)("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]])},2939:(e,t,s)=>{"use strict";s.d(t,{HistoryView:()=>eI});var r=s(5155),n=s(8500),i=s.n(n),a=s(2115),l=s(7422),o=s(3896),d=s(1735),c=s(7029),u=s(828),m=s(4173),h=s(3440),p=s(940),x=s(802),g=s(6582),f=s(9939),b=s(8664),y=s(4567),j=s(592);let v=j.U8,N=/^core:(\d+)$/;function w(e){let t=N.exec(e);if(null===t)return null;let s=Number(t[1]);return!Number.isSafeInteger(s)||s<0||s>=j.U8?null:s}function k(e){return[...new Set(e)].sort((e,t)=>(w(e)??0)-(w(t)??0))}function M(e,t=[]){var s;let r=e?.metrics?.payload.cpu,n=new Set(!Number.isFinite(s=Math.max(e?.inventory?.cpu.logicalCores??0,r?.status==="ok"?r.perCore.length:0))?[]:Array.from({length:Math.min(j.U8,Math.max(0,Math.floor(s)))},(e,t)=>`core:${t}`));for(let e of t)"cpu.core"===e.metric&&null!==w(e.resourceId)&&n.add(e.resourceId);return k([...n])}function $(e,t){let s=new Set(t);if(null===e)return k(t).slice(0,v);let r=[];for(let t of e)if(s.has(t)&&null!==w(t)&&(r.push(t),r.length>=v))break;return k(r)}function A(e){let t=w(e);return null===t?e:`Core ${t}`}var I=s(7726);function C(e){if("string"!=typeof e||0===e.length)return null;let t=Date.parse(e);return Number.isFinite(t)?t:null}var S=s(5078),R=s(2910),P=s(9942),U=s(8698);let L=(0,U.A)("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),_=(0,U.A)("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);var B=s(6114);let T=Object.freeze([]),z=new Set(y.H9.map(e=>e.metric)),E=e=>"boolean"==typeof e?e:null,D=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e)?e.slice(0,1e3):null,F=e=>S.pI.some(t=>t.id===e)?e:null,O=e=>"string"==typeof e&&(""===e||e.split(",").every(e=>z.has(e)))?e:null,H=/^core:\d+$/,Z=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e&&H.test(e))?[...new Set(e)].slice(0,j.U8):null;function G(e,t){return(0,B.u)(`history.hidden.${t}.${e}`,T,D)}function q(e){return(0,B.u)(`history.cores.${e}`,null,Z)}let V=e=>"bytes"===e||"percent"===e?e:null;function W(e,t){return(0,B.u)(`history.units.${t}.${e}`,"bytes",V)}let K="peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:[outline-color:var(--focus)]";function Y({label:e,action:t}){return(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:e}),(0,r.jsx)("span",{"aria-hidden":!0,className:"h-px min-w-0 flex-1 bg-border"}),t]})}let J="inline-flex min-h-8 items-center gap-1.5 rounded-md border border-transparent px-2.5 text-xs transition-colors",Q=`${J} ${K} bg-selected text-foreground`,X=`${J} ${K} bg-card-strong text-muted-foreground hover:text-foreground`;function ee(e){let{machine:t,range:s,selectedMetrics:n,catalog:i,catalogError:a,gpuCards:l,hiddenCards:o,autoRefresh:d,loading:c,manualRefreshing:m,statusText:h,onRangeChange:p,onToggleMetric:x,onSetMetrics:g,onToggleCard:f,onToggleAutoRefresh:b,onRefresh:j}=e,[v,N]=(0,B.u)("history.controlsOpen",!1,E,"session"),w=new Set(n),k=y.H9.filter(({metric:e})=>(0,y.yv)(t,e).available&&(null===i||void 0!==i[e])).map(({metric:e})=>e),I=new Set(k),C=(e,t)=>{let s=new Set(n);for(let r of e)t&&I.has(r)?s.add(r):t||s.delete(r);g([...s])},U=n.some(e=>e.startsWith("gpu.")),T=w.has("cpu.core"),[z,D]=q(t?.machineId??""),F=T?M(t):[],O=$(z,F),H=new Set(O);return(0,r.jsxs)("section",{"aria-labelledby":"history-query-heading","aria-busy":c,className:"mb-5 min-w-0 rounded-xl border border-border bg-card",children:[(0,r.jsx)("h2",{id:"history-query-heading",className:"sr-only",children:"History query"}),(0,r.jsxs)("div",{className:"flex flex-wrap items-end gap-x-5 gap-y-4 p-4 md:p-5",children:[(0,r.jsxs)("fieldset",{className:"flex min-w-0 flex-col gap-1.5",children:[(0,r.jsx)("legend",{className:"mb-1.5 text-xs text-muted-foreground",children:"Time range"}),(0,r.jsx)("div",{className:"inline-flex flex-wrap rounded-lg border border-border bg-background p-0.5",children:S.pI.map(e=>{let t=s===e.id;return(0,r.jsxs)("label",{className:"cursor-pointer",children:[(0,r.jsx)("input",{type:"radio",name:"history-range",value:e.id,checked:t,onChange:()=>p(e.id),className:"peer sr-only"}),(0,r.jsxs)("span",{className:`inline-flex min-h-8 items-center rounded-md px-2.5 text-xs transition-colors ${K} ${t?"bg-selected font-medium text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[e.shortLabel,(0,r.jsxs)("span",{className:"sr-only",children:[" — ",e.label]})]})]},e.id)})})]}),(0,r.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 sm:ml-auto",children:[(0,r.jsx)("p",{className:"order-first w-full text-xs text-muted-foreground sm:order-none sm:w-auto",children:h}),(0,r.jsxs)("button",{type:"button",onClick:j,disabled:m,className:"inline-flex min-h-8 items-center gap-1.5 rounded-md border border-border bg-background px-2.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-60",children:[(0,r.jsx)(u.A,{className:`h-3.5 w-3.5 ${m?"animate-spin":""}`,"aria-hidden":!0}),"Refresh"]}),(0,r.jsxs)("button",{type:"button",onClick:b,"aria-pressed":d,className:`inline-flex min-h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs transition-colors ${d?"border-accent/40 bg-selected text-foreground":"border-border bg-background text-muted-foreground hover:bg-card-strong hover:text-foreground"}`,children:[d?(0,r.jsx)(R.A,{className:"h-3.5 w-3.5","aria-hidden":!0}):(0,r.jsx)(P.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),d?"Pause":"Resume"]})]})]}),(0,r.jsxs)("div",{className:"border-t border-border px-4 py-4 md:px-5",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsxs)("button",{type:"button","aria-expanded":v,"aria-controls":"history-metric-options",onClick:()=>N(!v),className:"inline-flex min-h-8 items-center gap-1.5 rounded-md text-sm font-medium",children:["Metrics ",(0,r.jsxs)("span",{className:"tnum text-xs font-normal text-muted-foreground",children:[w.size," selected"]}),(0,r.jsx)(L,{"aria-hidden":!0,className:`h-3.5 w-3.5 text-muted-foreground transition-transform ${v?"rotate-180":""}`})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:()=>C(k,!0),disabled:k.every(e=>w.has(e)),className:"inline-flex min-h-8 items-center rounded-md border border-border bg-background px-2.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Select all"}),(0,r.jsx)("button",{type:"button",onClick:()=>g([]),disabled:0===w.size,className:"inline-flex min-h-8 items-center rounded-md border border-border bg-background px-2.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Unselect all"})]})]}),(0,r.jsx)("div",{id:"history-metric-options",hidden:!v,children:(0,r.jsxs)("div",{className:"mt-4 min-w-0 md:col-span-2",children:[(0,r.jsx)("div",{className:"min-w-0",children:(0,r.jsx)("div",{className:"grid gap-x-6 gap-y-5 md:grid-cols-2 xl:grid-cols-3",children:y.P$.map(e=>(0,r.jsxs)("fieldset",{className:`min-w-0 ${"disk"===e.id?"xl:col-span-2":""}`,children:[(0,r.jsx)("legend",{className:"sr-only",children:e.label}),(0,r.jsx)(Y,{label:e.label,action:(0,r.jsxs)("div",{className:"flex shrink-0 gap-2",children:[(0,r.jsx)("button",{type:"button","aria-label":`Select all ${e.label} metrics`,onClick:()=>C(e.metrics,!0),disabled:e.metrics.filter(e=>I.has(e)).every(e=>w.has(e)),className:"min-h-6 rounded-sm text-xs text-muted-foreground hover:text-foreground hover:underline disabled:opacity-50",children:"All"}),(0,r.jsx)("button",{type:"button","aria-label":`Unselect all ${e.label} metrics`,onClick:()=>C(e.metrics,!1),disabled:!e.metrics.some(e=>w.has(e)),className:"min-h-6 rounded-sm text-xs text-muted-foreground hover:text-foreground hover:underline disabled:opacity-50",children:"None"})]})}),(0,r.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:e.metrics.map(e=>{var s;let n=(0,y.oB)(e);if(null===n)return null;let a=(0,y.yv)(t,e),l=null===i||void 0!==i[e],o=a.available&&l,d=w.has(e),c=(0,y.Lf)(n,0);return(0,r.jsxs)("label",{className:o?"cursor-pointer":"cursor-not-allowed",title:a.available?l?n.description:"This hub does not record this metric.":a.reason??void 0,children:[(0,r.jsx)("input",{type:"checkbox",checked:d,onChange:()=>x(e),disabled:!o&&!d,className:"peer sr-only","aria-label":n.label}),(0,r.jsxs)("span",{className:`${!o?d?`${J} ${K} bg-card-strong text-muted-foreground line-through`:`${J} text-muted-foreground opacity-50`:d?Q:X}`,children:[(0,r.jsx)("span",{"aria-hidden":!0,className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-sm border border-current",style:{color:c.color},children:d?(0,r.jsx)(_,{className:"h-3 w-3",strokeWidth:3}):null}),(s=n.label,({"cpu.usage":"Usage","cpu.core":"Per-core","cpu.iowait":"I/O wait","cpu.pressure":"Pressure","cpu.temperature":"Temperature","cpu.power":"Package power","memory.used":"Used bytes","memory.usage":"Usage %","swap.used":"Swap","memory.pressure.some":"Pressure (some)","memory.pressure.full":"Pressure (full)","gpu.utilization":"Utilization","gpu.memory.used":"VRAM","gpu.temperature":"Temperature","gpu.power":"Power","fs.used":"Space used","fs.usage":"Capacity %","fs.inodes.usage":"Inodes %","net.rx":"Received","net.tx":"Sent"})[e]??s)]})]},e)})}),"gpu"===e.id&&U&&l.length>0?(0,r.jsxs)("fieldset",{className:"mt-4 border-t border-border pt-3",children:[(0,r.jsx)("legend",{className:"sr-only",children:"GPU cards"}),(0,r.jsx)(Y,{label:"GPU cards"}),(0,r.jsx)("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:l.map((e,t)=>{let s=e.id,n=!o.has(s);return(0,r.jsxs)("label",{className:"cursor-pointer",children:[(0,r.jsx)("input",{type:"checkbox",checked:n,onChange:()=>f(s),className:"peer sr-only"}),(0,r.jsxs)("span",{className:n?Q:X,children:[(0,r.jsx)("span",{className:"tnum text-xs text-muted-foreground",children:t+1}),e.label]})]},e.id)})})]}):null,"cpu"===e.id&&T?(0,r.jsxs)("fieldset",{className:"mt-4 border-t border-border pt-3",children:[(0,r.jsx)("legend",{className:"sr-only",children:"CPU cores"}),(0,r.jsx)(Y,{label:`CPU cores \xb7 ${O.length} / ${F.length}`,action:(0,r.jsxs)("div",{className:"flex shrink-0 gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:()=>D(null),disabled:O.length===F.length,className:"min-h-6 rounded-sm text-xs text-muted-foreground hover:text-foreground disabled:opacity-50",children:"All cores"}),(0,r.jsx)("button",{type:"button",onClick:()=>D([]),disabled:0===O.length,"aria-label":"Unselect all CPU cores",className:"min-h-6 rounded-sm text-xs text-muted-foreground hover:text-foreground disabled:opacity-50",children:"None"})]})}),0===F.length?(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Core count unavailable."}):(0,r.jsxs)("details",{className:"mt-2",children:[(0,r.jsxs)("summary",{className:"inline-flex min-h-8 cursor-pointer items-center gap-1 rounded-md text-xs text-muted-foreground hover:text-foreground",children:["Choose cores ",(0,r.jsx)(L,{className:"h-3.5 w-3.5","aria-hidden":!0})]}),(0,r.jsx)("div",{className:"mt-2 grid max-h-48 grid-cols-3 gap-1.5 overflow-y-auto p-1",children:F.map(e=>{let t=H.has(e);return(0,r.jsxs)("label",{className:"min-w-0 cursor-pointer",children:[(0,r.jsx)("input",{type:"checkbox",checked:t,onChange:()=>{var s;return s=!t,void D(t=>{let r=$(t,F);return s?r.includes(e)?t:[...r,e]:r.filter(t=>t!==e)})},className:"peer sr-only"}),(0,r.jsxs)("span",{className:`${t?Q:X} w-full px-1.5`,children:[(0,r.jsx)("span",{"aria-hidden":!0,className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-sm border border-current",children:t?(0,r.jsx)(_,{className:"h-3 w-3"}):null}),A(e)]})]},e)})})]})]}):null]},e.id))})}),a?(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:a}):null]})})]})]})}var et=s(9429),es=s(7284),er=s(6304),en=s(4150);let ei="grid grid-cols-[3rem_minmax(0,1fr)_4.5rem] items-center gap-2 sm:grid-cols-[3.5rem_minmax(0,1fr)_4.5rem_3rem]";function ea({title:e,series:t,fromMs:s,toMs:n,stepMs:i,gaps:l,hiddenKeys:o,onToggleSeries:d}){let[c,u]=(0,a.useState)(!1),m=(0,a.useMemo)(()=>t.filter(e=>!o.has(e.key)),[t,o]),h=(0,en.Au)({series:m,fromMs:s,toMs:n,stepMs:i,gaps:l}),p=(0,a.useMemo)(()=>{let e=t.map(e=>{let t=Array(10).fill("");return(function(e,t,s,r=120){let n=Array(r).fill(null),i=Math.max(1,s-t);for(let a of e){if(a.t<t||a.t>s)continue;let e=a.max??a.avg;if(null===e||!Number.isFinite(e))continue;let l=Math.min(r-1,Math.floor((a.t-t)/i*r));n[l]=Math.max(n[l]??0,Math.min(100,Math.max(0,e)))}return n})(e.points,s,n,120).forEach((e,s)=>{if(null===e)return;let r=Math.min(9,Math.floor(e/10));t[r]+=`M${s},1h1v16h-1z`}),{...e,stats:(0,I.T6)(e.points),paths:t}});return c&&e.sort((e,t)=>(t.stats.max??-1)-(e.stats.max??-1)),e},[t,s,n,c]),x=p.filter(e=>!o.has(e.key)).reduce((e,t)=>null!==t.stats.max&&(e?.stats.max===null||null===e||t.stats.max>e.stats.max)?t:e,null),g=null===h.timeMs?null:(0,S.r6)(h.timeMs),f=Math.max(1,n-s),b=(0,I.$z)(l,s,n);return(0,r.jsxs)("figure",{className:"min-w-0 lg:col-span-full",onPointerLeave:h.clear,children:[(0,r.jsxs)("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsx)("h3",{className:"text-xs font-medium text-foreground",children:e}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-3 text-xs",children:[x?(0,r.jsxs)("span",{className:"tnum text-muted-foreground",children:["Peak \xb7 ",x.label," ",(0,r.jsx)("span",{className:"text-foreground",children:(0,S.dd)(x.stats.max,"percent")})]}):null,(0,r.jsx)("button",{type:"button","aria-pressed":c,onClick:()=>u(!c),className:`min-h-8 rounded-md border border-border px-2 ${c?"bg-selected text-foreground":"bg-background text-muted-foreground hover:text-foreground"}`,children:"Busiest first"})]})]}),(0,r.jsxs)("div",{className:`${ei} mb-1 min-h-4 whitespace-nowrap text-xs leading-4 text-muted-foreground`,"aria-hidden":!0,children:[(0,r.jsx)("span",{children:"Core"}),(0,r.jsx)("span",{className:"truncate",children:null!==g?(0,r.jsx)("span",{className:"tnum",children:g}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"sm:hidden",children:"History"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Peak usage over time"})]})}),(0,r.jsx)("span",{className:"hidden text-right sm:block",children:null!==g?"At cursor":"Last"}),(0,r.jsxs)("span",{className:"text-right",children:[(0,r.jsx)("span",{className:"hidden sm:inline",children:"Peak"}),(0,r.jsx)("span",{className:"sm:hidden",children:null!==g?"At cursor":"Peak"})]})]}),(0,r.jsx)("p",{id:`${h.id}-instructions`,className:"sr-only",children:"Focus a core chart and use Left and Right arrows to inspect recorded bucket peaks, Home or End to jump, and Escape to dismiss."}),(0,r.jsx)("div",{role:"region","aria-label":"Per-core history rows",tabIndex:0,className:"max-h-96 overflow-y-auto rounded-md",children:0===p.length?(0,r.jsx)("p",{className:"py-8 text-center text-xs text-muted-foreground",children:"No stored per-core readings."}):p.map(e=>{let t=!o.has(e.key),a=null===h.timeMs?null:(0,er.bO)(e.points,h.timeMs,i,l),c=a?.max??a?.avg??null;return(0,r.jsxs)("div",{className:`${ei} min-h-7 border-b border-border/40 text-xs`,children:[(0,r.jsxs)("label",{className:"inline-flex min-h-7 cursor-pointer items-center rounded-sm",children:[(0,r.jsx)("input",{type:"checkbox",checked:t,onChange:()=>d(e.key),className:"peer sr-only"}),(0,r.jsx)("span",{className:`${t?"text-foreground":"text-muted-foreground line-through"} rounded-sm peer-focus-visible:outline-2 peer-focus-visible:outline-accent`,children:e.label})]}),(0,r.jsxs)("svg",{viewBox:"0 0 120 18",preserveAspectRatio:"none",role:"img","aria-label":`${e.label}: ${null!==g?`${(0,S.dd)(c,"percent")} at ${g}`:`latest ${(0,S.dd)(e.stats.latest,"percent")}`}, peak ${(0,S.dd)(e.stats.max,"percent")}${t?"":", hidden"}`,"aria-describedby":`${h.id}-instructions`,tabIndex:t?0:void 0,onPointerMove:t?e=>{let t=e.currentTarget.getBoundingClientRect();h.inspect((0,er.yk)(e.clientX,t.left,t.width,s,n))}:void 0,onFocus:h.onFocus,onBlur:h.clear,onKeyDown:h.onKeyDown,className:`h-5 w-full cursor-crosshair rounded-sm focus-visible:outline-2 focus-visible:outline-accent ${t?"":"opacity-20"}`,children:[(0,r.jsx)("title",{children:`${e.label} \xb7 Last ${(0,S.dd)(e.stats.latest,"percent")} \xb7 Peak ${(0,S.dd)(e.stats.max,"percent")}`}),t?e.paths.map((e,t)=>e?(0,r.jsx)("path",{d:e,fill:t<5?"var(--cpu)":t<8?"var(--warn)":"var(--crit)",opacity:t<5?.15+.17*t:.65+t%5*.07},t):null):null,b.map(e=>(0,r.jsx)("rect",{x:(e.fromMs-s)/f*120,width:(e.toMs-e.fromMs)/f*120,y:0,height:18,fill:"var(--card)"},`${e.fromMs}-${e.toMs}`)),null!==h.timeMs?(0,r.jsx)("line",{"aria-hidden":!0,x1:(h.timeMs-s)/f*120,x2:(h.timeMs-s)/f*120,y1:0,y2:18,stroke:"var(--foreground)",strokeWidth:"1",vectorEffect:"non-scaling-stroke",pointerEvents:"none"}):null]}),(0,r.jsx)("span",{className:"tnum hidden text-right text-muted-foreground sm:block",children:t?(0,S.dd)(null!==h.timeMs?c:e.stats.latest,"percent"):"—"}),(0,r.jsxs)("span",{className:`tnum text-right ${t&&(e.stats.max??0)>=80?"text-crit":"text-muted-foreground"}`,children:[(0,r.jsx)("span",{className:"hidden sm:inline",children:t?(0,S.dd)(e.stats.max,"percent"):"—"}),(0,r.jsx)("span",{className:"sm:hidden",children:t?(0,S.dd)(null!==h.timeMs?c:e.stats.max,"percent"):"—"})]})]},e.key)})}),(0,r.jsxs)("div",{className:`${ei} mt-2 text-xs text-muted-foreground`,"aria-hidden":!0,children:[(0,r.jsx)("span",{}),(0,r.jsx)("div",{className:"flex justify-between gap-2 tnum",children:(0,I.Cf)(s,n,3).map((e,t)=>(0,r.jsx)("span",{className:1===t?"hidden sm:inline":"",children:(0,S.O5)(e,f)},e))}),(0,r.jsx)("span",{className:"hidden sm:block"}),(0,r.jsx)("span",{})]}),(0,r.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[[{label:"0–49%",color:"var(--cpu)"},{label:"50–79%",color:"var(--warn)"},{label:"80–100%",color:"var(--crit)"}].map(e=>(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,r.jsx)("span",{"aria-hidden":!0,className:"h-2 w-4 rounded-sm",style:{backgroundColor:e.color}}),e.label]},e.label)),(0,r.jsx)("span",{children:"No fill \xb7 no reading"})]})]})}function el(e,t){return`${e}\0${t}`}function eo(e,t,s,r,n){let i=(0,y.oB)(s);return null===i?[]:e.series.filter(e=>e.metric===s&&(void 0===r||e.resourceId===r)).map((e,r)=>{let a=(0,y.Lf)(i,r),l=n?.(e,i,r)??(0,y.bP)(t,s,e.resourceId);return{key:el(e.metric,e.resourceId),label:l,metric:e.metric,resourceId:e.resourceId,color:a.color,dash:a.dash,points:e.points}})}function ed(e){let{machine:t,result:s,selectedMetrics:n,hiddenCards:i,hiddenSeries:a,onToggleSeries:l}=e,[o]=q(t.machineId),d=$(o,M(t,s.series)),c=function(e){let{machine:t,result:s,selectedMetrics:r,hiddenCards:n,coreIds:i}=e,a=new Set(r),l=[];if(["cpu.usage","cpu.core","cpu.temperature","cpu.power","cpu.iowait","cpu.pressure"].filter(e=>a.has(e)).length>0){let e=[],r=["cpu.usage","cpu.iowait","cpu.pressure"].filter(e=>a.has(e));if(r.length>0&&e.push({key:"cpu.usage",title:r.length>1?"Usage & stalls":(0,y.oB)(r[0]).label,unit:"percent",series:r.flatMap(e=>eo(s,t,e,void 0,(t,s)=>"cpu.pressure"===e?"Pressure (some)":s.shortLabel)),emptyMessage:"No stored CPU readings in this range."}),a.has("cpu.core")){let r=(0,y.oB)("cpu.core"),n=M(t,s.series),a=i??$(null,n),l=function(e,t){let s=(0,y.oB)("cpu.core");if(null===s)return[];let r=new Map(e.series.filter(e=>"cpu.core"===e.metric).map(e=>[e.resourceId,e]));return t.flatMap((e,t)=>{let n=r.get(e),i=(0,y.Lf)(s,t);return[{key:el("cpu.core",e),label:A(e),metric:"cpu.core",resourceId:e,color:i.color,dash:i.dash,points:n?.points??[]}]})}(s,a),o=n.length>a.length;e.push({key:"cpu.core",title:o?`Per-core usage \xb7 ${a.length} of ${n.length}`:"Per-core usage",unit:r.unit,series:l,emptyMessage:0===n.length?"No stored per-core readings in this range.":0===a.length?"No CPU cores are selected. Choose cores under Metrics.":"No stored per-core readings for the selected cores in this range."})}if(a.has("cpu.temperature")){let r=(0,y.oB)("cpu.temperature");e.push({key:"cpu.temperature",title:"Temperature",unit:r.unit,series:eo(s,t,"cpu.temperature"),emptyMessage:"No stored CPU temperature readings in this range."})}if(a.has("cpu.power")){let r=(0,y.oB)("cpu.power");e.push({key:"cpu.power",title:"Package power",unit:r.unit,series:eo(s,t,"cpu.power"),emptyMessage:"No stored CPU package power readings in this range."})}l.push({key:"cpu",title:"CPU",charts:e})}if(["memory.used","memory.usage","memory.pressure.some","memory.pressure.full","swap.used"].filter(e=>a.has(e)).length>0){let e=[],r=["memory.used","memory.usage"].filter(e=>a.has(e));if(r.length>0){let n=r.map(e=>({unit:(0,y.oB)(e).unit,series:eo(s,t,e,void 0,()=>"RAM")}));e.push({key:"memory.capacity",title:"RAM",...n[0],unitGroup:"memory",views:n,emptyMessage:"No stored memory readings in this range."})}a.has("swap.used")&&e.push({key:"swap.used",title:"Swap",unit:"bytes",series:eo(s,t,"swap.used"),emptyMessage:"No stored swap readings in this range."});let n=["memory.pressure.some","memory.pressure.full"].filter(e=>a.has(e));if(n.length>0){let r=(0,y.oB)(n[0]),i=n.flatMap(e=>eo(s,t,e,void 0,(t,s)=>"memory.pressure.some"===e?"Some":"memory.pressure.full"===e?"Full":s.shortLabel));e.push({key:"memory.pressure",title:"Memory pressure",unit:r.unit,series:i,emptyMessage:"No stored memory pressure in this range."})}l.push({key:"memory",title:"Memory",charts:e})}let o=["gpu.utilization","gpu.memory.used","gpu.temperature","gpu.power"].filter(e=>a.has(e));if(o.length>0){let e=(0,y.ue)(t,s.series),r=e.filter(e=>!n.has(e.id));for(let n of(0===r.length&&l.push({key:"gpu-empty",title:"GPU",charts:[{key:"gpu-empty",title:"Per-card history",unit:"percent",series:[],emptyMessage:e.length>0?"All GPU cards are hidden. Re-enable a card under Metrics to see its panels.":"No supported GPU cards or stored GPU history in this range."}]}),r)){let e=o.map(e=>{let r=(0,y.oB)(e),i=function(e,t,s,r){return eo(e,t,s,r,(e,t)=>"gpu.utilization"===s?"Utilization":"gpu.memory.used"===s?"VRAM used":t.shortLabel).map(e=>({...e}))}(s,t,e,n.id),a="gpu.memory.used"===e&&null!==n.totalBytes?`of ${(0,S.dd)(n.totalBytes,"bytes")}`:void 0;return{key:`${n.id}-${e}`,title:r.shortLabel,unit:r.unit,series:i,emptyMessage:`No stored ${r.shortLabel.toLowerCase()} readings for this card in this range.`,note:a}});l.push({key:`gpu-${n.id}`,title:`GPU ${n.index+1}${n.label?` \xb7 ${n.label}`:""}`,charts:e})}}if(["fs.used","fs.usage","fs.inodes.usage"].filter(e=>a.has(e)).length>0){let e=[],r=["fs.used","fs.usage"].filter(e=>a.has(e));if(r.length>0){let n=r.map(e=>({unit:(0,y.oB)(e).unit,series:eo(s,t,e)}));e.push({key:"fs.capacity",title:"Capacity used",...n[0],unitGroup:"filesystem",views:n,emptyMessage:"No stored filesystem usage in this range."})}if(a.has("fs.inodes.usage")){let r=(0,y.oB)("fs.inodes.usage");e.push({key:"fs.inodes.usage",title:"Inodes used",unit:r.unit,series:eo(s,t,"fs.inodes.usage"),emptyMessage:"No stored inode usage in this range."})}l.push({key:"filesystems",title:"Filesystems",charts:e})}let d=["disk.read","disk.write"].filter(e=>a.has(e));if(d.length>0){let e=d.flatMap(e=>{let r=(0,y.oB)(e);return eo(s,t,e,void 0,s=>`${(0,y.bP)(t,e,s.resourceId)} ${r.shortLabel.toLowerCase()}`)});l.push({key:"disk",title:"Disk throughput",charts:[{key:"disk",title:"Read and write",unit:"bytes_per_second",series:e,emptyMessage:"No stored disk throughput in this range."}]})}let c=["disk.read.latency","disk.write.latency"].filter(e=>a.has(e)),u=["io.pressure.some","io.pressure.full"].filter(e=>a.has(e));if(c.length>0||u.length>0||a.has("disk.utilization")){let e=[];if(c.length>0){let r=c.flatMap(e=>{let r=(0,y.oB)(e);return eo(s,t,e,void 0,s=>`${(0,y.bP)(t,e,s.resourceId)} ${r.shortLabel.toLowerCase()}`)}),n=(0,y.oB)(c[0]);e.push({key:"disk.latency",title:"Latency",unit:n.unit,series:r,emptyMessage:"No stored disk latency in this range."})}if(a.has("disk.utilization")){let r=(0,y.oB)("disk.utilization");e.push({key:"disk.utilization",title:"Utilization",unit:r.unit,series:eo(s,t,"disk.utilization"),emptyMessage:"No stored disk utilization in this range."})}if(u.length>0){let r=(0,y.oB)(u[0]),n=u.flatMap(e=>eo(s,t,e,void 0,(t,s)=>"io.pressure.some"===e?"Some":"io.pressure.full"===e?"Full":s.shortLabel));e.push({key:"io.pressure",title:"I/O pressure",unit:r.unit,series:n,emptyMessage:"No stored I/O pressure in this range."})}l.push({key:"disk-health",title:"Disk health",charts:e})}let m=["net.rx","net.tx"].filter(e=>a.has(e));if(m.length>0){let e=m.flatMap(e=>{let r=(0,y.oB)(e);return eo(s,t,e,void 0,s=>`${(0,y.bP)(t,e,s.resourceId)} ${r.shortLabel.toLowerCase()}`)});l.push({key:"network",title:"Network throughput",charts:[{key:"network",title:"Received and sent",unit:"bytes_per_second",series:e,emptyMessage:"No stored network throughput in this range."}]})}return l}({machine:t,result:s,selectedMetrics:n,hiddenCards:i,coreIds:d});return(0,r.jsx)(en._C,{children:(0,r.jsx)("div",{className:"grid grid-cols-1 gap-5",children:c.map(n=>{let i=n.charts.find(e=>"cpu.core"===e.key&&e.series.length>4),o=i?[...n.charts.filter(e=>e!==i),i]:n.charts,d=i&&4===o.length?"grid gap-6 lg:grid-cols-2 xl:grid-cols-3":o.length>1&&!(i&&2===o.length)?"grid gap-6 lg:grid-cols-2":"flex flex-col gap-6";return(0,r.jsx)(h.Z,{title:n.title,children:(0,r.jsx)("div",{className:d,children:o.map((n,d)=>{let c=n.unitGroup,u=c?e.capacityUnits[c]:void 0,m=n.views?.find(e=>e.unit===u)??n.views?.[0]??n,h=n===i||!i&&o.length%2==1&&d===o.length-1;return"cpu.core"===n.key&&n.series.length>8?(0,r.jsx)(ea,{title:n.title,series:n.series,fromMs:s.fromMs,toMs:s.toMs,gaps:s.gaps,stepMs:(0,I.jl)(s.stepMs,s.tier,t.expectedIntervalMs),hiddenKeys:a,onToggleSeries:l},n.key):(0,r.jsx)(es.t,{title:n.title,unit:m.unit,series:m.series,fromMs:s.fromMs,toMs:s.toMs,stepMs:(0,I.jl)(s.stepMs,s.tier,t.expectedIntervalMs),gaps:s.gaps,hiddenKeys:a,onToggleSeries:l,emptyMessage:n.emptyMessage,note:n.note,action:c&&n.views&&n.views.length>1?(0,r.jsx)("div",{role:"group","aria-label":`${n.title} units`,className:"inline-flex rounded-md border border-border bg-background p-0.5",children:n.views.map(t=>(0,r.jsx)("button",{type:"button","aria-pressed":t.unit===m.unit,onClick:()=>e.onCapacityUnitChange(c,t.unit),className:`min-h-7 rounded px-2 text-xs transition-colors ${t.unit===m.unit?"bg-selected text-foreground":"text-muted-foreground hover:text-foreground"}`,children:"bytes"===t.unit?"Bytes":"%"},t.unit))}):void 0,maxDrawPoints:"cpu.core"===n.key?150:void 0,className:h?"lg:col-span-full":void 0},n.key)})})},n.key)})})},`${t.machineId}|${s.toMs-s.fromMs}`)}var ec=s(1),eu=s(7499);let em={raw:"raw samples","1m":"1-minute rollups","1h":"1-hour rollups"};function eh(e){return e.displayName?.trim()||e.hostname.trim()||e.machineId}function ep(e,t){return`${e}\0${t}`}function ex(e){let t=new Set(e.selectedMetrics),s=new Set((0,y.ue)(e.machine,e.result.series).filter(t=>!e.hiddenCards.has(t.id)).map(e=>e.id));return e.result.series.filter(r=>!(!t.has(r.metric)||e.hiddenSeries.has(ep(r.metric,r.resourceId))||"cpu.core"===r.metric&&void 0!==e.coreIds&&!e.coreIds.includes(r.resourceId)||r.metric.startsWith("gpu.")&&""!==r.resourceId&&!s.has(r.resourceId)))}function eg(e){return new Date(e).toISOString()}function ef(e){return(0,y.oB)(e)?.label??e}function eb(e){return ex(e).map(t=>({metric:t.metric,label:ef(t.metric),resourceId:t.resourceId,resourceLabel:(0,y.bP)(e.machine,t.metric,t.resourceId),unit:t.unit,unitLabel:(0,y.RL)(t.unit),stats:(0,I.T6)(t.points),points:t.points.map(t=>{let s=Math.min(e.result.toMs,t.t+e.result.stepMs),r=null!==t.min||null!==t.max||null!==t.avg;return{t:t.t,tIso:eg(t.t),bucketStartMs:t.t,bucketStartIso:eg(t.t),bucketEndMs:s,bucketEndIso:eg(s),min:t.min,max:t.max,avg:t.avg,state:r?"recorded":"unavailable"}})}))}function ey(e){return(0,I.$z)(e.result.gaps,e.result.fromMs,e.result.toMs).map(e=>({...e,fromIso:eg(e.fromMs),toIso:eg(e.toMs)}))}function ej(e){let t=new Set(e.result.series.map(e=>e.metric));return e.selectedMetrics.filter(e=>!t.has(e))}function ev(e){let t=new Set(e.selectedMetrics),s=new Set(ex(e).map(e=>ep(e.metric,e.resourceId)));return e.result.series.filter(e=>t.has(e.metric)&&!s.has(ep(e.metric,e.resourceId))).length}function eN(e,t){let s=e.result,r=["Only the visible series from the loaded History result are included; this export does not query more data."];"raw"!==s.tier&&r.push(`Values are ${em[s.tier]}, not individual raw samples.`),s.truncated&&r.push("The loaded result is partial: the hub limited or shortened this history query.");let n=ey(e);n.length>0&&r.push(`${n.length} recorded data gap${1===n.length?"":"s"} included.`),t.length>0&&r.push(`Selected metrics without stored data: ${t.join(", ")}.`);let i=ev(e);return i>0&&r.push(`${i} selected series hidden in this view were not exported.`),r}let ew=["record_type","metric","metric_label","resource_id","resource_label","unit","bucket_start_ms","bucket_start_iso","bucket_end_ms","bucket_end_iso","min","max","avg","value_state","gap_kind","gap_reason","gap_dropped_records"],ek="inline-flex min-h-7 items-center rounded-md border border-border bg-background px-2 text-xs text-foreground transition-colors hover:bg-card-strong disabled:cursor-not-allowed disabled:opacity-50";function eM(e){let[t,s]=(0,a.useState)(null),n=ex(e).length,i=t=>{let r=Date.now(),n={...e,exportedAt:r};try{let e,i,a,l,o,d,c,u,m=function(e,t,s=Date.now()){return(0,eu.Y8)("history",eh(e.machine),s,t)}(n,t,r),h="csv"===t?function(e){let t,s,r,n,i,a,l=e.exportedAt??Date.now(),o=(t=(0,S.ly)(e.range),s=e.result,r=ex(e),n=ej(e),i=ey(e),a=e.selectedMetrics.map(ef).join("; "),[["Rigscope History export"],["Scope","Visible series from the loaded History result"],["Machine",eh(e.machine)],["Machine ID",e.machine.machineId],["Query",a],["Range",`${t.label} (${eg(s.fromMs)} – ${eg(s.toMs)})`],["Resolution",`${em[s.tier]} \xb7 ${s.stepMs} ms buckets`],["Loaded at",eg(e.loadedAt)],["Exported at",eg(l)],["Partial",s.truncated?"true":"false"],["Gaps",String(i.length)],["Visible series",String(r.length)],["Selected without stored data",n.length>0?n.join(", "):"none"],["Note",eN(e,n).join(" ")],[]]);for(let t of(o.push([...ew]),eb(e)))for(let e of t.points)o.push(["bucket",t.metric,t.label,t.resourceId,t.resourceLabel,t.unit,e.bucketStartMs,e.bucketStartIso,e.bucketEndMs,e.bucketEndIso,e.min,e.max,e.avg,e.state,"","",""]);for(let t of ey(e))o.push(["gap","","","","","",t.fromMs,t.fromIso,t.toMs,t.toIso,"","","","gap",t.kind,t.reason??"",t.droppedRecords??""]);return(0,ec.kg)(o)}(n):(e=n.exportedAt??Date.now(),i=(0,S.ly)(n.range),a=n.result,l=eb(n),o=ej(n),d=ey(n),c=ev(n),u={app:"Rigscope",kind:"history",version:1,exportedAt:eg(e),scope:{description:"Visible series from the loaded History result",machine:{id:n.machine.machineId,name:eh(n.machine),hostname:n.machine.hostname,connected:n.machine.connected,lastReceivedAt:n.machine.lastReceivedAt},query:{range:{id:i.id,label:i.label,fromMs:a.fromMs,fromIso:eg(a.fromMs),toMs:a.toMs,toIso:eg(a.toMs)},selectedMetrics:[...n.selectedMetrics],visibleSeries:l.length,hiddenSeriesCount:c}},resolution:{tier:a.tier,label:em[a.tier],stepMs:a.stepMs,expectedIntervalMs:n.machine.expectedIntervalMs??null},loadedAt:eg(n.loadedAt),partial:a.truncated,gaps:d,series:l.map(e=>({metric:e.metric,label:e.label,resourceId:e.resourceId,resourceLabel:e.resourceLabel,unit:e.unit,unitLabel:e.unitLabel,summary:{points:e.stats.count,min:e.stats.min,max:e.stats.max,averageOfBucketAverages:e.stats.avg,latest:e.stats.latest,latestAt:null===e.stats.latestT?null:eg(e.stats.latestT),firstAt:null===e.stats.firstT?null:eg(e.stats.firstT),lastAt:null===e.stats.lastT?null:eg(e.stats.lastT)},points:e.points})),missingData:o.map(e=>({metric:e,label:ef(e),reason:"No stored series in the loaded result."})),notes:eN(n,o)},`${JSON.stringify(u,null,2)}
|
|
2
|
+
`}function o(e,t,s){if("u"<typeof document)return;let r=new Blob([t],{type:s}),n=URL.createObjectURL(r),i=document.createElement("a");i.href=n,i.download=e,i.rel="noopener",i.style.display="none",document.body.append(i),i.click(),i.remove(),globalThis.setTimeout(()=>URL.revokeObjectURL(n),0)}let d="text/csv;charset=utf-8",c="application/json;charset=utf-8"},438:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(8698).A)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},2910:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(8698).A)("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]])},2939:(e,t,s)=>{"use strict";s.d(t,{HistoryView:()=>eI});var r=s(5155),n=s(8500),i=s.n(n),a=s(2115),l=s(7422),o=s(3896),d=s(1735),c=s(7029),u=s(828),m=s(4173),h=s(3440),p=s(940),x=s(802),g=s(6582),f=s(9939),b=s(8664),y=s(4567),j=s(592);let v=j.U8,N=/^core:(\d+)$/;function w(e){let t=N.exec(e);if(null===t)return null;let s=Number(t[1]);return!Number.isSafeInteger(s)||s<0||s>=j.U8?null:s}function k(e){return[...new Set(e)].sort((e,t)=>(w(e)??0)-(w(t)??0))}function M(e,t=[]){var s;let r=e?.metrics?.payload.cpu,n=new Set(!Number.isFinite(s=Math.max(e?.inventory?.cpu.logicalCores??0,r?.status==="ok"?r.perCore.length:0))?[]:Array.from({length:Math.min(j.U8,Math.max(0,Math.floor(s)))},(e,t)=>`core:${t}`));for(let e of t)"cpu.core"===e.metric&&null!==w(e.resourceId)&&n.add(e.resourceId);return k([...n])}function $(e,t){let s=new Set(t);if(null===e)return k(t).slice(0,v);let r=[];for(let t of e)if(s.has(t)&&null!==w(t)&&(r.push(t),r.length>=v))break;return k(r)}function A(e){let t=w(e);return null===t?e:`Core ${t}`}var I=s(7726);function C(e){if("string"!=typeof e||0===e.length)return null;let t=Date.parse(e);return Number.isFinite(t)?t:null}var S=s(5078),R=s(2910),P=s(9942),U=s(8698);let L=(0,U.A)("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),_=(0,U.A)("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);var B=s(6114);let T=Object.freeze([]),z=new Set(y.H9.map(e=>e.metric)),E=e=>"boolean"==typeof e?e:null,D=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e)?e.slice(0,1e3):null,F=e=>S.pI.some(t=>t.id===e)?e:null,O=e=>"string"==typeof e&&(""===e||e.split(",").every(e=>z.has(e)))?e:null,H=/^core:\d+$/,Z=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e&&H.test(e))?[...new Set(e)].slice(0,j.U8):null;function G(e,t){return(0,B.u)(`history.hidden.${t}.${e}`,T,D)}function q(e){return(0,B.u)(`history.cores.${e}`,null,Z)}let V=e=>"bytes"===e||"percent"===e?e:null;function W(e,t){return(0,B.u)(`history.units.${t}.${e}`,"bytes",V)}let K="peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:[outline-color:var(--focus)]";function Y({label:e,action:t}){return(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:e}),(0,r.jsx)("span",{"aria-hidden":!0,className:"h-px min-w-0 flex-1 bg-border"}),t]})}let J="inline-flex min-h-8 items-center gap-1.5 rounded-md border border-transparent px-2.5 text-xs transition-colors",Q=`${J} ${K} bg-selected text-foreground`,X=`${J} ${K} bg-card-strong text-muted-foreground hover:text-foreground`;function ee(e){let{machine:t,range:s,selectedMetrics:n,catalog:i,catalogError:a,gpuCards:l,hiddenCards:o,autoRefresh:d,loading:c,manualRefreshing:m,statusText:h,onRangeChange:p,onToggleMetric:x,onSetMetrics:g,onToggleCard:f,onToggleAutoRefresh:b,onRefresh:j}=e,[v,N]=(0,B.u)("history.controlsOpen",!1,E,"session"),w=new Set(n),k=y.H9.filter(({metric:e})=>(0,y.yv)(t,e).available&&(null===i||void 0!==i[e])).map(({metric:e})=>e),I=new Set(k),C=(e,t)=>{let s=new Set(n);for(let r of e)t&&I.has(r)?s.add(r):t||s.delete(r);g([...s])},U=n.some(e=>e.startsWith("gpu.")),T=w.has("cpu.core"),[z,D]=q(t?.machineId??""),F=T?M(t):[],O=$(z,F),H=new Set(O);return(0,r.jsxs)("section",{"aria-labelledby":"history-query-heading","aria-busy":c,className:"mb-5 min-w-0 rounded-xl border border-border bg-card",children:[(0,r.jsx)("h2",{id:"history-query-heading",className:"sr-only",children:"History query"}),(0,r.jsxs)("div",{className:"flex flex-wrap items-end gap-x-5 gap-y-4 p-4 md:p-5",children:[(0,r.jsxs)("fieldset",{className:"flex min-w-0 flex-col gap-1.5",children:[(0,r.jsx)("legend",{className:"mb-1.5 text-xs text-muted-foreground",children:"Time range"}),(0,r.jsx)("div",{className:"inline-flex flex-wrap rounded-lg border border-border bg-background p-0.5",children:S.pI.map(e=>{let t=s===e.id;return(0,r.jsxs)("label",{className:"cursor-pointer",children:[(0,r.jsx)("input",{type:"radio",name:"history-range",value:e.id,checked:t,onChange:()=>p(e.id),className:"peer sr-only"}),(0,r.jsxs)("span",{className:`inline-flex min-h-8 items-center rounded-md px-2.5 text-xs transition-colors ${K} ${t?"bg-selected font-medium text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[e.shortLabel,(0,r.jsxs)("span",{className:"sr-only",children:[" — ",e.label]})]})]},e.id)})})]}),(0,r.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2 sm:ml-auto",children:[(0,r.jsx)("p",{className:"order-first w-full text-xs text-muted-foreground sm:order-none sm:w-auto",children:h}),(0,r.jsxs)("button",{type:"button",onClick:j,disabled:m,className:"inline-flex min-h-8 items-center gap-1.5 rounded-md border border-border bg-background px-2.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-60",children:[(0,r.jsx)(u.A,{className:`h-3.5 w-3.5 ${m?"animate-spin":""}`,"aria-hidden":!0}),"Refresh"]}),(0,r.jsxs)("button",{type:"button",onClick:b,"aria-pressed":d,className:`inline-flex min-h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs transition-colors ${d?"border-accent/40 bg-selected text-foreground":"border-border bg-background text-muted-foreground hover:bg-card-strong hover:text-foreground"}`,children:[d?(0,r.jsx)(R.A,{className:"h-3.5 w-3.5","aria-hidden":!0}):(0,r.jsx)(P.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),d?"Pause":"Resume"]})]})]}),(0,r.jsxs)("div",{className:"border-t border-border px-4 py-4 md:px-5",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsxs)("button",{type:"button","aria-expanded":v,"aria-controls":"history-metric-options",onClick:()=>N(!v),className:"inline-flex min-h-8 items-center gap-1.5 rounded-md text-sm font-medium",children:["Metrics ",(0,r.jsxs)("span",{className:"tnum text-xs font-normal text-muted-foreground",children:[w.size," selected"]}),(0,r.jsx)(L,{"aria-hidden":!0,className:`h-3.5 w-3.5 text-muted-foreground transition-transform ${v?"rotate-180":""}`})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:()=>C(k,!0),disabled:k.every(e=>w.has(e)),className:"inline-flex min-h-8 items-center rounded-md border border-border bg-background px-2.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Select all"}),(0,r.jsx)("button",{type:"button",onClick:()=>g([]),disabled:0===w.size,className:"inline-flex min-h-8 items-center rounded-md border border-border bg-background px-2.5 text-xs text-foreground transition-colors hover:bg-card-strong disabled:opacity-50",children:"Unselect all"})]})]}),(0,r.jsx)("div",{id:"history-metric-options",hidden:!v,children:(0,r.jsxs)("div",{className:"mt-4 min-w-0 md:col-span-2",children:[(0,r.jsx)("div",{className:"min-w-0",children:(0,r.jsx)("div",{className:"grid gap-x-6 gap-y-5 md:grid-cols-2 xl:grid-cols-3",children:y.P$.map(e=>(0,r.jsxs)("fieldset",{className:`min-w-0 ${"disk"===e.id?"xl:col-span-2":""}`,children:[(0,r.jsx)("legend",{className:"sr-only",children:e.label}),(0,r.jsx)(Y,{label:e.label,action:(0,r.jsxs)("div",{className:"flex shrink-0 gap-2",children:[(0,r.jsx)("button",{type:"button","aria-label":`Select all ${e.label} metrics`,onClick:()=>C(e.metrics,!0),disabled:e.metrics.filter(e=>I.has(e)).every(e=>w.has(e)),className:"min-h-6 rounded-sm text-xs text-muted-foreground hover:text-foreground hover:underline disabled:opacity-50",children:"All"}),(0,r.jsx)("button",{type:"button","aria-label":`Unselect all ${e.label} metrics`,onClick:()=>C(e.metrics,!1),disabled:!e.metrics.some(e=>w.has(e)),className:"min-h-6 rounded-sm text-xs text-muted-foreground hover:text-foreground hover:underline disabled:opacity-50",children:"None"})]})}),(0,r.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:e.metrics.map(e=>{var s;let n=(0,y.oB)(e);if(null===n)return null;let a=(0,y.yv)(t,e),l=null===i||void 0!==i[e],o=a.available&&l,d=w.has(e),c=(0,y.Lf)(n,0);return(0,r.jsxs)("label",{className:o?"cursor-pointer":"cursor-not-allowed",title:a.available?l?n.description:"This hub does not record this metric.":a.reason??void 0,children:[(0,r.jsx)("input",{type:"checkbox",checked:d,onChange:()=>x(e),disabled:!o&&!d,className:"peer sr-only","aria-label":n.label}),(0,r.jsxs)("span",{className:`${!o?d?`${J} ${K} bg-card-strong text-muted-foreground line-through`:`${J} text-muted-foreground opacity-50`:d?Q:X}`,children:[(0,r.jsx)("span",{"aria-hidden":!0,className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-sm border border-current",style:{color:c.color},children:d?(0,r.jsx)(_,{className:"h-3 w-3",strokeWidth:3}):null}),(s=n.label,({"cpu.usage":"Usage","cpu.core":"Per-core","cpu.iowait":"I/O wait","cpu.pressure":"Pressure","cpu.temperature":"Temperature","cpu.power":"Package power","memory.used":"Used bytes","memory.usage":"Usage %","swap.used":"Swap","memory.pressure.some":"Pressure (some)","memory.pressure.full":"Pressure (full)","gpu.utilization":"Utilization","gpu.memory.used":"VRAM","gpu.temperature":"Temperature","gpu.power":"Power","fs.used":"Space used","fs.usage":"Capacity %","fs.inodes.usage":"Inodes %","net.rx":"Received","net.tx":"Sent"})[e]??s)]})]},e)})}),"gpu"===e.id&&U&&l.length>0?(0,r.jsxs)("fieldset",{className:"mt-4 border-t border-border pt-3",children:[(0,r.jsx)("legend",{className:"sr-only",children:"GPU cards"}),(0,r.jsx)(Y,{label:"GPU cards"}),(0,r.jsx)("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:l.map((e,t)=>{let s=e.id,n=!o.has(s);return(0,r.jsxs)("label",{className:"cursor-pointer",children:[(0,r.jsx)("input",{type:"checkbox",checked:n,onChange:()=>f(s),className:"peer sr-only"}),(0,r.jsxs)("span",{className:n?Q:X,children:[(0,r.jsx)("span",{className:"tnum text-xs text-muted-foreground",children:t+1}),e.label]})]},e.id)})})]}):null,"cpu"===e.id&&T?(0,r.jsxs)("fieldset",{className:"mt-4 border-t border-border pt-3",children:[(0,r.jsx)("legend",{className:"sr-only",children:"CPU cores"}),(0,r.jsx)(Y,{label:`CPU cores \xb7 ${O.length} / ${F.length}`,action:(0,r.jsxs)("div",{className:"flex shrink-0 gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:()=>D(null),disabled:O.length===F.length,className:"min-h-6 rounded-sm text-xs text-muted-foreground hover:text-foreground disabled:opacity-50",children:"All cores"}),(0,r.jsx)("button",{type:"button",onClick:()=>D([]),disabled:0===O.length,"aria-label":"Unselect all CPU cores",className:"min-h-6 rounded-sm text-xs text-muted-foreground hover:text-foreground disabled:opacity-50",children:"None"})]})}),0===F.length?(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Core count unavailable."}):(0,r.jsxs)("details",{className:"mt-2",children:[(0,r.jsxs)("summary",{className:"inline-flex min-h-8 cursor-pointer items-center gap-1 rounded-md text-xs text-muted-foreground hover:text-foreground",children:["Choose cores ",(0,r.jsx)(L,{className:"h-3.5 w-3.5","aria-hidden":!0})]}),(0,r.jsx)("div",{className:"mt-2 grid max-h-48 grid-cols-3 gap-1.5 overflow-y-auto p-1",children:F.map(e=>{let t=H.has(e);return(0,r.jsxs)("label",{className:"min-w-0 cursor-pointer",children:[(0,r.jsx)("input",{type:"checkbox",checked:t,onChange:()=>{var s;return s=!t,void D(t=>{let r=$(t,F);return s?r.includes(e)?t:[...r,e]:r.filter(t=>t!==e)})},className:"peer sr-only"}),(0,r.jsxs)("span",{className:`${t?Q:X} w-full px-1.5`,children:[(0,r.jsx)("span",{"aria-hidden":!0,className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-sm border border-current",children:t?(0,r.jsx)(_,{className:"h-3 w-3"}):null}),A(e)]})]},e)})})]})]}):null]},e.id))})}),a?(0,r.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:a}):null]})})]})]})}var et=s(9429),es=s(7284),er=s(6304),en=s(4150);let ei="grid grid-cols-[3rem_minmax(0,1fr)_4.5rem] items-center gap-2 sm:grid-cols-[3.5rem_minmax(0,1fr)_4.5rem_3rem]";function ea({title:e,series:t,fromMs:s,toMs:n,stepMs:i,gaps:l,hiddenKeys:o,onToggleSeries:d}){let[c,u]=(0,a.useState)(!1),m=(0,a.useMemo)(()=>t.filter(e=>!o.has(e.key)),[t,o]),h=(0,en.Au)({series:m,fromMs:s,toMs:n,stepMs:i,gaps:l}),p=(0,a.useMemo)(()=>{let e=t.map(e=>{let t=Array(10).fill("");return(function(e,t,s,r=120){let n=Array(r).fill(null),i=Math.max(1,s-t);for(let a of e){if(a.t<t||a.t>s)continue;let e=a.max??a.avg;if(null===e||!Number.isFinite(e))continue;let l=Math.min(r-1,Math.floor((a.t-t)/i*r));n[l]=Math.max(n[l]??0,Math.min(100,Math.max(0,e)))}return n})(e.points,s,n,120).forEach((e,s)=>{if(null===e)return;let r=Math.min(9,Math.floor(e/10));t[r]+=`M${s},1h1v16h-1z`}),{...e,stats:(0,I.T6)(e.points),paths:t}});return c&&e.sort((e,t)=>(t.stats.max??-1)-(e.stats.max??-1)),e},[t,s,n,c]),x=p.filter(e=>!o.has(e.key)).reduce((e,t)=>null!==t.stats.max&&(e?.stats.max===null||null===e||t.stats.max>e.stats.max)?t:e,null),g=null===h.timeMs?null:(0,S.r6)(h.timeMs),f=Math.max(1,n-s),b=(0,I.$z)(l,s,n);return(0,r.jsxs)("figure",{className:"min-w-0 lg:col-span-full",onPointerLeave:h.clear,children:[(0,r.jsxs)("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[(0,r.jsx)("h3",{className:"text-xs font-medium text-foreground",children:e}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-3 text-xs",children:[x?(0,r.jsxs)("span",{className:"tnum text-muted-foreground",children:["Peak \xb7 ",x.label," ",(0,r.jsx)("span",{className:"text-foreground",children:(0,S.dd)(x.stats.max,"percent")})]}):null,(0,r.jsx)("button",{type:"button","aria-pressed":c,onClick:()=>u(!c),className:`min-h-8 rounded-md border border-border px-2 ${c?"bg-selected text-foreground":"bg-background text-muted-foreground hover:text-foreground"}`,children:"Busiest first"})]})]}),(0,r.jsxs)("div",{className:`${ei} mb-1 min-h-4 whitespace-nowrap text-xs leading-4 text-muted-foreground`,"aria-hidden":!0,children:[(0,r.jsx)("span",{children:"Core"}),(0,r.jsx)("span",{className:"truncate",children:null!==g?(0,r.jsx)("span",{className:"tnum",children:g}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"sm:hidden",children:"History"}),(0,r.jsx)("span",{className:"hidden sm:inline",children:"Peak usage over time"})]})}),(0,r.jsx)("span",{className:"hidden text-right sm:block",children:null!==g?"At cursor":"Last"}),(0,r.jsxs)("span",{className:"text-right",children:[(0,r.jsx)("span",{className:"hidden sm:inline",children:"Peak"}),(0,r.jsx)("span",{className:"sm:hidden",children:null!==g?"At cursor":"Peak"})]})]}),(0,r.jsx)("p",{id:`${h.id}-instructions`,className:"sr-only",children:"Focus a core chart and use Left and Right arrows to inspect recorded bucket peaks, Home or End to jump, and Escape to dismiss."}),(0,r.jsx)("div",{role:"region","aria-label":"Per-core history rows",tabIndex:0,className:"max-h-96 overflow-y-auto rounded-md",children:0===p.length?(0,r.jsx)("p",{className:"py-8 text-center text-xs text-muted-foreground",children:"No stored per-core readings."}):p.map(e=>{let t=!o.has(e.key),a=null===h.timeMs?null:(0,er.bO)(e.points,h.timeMs,i,l),c=a?.max??a?.avg??null;return(0,r.jsxs)("div",{className:`${ei} min-h-7 border-b border-border/40 text-xs`,children:[(0,r.jsxs)("label",{className:"inline-flex min-h-7 cursor-pointer items-center rounded-sm",children:[(0,r.jsx)("input",{type:"checkbox",checked:t,onChange:()=>d(e.key),className:"peer sr-only"}),(0,r.jsx)("span",{className:`${t?"text-foreground":"text-muted-foreground line-through"} rounded-sm peer-focus-visible:outline-2 peer-focus-visible:outline-accent`,children:e.label})]}),(0,r.jsxs)("svg",{viewBox:"0 0 120 18",preserveAspectRatio:"none",role:"img","aria-label":`${e.label}: ${null!==g?`${(0,S.dd)(c,"percent")} at ${g}`:`latest ${(0,S.dd)(e.stats.latest,"percent")}`}, peak ${(0,S.dd)(e.stats.max,"percent")}${t?"":", hidden"}`,"aria-describedby":`${h.id}-instructions`,tabIndex:t?0:void 0,onPointerMove:t?e=>{let t=e.currentTarget.getBoundingClientRect();h.inspect((0,er.yk)(e.clientX,t.left,t.width,s,n))}:void 0,onFocus:h.onFocus,onBlur:h.clear,onKeyDown:h.onKeyDown,className:`h-5 w-full cursor-crosshair rounded-sm focus-visible:outline-2 focus-visible:outline-accent ${t?"":"opacity-20"}`,children:[(0,r.jsx)("title",{children:`${e.label} \xb7 Last ${(0,S.dd)(e.stats.latest,"percent")} \xb7 Peak ${(0,S.dd)(e.stats.max,"percent")}`}),t?e.paths.map((e,t)=>e?(0,r.jsx)("path",{d:e,fill:t<5?"var(--cpu)":t<8?"var(--warn)":"var(--crit)",opacity:t<5?.15+.17*t:.65+t%5*.07},t):null):null,b.map(e=>(0,r.jsx)("rect",{x:(e.fromMs-s)/f*120,width:(e.toMs-e.fromMs)/f*120,y:0,height:18,fill:"var(--card)"},`${e.fromMs}-${e.toMs}`)),null!==h.timeMs?(0,r.jsx)("line",{"aria-hidden":!0,x1:(h.timeMs-s)/f*120,x2:(h.timeMs-s)/f*120,y1:0,y2:18,stroke:"var(--foreground)",strokeWidth:"1",vectorEffect:"non-scaling-stroke",pointerEvents:"none"}):null]}),(0,r.jsx)("span",{className:"tnum hidden text-right text-muted-foreground sm:block",children:t?(0,S.dd)(null!==h.timeMs?c:e.stats.latest,"percent"):"—"}),(0,r.jsxs)("span",{className:`tnum text-right ${t&&(e.stats.max??0)>=80?"text-crit":"text-muted-foreground"}`,children:[(0,r.jsx)("span",{className:"hidden sm:inline",children:t?(0,S.dd)(e.stats.max,"percent"):"—"}),(0,r.jsx)("span",{className:"sm:hidden",children:t?(0,S.dd)(null!==h.timeMs?c:e.stats.max,"percent"):"—"})]})]},e.key)})}),(0,r.jsxs)("div",{className:`${ei} mt-2 text-xs text-muted-foreground`,"aria-hidden":!0,children:[(0,r.jsx)("span",{}),(0,r.jsx)("div",{className:"flex justify-between gap-2 tnum",children:(0,I.Cf)(s,n,3).map((e,t)=>(0,r.jsx)("span",{className:1===t?"hidden sm:inline":"",children:(0,S.O5)(e,f)},e))}),(0,r.jsx)("span",{className:"hidden sm:block"}),(0,r.jsx)("span",{})]}),(0,r.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[[{label:"0–49%",color:"var(--cpu)"},{label:"50–79%",color:"var(--warn)"},{label:"80–100%",color:"var(--crit)"}].map(e=>(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,r.jsx)("span",{"aria-hidden":!0,className:"h-2 w-4 rounded-sm",style:{backgroundColor:e.color}}),e.label]},e.label)),(0,r.jsx)("span",{children:"No fill \xb7 no reading"})]})]})}function el(e,t){return`${e}\0${t}`}function eo(e,t,s,r,n){let i=(0,y.oB)(s);return null===i?[]:e.series.filter(e=>e.metric===s&&(void 0===r||e.resourceId===r)).map((e,r)=>{let a=(0,y.Lf)(i,r),l=n?.(e,i,r)??(0,y.bP)(t,s,e.resourceId);return{key:el(e.metric,e.resourceId),label:l,metric:e.metric,resourceId:e.resourceId,color:a.color,dash:a.dash,points:e.points}})}function ed(e){let{machine:t,result:s,selectedMetrics:n,hiddenCards:i,hiddenSeries:a,onToggleSeries:l}=e,[o]=q(t.machineId),d=$(o,M(t,s.series)),c=function(e){let{machine:t,result:s,selectedMetrics:r,hiddenCards:n,coreIds:i}=e,a=new Set(r),l=[];if(["cpu.usage","cpu.core","cpu.temperature","cpu.power","cpu.iowait","cpu.pressure"].filter(e=>a.has(e)).length>0){let e=[],r=["cpu.usage","cpu.iowait","cpu.pressure"].filter(e=>a.has(e));if(r.length>0&&e.push({key:"cpu.usage",title:r.length>1?"Usage & stalls":(0,y.oB)(r[0]).label,unit:"percent",series:r.flatMap(e=>eo(s,t,e,void 0,(t,s)=>"cpu.pressure"===e?"Pressure (some)":s.shortLabel)),emptyMessage:"No stored CPU readings in this range."}),a.has("cpu.core")){let r=(0,y.oB)("cpu.core"),n=M(t,s.series),a=i??$(null,n),l=function(e,t){let s=(0,y.oB)("cpu.core");if(null===s)return[];let r=new Map(e.series.filter(e=>"cpu.core"===e.metric).map(e=>[e.resourceId,e]));return t.flatMap((e,t)=>{let n=r.get(e),i=(0,y.Lf)(s,t);return[{key:el("cpu.core",e),label:A(e),metric:"cpu.core",resourceId:e,color:i.color,dash:i.dash,points:n?.points??[]}]})}(s,a),o=n.length>a.length;e.push({key:"cpu.core",title:o?`Per-core usage \xb7 ${a.length} of ${n.length}`:"Per-core usage",unit:r.unit,series:l,emptyMessage:0===n.length?"No stored per-core readings in this range.":0===a.length?"No CPU cores are selected. Choose cores under Metrics.":"No stored per-core readings for the selected cores in this range."})}if(a.has("cpu.temperature")){let r=(0,y.oB)("cpu.temperature");e.push({key:"cpu.temperature",title:"Temperature",unit:r.unit,series:eo(s,t,"cpu.temperature"),emptyMessage:"No stored CPU temperature readings in this range."})}if(a.has("cpu.power")){let r=(0,y.oB)("cpu.power");e.push({key:"cpu.power",title:"Package power",unit:r.unit,series:eo(s,t,"cpu.power"),emptyMessage:"No stored CPU package power readings in this range."})}l.push({key:"cpu",title:"CPU",charts:e})}if(["memory.used","memory.usage","memory.pressure.some","memory.pressure.full","swap.used"].filter(e=>a.has(e)).length>0){let e=[],r=["memory.used","memory.usage"].filter(e=>a.has(e));if(r.length>0){let n=r.map(e=>({unit:(0,y.oB)(e).unit,series:eo(s,t,e,void 0,()=>"RAM")}));e.push({key:"memory.capacity",title:"RAM",...n[0],unitGroup:"memory",views:n,emptyMessage:"No stored memory readings in this range."})}a.has("swap.used")&&e.push({key:"swap.used",title:"Swap",unit:"bytes",series:eo(s,t,"swap.used"),emptyMessage:"No stored swap readings in this range."});let n=["memory.pressure.some","memory.pressure.full"].filter(e=>a.has(e));if(n.length>0){let r=(0,y.oB)(n[0]),i=n.flatMap(e=>eo(s,t,e,void 0,(t,s)=>"memory.pressure.some"===e?"Some":"memory.pressure.full"===e?"Full":s.shortLabel));e.push({key:"memory.pressure",title:"Memory pressure",unit:r.unit,series:i,emptyMessage:"No stored memory pressure in this range."})}l.push({key:"memory",title:"Memory",charts:e})}let o=["gpu.utilization","gpu.memory.used","gpu.temperature","gpu.power"].filter(e=>a.has(e));if(o.length>0){let e=(0,y.ue)(t,s.series),r=e.filter(e=>!n.has(e.id));for(let n of(0===r.length&&l.push({key:"gpu-empty",title:"GPU",charts:[{key:"gpu-empty",title:"Per-card history",unit:"percent",series:[],emptyMessage:e.length>0?"All GPU cards are hidden. Re-enable a card under Metrics to see its panels.":"No supported GPU cards or stored GPU history in this range."}]}),r)){let e=o.map(e=>{let r=(0,y.oB)(e),i=function(e,t,s,r){return eo(e,t,s,r,(e,t)=>"gpu.utilization"===s?"Utilization":"gpu.memory.used"===s?"VRAM used":t.shortLabel).map(e=>({...e}))}(s,t,e,n.id),a="gpu.memory.used"===e&&null!==n.totalBytes?`of ${(0,S.dd)(n.totalBytes,"bytes")}`:void 0;return{key:`${n.id}-${e}`,title:r.shortLabel,unit:r.unit,series:i,emptyMessage:`No stored ${r.shortLabel.toLowerCase()} readings for this card in this range.`,note:a}});l.push({key:`gpu-${n.id}`,title:`GPU ${n.index+1}${n.label?` \xb7 ${n.label}`:""}`,charts:e})}}if(["fs.used","fs.usage","fs.inodes.usage"].filter(e=>a.has(e)).length>0){let e=[],r=["fs.used","fs.usage"].filter(e=>a.has(e));if(r.length>0){let n=r.map(e=>({unit:(0,y.oB)(e).unit,series:eo(s,t,e)}));e.push({key:"fs.capacity",title:"Capacity used",...n[0],unitGroup:"filesystem",views:n,emptyMessage:"No stored filesystem usage in this range."})}if(a.has("fs.inodes.usage")){let r=(0,y.oB)("fs.inodes.usage");e.push({key:"fs.inodes.usage",title:"Inodes used",unit:r.unit,series:eo(s,t,"fs.inodes.usage"),emptyMessage:"No stored inode usage in this range."})}l.push({key:"filesystems",title:"Filesystems",charts:e})}let d=["disk.read","disk.write"].filter(e=>a.has(e));if(d.length>0){let e=d.flatMap(e=>{let r=(0,y.oB)(e);return eo(s,t,e,void 0,s=>`${(0,y.bP)(t,e,s.resourceId)} ${r.shortLabel.toLowerCase()}`)});l.push({key:"disk",title:"Disk throughput",charts:[{key:"disk",title:"Read and write",unit:"bytes_per_second",series:e,emptyMessage:"No stored disk throughput in this range."}]})}let c=["disk.read.latency","disk.write.latency"].filter(e=>a.has(e)),u=["io.pressure.some","io.pressure.full"].filter(e=>a.has(e));if(c.length>0||u.length>0||a.has("disk.utilization")){let e=[];if(c.length>0){let r=c.flatMap(e=>{let r=(0,y.oB)(e);return eo(s,t,e,void 0,s=>`${(0,y.bP)(t,e,s.resourceId)} ${r.shortLabel.toLowerCase()}`)}),n=(0,y.oB)(c[0]);e.push({key:"disk.latency",title:"Latency",unit:n.unit,series:r,emptyMessage:"No stored disk latency in this range."})}if(a.has("disk.utilization")){let r=(0,y.oB)("disk.utilization");e.push({key:"disk.utilization",title:"Utilization",unit:r.unit,series:eo(s,t,"disk.utilization"),emptyMessage:"No stored disk utilization in this range."})}if(u.length>0){let r=(0,y.oB)(u[0]),n=u.flatMap(e=>eo(s,t,e,void 0,(t,s)=>"io.pressure.some"===e?"Some":"io.pressure.full"===e?"Full":s.shortLabel));e.push({key:"io.pressure",title:"I/O pressure",unit:r.unit,series:n,emptyMessage:"No stored I/O pressure in this range."})}l.push({key:"disk-health",title:"Disk health",charts:e})}let m=["net.rx","net.tx"].filter(e=>a.has(e));if(m.length>0){let e=m.flatMap(e=>{let r=(0,y.oB)(e);return eo(s,t,e,void 0,s=>`${(0,y.bP)(t,e,s.resourceId)} ${r.shortLabel.toLowerCase()}`)});l.push({key:"network",title:"Network throughput",charts:[{key:"network",title:"Received and sent",unit:"bytes_per_second",series:e,emptyMessage:"No stored network throughput in this range."}]})}return l}({machine:t,result:s,selectedMetrics:n,hiddenCards:i,coreIds:d});return(0,r.jsx)(en._C,{children:(0,r.jsx)("div",{className:"grid grid-cols-1 gap-5",children:c.map(n=>{let i=n.charts.find(e=>"cpu.core"===e.key&&e.series.length>4),o=i?[...n.charts.filter(e=>e!==i),i]:n.charts,d=i&&4===o.length?"grid gap-6 lg:grid-cols-2 xl:grid-cols-3":o.length>1&&!(i&&2===o.length)?"grid gap-6 lg:grid-cols-2":"flex flex-col gap-6";return(0,r.jsx)(h.Z,{title:n.title,children:(0,r.jsx)("div",{className:d,children:o.map((n,d)=>{let c=n.unitGroup,u=c?e.capacityUnits[c]:void 0,m=n.views?.find(e=>e.unit===u)??n.views?.[0]??n,h=n===i||!i&&o.length%2==1&&d===o.length-1;return"cpu.core"===n.key&&n.series.length>8?(0,r.jsx)(ea,{title:n.title,series:n.series,fromMs:s.fromMs,toMs:s.toMs,gaps:s.gaps,stepMs:(0,I.jl)(s.stepMs,s.tier,t.expectedIntervalMs),hiddenKeys:a,onToggleSeries:l},n.key):(0,r.jsx)(es.t,{title:n.title,unit:m.unit,series:m.series,fromMs:s.fromMs,toMs:s.toMs,stepMs:(0,I.jl)(s.stepMs,s.tier,t.expectedIntervalMs),gaps:s.gaps,hiddenKeys:a,onToggleSeries:l,emptyMessage:n.emptyMessage,note:n.note,action:c&&n.views&&n.views.length>1?(0,r.jsx)("div",{role:"group","aria-label":`${n.title} units`,className:"inline-flex rounded-md border border-border bg-background p-0.5",children:n.views.map(t=>(0,r.jsx)("button",{type:"button","aria-pressed":t.unit===m.unit,onClick:()=>e.onCapacityUnitChange(c,t.unit),className:`min-h-7 rounded px-2 text-xs transition-colors ${t.unit===m.unit?"bg-selected text-foreground":"text-muted-foreground hover:text-foreground"}`,children:"bytes"===t.unit?"Bytes":"%"},t.unit))}):void 0,maxDrawPoints:"cpu.core"===n.key?150:void 0,className:h?"lg:col-span-full":void 0},n.key)})})},n.key)})})},`${t.machineId}|${s.toMs-s.fromMs}`)}var ec=s(1),eu=s(7499);let em={raw:"raw samples","1m":"1-minute rollups","1h":"1-hour rollups"};function eh(e){return e.displayName?.trim()||e.hostname.trim()||e.machineId}function ep(e,t){return`${e}\0${t}`}function ex(e){let t=new Set(e.selectedMetrics),s=new Set((0,y.ue)(e.machine,e.result.series).filter(t=>!e.hiddenCards.has(t.id)).map(e=>e.id));return e.result.series.filter(r=>!(!t.has(r.metric)||e.hiddenSeries.has(ep(r.metric,r.resourceId))||"cpu.core"===r.metric&&void 0!==e.coreIds&&!e.coreIds.includes(r.resourceId)||r.metric.startsWith("gpu.")&&""!==r.resourceId&&!s.has(r.resourceId)))}function eg(e){return new Date(e).toISOString()}function ef(e){return(0,y.oB)(e)?.label??e}function eb(e){return ex(e).map(t=>({metric:t.metric,label:ef(t.metric),resourceId:t.resourceId,resourceLabel:(0,y.bP)(e.machine,t.metric,t.resourceId),unit:t.unit,unitLabel:(0,y.RL)(t.unit),stats:(0,I.T6)(t.points),points:t.points.map(t=>{let s=Math.min(e.result.toMs,t.t+e.result.stepMs),r=null!==t.min||null!==t.max||null!==t.avg;return{t:t.t,tIso:eg(t.t),bucketStartMs:t.t,bucketStartIso:eg(t.t),bucketEndMs:s,bucketEndIso:eg(s),min:t.min,max:t.max,avg:t.avg,state:r?"recorded":"unavailable"}})}))}function ey(e){return(0,I.$z)(e.result.gaps,e.result.fromMs,e.result.toMs).map(e=>({...e,fromIso:eg(e.fromMs),toIso:eg(e.toMs)}))}function ej(e){let t=new Set(e.result.series.map(e=>e.metric));return e.selectedMetrics.filter(e=>!t.has(e))}function ev(e){let t=new Set(e.selectedMetrics),s=new Set(ex(e).map(e=>ep(e.metric,e.resourceId)));return e.result.series.filter(e=>t.has(e.metric)&&!s.has(ep(e.metric,e.resourceId))).length}function eN(e,t){let s=e.result,r=["Only the visible series from the loaded History result are included; this export does not query more data."];"raw"!==s.tier&&r.push(`Values are ${em[s.tier]}, not individual raw samples.`),s.truncated&&r.push("The loaded result is partial: the hub limited or shortened this history query.");let n=ey(e);n.length>0&&r.push(`${n.length} recorded data gap${1===n.length?"":"s"} included.`),t.length>0&&r.push(`Selected metrics without stored data: ${t.join(", ")}.`);let i=ev(e);return i>0&&r.push(`${i} selected series hidden in this view were not exported.`),r}let ew=["record_type","metric","metric_label","resource_id","resource_label","unit","bucket_start_ms","bucket_start_iso","bucket_end_ms","bucket_end_iso","min","max","avg","value_state","gap_kind","gap_reason","gap_dropped_records"],ek="inline-flex min-h-7 items-center rounded-md border border-border bg-background px-2 text-xs text-foreground transition-colors hover:bg-card-strong disabled:cursor-not-allowed disabled:opacity-50";function eM(e){let[t,s]=(0,a.useState)(null),n=ex(e).length,i=t=>{let r=Date.now(),n={...e,exportedAt:r};try{let e,i,a,l,o,d,c,u,m=function(e,t,s=Date.now()){return(0,eu.Y8)("history",eh(e.machine),s,t)}(n,t,r),h="csv"===t?function(e){let t,s,r,n,i,a,l=e.exportedAt??Date.now(),o=(t=(0,S.ly)(e.range),s=e.result,r=ex(e),n=ej(e),i=ey(e),a=e.selectedMetrics.map(ef).join("; "),[["Rigscope History export"],["Scope","Visible series from the loaded History result"],["Machine",eh(e.machine)],["Machine ID",e.machine.machineId],["Query",a],["Range",`${t.label} (${eg(s.fromMs)} – ${eg(s.toMs)})`],["Resolution",`${em[s.tier]} \xb7 ${s.stepMs} ms buckets`],["Loaded at",eg(e.loadedAt)],["Exported at",eg(l)],["Partial",s.truncated?"true":"false"],["Gaps",String(i.length)],["Visible series",String(r.length)],["Selected without stored data",n.length>0?n.join(", "):"none"],["Note",eN(e,n).join(" ")],[]]);for(let t of(o.push([...ew]),eb(e)))for(let e of t.points)o.push(["bucket",t.metric,t.label,t.resourceId,t.resourceLabel,t.unit,e.bucketStartMs,e.bucketStartIso,e.bucketEndMs,e.bucketEndIso,e.min,e.max,e.avg,e.state,"","",""]);for(let t of ey(e))o.push(["gap","","","","","",t.fromMs,t.fromIso,t.toMs,t.toIso,"","","","gap",t.kind,t.reason??"",t.droppedRecords??""]);return(0,ec.kg)(o)}(n):(e=n.exportedAt??Date.now(),i=(0,S.ly)(n.range),a=n.result,l=eb(n),o=ej(n),d=ey(n),c=ev(n),u={app:"Rigscope",kind:"history",exportedAt:eg(e),scope:{description:"Visible series from the loaded History result",machine:{id:n.machine.machineId,name:eh(n.machine),hostname:n.machine.hostname,connected:n.machine.connected,lastReceivedAt:n.machine.lastReceivedAt},query:{range:{id:i.id,label:i.label,fromMs:a.fromMs,fromIso:eg(a.fromMs),toMs:a.toMs,toIso:eg(a.toMs)},selectedMetrics:[...n.selectedMetrics],visibleSeries:l.length,hiddenSeriesCount:c}},resolution:{tier:a.tier,label:em[a.tier],stepMs:a.stepMs,expectedIntervalMs:n.machine.expectedIntervalMs??null},loadedAt:eg(n.loadedAt),partial:a.truncated,gaps:d,series:l.map(e=>({metric:e.metric,label:e.label,resourceId:e.resourceId,resourceLabel:e.resourceLabel,unit:e.unit,unitLabel:e.unitLabel,summary:{points:e.stats.count,min:e.stats.min,max:e.stats.max,averageOfBucketAverages:e.stats.avg,latest:e.stats.latest,latestAt:null===e.stats.latestT?null:eg(e.stats.latestT),firstAt:null===e.stats.firstT?null:eg(e.stats.firstT),lastAt:null===e.stats.lastT?null:eg(e.stats.lastT)},points:e.points})),missingData:o.map(e=>({metric:e,label:ef(e),reason:"No stored series in the loaded result."})),notes:eN(n,o)},`${JSON.stringify(u,null,2)}
|
|
3
3
|
`);(0,ec.PE)(m,h,"csv"===t?ec.UR:ec.uW),s(null)}catch{s("The history export could not be created.")}};return(0,r.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[(0,r.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Export visible",(0,r.jsx)("span",{className:"sr-only",children:` (${n} series from the loaded result)`})]}),(0,r.jsx)("button",{type:"button",onClick:()=>i("csv"),"aria-label":"Download visible history as CSV",title:"Download the visible series from this loaded result as CSV",className:ek,children:"CSV"}),(0,r.jsx)("button",{type:"button",onClick:()=>i("json"),"aria-label":"Download visible history as JSON",title:"Download the visible series from this loaded result as JSON",className:ek,children:"JSON"}),null!==t?(0,r.jsxs)("span",{role:"status",className:"inline-flex items-center gap-1 text-xs text-warn",children:[(0,r.jsx)(d.A,{className:"h-3 w-3","aria-hidden":!0}),t]}):null]})}function e$(e){return e.displayName?.trim()||e.hostname.trim()||e.machineId}function eA(){return(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-5 xl:grid-cols-2","aria-busy":"true",children:[(0,r.jsx)(h.Z,{title:"Loading stored history",children:(0,r.jsx)("div",{className:"h-40 animate-pulse rounded-lg bg-card-strong","aria-hidden":!0})}),(0,r.jsx)(h.Z,{title:"Preparing charts",children:(0,r.jsx)("div",{className:"h-40 animate-pulse rounded-lg bg-card-strong","aria-hidden":!0})})]})}function eI(){let e,t,s,n,{session:j,phase:v,machines:N,retryConnection:w}=(0,f.M)(),k=(0,g.x)(),{machine:A,machineId:R,requestedMachineId:P}=(0,b.JG)("history"),[U,L]=W(R,"memory"),[_,T]=W(R,"filesystem"),z={memory:U,filesystem:_},[D,H]=(0,B.u)("history.range","10m",F),[Z,V]=(0,B.u)(`history.metrics.${R}`,null,O),[K]=q(R),Y=M(A),J=$(K,Y),[Q,X]=G(R,"cards"),[es,er]=G(R,"series"),en=(0,a.useMemo)(()=>new Set(Q),[Q]),ei=(0,a.useMemo)(()=>new Set(es),[es]),[ea,el]=(0,B.u)("history.autoRefresh",!0,E,"session"),[eo,ec]=(0,a.useState)(null),[eu,em]=(0,a.useState)(null),[eh,ep]=(0,a.useState)(0),ex=(0,a.useRef)(null),[eg,ef]=(0,a.useState)(null),[eb,ey]=(0,a.useState)(Date.now);(0,a.useEffect)(()=>{if(void 0===A){ex.current=null,ef(null);return}let e=ex.current,t={connected:A.connected,lastReceivedAt:A.lastReceivedAt},s=e?.machineId===A.machineId?e.point:null;ef(e=>{let r=function(e,t,s,r){let n=e.findIndex(e=>null===e.toMs);if(!s.connected){if(n>=0)return e;let i=[...e,{fromMs:C(s.lastReceivedAt)??C(t?.lastReceivedAt??null)??r,toMs:null}];return i.length>64?i.slice(i.length-64):i}if(n<0||null===t||t.connected)return e;let i=e[n],a=C(s.lastReceivedAt),l=null!==a&&a>i.fromMs?a:Math.max(i.fromMs,r);return e.map((e,t)=>t===n?{fromMs:e.fromMs,toMs:l}:e)}(e?.machineId===A.machineId?e.outages:[],s,t,Date.now());return e?.machineId===A.machineId&&e.outages===r?e:{machineId:A.machineId,outages:r}}),t.connected&&s?.connected!==!1||ey(Date.now()),ex.current={machineId:A.machineId,point:t}},[A?.machineId,A?.connected,A?.lastReceivedAt]),(0,a.useEffect)(()=>{if(A?.connected!==!1||!ea)return;let e=window.setInterval(()=>{"visible"===document.visibilityState&&ey(Date.now())},1e3);return()=>window.clearInterval(e)},[A?.machineId,A?.connected,ea]);let ej=(0,a.useMemo)(()=>void 0===A?"":(0,y.er)(A).join(","),[A?.machineId,A?.inventory,A?.metrics?.payload.gpus]),ev=Z??ej,eN=""===ev?[]:ev.split(","),ew="signed-in"===j.kind&&void 0!==A&&""!==R&&""!==ev;(0,a.useEffect)(()=>{if(""===R){ec(null),em(null);return}let e=new AbortController;return ec(null),em(null),fetch(`/api/history/metrics?machineId=${encodeURIComponent(R)}`,{signal:e.signal,cache:"no-store",headers:{Accept:"application/json"}}).then(async t=>{if(!t.ok){if(401===t.status||403===t.status||404===t.status)return;throw Error(`catalog ${t.status}`)}let s=await t.json();if(null===s||"object"!=typeof s||!("metrics"in s))throw Error("catalog shape");let r=s.metrics;if(null===r||"object"!=typeof r)throw Error("catalog shape");let n=Object.create(null);for(let[e,t]of Object.entries(r))null!==t&&"object"==typeof t&&"string"==typeof t.unit&&(n[e]={unit:t.unit});e.signal.aborted||ec(n)}).catch(()=>{e.signal.aborted||em("The hub's metric catalog could not be loaded; standard metric names are shown.")}),()=>e.abort()},[R]);let{data:ek,error:eI,loading:eC,manualRefreshing:eS}=(0,et.n)({machineId:R,metricsKey:ev,coreIdsKey:eN.includes("cpu.core")&&J.length!==Y.length?J.join(","):void 0,range:D,enabled:ew,autoRefresh:ea,refreshNonce:eh});(0,a.useEffect)(()=>{eI?.kind==="rate-limited"&&el(!1)},[eI?.kind,el]);let eR=(0,a.useMemo)(()=>{if(!ek||eg?.machineId!==R||0===eg.outages.length)return ek;let e=ek.result,t=Math.max(e.toMs,...eg.outages.map(e=>e.toMs??eb)),s=e.fromMs+t-e.toMs;return{...ek,result:{...e,fromMs:s,toMs:t,gaps:(0,I.$z)([...e.gaps,...function(e,t,s){if(!Number.isFinite(t)||!Number.isFinite(s)||s<=t)return[];let r=[];for(let n of e){let e=Math.max(t,n.fromMs),i=Math.min(s,n.toMs??s);Number.isFinite(e)&&Number.isFinite(i)&&!(i<=e)&&r.push({fromMs:e,toMs:i,kind:"missing",reason:null===n.toMs?"collector disconnected":"collector outage"})}var n=r;let i=n.filter(e=>Number.isFinite(e.fromMs)&&Number.isFinite(e.toMs)&&e.toMs>e.fromMs).map(e=>({...e})).sort((e,t)=>e.fromMs-t.fromMs||e.toMs-t.toMs),a=[];for(let e of i){let t=a.at(-1);if(void 0!==t&&e.fromMs<=t.toMs){t.toMs=Math.max(t.toMs,e.toMs),"dropped"===e.kind&&(t.kind="dropped"),void 0===t.reason&&void 0!==e.reason&&(t.reason=e.reason),void 0===t.droppedRecords&&void 0!==e.droppedRecords&&(t.droppedRecords=e.droppedRecords);continue}a.push(e)}return a}(eg.outages,s,t)],s,t)}}},[ek,R,eg,eb]),eP=eR?.result??null,eU=void 0===A?[]:(0,y.ue)(A,eP?.series??[]),eL=(0,S.ly)(D),e_=null!==eI?null!==eR?`${"rate-limited"===eI.kind?"Refresh paused":"Refresh failed"} \xb7 ${(0,S.ei)(eR.loadedAt)}`:"History unavailable":null!==eR?`Updated ${(0,S.ei)(eR.loadedAt)}`:eC?"Loading…":"",eB=ew&&null===eR&&null===eI,eT=N.length,ez="disconnected"===v;return(0,r.jsx)(m.G,{title:"History",machineId:R,machineView:"history",headerRight:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(p.$E,{}),(0,r.jsx)(x.B,{})]}),children:k||(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{role:"status","aria-live":"polite",className:"sr-only",children:eI?.message??""}),(0,r.jsx)(ee,{machine:A,range:D,selectedMetrics:eN,catalog:eo,catalogError:eu,gpuCards:eU,hiddenCards:en,autoRefresh:ea,loading:eC,manualRefreshing:eS,statusText:e_,onRangeChange:H,onToggleMetric:e=>{let t=new Set(eN);t.has(e)?t.delete(e):t.add(e),V([...t].sort().join(","))},onSetMetrics:e=>V([...new Set(e)].sort().join(",")),onToggleCard:e=>{X(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),[...s]})},onToggleAutoRefresh:()=>el(e=>!e),onRefresh:()=>ep(e=>e+1)}),"reconnecting"===v||"disconnected"===v?(0,r.jsxs)("div",{role:"status",className:"mb-4 flex items-start gap-2 rounded-lg border border-border bg-card px-4 py-2.5 text-xs text-muted-foreground",children:[(0,r.jsx)(d.A,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-warn","aria-hidden":!0}),(0,r.jsxs)("span",{children:["Live feed ","disconnected"===v?"disconnected":"reconnecting"," \xb7 stored history available"]}),"disconnected"===v?(0,r.jsxs)("button",{type:"button",onClick:w,className:"ml-auto inline-flex min-h-8 shrink-0 items-center gap-1.5 rounded-md border border-border px-2.5 text-xs text-foreground transition-colors hover:bg-card-strong",children:[(0,r.jsx)(u.A,{className:"h-3 w-3","aria-hidden":!0}),"Retry now"]}):null]}):null,void 0===A?ez?(0,r.jsxs)(h.Z,{title:"Hub disconnected",className:"mx-auto mt-3 max-w-xl",children:[(0,r.jsx)(h.p,{icon:c.A,note:"The hub is unreachable, so the authorized machine list is unavailable."}),(0,r.jsx)("div",{className:"mt-2 flex justify-center",children:(0,r.jsxs)("button",{type:"button",onClick:w,className:"inline-flex min-h-8 items-center gap-1.5 rounded-md border border-border px-3 text-xs text-foreground transition-colors hover:bg-card-strong",children:[(0,r.jsx)(u.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Check again"]})})]}):0!==eT||ez||"idle"!==v&&"connecting"!==v&&"reconnecting"!==v?0===eT?(0,r.jsx)(h.Z,{title:"No machines",className:"mx-auto mt-3 max-w-xl",children:(0,r.jsx)(h.p,{icon:o.A,note:"No machines are available in your authorized fleet."})}):(0,r.jsxs)(h.Z,{title:"Machine not found",className:"mx-auto mt-3 max-w-xl",children:[(0,r.jsx)(h.p,{icon:o.A,note:"This machine is unavailable or outside your access."}),P?(0,r.jsxs)("p",{className:"tnum mt-2 text-center text-xs text-muted-foreground",children:["Requested identifier: ",P]}):null,(0,r.jsx)("div",{className:"mt-2 flex justify-center",children:(0,r.jsx)(i(),{href:"/",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:"Back to fleet"})})]}):(0,r.jsx)(h.Z,{title:"Waiting for machines",className:"mx-auto mt-3 max-w-xl",children:(0,r.jsx)(h.p,{icon:o.A,note:"Waiting for the hub to report your authorized machines…"})}):0===eN.length?(0,r.jsx)(h.Z,{title:"No metrics selected",className:"mx-auto mt-3 max-w-xl",children:(0,r.jsx)(h.p,{icon:o.A,note:""===ej?"No metric families are shared with this hub.":"Choose at least one metric above to draw history."})}):null!==eI&&null===eR?(t=(e=function(e){switch(e.kind){case"unauthorized":return{title:"Session ended",note:"Your session is no longer accepted, so stored history is hidden.",icon:l.A};case"denied":return{title:"History access denied",note:e.message,icon:l.A};case"missing":return{title:"Machine unavailable",note:e.message,icon:o.A};case"rate-limited":return{title:"History requests limited",note:e.message,icon:d.A};case"unavailable":return{title:"History unavailable",note:e.message,icon:c.A};case"network":return{title:"Hub unreachable",note:"The hub could not be reached for stored history.",icon:c.A};case"invalid":return{title:"Unexpected history response",note:e.message,icon:d.A}}}(eI)).icon,(0,r.jsxs)(h.Z,{title:e.title,className:"mx-auto mt-3 max-w-xl",children:[(0,r.jsx)(h.p,{icon:t,note:e.note}),(0,r.jsxs)("div",{className:"mt-2 flex flex-wrap justify-center gap-2",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>ep(e=>e+1),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,r.jsx)(u.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Try again"]}),"unauthorized"===eI.kind?(0,r.jsx)(i(),{href:"/login",className:"inline-flex items-center rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-accent-foreground transition-colors hover:bg-accent/90",children:"Sign in"}):null]})]})):(eC||eB)&&null===eR?(0,r.jsx)(eA,{}):null===eR?(0,r.jsx)(h.Z,{title:"History",className:"mx-auto mt-3 max-w-xl",children:(0,r.jsx)(h.p,{icon:o.A,note:"No stored history has arrived yet."})}):(n="raw"===(s=eR.result).tier?"raw samples":"1m"===s.tier?"1-minute rollups":"1-hour rollups",(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"mb-3 flex flex-wrap items-baseline gap-x-4 gap-y-1 text-xs text-muted-foreground",children:[(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-foreground",children:[(0,r.jsx)("span",{"aria-hidden":!0,className:`inline-block h-2 w-2 shrink-0 rounded-full ${A.connected?"bg-ok":"bg-crit"}`}),e$(A)]}),(0,r.jsxs)("span",{children:[(0,S.r6)(s.fromMs)," – ",(0,S.r6)(s.toMs)]}),(0,r.jsxs)("span",{className:"tnum",title:n,children:[(0,S.I_)(s.stepMs)," buckets"]}),(0,r.jsx)("div",{className:"ml-auto self-center",children:(0,r.jsx)(eM,{machine:A,result:s,range:D,selectedMetrics:(0,y.Cv)(eN,z),hiddenCards:en,hiddenSeries:ei,coreIds:J,loadedAt:eR.loadedAt})})]}),s.truncated?(0,r.jsxs)("div",{role:"status",className:"mb-4 flex items-start gap-2 rounded-lg bg-warn-soft px-4 py-2.5 text-xs text-foreground",children:[(0,r.jsx)(d.A,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-warn","aria-hidden":!0}),(0,r.jsx)("span",{children:"Partial history \xb7 narrow the range for more detail."})]}):null,s.gaps.length>0?(0,r.jsxs)("details",{className:"mb-4 max-w-3xl text-xs text-muted-foreground",children:[(0,r.jsxs)("summary",{className:"inline-flex min-h-8 cursor-pointer items-center gap-2 rounded-md text-warn",children:[(0,r.jsx)(d.A,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-warn","aria-hidden":!0}),(0,r.jsxs)("span",{children:[(0,r.jsx)("strong",{className:"font-medium",children:"Data gaps:"})," ",(0,S.fH)(s.gaps,s.fromMs,s.toMs)]})]}),(0,r.jsxs)("ul",{className:"mt-1.5 flex flex-col gap-1",children:[s.gaps.slice(0,20).map(e=>(0,r.jsxs)("li",{className:"tnum text-xs",children:[(0,S.r6)(e.fromMs)," – ",(0,S.r6)(e.toMs)," (",(0,S.I_)(e.toMs-e.fromMs),"):"," ","dropped"===e.kind?"dropped":"missed",e.reason?` \xb7 ${e.reason}`:"",void 0!==e.droppedRecords?` \xb7 ${e.droppedRecords} record${1===e.droppedRecords?"":"s"}`:""]},`${e.fromMs}-${e.toMs}-${e.kind}`)),s.gaps.length>20?(0,r.jsxs)("li",{className:"text-xs text-muted-foreground",children:["…and ",s.gaps.length-20," more."]}):null]})]}):null,0===s.series.length?(0,r.jsx)(h.Z,{title:"No stored points",className:"mx-auto max-w-xl",children:(0,r.jsx)(h.p,{icon:o.A,note:`No stored readings for ${void 0===A?"this machine":e$(A)} in ${eL.label.toLowerCase()}.`})}):(0,r.jsx)(ed,{machine:A,result:s,selectedMetrics:eN,hiddenCards:en,hiddenSeries:ei,onToggleSeries:e=>{er(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),[...s]})},capacityUnits:z,onCapacityUnitChange:(e,t)=>("memory"===e?L:T)(t)})]}))]})})}},6582:(e,t,s)=>{"use strict";s.d(t,{E:()=>f,x:()=>g});var r=s(5155),n=s(8500),i=s.n(n),a=s(828),l=s(6914),o=s(7029),d=s(438),c=s(7422),u=s(1735),m=s(3440),h=s(9939);function p(e){return(0,r.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,r.jsx)(a.A,{className:"h-3.5 w-3.5","aria-hidden":!0}),e.children]})}function x(e){return(0,r.jsx)(i(),{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 g(){let{session:e,phase:t,retryConnection:s}=(0,h.M)();switch(e.kind){case"restoring":return(0,r.jsx)(m.Z,{title:"Checking session",className:"mx-auto my-12 max-w-md",children:(0,r.jsx)(m.p,{icon:l.A,note:"Checking your session…"})});case"restore-failed":return(0,r.jsxs)(m.Z,{title:"Hub unreachable",className:"mx-auto my-12 max-w-md",children:[(0,r.jsx)(m.p,{icon:o.A,note:"The hub is unreachable right now."}),(0,r.jsx)("div",{className:"flex justify-center",children:(0,r.jsx)(p,{onClick:s,children:"Check again"})})]});case"signed-out":if("expired"===t)return(0,r.jsxs)(m.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,r.jsx)(m.p,{icon:d.A,note:"Your session ended."}),(0,r.jsx)("div",{className:"flex justify-center",children:(0,r.jsx)(x,{href:"/login",primary:!0,children:"Sign in"})})]});return(0,r.jsxs)(m.Z,{title:"Sign in required",className:"mx-auto my-12 max-w-md",children:[(0,r.jsx)(m.p,{icon:l.A,note:"Sign in required."}),(0,r.jsx)("div",{className:"flex justify-center",children:(0,r.jsx)(x,{href:"/login",primary:!0,children:"Sign in"})})]});case"auth-unavailable":return(0,r.jsx)(m.Z,{title:"Sign-in unavailable",className:"mx-auto my-12 max-w-md",children:(0,r.jsx)(m.p,{icon:c.A,note:"Browser sign-in is not configured on this hub."})})}return"expired"===t?(0,r.jsxs)(m.Z,{title:"Session ended",className:"mx-auto my-12 max-w-md",children:[(0,r.jsx)(m.p,{icon:d.A,note:"Your session ended."}),(0,r.jsx)("div",{className:"flex justify-center",children:(0,r.jsx)(x,{href:"/login",primary:!0,children:"Sign in"})})]}):"no-permission"===t?(0,r.jsxs)(m.Z,{title:"No permission",className:"mx-auto my-12 max-w-md",children:[(0,r.jsx)(m.p,{icon:c.A,note:`You are signed in as ${e.user.username}, but this hub grants no machine view to this account.`}),(0,r.jsx)("div",{className:"flex justify-center",children:(0,r.jsx)(p,{onClick:s,children:"Check again"})})]}):null}function f(){let{phase:e,retryConnection:t}=(0,h.M)();return"reconnecting"!==e&&"disconnected"!==e&&"connecting"!==e?null:"connecting"===e?(0,r.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,r.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,r.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,r.jsx)(u.A,{className:"h-3.5 w-3.5 shrink-0 text-warn","aria-hidden":!0}),(0,r.jsxs)("span",{children:["Connection lost — values below are ",(0,r.jsx)("strong",{className:"font-medium text-foreground",children:"last known"}),", not live measurements","reconnecting"===e?" — retrying with backoff…":" — retries stopped."]}),"disconnected"===e?(0,r.jsx)(p,{onClick:t,children:"Retry now"}):null]})}},7148:(e,t,s)=>{Promise.resolve().then(s.bind(s,2939)),Promise.resolve().then(s.bind(s,1721)),Promise.resolve().then(s.bind(s,2701)),Promise.resolve().then(s.bind(s,2394))},7499:(e,t,s)=>{"use strict";function r(e,t,s,r){return`rigscope-${e}-${function(e,t="machine"){let s=e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48).replace(/-+$/g,"");return s.length>0?s:t}(t)}-${!Number.isFinite(s)?"unknown-time":new Date(s).toISOString().replace(/[-:]/g,"").replace(/\.\d{3}Z$/,"Z")}.${r}`}s.d(t,{Y8:()=>r})},9942:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(8698).A)("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]])}},e=>{e.O(0,[157,939,103,408,441,794,358],()=>e(e.s=7148)),_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,227,408,441,794,358],()=>e(e.s=4546)),_N_E=e.O()}]);
|