import { getFrontendAppName } from '../../base/support/basename.mjs';
import { CLIENT_MAIN_SRC_DIR, CLIENT_TEST_SRC_DIR, CLIENT_I18N_DIR } from '../../generator-constants.mjs';
export const loadClientConfig = ({ config, application }) => {
    application.clientPackageManager = config.clientPackageManager;
    application.clientFramework = config.clientFramework;
    application.clientTheme = config.clientTheme;
    application.clientThemeVariant = config.clientThemeVariant;
    application.devServerPort = config.devServerPort;
    application.clientRootDir = config.clientRootDir ?? '';
    application.clientSrcDir = config.clientSrcDir ?? `${application.clientRootDir}${CLIENT_MAIN_SRC_DIR}`;
    application.clientTestDir = config.clientTestDir ?? `${application.clientRootDir}${CLIENT_TEST_SRC_DIR}`;
    if (config.skipServer) {
        application.clientSrcDir = config.clientSrcDir || CLIENT_MAIN_SRC_DIR;
        application.clientTestDir = config.clientTestDir || CLIENT_TEST_SRC_DIR;
        application.clientDir = '';
    }
    else {
        application.clientSrcDir = 'front/' + (config.clientSrcDir || CLIENT_MAIN_SRC_DIR);
        application.clientTestDir = 'front/' + (config.clientTestDir || CLIENT_TEST_SRC_DIR);
        application.clientDir = 'front/';
    }
    if (!config.skipMobile) {
        if (config.skipServer) {
            application.mobileClientDir = '';
        }
        else {
            application.mobileClientDir = 'mobile/';
        }
        application.mobileSrcDir = application.mobileClientDir + 'src/';
    }
    application.clientI18nDir = ['vben'].includes(application.clientTheme) ? 'locales/' : (config.clientI18nDir || CLIENT_I18N_DIR);
    application.languageFileType = ['vben'].includes(application.clientTheme) ? 'ts' : 'json';
};
export const loadDerivedClientConfig = ({ application }) => {
    if (application.microfrontend === undefined) {
        if (application.applicationTypeMicroservice) {
            application.microfrontend = application.clientFrameworkAny;
        }
        else if (application.applicationTypeGateway) {
            application.microfrontend = application.microfrontends && application.microfrontends.length > 0;
        }
    }
    application.clientThemeNone = application.clientTheme === 'none';
    application.clientThemePrimary = application.clientThemeVariant === 'primary';
    application.clientThemeLight = application.clientThemeVariant === 'light';
    application.clientThemeDark = application.clientThemeVariant === 'dark';
    if (application.baseName) {
        application.frontendAppName = getFrontendAppName({ baseName: application.baseName });
    }
};
