import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { Checkbox } from "../../components/ui/checkbox";
import { Button } from "../../components/ui/button";
import { Check, X, Clock, Lock, Calendar, MessageSquare, Lightbulb, Globe, Users, ClipboardCheck, } from "lucide-react";
import { DeleteIcon } from "../../components/ui/delete-icon";
import { formatDate } from "../utils";
import { cn } from "../../lib/utils";
export function ReviewCard({ review, isSelected, onSelect, onClick, onDelete, canDelete, }) {
    const status = review.finalDecision ?? review.status ?? "In Progress";
    const getStatusInfo = () => {
        if (status === "Approved") {
            return {
                icon: _jsx(Check, { className: "text-feedback-green h-3 w-3" }),
                text: "Approved",
                className: "text-feedback-green",
            };
        }
        if (status === "Rejected") {
            return {
                icon: _jsx(X, { className: "text-feedback-red h-3 w-3" }),
                text: "Rejected",
                className: "text-feedback-red",
            };
        }
        return {
            icon: _jsx(Clock, { className: "text-neutral-grey-50 h-3 w-3" }),
            text: "In Progress",
            className: "text-neutral-grey-50",
        };
    };
    const statusInfo = getStatusInfo();
    return (_jsxs("div", { "data-testid": "review-card", "data-review-id": review.reviewId, onClick: () => onClick(review.reviewId), className: cn("group relative flex cursor-pointer flex-col rounded-lg border bg-white p-3 transition-shadow hover:shadow-md", isSelected
            ? "border-feedback-blue bg-feedback-blue-light/30 ring-feedback-blue/20 ring-1"
            : "border-border-default"), children: [_jsxs("div", { className: "mb-2 flex items-start gap-2", children: [_jsx("div", { onClick: (e) => {
                            e.stopPropagation();
                            if (canDelete) {
                                onSelect(review.reviewId, !isSelected);
                            }
                        }, className: cn("mt-1 shrink-0", !canDelete && "invisible"), children: _jsx(Checkbox, { checked: isSelected, onCheckedChange: (checked) => onSelect(review.reviewId, checked === true), disabled: !canDelete, onClick: (e) => e.stopPropagation() }) }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsxs("div", { className: "mb-0.5 flex items-center gap-2", children: [_jsx("h4", { "data-testid": "review-card-title", className: "text-neutral-grey-100 truncate text-sm font-medium", children: review.title || `Review ${review.reviewId.slice(0, 8)}` }), review.requiresSecret && (_jsx(Lock, { className: "text-neutral-grey-50 h-3 w-3" }))] }), _jsxs("div", { className: "text-neutral-grey-50 flex items-center gap-1.5 text-[11px]", children: [_jsxs("span", { className: "truncate", children: ["By ", review.createdBy] }), _jsx("span", { children: "\u2022" }), _jsx("span", { className: "whitespace-nowrap", children: formatDate(new Date(review.createdAt)) })] })] }), canDelete && (_jsx(Button, { variant: "ghost", size: "icon", onClick: (e) => onDelete(review.reviewId, e), className: "text-neutral-grey-50 hover:bg-neutral-grey-5 hover:text-neutral-grey-50 -mt-1 -mr-1 h-7 w-7 opacity-0 transition-opacity group-hover:opacity-100", children: _jsx(DeleteIcon, { size: "md" }) }))] }), _jsxs("div", { className: "border-border-default flex flex-wrap items-center gap-x-3 gap-y-2 border-t pt-2", children: [_jsxs("div", { className: "flex shrink-0 items-center gap-1", children: [statusInfo.icon, _jsx("span", { className: cn("text-[10px] font-bold", statusInfo.className), children: statusInfo.text })] }), _jsx("div", { className: "xs:block bg-border-default hidden h-3 w-px shrink-0" }), _jsx("div", { className: "flex shrink-0 items-center gap-2", children: review.commentsCount || review.suggestionsCount ? (_jsxs(_Fragment, { children: [review.commentsCount ? (_jsxs("div", { className: "text-neutral-grey-50 flex items-center gap-1 text-[10px]", title: "Comments", children: [_jsx(MessageSquare, { className: "h-3 w-3" }), _jsx("span", { children: review.commentsCount })] })) : null, review.suggestionsCount ? (_jsxs("div", { className: "text-feedback-orange flex items-center gap-1 text-[10px] font-medium", title: "Suggestions", children: [_jsx(Lightbulb, { className: "h-3 w-3" }), _jsx("span", { children: review.suggestionsCount })] })) : null] })) : (_jsx("span", { className: "text-neutral-grey-50 text-[10px] italic", children: "No feedback" })) }), _jsxs("div", { className: "text-neutral-grey-50 ml-auto flex shrink-0 items-center gap-2.5", children: [_jsxs("div", { className: "flex items-center gap-1", title: "Language", children: [_jsx(Globe, { className: "h-3 w-3" }), _jsx("span", { className: "text-neutral-grey-50 text-[10px]", children: review.language === "*"
                                            ? "All"
                                            : review.language === "mixed"
                                                ? "Mixed"
                                                : review.language })] }), _jsxs("div", { className: "flex items-center gap-1", title: "Reviewers", children: [_jsx(Users, { className: "h-3 w-3" }), _jsx("span", { className: "text-neutral-grey-50 text-[10px]", children: review.reviewersCount })] }), _jsxs("div", { className: "flex items-center gap-1", title: "Pages", children: [_jsx(ClipboardCheck, { className: "h-3 w-3", strokeWidth: 1 }), _jsx("span", { className: "text-neutral-grey-50 text-[10px]", children: review.pagesCount })] })] })] }), review.expiresAtUtc && !review.isExpired && (_jsxs("div", { className: "border-component-shared/50 bg-component-shared-drop-zone/50 text-component-shared mt-2 flex items-center justify-center gap-1 rounded border py-1 text-[10px]", children: [_jsx(Calendar, { className: "h-3 w-3" }), _jsxs("span", { children: ["Expires ", formatDate(new Date(review.expiresAtUtc))] })] })), review.isExpired && (_jsxs("div", { className: "border-feedback-red/50 bg-feedback-red-light/50 text-feedback-red mt-2 flex items-center justify-center gap-1 rounded border py-1 text-[10px] font-medium", children: [_jsx(X, { className: "h-3 w-3" }), _jsx("span", { children: "Expired" })] }))] }));
}
//# sourceMappingURL=ReviewCard.js.map