import { CommentRepository, ReactionRepository } from '@amityco/ts-sdk-react-native';
export async function addCommentReaction(commentId, reactionName) {
  const reactionObject = new Promise(async (resolve, reject) => {
    try {
      const isCommentReactionAdded = await ReactionRepository.addReaction('comment', commentId, reactionName);
      resolve(isCommentReactionAdded);
    } catch (error) {
      reject(error);
    }
  });
  return reactionObject;
}
export async function removeCommentReaction(commentId, reactionName) {
  const reactionObject = new Promise(async (resolve, reject) => {
    try {
      const isCommentReactionRemoved = await ReactionRepository.removeReaction('comment', commentId, reactionName);
      resolve(isCommentReactionRemoved);
    } catch (error) {
      reject(error);
    }
  });
  return reactionObject;
}
export async function createComment(text, postId, mentionUserIds, mentionPosition, referenceType) {
  const createCommentObject = new Promise(async (resolve, reject) => {
    try {
      const newComment = {
        data: {
          text: text
        },
        referenceId: postId,
        referenceType: referenceType,
        mentionees: [{
          type: 'user',
          userIds: mentionUserIds
        }],
        metadata: {
          mentioned: mentionPosition
        }
      };
      const {
        data: comment
      } = await CommentRepository.createComment(newComment);
      resolve(comment);
    } catch (error) {
      reject(error);
    }
  });
  return createCommentObject;
}
export async function createReplyComment(text, postId, parentId, mentionUserIds, mentionPosition, referenceType) {
  const createCommentObject = new Promise(async (resolve, reject) => {
    try {
      const newComment = {
        data: {
          text: text
        },
        referenceId: postId,
        referenceType: referenceType,
        mentionees: [{
          type: 'user',
          userIds: mentionUserIds
        }],
        metadata: {
          mentioned: mentionPosition
        },
        parentId: parentId
      };
      const {
        data: comment
      } = await CommentRepository.createComment(newComment);
      resolve(comment);
    } catch (error) {
      reject(error);
    }
  });
  return createCommentObject;
}
export async function editComment(text, commentId, referenceType, mentionUserIds, mentionPosition) {
  const createCommentObject = new Promise(async (resolve, reject) => {
    try {
      const updatedComment = {
        data: {
          text: text
        },
        referenceType: referenceType,
        mentionees: [{
          type: 'user',
          userIds: mentionUserIds ?? []
        }],
        metadata: {
          mentioned: mentionPosition ?? []
        }
      };
      const {
        data: comment
      } = await CommentRepository.updateComment(commentId, updatedComment);
      resolve(comment);
    } catch (error) {
      reject(error);
    }
  });
  return createCommentObject;
}
export async function deleteCommentById(commentId) {
  const isDeletedObject = new Promise(async (resolve, reject) => {
    try {
      const hardDelete = await CommentRepository.deleteComment(commentId, true);
      if (hardDelete) {
        resolve(true);
      }
    } catch (error) {
      reject(error);
    }
  });
  return isDeletedObject;
}
//# sourceMappingURL=comment.js.map