import { jsx as _jsx } from "react/jsx-runtime";
import { Input } from 'antd';
import { debounce } from 'throttle-debounce';
import { useRef, useState } from 'react';
import { Select } from '../components';
const FilterInputs = {
    string: ({ values = [], disabled, onChange }) => (_jsx(Select, { disabled: disabled, style: { width: 300 }, mode: "tags", value: values, maxTagCount: "responsive", onChange: onChange }, "input")),
    number: ({ values = [], disabled, onChange }) => (_jsx(Input, { disabled: disabled, style: { width: 300 }, onChange: (e) => onChange([e.target.value]), value: values?.[0] || '' }, "input")),
};
export default function FilterInput({ member, disabled = false, updateMethods, }) {
    const Filter = FilterInputs[member.dimension.type] || FilterInputs.string;
    const ref = useRef(debounce(500, (member, values) => {
        updateMethods.update(member, { ...member, values });
    }));
    const [values, setValues] = useState(member.values);
    return (_jsx(Filter, { disabled: disabled, values: values, onChange: (values) => {
            setValues(values);
            ref.current(member, values);
        } }, "filter"));
}
//# sourceMappingURL=FilterInput.js.map