/* ============================================================================
MOWDEW HOMEOWNER — Pool chemistry timeline + Reschedule / message owner
POV: Emma Walsh, 88 Crestline Ave (pool). Readings captured from a photo of
the test strip on each verified visit, trended over time.
========================================================================= */
/* Homeowner POV: Emma Walsh, 88 Crestline Ave. Full readings live in
POOL_CHEM_LOG (mowdew-chem.jsx, loaded first). CHEM_LOG kept as an alias. */
const CHEM_LOG = (window.POOL_CHEM_LOG || []);
/* ============================== POOL CHEMISTRY ====================== */
function HomeChemistry({ go, openFab }) {
const log = window.POOL_CHEM_LOG || [];
const latest = log[0];
const [trendKey, setTrendKey] = React.useState('ph');
const [showAll, setShowAll] = React.useState(false);
const TREND_KEYS = ['ph', 'cl', 'alk'];
const r = READINGS[trendKey];
const series = log.map(x => x[trendKey]).reverse();
const labels = log.map(x => x.short).reverse().map((s, i, a) => (i === 0 || i === a.length - 1 || i === Math.floor(a.length / 2)) ? s : '');
labels[labels.length - 1] = 'Now';
const inRange = log.filter(x => chemState(trendKey, x[trendKey]) === 'ideal').length;
const span = r.max - r.min;
return (