"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.buildCustomFieldFilterElement = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _react = _interopRequireDefault(require("react"));
var _DateCustomFieldFilter = require("./DateCustomFieldFilter");
var _DateTimeCustomFieldFilter = require("./DateTimeCustomFieldFilter");
var _CheckboxCustomFieldFilter = require("./CheckboxCustomFieldFilter");
var _NumberRangeFilter = require("../NumberRangeFilter");
var _OperatorFilterCustomFieldFilter = require("./OperatorFilterCustomFieldFilter");
var _fieldTypePrefixIcons = require("../../utils/fieldTypePrefixIcons");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/CustomFieldFilters/buildCustomFieldFilterElement.tsx";
const buildCustomFieldFilterElement = (state, customField) => {
  const customFieldFilterComponents = {
    date: _DateCustomFieldFilter.DateCustomFieldFilter,
    dateTime: _DateTimeCustomFieldFilter.DateTimeCustomFieldFilter,
    checkbox: _CheckboxCustomFieldFilter.CheckboxCustomFieldFilter,
    integer: _NumberRangeFilter.NumberRangeFilter,
    decimal: props => /*#__PURE__*/_react.default.createElement(_NumberRangeFilter.NumberRangeFilter, (0, _extends2.default)({}, props, {
      decimal: true,
      __self: void 0,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 23,
        columnNumber: 25
      }
    })),
    shortText: _OperatorFilterCustomFieldFilter.OperatorFilterCustomFieldFilter,
    url: _OperatorFilterCustomFieldFilter.OperatorFilterCustomFieldFilter,
    longText: _OperatorFilterCustomFieldFilter.OperatorFilterCustomFieldFilter
  };
  const CustomFieldFilterComponent = customFieldFilterComponents[customField.type];
  if (!CustomFieldFilterComponent) {
    return null;
  }
  const label = customField.label || customField.id;
  return /*#__PURE__*/_react.default.createElement(CustomFieldFilterComponent, {
    key: customField.id,
    filter: state.collection.filters[customField.id],
    fieldType: (0, _fieldTypePrefixIcons.toFieldType)(customField.type),
    accordionItemProps: {
      label
    },
    toolbarItemProps: {
      label
    },
    toolbarTagProps: {
      label
    },
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 39,
      columnNumber: 5
    }
  });
};
exports.buildCustomFieldFilterElement = buildCustomFieldFilterElement;
//# sourceMappingURL=buildCustomFieldFilterElement.js.map