import { CompressMethod, Config } from './types';

const env = import.meta.env.VITE_APP_ENV || 'production';
const isDev = env === 'development';
const isTest = env === 'test';

const configTitle = import.meta.env.VITE_APP_TITLE!;
let title = configTitle;
if (isDev) {
    title = `${configTitle} - 开发环境`;
} else if (isTest) {
    title = `${configTitle} - 测试环境`;
}

const config: Config = {
    app: {
        code: import.meta.env.VITE_API_PRODUCT_CODE!,
        title,
        version: import.meta.env.VITE_APP_VERSION!,
        routerMode: import.meta.env.VITE_ROUTER_MODE!,
        storageNameSpace: import.meta.env.VITE_STORAGE_NAME_SPACE!,
    },
    security: {
        enableRequestEncryption: import.meta.env.VITE_ENABLE_REQUEST_ENCRYPTION === 'true',
        requestEncryptionKey: import.meta.env.VITE_REQUEST_ENCRYPTION_KEY ?? '',
        enableStorageEncryption: import.meta.env.VITE_ENABLE_STORAGE_ENCRYPTION === 'true',
        storageEncryptionKey: import.meta.env.VITE_STORAGE_ENCRYPTION_KEY ?? '',
        compressMethod:
            (import.meta.env.VITE_REQUEST_DATA_COMPRESSION as CompressMethod) ??
            CompressMethod.NO_ZIP,
    },
    api: {
        baseURL: import.meta.env.VITE_API_BASE_URL!,
    },
};

export default config;
