"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _typeof3 = require("@babel/runtime/helpers/typeof");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));

var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var React = _interopRequireWildcard(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _classnames = _interopRequireDefault(require("classnames"));

var _editableHtml = require("@pie-lib/pie-toolbox/editable-html");

var _configUi = require("@pie-lib/pie-toolbox/config-ui");

var _styles = require("@material-ui/core/styles");

var _InputLabel = _interopRequireDefault(require("@material-ui/core/InputLabel"));

var _Select = _interopRequireDefault(require("@material-ui/core/Select"));

var _MenuItem = _interopRequireDefault(require("@material-ui/core/MenuItem"));

var _response = _interopRequireDefault(require("./response"));

var _mathToolbar = require("@pie-lib/pie-toolbox/math-toolbar");

var _isEqual = _interopRequireDefault(require("lodash/isEqual"));

var _utils = require("./utils");

var _mathquill = _interopRequireDefault(require("@pie-framework/mathquill"));

var _Info = _interopRequireDefault(require("@material-ui/icons/Info"));

var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

var registered = false;

var styles = function styles(theme) {
  return {
    container: {
      display: 'flex',
      flexDirection: 'column'
    },
    templateTitle: {
      fontSize: '0.85rem'
    },
    title: {
      fontSize: '1.1rem'
    },
    addResponseButton: {
      border: "1px solid ".concat(theme.palette.grey['A100']),
      "float": 'right',
      width: '150px'
    },
    flexContainer: {
      display: 'flex',
      alignItems: 'center',
      justifyContent: 'space-between'
    },
    selectContainer: {
      flex: 'initial',
      width: '40%',
      marginTop: theme.spacing.unit * 2,
      marginBottom: theme.spacing.unit * 2
    },
    responseTemplate: {
      display: 'flex',
      flexDirection: 'column'
    },
    responseEditor: {
      display: 'flex',
      justifyContent: 'center',
      width: '100%',
      // minWidth: '500px',
      maxWidth: 'inherit',
      height: 'auto',
      minHeight: '130px',
      textAlign: 'left',
      padding: theme.spacing.unit
    },
    promptHolder: {
      width: '100%',
      paddingTop: theme.spacing.unit * 2,
      marginBottom: theme.spacing.unit * 2
    },
    blockContainer: {
      margin: theme.spacing.unit,
      display: 'inline-flex',
      border: '2px solid grey'
    },
    blockContainerGeneric: {
      margin: theme.spacing.unit / 2
    },
    blockResponse: {
      fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
      flex: 2,
      color: 'grey',
      background: theme.palette.grey['A100'],
      fontSize: '0.8rem',
      padding: theme.spacing.unit / 2,
      display: 'flex',
      alignItems: 'center',
      justifyContent: 'center',
      borderRight: '2px solid grey'
    },
    blockResponseGeneric: {
      borderRight: 0
    },
    blockMath: {
      color: theme.palette.grey[400],
      padding: theme.spacing.unit / 2,
      display: 'flex',
      alignItems: 'center',
      justifyContent: 'center',
      flex: 8,
      '& > .mq-math-mode': {
        '& > .mq-hasCursor': {
          '& > .mq-cursor': {
            display: 'none'
          }
        }
      }
    },
    tooltip: {
      fontSize: theme.typography.fontSize - 2,
      whiteSpace: 'pre-wrap'
    },
    errorText: {
      fontSize: theme.typography.fontSize - 2,
      color: theme.palette.error.main,
      paddingTop: theme.spacing.unit
    },
    advancedResponse: {
      marginBottom: theme.spacing.unit * 2.5
    }
  };
};

var REGEX = /{{response}}/gm;
var TEMPORARY_RESPONSE_FIELD = /\\%response\\%/gm;
var ANSWER_BLOCK_REGEX = /\\embed\{answerBlock\}\[r\d*\]/g;
var NEWLINE_BLOCK = /\\embed\{newLine\}\[\]/g;
var NEWLINE_LATEX = /\\newline/g;

function prepareForStatic(expression) {
  if (expression) {
    var answerBlocks = 1; // assume one at least

    return expression.replace(REGEX, function () {
      return "\\embed{answerBlock}[r".concat(answerBlocks++, "]");
    }).replace(NEWLINE_LATEX, '\\embed{newLine}[]');
  }
}

function prepareForModel(expression) {
  if (expression) {
    return expression.replace(ANSWER_BLOCK_REGEX, function () {
      return '{{response}}';
    }).replace(TEMPORARY_RESPONSE_FIELD, function () {
      return '{{response}}';
    }).replace(NEWLINE_BLOCK, function () {
      return '\\newline';
    });
  }
}

var GeneralConfigBlock = /*#__PURE__*/function (_React$Component) {
  (0, _inherits2["default"])(GeneralConfigBlock, _React$Component);

  var _super = _createSuper(GeneralConfigBlock);

  function GeneralConfigBlock(props) {
    var _this;

    (0, _classCallCheck2["default"])(this, GeneralConfigBlock);
    _this = _super.call(this, props);
    (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChange", function (name) {
      return function (evtOrValue) {
        var _this$props = _this.props,
            model = _this$props.model,
            onChange = _this$props.onChange;

        var newModel = _objectSpread({}, model);

        if ((0, _typeof2["default"])(evtOrValue) === 'object') {
          newModel[name] = evtOrValue.target.value;
        } else {
          newModel[name] = evtOrValue;
        }

        if (name === 'expression') {
          newModel[name] = prepareForModel(evtOrValue);
        }

        onChange(newModel);
      };
    });
    (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onDone", function () {
      _this.setState({
        showKeypad: false
      });
    });
    (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onFocus", function () {
      _this.setState({
        showKeypad: true
      });
    });
    (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPromptFocus", function () {
      _this.setState({
        showKeypad: false
      });
    });
    (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleAnswerBlockDomUpdate", function () {
      var model = _this.props.model;
      var responseAreas = {};

      if (model && model.expression) {
        var answerBlocks = 1; // assume one at least
        // build out local state model using responses declared in expression

        model.expression.replace(REGEX, function () {
          responseAreas["r".concat(answerBlocks++)] = {
            value: ''
          };
        });
      }

      if (!(0, _isEqual["default"])(responseAreas, _this.state.responseAreas)) {
        _this.setState({
          responseAreas: responseAreas
        }, function () {
          if (_this.root && Object.keys(responseAreas).length) {
            Object.keys(responseAreas).forEach(function (responseId, idx) {
              var el = _this.root.querySelector("#".concat(responseId));

              var indexEl = _this.root.querySelector("#".concat(responseId, "Index"));

              if (el) {
                // const MathQuill = require('@pie-framework/mathquill');
                var MQ = _mathquill["default"].getInterface(2); // We no longer have individual answers, so we cannot set text content of blocks
                // el.textContent = response.answer;


                MQ.StaticMath(el);
                indexEl.textContent = "R".concat(idx + 1);
              }
            });
          }
        });
      }
    });
    (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onAddResponse", function () {
      var _this$props2 = _this.props,
          model = _this$props2.model,
          onChange = _this$props2.onChange;
      var responseIdCounter = _this.state.responseIdCounter;

      var newModel = _objectSpread({}, model);

      var newCounter = responseIdCounter;

      while (model.responses.find(function (response) {
        return response.id === newCounter;
      })) {
        newCounter++;
      }

      var response = {
        id: newCounter,
        validation: 'literal',
        answer: '',
        alternates: {}
      };
      newModel.responses = newModel.responses.concat(response);
      onChange(newModel);

      _this.setState({
        responseIdCounter: response.id
      });
    });
    (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onResponseChange", function (response, index) {
      var _this$props3 = _this.props,
          model = _this$props3.model,
          onChange = _this$props3.onChange;

      var newModel = _objectSpread({}, model);

      newModel.responses[index] = response;
      onChange(newModel);
    });
    var _responseAreas = {};

    if (props.model && props.model.expression) {
      var answerBlocks = 1; // assume one at least
      // build out local state model using responses declared in expression

      props.model.expression.replace(REGEX, function () {
        _responseAreas["r".concat(answerBlocks++)] = {
          value: ''
        };
      });
    }

    _this.state = {
      showKeypad: false,
      responseAreas: _responseAreas,
      responseIdCounter: Object.keys(_responseAreas).length
    };
    return _this;
  }

  (0, _createClass2["default"])(GeneralConfigBlock, [{
    key: "UNSAFE_componentWillMount",
    value: function UNSAFE_componentWillMount() {
      var classes = this.props.classes;

      if (typeof window !== 'undefined') {
        // const MathQuill = require('@pie-framework/mathquill');
        var MQ = _mathquill["default"].getInterface(2);

        if (!registered) {
          MQ.registerEmbed('answerBlock', function (data) {
            // not used until we implement individual answer tracking
            // const individualAnswerBlock = `<div class="${classes.blockContainer}">
            //     <div class="${classes.blockResponse}" id="${data}Index">R</div>
            //     <div class="${classes.blockMath}">
            //        <span id="${data}"></span>
            //      </div>
            //   </div>`;
            var genericAnswerBlock = "<div class=\"".concat((0, _classnames["default"])(classes.blockContainer, classes.blockContainerGeneric), "\">\n                <div class=\"").concat((0, _classnames["default"])(classes.blockResponse, classes.blockResponseGeneric), "\" id=\"").concat(data, "Index\">Response</div>\n              </div>");
            return {
              htmlString: genericAnswerBlock,
              text: function text() {
                return 'text';
              },
              latex: function latex() {
                return "\\embed{answerBlock}[".concat(data, "]");
              }
            };
          });
          registered = true;
        }
      }
    }
  }, {
    key: "componentDidMount",
    value: function componentDidMount() {
      this.handleAnswerBlockDomUpdate();
    }
  }, {
    key: "componentDidUpdate",
    value: function componentDidUpdate() {
      this.handleAnswerBlockDomUpdate();
    }
  }, {
    key: "render",
    value: function render() {
      var _this2 = this;

      var _this$props4 = this.props,
          classes = _this$props4.classes,
          model = _this$props4.model,
          imageSupport = _this$props4.imageSupport,
          uploadSoundSupport = _this$props4.uploadSoundSupport,
          configuration = _this$props4.configuration,
          promptEnabled = _this$props4.promptEnabled,
          rationaleEnabled = _this$props4.rationaleEnabled,
          toolbarOpts = _this$props4.toolbarOpts;
      var showKeypad = this.state.showKeypad;
      var prompt = model.prompt,
          expression = model.expression,
          equationEditor = model.equationEditor,
          _model$promptEquation = model.promptEquationEditor,
          promptEquationEditor = _model$promptEquation === void 0 ? '8' : _model$promptEquation,
          responses = model.responses,
          responseType = model.responseType,
          rationale = model.rationale,
          spellCheckEnabled = model.spellCheckEnabled,
          _model$errors = model.errors,
          errors = _model$errors === void 0 ? {} : _model$errors;

      var _ref = configuration || {},
          _ref$baseInputConfigu = _ref.baseInputConfiguration,
          baseInputConfiguration = _ref$baseInputConfigu === void 0 ? {} : _ref$baseInputConfigu,
          _ref$rationale = _ref.rationale,
          cRationale = _ref$rationale === void 0 ? {} : _ref$rationale,
          _ref$prompt = _ref.prompt,
          cPrompt = _ref$prompt === void 0 ? {} : _ref$prompt,
          _ref$ignoreOrder = _ref.ignoreOrder,
          cIgnoreOrder = _ref$ignoreOrder === void 0 ? {} : _ref$ignoreOrder,
          _ref$allowTrailingZer = _ref.allowTrailingZeros,
          cAllowTrailingZeros = _ref$allowTrailingZer === void 0 ? {} : _ref$allowTrailingZer,
          maxResponseAreas = _ref.maxResponseAreas,
          _ref$maxImageWidth = _ref.maxImageWidth,
          maxImageWidth = _ref$maxImageWidth === void 0 ? {} : _ref$maxImageWidth,
          _ref$maxImageHeight = _ref.maxImageHeight,
          maxImageHeight = _ref$maxImageHeight === void 0 ? {} : _ref$maxImageHeight,
          _ref$mathMlOptions = _ref.mathMlOptions,
          mathMlOptions = _ref$mathMlOptions === void 0 ? {} : _ref$mathMlOptions;

      var validationMessage = (0, _utils.generateValidationMessage)(configuration, model);
      var promptError = errors.prompt,
          rationaleError = errors.rationale,
          responsesErrors = errors.responsesErrors,
          responseAreasError = errors.responseAreasError;
      var defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
      var defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
      var classNames = {
        editor: classes.responseEditor,
        mathToolbar: classes.mathToolbar
      };
      var responsesToUse = responseType === _utils.ResponseTypes.advanced ? responses : responses.slice(0, 1);
      var validationTooltip = /*#__PURE__*/React.createElement(_Tooltip["default"], {
        classes: {
          tooltip: classes.tooltip
        },
        disableFocusListener: true,
        disableTouchListener: true,
        placement: 'right',
        title: validationMessage
      }, /*#__PURE__*/React.createElement(_Info["default"], {
        fontSize: 'small',
        color: 'primary',
        style: {
          marginLeft: '5px'
        }
      }));
      return /*#__PURE__*/React.createElement("div", {
        ref: function ref(r) {
          return _this2.root = r || _this2.root;
        },
        className: classes.container
      }, promptEnabled && /*#__PURE__*/React.createElement(_configUi.InputContainer, {
        label: cPrompt.label,
        className: classes.promptHolder
      }, /*#__PURE__*/React.createElement(_editableHtml.EditableHtml, {
        onFocus: this.onPromptFocus,
        className: classes.prompt,
        markup: prompt || '',
        onChange: this.onChange('prompt'),
        imageSupport: imageSupport,
        nonEmpty: false,
        error: promptError,
        toolbarOpts: toolbarOpts,
        pluginProps: (0, _utils.getPluginProps)(cPrompt === null || cPrompt === void 0 ? void 0 : cPrompt.inputConfiguration, baseInputConfiguration),
        spellCheck: spellCheckEnabled,
        maxImageWidth: defaultImageMaxWidth,
        maxImageHeight: defaultImageMaxHeight,
        uploadSoundSupport: uploadSoundSupport,
        languageCharactersProps: [{
          language: 'spanish'
        }, {
          language: 'special'
        }],
        mathMlOptions: mathMlOptions
      }), promptError && /*#__PURE__*/React.createElement("div", {
        className: classes.errorText
      }, promptError)), responseType === _utils.ResponseTypes.advanced && /*#__PURE__*/React.createElement("div", {
        className: classes.advancedResponse
      }, /*#__PURE__*/React.createElement("div", {
        className: classes.flexContainer,
        style: {
          justifyContent: 'flex-start'
        }
      }, /*#__PURE__*/React.createElement("div", {
        className: classes.title
      }, "Define Response"), validationTooltip), /*#__PURE__*/React.createElement(_configUi.InputContainer, {
        key: "templateEditorType",
        label: "Response Template Equation Editor",
        className: classes.selectContainer
      }, /*#__PURE__*/React.createElement(_Select["default"], {
        className: classes.select,
        onChange: this.onChange('promptEquationEditor'),
        value: promptEquationEditor
      }, /*#__PURE__*/React.createElement(_MenuItem["default"], {
        value: "non-negative-integers"
      }, "Numeric - Non-Negative Integers"), /*#__PURE__*/React.createElement(_MenuItem["default"], {
        value: "integers"
      }, "Numeric - Integers"), /*#__PURE__*/React.createElement(_MenuItem["default"], {
        value: "decimals"
      }, "Numeric - Decimals"), /*#__PURE__*/React.createElement(_MenuItem["default"], {
        value: "fractions"
      }, "Numeric - Fractions"), /*#__PURE__*/React.createElement(_MenuItem["default"], {
        value: 1
      }, "Grade 1 - 2"), /*#__PURE__*/React.createElement(_MenuItem["default"], {
        value: 3
      }, "Grade 3 - 5"), /*#__PURE__*/React.createElement(_MenuItem["default"], {
        value: 6
      }, "Grade 6 - 7"), /*#__PURE__*/React.createElement(_MenuItem["default"], {
        value: 8
      }, "Grade 8 - HS"), /*#__PURE__*/React.createElement(_MenuItem["default"], {
        value: 'geometry'
      }, "Geometry"), /*#__PURE__*/React.createElement(_MenuItem["default"], {
        value: 'advanced-algebra'
      }, "Advanced Algebra"), /*#__PURE__*/React.createElement(_MenuItem["default"], {
        value: 'statistics'
      }, "Statistics"), /*#__PURE__*/React.createElement(_MenuItem["default"], {
        value: 'item-authoring'
      }, "Item Authoring"))), /*#__PURE__*/React.createElement("div", {
        className: classes.responseTemplate,
        key: "templateHolder"
      }, /*#__PURE__*/React.createElement(_InputLabel["default"], {
        className: classes.templateTitle
      }, "RESPONSE TEMPLATE"), /*#__PURE__*/React.createElement(_mathToolbar.MathToolbar, {
        classNames: classNames,
        allowAnswerBlock: true,
        keypadMode: promptEquationEditor,
        controlledKeypad: true,
        showKeypad: showKeypad,
        latex: prepareForStatic(expression) || '',
        onChange: this.onChange('expression'),
        onFocus: this.onFocus,
        onDone: this.onDone,
        maxResponseAreas: maxResponseAreas,
        error: responseAreasError
      })), responseAreasError && /*#__PURE__*/React.createElement("div", {
        className: classes.errorText
      }, responseAreasError)), /*#__PURE__*/React.createElement("div", {
        className: classes.flexContainer,
        style: {
          justifyContent: 'flex-start'
        }
      }, /*#__PURE__*/React.createElement("div", {
        className: classes.title
      }, "Define Correct Response"), responseType === _utils.ResponseTypes.simple ? validationTooltip : null), /*#__PURE__*/React.createElement(_configUi.InputContainer, {
        label: "Equation Editor",
        className: classes.selectContainer
      }, /*#__PURE__*/React.createElement(_Select["default"], {
        className: classes.select,
        onChange: this.onChange('equationEditor'),
        value: equationEditor
      }, /*#__PURE__*/React.createElement(_MenuItem["default"], {
        value: "non-negative-integers"
      }, "Numeric - Non-Negative Integers"), /*#__PURE__*/React.createElement(_MenuItem["default"], {
        value: "integers"
      }, "Numeric - Integers"), /*#__PURE__*/React.createElement(_MenuItem["default"], {
        value: "decimals"
      }, "Numeric - Decimals"), /*#__PURE__*/React.createElement(_MenuItem["default"], {
        value: "fractions"
      }, "Numeric - Fractions"), /*#__PURE__*/React.createElement(_MenuItem["default"], {
        value: 1
      }, "Grade 1 - 2"), /*#__PURE__*/React.createElement(_MenuItem["default"], {
        value: 3
      }, "Grade 3 - 5"), /*#__PURE__*/React.createElement(_MenuItem["default"], {
        value: 6
      }, "Grade 6 - 7"), /*#__PURE__*/React.createElement(_MenuItem["default"], {
        value: 8
      }, "Grade 8 - HS"), /*#__PURE__*/React.createElement(_MenuItem["default"], {
        value: 'geometry'
      }, "Geometry"), /*#__PURE__*/React.createElement(_MenuItem["default"], {
        value: 'advanced-algebra'
      }, "Advanced Algebra"), /*#__PURE__*/React.createElement(_MenuItem["default"], {
        value: 'statistics'
      }, "Statistics"), /*#__PURE__*/React.createElement(_MenuItem["default"], {
        value: 'item-authoring'
      }, "Item Authoring"))), responsesToUse.map(function (response, idx) {
        return /*#__PURE__*/React.createElement(_response["default"], {
          key: response.id,
          mode: equationEditor,
          response: response,
          defaultResponse: responseType === _utils.ResponseTypes.simple,
          onResponseChange: _this2.onResponseChange,
          index: idx,
          cIgnoreOrder: cIgnoreOrder,
          cAllowTrailingZeros: cAllowTrailingZeros,
          error: responsesErrors && responsesErrors[idx]
        });
      }), rationaleEnabled && /*#__PURE__*/React.createElement(_configUi.InputContainer, {
        label: cRationale.label,
        className: classes.promptHolder
      }, /*#__PURE__*/React.createElement(_editableHtml.EditableHtml, {
        className: classes.prompt,
        markup: rationale || '',
        onChange: this.onChange('rationale'),
        imageSupport: imageSupport,
        nonEmpty: false,
        error: rationaleError,
        toolbarOpts: toolbarOpts,
        pluginProps: (0, _utils.getPluginProps)(cRationale === null || cRationale === void 0 ? void 0 : cRationale.inputConfiguration, _objectSpread(_objectSpread({}, baseInputConfiguration), {}, {
          math: {
            controlledKeypadMode: false
          }
        })),
        spellCheck: spellCheckEnabled,
        maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
        maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
        uploadSoundSupport: uploadSoundSupport,
        languageCharactersProps: [{
          language: 'spanish'
        }, {
          language: 'special'
        }],
        mathMlOptions: mathMlOptions
      }), rationaleError && /*#__PURE__*/React.createElement("div", {
        className: classes.errorText
      }, rationaleError)));
    }
  }]);
  return GeneralConfigBlock;
}(React.Component);

(0, _defineProperty2["default"])(GeneralConfigBlock, "propTypes", {
  classes: _propTypes["default"].object.isRequired,
  model: _propTypes["default"].object.isRequired,
  imageSupport: _propTypes["default"].object,
  uploadSoundSupport: _propTypes["default"].object,
  configuration: _propTypes["default"].object,
  onChange: _propTypes["default"].func.isRequired,
  promptEnabled: _propTypes["default"].bool,
  rationaleEnabled: _propTypes["default"].bool,
  toolbarOpts: _propTypes["default"].object
});

var _default = (0, _styles.withStyles)(styles)(GeneralConfigBlock);

exports["default"] = _default;
//# sourceMappingURL=general-config-block.js.map