'use strict';

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

var React = require('react');
var useForkRef = require('../../../../hooks/useForkRef.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 value = _ref.value,
    opened = _ref.opened,
    valueToItemMap = _ref.valueToItemMap,
    label = _ref.label,
    placeholder = _ref.placeholder,
    onKeyDown = _ref.onKeyDown,
    labelPlacement = _ref.labelPlacement,
    size = _ref.size,
    contentLeft = _ref.contentLeft,
    contentRight = _ref.contentRight,
    disabled = _ref.disabled,
    readOnly = _ref.readOnly,
    renderValue = _ref.renderValue,
    selectProps = _ref.selectProps,
    inputWrapperRef = _ref.inputWrapperRef,
    multiselect = _ref.multiselect,
    view = _ref.view,
    helperText = _ref.helperText,
    treeId = _ref.treeId,
    activeDescendantItemValue = _ref.activeDescendantItemValue,
    isTargetAmount = _ref.isTargetAmount,
    onChange = _ref.onChange,
    chipView = _ref.chipView,
    separator = _ref.separator,
    requiredProps = _ref.requiredProps,
    hintProps = _ref.hintProps;
  var buttonRef = useForkRef.useForkRef(ref, inputWrapperRef);
  if (selectProps.renderTarget) {
    return /*#__PURE__*/React__default.default.createElement("div", {
      ref: inputWrapperRef
    }, selectProps.renderTarget(Array.isArray(value) ? value.map(function (value) {
      return valueToItemMap.get(value);
    }) : valueToItemMap.get(value), opened));
  }
  return selectProps.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,
    selectProps: selectProps,
    separator: separator,
    treeId: treeId,
    activeDescendantItemValue: activeDescendantItemValue
  }) : /*#__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,
    onChange: onChange,
    chipView: chipView,
    requiredProps: requiredProps,
    hintProps: hintProps,
    chipType: selectProps.chipType,
    chipClickArea: selectProps.chipClickArea
  });
});

exports.Target = Target;
//# sourceMappingURL=Target.js.map
