"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.INSTRUMENT_ROUTING = void 0;
exports.resolveInstrumentGl = resolveInstrumentGl;
exports.isIbanValid = isIbanValid;
/** SWIFT / trade-finance instrument routing */
exports.INSTRUMENT_ROUTING = {
    SBLC: { swift: ['MT103', 'MT202'], glDebit: '1410', glCredit: '2100' },
    DLC: { swift: ['MT103', 'MT102'], glDebit: '1410', glCredit: '1000' },
    BG: { swift: ['MT103'], glDebit: '1410', glCredit: '2100' },
    LS: { swift: ['MT102', 'MT103'], glDebit: '1000', glCredit: '2200' },
};
function resolveInstrumentGl(instrument) {
    const r = exports.INSTRUMENT_ROUTING[instrument];
    return { debitGl: r.glDebit, creditGl: r.glCredit, swiftKinds: r.swift };
}
function isIbanValid(iban) {
    const normalized = iban.replace(/\s/g, '').toUpperCase();
    if (!/^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$/.test(normalized))
        return false;
    const rearranged = normalized.slice(4) + normalized.slice(0, 4);
    const numeric = rearranged.replace(/[A-Z]/g, (c) => String(c.charCodeAt(0) - 55));
    let remainder = 0;
    for (const ch of numeric) {
        remainder = (remainder * 10 + parseInt(ch, 10)) % 97;
    }
    return remainder === 1;
}
