import React, {useState, useEffect} from 'react'; import {Upload, Download, RefreshCw, Play, Info, ArrowRight, CheckCircle2} from 'lucide-react'; import Papa from 'papaparse'; async function api(path,payload){const r=await fetch(path,{method:payload===undefined?'GET':'POST',headers:payload===undefined?{}:{'Content-Type':'application/json'},body:payload===undefined?undefined:JSON.stringify(payload)});const d=await r.json();if(!r.ok)throw Error(d.detail||'Request failed');return d;} function save(value,name){const url=URL.createObjectURL(new Blob([JSON.stringify(value,null,2)],{type:'application/json'}));const a=document.createElement('a');a.href=url;a.download=name;a.click();URL.revokeObjectURL(url);} function SmallTable({rows,fields}){return
{fields.map(([key,label])=>)}{rows.map((row,i)=>{fields.map(([key])=>)})}
{label}
{typeof row[key]==='number'?row[key].toLocaleString(undefined,{maximumFractionDigits:3}):String(row[key]??'—')}
} function Note({children}){return
{children}
} export function AuditDatasets(){ const [catalog,setCatalog]=useState(null),[error,setError]=useState(''); useEffect(()=>{api('/api/datasets/manifest').then(setCatalog).catch(e=>setError(e.message));},[]); return

Inspect the benchmark data

Source snapshots, recorded predictions, truth values, protocol and checksums.

Public audit ZIP
{error&&

{error}

}
{catalog?.datasets.map(d=>
{d.title}{d.rows.toLocaleString()} rows · {d.unit}{d.sha256}
CSV
)}
These downloads contain official grid snapshots and recorded benchmark evidence. Uploaded customer bills and private analysis results are separate. Transformer/LLM evidence remains retrospective.
; } export default function AnalysisPanel({country,quotes,onProfile,onError}){ const [busy,setBusy]=useState(false),[importJob,setImportJob]=useState(null),[imported,setImported]=useState(null),[job,setJob]=useState(null),[result,setResult]=useState(null),[reviewed,setReviewed]=useState(false),[future,setFuture]=useState(false),[growth,setGrowth]=useState(5),[history,setHistory]=useState(null),[mode,setMode]=useState('switching'),[bulkInput,setBulkInput]=useState(''),[selected,setSelected]=useState(''); const run=async(fn)=>{setBusy(true);onError('');try{await fn()}catch(e){onError(e.message)}finally{setBusy(false)}}; const poll=async(jid,type)=>{const r=await api('/api/analysis_result',{job_id:jid,limit:20});if(r.state==='failed')throw Error(r.error);if(type==='import'){setImportJob(r);if(r.state==='completed'){setImported(r.result);setReviewed(false);}}else{setJob(r);if(r.state==='completed')setResult(r.result);}return r;}; useEffect(()=>{let jid=importJob?.job_id;if(!jid||!['queued','running'].includes(importJob.state||'queued'))return;let id=setInterval(()=>poll(jid,'import').catch(e=>{onError(e.message);clearInterval(id);}),2500);return()=>clearInterval(id)},[importJob?.job_id,importJob?.state]); useEffect(()=>{let jid=job?.job_id;if(!jid||!['queued','running'].includes(job.state||'queued'))return;let id=setInterval(()=>poll(jid,'analysis').catch(e=>{onError(e.message);clearInterval(id);}),2500);return()=>clearInterval(id)},[job?.job_id,job?.state]); const upload=async(files)=>{if(!files.length)return;if([...files].reduce((s,f)=>s+f.size,0)>25*1024*1024)throw Error('Combined compressed files must be at most 25 MiB.');let form=new FormData();for(const f of files)form.append('files',f);const r=await fetch('/api/billing_import',{method:'POST',body:form});const data=await r.json();if(!r.ok)throw Error(data.detail||'Import failed');setImported(null);setImportJob({...data,state:'queued'});setSelected('');}; const profiles=imported?.profiles||[]; const submit=async()=>{let payload;if(mode==='switching'){const prices={};for(const q of quotes||[])prices[q.provider]=Number(growth);payload={kind:'switching',import_job_id:importJob?.job_id,profiles:selected?profiles.filter(p=>p.profile_id===selected):profiles,offers:quotes||[],horizons:[3,12,36],accept_profile_estimates:reviewed,assume_future_enrolment:future,price_scenarios:[{name:'constant-price',annual_price_change_pct:{}},{name:'declared-price-change',annual_price_change_pct:prices}]};}else{payload=JSON.parse(bulkInput);payload.kind=mode;}const data=await api('/api/analysis_submit',payload);setResult(null);setJob({...data,state:'queued'});}; const plans=result?.profiles?.flatMap(p=>p.plans.map(x=>({profile_id:p.profile_id,...x})))||[]; return <>

Import compressed bills

Keep multiple meters apart. Inspect what was extracted.

ZIP · PDF · CSV · JSON
Text-based EDP Portugal PDFs are supported. Germany/Australia and other PDF layouts need normalized CSV/JSON. Water and unrelated files are excluded; scanned PDFs need OCR elsewhere. Raw files are used for this temporary computation and are not published.{importJob&&
Import: {importJob.state}
}{imported&&<>({status,count}))} fields={[["status","Document outcome"],["count","Count"]]}/>
Private import audit
}

Short, middle and long horizons

Compare staying with constrained swap schedules over 3, 12 and 36 months, under explicit future-price assumptions.

{mode==='switching'&&}
{mode==='switching'?<>{quotes?.length||0} supplied quotes loaded from Quote explorer. A comparison requires complete, fresh, tax-inclusive quotes matching each meter’s power and contract terms. Without quotes the scenario keeps the historical bill baseline.:<>