import { useEffect } from "react";
import { useField, useFieldSchema } from "@tachybase/schema";
import { useCollectionManager_deprecated, useCollection_deprecated } from "../../collection-manager/index.mjs";
import { useCompile } from "./useCompile.mjs";
const useFieldTitle = ()=>{
    var _collectionField_uiSchema;
    const field = useField();
    const fieldSchema = useFieldSchema();
    const { getField } = useCollection_deprecated();
    const { getCollectionJoinField } = useCollectionManager_deprecated();
    const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']);
    const compile = useCompile();
    useEffect(()=>{
        if (!(null == field ? void 0 : field.title)) {
            var _collectionField_uiSchema;
            field.title = compile(null == collectionField ? void 0 : null == (_collectionField_uiSchema = collectionField.uiSchema) ? void 0 : _collectionField_uiSchema.title);
        }
    }, [
        null == collectionField ? void 0 : null == (_collectionField_uiSchema = collectionField.uiSchema) ? void 0 : _collectionField_uiSchema.title
    ]);
};
export { useFieldTitle };
