"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseCigar = parseCigar;
exports.flipCigar = flipCigar;
exports.swapIndelCigar = swapIndelCigar;
const cigarRegex = new RegExp(/([MIDNSHPX=])/);
function parseCigar(cigar = '') {
    return cigar.split(cigarRegex).slice(0, -1);
}
function flipCigar(cigar) {
    const arr = [];
    for (let i = cigar.length - 2; i >= 0; i -= 2) {
        arr.push(cigar[i]);
        const op = cigar[i + 1];
        if (op === 'D') {
            arr.push('I');
        }
        else if (op === 'I') {
            arr.push('D');
        }
        else {
            arr.push(op);
        }
    }
    return arr;
}
function swapIndelCigar(cigar) {
    return cigar.replaceAll('D', 'K').replaceAll('I', 'D').replaceAll('K', 'I');
}
