export const DEFAULT_CHUNK_SIZE = 200;
export const MIN_CHUNK_SIZE = 50;
export const MAX_CHUNK_SIZE = 8191;
export const DEFAULT_CHUNK_OVERLAP = 40;
export const MIN_CHUNK_OVERLAP = 25;
export const DEFAULT_MAX_OVERLAP_RATIO = 0.5;

export const DEFAULT_VECTOR_DIMENSIONS = 1536;

// File size limit (バイト)
export const MAX_FILE_SIZE = 100 * 1024 * 1024; // 100MB

export const DEFAULT_MAX_BATCH_SIZE = 2048;

// Supported languages
const SUPPORTED_LANGUAGES = ['zh', 'en', 'ja'] as const;

/**
 * Get the default language from the environment variable.
 * Fallback to 'en' (English) if not set or invalid.
 */
function getDefaultLanguage(): (typeof SUPPORTED_LANGUAGES)[number] {
  const envValue = process.env.DEFAULT_LANGUAGE?.toLowerCase();

  // Validate: must be one of supported languages
  if (
    envValue &&
    SUPPORTED_LANGUAGES.includes(
      envValue as (typeof SUPPORTED_LANGUAGES)[number],
    )
  ) {
    return envValue as (typeof SUPPORTED_LANGUAGES)[number];
  }

  // Fallback to English if not set or invalid
  return 'en';
}

// Default language - read from env, fallback to English
export const DEFAULT_LANGUAGE = getDefaultLanguage();
export const DEFAULT_LANGUAGE_FALLBACK = 'en';

// システム全体の共通テナントID（シードデータetc.で使用）
export const GLOBAL_TENANT_ID = '00000000-0000-0000-0000-000000000000';
