// Bug: loose regex plus parseFloat * 100 (accepts bad grouping and leading zeros, returns -0, no size check).export type AmountFailure = { kind: "invalid_amount"; input: string } | { kind: "too_large" };export class AmountError extends Error { declare readonly kind: AmountFailure["kind"]; declare readonly input?: string; constructor(failure: AmountFailure) { super(failure.kind); Object.assign(this, failure); }}export function parseAmount(text: string): number { if (!/^-?\d[\d,]*(\.\d{1,2})?$/.test(text)) throw new AmountError({ kind: "invalid_amount", input: text }); const n = parseFloat(text.replace(/,/g, "")); if (Number.isNaN(n)) throw new AmountError({ kind: "invalid_amount", input: text }); return Math.round(n * 100);}