export const normaliseChoice = (value: string) => value .normalize('NFD') .replace(/\p{Diacritic}/gu, '') .toLocaleLowerCase('pt') .trim(); export function matchesChoice(query: string, labels: string[]): boolean { const needle = normaliseChoice(query); return ( !needle || labels.some((label) => normaliseChoice(label).includes(needle)) ); } /** The same ISO currency source already used by the simulator, with readable labels. */ export function currencyChoices(codes?: readonly string[]) { const intl = Intl as unknown as { supportedValuesOf?: (key: string) => string[]; }; const names = new Intl.DisplayNames(['pt-MZ'], { type: 'currency' }); return [ ...new Set( codes ?? intl.supportedValuesOf?.('currency') ?? [ 'MZN', 'USD', 'EUR', 'ZAR', ], ), ].map((code) => ({ value: code, label: `${names.of(code) ?? code} — ${code}`, keywords: [code, names.of(code) ?? code], })); }