import { router } from "@repo/core-shared/trpc/init";

import { authContainer } from "../../di/container";
import { AUTH_SYMBOLS } from "../../di/symbols";

import { signInInputSchema } from "../../application/use-cases/sign-in.use-case";
import { signUpInputSchema } from "../../application/use-cases/sign-up.use-case";
import { signOutInputSchema } from "../../application/use-cases/sign-out.use-case";

import type { ISignInController } from "../../interface-adapters/controllers/sign-in.controller";
import type { ISignUpController } from "../../interface-adapters/controllers/sign-up.controller";
import type { ISignOutController } from "../../interface-adapters/controllers/sign-out.controller";

import { authProcedure } from "./procedures";

export const authRouter = router({
  signIn: authProcedure.input(signInInputSchema).mutation(({ input }) => {
    const ctrl = authContainer.get<ISignInController>(AUTH_SYMBOLS.ISignInController);
    return ctrl(input);
  }),

  signUp: authProcedure.input(signUpInputSchema).mutation(({ input }) => {
    const ctrl = authContainer.get<ISignUpController>(AUTH_SYMBOLS.ISignUpController);
    return ctrl(input);
  }),

  signOut: authProcedure.input(signOutInputSchema).mutation(({ input }) => {
    const ctrl = authContainer.get<ISignOutController>(AUTH_SYMBOLS.ISignOutController);
    return ctrl(input);
  }),
});

export type AuthRouter = typeof authRouter;
