"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

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

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

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

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

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

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

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

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

var _require = require('humps'),
    pascalize = _require.pascalize;

var _ref =
/*#__PURE__*/
_react.default.createElement("div", null, "UnregisteredItem");

var UnregisteredItem =
/*#__PURE__*/
function (_Component) {
  (0, _inherits2.default)(UnregisteredItem, _Component);

  function UnregisteredItem() {
    (0, _classCallCheck2.default)(this, UnregisteredItem);
    return (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(UnregisteredItem).apply(this, arguments));
  }

  (0, _createClass2.default)(UnregisteredItem, [{
    key: "render",
    value: function render() {
      return _ref;
    }
  }]);
  UnregisteredItem.displayName = "UnregisteredItem";
  return UnregisteredItem;
}(_react.Component); // TODO: when webpack 2 upgrade finished, change this to use System.import


exports.UnregisteredItem = UnregisteredItem;

var componentForItem = function componentForItem(intTypeSlug, usage) {
  // MC and MA interactionTypes are the only two that don't have slugs that match
  // the naming conventions on quiz_interactions, we we change them to match
  var componentKey = intTypeSlug && intTypeSlug.replace('-', '_');

  if (componentKey === 'multi_answer') {
    componentKey = 'multiple_answer';
  }

  if (componentKey === 'choice') {
    componentKey = 'multiple_choice';
  } // TODO: change quiz interactions
  // to include the underscore


  if (componentKey === 'hot_spot') {
    componentKey = 'hotspot';
  } // Try to find the module in the quiz_interactions library with
  // the key that matches the pattern of the slug and use


  try {
    return require("quiz-interactions/lib/components/".concat(componentKey, "/").concat(pascalize(usage.toLowerCase()), "/index.js")).default;
  } catch (ex) {
    return UnregisteredItem;
  }
};

var _default = componentForItem;
exports.default = _default;