import _map from "lodash/fp/map";
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 PropTypes from 'prop-types';
import Accordion from '../../organism/accordion/toggler';
import Select from '../../atom/select';
import InputReadonly from '../../atom/input-readonly';
import InputText from '../../atom/input-text';
import InputCheckbox from '../../atom/input-checkbox';
import InputDoublestep from '../../atom/input-doublestep';
import InputSwitch from '../../atom/input-switch';
import InputFileDraggable from '../../atom/input-file-draggable';
import SetupCohortItem from '../setup-cohort-item';
import MessagePopin from '../message-popin';
import BrandDownloadBox from '../brand-download-box';
import Title from '../../atom/title';
import style from './style.css';
const SetupSlider = props => {
  const {
    tabProps = [],
    slides = []
  } = props;
  const buildSlides = slides_ => {
    return _map.convert({
      cap: false
    })((slide, key) => {
      const buildInput = field => {
        const {
          type,
          ...rest
        } = field;
        switch (type) {
          case 'switch':
            return /*#__PURE__*/React.createElement(InputSwitch, field);
          case 'select':
            return /*#__PURE__*/React.createElement(Select, _extends({}, field, {
              theme: 'coorpmanager'
            }));
          case 'checkbox':
            return /*#__PURE__*/React.createElement(InputCheckbox, field);
          case 'image':
            return /*#__PURE__*/React.createElement("div", {
              className: style.imageUploadContainer
            }, /*#__PURE__*/React.createElement(InputFileDraggable, field));
          case 'splitForm':
            return /*#__PURE__*/React.createElement(SetupCohortItem, {
              field: field
            });
          case 'alert':
            return /*#__PURE__*/React.createElement(MessagePopin, {
              header: field.title,
              content: field.subtitle
            });
          case 'readonly':
            return /*#__PURE__*/React.createElement(InputReadonly, field);
          case 'doublestep':
            return /*#__PURE__*/React.createElement(InputDoublestep, field);
          case 'downloadbox':
            return /*#__PURE__*/React.createElement(BrandDownloadBox, field);
          case 'form-group':
            return /*#__PURE__*/React.createElement(Title, field);
          case 'slider':
            return /*#__PURE__*/React.createElement(Accordion, {
              tabProps: field.tabProps,
              type: 'all',
              theme: 'setup'
            }, buildSlides(field.slides));
          case 'text':
          case 'password':
            return /*#__PURE__*/React.createElement(InputText, field);
          default:
            return /*#__PURE__*/React.createElement(InputText, _extends({}, rest, {
              type: 'text'
            }));
        }
      };
      const buildField = (field, index) => {
        const input = buildInput(field);
        return /*#__PURE__*/React.createElement("div", {
          className: style.field,
          key: index
        }, input);
      };
      const fieldsList = _map.convert({
        cap: false
      })(buildField, slide.fields);
      return /*#__PURE__*/React.createElement("div", {
        className: style.wrapper,
        key: key
      }, fieldsList);
    }, slides_);
  };
  const slidesView = buildSlides(slides);
  return /*#__PURE__*/React.createElement("div", {
    className: style.wrapperStyle
  }, /*#__PURE__*/React.createElement(Accordion, {
    tabProps: tabProps,
    type: 'all',
    theme: 'setup'
  }, slidesView));
};
const SlidePropTypes = process.env.NODE_ENV !== "production" ? PropTypes.shape({
  fields: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.shape({
    ...SetupSlider.propTypes,
    type: PropTypes.oneOf(['slider'])
  }), PropTypes.shape({
    ...InputSwitch.propTypes,
    type: PropTypes.oneOf(['switch'])
  }), PropTypes.shape({
    ...Select.propTypes,
    type: PropTypes.oneOf(['select'])
  }), PropTypes.shape({
    ...InputCheckbox.propTypes,
    type: PropTypes.oneOf(['checkbox'])
  }), PropTypes.shape({
    ...InputFileDraggable.propTypes,
    type: PropTypes.oneOf(['image'])
  }), PropTypes.shape({
    ...InputReadonly.propTypes,
    type: PropTypes.oneOf(['readonly'])
  }), PropTypes.shape({
    ...InputText.propTypes,
    type: PropTypes.oneOf(['text', 'password'])
  }), PropTypes.shape({
    ...InputDoublestep.propTypes,
    type: PropTypes.oneOf(['doublestep'])
  }), PropTypes.shape({
    ...SetupCohortItem.propTypes,
    type: PropTypes.oneOf(['splitForm'])
  }), PropTypes.shape({
    ...MessagePopin.propTypes,
    type: PropTypes.oneOf(['alert'])
  }), PropTypes.shape(InputText.propTypes), PropTypes.shape({
    ...BrandDownloadBox.propTypes,
    type: PropTypes.oneOf(['downloadbox'])
  })]))
}) : {};
const SetupSliderPropTypes = process.env.NODE_ENV !== "production" ? {
  tabProps: PropTypes.arrayOf(PropTypes.shape(Accordion.propTypes)),
  slides: PropTypes.arrayOf(SlidePropTypes)
} : {};
SetupSlider.propTypes = process.env.NODE_ENV !== "production" ? SetupSliderPropTypes : {};
export default SetupSlider;
//# sourceMappingURL=index.js.map