/**
 * Field metadata normalization utilities
 *
 * These functions convert consumer-facing input formats to canonical internal format.
 * Handles both legacy (hidden, dataOk) and preferred (visibility, data_ok) formats.
 */
/**
 * Check if we're in development mode
 */
const IS_DEV = typeof process !== 'undefined' && process.env?.NODE_ENV === 'development';
/**
 * Log a development-mode warning
 * Only logs in development, silent in production
 */
export function dev_warning(message, details) {
    if (IS_DEV) {
        const prefix = '[hazo_collab_forms]';
        if (details) {
            console.warn(`${prefix} Warning: ${message}`, details);
        }
        else {
            console.warn(`${prefix} Warning: ${message}`);
        }
    }
}
/**
 * Normalize field metadata input to canonical format
 *
 * Converts alternative naming conventions to preferred format:
 *
 * - `hidden: true` → `visibility: 'hidden'`
 * - `hidden: false` → `visibility: 'visible'`
 * - `dataOk: value` → `data_ok: value`
 *
 * @param input - Field metadata in any supported format
 * @returns Normalized metadata with canonical property names
 *
 * @example
 * ```ts
 * normalize_field_metadata_input({ hidden: true, dataOk: 'ok' })
 * // => { visibility: 'hidden', data_ok: 'ok' }
 *
 * normalize_field_metadata_input({ visibility: 'visible', data_ok: false })
 * // => { visibility: 'visible', data_ok: false }
 * ```
 */
export function normalize_field_metadata_input(input) {
    // Handle visibility: prefer visibility prop, fallback to hidden
    let visibility = input.visibility;
    if (visibility === undefined && input.hidden !== undefined) {
        visibility = input.hidden ? 'hidden' : 'visible';
    }
    // Handle data_ok: prefer data_ok, fallback to dataOk
    const data_ok = input.data_ok ?? input.dataOk;
    return {
        visibility,
        locked: input.locked,
        data_ok,
        deleted: input.deleted,
        skipped: input.skipped,
        has_clarification: input.has_clarification,
    };
}
/**
 * Normalize field metadata from consumer input to internal format
 *
 * This is the full normalization that preserves all properties.
 * Use this when you need the complete FieldMetadata object.
 *
 * @param input - Field metadata in any supported format
 * @returns Normalized FieldMetadata with canonical property names
 */
export function normalize_field_metadata(input) {
    const result = { ...input };
    // Handle hidden -> visibility conversion
    if ('hidden' in input && input.hidden !== undefined) {
        result.visibility = input.hidden ? 'hidden' : 'visible';
        delete result['hidden'];
    }
    // Handle dataOk -> data_ok conversion (camelCase to snake_case)
    if ('dataOk' in input && input.dataOk !== undefined) {
        // Only use dataOk if data_ok is not already set (data_ok takes priority)
        if (result.data_ok === undefined) {
            result.data_ok = input.dataOk;
        }
        delete result['dataOk'];
    }
    return result;
}
/**
 * Normalize a record of field metadata
 * Applies normalize_field_metadata to each entry
 *
 * @param input - Record of field metadata keyed by field ID
 * @returns Record with all values normalized
 */
export function normalize_field_metadata_record(input) {
    const result = {};
    for (const [key, value] of Object.entries(input)) {
        result[key] = normalize_field_metadata(value);
    }
    return result;
}
//# sourceMappingURL=normalize.js.map