import VariablePlayClient from "./VariablePlayClient";
import type { VariableProblemCount } from "@/store/variableGameStore";

interface VariablePlayPageProps {
  searchParams?: {
    count?: string | string[];
  };
}

function parseProblemCount(count?: string | string[]): VariableProblemCount {
  if (Array.isArray(count)) {
    return parseProblemCount(count[0]);
  }

  return count === "5" ? 5 : 10;
}

export default function VariablePlayPage({
  searchParams,
}: VariablePlayPageProps) {
  return (
    <VariablePlayClient problemCount={parseProblemCount(searchParams?.count)} />
  );
}
