"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SubHeaderContainer = void 0;
var react_1 = __importStar(require("react"));
var react_utils_1 = require("@devesharp/react-utils");
var web_1 = require("@unform/web");
var Button_1 = require("../../Button");
var Select_1 = require("../../Select");
var TagsFilters_1 = require("../../TagsFilters");
var PageListingContext_1 = require("../PageListingContext");
var S = __importStar(require("./SubHeaderContainer.style"));
function SubHeaderContainer() {
    var context = react_1.useContext(PageListingContext_1.PageListingContext);
    return react_1.default.createElement(SubHeaderMainComponent, __assign({}, context));
}
exports.SubHeaderContainer = SubHeaderContainer;
var SubHeaderMainComponent = function FiltersComponent(props) {
    var pageCountStart = props.pageCountStart, pageCountEnd = props.pageCountEnd, searching = props.searching, loading = props.loading, _a = props.showCountListing, showCountListing = _a === void 0 ? true : _a, sortOptions = props.sortOptions, resourcesTotal = props.resourcesTotal, filters = props.filters, formSortRef = props.formSortRef, setSort = props.setSort, tagsFilters = props.tagsFilters, tagsFiltersRef = props.tagsFiltersRef, setFilters = props.setFilters, openFilters = props.openFilters;
    return (react_1.default.createElement(S.SubHeaderContainerStyle, null,
        react_1.default.createElement(SubHeaderComponent, { pageCountStart: pageCountStart, pageCountEnd: pageCountEnd, searching: searching, loading: loading, showCountListing: showCountListing, resourcesTotal: resourcesTotal, filters: filters, setSort: setSort, openFilters: openFilters, sortOptions: sortOptions, formSortRef: formSortRef }),
        tagsFilters && (react_1.default.createElement("div", { className: "tags-filter-container" },
            react_1.default.createElement(TagsFilters_1.TagsFilters, __assign({ ref: tagsFiltersRef, removeTag: function (key, value) {
                    var newFilters = __assign({}, filters);
                    newFilters[key] = value;
                    console.log(newFilters);
                    setFilters(function () { return react_utils_1.DeleteEmpty(newFilters); });
                } }, tagsFilters, { filters: filters }))))));
};
var SubHeaderComponent = function FiltersDesktop(props) {
    var pageCountStart = props.pageCountStart, pageCountEnd = props.pageCountEnd, searching = props.searching, loading = props.loading, _a = props.showCountListing, showCountListing = _a === void 0 ? true : _a, resourcesTotal = props.resourcesTotal, sortOptions = props.sortOptions, filters = props.filters, formSortRef = props.formSortRef, openFilters = props.openFilters, setSort = props.setSort;
    return (react_1.default.createElement("div", null,
        react_1.default.createElement("div", { className: "results-info" },
            react_1.default.createElement("div", { className: "text-results" }, showCountListing && (react_1.default.createElement("span", { className: ((searching || loading) && 'text-skeleton') + " text-non-skeleton" },
                react_1.default.createElement("b", null, pageCountStart),
                "-",
                react_1.default.createElement("b", null, pageCountEnd),
                " de ",
                react_1.default.createElement("b", null, resourcesTotal),
                " resultados"))),
            react_1.default.createElement("div", { className: "btn-filter-row" },
                react_1.default.createElement(Button_1.Button, { onClick: openFilters, "data-testid": "open-mobile-filters", type: "button", w100: true, outline: true, variant: "primary" }, "Editar Filtros")),
            sortOptions && (react_1.default.createElement("div", { className: "sort" },
                react_1.default.createElement(web_1.Form, { onSubmit: function () { }, initialData: filters, ref: formSortRef },
                    react_1.default.createElement(Select_1.Select, { name: "sort", onChange: function (sort) { return setSort(sort); }, "data-testid": "sort-filters", options: sortOptions })))))));
};
//# sourceMappingURL=SubHeaderContainer.js.map