'use strict';

import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import React from 'react';
import PropTypes from 'prop-types';
import BrandedFileLoader from '../utils/BrandedFileLoader';
export var BrandedImage =
/*#__PURE__*/
function (_React$Component) {
  _inheritsLoose(BrandedImage, _React$Component);

  function BrandedImage() {
    return _React$Component.apply(this, arguments) || this;
  }

  var _proto = BrandedImage.prototype;

  _proto.render = function render() {
    var _this$props = this.props,
        src = _this$props.src,
        folderContext = _this$props.folderContext,
        props = _objectWithoutPropertiesLoose(_this$props, ["src", "folderContext"]);

    var imageLoader = new BrandedFileLoader(folderContext);
    var fileInfo = imageLoader.getFileInfo(src);
    return React.createElement("img", _extends({}, props, {
      src: fileInfo.file,
      "data-src": fileInfo.requirePath
    }));
  };

  return BrandedImage;
}(React.Component);

_defineProperty(BrandedImage, "propTypes", {
  src: PropTypes.string.isRequired,
  // file path relative to target folder
  folderContext: PropTypes.func.isRequired,
  // require.context('./target/folder/relative/path/to/current/file')
  alt: PropTypes.string
});

_defineProperty(BrandedImage, "defaultProps", {
  alt: ''
});