import * as React from 'react';
// eslint-disable-next-line import/no-cycle
import { CnAsyncSelect, CnTreeSelect } from '@cainiaofe/cn-ui';
export default (column) => {
    const { options = {} } = column;
    const requestConfig = options.requestConfig || {};
    return {
        cell(value) {
            const config = {
                ...options,
                filterLocal: true,
                value,
                requestConfig: {
                    cacheKey: `${requestConfig.url}+${requestConfig.method}+${JSON.stringify(requestConfig.params)}+${JSON.stringify(requestConfig.data)}`,
                    staleTime: 5000,
                    ...requestConfig,
                },
                readOnly: true,
                multiple: true,
            };
            if (options.mode === 'TreeSelect') {
                return React.createElement(CnTreeSelect, { readOnlyProps: { valueSeparator: ',' }, ...config });
            }
            return React.createElement(CnAsyncSelect, { ...config });
        },
    };
};
