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

//#region ----   Imports   ----
//#endregion
//#region ----   Entity Factory   ----
async function emergencyServiceFactory(injector) {
    const i18n = RootConfig.config.i18n;
    const entity = RootConfig.entities.emergencyService;
    const sections = [
        { id: 'basic-info', layout: { positions: { lg: { colSpan: 12 } } } },
        { id: 'contact-info', layout: { positions: { lg: { colSpan: 12 } } } },
        { id: 'usage-guide', layout: { positions: { lg: { colSpan: 12 } } } },
    ];
    const propertyLayouts = [
        { name: 'title', layout: { positions: { lg: { colSpan: 12, order: 1 } } } },
        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 2 } } } },
        { name: 'countryId', layout: { positions: { lg: { colSpan: 6, order: 3 } } } },
        { name: 'availability', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
        { name: 'phoneNumber', layout: { positions: { lg: { colSpan: 6, order: 5 } } } },
        { name: 'alternateNumbers', layout: { positions: { lg: { colSpan: 6, order: 6 } } } },
        { name: 'textNumber', layout: { positions: { lg: { colSpan: 6, order: 7 } } } },
        { name: 'whenToCall', layout: { positions: { lg: { colSpan: 12, order: 8 } } } },
        { name: 'whenNotToCall', layout: { positions: { lg: { colSpan: 12, order: 9 } } } },
        { name: 'instructions', layout: { positions: { lg: { colSpan: 12, order: 10 } } } },
    ];
    const entityDef = {
        module: RootConfig.module.name,
        name: entity.name,
        title: entity.title,
        icon: entity.icon,
        formats: {
            individual: entity.title,
            plural: entity.titlePlural,
            searchResult: {
                title: '{{ title }}',
                description: `@${i18n}:emergency-services.entities.emergency-service.search-result-description`,
            },
        },
        plugins: [
            { name: 'history' },
            { name: 'compare' },
            { name: 'clone' },
            {
                name: 'category',
                options: {
                    appearance: { icon: true, color: true },
                },
            },
        ],
        groups: [
            { id: 'basic-info', title: `@${i18n}:emergency-services.entities.emergency-service.groups.basic-info` },
            { id: 'contact-info', title: `@${i18n}:emergency-services.entities.emergency-service.groups.contact-info` },
            { id: 'usage-guide', title: `@${i18n}:emergency-services.entities.emergency-service.groups.usage-guide` },
        ],
        properties: [
            {
                name: 'id',
                title: '@general:terms.common.id',
                groupId: 'basic-info',
                schema: {
                    dataType: 'uuid',
                    visible: false,
                    readonly: true,
                    unique: { enabled: true },
                },
            },
            {
                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: AXPWidgetsList.Editors.TextBox,
                        options: {
                            placeholder: `@${i18n}:emergency-services.entities.emergency-service.fields.title.placeholder`,
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'description',
                title: '@general:terms.common.description',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: false },
                    filter: { advance: { enabled: true }, inline: { enabled: false } },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LargeTextBox,
                        options: {
                            rows: 3,
                            placeholder: `@${i18n}:emergency-services.entities.emergency-service.fields.description.placeholder`,
                        },
                    },
                },
            },
            {
                name: 'countryId',
                title: `@${i18n}:emergency-services.entities.emergency-service.fields.country.title`,
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: { advance: { enabled: true }, inline: { enabled: true } },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LookupBox,
                        options: {
                            entity: 'LocationManagement.GeographicRegion',
                            textField: 'title',
                            valueField: 'id',
                            look: 'select',
                            expose: [
                                { source: 'id', target: 'country.id' },
                                { source: 'title', target: 'country.title' },
                            ],
                            filter: {
                                logic: 'and',
                                filters: [
                                    { field: 'type.code', operator: { type: 'equal' }, value: 'country' },
                                ],
                            },
                        },
                    },
                },
            },
            {
                name: 'availability',
                title: `@${i18n}:emergency-services.entities.emergency-service.fields.availability.title`,
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: { advance: { enabled: true }, inline: { enabled: true } },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.SelectBox,
                        options: {
                            valueField: 'value',
                            textField: 'title',
                            dataSource: 'availability-options',
                        },
                    },
                },
            },
            {
                name: 'phoneNumber',
                title: `@${i18n}:emergency-services.entities.emergency-service.fields.phone-number.title`,
                groupId: 'contact-info',
                options: {
                    sort: { enabled: true },
                    filter: { advance: { enabled: true }, inline: { enabled: true } },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.ContactBox,
                        options: {
                            type: 'phone',
                            hasLabel: false,
                            hasIcon: true,
                            placeholder: `@${i18n}:emergency-services.entities.emergency-service.fields.phone-number.placeholder`,
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'alternateNumbers',
                title: `@${i18n}:emergency-services.entities.emergency-service.fields.alternate-numbers.title`,
                groupId: 'contact-info',
                options: {
                    sort: { enabled: false },
                    filter: { advance: { enabled: true }, inline: { enabled: false } },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.ContactBox,
                        options: {
                            type: 'phone',
                            hasLabel: false,
                            hasIcon: true,
                            placeholder: `@${i18n}:emergency-services.entities.emergency-service.fields.alternate-numbers.placeholder`,
                        },
                    },
                },
            },
            {
                name: 'textNumber',
                title: `@${i18n}:emergency-services.entities.emergency-service.fields.text-number.title`,
                groupId: 'contact-info',
                options: {
                    sort: { enabled: true },
                    filter: { advance: { enabled: true }, inline: { enabled: true } },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.ContactBox,
                        options: {
                            type: 'phone',
                            hasIcon: true,
                            hasLabel: false,
                            placeholder: `@${i18n}:emergency-services.entities.emergency-service.fields.text-number.placeholder`,
                        },
                    },
                },
            },
            {
                name: 'whenToCall',
                title: `@${i18n}:emergency-services.entities.emergency-service.fields.when-to-call.title`,
                groupId: 'usage-guide',
                options: {
                    sort: { enabled: false },
                    filter: { advance: { enabled: true }, inline: { enabled: false } },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LargeTextBox,
                        options: {
                            rows: 4,
                            placeholder: `@${i18n}:emergency-services.entities.emergency-service.fields.when-to-call.placeholder`,
                        },
                    },
                },
            },
            {
                name: 'whenNotToCall',
                title: `@${i18n}:emergency-services.entities.emergency-service.fields.when-not-to-call.title`,
                groupId: 'usage-guide',
                options: {
                    sort: { enabled: false },
                    filter: { advance: { enabled: true }, inline: { enabled: false } },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LargeTextBox,
                        options: {
                            rows: 4,
                            placeholder: `@${i18n}:emergency-services.entities.emergency-service.fields.when-not-to-call.placeholder`,
                        },
                    },
                },
            },
            {
                name: 'instructions',
                title: `@${i18n}:emergency-services.entities.emergency-service.fields.instructions.title`,
                groupId: 'usage-guide',
                options: {
                    sort: { enabled: false },
                    filter: { advance: { enabled: true }, inline: { enabled: false } },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LargeTextBox,
                        options: {
                            rows: 6,
                            placeholder: `@${i18n}:emergency-services.entities.emergency-service.fields.instructions.placeholder`,
                        },
                    },
                },
            },
        ],
        columns: [
            { name: 'title', options: { width: '200px', order: 1 } },
            { name: 'phoneNumber', options: { width: '140px', order: 2 } },
            { name: 'countryId', options: { width: '140px', order: 3, dataPath: 'country.title' } },
            { name: 'availability', options: { width: '120px', order: 4 } },
        ],
        interfaces: {
            master: {
                create: {
                    sections,
                    properties: propertyLayouts,
                },
                update: {
                    sections,
                    properties: propertyLayouts,
                },
                single: {
                    title: '{{ title }}',
                    sections,
                    properties: propertyLayouts,
                    actions: [...entityMasterRecordActions()],
                },
                list: {
                    actions: [...entityMasterCrudActions()],
                    views: [
                        createAllQueryView({
                            sorts: [{ name: 'title', dir: 'asc' }],
                        }),
                    ],
                },
            },
        },
    };
    return entityDef;
}
//#endregion

export { emergencyServiceFactory };
//# sourceMappingURL=acorex-modules-contact-core-emergency-service.entity-l8rYNqP1.mjs.map
