import { createTRPCRouter, protectedProcedure } from "../trpc.js";
import {
  CommentEntityInputSchema,
  CommentMentionCandidatesInputSchema,
  CreateCommentInputSchema,
  DeleteCommentInputSchema,
  ResolveCommentInputSchema,
  countComments,
  createComment,
  deleteComment,
  listCommentMentionCandidates,
  listComments,
  resolveComment,
} from "./comment-procedure-support.js";

export const commentRouter = createTRPCRouter({
  list: protectedProcedure
    .input(CommentEntityInputSchema)
    .query(({ ctx, input }) => listComments(ctx, input)),

  listMentionCandidates: protectedProcedure
    .input(CommentMentionCandidatesInputSchema)
    .query(({ ctx, input }) => listCommentMentionCandidates(ctx, input)),

  count: protectedProcedure
    .input(CommentEntityInputSchema)
    .query(({ ctx, input }) => countComments(ctx, input)),

  create: protectedProcedure
    .input(CreateCommentInputSchema)
    .mutation(({ ctx, input }) => createComment(ctx, input)),

  resolve: protectedProcedure
    .input(ResolveCommentInputSchema)
    .mutation(({ ctx, input }) => resolveComment(ctx, input)),

  delete: protectedProcedure
    .input(DeleteCommentInputSchema)
    .mutation(({ ctx, input }) => deleteComment(ctx, input)),
});
