import { createAllQueryView, AXPEntityQueryType } from '@acorex/platform/common';
import { AXPWidgetsCatalog } from '@acorex/platform/layout/widget-core';
import { a as AXMCustomerManagementCustomerTypeEntityService, R as RootConfig } from './acorex-modules-customer-management-acorex-modules-customer-management-DJHmt24j.mjs';
import { entityMasterCrudActions, entityMasterDeleteAction } from '@acorex/platform/layout/entity';

async function customerTypeFactory(injector) {
    const dataService = injector.get(AXMCustomerManagementCustomerTypeEntityService);
    const i18n = RootConfig.config.i18n;
    const entityName = 'customer-type';
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.customerType.name,
        title: RootConfig.entities.customerType.title,
        icon: RootConfig.entities.customerType.icon,
        formats: {
            individual: `@${i18n}:${entityName}.individual-title`,
            plural: `@${i18n}:${entityName}.plural-title`,
            searchResult: { title: '{{ title }}', description: RootConfig.module.title },
        },
        groups: [
            { id: 'basic-info', title: `@${i18n}:${entityName}.basic-info` },
            { id: 'settings', title: '@general:terms.interface.settings' },
        ],
        properties: [
            {
                name: 'title',
                title: `@${i18n}:${entityName}.title`,
                groupId: 'basic-info',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'description',
                title: `@${i18n}:${entityName}.description`,
                groupId: 'basic-info',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.largeText, options: { rows: 3 } } },
            },
            {
                name: 'isActive',
                title: '@general:terms.status.states.is-active',
                groupId: 'settings',
                schema: { dataType: 'boolean', interface: { type: AXPWidgetsCatalog.toggle } },
            },
        ],
        columns: [{ name: 'title' }, { name: 'description' }, { name: 'isActive' }],
        commands: {
            create: { execute: async (data) => ({ id: await dataService.insertOne(data) }) },
            delete: { execute: async (id) => await dataService.deleteOne(id) },
            update: { execute: async (data) => await dataService.updateOne(data.id, data) },
        },
        queries: {
            byKey: { execute: async (id) => await dataService.getOne(id), type: AXPEntityQueryType.Single },
            list: { execute: async (e) => await dataService.query(e), type: AXPEntityQueryType.List },
        },
        interfaces: {
            master: {
                create: {
                    sections: [{ id: 'basic-info' }, { id: 'settings' }],
                    properties: [
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 2 } } } },
                        { name: 'isActive', layout: { positions: { lg: { colSpan: 3, order: 3 } } } },
                    ],
                },
                update: {
                    sections: [{ id: 'basic-info' }, { id: 'settings' }],
                    properties: [
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 2 } } } },
                        { name: 'isActive', layout: { positions: { lg: { colSpan: 3, order: 3 } } } },
                    ],
                },
                single: {
                    title: '{{title}}',
                    sections: [{ id: 'basic-info', layout: { positions: { lg: { colSpan: 12 } } } }, { id: 'settings', layout: { positions: { lg: { colSpan: 12 } } } }],
                    properties: [
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 2 } } } },
                        { name: 'isActive', layout: { positions: { lg: { colSpan: 3, order: 3 } } } },
                    ],
                    actions: [entityMasterDeleteAction()],
                },
                list: {
                    actions: [...entityMasterCrudActions()],
                    views: [createAllQueryView({ sorts: [{ name: 'title', dir: 'asc' }] })],
                },
            },
        },
    };
    return entityDef;
}

export { customerTypeFactory };
//# sourceMappingURL=acorex-modules-customer-management-customer-type.entity-D3mT_QJr.mjs.map
