import type { SolveInput } from '~/shared/types/schedule'

interface FeasibilityIssue {
  message: string
  blocking: boolean
}

export function checkFeasibility(input: SolveInput): FeasibilityIssue[] {
  const issues: FeasibilityIssue[] = []
  const { employees, framework } = input

  if (employees.length === 0) {
    issues.push({ message: 'Keine Mitarbeiter vorhanden', blocking: true })
    return issues
  }

  if (framework.shifts.length === 0) {
    issues.push({ message: 'Keine Schichten definiert', blocking: true })
    return issues
  }

  // Check if enough employees for the highest shift requirement
  const maxRequired = Math.max(...framework.shifts.map(s => s.workers_required))
  if (employees.length < maxRequired) {
    issues.push({
      message: `Zu wenige Mitarbeiter: ${maxRequired} benötigt, nur ${employees.length} vorhanden`,
      blocking: true
    })
  }

  return issues
}
