'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var React = require('react');
var useForkRef = require('../../../../hooks/useForkRef.js');
var RenderTarget = require('./ui/RenderTarget/RenderTarget.js');
var Button = require('./ui/Button/Button.js');
var Textfield = require('./ui/Textfield/Textfield.js');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var React__default = /*#__PURE__*/_interopDefault(React);

var Target = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
  var target = _ref.target,
    renderTarget = _ref.renderTarget,
    value = _ref.value,
    opened = _ref.opened,
    valueToItemMap = _ref.valueToItemMap,
    label = _ref.label,
    placeholder = _ref.placeholder,
    onKeyDown = _ref.onKeyDown,
    labelPlacement = _ref.labelPlacement,
    size = _ref.size,
    view = _ref.view,
    contentLeft = _ref.contentLeft,
    contentRight = _ref.contentRight,
    disabled = _ref.disabled,
    readOnly = _ref.readOnly,
    renderValue = _ref.renderValue,
    inputWrapperRef = _ref.inputWrapperRef,
    multiselect = _ref.multiselect,
    helperText = _ref.helperText,
    treeId = _ref.treeId,
    activeDescendantItemValue = _ref.activeDescendantItemValue,
    isTargetAmount = _ref.isTargetAmount,
    handleChange = _ref.handleChange,
    chipView = _ref.chipView,
    chipType = _ref.chipType,
    chipClickArea = _ref.chipClickArea,
    keepPlaceholder = _ref.keepPlaceholder,
    requiredProps = _ref.requiredProps,
    hintProps = _ref.hintProps;
  var buttonRef = useForkRef.useForkRef(ref, inputWrapperRef);
  if (renderTarget) {
    return /*#__PURE__*/React__default.default.createElement(RenderTarget.RenderTarget, {
      inputWrapperRef: inputWrapperRef,
      multiselect: multiselect,
      value: value,
      opened: opened,
      renderTarget: renderTarget,
      valueToItemMap: valueToItemMap
    });
  }
  return target === 'button-like' ? /*#__PURE__*/React__default.default.createElement(Button.Button, {
    ref: buttonRef,
    opened: opened,
    value: value,
    valueToItemMap: valueToItemMap,
    onKeyDown: onKeyDown,
    label: label,
    size: size,
    disabled: disabled || readOnly,
    renderValue: renderValue,
    treeId: treeId,
    activeDescendantItemValue: activeDescendantItemValue,
    multiselect: multiselect,
    isTargetAmount: isTargetAmount
  }) : /*#__PURE__*/React__default.default.createElement(Textfield.Textfield, {
    ref: ref,
    inputWrapperRef: inputWrapperRef,
    opened: opened,
    multiselect: multiselect,
    value: value,
    label: label,
    placeholder: placeholder,
    onKeyDown: onKeyDown,
    labelPlacement: labelPlacement,
    size: size,
    view: view,
    contentLeft: contentLeft,
    contentRight: contentRight,
    helperText: helperText,
    treeId: treeId,
    activeDescendantItemValue: activeDescendantItemValue,
    disabled: disabled,
    readOnly: readOnly,
    isTargetAmount: isTargetAmount,
    valueToItemMap: valueToItemMap,
    renderValue: renderValue,
    handleChange: handleChange,
    chipView: chipView,
    chipType: chipType,
    chipClickArea: chipClickArea,
    keepPlaceholder: keepPlaceholder,
    requiredProps: requiredProps,
    hintProps: hintProps
  });
});

exports.Target = Target;
