import { theme as defaultTheme } from './../theme';
import { mergeWith } from 'lodash';

function isFunction(value) {
  return typeof value === 'function';
}

export function extendTheme(overrides) {
  function customizer(source, override) {
    if (isFunction(source)) {
      return (...args) => {
        const sourceValue = source(...args);
        const overrideValue = isFunction(override) ? override(...args) : override;
        return mergeWith({}, sourceValue, overrideValue, customizer);
      };
    }

    return undefined;
  }

  return mergeWith({}, defaultTheme, overrides, customizer);
}
//# sourceMappingURL=extendTheme.js.map