/**
 * Multi-country profile scaffold. UZ is the pilot default; additional countries
 * register via registerCountryProfile without changing call sites.
 */

export interface CountryFeatureFlags {
  gisAgentAssist?: boolean;
  voiceOtp?: boolean;
  institutionRouting?: boolean;
  [key: string]: boolean | undefined;
}

export interface CountryProfile {
  countryCode: string;
  displayName: string;
  defaultLocale: string;
  languages: string[];
  consentVersion: string;
  consentPdfUrl?: string;
  currencyCode: string;
  phonePrefix: string;
  featureFlags: CountryFeatureFlags;
}

const UZ_PROFILE: CountryProfile = {
  countryCode: "UZ",
  displayName: "Uzbekistan",
  defaultLocale: "uz",
  languages: ["uz", "ru", "en"],
  consentVersion: "2026.1",
  consentPdfUrl: "https://agnet.global/legal/consent-uz-2026.1.pdf",
  currencyCode: "UZS",
  phonePrefix: "+998",
  featureFlags: {
    gisAgentAssist: true,
    voiceOtp: false,
    institutionRouting: true,
  },
};

const profiles = new Map<string, CountryProfile>([[UZ_PROFILE.countryCode, UZ_PROFILE]]);

export function registerCountryProfile(profile: CountryProfile): void {
  profiles.set(profile.countryCode.toUpperCase(), profile);
}

export function getCountryProfile(countryCode = "UZ"): CountryProfile | undefined {
  return profiles.get(countryCode.toUpperCase());
}

export function getDefaultCountryProfile(): CountryProfile {
  return UZ_PROFILE;
}

export function listCountryProfiles(): CountryProfile[] {
  return [...profiles.values()];
}
