(function (global, factory) {
	if (typeof define === "function" && define.amd) {
		define(['exports', 'react', 'classnames', './', './px-icon.scss'], factory);
	} else if (typeof exports !== "undefined") {
		factory(exports, require('react'), require('classnames'), require('./'), require('./px-icon.scss'));
	} else {
		var mod = {
			exports: {}
		};
		factory(mod.exports, global.react, global.classnames, global._, global.pxIcon);
		global.Icon = mod.exports;
	}
})(this, function (exports, _react, _classnames, _, _pxIcon) {
	'use strict';

	Object.defineProperty(exports, "__esModule", {
		value: true
	});

	var _react2 = _interopRequireDefault(_react);

	var _classnames2 = _interopRequireDefault(_classnames);

	var _2 = _interopRequireDefault(_);

	var _pxIcon2 = _interopRequireDefault(_pxIcon);

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

	function _classCallCheck(instance, Constructor) {
		if (!(instance instanceof Constructor)) {
			throw new TypeError("Cannot call a class as a function");
		}
	}

	var _createClass = function () {
		function defineProperties(target, props) {
			for (var i = 0; i < props.length; i++) {
				var descriptor = props[i];
				descriptor.enumerable = descriptor.enumerable || false;
				descriptor.configurable = true;
				if ("value" in descriptor) descriptor.writable = true;
				Object.defineProperty(target, descriptor.key, descriptor);
			}
		}

		return function (Constructor, protoProps, staticProps) {
			if (protoProps) defineProperties(Constructor.prototype, protoProps);
			if (staticProps) defineProperties(Constructor, staticProps);
			return Constructor;
		};
	}();

	function _possibleConstructorReturn(self, call) {
		if (!self) {
			throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
		}

		return call && (typeof call === "object" || typeof call === "function") ? call : self;
	}

	function _inherits(subClass, superClass) {
		if (typeof superClass !== "function" && superClass !== null) {
			throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
		}

		subClass.prototype = Object.create(superClass && superClass.prototype, {
			constructor: {
				value: subClass,
				enumerable: false,
				writable: true,
				configurable: true
			}
		});
		if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
	}

	var Icon = function (_React$Component) {
		_inherits(Icon, _React$Component);

		function Icon(props) {
			_classCallCheck(this, Icon);

			var _this = _possibleConstructorReturn(this, (Icon.__proto__ || Object.getPrototypeOf(Icon)).call(this, props));

			_this.createMarkup = _this.createMarkup.bind(_this);
			_this.mergeStyles = _this.mergeStyles.bind(_this);
			return _this;
		}

		_createClass(Icon, [{
			key: 'mergeStyles',
			value: function mergeStyles() {
				for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
					args[_key] = arguments[_key];
				}

				return Object.assign.apply(Object, [{}].concat(args));
			}
		}, {
			key: 'createMarkup',
			value: function createMarkup(icon) {
				var name = icon && icon.replace(':', '-');
				var html = this.getIcon(name);
				return { __html: html };
			}
		}, {
			key: 'getIcon',
			value: function getIcon(name) {
				if (_2.default.hasOwnProperty(name)) {
					return _2.default[name];
				}
			}
		}, {
			key: 'render',
			value: function render() {
				var _props = this.props,
				    _props$icon = _props.icon,
				    icon = _props$icon === undefined ? '' : _props$icon,
				    size = _props.size,
				    style = _props.style,
				    className = _props.className,
				    viewBox = _props.viewBox;

				var styles = {
					width: size + 'px',
					height: size + 'px'
				};
				var svgStyles = {
					pointerEvents: 'none',
					display: 'block',
					width: size + 'px',
					height: size + 'px'
				};
				var icn = icon && icon.replace(':', '-');
				var _viewBox = viewBox || '0 0 ' + size + ' ' + size;
				return _react2.default.createElement(
					'i',
					{ className: (0, _classnames2.default)('px-icon', className, icn), style: styles },
					_react2.default.createElement('svg', { viewBox: _viewBox,
						preserveAspectRatio: 'xMidYMid meet',
						dangerouslySetInnerHTML: this.createMarkup(icon),
						style: this.mergeStyles(svgStyles, style) })
				);
			}
		}]);

		return Icon;
	}(_react2.default.Component);

	Icon.defaultProps = {
		size: 24
	};

	exports.default = Icon;
});