import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
import * as __WEBPACK_EXTERNAL_MODULE__application_schema_initializer_SchemaInitializer_mjs__ from "../../../../application/schema-initializer/SchemaInitializer.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__ from "../../../../data-source/index.mjs";
const tableActionInitializers = new __WEBPACK_EXTERNAL_MODULE__application_schema_initializer_SchemaInitializer_mjs__.SchemaInitializer({
    name: 'table:configureActions',
    title: "{{t('Configure actions')}}",
    icon: 'SettingOutlined',
    style: {
        marginLeft: 8
    },
    items: [
        {
            type: 'itemGroup',
            name: 'enableActions',
            title: "{{t('Enable actions')}}",
            children: [
                {
                    type: 'item',
                    name: 'filter',
                    title: "{{t('Filter')}}",
                    Component: 'FilterActionInitializer',
                    schema: {
                        'x-align': 'left'
                    }
                },
                {
                    type: 'item',
                    title: "{{t('Add new')}}",
                    name: 'addNew',
                    Component: 'CreateActionInitializer',
                    schema: {
                        'x-align': 'right',
                        'x-decorator': 'ACLActionProvider',
                        'x-acl-action-props': {
                            skipScopeCheck: true
                        }
                    },
                    useVisible () {
                        const collection = (0, __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__.useCollection)();
                        return ![
                            'view',
                            'file',
                            'sql'
                        ].includes(collection.template) || (null == collection ? void 0 : collection.writableView);
                    }
                },
                {
                    type: 'item',
                    title: "{{t('Associate')}}",
                    name: 'associate',
                    Component: 'AssociateActionInitializer',
                    useVisible () {
                        const collection = (0, __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__.useCollection)();
                        const props = (0, __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__.useDataBlockProps)();
                        return props.association && (![
                            'view',
                            'file',
                            'sql'
                        ].includes(collection.template) || (null == collection ? void 0 : collection.writableView));
                    }
                },
                {
                    type: 'item',
                    title: "{{t('Delete')}}",
                    name: 'delete',
                    Component: 'BulkDestroyActionInitializer',
                    schema: {
                        'x-align': 'right',
                        'x-decorator': 'ACLActionProvider'
                    },
                    useVisible () {
                        const collection = (0, __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__.useCollection)();
                        return ![
                            'view',
                            'sql'
                        ].includes(collection.template) || (null == collection ? void 0 : collection.writableView);
                    }
                },
                {
                    type: 'item',
                    title: "{{t('Refresh')}}",
                    name: 'refresh',
                    Component: 'RefreshActionInitializer',
                    schema: {
                        'x-align': 'right'
                    }
                },
                {
                    name: 'toggle',
                    title: "{{t('Expand/Collapse')}}",
                    Component: 'ExpandableActionInitializer',
                    schema: {
                        'x-align': 'right'
                    },
                    useVisible () {
                        var _schema_parent;
                        const schema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
                        const collection = (0, __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__.useCollection)();
                        const { treeTable } = (null == schema ? void 0 : null === (_schema_parent = schema.parent) || void 0 === _schema_parent ? void 0 : _schema_parent['x-decorator-props']) || {};
                        return collection.tree && false !== treeTable;
                    }
                }
            ]
        },
        {
            name: 'divider',
            type: 'divider',
            useVisible () {
                const collection = (0, __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__.useCollection)();
                return ![
                    'view',
                    'sql'
                ].includes(collection.template) || (null == collection ? void 0 : collection.writableView);
            }
        },
        {
            type: 'subMenu',
            name: 'customize',
            title: '{{t("Customize")}}',
            children: [
                {
                    type: 'item',
                    title: '{{t("Add record")}}',
                    name: 'addRecord',
                    Component: 'CustomizeAddRecordActionInitializer',
                    schema: {
                        'x-align': 'right',
                        'x-decorator': 'ACLActionProvider',
                        'x-acl-action': 'create',
                        'x-acl-action-props': {
                            skipScopeCheck: true
                        }
                    }
                }
            ],
            useVisible () {
                const collection = (0, __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__.useCollection)();
                return ![
                    'view',
                    'sql'
                ].includes(collection.template) || (null == collection ? void 0 : collection.writableView);
            }
        }
    ]
});
export { tableActionInitializers };
