'use strict';

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

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

exports.default = getPropsFrom;
var NATIVE_PROPS = ['aria-label', 'autoFocus', 'className', 'id', 'name'];

function extractComponentProps(Component, props) {
	if (!Component) {
		return {};
	}
	var extractedProps = {};
	Object.keys(Component.propTypes || {}).forEach(function (propName) {
		if (props[propName] !== undefined) {
			extractedProps[propName] = props[propName];
		}
	});
	return extractedProps;
}

function extractNativeProps(props) {
	var extractedProps = {};
	NATIVE_PROPS.forEach(function (propName) {
		if (props[propName] !== undefined) {
			extractedProps[propName] = props[propName];
		}
	});
	return extractedProps;
}

function getPropsFrom(Component, props) {
	if (!Component) {
		return {};
	}
	return _extends({}, extractNativeProps(props), extractComponentProps(Component, props));
}