/**
 * Investment Section Builder
 *
 * Creates an investment and next steps page.
 * Consumer provides content only; styling is handled internally.
 */

import type { Page } from '../types'
import type { InvestmentConfig } from './types'

/** Tier descriptions for standard packages */
const TIER_DESCRIPTIONS: Record<string, string> = {
  tier1: 'Tier 1: Essential Automation - $1,500-3,000/month',
  tier2: 'Tier 2: Growth Automation - $3,000-5,000/month',
  tier3: 'Tier 3: Enterprise Automation - $5,000-10,000/month',
  custom: 'Custom Package - Tailored to your needs'
}

/** Default next steps if not provided */
const DEFAULT_NEXT_STEPS = [
  'Review this proposal and note any questions',
  'Schedule a follow-up call to discuss details',
  "We'll provide a detailed SOW with timeline",
  'Begin implementation within 2 weeks of approval'
]

/**
 * Creates an investment page with tier info and next steps
 *
 * @param config - Content-only configuration
 * @returns Page object ready for PDFDocument.pages array
 */
export function investmentSection(config: InvestmentConfig): Page {
  const {
    tier,
    customTierDescription,
    nextSteps = DEFAULT_NEXT_STEPS,
    contactCta = 'Questions? Reply to this email or use the contact link provided by your advisor'
  } = config

  const tierDescription = tier === 'custom' && customTierDescription
    ? customTierDescription
    : TIER_DESCRIPTIONS[tier]

  return {
    sections: [
      {
        type: 'card',
        title: 'Recommended Package',
        content: [
          { type: 'text', content: tierDescription, variant: 'subtitle' }
        ]
      },
      { type: 'text', content: 'Next Steps', variant: 'subtitle' },
      {
        type: 'list',
        ordered: true,
        items: nextSteps
      },
      {
        type: 'text',
        content: contactCta,
        variant: 'caption'
      }
    ],
    header: { title: 'Investment', variant: 'accent' },
    footer: true
  }
}
