import { AXPWidgetsList } from '@acorex/modules/common';
import { createAllQueryView } from '@acorex/platform/common';
import { entityMasterCrudActions, entityMasterRecordActions } from '@acorex/platform/layout/entity';
import { AXPWidgetsCatalog } from '@acorex/platform/layout/widget-core';
import { RootConfig } from './acorex-modules-workflow-management.mjs';

async function factory() {
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.activityDefinition.name,
        title: RootConfig.entities.activityDefinition.title,
        icon: RootConfig.entities.activityDefinition.icon,
        formats: {
            individual: RootConfig.entities.activityDefinition.title,
            plural: RootConfig.entities.activityDefinition.titlePlural,
            displayName: '{{ title || name }}',
            searchResult: {
                title: '{{ title || name }}',
                description: '{{ description }}',
            },
        },
        plugins: [
            { name: 'history' },
            { name: 'category', options: { appearance: { icon: true, color: true }, metaData: { enabled: true } } },
        ],
        groups: [
            { id: 'basic-info', title: '@general:terms.interface.basic-info' },
            { id: 'configuration', title: '@general:terms.interface.configuration' },
        ],
        properties: [
            {
                name: 'name',
                title: '@general:terms.common.name',
                groupId: 'basic-info',
                schema: {
                    dataType: 'string',
                    interface: { type: AXPWidgetsCatalog.text },
                },
                options: { sort: { enabled: true }, filter: { advance: { enabled: true }, inline: { enabled: true } } },
                validations: [{ rule: 'required' }, { rule: 'unique' }],
            },
            {
                name: 'id',
                title: 'ID',
                groupId: 'basic-info',
                schema: { dataType: 'string', visible: false, nullable: false, readonly: true, unique: { enabled: true } },
            },
            {
                name: 'type',
                title: '@general:terms.common.type',
                groupId: 'basic-info',
                schema: {
                    dataType: 'string',
                    interface: { type: AXPWidgetsCatalog.text },
                },
                options: { sort: { enabled: true }, filter: { advance: { enabled: true }, inline: { enabled: true } } },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'title',
                title: '@general:terms.common.title',
                groupId: 'basic-info',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } },
                options: { sort: { enabled: true }, filter: { advance: { enabled: true }, inline: { enabled: true } } },
            },
            {
                name: 'description',
                title: '@general:terms.common.description',
                groupId: 'basic-info',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.largeText, options: { rows: 3 } } },
            },
            {
                name: 'category',
                title: '@general:terms.classification.category',
                groupId: 'configuration',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.EntityCategory,
                        options: {
                            entity: `${RootConfig.module.name}.ActivityDefinitionCategory`,
                            multiple: false,
                            textField: 'title',
                            valueField: 'id',
                            parentKey: 'parentId',
                        },
                    },
                },
                options: { filter: { advance: { enabled: true }, inline: { enabled: true } } },
            },
            {
                name: 'executionMode',
                title: '@workflow-management:activities.entities.activity-definition.fields.execution-mode.title',
                groupId: 'configuration',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.select,
                        options: {
                            valueField: 'value',
                            textField: 'text',
                            dataSource: [
                                { value: 'frontend', text: 'Frontend' },
                                { value: 'backend', text: 'Backend' },
                                { value: 'both', text: 'Both' },
                            ],
                        },
                    },
                },
                options: { filter: { inline: { enabled: true } } },
            },
            {
                name: 'taskType',
                title: '@workflow-management:activities.entities.activity-definition.fields.task-type.title',
                groupId: 'configuration',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.select,
                        options: {
                            valueField: 'value',
                            textField: 'text',
                            dataSource: [
                                { value: 'human-task', text: 'Human Task' },
                                { value: 'ui-activity', text: 'UI Activity' },
                                { value: 'system-activity', text: 'System Activity' },
                            ],
                        },
                    },
                },
                options: { filter: { inline: { enabled: true } } },
            },
            {
                name: 'icon',
                title: '@general:terms.common.icon',
                groupId: 'configuration',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } },
            },
            {
                name: 'isBrowsable',
                title: '@workflow-management:activities.entities.activity-definition.fields.is-browsable.title',
                groupId: 'configuration',
                schema: { dataType: 'boolean', interface: { type: AXPWidgetsCatalog.toggle } },
                options: { filter: { inline: { enabled: true } } },
            },
            {
                name: 'isContainer',
                title: '@workflow-management:activities.entities.activity-definition.fields.is-container.title',
                groupId: 'configuration',
                schema: { dataType: 'boolean', interface: { type: AXPWidgetsCatalog.toggle } },
                options: { filter: { inline: { enabled: true } } },
            },
            {
                name: 'outcomes',
                title: '@workflow-management:activities.entities.activity-definition.fields.outcomes.title',
                groupId: 'configuration',
                schema: {
                    dataType: 'array',
                    interface: { type: AXPWidgetsList.Advanced.CodeEditor, options: { language: 'json' } },
                },
            },
            {
                name: 'inputs',
                title: '@workflow-management:activities.entities.activity-definition.fields.inputs.title',
                groupId: 'configuration',
                schema: {
                    dataType: 'array',
                    interface: { type: AXPWidgetsList.Advanced.CodeEditor, options: { language: 'json' } },
                },
            },
            {
                name: 'outputs',
                title: '@workflow-management:activities.entities.activity-definition.fields.outputs.title',
                groupId: 'configuration',
                schema: {
                    dataType: 'array',
                    interface: { type: AXPWidgetsList.Advanced.CodeEditor, options: { language: 'json' } },
                },
            },
        ],
        columns: [
            { name: 'title', title: '@general:terms.common.title', showAs: { type: AXPWidgetsCatalog.text } },
            { name: 'name', title: '@general:terms.common.name', showAs: { type: AXPWidgetsCatalog.text } },
            { name: 'type', title: '@general:terms.common.type', showAs: { type: AXPWidgetsCatalog.text } },
            { name: 'executionMode', title: '@workflow-management:activities.entities.activity-definition.fields.execution-mode.title' },
            { name: 'taskType', title: '@workflow-management:activities.entities.activity-definition.fields.task-type.title' },
            { name: 'category', title: '@general:terms.classification.category' },
        ],
        interfaces: {
            master: {
                create: {
                    sections: [{ id: 'basic-info' }, { id: 'configuration' }],
                    properties: [
                        { name: 'name', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'type', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'title', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'category', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'executionMode', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'taskType', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'isBrowsable', layout: { positions: { lg: { colSpan: 3 } } } },
                        { name: 'isContainer', layout: { positions: { lg: { colSpan: 3 } } } },
                        { name: 'icon', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12 } } } },
                        { name: 'inputs', layout: { positions: { lg: { colSpan: 12 } } } },
                        { name: 'outputs', layout: { positions: { lg: { colSpan: 12 } } } },
                        { name: 'outcomes', layout: { positions: { lg: { colSpan: 12 } } } },
                    ],
                },
                update: {
                    sections: [{ id: 'basic-info' }, { id: 'configuration' }],
                    properties: [
                        { name: 'name', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'type', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'title', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'category', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'executionMode', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'taskType', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'isBrowsable', layout: { positions: { lg: { colSpan: 3 } } } },
                        { name: 'isContainer', layout: { positions: { lg: { colSpan: 3 } } } },
                        { name: 'icon', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12 } } } },
                        { name: 'inputs', layout: { positions: { lg: { colSpan: 12 } } } },
                        { name: 'outputs', layout: { positions: { lg: { colSpan: 12 } } } },
                        { name: 'outcomes', layout: { positions: { lg: { colSpan: 12 } } } },
                    ],
                },
                single: {
                    title: '{{ title || name }}',
                    sections: [{ id: 'basic-info' }, { id: 'configuration' }],
                    properties: [
                        { name: 'name', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'type', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'title', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'category', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'executionMode', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'taskType', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'isBrowsable', layout: { positions: { lg: { colSpan: 3 } } } },
                        { name: 'isContainer', layout: { positions: { lg: { colSpan: 3 } } } },
                        { name: 'icon', layout: { positions: { lg: { colSpan: 6 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12 } } } },
                        { name: 'inputs', layout: { positions: { lg: { colSpan: 12 } } } },
                        { name: 'outputs', layout: { positions: { lg: { colSpan: 12 } } } },
                        { name: 'outcomes', layout: { positions: { lg: { colSpan: 12 } } } },
                    ],
                    actions: [...entityMasterRecordActions()],
                },
                list: {
                    actions: [...entityMasterCrudActions()],
                    views: [createAllQueryView({ sorts: [{ name: 'name', dir: 'asc' }] })],
                },
            },
        },
    };
    return entityDef;
}

export { factory };
//# sourceMappingURL=acorex-modules-workflow-management-activity-definition.entity-BbBEPTBa.mjs.map
