import { Layout, Txt, makeScene2D } from "@motion-canvas/2d";
import {
  Direction,
  beginSlide,
  createRef,
  slideTransition,
} from "@motion-canvas/core";
import { theme } from "../theme";

const reductions = [
  "1. α - conversion: Renaming of bound variables to avoid name clashes (out of\nscope - assume user knows not to bind variable names already chosen elsewhere).",
  "2. β - reduction: Application of a function to an argument.",
  "3. η - reduction: Conversion of a function to a point-free form (out of scope).",
];

export default makeScene2D(function* (view) {
  const rules = createRef<Txt>();

  view.add(
    <Layout layout direction="column" alignItems="center">
      <Txt fontSize={40} fontFamily={theme.font} fill={theme.text.hex}>
        The Lambda Calculus - Reductions
      </Txt>
      <Txt
        ref={rules}
        fontSize={30}
        fontFamily={theme.font}
        fill={theme.text.hex}
      ></Txt>
    </Layout>
  );

  yield* slideTransition(Direction.Right);
  yield* beginSlide("The Lambda Calculus - Reductions");

  for (const rule of reductions) {
    yield* rules().text(rules().text() + "\n\n" + rule, 1);
    yield* beginSlide("reduction - " + rule);
  }
});
