"use strict";
var __webpack_require__ = {};
(()=>{
    __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__, {
    uiSchemaTemplatesSchema: ()=>uiSchemaTemplatesSchema
});
const schema_namespaceObject = require("@tachybase/schema");
const index_js_namespaceObject = require("../../block-provider/hooks/index.js");
const uiSchemaTemplates_js_namespaceObject = require("../collections/uiSchemaTemplates.js");
const external_useSchemaTemplateManager_js_namespaceObject = require("../useSchemaTemplateManager.js");
const external_CollectionTitle_js_namespaceObject = require("./CollectionTitle.js");
const useUpdateSchemaTemplateActionProps = ()=>{
    const props = (0, index_js_namespaceObject.useUpdateActionProps)();
    const { refresh } = (0, external_useSchemaTemplateManager_js_namespaceObject.useSchemaTemplateManager)();
    return {
        async onClick () {
            await props.onClick();
            refresh();
        }
    };
};
const useBulkDestroyTemplateProps = ()=>{
    const props = (0, index_js_namespaceObject.useBulkDestroyActionProps)();
    const { refresh } = (0, external_useSchemaTemplateManager_js_namespaceObject.useSchemaTemplateManager)();
    return {
        async onClick () {
            await props.onClick();
            refresh();
        }
    };
};
const useDestroyTemplateProps = ()=>{
    const props = (0, index_js_namespaceObject.useDestroyActionProps)();
    const { refresh } = (0, external_useSchemaTemplateManager_js_namespaceObject.useSchemaTemplateManager)();
    return {
        async onClick () {
            await props.onClick();
            refresh();
        }
    };
};
const uiSchemaTemplatesSchema = {
    type: 'object',
    properties: {
        [(0, schema_namespaceObject.uid)()]: {
            type: 'void',
            'x-decorator': 'TableBlockProvider',
            'x-decorator-props': {
                collection: uiSchemaTemplates_js_namespaceObject.uiSchemaTemplatesCollection,
                resource: 'uiSchemaTemplates',
                action: 'list',
                params: {
                    pageSize: 20,
                    sort: [
                        '-createdAt'
                    ]
                },
                rowKey: 'key',
                showIndex: true,
                dragSort: false
            },
            'x-component': 'CardItem',
            properties: {
                actions: {
                    type: 'void',
                    'x-component': 'ActionBar',
                    'x-component-props': {
                        style: {
                            marginBottom: 16
                        }
                    },
                    properties: {
                        destroy: {
                            title: '{{ t("Delete") }}',
                            'x-action': 'destroy',
                            'x-component': 'Action',
                            'x-use-component-props': useBulkDestroyTemplateProps,
                            'x-component-props': {
                                icon: 'DeleteOutlined',
                                confirm: {
                                    title: "{{t('Delete record')}}",
                                    content: "{{t('Are you sure you want to delete it?')}}"
                                }
                            }
                        }
                    }
                },
                [(0, schema_namespaceObject.uid)()]: {
                    type: 'array',
                    'x-component': 'TableV2',
                    'x-use-component-props': 'useTableBlockProps',
                    'x-component-props': {
                        rowSelection: {
                            type: 'checkbox'
                        }
                    },
                    properties: {
                        actions: {
                            type: 'void',
                            title: '{{ t("Actions") }}',
                            'x-component': 'TableV2.Column',
                            properties: {
                                actions: {
                                    type: 'void',
                                    'x-decorator': 'DndContext',
                                    'x-component': 'Space',
                                    'x-component-props': {
                                        split: '|'
                                    },
                                    properties: {
                                        edit: {
                                            type: 'void',
                                            title: '{{ t("Edit") }}',
                                            'x-action': 'update',
                                            'x-component': 'Action.Link',
                                            'x-component-props': {
                                                openMode: 'drawer',
                                                icon: 'EditOutlined'
                                            },
                                            properties: {
                                                drawer: {
                                                    type: 'void',
                                                    title: '{{ t("Edit record") }}',
                                                    'x-component': 'Action.Container',
                                                    'x-component-props': {
                                                        className: 'tb-action-popup'
                                                    },
                                                    properties: {
                                                        form: {
                                                            type: 'void',
                                                            'x-decorator': 'FormBlockProvider',
                                                            'x-decorator-props': {
                                                                resource: 'uiSchemaTemplates',
                                                                collection: uiSchemaTemplates_js_namespaceObject.uiSchemaTemplatesCollection,
                                                                action: 'get',
                                                                useParams: '{{ useParamsFromRecord }}'
                                                            },
                                                            'x-component': 'CardItem',
                                                            properties: {
                                                                [(0, schema_namespaceObject.uid)()]: {
                                                                    type: 'void',
                                                                    'x-component': 'FormV2',
                                                                    'x-use-component-props': 'useFormBlockProps',
                                                                    properties: {
                                                                        name: {
                                                                            type: 'string',
                                                                            'x-component': 'CollectionField',
                                                                            'x-decorator': 'FormItem',
                                                                            'x-collection-field': 'uiSchemaTemplates.name',
                                                                            required: true
                                                                        },
                                                                        actions: {
                                                                            type: 'void',
                                                                            'x-component': 'ActionBar',
                                                                            'x-component-props': {
                                                                                layout: 'one-column',
                                                                                style: {
                                                                                    marginTop: 24
                                                                                }
                                                                            },
                                                                            properties: {
                                                                                submit: {
                                                                                    title: '{{t("Submit")}}',
                                                                                    'x-action': 'submit',
                                                                                    'x-component': 'Action',
                                                                                    'x-use-component-props': useUpdateSchemaTemplateActionProps,
                                                                                    'x-component-props': {
                                                                                        type: 'primary',
                                                                                        htmlType: 'submit'
                                                                                    },
                                                                                    type: 'void'
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        },
                                        destroy: {
                                            title: '{{ t("Delete") }}',
                                            'x-action': 'destroy',
                                            'x-component': 'Action.Link',
                                            'x-use-component-props': useDestroyTemplateProps,
                                            'x-component-props': {
                                                icon: 'DeleteOutlined',
                                                confirm: {
                                                    title: "{{t('Delete record')}}",
                                                    content: "{{t('Are you sure you want to delete it?')}}"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        },
                        column1: {
                            type: 'void',
                            'x-decorator': 'TableV2.Column.Decorator',
                            'x-component': 'TableV2.Column',
                            properties: {
                                name: {
                                    type: 'string',
                                    'x-collection-field': 'uiSchemaTemplates.name',
                                    'x-component': 'CollectionField',
                                    'x-read-pretty': true,
                                    'x-component-props': {
                                        ellipsis: true
                                    }
                                }
                            }
                        },
                        column2: {
                            type: 'void',
                            title: '{{t("Collection display name")}}',
                            'x-component': 'TableV2.Column',
                            properties: {
                                'collection.title': {
                                    type: 'string',
                                    'x-component': external_CollectionTitle_js_namespaceObject.CollectionTitle,
                                    'x-read-pretty': true,
                                    'x-component-props': {
                                        ellipsis: true
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
};
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
});
