// Production UI: Sector Toolbar and Executive Summaries import { SECTORS } from '../../data/products.js'; import { fmtNum } from '../../core/formatters.js'; export function renderSectorTabsHtml(selectedSector, engine) { return `
${SECTORS.map(s => { const stats = engine?.sectorStats?.[s.id] || { revenueRate: 0 }; return ` `; }).join('')}
`; } export function renderSectorSummariesHtml(selectedSector, engine) { const currentSectorObj = SECTORS.find(s => s.id === selectedSector); let html = ''; // 1. Single Sector Executive Summary Banner if (selectedSector !== 'all' && currentSectorObj) { const stats = engine?.sectorStats?.[selectedSector] || { revenueRate: 0, unitsRate: 0, activeLines: 0, totalProduced: 0 }; html += `
INDUSTRY OUTPUT OVERVIEW

${currentSectorObj.name}

${currentSectorObj.description}

Wholesale Output Rate: +$${fmtNum(stats.revenueRate, 2)}/s
Production Velocity: ${fmtNum(stats.unitsRate, 1)} units/s
Operating Lines: ${stats.activeLines} active
Lifetime Sector Output: ${fmtNum(stats.totalProduced, 0)} units
`; } // 2. All Sectors Mini Summary Grid if (selectedSector === 'all') { html += `
${SECTORS.map(s => { const stats = engine?.sectorStats?.[s.id] || { revenueRate: 0, unitsRate: 0, activeLines: 0 }; return `

${s.name}

${stats.activeLines} lines active
Output Rate +$${fmtNum(stats.revenueRate, 2)}/s
Velocity ${fmtNum(stats.unitsRate, 1)} u/s
`; }).join('')}
`; } return html; } export function renderSectorBarHtml(selectedSector, engine) { return renderSectorTabsHtml(selectedSector, engine) + renderSectorSummariesHtml(selectedSector, engine); } export function updateSectorBarDom(selectedSector, engine) { const elPillRateAll = document.getElementById('pill-rate-all'); if (elPillRateAll) { const text = `+$${fmtNum(engine?.cashRate || 0, 1)}/s`; if (elPillRateAll.textContent !== text) elPillRateAll.textContent = text; } for (const s of SECTORS) { const stats = engine?.sectorStats?.[s.id]; if (stats) { const elPillRate = document.getElementById(`pill-rate-${s.id}`); if (elPillRate) { const text = `+$${fmtNum(stats.revenueRate, 1)}/s`; if (elPillRate.textContent !== text) elPillRate.textContent = text; } if (selectedSector === 'all') { const elMiniRev = document.getElementById(`all-sec-rev-${s.id}`); if (elMiniRev) { const text = `+$${fmtNum(stats.revenueRate, 2)}/s`; if (elMiniRev.textContent !== text) elMiniRev.textContent = text; } const elMiniUnits = document.getElementById(`all-sec-units-${s.id}`); if (elMiniUnits) { const text = `${fmtNum(stats.unitsRate, 1)} u/s`; if (elMiniUnits.textContent !== text) elMiniUnits.textContent = text; } const elMiniLines = document.getElementById(`all-sec-lines-${s.id}`); if (elMiniLines) { const text = `${stats.activeLines} lines active`; if (elMiniLines.textContent !== text) elMiniLines.textContent = text; } } } } if (selectedSector !== 'all') { const stats = engine?.sectorStats?.[selectedSector]; if (stats) { const elRev = document.getElementById('sec-sum-rev'); if (elRev) { const text = `+$${fmtNum(stats.revenueRate, 2)}/s`; if (elRev.textContent !== text) elRev.textContent = text; } const elUnits = document.getElementById('sec-sum-units'); if (elUnits) { const text = `${fmtNum(stats.unitsRate, 1)} units/s`; if (elUnits.textContent !== text) elUnits.textContent = text; } const elLines = document.getElementById('sec-sum-lines'); if (elLines) { const text = `${stats.activeLines} active`; if (elLines.textContent !== text) elLines.textContent = text; } const elTotal = document.getElementById('sec-sum-total'); if (elTotal) { const text = `${fmtNum(stats.totalProduced, 0)} units`; if (elTotal.textContent !== text) elTotal.textContent = text; } } } }