import{g as Oe,u as Me,a as Ee,i as Ae,b as Te,D as De,c as Ie,j as e,S as Le,t as Fe,C as oe,L as Ne,r as de,d as Pe,e as We}from"./index-O0kA0qO6.js";var be={exports:{}};var Ue=be.exports,Re;function He(){return Re||(Re=1,(function(k,C){((P,j)=>{k.exports=j()})(Ue,function P(){var j=typeof self<"u"?self:typeof window<"u"?window:j!==void 0?j:{},H=!j.document&&!!j.postMessage,q=j.IS_PAPA_WORKER||!1,p={},fe=0,n={};function he(s){return s.charCodeAt(0)===65279?s.slice(1):s}function u(s){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},(function(t){var r=je(t);r.chunkSize=parseInt(r.chunkSize),t.step||t.chunk||(r.chunkSize=null),this._handle=new _(r),(this._handle.streamer=this)._config=r}).call(this,s),this.parseChunk=function(t,r){var l=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0=this._config.preview),q)j.postMessage({results:i,workerId:n.WORKER_ID,finished:l});else if(T(this._config.chunk)&&!r){if(this._config.chunk(i,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);this._completeResults=i=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(i.data),this._completeResults.errors=this._completeResults.errors.concat(i.errors),this._completeResults.meta=i.meta),this._completed||!l||!T(this._config.complete)||i&&i.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),l||i&&i.meta.paused||this._nextChunk(),i}this._halted=!0},this._sendError=function(t){T(this._config.error)?this._config.error(t):q&&this._config.error&&j.postMessage({workerId:n.WORKER_ID,error:t,finished:!1})}}function A(s){var t;(s=s||{}).chunkSize||(s.chunkSize=n.RemoteChunkSize),u.call(this,s),this._nextChunk=H?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(r){this._input=r,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(t=new XMLHttpRequest,this._config.withCredentials&&(t.withCredentials=this._config.withCredentials),H||(t.onload=te(this._chunkLoaded,this),t.onerror=te(this._chunkError,this)),t.ontimeout=te(this._chunkTimeout,this),t.open(this._config.downloadRequestBody?"POST":"GET",this._input,!H),this._config.downloadTimeout&&!H&&(t.timeout=this._config.downloadTimeout),this._config.downloadRequestHeaders){var r,l=this._config.downloadRequestHeaders;for(r in l)t.setRequestHeader(r,l[r])}var i;this._config.chunkSize&&(i=this._start+this._config.chunkSize-1,t.setRequestHeader("Range","bytes="+this._start+"-"+i));try{t.send(this._config.downloadRequestBody)}catch(b){this._chunkError(b.message)}H&&t.status===0&&this._chunkError()}},this._chunkLoaded=function(){t.readyState===4&&(t.status<200||400<=t.status?this._chunkError():(this._start+=this._config.chunkSize||t.responseText.length,this._finished=!this._config.chunkSize||this._start>=(r=>(r=r.getResponseHeader("Content-Range"))!==null?parseInt(r.substring(r.lastIndexOf("/")+1)):-1)(t),this.parseChunk(t.responseText)))},this._chunkError=function(r){r=t.statusText||r,this._sendError(new Error(r))},this._chunkTimeout=function(){this._chunkError("Request timed out after "+this._config.downloadTimeout+"ms")}}function ee(s){(s=s||{}).chunkSize||(s.chunkSize=n.LocalChunkSize),u.call(this,s);var t,r,l=typeof FileReader<"u";this.stream=function(i){this._input=i,r=i.slice||i.webkitSlice||i.mozSlice,l?((t=new FileReader).onload=te(this._chunkLoaded,this),t.onerror=te(this._chunkError,this)):t=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount=this._input.size,this.parseChunk(i.target.result)},this._chunkError=function(){this._sendError(t.error)}}function S(s){var t;u.call(this,s=s||{}),this.stream=function(r){return t=r,this._nextChunk()},this._nextChunk=function(){var r,l;if(!this._finished)return r=this._config.chunkSize,t=r?(l=t.substring(0,r),t.substring(r)):(l=t,""),this._finished=!t,this.parseChunk(l)}}function o(s){u.call(this,s=s||{});var t=[],r=!0,l=!1;this.pause=function(){u.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){u.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(i){this._input=i,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){l&&t.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),t.length?this.parseChunk(t.shift()):r=!0},this._streamData=te(function(i){try{t.push(typeof i=="string"?i:i.toString(this._config.encoding)),r&&(r=!1,this._checkIsFinished(),this.parseChunk(t.shift()))}catch(b){this._streamError(b)}},this),this._streamError=te(function(i){this._streamCleanUp(),this._sendError(i)},this),this._streamEnd=te(function(){this._streamCleanUp(),l=!0,this._streamData("")},this),this._streamCleanUp=te(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function _(s){var t,r,l,i,b=Math.pow(2,53),$=-b,J=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,se=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,N=this,z=0,h=0,K=!1,f=!1,m=[],a={data:[],errors:[],meta:{}};function V(y){return s.skipEmptyLines==="greedy"?y.join("").trim()==="":y.length===1&&y[0].length===0}function E(){if(a&&l&&(Q("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+n.DefaultDelimiter+"'"),l=!1),s.skipEmptyLines&&(a.data=a.data.filter(function(d){return!V(d)})),D()){let d=function(I){m.push(I)};if(a)if(Array.isArray(a.data[0])){for(var y=0;D()&&y(O=>(s.dynamicTypingFunction&&s.dynamicTyping[O]===void 0&&(s.dynamicTyping[O]=s.dynamicTypingFunction(O)),(s.dynamicTyping[O]||s.dynamicTyping)===!0))(G)?c==="true"||c==="TRUE"||c!=="false"&&c!=="FALSE"&&((O=>{if(J.test(O)&&(O=parseFloat(O),$=m.length?"__parsed_extra":m[w]:R,x=s.transform?s.transform(x,R):x);R==="__parsed_extra"?(W[R]=W[R]||[],W[R].push(x)):W[R]=x}return s.header&&(w>m.length?Q("FieldMismatch","TooManyFields","Too many fields: expected "+m.length+" fields but parsed "+w,h+I):ws.preview?r.abort():(a.data=a.data[0],i(a,N))))}),this.parse=function(y,g,M){var d=s.quoteChar||'"',d=(s.newline||(s.newline=this.guessLineEndings(y,d)),l=!1,s.delimiter?T(s.delimiter)&&(s.delimiter=s.delimiter(y),a.meta.delimiter=s.delimiter):((d=((I,W,w,R,x)=>{var G,c,O,le;x=x||[","," ","|",";",n.RECORD_SEP,n.UNIT_SEP];for(var ce=0;ce=M.length/2?`\r `:"\r"}}function ne(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ae(s){var t=(s=s||{}).delimiter,r=s.newline,l=s.comments,i=s.step,b=s.preview,$=s.fastMode,J=null,se=!1,N=s.quoteChar==null?'"':s.quoteChar,z=N;if(s.escapeChar!==void 0&&(z=s.escapeChar),(typeof t!="string"||-1=b)return U(!0);break}M.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:g.length,index:h}),c++}}else if(l&&d.length===0&&f.substring(h,h+Q)===l){if(x===-1)return U();h=x+D,x=f.indexOf(r,h),R=f.indexOf(t,h)}else if(R!==-1&&(R=b)return U(!0)}return Y();function le(F){g.push(F),I=h}function ce(F){var B=0;return B=F!==-1&&(F=f.substring(c+1,F))&&F.trim()===""?F.length:B}function Y(F){return a||(F===void 0&&(F=f.substring(h)),d.push(F),h=V,le(d),y&&Z()),U()}function me(F){h=F,le(d),d=[],x=f.indexOf(r,h)}function U(F){if(s.header&&!m&&g.length&&!se){var B=g[0],re=Object.create(null),_e=new Set(B);let we=!1;for(let ue=0;ue{var l;return!!n.WORKERS_SUPPORTED&&(l=(()=>{var i=j.URL||j.webkitURL||null,b=P.toString();return n.BLOB_URL||(n.BLOB_URL=i.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",b,")();"],{type:"text/javascript"})))})(),(l=new j.Worker(l)).onmessage=ye,l.id=fe++,p[l.id]=l)})()).userStep=t.step,r.userChunk=t.chunk,r.userComplete=t.complete,r.userError=t.error,t.step=T(t.step),t.chunk=T(t.chunk),t.complete=T(t.complete),t.error=T(t.error),delete t.worker,r.postMessage({input:s,config:t,workerId:r.id})},n.unparse=function(s,t){var r=!1,l=!0,i=",",b=`\r `,$='"',J=$+$,se=!1,N=null,z=!1,h=((()=>{if(typeof t=="object"){if(typeof t.delimiter!="string"||n.BAD_DELIMITERS.filter(function(m){return t.delimiter.indexOf(m)!==-1}).length||(i=t.delimiter),typeof t.quotes!="boolean"&&typeof t.quotes!="function"&&!Array.isArray(t.quotes)||(r=t.quotes),typeof t.skipEmptyLines!="boolean"&&typeof t.skipEmptyLines!="string"||(se=t.skipEmptyLines),typeof t.newline=="string"&&(b=t.newline),typeof t.quoteChar=="string"&&($=t.quoteChar,J=$+$),typeof t.header=="boolean"&&(l=t.header),Array.isArray(t.columns)){if(t.columns.length===0)throw new Error("Option columns is empty");N=t.columns}t.escapeChar!==void 0&&(J=t.escapeChar+$),t.escapeFormulae instanceof RegExp?z=t.escapeFormulae:typeof t.escapeFormulae=="boolean"&&t.escapeFormulae&&(z=/^[=+\-@\t\r].*$/)}})(),new RegExp(ne($),"g"));if(typeof s=="string"&&(s=JSON.parse(s)),Array.isArray(s)){if(!s.length||Array.isArray(s[0]))return K(null,s,se);if(typeof s[0]=="object")return K(N||Object.keys(s[0]),s,se)}else if(typeof s=="object")return typeof s.data=="string"&&(s.data=JSON.parse(s.data)),Array.isArray(s.data)&&(s.fields||(s.fields=s.meta&&s.meta.fields||N),s.fields||(s.fields=Array.isArray(s.data[0])?s.fields:typeof s.data[0]=="object"?Object.keys(s.data[0]):[]),Array.isArray(s.data[0])||typeof s.data[0]=="object"||(s.data=[s.data])),K(s.fields||[],s.data||[],se);throw new Error("Unable to serialize unrecognized input");function K(m,a,V){var E="",D=(typeof m=="string"&&(m=JSON.parse(m)),typeof a=="string"&&(a=JSON.parse(a)),Array.isArray(m)&&0{for(var g=0;g=1e6?`${v(C/1e6)} km`:`${v(C/1e3,1)} m`}function Ke(k){const C=qe.unparse(k.map(H=>({...H,batteryHealth:JSON.stringify(H.batteryHealth)}))),P=URL.createObjectURL(new Blob([C],{type:"text/csv;charset=utf-8"})),j=document.createElement("a");j.href=P,j.download="fleet-battery-efficiency.csv",j.click(),URL.revokeObjectURL(P)}function ie({label:k,value:C,detail:P}){return e.jsxs("div",{className:"surface min-w-0 px-1 py-0.5",children:[e.jsx("div",{className:"text-[0.68rem] text-slate-400",children:k}),e.jsx("div",{className:"truncate text-sm font-semibold text-slate-100",children:C}),P?e.jsx("div",{className:"truncate text-[0.68rem] text-slate-500",children:P}):null]})}function L({field:k,sort:C,onSort:P,children:j}){return e.jsx("th",{children:e.jsxs("button",{type:"button",className:"whitespace-nowrap text-left",onClick:()=>P(k),children:[j,C.key===k?C.descending?" ↓":" ↑":""]})})}function Be({report:k,refresh:C}){const P=We(),j=Ee(u=>u.session?.role||null),H=j==="admin"||j==="lockdown",[q,p]=de.useState({roverId:k.rovers[0]?.roverId||"",chemistry:"unknown",ratedCapacityMah:"",installedDate:new Date().toISOString().slice(0,10),notes:""}),[fe,n]=de.useState("");function he(u){u.preventDefault(),n("Saving…"),P.emit("fleetReports:replaceBattery",{...q,ratedCapacityMah:Number(q.ratedCapacityMah),installedAt:new Date(`${q.installedDate}T12:00:00`).getTime()},(A={})=>{n(A.error||`Registered ${A.battery?.batteryKey||"battery"}`),A.error||C()})}return e.jsxs(oe,{title:"Battery identity and baselines",meta:`${k.batteryRegistry.length} records`,bodyClassName:"space-y-0.5 p-0.5",children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full whitespace-nowrap text-left text-xs",children:[e.jsx("thead",{className:"text-slate-400",children:e.jsxs("tr",{children:[e.jsx("th",{children:"Rover"}),e.jsx("th",{children:"Battery"}),e.jsx("th",{children:"Chemistry"}),e.jsx("th",{children:"Rated mAh"}),e.jsx("th",{children:"Installed"}),e.jsx("th",{children:"Retired"}),e.jsx("th",{children:"Learned baseline mAh"}),e.jsx("th",{children:"Notes"})]})}),e.jsx("tbody",{children:k.batteryRegistry.map(u=>e.jsxs("tr",{className:"border-t border-neutral-700/70 text-slate-200",children:[e.jsx("td",{children:u.roverId}),e.jsx("td",{children:u.batteryKey}),e.jsx("td",{children:u.chemistry||"--"}),e.jsx("td",{children:v(u.ratedCapacityMah,0)}),e.jsx("td",{children:xe(u.installedAt)}),e.jsx("td",{children:xe(u.retiredAt)}),e.jsx("td",{children:v(u.healthyBaselineMah,0)}),e.jsx("td",{children:u.notes||"--"})]},u.batteryKey))})]})}),H?e.jsxs("form",{className:"surface grid gap-0.5 p-1 text-xs md:grid-cols-2 xl:grid-cols-6",onSubmit:he,children:[e.jsxs("label",{children:[e.jsx("span",{className:"text-slate-400",children:"Rover"}),e.jsx("select",{className:"w-full bg-neutral-800 p-0.5",value:q.roverId,onChange:u=>p(A=>({...A,roverId:u.target.value})),children:k.rovers.map(u=>e.jsx("option",{value:u.roverId,children:u.name},u.roverId))})]}),e.jsxs("label",{children:[e.jsx("span",{className:"text-slate-400",children:"Chemistry"}),e.jsxs("select",{className:"w-full bg-neutral-800 p-0.5",value:q.chemistry,onChange:u=>p(A=>({...A,chemistry:u.target.value})),children:[e.jsx("option",{value:"unknown",children:"Unknown"}),e.jsx("option",{value:"NiMH",children:"NiMH"}),e.jsx("option",{value:"Li-ion",children:"Li-ion"})]})]}),e.jsxs("label",{children:[e.jsx("span",{className:"text-slate-400",children:"Rated capacity mAh"}),e.jsx("input",{required:!0,min:"1",max:"65535",type:"number",className:"w-full bg-neutral-800 p-0.5",value:q.ratedCapacityMah,onChange:u=>p(A=>({...A,ratedCapacityMah:u.target.value}))})]}),e.jsxs("label",{children:[e.jsx("span",{className:"text-slate-400",children:"Installed"}),e.jsx("input",{required:!0,type:"date",className:"w-full bg-neutral-800 p-0.5",value:q.installedDate,onChange:u=>p(A=>({...A,installedDate:u.target.value}))})]}),e.jsxs("label",{children:[e.jsx("span",{className:"text-slate-400",children:"Notes"}),e.jsx("input",{className:"w-full bg-neutral-800 p-0.5",value:q.notes,onChange:u=>p(A=>({...A,notes:u.target.value}))})]}),e.jsxs("div",{className:"flex items-end gap-0.5",children:[e.jsx("button",{type:"submit",className:"button-dark px-1 py-0.5",children:"Install or replace"}),e.jsx("span",{className:"text-slate-400",children:fe})]})]}):null]})}function Ve(){const[k,C]=de.useState(Ce[1].ms),[P,j]=de.useState(()=>Date.now()),[H,q]=de.useState(""),[p,fe]=de.useState({key:"name",descending:!1}),{report:n,loading:he,error:u,refresh:A}=Pe({since:P-k,until:P,includeEvents:!1}),ee=de.useMemo(()=>[...(n?.rovers||[]).filter(_=>`${_.name} ${_.roverId}`.toLowerCase().includes(H.trim().toLowerCase()))].sort((_,ne)=>{const ae=p.key.startsWith("batteryHealth.")?_.batteryHealth?.[p.key.slice(14)]:_[p.key],ye=p.key.startsWith("batteryHealth.")?ne.batteryHealth?.[p.key.slice(14)]:ne[p.key],pe=typeof ae=="string"?ae.localeCompare(String(ye??"")):(Number(ae)||0)-(Number(ye)||0);return p.descending?-pe:pe}),[H,n,p]);function S(o){fe(_=>({key:o,descending:_.key===o?!_.descending:!1}))}return e.jsxs(e.Fragment,{children:[e.jsxs(oe,{title:"Fleet battery health and efficiency",meta:n?xe(n.generatedAt):"Loading",bodyClassName:"space-y-0.5 p-0.5",children:[e.jsxs("div",{className:"surface flex flex-wrap items-end gap-0.5 p-0.5 text-xs",children:[e.jsxs("label",{children:[e.jsx("span",{className:"mr-0.5 text-slate-400",children:"Range"}),e.jsx("select",{className:"bg-neutral-800 p-0.5",value:k,onChange:o=>C(Number(o.target.value)),children:Ce.map(o=>e.jsx("option",{value:o.ms,children:o.label},o.ms))})]}),e.jsxs("label",{children:[e.jsx("span",{className:"mr-0.5 text-slate-400",children:"Find rover"}),e.jsx("input",{className:"bg-neutral-800 p-0.5",value:H,onChange:o=>q(o.target.value)})]}),e.jsx("button",{type:"button",className:"button-dark px-1 py-0.5",onClick:()=>{j(Date.now()),A()},children:"Refresh"}),e.jsx(Ne,{className:"button-dark px-1 py-0.5",to:"/",children:"Back"})]}),he&&!n?e.jsx("p",{className:"text-slate-400",children:"Loading fleet metrics…"}):null,u?e.jsx("p",{className:"text-red-300",children:u}):null,n?e.jsxs("div",{className:"grid grid-cols-2 gap-0.5 md:grid-cols-4 xl:grid-cols-8",children:[e.jsx(ie,{label:"Rovers online",value:`${n.totals.onlineRoverCount}/${n.totals.roverCount}`}),e.jsx(ie,{label:"Distance",value:ve(n.totals.distanceMm)}),e.jsx(ie,{label:"Energy used",value:`${v(n.totals.dischargedWh)} Wh`}),e.jsx(ie,{label:"Fleet Wh/km",value:n.totals.overallWhPerKm==null?"--":v(n.totals.overallWhPerKm)}),e.jsx(ie,{label:"Moving Wh/km",value:n.totals.movingWhPerKm==null?"--":v(n.totals.movingWhPerKm)}),e.jsx(ie,{label:"Moving energy",value:`${v(n.totals.movingDischargedWh)} Wh`}),e.jsx(ie,{label:"Stationary energy",value:`${v(n.totals.stationaryDischargedWh)} Wh`}),e.jsx(ie,{label:"Attention",value:v(n.totals.attentionCount,0)})]}):null]}),n?e.jsxs(e.Fragment,{children:[e.jsx(oe,{title:"All rovers",meta:`${ee.length} visible`,actions:e.jsx("button",{type:"button",className:"button-dark px-1 py-0.25 text-xs",onClick:()=>Ke(ee),children:"Export CSV"}),bodyClassName:"overflow-x-auto p-0.5",children:e.jsxs("table",{className:"w-full whitespace-nowrap text-left text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-neutral-900 text-slate-400",children:e.jsxs("tr",{children:[e.jsx(L,{field:"name",sort:p,onSort:S,children:"Rover"}),e.jsx(L,{field:"online",sort:p,onSort:S,children:"State"}),e.jsx(L,{field:"batteryHealth.capacityRetentionPercent",sort:p,onSort:S,children:"Health"}),e.jsx(L,{field:"batteryHealth.measuredUsableMah",sort:p,onSort:S,children:"Usable Ah"}),e.jsx(L,{field:"batteryHealth.measuredUsableWh",sort:p,onSort:S,children:"Usable Wh"}),e.jsx(L,{field:"batteryHealth.confidence",sort:p,onSort:S,children:"Confidence"}),e.jsx(L,{field:"overallWhPerKm",sort:p,onSort:S,children:"Wh/km"}),e.jsx(L,{field:"movingWhPerKm",sort:p,onSort:S,children:"Moving Wh/km"}),e.jsx(L,{field:"distanceMm",sort:p,onSort:S,children:"Distance"}),e.jsx(L,{field:"dischargedWh",sort:p,onSort:S,children:"Used Wh"}),e.jsx(L,{field:"movingDischargedWh",sort:p,onSort:S,children:"Moving Wh"}),e.jsx(L,{field:"stationaryDischargedWh",sort:p,onSort:S,children:"Stationary Wh"}),e.jsx(L,{field:"movingMs",sort:p,onSort:S,children:"Moving time"}),e.jsx(L,{field:"averageSpeedMmPerSecond",sort:p,onSort:S,children:"Average speed"}),e.jsx(L,{field:"maximumSpeedMmPerSecond",sort:p,onSort:S,children:"Maximum speed"}),e.jsx(L,{field:"latestChargeMah",sort:p,onSort:S,children:"Charge"}),e.jsx(L,{field:"averageVoltageMv",sort:p,onSort:S,children:"Voltage"}),e.jsx(L,{field:"averageCurrentMa",sort:p,onSort:S,children:"Current"}),e.jsx(L,{field:"maximumTemperatureC",sort:p,onSort:S,children:"Temperature"}),e.jsx(L,{field:"lastSampleAt",sort:p,onSort:S,children:"Last data"})]})}),e.jsx("tbody",{children:ee.map(o=>{const _=o.batteryHealth;return e.jsxs("tr",{className:"border-t border-neutral-700/70 text-slate-200",children:[e.jsx("td",{className:"sticky left-0 bg-neutral-900 font-semibold",children:o.name}),e.jsx("td",{children:o.online?"online":"offline"}),e.jsx("td",{children:_.capacityRetentionPercent==null?"--":`${v(_.capacityRetentionPercent,1)}%`}),e.jsx("td",{children:_.measuredUsableMah==null?"--":v(_.measuredUsableMah/1e3,3)}),e.jsx("td",{children:v(_.measuredUsableWh)}),e.jsx("td",{title:_.confidenceReason,children:_.confidence}),e.jsx("td",{children:o.overallWhPerKm==null?`need ${ve(o.efficiencyDistanceRequiredMm)}`:v(o.overallWhPerKm)}),e.jsx("td",{children:v(o.movingWhPerKm)}),e.jsx("td",{children:ve(o.distanceMm)}),e.jsx("td",{children:v(o.dischargedWh)}),e.jsx("td",{children:v(o.movingDischargedWh)}),e.jsx("td",{children:v(o.stationaryDischargedWh)}),e.jsx("td",{children:ze(o.movingMs)}),e.jsx("td",{children:o.averageSpeedMmPerSecond==null?"--":`${v(o.averageSpeedMmPerSecond)} mm/s`}),e.jsx("td",{children:o.maximumSpeedMmPerSecond==null?"--":`${v(o.maximumSpeedMmPerSecond)} mm/s`}),e.jsxs("td",{children:[v(o.latestChargeMah,0)," mAh"]}),e.jsxs("td",{children:[v(o.averageVoltageMv,0)," mV"]}),e.jsxs("td",{children:[v(o.averageCurrentMa,0)," mA"]}),e.jsxs("td",{children:[v(o.maximumTemperatureC,1)," °C"]}),e.jsx("td",{children:xe(o.lastSampleAt)})]},o.roverId)})})]})}),e.jsx(oe,{title:"Battery-health evidence",meta:"All rovers",bodyClassName:"overflow-x-auto p-0.5",children:e.jsxs("table",{className:"w-full whitespace-nowrap text-left text-xs",children:[e.jsx("thead",{className:"text-slate-400",children:e.jsxs("tr",{children:[e.jsx("th",{children:"Rover"}),e.jsx("th",{children:"Battery"}),e.jsx("th",{children:"Reference mAh"}),e.jsx("th",{children:"Estimated usable mAh"}),e.jsx("th",{children:"Observed range floor"}),e.jsx("th",{children:"Retention"}),e.jsx("th",{children:"Observations"}),e.jsx("th",{children:"Average depth"}),e.jsx("th",{children:"Throughput"}),e.jsx("th",{children:"Latest evidence"}),e.jsx("th",{children:"Confidence basis"})]})}),e.jsx("tbody",{children:ee.map(o=>{const _=o.batteryHealth;return e.jsxs("tr",{className:"border-t border-neutral-700/70 text-slate-200",children:[e.jsx("td",{children:o.name}),e.jsx("td",{children:_.batteryKey}),e.jsx("td",{children:v(_.referenceMah,0)}),e.jsx("td",{children:v(_.measuredUsableMah,0)}),e.jsx("td",{children:v(_.observedUsableFloorMah,0)}),e.jsx("td",{children:_.capacityRetentionPercent==null?"--":`${v(_.capacityRetentionPercent,1)}%`}),e.jsx("td",{children:v(_.observationCount,0)}),e.jsxs("td",{children:[v(_.averageObservationDepthPercent,1),"%"]}),e.jsxs("td",{children:[v(_.dischargedThroughputMah,0)," mAh"]}),e.jsx("td",{children:xe(_.latestObservationAt)}),e.jsx("td",{children:_.confidenceReason})]},o.roverId)})})]})}),n.attention.length?e.jsx(oe,{title:"Attention",meta:n.attention.length,bodyClassName:"p-0.5 text-xs",children:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{className:"text-slate-400",children:e.jsxs("tr",{children:[e.jsx("th",{children:"Rover"}),e.jsx("th",{children:"Severity"}),e.jsx("th",{children:"Reason"})]})}),e.jsx("tbody",{children:n.attention.map(o=>e.jsxs("tr",{className:"border-t border-neutral-700/70",children:[e.jsx("td",{children:o.roverId}),e.jsx("td",{children:o.severity}),e.jsx("td",{children:o.title})]},o.key))})]})}):null,e.jsx(Be,{report:n,refresh:A}),e.jsxs(oe,{title:"Methodology",bodyClassName:"space-y-0.5 p-1 text-xs text-slate-300",children:[e.jsx("p",{children:"Energy is integrated per sensor interval from OI voltage and signed current. Existing odometer distance and speed are consumed directly; reporting does not calculate a competing speed value."}),e.jsx("p",{children:"Capacity combines partial discharge current with packet 25 charge movement. Every usable observation contributes; deeper observations increase confidence without labeling cycles good or bad. Packet 26 is only a fixed reference."}),e.jsx("p",{children:"Wh/km appears after 25 m of selected-range odometer travel. Existing historical rows predate exact power integration, so their Wh fields remain zero rather than being backfilled with false precision."})]})]}):null]})}function Ge(){Me({identitySurface:"passive"});const k=Ee(j=>Ae(j,"fleetReports")),{value:C}=Te("page",{backgroundTheme:De}),P=Ie(C?.backgroundTheme);return e.jsxs("div",{className:`${P} min-h-screen text-slate-100`,children:[e.jsx(Le,{}),e.jsx("main",{className:`mx-auto flex min-h-screen w-full max-w-[120rem] flex-col ${Fe} p-1`,children:k?e.jsx(Ve,{}):e.jsxs(oe,{title:"Fleet reports unavailable",bodyClassName:"space-y-0.5 p-1 text-sm text-slate-300",children:[e.jsx("p",{children:"This server has not enabled fleet reporting."}),e.jsx(Ne,{className:"button-dark inline-block px-1 py-0.5 text-xs",to:"/",children:"Back to rover page"})]})})]})}export{Ge as default}; //# sourceMappingURL=FleetReportsApp-B67LY1yW.js.map