import { a as theme } from './chunk-aeb80e51.js';
import React from 'react';
import { create } from 'nano-css';
import { addon } from 'nano-css/addon/cache';
import { addon as addon$1 } from 'nano-css/addon/stable';
import { addon as addon$2 } from 'nano-css/addon/nesting';
import { addon as addon$3 } from 'nano-css/addon/keyframes';
import { addon as addon$4 } from 'nano-css/addon/unitless';
import { addon as addon$5 } from 'nano-css/addon/rule';
import { addon as addon$6 } from 'nano-css/addon/sheet';
import { a as classCallCheck, b as createClass, c as defineProperty, d as inherits, e as objectWithoutProperties, f as possibleConstructorReturn, g as slicedToArray, h as _typeof, i as _extends } from './chunk-aad905a2.js';

var withTheme = function withTheme(styles) {
	if (typeof styles === 'function') {
		return styles(theme);
	}
	return styles;
};

var nano = create({
	// Add prefix to all generated class names.
	pfx: 'es-'
});

// Add addons you would like to use.
addon(nano);
addon$1(nano);
addon$2(nano);
addon$3(nano);
addon$5(nano);
addon$6(nano);
addon$4(nano);

var withNano = function withNano(styles, _displayName) {
	return function (WrappedComponent) {
		var displayName = _displayName || WrappedComponent.displayName || WrappedComponent.name || 'Component';
		var themedStyles = withTheme(styles);

		var _Object$keys$reduce = Object.keys(themedStyles).reduce(function (memo, key) {
			var idx = typeof themedStyles[key] === 'function' ? 1 : 0;
			memo[idx][key] = themedStyles[key];
			return memo;
		}, [{}, {}]),
		    _Object$keys$reduce2 = slicedToArray(_Object$keys$reduce, 2),
		    baseStyles = _Object$keys$reduce2[0],
		    dynamicStyles = _Object$keys$reduce2[1];

		var baseClasses = nano.sheet(baseStyles, displayName);
		var Component = function Component(props) {
			var compiledStyles = Object.keys(dynamicStyles).reduce(function (memo, key) {
				memo[key] = dynamicStyles[key](props);
				return memo;
			}, {});
			var rnd = Math.random().toString(36).substr(2);
			var dynamicClasses = nano.sheet(compiledStyles, displayName + '-' + rnd);
			return React.createElement(WrappedComponent, _extends({ classes: _extends({}, baseClasses, dynamicClasses) }, props));
		};
		Component.displayName = 'WithNano(' + displayName + ')';
		return Component;
	};
};

function createCommonjsModule(fn, module) {
	return module = { exports: {} }, fn(module, module.exports), module.exports;
}

var classnames = createCommonjsModule(function (module) {
/*!
  Copyright (c) 2017 Jed Watson.
  Licensed under the MIT License (MIT), see
  http://jedwatson.github.io/classnames
*/
/* global define */

(function () {

	var hasOwn = {}.hasOwnProperty;

	function classNames () {
		var classes = [];

		for (var i = 0; i < arguments.length; i++) {
			var arg = arguments[i];
			if (!arg) continue;

			var argType = typeof arg;

			if (argType === 'string' || argType === 'number') {
				classes.push(arg);
			} else if (Array.isArray(arg) && arg.length) {
				var inner = classNames.apply(null, arg);
				if (inner) {
					classes.push(inner);
				}
			} else if (argType === 'object') {
				for (var key in arg) {
					if (hasOwn.call(arg, key) && arg[key]) {
						classes.push(key);
					}
				}
			}
		}

		return classes.join(' ');
	}

	if (module.exports) {
		classNames.default = classNames;
		module.exports = classNames;
	} else {
		window.classNames = classNames;
	}
}());
});

export { withNano as a, classnames as b };
//# sourceMappingURL=chunk-86765554.js.map
