/**
 * Field ID collection utility
 *
 * Extracts all field IDs from a nested field/section structure.
 * Used for batch operations like chat status fetching.
 */
import { traverse_fields, traverse_sections } from './traverse_fields.js';
/**
 * Collect all field IDs from a flat or nested field array
 *
 * @param fields - Array of fields (may contain groups with nested fields)
 * @returns Array of all field IDs, including nested fields
 *
 * @example
 * ```ts
 * const fields = [
 *   { id: 'name', field_type: 'inputbox' },
 *   { id: 'address', field_type: 'group', fields: [
 *     { id: 'street', field_type: 'inputbox' },
 *     { id: 'city', field_type: 'inputbox' },
 *   ]},
 * ];
 *
 * collect_field_ids(fields);
 * // => ['name', 'address', 'street', 'city']
 * ```
 */
export function collect_field_ids(fields) {
    const ids = [];
    traverse_fields(fields, (field) => {
        ids.push(field.id);
    });
    return ids;
}
/**
 * Collect all field IDs from sections
 *
 * Traverses all sections and their groups to collect every field ID.
 * Includes group IDs and all nested field IDs.
 *
 * @param sections - Array of sections containing groups
 * @returns Array of all field IDs across all sections
 *
 * @example
 * ```ts
 * const sections = [
 *   {
 *     section_name: 'Personal Info',
 *     groups: [
 *       { id: 'basic', field_type: 'group', fields: [
 *         { id: 'first_name', field_type: 'inputbox' },
 *         { id: 'last_name', field_type: 'inputbox' },
 *       ]},
 *     ],
 *   },
 * ];
 *
 * collect_field_ids_from_sections(sections);
 * // => ['basic', 'first_name', 'last_name']
 * ```
 */
export function collect_field_ids_from_sections(sections) {
    const ids = [];
    traverse_sections(sections, (field) => {
        ids.push(field.id);
    });
    return ids;
}
/**
 * Collect field IDs excluding group containers
 *
 * Returns only leaf field IDs, not group container IDs.
 * Useful when you only care about actual data fields.
 *
 * @param fields - Array of fields
 * @returns Array of non-group field IDs
 */
export function collect_leaf_field_ids(fields) {
    const ids = [];
    traverse_fields(fields, (field) => {
        if (field.field_type !== 'group') {
            ids.push(field.id);
        }
    }, { include_groups: true } // Still traverse through groups, just don't add their IDs
    );
    return ids;
}
//# sourceMappingURL=collect_field_ids.js.map