/**
 * 사용자 계정 상태 카탈로그
 *
 * SSOT: backend kcg.auth_user.user_stts_cd
 * 사용처: AccessControl, 사용자 관리 화면
 */

import type { BadgeIntent } from '@lib/theme/variants';

export type UserAccountStatus = 'ACTIVE' | 'LOCKED' | 'INACTIVE' | 'PENDING';

interface UserAccountStatusMeta {
  code: UserAccountStatus;
  i18nKey: string;
  fallback: { ko: string; en: string };
  intent: BadgeIntent;
}

export const USER_ACCOUNT_STATUSES: Record<UserAccountStatus, UserAccountStatusMeta> = {
  ACTIVE: {
    code: 'ACTIVE',
    i18nKey: 'userAccountStatus.ACTIVE',
    fallback: { ko: '활성', en: 'Active' },
    intent: 'success',
  },
  PENDING: {
    code: 'PENDING',
    i18nKey: 'userAccountStatus.PENDING',
    fallback: { ko: '승인 대기', en: 'Pending' },
    intent: 'warning',
  },
  LOCKED: {
    code: 'LOCKED',
    i18nKey: 'userAccountStatus.LOCKED',
    fallback: { ko: '잠금', en: 'Locked' },
    intent: 'critical',
  },
  INACTIVE: {
    code: 'INACTIVE',
    i18nKey: 'userAccountStatus.INACTIVE',
    fallback: { ko: '비활성', en: 'Inactive' },
    intent: 'muted',
  },
};

export function getUserAccountStatusIntent(s: string): BadgeIntent {
  return USER_ACCOUNT_STATUSES[s as UserAccountStatus]?.intent ?? 'muted';
}
export function getUserAccountStatusLabel(
  s: string,
  t: (k: string, opts?: { defaultValue?: string }) => string,
  lang: 'ko' | 'en' = 'ko',
): string {
  const meta = USER_ACCOUNT_STATUSES[s as UserAccountStatus];
  if (!meta) return s;
  return t(meta.i18nKey, { defaultValue: meta.fallback[lang] });
}
