import isNull from 'lodash/isNull';
import omitBy from 'lodash/omitBy';
import { darkTheme, theme } from '@darajs/styled-components';
function isTheme(configTheme) {
    return typeof configTheme !== 'string';
}
/**
 * Resolve the theme passed from the backend. If the default values of 'default' or 'dark' are passed then return the
 * default themes from styled-components, otherwise pass back the custom theme scheme.
 *
 * @param configTheme - the config theme structure of the app
 */
export default function resolveTheme(configTheme, baseTheme) {
    if (!configTheme || configTheme === 'light') {
        return theme;
    }
    if (configTheme === 'dark') {
        return darkTheme;
    }
    if (isTheme(configTheme)) {
        const original = baseTheme === 'dark' ? darkTheme : theme;
        return Object.assign(Object.assign(Object.assign({}, original), omitBy(configTheme, isNull)), { colors: Object.assign(Object.assign({}, original.colors), omitBy(configTheme.colors, isNull)), font: Object.assign(Object.assign({}, original.font), omitBy(configTheme.font, isNull)), shadow: Object.assign(Object.assign({}, original.shadow), omitBy(configTheme.shadow, isNull)) });
    }
    // eslint-disable-next-line no-console
    console.warn('No valid theme was found. Defaulting to light theme.');
    return theme;
}
//# sourceMappingURL=resolve-theme.js.map