/**
 * Field-level control resolution with cascade inheritance
 *
 * Resolves which controls are enabled for a field using cascade priority:
 * field-level > parent-group > form-level > fallback
 *
 * This allows groups to set control defaults that propagate to children,
 * while still allowing individual fields to override.
 */
/**
 * Resolve effective control settings for a field.
 *
 * Cascade priority: field-level > parent-group > form-level > false
 *
 * This allows groups to set control defaults that propagate to their children,
 * while still allowing individual fields to override.
 *
 * @param field - The field's control settings
 * @param parent_group - The parent group's control settings (if this field is inside a group)
 * @param form_level - Form-level control settings from component props
 * @returns Resolved settings with all controls having definite boolean values
 *
 * @example
 * ```ts
 * // Group with enable_lock=true
 * // Child field inherits enable_lock=true unless it explicitly sets enable_lock=false
 *
 * const field_settings: ControlEnableSettings = {};
 * const group_settings: ControlEnableSettings = { enable_lock: true, enable_notes: true };
 * const form_settings: ControlEnableSettings = { enable_data_ok: true };
 *
 * const resolved = resolve_field_controls(field_settings, group_settings, form_settings);
 * // => { enable_lock: true, enable_notes: true, enable_data_ok: true, ... }
 * ```
 */
export function resolve_field_controls(field, parent_group, form_level) {
    return {
        enable_lock: field?.enable_lock ??
            parent_group?.enable_lock ??
            form_level.enable_lock ??
            false,
        enable_visibility_toggle: field?.enable_visibility_toggle ??
            parent_group?.enable_visibility_toggle ??
            form_level.enable_visibility_toggle ??
            false,
        enable_delete: field?.enable_delete ??
            parent_group?.enable_delete ??
            form_level.enable_delete ??
            false,
        enable_data_ok: field?.enable_data_ok ??
            parent_group?.enable_data_ok ??
            form_level.enable_data_ok ??
            false,
        enable_complete: field?.enable_complete ??
            parent_group?.enable_complete ??
            form_level.enable_complete ??
            false,
        enable_skip: field?.enable_skip ??
            parent_group?.enable_skip ??
            form_level.enable_skip ??
            false,
        enable_notes: field?.enable_notes ??
            parent_group?.enable_notes ??
            form_level.enable_notes ??
            false,
        enable_chat: field?.enable_chat ??
            parent_group?.enable_chat ??
            form_level.enable_chat ??
            false,
        enable_edit_fields: field?.enable_edit_fields ??
            parent_group?.enable_edit_fields ??
            form_level.enable_edit_fields ??
            false,
    };
}
/**
 * Convert resolved control settings to fallback visibility settings
 * for use with UnifiedFieldControls
 *
 * @param settings - Resolved control settings
 * @returns FallbackSettings compatible with UnifiedFieldControls
 */
export function controls_to_fallback_visibility(settings) {
    return {
        data_ok: settings.enable_data_ok,
        skip: settings.enable_skip,
        notes: settings.enable_notes,
        chat: settings.enable_chat,
        visibility: settings.enable_visibility_toggle,
        lock: settings.enable_lock,
        delete: settings.enable_delete,
        add_elements: settings.enable_edit_fields,
    };
}
//# sourceMappingURL=resolve_field_controls.js.map