import { get, post } from "./serviceHelper";
export function createOrUpdateComment(comment) {
    return post("/parhelia/comments/save", comment);
}
export function getComments(itemId, language, version, reviewId) {
    const params = new URLSearchParams({
        mainItemId: itemId,
        language,
        version: version.toString(),
    });
    if (reviewId) {
        params.set("reviewId", reviewId);
    }
    return get(`/parhelia/comments/index?${params.toString()}`);
}
// Latest comments across the system, already filtered by backend for user access.
export function getLatestComments(take, language) {
    const params = new URLSearchParams();
    if (take && take > 0)
        params.set("take", take.toString());
    if (language)
        params.set("language", language);
    const query = params.toString();
    return get(`/parhelia/comments/latest${query ? `?${query}` : ""}`);
}
export function resolveComment(comment) {
    return post(`/parhelia/comments/resolve?commentId=${comment.id}`, {});
}
export function unresolveComment(comment) {
    return post(`/parhelia/comments/unresolve?commentId=${comment.id}`, {});
}
export function deleteComment(comment) {
    return post(`/parhelia/comments/delete?commentId=${comment.id}`, {});
}
export function getReviews(itemId, language, version) {
    return get(`/parhelia/reviews/index?itemId=${itemId}&language=${language}&version=${version}`);
}
export function approveReview(itemDescriptor) {
    return post(`/parhelia/reviews/approve`, itemDescriptor);
}
export function rejectReview(itemDescriptor) {
    return post(`/parhelia/reviews/reject`, itemDescriptor);
}
// New multi-reviewer multi-page review functions
export function createReview(request) {
    return post(`/parhelia/reviews/create`, request);
}
export function getAllReviews(language) {
    // Don't filter by language in the reviews list - show all reviews
    return get(`/parhelia/reviews/all`);
}
export function getReviewStatus(reviewId) {
    return get(`/parhelia/reviews/status?reviewId=${reviewId}`);
}
export function addReviewers(reviewId, reviewers) {
    return post(`/parhelia/reviews/addReviewers`, { reviewId, reviewers });
}
export function removeReviewer(assignmentId) {
    return post(`/parhelia/reviews/removeReviewer`, { assignmentId });
}
export function sendInvitations(assignmentIds) {
    return post(`/parhelia/reviews/invite`, { assignmentIds });
}
export function setItemDecision(assignmentId, itemId, itemLanguage, itemVersion, decision) {
    return post(`/parhelia/reviews/setItemDecision`, {
        assignmentId,
        itemId,
        itemLanguage,
        itemVersion,
        decision,
    });
}
export function setFinalDecision(reviewId, decision) {
    return post(`/parhelia/reviews/setFinalDecision`, { reviewId, decision });
}
export function addPagesToReview(reviewId, items) {
    return post(`/parhelia/reviews/addItems`, { reviewId, items });
}
export function removePagesFromReview(reviewId, items) {
    return post(`/parhelia/reviews/removeItems`, { reviewId, items });
}
export function unlockReview(reviewId, secret) {
    return post(`/parhelia/reviews/unlock`, { reviewId, secret });
}
export function deleteReview(reviewId) {
    return post(`/parhelia/reviews/deletereview`, {
        reviewId,
    });
}
export function deleteReviews(reviewIds) {
    return post(`/parhelia/reviews/deletereviews`, {
        reviewIds,
    });
}
export function updateReviewSettings(reviewId, languages, secret, updateWorkflowOnCompletion, requiredApprovals, removeSecret, shareCommentsAndSuggestions) {
    return post(`/parhelia/reviews/updateSettings`, {
        reviewId,
        languages,
        secret,
        removeSecret,
        updateWorkflowOnCompletion,
        requiredApprovals,
        shareCommentsAndSuggestions,
    });
}
export function getInvitationLink(assignmentId) {
    return post(`/parhelia/reviews/getInvitationLink`, { assignmentId });
}
export function getPreconfiguredReviewers(itemIds, language = "en") {
    return post(`/parhelia/reviews/getPreconfiguredReviewers`, {
        itemIds,
        language,
    });
}
// New API endpoints for comment related items
export function getCommentsByRelatedItem(itemId) {
    return get(`/parhelia/comments/getCommentsByRelatedItem?itemId=${itemId}`);
}
export function addRelatedItemToComment(commentId, itemId) {
    return post(`/parhelia/comments/addRelatedItem?commentId=${commentId}&itemId=${itemId}`, {});
}
export function removeRelatedItemFromComment(commentId, itemId) {
    return post(`/parhelia/comments/removeRelatedItem?commentId=${commentId}&itemId=${itemId}`, {});
}
// Tags
export async function getAvailableCommentTags(descriptor) {
    const result = await post(`/parhelia/comments/getAvailableTags`, descriptor);
    return (result.data || []);
}
//# sourceMappingURL=reviewsService.js.map