import React from "react";
import { Button } from "../button/Button";
import { FilterListItem } from "./FilterListItem";
import { TermListItem } from "./TermListItem";
export const FiltersBlock = ({ keywords, loading, searchAllDatasets, modality_selected, datasetType_selected, datasetStatus_selected, ageRange, subjectCountRange, authors, sex_selected, tasks, diagnosis_selected, section_selected, species_selected, studyDomains, date_selected, bodyParts, scannerManufacturers, scannerManufacturersModelNames, tracerNames, tracerRadionuclides, noFilters, removeFilterItem, removeAllFilters, numTotalResults, bidsDatasetType_selected, }) => {
    const ageRangeIsNull = JSON.stringify(ageRange) === JSON.stringify([null, null]);
    const subjectCountRangeIsNull = JSON.stringify(subjectCountRange) === JSON.stringify([null, null]);
    return (React.createElement("div", { className: "filters-block" },
        React.createElement("h2", null, noFilters
            ? (React.createElement("b", null,
                "Showing all available ",
                modality_selected ? modality_selected : "",
                " ",
                "datasets"))
            : (React.createElement(React.Fragment, null,
                loading
                    ? (" Loading Results...")
                    : (React.createElement(React.Fragment, null,
                        "These filters return ",
                        React.createElement("span", null, numTotalResults),
                        " ",
                        "datasets:",
                        " ")),
                React.createElement(Button, { label: "Clear All", size: "small", onClick: removeAllFilters })))),
        React.createElement("ul", { className: "active-filters" },
            keywords && (React.createElement(TermListItem, { type: "Keyword", item: { param: "keywords", values: keywords }, removeFilterItem: removeFilterItem() })),
            modality_selected && (React.createElement(FilterListItem, { type: "Modality", item: { param: "modality_selected", value: modality_selected }, removeFilterItem: removeFilterItem(true) })),
            bidsDatasetType_selected && (React.createElement(FilterListItem, { type: "Dataset Type", item: {
                    param: "bidsDatasetType_selected",
                    value: bidsDatasetType_selected,
                }, removeFilterItem: removeFilterItem(true) })),
            !searchAllDatasets && (React.createElement(React.Fragment, null,
                datasetType_selected && (React.createElement(FilterListItem, { type: "Type", item: {
                        param: "datasetType_selected",
                        value: datasetType_selected,
                    }, removeFilterItem: removeFilterItem() })),
                datasetStatus_selected && (React.createElement(FilterListItem, { type: "Status", item: {
                        param: "datasetStatus_selected",
                        value: datasetStatus_selected,
                    }, removeFilterItem: removeFilterItem() })))),
            !ageRangeIsNull && (React.createElement(FilterListItem, { type: "Age", item: { param: "ageRange", value: ageRange }, removeFilterItem: removeFilterItem() })),
            !subjectCountRangeIsNull && (React.createElement(FilterListItem, { type: "Participants", item: { param: "subjectCountRange", value: subjectCountRange }, removeFilterItem: removeFilterItem() })),
            authors && (React.createElement(TermListItem, { type: "Authors/PI", item: { param: "authors", values: authors }, removeFilterItem: removeFilterItem() })),
            sex_selected && (React.createElement(FilterListItem, { type: "Gender", item: { param: "sex_selected", value: sex_selected }, removeFilterItem: removeFilterItem() })),
            tasks && (React.createElement(TermListItem, { type: "Task", item: { param: "tasks", values: tasks }, removeFilterItem: removeFilterItem() })),
            diagnosis_selected && (React.createElement(FilterListItem, { type: "Diagnosis", item: { param: "diagnosis_selected", value: diagnosis_selected }, removeFilterItem: removeFilterItem() })),
            section_selected && (React.createElement(FilterListItem, { type: "Section", item: { param: "section_selected", value: section_selected }, removeFilterItem: removeFilterItem() })),
            species_selected && (React.createElement(FilterListItem, { type: "Species", item: { param: "species_selected", value: species_selected }, removeFilterItem: removeFilterItem() })),
            studyDomains && (React.createElement(TermListItem, { type: "Ontology", item: {
                    param: "studyDomains",
                    values: studyDomains,
                }, removeFilterItem: removeFilterItem() })),
            date_selected && (React.createElement(FilterListItem, { type: "Publication Date ", item: { param: "date_selected", value: date_selected }, removeFilterItem: removeFilterItem() })),
            bodyParts && (React.createElement(TermListItem, { type: "Target", item: { param: "bodyParts", values: bodyParts }, removeFilterItem: removeFilterItem() })),
            scannerManufacturers && (React.createElement(TermListItem, { type: "Scanner Manufacturers", item: {
                    param: "scannerManufacturers",
                    values: scannerManufacturers,
                }, removeFilterItem: removeFilterItem() })),
            scannerManufacturersModelNames && (React.createElement(TermListItem, { type: "Scanner Model", item: {
                    param: "scannerManufacturersModelNames",
                    values: scannerManufacturersModelNames,
                }, removeFilterItem: removeFilterItem() })),
            tracerNames && (React.createElement(TermListItem, { type: "Radiotracers", item: { param: "tracerNames", values: tracerNames }, removeFilterItem: removeFilterItem() })),
            tracerRadionuclides && (React.createElement(TermListItem, { type: "Radionuclide", item: { param: "tracerRadionuclides", values: tracerRadionuclides }, removeFilterItem: removeFilterItem() })))));
};
