/**
 * Converts a number to a Roman numeral.
 * @param num - The number to convert.
 * @returns The Roman numeral representation.
 */
export const convertToRoman = (num) => {
    const romanMap = [
        ['m', 1000],
        ['cm', 900],
        ['d', 500],
        ['cd', 400],
        ['c', 100],
        ['xc', 90],
        ['l', 50],
        ['xl', 40],
        ['x', 10],
        ['ix', 9],
        ['v', 5],
        ['iv', 4],
        ['i', 1]
    ];
    let result = '';
    for (const [roman, value] of romanMap) {
        while (num >= value) {
            result += roman;
            num -= value;
        }
    }
    return result;
};
/**
 * Converts a number to a base-26 alphabetic string (a, b, c... aa, ab, ac...).
 * @param num - The 0-based index to convert.
 * @returns The alphabetic representation.
 */
export const convertToAlphabetic = (num) => {
    let result = '';
    while (num >= 0) {
        result = String.fromCharCode((num % 26) + 97) + result;
        num = Math.floor(num / 26) - 1;
    }
    return result;
};
/**
 * Generates a list number based on depth and index.
 * @param levelIndex - The index of the item in the list (0-based).
 * @param depth - The depth of the list (0-based).
 * @returns The formatted list number.
 */
export const getFormattedListNumber = (levelIndex, depth) => {
    if (depth % 3 === 0) {
        return (levelIndex + 1).toString();
    }
    if (depth % 3 === 1) {
        return convertToAlphabetic(levelIndex);
    }
    return convertToRoman(levelIndex + 1);
};
/**
 * Generates a compound index and the current list index based on the depth and index of the current item and its ancestors.
 * @param indices - An array of indices representing the position at each depth (e.g., [0, 1, 2]).
 * @returns An object containing:
 * - `rootIndex`: The zero-based index at the root level (e.g., 0 for "1.", 1 for "2.").
 * - `currentIndex`: The index at the latest depth (e.g., "a." or "i.").
 * - `compoundIndex`: The full compound index (e.g., "1 A II").
 */
export const getIndexDetails = (indices) => {
    const indexSegments = indices.map((levelIndex, index) => getFormattedListNumber(levelIndex, index));
    const rootIndex = indices[0];
    const currentIndex = `${indexSegments[indexSegments.length - 1]}.`;
    const compoundIndex = indexSegments.join(' ').toUpperCase();
    return { rootIndex, currentIndex, compoundIndex };
};
//# sourceMappingURL=FieldGroupList.utils.js.map