import { jsx as _jsx } from "@emotion/react/jsx-runtime";
import { useTranslation, I18nextProvider } from 'react-i18next';
import { Widget } from '../widget';
import { CustomWidget } from '../custom-widget';
import { EntityFormStyled } from './entity-list.style';
export const EntityForm = ({ data, path }) => {
    const { t, i18n } = useTranslation();
    const { schema, namespace } = data;
    if (!schema || !namespace) {
        return (_jsx(EntityFormStyled, { children: t('inspector.entityList.content.noSchema.title') }));
    }
    if (schema.view) {
        return (_jsx(CustomWidget, { fields: schema.fields || [], path: path, component: schema.view, namespace: namespace }));
    }
    if (!schema.fields || schema.fields.length === 0) {
        return (_jsx(EntityFormStyled, { children: t('inspector.entityList.content.empty.title') }));
    }
    return (_jsx(I18nextProvider, { i18n: i18n, defaultNS: namespace, children: _jsx(Widget, { fields: schema.fields, path: path }) }));
};
