import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { UserInfo } from '../../user/UserInfo';
export function createUserFilterGroup({ buckets, name, placeholder }) {
    const options = buckets.map((bucket) => {
        return {
            value: bucket._id,
            label: `(${bucket.count})`
        };
    });
    const filterGroup = {
        name: name,
        placeholder: placeholder || `${name.charAt(0).toUpperCase() + name.slice(1)}`,
        options: options,
        labelRenderer: (userRef) => {
            const isUnknownUser = userRef === 'Unknown User' || !userRef;
            if (isUnknownUser) {
                // Find the count for this user from buckets
                const bucket = buckets.find(b => b._id === userRef);
                return `Unknown User (${bucket?.count || 0})`;
            }
            // For known users, render UserInfo with count
            const bucket = buckets.find(b => b._id === userRef);
            return (_jsxs("div", { className: "flex items-center w-full gap-2", children: [_jsx("div", { className: "flex-1 min-w-0 flex items-center truncate", children: _jsx(UserInfo, { userRef: userRef, showTitle: true, size: "sm" }) }), _jsxs("span", { className: "text-muted-foreground flex-shrink-0", children: ["(", bucket?.count || 0, ")"] })] }));
        },
    };
    return filterGroup;
}
export function VUserFacet({ buckets, name, placeholder }) {
    return createUserFilterGroup({ buckets, name, placeholder });
}
//# sourceMappingURL=VUserFacet.js.map