import { AXTranslationService } from '@acorex/core/translation';
import { createAllQueryView, AXPEntityQueryType } from '@acorex/platform/common';
import { AXPWidgetsCatalog } from '@acorex/platform/layout/widget-core';
import { entityMasterCrudActions, entityMasterRecordActions } from '@acorex/platform/layout/entity';
import { d as AXMPartyIdentifierTypeService, R as RootConfig } from './acorex-modules-party-management-acorex-modules-party-management-BkRsPvsw.mjs';

//#region ----   Imports   ----
//#endregion
async function partyIdentifierTypeFactory(injector) {
    const dataService = injector.get(AXMPartyIdentifierTypeService);
    const i18n = RootConfig.config.i18n;
    const translateService = injector.get(AXTranslationService);
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.partyIdentifierType.name,
        title: RootConfig.entities.partyIdentifierType.title,
        icon: RootConfig.entities.partyIdentifierType.icon,
        formats: {
            individual: RootConfig.entities.partyIdentifierType.title,
            plural: RootConfig.entities.partyIdentifierType.titlePlural,
            searchResult: {
                title: RootConfig.entities.partyIdentifierType.title,
                description: '@party-management:party-identifier-type.search-result-description',
            },
        },
        groups: [
            {
                id: 'basic-info',
                title: '@general:terms.interface.basic-info',
            },
            {
                id: 'validation',
                title: '@general:terms.validation.validation',
            },
        ],
        properties: [
            {
                name: 'title',
                title: '@general:terms.common.title',
                groupId: 'basic-info',
                options: { sort: { enabled: true }, filter: { advance: { enabled: true }, inline: { enabled: true } } },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.text,
                    },
                },
                validations: [
                    {
                        rule: 'required',
                    },
                ],
            },
            {
                name: 'description',
                title: '@general:terms.common.description',
                groupId: 'basic-info',
                options: { sort: { enabled: true }, filter: { advance: { enabled: true }, inline: { enabled: true } } },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.largeText,
                        options: {
                            rows: 3,
                        },
                    },
                },
            },
            {
                name: 'scope',
                title: '@party-management:party-identifier-type.properties.scope.title',
                groupId: 'basic-info',
                options: { sort: { enabled: true }, filter: { advance: { enabled: true }, inline: { enabled: true } } },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.select,
                        options: {
                            valueField: 'value',
                            textField: 'text',
                            dataSource: [
                                {
                                    value: 'global',
                                    text: await translateService.translateAsync('@party-management:party-identifier-type.properties.scope.options.global'),
                                },
                                {
                                    value: 'national',
                                    text: await translateService.translateAsync('@party-management:party-identifier-type.properties.scope.options.national'),
                                },
                                {
                                    value: 'regional',
                                    text: await translateService.translateAsync('@party-management:party-identifier-type.properties.scope.options.regional'),
                                },
                            ],
                        },
                    },
                },
                validations: [
                    {
                        rule: 'required',
                    },
                ],
            },
            {
                name: 'formatRegex',
                title: '@general:terms.validation.regex',
                groupId: 'validation',
                options: {
                    sort: {
                        enabled: false,
                    },
                    filter: {
                        advance: {
                            enabled: true,
                        },
                        inline: {
                            enabled: false,
                        },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.text,
                    },
                },
            },
            {
                name: 'minLength',
                title: '@general:terms.validation.min-length',
                groupId: 'validation',
                options: {
                    sort: {
                        enabled: true,
                    },
                    filter: {
                        advance: {
                            enabled: true,
                        },
                        inline: {
                            enabled: false,
                        },
                    },
                },
                schema: {
                    dataType: 'number',
                    interface: {
                        type: AXPWidgetsCatalog.number,
                        options: {
                            minValue: 1,
                            maxValue: 100,
                        },
                    },
                },
            },
            {
                name: 'maxLength',
                title: '@general:terms.validation.max-length',
                groupId: 'validation',
                options: {
                    sort: {
                        enabled: true,
                    },
                    filter: {
                        advance: {
                            enabled: true,
                        },
                        inline: {
                            enabled: false,
                        },
                    },
                },
                schema: {
                    dataType: 'number',
                    interface: {
                        type: AXPWidgetsCatalog.number,
                        options: {
                            minValue: 1,
                            maxValue: 1000,
                        },
                    },
                },
            },
            {
                name: 'isUnique',
                title: '@general:terms.status.states.is-unique',
                groupId: 'validation',
                options: {
                    sort: {
                        enabled: true,
                    },
                    filter: {
                        advance: {
                            enabled: true,
                        },
                        inline: {
                            enabled: true,
                        },
                    },
                },
                schema: {
                    dataType: 'boolean',
                    interface: {
                        type: AXPWidgetsCatalog.toggle,
                    },
                },
            },
        ],
        columns: [{ name: 'title' }, { name: 'scope' }, { name: 'isActive' }],
        commands: {
            create: {
                execute: async (data) => {
                    const res = await dataService.insertOne(data);
                    return { id: res };
                },
            },
            delete: {
                execute: async (id) => {
                    return await dataService.deleteOne(id);
                },
            },
            update: {
                execute: async (data) => {
                    return await dataService.updateOne(data.id, data);
                },
            },
        },
        queries: {
            byKey: {
                execute: async (id) => {
                    return await dataService.getOne(id);
                },
                type: AXPEntityQueryType.Single,
            },
            list: {
                execute: async (e) => {
                    return await dataService.query(e);
                },
                type: AXPEntityQueryType.List,
            },
        },
        interfaces: {
            master: {
                create: {
                    sections: [
                        {
                            id: 'basic-info',
                        },
                        {
                            id: 'validation',
                        },
                    ],
                    properties: [
                        {
                            name: 'title',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                        order: 1,
                                    },
                                },
                            },
                        },
                        {
                            name: 'description',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                        order: 2,
                                    },
                                },
                            },
                        },
                        {
                            name: 'scope',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 3,
                                    },
                                },
                            },
                        },
                        {
                            name: 'formatRegex',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 4,
                                    },
                                },
                            },
                        },
                        {
                            name: 'minLength',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 3,
                                        order: 5,
                                    },
                                },
                            },
                        },
                        {
                            name: 'maxLength',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 3,
                                        order: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'isUnique',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 3,
                                        order: 7,
                                    },
                                },
                            },
                        },
                        {
                            name: 'isActive',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 3,
                                        order: 8,
                                    },
                                },
                            },
                        },
                    ],
                },
                update: {
                    sections: [
                        {
                            id: 'basic-info',
                        },
                        {
                            id: 'validation',
                        },
                    ],
                    properties: [
                        {
                            name: 'title',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 2,
                                    },
                                },
                            },
                        },
                        {
                            name: 'description',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                        order: 3,
                                    },
                                },
                            },
                        },
                        {
                            name: 'scope',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 4,
                                    },
                                },
                            },
                        },
                        {
                            name: 'formatRegex',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 5,
                                    },
                                },
                            },
                        },
                        {
                            name: 'minLength',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 3,
                                        order: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'maxLength',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 3,
                                        order: 7,
                                    },
                                },
                            },
                        },
                        {
                            name: 'isUnique',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 3,
                                        order: 8,
                                    },
                                },
                            },
                        },
                        {
                            name: 'isActive',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 3,
                                        order: 9,
                                    },
                                },
                            },
                        },
                    ],
                },
                single: {
                    title: '{{title}}',
                    sections: [
                        {
                            id: 'basic-info',
                        },
                        {
                            id: 'validation',
                        },
                    ],
                    properties: [
                        {
                            name: 'title',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 2,
                                    },
                                },
                            },
                        },
                        {
                            name: 'description',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                        order: 3,
                                    },
                                },
                            },
                        },
                        {
                            name: 'scope',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 4,
                                    },
                                },
                            },
                        },
                        {
                            name: 'formatRegex',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 5,
                                    },
                                },
                            },
                        },
                        {
                            name: 'minLength',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 3,
                                        order: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'maxLength',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 3,
                                        order: 7,
                                    },
                                },
                            },
                        },
                        {
                            name: 'isUnique',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 3,
                                        order: 8,
                                    },
                                },
                            },
                        },
                    ],
                    actions: [...entityMasterRecordActions()],
                },
                list: {
                    actions: [...entityMasterCrudActions()],
                    views: [
                        createAllQueryView({
                            sorts: [{ name: 'title', dir: 'asc' }],
                        }),
                    ],
                },
            },
        },
    };
    return entityDef;
}

export { partyIdentifierTypeFactory };
//# sourceMappingURL=acorex-modules-party-management-party-identifier-type.entity-UMIM9R7g.mjs.map
