/** Favorable response share. An unknown answer is not favorable on either * wording direction. Never infer disagreement as the complement of agreement. */ export function favorableSurveyShare(row: { pct_agree?: string; pct_dk?: string; pct_disagree?: string }, reverse: boolean): number | null { const read = (value: string | undefined) => value === undefined || value.trim() === "" ? null : Number(value); const agree = read(row.pct_agree), unknown = read(row.pct_dk), disagree = read(row.pct_disagree); // Protect loads from older parsed files that retain a publisher's empty profile. if (agree === 0 && unknown === 0 && disagree === 0) return null; const value = reverse ? disagree : agree; return value !== null && Number.isFinite(value) && value >= 0 && value <= 100 ? value : null; }