import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE_antd__ from "antd";
import * as __WEBPACK_EXTERNAL_MODULE_react_i18next__ from "react-i18next";
import * as __WEBPACK_EXTERNAL_MODULE__data_source_DataSourceManager_mjs__ from "../data-source/DataSourceManager.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__ from "../../schema-component/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__collection_index_mjs__ from "../collection/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__ from "../data-source/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__data_source_DataSourceProvider_mjs__ from "../data-source/DataSourceProvider.mjs";
const { Text } = __WEBPACK_EXTERNAL_MODULE_antd__.Typography;
const CollectionDeletedPlaceholder = (param)=>{
    let { type, name, message } = param;
    const { designable, dn } = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useDesignable)();
    const { modal } = __WEBPACK_EXTERNAL_MODULE_antd__.App.useApp();
    const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
    const dataSource = (0, __WEBPACK_EXTERNAL_MODULE__data_source_DataSourceProvider_mjs__.useDataSource)();
    const compile = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useCompile)();
    const collection = (0, __WEBPACK_EXTERNAL_MODULE__collection_index_mjs__.useCollection)();
    const dataSourceManager = (0, __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__.useDataSourceManager)();
    const nameValue = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
        if ('DataSource' === type) return name;
        const dataSourcePrefix = (null == dataSourceManager ? void 0 : dataSourceManager.getDataSources().length) >= 1 && dataSource && dataSource.key !== __WEBPACK_EXTERNAL_MODULE__data_source_DataSourceManager_mjs__.DEFAULT_DATA_SOURCE_KEY ? "".concat(compile(dataSource.displayName || dataSource.key), " > ") : '';
        if ('Collection' === type) return "".concat(dataSourcePrefix).concat(name);
        const collectionPrefix = collection ? "".concat(compile(collection.title) || collection.name || collection.tableName, " > ") : '';
        return "".concat(dataSourcePrefix).concat(collectionPrefix).concat(name);
    }, []);
    const blockType = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
        if ('Field' === type) return 'Field';
        return 'Block';
    }, [
        type
    ]);
    const messageValue = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
        if (!name) return "".concat(t(type), " ", 'name is required');
        if (message) return "".concat(t(type), ' "').concat(nameValue, '" ').concat(message);
        return t('The {{type}} "{{name}}" may have been deleted. Please remove this {{blockType}}.', {
            type: t(type).toLocaleLowerCase(),
            name: nameValue,
            blockType: t(blockType)
        }).replaceAll('&gt;', '>');
    }, [
        message,
        nameValue,
        type,
        t,
        blockType
    ]);
    if (designable) {
        if ('Field' === type) return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.EllipsisWithTooltip, {
            ellipsis: true,
            children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(Text, {
                type: "secondary",
                children: messageValue
            })
        });
        return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.CardItem, {
            children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Result, {
                status: "404",
                subTitle: messageValue,
                extra: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Button, {
                    onClick: ()=>modal.confirm({
                            title: t('Delete block'),
                            content: t('Are you sure you want to delete it?'),
                            ...confirm,
                            onOk () {
                                dn.remove(null, {
                                    removeParentsIfNoChildren: true,
                                    breakRemoveOn: {
                                        'x-component': 'Grid'
                                    }
                                });
                            }
                        }),
                    children: t('Delete')
                }, "Delete")
            })
        });
    }
    return null;
};
export { CollectionDeletedPlaceholder };
