import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { cn } from '../../../utils/cn.js';
import { format_currency } from '../../../utils/financial_format.js';
export function SummaryRowField(props) {
    const { field, value, config, value_column_width, badge_column_width, reserve_file_column, paired_value } = props;
    const num_value = value != null && value !== '' ? Number(value) : null;
    const symbol = field.currency_symbol || config.default_currency_symbol;
    const decimals = field.decimal_places ?? config.default_decimal_places;
    const variant_style = field.style_variant && config.style_resolver.has_style(field.style_variant)
        ? config.style_resolver.to_style(field.style_variant)
        : {};
    const display_value = num_value != null && !isNaN(num_value)
        ? format_currency(num_value, symbol, decimals)
        : '';
    // Paired field support
    const has_paired = Boolean(field.paired_field);
    const paired_symbol = field.paired_field?.currency_symbol || symbol;
    const paired_decimals = field.paired_field?.decimal_places ?? decimals;
    const paired_num = paired_value != null && paired_value !== '' ? Number(paired_value) : null;
    const paired_display = paired_num != null && !isNaN(paired_num)
        ? format_currency(paired_num, paired_symbol, paired_decimals)
        : '';
    return (_jsxs("div", { className: cn('cls_data_form_summary_row', 'flex items-center gap-2 py-1.5 px-2'), style: {
            ...variant_style,
            borderStyle: variant_style.borderWidth ? 'solid' : undefined,
        }, children: [_jsxs("div", { className: "flex-1 min-w-0", children: [_jsx("span", { className: "font-semibold", children: field.label || field.id }), field.summary_note && (_jsx("span", { className: "ml-2 text-xs text-gray-500", children: field.summary_note }))] }), badge_column_width && (_jsx("div", { style: { width: badge_column_width }, className: "shrink-0" })), _jsx("div", { className: "shrink-0 text-right font-semibold", style: { width: value_column_width || '200px' }, children: display_value || '\u00A0' }), has_paired && (_jsx("div", { className: "shrink-0 text-right font-semibold", style: { width: value_column_width || '200px' }, children: paired_display || '\u00A0' })), reserve_file_column && (_jsx("div", { className: "shrink-0 ml-1", style: { width: 26 } }))] }));
}
//# sourceMappingURL=summary_row_field.js.map