function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
import React from "react";
import ComparisonFilter from "./comparison";
import SelectFilter from "./select";
import SearchFilter from "./search";
var availableFilters = {
  comparison: ComparisonFilter,
  select: SelectFilter,
  "default": SearchFilter
};
var Filter = function Filter(_ref) {
  var _meta$filter, _meta$filter2;
  var column = _ref.column,
    testPrefix = _ref.testPrefix,
    index = _ref.index;
  if (!column.getCanFilter()) return null;
  var meta = typeof column.columnDef.meta === "function" ? column.columnDef.meta({}, column, index) : column.columnDef.meta;
  var selectedFilter = meta && meta != null && (_meta$filter = meta.filter) != null && _meta$filter.component ? meta == null || (_meta$filter2 = meta.filter) == null ? void 0 : _meta$filter2.component : "default";
  var filterOptions = meta && meta != null && meta.filter ? meta == null ? void 0 : meta.filter : {};
  var FilterComponent = availableFilters[selectedFilter];
  return /*#__PURE__*/React.createElement(FilterComponent, _extends({
    column: column,
    testPrefix: testPrefix
  }, filterOptions));
};
export default Filter;