"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.PollQuestion = PollQuestion;
var _styles = require("../styles");
var _reactNative = require("react-native");
var _constants = require("../../../../../core/constants");
var _Typography = require("../../../../../core/components/Typography/Typography");
var _PollPostComposer = require("../PollPostComposer");
var _reactNativeControlledMentions = require("react-native-controlled-mentions");
var _FormLabel = _interopRequireDefault(require("../../../../elements/FormLabel"));
var _enums = require("../../../../enums");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function PollQuestion({
  renderInput
}) {
  const {
    styles,
    theme
  } = (0, _styles.useStyles)();
  const {
    pollQuestion
  } = (0, _PollPostComposer.usePollPostComposerContext)();
  const questionLength = (0, _reactNativeControlledMentions.replaceTriggerValues)(pollQuestion, ({
    name
  }) => `@${name}`).length;
  return /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.fieldContainer
  }, /*#__PURE__*/React.createElement(_reactNative.View, {
    style: [styles.inputContainer, questionLength > _constants.MAX_POLL_QUESTION_LENGTH && styles.inputContainerError]
  }, /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.rowContainer
  }, /*#__PURE__*/React.createElement(_FormLabel.default, {
    style: styles.base,
    pageId: _enums.PageID.poll_post_composer_page,
    elementId: _enums.ElementID.poll_question_title
  }), /*#__PURE__*/React.createElement(_Typography.Typography.Caption, null, questionLength, "/", _constants.MAX_POLL_QUESTION_LENGTH)), renderInput({
    multiline: true,
    style: styles.pollQuestionInput,
    placeholder: "What's your poll question?",
    placeholderTextColor: theme.colors.baseShade3
  })), questionLength > _constants.MAX_POLL_QUESTION_LENGTH && /*#__PURE__*/React.createElement(_Typography.Typography.Caption, {
    style: styles.errorText
  }, "Poll question cannot exceed ", _constants.MAX_POLL_QUESTION_LENGTH, " characters."));
}
//# sourceMappingURL=PollQuestion.js.map