'use strict';

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

var _defineProperty2 = require('babel-runtime/helpers/defineProperty');

var _defineProperty3 = _interopRequireDefault(_defineProperty2);

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _react = require('react');

var React = _interopRequireWildcard(_react);

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

var Icon = function (_React$Component) {
    (0, _inherits3["default"])(Icon, _React$Component);

    function Icon() {
        (0, _classCallCheck3["default"])(this, Icon);

        var _this = (0, _possibleConstructorReturn3["default"])(this, _React$Component.apply(this, arguments));

        _this.renderSvg = function () {
            var svg = void 0;
            try {
                svg = require('./style/assets/' + _this.props.type + '.svg');
            } finally {
                return svg;
            }
        };
        return _this;
    }

    Icon.prototype.render = function render() {
        var _classNames;

        var _props = this.props,
            type = _props.type,
            className = _props.className,
            style = _props.style,
            _props$size = _props.size,
            size = _props$size === undefined ? 'md' : _props$size;

        var xlinkHref = this.renderSvg();
        var outerIcon = void 0;
        if (!xlinkHref) {
            outerIcon = true;
            xlinkHref = type;
        } else {
            xlinkHref = '#' + type;
        }
        var iconClassName = (0, _classnames2["default"])((_classNames = {
            'am-icon': true
        }, (0, _defineProperty3["default"])(_classNames, 'am-icon-' + (outerIcon ? type.substr(1) : type), true), (0, _defineProperty3["default"])(_classNames, 'am-icon-' + size, true), (0, _defineProperty3["default"])(_classNames, className, !!className), _classNames));
        return React.createElement(
            'svg',
            { className: iconClassName, style: style },
            React.createElement('use', { xlinkHref: xlinkHref })
        );
    };

    return Icon;
}(React.Component);

exports["default"] = Icon;
module.exports = exports['default'];