import{g as Me,u as Ae,a as Ne,i as De,b as Ie,D as Le,c as Te,j as e,S as Fe,t as Pe,C as de,L as Oe,r as he,d as We,e as Ue}from"./index-4jkroh7K.js";var be={exports:{}};var He=be.exports,Ce;function $e(){return Ce||(Ce=1,(function(S,M){(($,b)=>{S.exports=b()})(He,function $(){var b=typeof self<"u"?self:typeof window<"u"?window:b!==void 0?b:{},B,z=!b.document&&!!b.postMessage,f=b.IS_PAPA_WORKER||!1,ie={},w=0,o={};function j(t){return t.charCodeAt(0)===65279?t.slice(1):t}function C(t){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(r){var s=je(r);s.chunkSize=parseInt(s.chunkSize),r.step||r.chunk||(s.chunkSize=null),this._handle=new pe(s),(this._handle.streamer=this)._config=s}).call(this,t),this.parseChunk=function(r,s){var i=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0=this._config.preview),f)b.postMessage({results:n,workerId:o.WORKER_ID,finished:i});else if(E(this._config.chunk)&&!s){if(this._config.chunk(n,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);this._completeResults=n=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(n.data),this._completeResults.errors=this._completeResults.errors.concat(n.errors),this._completeResults.meta=n.meta),this._completed||!i||!E(this._config.complete)||n&&n.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),i||n&&n.meta.paused||this._nextChunk(),n}this._halted=!0},this._sendError=function(r){E(this._config.error)?this._config.error(r):f&&this._config.error&&b.postMessage({workerId:o.WORKER_ID,error:r,finished:!1})}}function re(t){var r;(t=t||{}).chunkSize||(t.chunkSize=o.RemoteChunkSize),C.call(this,t),this._nextChunk=z?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(s){this._input=s,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(r=new XMLHttpRequest,this._config.withCredentials&&(r.withCredentials=this._config.withCredentials),z||(r.onload=ae(this._chunkLoaded,this),r.onerror=ae(this._chunkError,this)),r.open(this._config.downloadRequestBody?"POST":"GET",this._input,!z),this._config.downloadRequestHeaders){var s,i=this._config.downloadRequestHeaders;for(s in i)r.setRequestHeader(s,i[s])}var n;this._config.chunkSize&&(n=this._start+this._config.chunkSize-1,r.setRequestHeader("Range","bytes="+this._start+"-"+n));try{r.send(this._config.downloadRequestBody)}catch(p){this._chunkError(p.message)}z&&r.status===0&&this._chunkError()}},this._chunkLoaded=function(){r.readyState===4&&(r.status<200||400<=r.status?this._chunkError():(this._start+=this._config.chunkSize||r.responseText.length,this._finished=!this._config.chunkSize||this._start>=(s=>(s=s.getResponseHeader("Content-Range"))!==null?parseInt(s.substring(s.lastIndexOf("/")+1)):-1)(r),this.parseChunk(r.responseText)))},this._chunkError=function(s){s=r.statusText||s,this._sendError(new Error(s))}}function O(t){(t=t||{}).chunkSize||(t.chunkSize=o.LocalChunkSize),C.call(this,t);var r,s,i=typeof FileReader<"u";this.stream=function(n){this._input=n,s=n.slice||n.webkitSlice||n.mozSlice,i?((r=new FileReader).onload=ae(this._chunkLoaded,this),r.onerror=ae(this._chunkError,this)):r=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount=this._input.size,this.parseChunk(n.target.result)},this._chunkError=function(){this._sendError(r.error)}}function l(t){var r;C.call(this,t=t||{}),this.stream=function(s){return r=s,this._nextChunk()},this._nextChunk=function(){var s,i;if(!this._finished)return s=this._config.chunkSize,r=s?(i=r.substring(0,s),r.substring(s)):(i=r,""),this._finished=!r,this.parseChunk(i)}}function v(t){C.call(this,t=t||{});var r=[],s=!0,i=!1;this.pause=function(){C.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){C.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(n){this._input=n,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){i&&r.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),r.length?this.parseChunk(r.shift()):s=!0},this._streamData=ae(function(n){try{r.push(typeof n=="string"?n:n.toString(this._config.encoding)),s&&(s=!1,this._checkIsFinished(),this.parseChunk(r.shift()))}catch(p){this._streamError(p)}},this),this._streamError=ae(function(n){this._streamCleanUp(),this._sendError(n)},this),this._streamEnd=ae(function(){this._streamCleanUp(),i=!0,this._streamData("")},this),this._streamCleanUp=ae(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function pe(t){var r,s,i,n,p=Math.pow(2,53),L=-p,V=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,G=/^((\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)))$/,m=this,T=0,d=0,K=!1,c=!1,g=[],a={data:[],errors:[],meta:{}};function J(_){return t.skipEmptyLines==="greedy"?_.join("").trim()==="":_.length===1&&_[0].length===0}function A(){if(a&&i&&(Y("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+o.DefaultDelimiter+"'"),i=!1),t.skipEmptyLines&&(a.data=a.data.filter(function(h){return!J(h)})),P()){let h=function(D,U){D=j(D),E(t.transformHeader)&&(D=t.transformHeader(D,U)),g.push(D)};if(a)if(Array.isArray(a.data[0])){for(var _=0;P()&&_(I=>(t.dynamicTypingFunction&&t.dynamicTyping[I]===void 0&&(t.dynamicTyping[I]=t.dynamicTypingFunction(I)),(t.dynamicTyping[I]||t.dynamicTyping)===!0))(Z)?u==="true"||u==="TRUE"||u!=="false"&&u!=="FALSE"&&((I=>{if(V.test(I)&&(I=parseFloat(I),L=g.length?"__parsed_extra":g[R]:N,y=t.transform?t.transform(y,N):y);N==="__parsed_extra"?(U[N]=U[N]||[],U[N].push(y)):U[N]=y}return t.header&&(R>g.length?Y("FieldMismatch","TooManyFields","Too many fields: expected "+g.length+" fields but parsed "+R,d+D):Rt.preview?s.abort():(a.data=a.data[0],n(a,m))))}),this.parse=function(_,x,F){var h=t.quoteChar||'"',h=(t.newline||(t.newline=this.guessLineEndings(_,h)),i=!1,t.delimiter?E(t.delimiter)&&(t.delimiter=t.delimiter(_),a.meta.delimiter=t.delimiter):((h=((D,U,R,N,y)=>{var Z,u,I,le;y=y||[","," ","|",";",o.RECORD_SEP,o.UNIT_SEP];for(var ue=0;ue=F.length/2?`\r `:"\r"}}function se(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ce(t){var r=(t=t||{}).delimiter,s=t.newline,i=t.comments,n=t.step,p=t.preview,L=t.fastMode,V=null,G=!1,m=t.quoteChar==null?'"':t.quoteChar,T=m;if(t.escapeChar!==void 0&&(T=t.escapeChar),(typeof r!="string"||-1=p)return q(!0);break}F.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:x.length,index:d}),u++}}else if(i&&h.length===0&&c.substring(d,d+Y)===i){if(y===-1)return q();d=y+P,y=c.indexOf(s,d),N=c.indexOf(r,d)}else if(N!==-1&&(N=p)return q(!0)}return X();function le(H){x.push(H),D=d}function ue(H){var Q=0;return Q=H!==-1&&(H=c.substring(u+1,H))&&H.trim()===""?H.length:Q}function X(H){return a||(H===void 0&&(H=c.substring(d)),h.push(H),d=J,le(h),_&&ee()),q()}function me(H){d=H,le(h),h=[],y=c.indexOf(s,d)}function q(H){if(t.header&&!g&&x.length&&!G){var Q=x[0],ne=Object.create(null),_e=new Set(Q);let we=!1;for(let fe=0;fe{var i;return!!o.WORKERS_SUPPORTED&&(i=(()=>{var n=b.URL||b.webkitURL||null,p=$.toString();return o.BLOB_URL||(o.BLOB_URL=n.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; ","(",p,")();"],{type:"text/javascript"})))})(),(i=new b.Worker(i)).onmessage=ye,i.id=w++,ie[i.id]=i)})()).userStep=r.step,s.userChunk=r.chunk,s.userComplete=r.complete,s.userError=r.error,r.step=E(r.step),r.chunk=E(r.chunk),r.complete=E(r.complete),r.error=E(r.error),delete r.worker,s.postMessage({input:t,config:r,workerId:s.id})},o.unparse=function(t,r){var s=!1,i=!0,n=",",p=`\r `,L='"',V=L+L,G=!1,m=null,T=!1,d=((()=>{if(typeof r=="object"){if(typeof r.delimiter!="string"||o.BAD_DELIMITERS.filter(function(g){return r.delimiter.indexOf(g)!==-1}).length||(n=r.delimiter),typeof r.quotes!="boolean"&&typeof r.quotes!="function"&&!Array.isArray(r.quotes)||(s=r.quotes),typeof r.skipEmptyLines!="boolean"&&typeof r.skipEmptyLines!="string"||(G=r.skipEmptyLines),typeof r.newline=="string"&&(p=r.newline),typeof r.quoteChar=="string"&&(L=r.quoteChar,V=L+L),typeof r.header=="boolean"&&(i=r.header),Array.isArray(r.columns)){if(r.columns.length===0)throw new Error("Option columns is empty");m=r.columns}r.escapeChar!==void 0&&(V=r.escapeChar+L),r.escapeFormulae instanceof RegExp?T=r.escapeFormulae:typeof r.escapeFormulae=="boolean"&&r.escapeFormulae&&(T=/^[=+\-@\t\r].*$/)}})(),new RegExp(se(L),"g"));if(typeof t=="string"&&(t=JSON.parse(t)),Array.isArray(t)){if(!t.length||Array.isArray(t[0]))return K(null,t,G);if(typeof t[0]=="object")return K(m||Object.keys(t[0]),t,G)}else if(typeof t=="object")return typeof t.data=="string"&&(t.data=JSON.parse(t.data)),Array.isArray(t.data)&&(t.fields||(t.fields=t.meta&&t.meta.fields||m),t.fields||(t.fields=Array.isArray(t.data[0])?t.fields:typeof t.data[0]=="object"?Object.keys(t.data[0]):[]),Array.isArray(t.data[0])||typeof t.data[0]=="object"||(t.data=[t.data])),K(t.fields||[],t.data||[],G);throw new Error("Unable to serialize unrecognized input");function K(g,a,J){var A="",P=(typeof g=="string"&&(g=JSON.parse(g)),typeof a=="string"&&(a=JSON.parse(a)),Array.isArray(g)&&0{for(var x=0;x<_.length;x++)if(-1=1e6?`${k(M/1e6)} km`:`${k(M/1e3,1)} m`}function Be(S){const M=Ke.unparse(S.map(B=>({...B,batteryHealth:JSON.stringify(B.batteryHealth)}))),$=URL.createObjectURL(new Blob([M],{type:"text/csv;charset=utf-8"})),b=document.createElement("a");b.href=$,b.download="fleet-battery-efficiency.csv",b.click(),URL.revokeObjectURL($)}function oe({label:S,value:M,detail:$}){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:S}),e.jsx("div",{className:"truncate text-sm font-semibold text-slate-100",children:M}),$?e.jsx("div",{className:"truncate text-[0.68rem] text-slate-500",children:$}):null]})}function W({field:S,sort:M,onSort:$,children:b}){return e.jsx("th",{children:e.jsxs("button",{type:"button",className:"whitespace-nowrap text-left",onClick:()=>$(S),children:[b,M.key===S?M.descending?" ↓":" ↑":""]})})}function Qe({report:S,refresh:M}){const $=Ue(),b=Ne(j=>j.session?.role||null),B=b==="admin"||b==="lockdown",[z,f]=he.useState({roverId:S.rovers[0]?.roverId||"",chemistry:"unknown",ratedCapacityMah:"",installedDate:new Date().toISOString().slice(0,10),notes:""}),[ie,w]=he.useState("");function o(j){j.preventDefault(),w("Saving…"),$.emit("fleetReports:replaceBattery",{...z,ratedCapacityMah:Number(z.ratedCapacityMah),installedAt:new Date(`${z.installedDate}T12:00:00`).getTime()},(C={})=>{w(C.error||`Registered ${C.battery?.batteryKey||"battery"}`),C.error||M()})}return e.jsxs(de,{title:"Battery identity and baselines",meta:`${S.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:S.batteryRegistry.map(j=>e.jsxs("tr",{className:"border-t border-neutral-700/70 text-slate-200",children:[e.jsx("td",{children:j.roverId}),e.jsx("td",{children:j.batteryKey}),e.jsx("td",{children:j.chemistry||"--"}),e.jsx("td",{children:k(j.ratedCapacityMah,0)}),e.jsx("td",{children:xe(j.installedAt)}),e.jsx("td",{children:xe(j.retiredAt)}),e.jsx("td",{children:k(j.healthyBaselineMah,0)}),e.jsx("td",{children:j.notes||"--"})]},j.batteryKey))})]})}),B?e.jsxs("form",{className:"surface grid gap-0.5 p-1 text-xs md:grid-cols-2 xl:grid-cols-6",onSubmit:o,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:z.roverId,onChange:j=>f(C=>({...C,roverId:j.target.value})),children:S.rovers.map(j=>e.jsx("option",{value:j.roverId,children:j.name},j.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:z.chemistry,onChange:j=>f(C=>({...C,chemistry:j.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:z.ratedCapacityMah,onChange:j=>f(C=>({...C,ratedCapacityMah:j.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:z.installedDate,onChange:j=>f(C=>({...C,installedDate:j.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:z.notes,onChange:j=>f(C=>({...C,notes:j.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:ie})]})]}):null]})}function Ve(){const[S,M]=he.useState(Ee[1].ms),[$,b]=he.useState(()=>Date.now()),[B,z]=he.useState(""),[f,ie]=he.useState({key:"name",descending:!1}),{report:w,loading:o,error:j,refresh:C}=We({since:$-S,until:$,includeEvents:!1}),re=he.useMemo(()=>[...(w?.rovers||[]).filter(v=>`${v.name} ${v.roverId}`.toLowerCase().includes(B.trim().toLowerCase()))].sort((v,pe)=>{const se=f.key.startsWith("batteryHealth.")?v.batteryHealth?.[f.key.slice(14)]:v[f.key],ce=f.key.startsWith("batteryHealth.")?pe.batteryHealth?.[f.key.slice(14)]:pe[f.key],ye=typeof se=="string"?se.localeCompare(String(ce??"")):(Number(se)||0)-(Number(ce)||0);return f.descending?-ye:ye}),[B,w,f]);function O(l){ie(v=>({key:l,descending:v.key===l?!v.descending:!1}))}return e.jsxs(e.Fragment,{children:[e.jsxs(de,{title:"Fleet battery health and efficiency",meta:w?xe(w.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:S,onChange:l=>M(Number(l.target.value)),children:Ee.map(l=>e.jsx("option",{value:l.ms,children:l.label},l.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:B,onChange:l=>z(l.target.value)})]}),e.jsx("button",{type:"button",className:"button-dark px-1 py-0.5",onClick:()=>{b(Date.now()),C()},children:"Refresh"}),e.jsx(Oe,{className:"button-dark px-1 py-0.5",to:"/",children:"Back"})]}),o&&!w?e.jsx("p",{className:"text-slate-400",children:"Loading fleet metrics…"}):null,j?e.jsx("p",{className:"text-red-300",children:j}):null,w?e.jsxs("div",{className:"grid grid-cols-2 gap-0.5 md:grid-cols-4 xl:grid-cols-8",children:[e.jsx(oe,{label:"Rovers online",value:`${w.totals.onlineRoverCount}/${w.totals.roverCount}`}),e.jsx(oe,{label:"Distance",value:ve(w.totals.distanceMm)}),e.jsx(oe,{label:"Energy used",value:`${k(w.totals.dischargedWh)} Wh`}),e.jsx(oe,{label:"Fleet Wh/km",value:w.totals.overallWhPerKm==null?"--":k(w.totals.overallWhPerKm)}),e.jsx(oe,{label:"Moving Wh/km",value:w.totals.movingWhPerKm==null?"--":k(w.totals.movingWhPerKm)}),e.jsx(oe,{label:"Moving energy",value:`${k(w.totals.movingDischargedWh)} Wh`}),e.jsx(oe,{label:"Stationary energy",value:`${k(w.totals.stationaryDischargedWh)} Wh`}),e.jsx(oe,{label:"Attention",value:k(w.totals.attentionCount,0)})]}):null]}),w?e.jsxs(e.Fragment,{children:[e.jsx(de,{title:"All rovers",meta:`${re.length} visible`,actions:e.jsx("button",{type:"button",className:"button-dark px-1 py-0.25 text-xs",onClick:()=>Be(re),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(W,{field:"name",sort:f,onSort:O,children:"Rover"}),e.jsx(W,{field:"online",sort:f,onSort:O,children:"State"}),e.jsx(W,{field:"batteryHealth.capacityRetentionPercent",sort:f,onSort:O,children:"Health"}),e.jsx(W,{field:"batteryHealth.measuredUsableMah",sort:f,onSort:O,children:"Usable Ah"}),e.jsx(W,{field:"batteryHealth.measuredUsableWh",sort:f,onSort:O,children:"Usable Wh"}),e.jsx(W,{field:"batteryHealth.confidence",sort:f,onSort:O,children:"Confidence"}),e.jsx(W,{field:"overallWhPerKm",sort:f,onSort:O,children:"Wh/km"}),e.jsx(W,{field:"movingWhPerKm",sort:f,onSort:O,children:"Moving Wh/km"}),e.jsx(W,{field:"distanceMm",sort:f,onSort:O,children:"Distance"}),e.jsx(W,{field:"dischargedWh",sort:f,onSort:O,children:"Used Wh"}),e.jsx(W,{field:"movingDischargedWh",sort:f,onSort:O,children:"Moving Wh"}),e.jsx(W,{field:"stationaryDischargedWh",sort:f,onSort:O,children:"Stationary Wh"}),e.jsx(W,{field:"movingMs",sort:f,onSort:O,children:"Moving time"}),e.jsx(W,{field:"averageSpeedMmPerSecond",sort:f,onSort:O,children:"Average speed"}),e.jsx(W,{field:"maximumSpeedMmPerSecond",sort:f,onSort:O,children:"Maximum speed"}),e.jsx(W,{field:"latestChargeMah",sort:f,onSort:O,children:"Charge"}),e.jsx(W,{field:"averageVoltageMv",sort:f,onSort:O,children:"Voltage"}),e.jsx(W,{field:"averageCurrentMa",sort:f,onSort:O,children:"Current"}),e.jsx(W,{field:"maximumTemperatureC",sort:f,onSort:O,children:"Temperature"}),e.jsx(W,{field:"lastSampleAt",sort:f,onSort:O,children:"Last data"})]})}),e.jsx("tbody",{children:re.map(l=>{const v=l.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:l.name}),e.jsx("td",{children:l.online?"online":"offline"}),e.jsx("td",{children:v.capacityRetentionPercent==null?"--":`${k(v.capacityRetentionPercent,1)}%`}),e.jsx("td",{children:v.measuredUsableMah==null?"--":k(v.measuredUsableMah/1e3,3)}),e.jsx("td",{children:k(v.measuredUsableWh)}),e.jsx("td",{title:v.confidenceReason,children:v.confidence}),e.jsx("td",{children:l.overallWhPerKm==null?`need ${ve(l.efficiencyDistanceRequiredMm)}`:k(l.overallWhPerKm)}),e.jsx("td",{children:k(l.movingWhPerKm)}),e.jsx("td",{children:ve(l.distanceMm)}),e.jsx("td",{children:k(l.dischargedWh)}),e.jsx("td",{children:k(l.movingDischargedWh)}),e.jsx("td",{children:k(l.stationaryDischargedWh)}),e.jsx("td",{children:qe(l.movingMs)}),e.jsx("td",{children:l.averageSpeedMmPerSecond==null?"--":`${k(l.averageSpeedMmPerSecond)} mm/s`}),e.jsx("td",{children:l.maximumSpeedMmPerSecond==null?"--":`${k(l.maximumSpeedMmPerSecond)} mm/s`}),e.jsxs("td",{children:[k(l.latestChargeMah,0)," mAh"]}),e.jsxs("td",{children:[k(l.averageVoltageMv,0)," mV"]}),e.jsxs("td",{children:[k(l.averageCurrentMa,0)," mA"]}),e.jsxs("td",{children:[k(l.maximumTemperatureC,1)," °C"]}),e.jsx("td",{children:xe(l.lastSampleAt)})]},l.roverId)})})]})}),e.jsx(de,{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:re.map(l=>{const v=l.batteryHealth;return e.jsxs("tr",{className:"border-t border-neutral-700/70 text-slate-200",children:[e.jsx("td",{children:l.name}),e.jsx("td",{children:v.batteryKey}),e.jsx("td",{children:k(v.referenceMah,0)}),e.jsx("td",{children:k(v.measuredUsableMah,0)}),e.jsx("td",{children:k(v.observedUsableFloorMah,0)}),e.jsx("td",{children:v.capacityRetentionPercent==null?"--":`${k(v.capacityRetentionPercent,1)}%`}),e.jsx("td",{children:k(v.observationCount,0)}),e.jsxs("td",{children:[k(v.averageObservationDepthPercent,1),"%"]}),e.jsxs("td",{children:[k(v.dischargedThroughputMah,0)," mAh"]}),e.jsx("td",{children:xe(v.latestObservationAt)}),e.jsx("td",{children:v.confidenceReason})]},l.roverId)})})]})}),w.attention.length?e.jsx(de,{title:"Attention",meta:w.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:w.attention.map(l=>e.jsxs("tr",{className:"border-t border-neutral-700/70",children:[e.jsx("td",{children:l.roverId}),e.jsx("td",{children:l.severity}),e.jsx("td",{children:l.title})]},l.key))})]})}):null,e.jsx(Qe,{report:w,refresh:C}),e.jsxs(de,{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(){Ae({identitySurface:"passive"});const S=Ne(b=>De(b,"fleetReports")),{value:M}=Ie("page",{backgroundTheme:Le}),$=Te(M?.backgroundTheme);return e.jsxs("div",{className:`${$} min-h-screen text-slate-100`,children:[e.jsx(Fe,{}),e.jsx("main",{className:`mx-auto flex min-h-screen w-full max-w-[120rem] flex-col ${Pe} p-1`,children:S?e.jsx(Ve,{}):e.jsxs(de,{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(Oe,{className:"button-dark inline-block px-1 py-0.5 text-xs",to:"/",children:"Back to rover page"})]})})]})}export{Ge as default}; //# sourceMappingURL=FleetReportsApp-Bfte7B4J.js.map