"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FiltersBlock = void 0;
const react_1 = __importDefault(require("react"));
const Button_1 = require("../button/Button");
const FilterListItem_1 = require("./FilterListItem");
const TermListItem_1 = require("./TermListItem");
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, }) => {
    const ageRangeIsNull = JSON.stringify(ageRange) === JSON.stringify([null, null]);
    const subjectCountRangeIsNull = JSON.stringify(subjectCountRange) === JSON.stringify([null, null]);
    return (react_1.default.createElement("div", { className: "filters-block" },
        react_1.default.createElement("h2", null, noFilters ? (react_1.default.createElement("b", null,
            "Showing all available ",
            modality_selected ? modality_selected : '',
            ' ',
            "datasets")) : (react_1.default.createElement(react_1.default.Fragment, null,
            loading ? (' Loading Results...') : (react_1.default.createElement(react_1.default.Fragment, null,
                "These filters return ",
                react_1.default.createElement("span", null, numTotalResults),
                " datasets:",
                ' ')),
            react_1.default.createElement(Button_1.Button, { label: "Clear All", size: "small", onClick: removeAllFilters })))),
        react_1.default.createElement("ul", { className: "active-filters" },
            keywords && (react_1.default.createElement(TermListItem_1.TermListItem, { type: "Keyword", item: { param: 'keywords', values: keywords }, removeFilterItem: removeFilterItem() })),
            modality_selected && (react_1.default.createElement(FilterListItem_1.FilterListItem, { type: "Modality", item: { param: 'modality_selected', value: modality_selected }, removeFilterItem: removeFilterItem(true) })),
            !searchAllDatasets && (react_1.default.createElement(react_1.default.Fragment, null,
                datasetType_selected && (react_1.default.createElement(FilterListItem_1.FilterListItem, { type: "Type", item: {
                        param: 'datasetType_selected',
                        value: datasetType_selected,
                    }, removeFilterItem: removeFilterItem() })),
                datasetStatus_selected && (react_1.default.createElement(FilterListItem_1.FilterListItem, { type: "Status", item: {
                        param: 'datasetStatus_selected',
                        value: datasetStatus_selected,
                    }, removeFilterItem: removeFilterItem() })))),
            !ageRangeIsNull && (react_1.default.createElement(FilterListItem_1.FilterListItem, { type: "Age", item: { param: 'ageRange', value: ageRange }, removeFilterItem: removeFilterItem() })),
            !subjectCountRangeIsNull && (react_1.default.createElement(FilterListItem_1.FilterListItem, { type: "Participants", item: { param: 'subjectCountRange', value: subjectCountRange }, removeFilterItem: removeFilterItem() })),
            authors && (react_1.default.createElement(TermListItem_1.TermListItem, { type: "Authors/PI", item: { param: 'authors', values: authors }, removeFilterItem: removeFilterItem() })),
            sex_selected && (react_1.default.createElement(FilterListItem_1.FilterListItem, { type: "Gender", item: { param: 'sex_selected', value: sex_selected }, removeFilterItem: removeFilterItem() })),
            tasks && (react_1.default.createElement(TermListItem_1.TermListItem, { type: "Task", item: { param: 'tasks', values: tasks }, removeFilterItem: removeFilterItem() })),
            diagnosis_selected && (react_1.default.createElement(FilterListItem_1.FilterListItem, { type: "Diagnosis", item: { param: 'diagnosis_selected', value: diagnosis_selected }, removeFilterItem: removeFilterItem() })),
            section_selected && (react_1.default.createElement(FilterListItem_1.FilterListItem, { type: "Section", item: { param: 'section_selected', value: section_selected }, removeFilterItem: removeFilterItem() })),
            species_selected && (react_1.default.createElement(FilterListItem_1.FilterListItem, { type: "Species", item: { param: 'species_selected', value: species_selected }, removeFilterItem: removeFilterItem() })),
            studyDomains && (react_1.default.createElement(TermListItem_1.TermListItem, { type: "Ontology", item: {
                    param: 'studyDomains',
                    values: studyDomains,
                }, removeFilterItem: removeFilterItem() })),
            date_selected && (react_1.default.createElement(FilterListItem_1.FilterListItem, { type: "Publication Date ", item: { param: 'date_selected', value: date_selected }, removeFilterItem: removeFilterItem() })),
            bodyParts && (react_1.default.createElement(TermListItem_1.TermListItem, { type: "Target", item: { param: 'bodyParts', values: bodyParts }, removeFilterItem: removeFilterItem() })),
            scannerManufacturers && (react_1.default.createElement(TermListItem_1.TermListItem, { type: "Scanner Manufacturers", item: {
                    param: 'scannerManufacturers',
                    values: scannerManufacturers,
                }, removeFilterItem: removeFilterItem() })),
            scannerManufacturersModelNames && (react_1.default.createElement(TermListItem_1.TermListItem, { type: "Scanner Model", item: {
                    param: 'scannerManufacturersModelNames',
                    values: scannerManufacturersModelNames,
                }, removeFilterItem: removeFilterItem() })),
            tracerNames && (react_1.default.createElement(TermListItem_1.TermListItem, { type: "Radiotracers", item: { param: 'tracerNames', values: tracerNames }, removeFilterItem: removeFilterItem() })),
            tracerRadionuclides && (react_1.default.createElement(TermListItem_1.TermListItem, { type: "Radionuclide", item: { param: 'tracerRadionuclides', values: tracerRadionuclides }, removeFilterItem: removeFilterItem() })))));
};
exports.FiltersBlock = FiltersBlock;
