"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__, {
    roleSchema: ()=>roleSchema
});
const external_react_namespaceObject = require("react");
const schema_namespaceObject = require("@tachybase/schema");
const pick_namespaceObject = require("lodash/pick");
var pick_default = /*#__PURE__*/ __webpack_require__.n(pick_namespaceObject);
const index_js_namespaceObject = require("../../../../api-client/index.js");
const external_record_provider_index_js_namespaceObject = require("../../../../record-provider/index.js");
const external_schema_component_index_js_namespaceObject = require("../../../../schema-component/index.js");
const collection = {
    name: 'roles',
    filterTargetKey: 'name',
    targetKey: 'name',
    fields: [
        {
            type: 'integer',
            name: 'title',
            interface: 'input',
            uiSchema: {
                title: '{{t("Role display name")}}',
                type: 'number',
                'x-component': 'Input',
                required: true
            }
        },
        {
            type: 'string',
            name: 'name',
            interface: 'input',
            uiSchema: {
                title: '{{t("Role UID")}}',
                type: 'string',
                'x-component': 'Input'
            }
        },
        {
            type: 'boolean',
            name: 'default',
            interface: 'boolean',
            uiSchema: {
                title: '{{t("Default role")}}',
                type: 'boolean',
                'x-component': 'Checkbox'
            }
        }
    ]
};
const roleSchema = {
    type: 'object',
    properties: {
        block1: {
            type: 'void',
            'x-decorator': 'ResourceActionProvider',
            'x-decorator-props': {
                collection,
                resourceName: 'roles',
                request: {
                    resource: 'roles',
                    action: 'list',
                    params: {
                        pageSize: 50,
                        filter: {
                            'name.$ne': 'root'
                        },
                        showAnonymous: true,
                        sort: [
                            'createdAt'
                        ],
                        appends: []
                    }
                }
            },
            'x-component': 'CollectionProvider_deprecated',
            'x-component-props': {
                collection
            },
            properties: {
                actions: {
                    type: 'void',
                    'x-component': 'ActionBar',
                    'x-component-props': {
                        style: {
                            marginBottom: 16
                        }
                    },
                    properties: {
                        delete: {
                            type: 'void',
                            title: '{{ t("Delete") }}',
                            'x-component': 'Action',
                            'x-component-props': {
                                useAction: '{{ cm.useBulkDestroyAction }}',
                                confirm: {
                                    title: "{{t('Delete role')}}",
                                    content: "{{t('Are you sure you want to delete it?')}}"
                                }
                            }
                        },
                        create: {
                            type: 'void',
                            title: '{{t("Add role")}}',
                            'x-component': 'Action',
                            'x-component-props': {
                                type: 'primary'
                            },
                            properties: {
                                drawer: {
                                    type: 'void',
                                    'x-component': 'Action.Drawer',
                                    'x-decorator': 'Form',
                                    'x-decorator-props': {
                                        useValues (options) {
                                            const ctx = (0, external_schema_component_index_js_namespaceObject.useActionContext)();
                                            return (0, index_js_namespaceObject.useRequest)(()=>Promise.resolve({
                                                    data: {
                                                        name: "r_".concat((0, schema_namespaceObject.uid)()),
                                                        snippets: [
                                                            '!ui.*',
                                                            '!pm',
                                                            '!pm.*'
                                                        ]
                                                    }
                                                }), {
                                                ...options,
                                                refreshDeps: [
                                                    ctx.visible
                                                ]
                                            });
                                        }
                                    },
                                    title: '{{t("Add role")}}',
                                    properties: {
                                        title: {
                                            'x-component': 'CollectionField',
                                            'x-decorator': 'FormItem'
                                        },
                                        name: {
                                            'x-component': 'CollectionField',
                                            'x-decorator': 'FormItem',
                                            description: '{{t("Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.")}}'
                                        },
                                        default: {
                                            'x-component': 'CollectionField',
                                            'x-decorator': 'FormItem',
                                            title: '',
                                            'x-content': '{{t("Default role")}}'
                                        },
                                        footer: {
                                            type: 'void',
                                            'x-component': 'Action.Drawer.Footer',
                                            properties: {
                                                cancel: {
                                                    title: '{{t("Cancel")}}',
                                                    'x-component': 'Action',
                                                    'x-component-props': {
                                                        useAction: '{{ cm.useCancelAction }}'
                                                    }
                                                },
                                                submit: {
                                                    title: '{{t("Submit")}}',
                                                    'x-component': 'Action',
                                                    'x-component-props': {
                                                        type: 'primary',
                                                        useAction: '{{ cm.useCreateAction }}'
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                table: {
                    type: 'void',
                    'x-uid': 'input',
                    'x-component': 'Table.Void',
                    'x-component-props': {
                        rowKey: 'name',
                        rowSelection: {
                            type: 'checkbox'
                        },
                        useDataSource: '{{ cm.useDataSourceFromRAC }}'
                    },
                    properties: {
                        column1: {
                            type: 'void',
                            'x-decorator': 'Table.Column.Decorator',
                            'x-component': 'Table.Column',
                            properties: {
                                title: {
                                    type: 'number',
                                    'x-component': 'CollectionField',
                                    'x-read-pretty': true
                                }
                            }
                        },
                        column2: {
                            type: 'void',
                            'x-decorator': 'Table.Column.Decorator',
                            'x-component': 'Table.Column',
                            properties: {
                                name: {
                                    type: 'string',
                                    'x-component': 'CollectionField',
                                    'x-read-pretty': true
                                }
                            }
                        },
                        column3: {
                            type: 'void',
                            'x-decorator': 'Table.Column.Decorator',
                            'x-component': 'Table.Column',
                            properties: {
                                default: {
                                    type: 'string',
                                    'x-component': 'CollectionField',
                                    'x-read-pretty': true
                                }
                            }
                        },
                        column4: {
                            type: 'void',
                            title: '{{t("Actions")}}',
                            'x-component': 'Table.Column',
                            properties: {
                                actions: {
                                    type: 'void',
                                    'x-component': 'Space',
                                    'x-component-props': {
                                        split: '|'
                                    },
                                    properties: {
                                        view: {
                                            type: 'void',
                                            title: '{{t("Configure")}}',
                                            'x-component': 'Action.Link',
                                            'x-decorator': 'ACLActionProvider',
                                            'x-acl-action': 'roles:update',
                                            'x-component-props': {},
                                            properties: {
                                                drawer: {
                                                    type: 'void',
                                                    'x-component': 'Action.Drawer',
                                                    'x-decorator': 'PermissionProvider',
                                                    title: '{{t("Configure permissions")}}',
                                                    properties: {
                                                        tabs1: {
                                                            type: 'void',
                                                            'x-component': 'Tabs',
                                                            'x-component-props': {},
                                                            properties: {
                                                                tab1: {
                                                                    type: 'void',
                                                                    title: '{{t("General permissions")}}',
                                                                    'x-component': 'Tabs.TabPane',
                                                                    'x-component-props': {},
                                                                    properties: {
                                                                        role: {
                                                                            'x-component': 'RoleConfigure'
                                                                        }
                                                                    }
                                                                },
                                                                tab3: {
                                                                    type: 'void',
                                                                    title: '{{t("Menu permissions")}}',
                                                                    'x-component': 'Tabs.TabPane',
                                                                    'x-component-props': {},
                                                                    properties: {
                                                                        menu: {
                                                                            'x-decorator': 'MenuItemsProvider',
                                                                            'x-component': 'MenuConfigure'
                                                                        }
                                                                    }
                                                                },
                                                                tab4: {
                                                                    type: 'void',
                                                                    title: '{{t("Plugin settings permissions")}}',
                                                                    'x-decorator': 'SettingCenterPermissionProvider',
                                                                    'x-component': 'Tabs.TabPane',
                                                                    'x-component-props': {},
                                                                    properties: {
                                                                        menu: {
                                                                            'x-decorator': 'SettingCenterProvider',
                                                                            'x-component': 'SettingsCenterConfigure'
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        },
                                        update: {
                                            type: 'void',
                                            title: '{{t("Edit")}}',
                                            'x-decorator': 'ACLActionProvider',
                                            'x-acl-action': 'roles:update',
                                            'x-component': 'Action.Link',
                                            'x-component-props': {
                                                type: 'primary'
                                            },
                                            properties: {
                                                drawer: {
                                                    type: 'void',
                                                    'x-component': 'Action.Drawer',
                                                    'x-decorator': 'Form',
                                                    'x-decorator-props': {
                                                        useValues: (options)=>{
                                                            const record = (0, external_record_provider_index_js_namespaceObject.useRecord)();
                                                            const result = (0, index_js_namespaceObject.useRequest)(()=>Promise.resolve({
                                                                    data: pick_default()(record, [
                                                                        'title',
                                                                        'name',
                                                                        'default'
                                                                    ])
                                                                }), {
                                                                ...options,
                                                                manual: true
                                                            });
                                                            const ctx = (0, external_schema_component_index_js_namespaceObject.useActionContext)();
                                                            (0, external_react_namespaceObject.useEffect)(()=>{
                                                                if (ctx.visible) result.run();
                                                            }, [
                                                                ctx.visible
                                                            ]);
                                                            return result;
                                                        }
                                                    },
                                                    title: '{{t("Edit role")}}',
                                                    properties: {
                                                        title: {
                                                            'x-component': 'CollectionField',
                                                            'x-decorator': 'FormItem'
                                                        },
                                                        name: {
                                                            'x-component': 'CollectionField',
                                                            'x-decorator': 'FormItem',
                                                            'x-disabled': true
                                                        },
                                                        default: {
                                                            title: '',
                                                            'x-component': 'CollectionField',
                                                            'x-decorator': 'FormItem',
                                                            'x-content': '{{t("Default role")}}'
                                                        },
                                                        footer: {
                                                            type: 'void',
                                                            'x-component': 'Action.Drawer.Footer',
                                                            properties: {
                                                                cancel: {
                                                                    title: '{{t("Cancel")}}',
                                                                    'x-component': 'Action',
                                                                    'x-component-props': {
                                                                        useAction: '{{ cm.useCancelAction }}'
                                                                    }
                                                                },
                                                                submit: {
                                                                    title: '{{t("Submit")}}',
                                                                    'x-component': 'Action',
                                                                    'x-component-props': {
                                                                        type: 'primary',
                                                                        useAction: '{{ cm.useUpdateAction }}'
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        },
                                        delete: {
                                            type: 'void',
                                            title: '{{ t("Delete") }}',
                                            'x-acl-action': 'roles:destroy',
                                            'x-decorator': 'ACLActionProvider',
                                            'x-component': 'Action.Link',
                                            'x-component-props': {
                                                confirm: {
                                                    title: "{{t('Delete role')}}",
                                                    content: "{{t('Are you sure you want to delete it?')}}"
                                                },
                                                useAction: '{{cm.useDestroyAction}}'
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
};
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
});
