import React from 'react';
import { di } from 'react-magnetic-di';
import { ErrorMessage, Field, MessageWrapper } from '@atlaskit/form';
import { fg } from '@atlaskit/platform-feature-flags';
import Textfield from '@atlaskit/textfield';
import messages from '../../common/messages';
var Errors = /*#__PURE__*/function (Errors) {
  Errors["EMPTY"] = "EMPTY";
  return Errors;
}(Errors || {});
const TextInputPrompt = ({
  userInputPrompt
}) => {
  const {
    variableName,
    required,
    displayName,
    defaultValue
  } = userInputPrompt;
  const validate = value => required && !value ? Errors.EMPTY : undefined;
  return /*#__PURE__*/React.createElement(Field, {
    name: variableName,
    label: displayName,
    defaultValue: defaultValue,
    isRequired: required,
    validate: validate
  }, ({
    fieldProps,
    error
  }) => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Textfield, fieldProps), fg('platform_navx_3298_message_wrapper') ? /*#__PURE__*/React.createElement(MessageWrapper, null, error === Errors.EMPTY && /*#__PURE__*/React.createElement(ErrorMessage, null, messages.errorInputMustNotBeEmpty.defaultMessage)) : error === Errors.EMPTY && /*#__PURE__*/React.createElement(ErrorMessage, null, messages.errorInputMustNotBeEmpty.defaultMessage)));
};
export default TextInputPrompt;