import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
import * as __WEBPACK_EXTERNAL_MODULE_react_i18next__ from "react-i18next";
import * as __WEBPACK_EXTERNAL_MODULE__collection_manager_index_mjs__ from "../../collection-manager/index.mjs";
const useFieldComponentOptions = ()=>{
    var _fieldSchema_xcomponentprops;
    const { getCollectionJoinField, getCollection } = (0, __WEBPACK_EXTERNAL_MODULE__collection_manager_index_mjs__.useCollectionManager_deprecated)();
    const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
    const { getField } = (0, __WEBPACK_EXTERNAL_MODULE__collection_manager_index_mjs__.useCollection_deprecated)();
    const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']);
    const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
    const { label } = (null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.fieldNames) || {};
    const fieldComponentOptions = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
        if (!collectionField || !(null == collectionField ? void 0 : collectionField.interface)) return;
        if (![
            'o2o',
            'oho',
            'obo',
            'o2m',
            'linkTo',
            'm2o',
            'm2m'
        ].includes(collectionField.interface)) return;
        const collection = getCollection(collectionField.target);
        if ((null == collection ? void 0 : collection.template) === 'file') return [
            {
                label: t('Record picker'),
                value: 'CollectionField'
            },
            {
                label: t('Select'),
                value: 'AssociationSelect'
            }
        ];
        switch(collectionField.interface){
            case 'o2m':
                return [
                    {
                        label: t('Record picker'),
                        value: 'CollectionField'
                    },
                    {
                        label: t('Subtable'),
                        value: 'TableField'
                    },
                    {
                        label: t('Select'),
                        value: 'AssociationSelect'
                    }
                ];
            case 'm2o':
            case 'm2m':
            case 'linkTo':
                return [
                    {
                        label: t('Record picker'),
                        value: 'CollectionField'
                    },
                    {
                        label: t('Select'),
                        value: 'AssociationSelect'
                    }
                ];
            default:
                return [
                    {
                        label: t('Record picker'),
                        value: 'CollectionField'
                    },
                    {
                        label: t('Subform'),
                        value: 'FormField'
                    },
                    {
                        label: t('Select'),
                        value: 'AssociationSelect'
                    }
                ];
        }
    }, [
        t,
        null == collectionField ? void 0 : collectionField.interface,
        label
    ]);
    return fieldComponentOptions;
};
export { useFieldComponentOptions };
