// FilterComponent.jsx
import PropTypes from 'prop-types';
import { FormControl, FormLabel, FormGroup, FormControlLabel, Checkbox } from '@mui/material';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
FilterComponent.propTypes = {
  filterList: PropTypes.array.isRequired,
  onChange: PropTypes.func.isRequired,
  index: PropTypes.number.isRequired,
  column: PropTypes.object.isRequired,
  filterValues: PropTypes.array.isRequired,
  label: PropTypes.string.isRequired,
  renderLabel: PropTypes.func.isRequired
};
export default function FilterComponent({
  filterList,
  onChange,
  index,
  column,
  filterValues,
  label,
  renderLabel
}) {
  return /*#__PURE__*/_jsxs(FormControl, {
    className: "filter-container",
    children: [/*#__PURE__*/_jsx(FormLabel, {
      component: "legend",
      children: label
    }), /*#__PURE__*/_jsx(FormGroup, {
      row: true,
      children: filterValues.map(x => /*#__PURE__*/_jsx(FormControlLabel, {
        control: /*#__PURE__*/_jsx(Checkbox, {
          checked: filterList[index].indexOf(x.value ?? x) > -1,
          onChange: event => {
            const newFilterList = [...filterList];
            if (event.target.checked) {
              newFilterList[index] = [...newFilterList[index], x.value ?? x];
            } else {
              newFilterList[index] = newFilterList[index].filter(v => v !== (x.value ?? x));
            }
            onChange(newFilterList[index], index, column);
          },
          name: x.value ?? x
        }),
        label: /*#__PURE__*/_jsx("span", {
          style: {
            display: 'flex',
            alignItems: 'center'
          },
          children: renderLabel(x)
        })
      }, x.value ?? x))
    })]
  });
}