"use strict";

exports.__esModule = true;
exports.default = void 0;
var _compact2 = _interopRequireDefault(require("lodash/fp/compact"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const reg = /{{(\w+)}}/;
function parseTemplateString(_template) {
  if (!_template) {
    return [];
  }
  const template = _template.replace(/<br\s*\/*>/g, '<br>').replace(/\r?\n|\r/g, '<br>');
  const res = reg.exec(template);
  if (!res) {
    return [{
      type: 'string',
      value: template
    }];
  }
  return (0, _compact2.default)([res.index === 0 ? null : {
    type: 'string',
    value: template.slice(0, res.index)
  }, {
    type: 'answerField',
    value: res[1]
  }]).concat(parseTemplateString(template.slice(res.index + res[0].length)));
}
var _default = exports.default = parseTemplateString;
//# sourceMappingURL=parse-template-string.js.map