import type { GlobConfig } from '/#/config';

// import { warn } from '@/utils/log';
import { getAppEnvConfig } from '@/utils/env';

export const useGlobSetting = (): Readonly<GlobConfig> => {
  const {
    VITE_GLOB_APP_TITLE,
    VITE_GLOB_API_URL_PREFIX,
    VITE_GLOB_DRILL_SIGN_URL,
    VITE_GLOB_SKYEYE_LOGIN_URL,
    VITE_GLOB_SKYEYE_PLATFORM_URL,
    VITE_GLOB_SKYEYE_ADMIN_URL,
    VITE_GLOB_SKYEYE_H5_URL,
    VITE_GLOB_TIANSUO_PLATFORM,
    VITE_GLOB_SHOW_CAPTCHA,
    VITE_GLOB_CBRAIN_LOGIN_APP,
    VITE_GLOB_CBRAIN_LOGIN_CLIENT_ID,
  } = getAppEnvConfig();

  // Take global configuration
  const glob: Readonly<GlobConfig> = {
    title: VITE_GLOB_APP_TITLE,

    urlPrefix: VITE_GLOB_API_URL_PREFIX || '',

    drillSignUrl: VITE_GLOB_DRILL_SIGN_URL || '',

    // tenantCode: VITE_GLOB_TENANT_CODE,

    skyeyeLoginHost: VITE_GLOB_SKYEYE_LOGIN_URL,
    skyeyePlatformHost: VITE_GLOB_SKYEYE_PLATFORM_URL,
    skyeyeAdminHost: VITE_GLOB_SKYEYE_ADMIN_URL,
    skyeyeH5Host: VITE_GLOB_SKYEYE_H5_URL,

    tiansuoHost: VITE_GLOB_TIANSUO_PLATFORM,
    showCaptcha: VITE_GLOB_SHOW_CAPTCHA,
    cbrainLoginApp: VITE_GLOB_CBRAIN_LOGIN_APP,
    cbrainLoginClientId: VITE_GLOB_CBRAIN_LOGIN_CLIENT_ID,
  };
  return glob as Readonly<GlobConfig>;
};
