"use strict";

exports.__esModule = true;
exports.inputStyle = exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _title = _interopRequireDefault(require("../../atom/title"));
var _autocomplete = _interopRequireDefault(require("../../atom/autocomplete"));
var _inputText = _interopRequireDefault(require("../../atom/input-text"));
var _inputTextarea = _interopRequireDefault(require("../../atom/input-textarea"));
var _select = _interopRequireDefault(require("../../atom/select"));
var _selectMultiple = _interopRequireDefault(require("../../molecule/select-multiple"));
var _selectOpponents = _interopRequireDefault(require("../select-opponents"));
var _iconEditor = _interopRequireDefault(require("../icon-editor"));
var _types = _interopRequireDefault(require("./types"));
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const inputStyle = exports.inputStyle = {
  default: _style.default.defaultWidth,
  medium: _style.default.mediumWidth,
  large: _style.default.largeWidth
};
const buildInput = (childType, field) => {
  switch (childType) {
    case 'autoComplete':
      return /*#__PURE__*/_react.default.createElement(_autocomplete.default, field);
    case 'iconEditor':
      return /*#__PURE__*/_react.default.createElement(_iconEditor.default, field);
    case 'inputText':
      return /*#__PURE__*/_react.default.createElement(_inputText.default, field);
    case 'inputTextArea':
      return /*#__PURE__*/_react.default.createElement(_inputTextarea.default, field);
    case 'select':
      return /*#__PURE__*/_react.default.createElement(_select.default, field);
    case 'selectMultiple':
      return /*#__PURE__*/_react.default.createElement(_selectMultiple.default, field);
    case 'selectOpponents':
      return /*#__PURE__*/_react.default.createElement(_selectOpponents.default, field);
  }
};
const TitleAndInput = props => {
  const {
    title: {
      titleSize,
      subtitleSize,
      type,
      ...restTitleProps
    },
    field,
    childType
  } = props;
  const titleProps = {
    ...restTitleProps,
    titleSize: titleSize ?? 'medium',
    subtitleSize: subtitleSize ?? 'small-without-margin',
    type: type ?? 'form-group'
  };
  const input = buildInput(childType, field);
  const {
    size = 'default'
  } = field;
  const styleInput = childType === 'selectOpponents' ? _style.default.selectOpponentsContainer : inputStyle[size];
  return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_title.default, titleProps), /*#__PURE__*/_react.default.createElement("div", {
    className: styleInput
  }, input));
};
TitleAndInput.propTypes = process.env.NODE_ENV !== "production" ? _types.default : {};
var _default = exports.default = TitleAndInput;
//# sourceMappingURL=index.js.map