import type {Sensor,SensorInventory,SensorPreparation} from './contracts'; export function devicePreparation(inventory:SensorInventory,device:Sensor):SensorPreparation|undefined { const operation=inventory.operations?.find(value=>value.device_id===device.id&&value.action_id==='prepare'&&value.state==='running'); if(!operation)return; if(inventory.preparations){ const matches=inventory.preparations.filter(value=>value.operation_id===operation.operation_id&&value.device_id===device.id); return matches.length===1&&matches[0].steps.length>0?matches[0]:undefined; } // Old Nodes publish a single RealSense installation report. Never project // that compatibility report onto an Insta360 or another vendor's device. const legacy=inventory.preparation; if(!device.id.startsWith('rsd455_')||!legacy||legacy.started_at*1000step.state==='running'); return {label,value:preparation&&preparation.steps.length>0?preparation.steps.filter(step=>step.state==='complete').length/preparation.steps.length:undefined, valueText:running?.label??label}; }