import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE__api_client_index_mjs__ from "../../api-client/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__data_source_collection_CollectionProvider_mjs__ from "../../data-source/collection/CollectionProvider.mjs";
const useCollection_deprecated = ()=>{
    var _collection_getOptions;
    const collection = (0, __WEBPACK_EXTERNAL_MODULE__data_source_collection_CollectionProvider_mjs__.useCollection)();
    const api = (0, __WEBPACK_EXTERNAL_MODULE__api_client_index_mjs__.useAPIClient)();
    const resource = null == api ? void 0 : api.resource(null == collection ? void 0 : collection.name);
    const currentFields = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>(null == collection ? void 0 : collection.fields) || [], [
        collection
    ]);
    const inheritedFields = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
        var _collection_getInheritedFields;
        return (null == collection ? void 0 : null === (_collection_getInheritedFields = collection.getInheritedFields) || void 0 === _collection_getInheritedFields ? void 0 : _collection_getInheritedFields.call(collection)) || [];
    }, [
        collection
    ]);
    const totalFields = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
        var _collection_getAllFields, _collection_getFields;
        return (null == collection ? void 0 : null === (_collection_getAllFields = collection.getAllFields) || void 0 === _collection_getAllFields ? void 0 : _collection_getAllFields.call(collection)) || (null == collection ? void 0 : null === (_collection_getFields = collection.getFields) || void 0 === _collection_getFields ? void 0 : _collection_getFields.call(collection)) || [];
    }, [
        collection
    ]);
    const foreignKeyFields = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
        var _collection_getForeignKeyFields;
        return (null == collection ? void 0 : null === (_collection_getForeignKeyFields = collection.getForeignKeyFields) || void 0 === _collection_getForeignKeyFields ? void 0 : _collection_getForeignKeyFields.call(collection)) || [];
    }, [
        collection
    ]);
    const getTreeParentField = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)(()=>null == totalFields ? void 0 : totalFields.find((field)=>field.treeParent), [
        totalFields
    ]);
    const getField = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((name)=>{
        var _collection_getField;
        return null == collection ? void 0 : null === (_collection_getField = collection.getField) || void 0 === _collection_getField ? void 0 : _collection_getField.call(collection, name);
    }, [
        collection
    ]);
    const getPrimaryKey = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)(()=>null == collection ? void 0 : collection.getPrimaryKey(), [
        collection
    ]);
    return {
        ...null == collection ? void 0 : null === (_collection_getOptions = collection.getOptions) || void 0 === _collection_getOptions ? void 0 : _collection_getOptions.call(collection),
        resource,
        getTreeParentField,
        fields: totalFields,
        getField,
        getPrimaryKey,
        currentFields,
        inheritedFields,
        foreignKeyFields
    };
};
export { useCollection_deprecated };
