import React from 'react';
import { ExtendedColumn } from '../components/ExtendedColumn/ExtendedColumn';
const ExtendedColumnsConfig = {
    shortText: {
        width: '150px',
        align: 'start',
    },
    dateTime: {
        width: '200px',
        align: 'center',
    },
    date: {
        width: '150px',
        align: 'center',
    },
    decimal: {
        width: '100px',
        align: 'center',
    },
    integer: {
        width: '100px',
        align: 'center',
    },
    checkbox: {
        width: '100px',
        align: 'center',
    },
    longText: {
        width: '250px',
        align: 'start',
    },
    url: {
        width: '250px',
        align: 'start',
    },
    dropdown: {
        width: '150px',
        align: 'start',
    },
    files: {
        width: '180px',
        align: 'start',
    },
    multiSelect: {
        width: '150px',
        align: 'start',
    },
};
export const prefixFieldWithNamespace = (id, namespace) => `extendedFields.namespaces.${namespace}.${id}`;
export const prefixFieldWithUserFieldsNamespace = (id) => prefixFieldWithNamespace(id, '_user_fields');
export function simplifyExtendedColumns({ fields, toExtendedFields, defaultHidden, }) {
    return fields.map((field) => {
        const type = field.type;
        const id = prefixFieldWithNamespace(field.id, field.namespace);
        return {
            dataExtension: field,
            id,
            dataHook: id,
            name: field.label || field.id,
            title: field.label || field.id,
            hideable: true,
            sortable: field.filterable,
            defaultHidden: defaultHidden || field.owner !== 'user',
            align: type ? ExtendedColumnsConfig[type].align : undefined,
            width: type ? ExtendedColumnsConfig[type].width : undefined,
            style: type ? ExtendedColumnsConfig[type].style : undefined,
            render: (row) => {
                const value = toExtendedFields?.(row)?.namespaces?.[field.namespace]?.[field.id];
                return React.createElement(ExtendedColumn, { type: type, value: value });
            },
        };
    });
}
//# sourceMappingURL=simplifyExtendedColumns.js.map