import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
import * as __WEBPACK_EXTERNAL_MODULE_lodash__ from "lodash";
import * as __WEBPACK_EXTERNAL_MODULE__block_provider_BlockProvider_mjs__ from "../../../../block-provider/BlockProvider.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__ from "../../../../data-source/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__ from "../../../hooks/index.mjs";
const useGetAriaLabelOfBlockItem = (defaultName)=>{
    var _fieldSchema_xcomponent, _collection_getField_uiSchema, _collection_getField;
    const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
    const compile = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.useCompile)();
    const component = __WEBPACK_EXTERNAL_MODULE_lodash__["default"].isString(fieldSchema['x-component']) ? fieldSchema['x-component'] : null === (_fieldSchema_xcomponent = fieldSchema['x-component']) || void 0 === _fieldSchema_xcomponent ? void 0 : _fieldSchema_xcomponent.displayName;
    const collectionField = compile(fieldSchema['x-collection-field']);
    const { name: blockName } = (0, __WEBPACK_EXTERNAL_MODULE__block_provider_BlockProvider_mjs__.useBlockContext)() || {};
    const collection = (0, __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__.useCollection)();
    const name = defaultName || blockName;
    const title = compile(fieldSchema['title']) || compile(null == collection ? void 0 : null === (_collection_getField = collection.getField(fieldSchema.name)) || void 0 === _collection_getField ? void 0 : null === (_collection_getField_uiSchema = _collection_getField.uiSchema) || void 0 === _collection_getField_uiSchema ? void 0 : _collection_getField_uiSchema.title);
    const getAriaLabel = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((postfix)=>{
        postfix = postfix ? "-".concat(postfix) : '';
        return [
            'block-item',
            component,
            null == collection ? void 0 : collection.name,
            name,
            collectionField,
            title,
            postfix
        ].filter(Boolean).join('-');
    }, [
        component,
        null == collection ? void 0 : collection.name,
        name,
        collectionField,
        title
    ]);
    return {
        getAriaLabel
    };
};
export { useGetAriaLabelOfBlockItem };
