import { useSelector } from '../../useSelector';
import { TagsFilter } from './TagsFilter';
import React from 'react';
export const buildTagsFilterElement = (state) => {
    const label = state.container.translate('cairo.tags.filterPanel.dropdown.title');
    return (React.createElement(TagsFilter, { key: state.collection.filters.tags?.name, filter: state.collection.filters.tags, accordionItemProps: {
            label,
        }, toolbarItemProps: {
            label,
        } }));
};
export const useTagsFilter = (state) => {
    useSelector(() => state.toolbar.collection.filters.tags);
    const buildTagsFilterWrapper = () => {
        return buildTagsFilterElement(state.toolbar);
    };
    return { buildTagsFilter: buildTagsFilterWrapper };
};
export const extractTagsFilter = (filters, key = 'tags.privateTags.tagIds') => {
    const tagsFilterValue = filters.tags;
    if (!tagsFilterValue?.length) {
        return {};
    }
    const tagIds = tagsFilterValue.map((tag) => tag.id);
    return { [key]: tagIds };
};
//# sourceMappingURL=tagsFilterBuilder.js.map