export type AppLocale = "zh-TW" | "en";

/** 扁平 key → 字串；{name} 可插值 */
export type MessageDict = Record<string, string>;

export type AppCurrency = "TWD" | "USD" | "JPY" | "EUR" | "HKD";

export type LocaleMeta = {
  id: AppLocale;
  label: string;
  nativeLabel: string;
};

export type CurrencyMeta = {
  id: AppCurrency;
  label: string;
  symbol: string;
  /** 相對 TWD 的 mock 匯率（1 TWD = rate * foreign? 改用：amount_twd * rate = foreign） */
  fromTwd: number;
};

export const LOCALES: LocaleMeta[] = [
  { id: "zh-TW", label: "Traditional Chinese", nativeLabel: "繁體中文" },
  { id: "en", label: "English", nativeLabel: "English" },
];

export const CURRENCIES: CurrencyMeta[] = [
  { id: "TWD", label: "New Taiwan Dollar", symbol: "NT$", fromTwd: 1 },
  { id: "USD", label: "US Dollar", symbol: "US$", fromTwd: 1 / 32 },
  { id: "HKD", label: "Hong Kong Dollar", symbol: "HK$", fromTwd: 1 / 4.1 },
  { id: "JPY", label: "Japanese Yen", symbol: "¥", fromTwd: 4.7 },
  { id: "EUR", label: "Euro", symbol: "€", fromTwd: 1 / 35 },
];

export function isAppLocale(v: string): v is AppLocale {
  return v === "zh-TW" || v === "en";
}

export function isAppCurrency(v: string): v is AppCurrency {
  return CURRENCIES.some((c) => c.id === v);
}
