"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DataTableFilter = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("@chakra-ui/react");
const DataTableFilter = ({ column, table, }) => {
    var _a, _b, _c;
    const firstValue = (_a = table
        .getPreFilteredRowModel()
        .flatRows[0]) === null || _a === void 0 ? void 0 : _a.getValue(column.id);
    const columnFilterValue = column.getFilterValue();
    return typeof firstValue === "number" ? ((0, jsx_runtime_1.jsxs)(react_1.Flex, { children: [(0, jsx_runtime_1.jsx)(SearchInput, { size: "xs", type: "number", value: (_b = columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue[0]) !== null && _b !== void 0 ? _b : "", onChange: (e) => column.setFilterValue((old) => [
                    e.target.value,
                    old === null || old === void 0 ? void 0 : old[1],
                ]), placeholder: "Min" }), (0, jsx_runtime_1.jsx)(SearchInput, { type: "number", value: (_c = columnFilterValue === null || columnFilterValue === void 0 ? void 0 : columnFilterValue[1]) !== null && _c !== void 0 ? _c : "", onChange: (e) => column.setFilterValue((old) => [
                    old === null || old === void 0 ? void 0 : old[0],
                    e.target.value,
                ]), placeholder: "Max" })] })) : ((0, jsx_runtime_1.jsx)(SearchInput, { size: "xs", type: "text", value: (columnFilterValue !== null && columnFilterValue !== void 0 ? columnFilterValue : ""), onChange: (e) => column.setFilterValue(e.target.value), placeholder: "Search..." }));
};
exports.DataTableFilter = DataTableFilter;
const SearchInput = (0, react_1.chakra)(react_1.Input, {
    baseStyle: {
        rounded: "lg",
        maxW: "100px",
    },
});
//# sourceMappingURL=DataTableFilter.js.map