import { merge } from '@uifabric-vue/utilities';
import { getSemanticColors } from './utilities/makeSemanticColors.js';

/**
 * Merge a partial/full theme into a full theme and returns a merged full theme.
 */
function mergeThemes(theme, partialTheme) {
    if (partialTheme === void 0) { partialTheme = {}; }
    var _a, _b, _c, _d;
    var mergedTheme = merge({}, theme, partialTheme, {
        semanticColors: getSemanticColors(partialTheme.palette, partialTheme.effects, partialTheme.semanticColors, partialTheme.isInverted === undefined ? theme.isInverted : partialTheme.isInverted),
    });
    if (((_a = partialTheme.palette) === null || _a === void 0 ? void 0 : _a.themePrimary) && !((_b = partialTheme.palette) === null || _b === void 0 ? void 0 : _b.accent)) {
        mergedTheme.palette.accent = partialTheme.palette.themePrimary;
    }
    if (partialTheme.defaultFontStyle) {
        for (var _i = 0, _e = Object.keys(mergedTheme.fonts); _i < _e.length; _i++) {
            var fontStyle = _e[_i];
            mergedTheme.fonts[fontStyle] = merge(mergedTheme.fonts[fontStyle], partialTheme.defaultFontStyle, (_d = (_c = partialTheme) === null || _c === void 0 ? void 0 : _c.fonts) === null || _d === void 0 ? void 0 : _d[fontStyle]);
        }
    }
    if (partialTheme.stylesheets) {
        mergedTheme.stylesheets = (theme.stylesheets || []).concat(partialTheme.stylesheets);
    }
    return mergedTheme;
}

export { mergeThemes };
