import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { InteractionStatus } from '@vertesia/common';
import { Badge } from '@vertesia/ui/core';
export function VInteractionFacet({ buckets, name, placeholder }) {
    const options = buckets.map((bucket) => ({
        label: `(${bucket.count})`,
        value: bucket._id
    }));
    const filterGroup = {
        name: name,
        placeholder: placeholder || `${name.charAt(0).toUpperCase() + name.slice(1)}`,
        options: options,
        type: "select",
        labelRenderer: (interactionId) => {
            const bucket = buckets.find(b => b._id === interactionId);
            const displayName = bucket?.name || interactionId;
            // Determine badge variant based on status
            let badgeVariant = "success";
            if (bucket?.status) {
                switch (bucket.status) {
                    case InteractionStatus.published:
                        badgeVariant = "success";
                        break;
                    case InteractionStatus.archived:
                        badgeVariant = "destructive";
                        break;
                    default:
                        badgeVariant = "attention";
                        break;
                }
            }
            const badgeText = bucket?.version && bucket?.status ?
                `v${bucket.version} ${bucket.status}` :
                bucket?.status || (bucket?.version ? `v${bucket.version}` : '');
            return (_jsxs("div", { className: "w-full flex items-center justify-between", children: [_jsxs("div", { className: "flex flex-row flex-wrap items-center gap-2 min-w-0 flex-1", children: [_jsx("span", { className: "text-sm truncate", children: displayName }), badgeText && (_jsx(Badge, { variant: badgeVariant, className: "text-xs w-fit", children: badgeText }))] }), _jsxs("span", { className: "ml-2 text-xs shrink-0", children: ["(", bucket?.count || 0, ")"] })] }));
        },
        filterBy: (optionValue, searchText) => {
            const bucket = buckets.find(b => b._id === optionValue);
            const searchName = bucket?.name || optionValue;
            return searchName.toLowerCase().includes(searchText.toLowerCase());
        }
    };
    return filterGroup;
}
//# sourceMappingURL=VInteractionFacet.js.map