/* =====================================================================
 * roi-preflight-steps — derivation helper for RoiPreflightChecklist.
 *
 * Extracted to a sibling module to keep RoiPreflightChecklist.tsx a
 * component-only file (react-refresh/only-export-components).
 * ===================================================================== */

export interface RoiPreflightStep {
  /** Short step name — "Analysis complete", "N recommendations ready", etc. */
  label: string;
  /** Optional one-line sub-text rendered under the label. */
  hint?: string;
  /** Visual state — `done` shows a check in a filled circle. */
  status: 'done' | 'pending';
}

/**
 * Derive the three preflight steps shown above the ROI empty state.
 *
 * Pass `null` for `recommendationsReady` when the calling page does not
 * surface a usable count — the middle step is then "always-green" with a
 * generic label, since reaching this surface implies recommendations
 * have been generated upstream.
 */
export function deriveRoiPreflightSteps(
  recommendationsReady: number | null,
): RoiPreflightStep[] {
  const hasKnownCount =
    typeof recommendationsReady === 'number' && recommendationsReady > 0;
  const knownZero =
    typeof recommendationsReady === 'number' && recommendationsReady === 0;

  return [
    {
      label: 'Analysis complete',
      status: 'done',
    },
    {
      label: hasKnownCount
        ? `${recommendationsReady} recommendation${recommendationsReady === 1 ? '' : 's'} ready`
        : 'Recommendations ready',
      hint: knownZero ? 'Run an analysis to surface what to fix.' : undefined,
      // Unknown count → always-green per design (we know recommendations exist
      // upstream by the time the operator reaches this surface).
      status: knownZero ? 'pending' : 'done',
    },
    {
      label: 'Apply your first one',
      hint: 'Mark a recommendation Applied to start before-after tracking.',
      status: 'pending',
    },
  ];
}
