"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = function(module) {
        var getter = module && module.__esModule ? function() {
            return module['default'];
        } : function() {
            return module;
        };
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __webpack_require__.d = function(exports1, definition) {
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
(()=>{
    __webpack_require__.r = function(exports1) {
        if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    tableActionColumnInitializers: ()=>tableActionColumnInitializers,
    Resizable: ()=>Resizable
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const external_react_namespaceObject = require("react");
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
const schema_namespaceObject = require("@tachybase/schema");
const icons_namespaceObject = require("@ant-design/icons");
const external_lodash_namespaceObject = require("lodash");
var external_lodash_default = /*#__PURE__*/ __webpack_require__.n(external_lodash_namespaceObject);
const external_react_i18next_namespaceObject = require("react-i18next");
const index_js_namespaceObject = require("../../../../api-client/index.js");
const SchemaInitializerActionModal_js_namespaceObject = require("../../../../application/schema-initializer/components/SchemaInitializerActionModal.js");
const SchemaInitializerItem_js_namespaceObject = require("../../../../application/schema-initializer/components/SchemaInitializerItem.js");
const context_index_js_namespaceObject = require("../../../../application/schema-initializer/context/index.js");
const SchemaInitializer_js_namespaceObject = require("../../../../application/schema-initializer/SchemaInitializer.js");
const external_data_source_index_js_namespaceObject = require("../../../../data-source/index.js");
const external_schema_component_index_js_namespaceObject = require("../../../../schema-component/index.js");
const useGetAriaLabelOfDesigner_js_namespaceObject = require("../../../../schema-settings/hooks/useGetAriaLabelOfDesigner.js");
const Resizable = ()=>{
    var _fieldSchema_xcomponentprops;
    const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
    const { dn } = (0, external_schema_component_index_js_namespaceObject.useDesignable)();
    const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SchemaInitializerActionModal_js_namespaceObject.SchemaInitializerActionModal, {
        title: t('Column width'),
        component: /*#__PURE__*/ external_react_default().forwardRef((props, ref)=>{
            const { children, onClick, ...others } = props;
            const { setVisible } = (0, context_index_js_namespaceObject.useSchemaInitializer)();
            return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SchemaInitializerItem_js_namespaceObject.SchemaInitializerItem, {
                ref: ref,
                onClick: (param)=>{
                    let { event } = param;
                    setVisible(false);
                    onClick(event);
                },
                ...others,
                title: t('Column width')
            });
        }),
        schema: {
            type: 'object',
            title: t('Column width'),
            properties: {
                width: {
                    'x-decorator': 'FormItem',
                    'x-component': 'InputNumber',
                    'x-component-props': {},
                    default: (null == fieldSchema ? void 0 : null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.width) || 200
                }
            }
        },
        onSubmit: (param)=>{
            let { width } = param;
            const props = fieldSchema['x-component-props'] || {};
            props['width'] = width;
            const schema = {
                ['x-uid']: fieldSchema['x-uid']
            };
            schema['x-component-props'] = props;
            fieldSchema['x-component-props'] = props;
            dn.emit('patch', {
                schema
            });
            dn.refresh();
        }
    });
};
const commonOptions = {
    insertPosition: 'beforeEnd',
    useInsert: function() {
        const { refresh } = (0, external_schema_component_index_js_namespaceObject.useDesignable)();
        const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
        const api = (0, index_js_namespaceObject.useAPIClient)();
        const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
        return function(schema) {
            const spaceSchema = fieldSchema.reduceProperties((buf, schema)=>{
                if ('Space' === schema['x-component']) return schema;
                return buf;
            }, null);
            if (!spaceSchema) return;
            external_lodash_default().set(schema, 'x-designer-props.linkageAction', true);
            const dn = (0, external_schema_component_index_js_namespaceObject.createDesignable)({
                t,
                api,
                refresh,
                current: spaceSchema
            });
            dn.loadAPIClientEvents();
            dn.insertBeforeEnd(schema);
        };
    },
    Component: (props)=>{
        const { getAriaLabel } = (0, useGetAriaLabelOfDesigner_js_namespaceObject.useGetAriaLabelOfDesigner)();
        return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.MenuOutlined, {
            ...props,
            role: "button",
            "aria-label": getAriaLabel('schema-settings'),
            style: {
                cursor: 'pointer'
            }
        });
    },
    items: [
        {
            type: 'itemGroup',
            name: 'actions',
            title: '{{t("Enable actions")}}',
            children: [
                {
                    type: 'item',
                    title: '{{t("View")}}',
                    name: 'view',
                    Component: 'ViewActionInitializer',
                    schema: {
                        'x-component': 'Action.Link',
                        'x-action': 'view',
                        'x-decorator': 'ACLActionProvider'
                    }
                },
                {
                    type: 'item',
                    name: 'edit',
                    title: '{{t("Edit")}}',
                    Component: 'UpdateActionInitializer',
                    schema: {
                        'x-component': 'Action.Link',
                        'x-action': 'update',
                        'x-decorator': 'ACLActionProvider'
                    },
                    useVisible () {
                        const collection = (0, external_data_source_index_js_namespaceObject.useCollection)();
                        return ('view' !== collection.template || (null == collection ? void 0 : collection.writableView)) && 'sql' !== collection.template;
                    }
                },
                {
                    type: 'item',
                    title: '{{t("Delete")}}',
                    name: 'delete',
                    Component: 'DestroyActionInitializer',
                    schema: {
                        'x-component': 'Action.Link',
                        'x-action': 'destroy',
                        'x-decorator': 'ACLActionProvider'
                    },
                    useVisible () {
                        const collection = (0, external_data_source_index_js_namespaceObject.useCollection)();
                        return ('view' !== collection.template || (null == collection ? void 0 : collection.writableView)) && 'sql' !== collection.template;
                    }
                },
                {
                    type: 'item',
                    title: '{{t("Disassociate")}}',
                    name: 'disassociate',
                    Component: 'DisassociateActionInitializer',
                    schema: {
                        'x-component': 'Action.Link',
                        'x-action': 'disassociate',
                        'x-acl-action': 'destroy',
                        'x-decorator': 'ACLActionProvider'
                    },
                    useVisible () {
                        const props = (0, external_data_source_index_js_namespaceObject.useDataBlockProps)();
                        const collection = (0, external_data_source_index_js_namespaceObject.useCollection)();
                        return !!(null == props ? void 0 : props.association) && ('view' !== collection.template || (null == collection ? void 0 : collection.writableView)) && 'sql' !== collection.template;
                    }
                },
                {
                    type: 'item',
                    title: '{{t("Add child")}}',
                    name: 'addChildren',
                    Component: 'CreateChildInitializer',
                    schema: {
                        'x-component': 'Action.Link',
                        'x-action': 'create',
                        'x-decorator': 'ACLActionProvider'
                    },
                    useVisible () {
                        var _fieldSchema_parent;
                        const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
                        const collection = (0, external_data_source_index_js_namespaceObject.useCollection)();
                        const { treeTable } = (null == fieldSchema ? void 0 : null === (_fieldSchema_parent = fieldSchema.parent) || void 0 === _fieldSchema_parent ? void 0 : _fieldSchema_parent.parent['x-decorator-props']) || {};
                        return collection.tree && false !== treeTable;
                    }
                }
            ]
        },
        {
            name: 'divider',
            type: 'divider'
        },
        {
            type: 'subMenu',
            title: '{{t("Customize")}}',
            name: 'customize',
            children: [
                {
                    type: 'item',
                    title: '{{t("Popup")}}',
                    name: 'popup',
                    Component: 'PopupActionInitializer'
                },
                {
                    type: 'item',
                    title: '{{t("Update record")}}',
                    name: 'updateRecord',
                    Component: 'UpdateRecordActionInitializer',
                    useVisible () {
                        const collection = (0, external_data_source_index_js_namespaceObject.useCollection)();
                        return ('view' !== collection.template || (null == collection ? void 0 : collection.writableView)) && 'sql' !== collection.template;
                    }
                },
                {
                    name: 'customRequest',
                    title: '{{t("Custom request")}}',
                    Component: 'CustomRequestInitializer',
                    schema: {
                        'x-action': 'customize:table:request'
                    },
                    useVisible () {
                        const collection = (0, external_data_source_index_js_namespaceObject.useCollection)();
                        return ('view' !== collection.template || (null == collection ? void 0 : collection.writableView)) && 'sql' !== collection.template;
                    }
                }
            ]
        },
        {
            name: 'divider2',
            type: 'divider'
        },
        {
            type: 'item',
            name: 'columnWidth',
            title: 't("Column width")',
            Component: Resizable
        }
    ]
};
const tableActionColumnInitializers = new SchemaInitializer_js_namespaceObject.SchemaInitializer({
    name: 'table:configureItemActions',
    ...commonOptions
});
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
