import { AXP_PERMISSION_DEFINITION_PROVIDER } from '@acorex/platform/auth';
import { AXPSearchCommandProvider, createAllQueryView, createQueryView, AXPEntityCommandScope, AXPEntityQueryType, AXP_MENU_PROVIDER, AXP_SETTING_DEFINITION_PROVIDER, AXP_SEARCH_PROVIDER } from '@acorex/platform/common';
import { AXPEntityService, AXMEntityCrudServiceImpl, AXP_ENTITY_DEFINITION_LOADER } from '@acorex/platform/layout/entity';
import * as i0 from '@angular/core';
import { inject, Injector, Injectable, NgModule } from '@angular/core';
import { AXPWidgetsCatalog } from '@acorex/platform/layout/widget-core';
import { AXTranslationService } from '@acorex/core/translation';

const config = {
    i18n: 'log-management',
};
const RootConfig = {
    config,
    module: {
        route: 'log-management',
        module: 'log-management',
        name: 'log-management',
        title: `t('module-name', {scope:"${config.i18n}"})`,
        icon: 'fa-light fa-monitor-waveform',
    },
    entities: {
        axpLog: {
            name: 'Log',
            title: `t("log",{scope:"${config.i18n}"})`,
            titlePlural: `t("logs",{scope:"${config.i18n}"})`,
            icon: 'fa-light fa-file-code'
        }
    },
};

class AXMEntityProvider {
    constructor() {
        this.injector = inject(Injector);
    }
    preload() {
        const module = RootConfig.module.name;
        return Array.from(Object.values(RootConfig.entities)).map((entity) => ({
            module: module,
            entity: entity.name,
        }));
    }
    async get(moduleName, entityName) {
        if (moduleName == RootConfig.module.name) {
            switch (entityName
            // case RootConfig.entities.sample.name:
            //   return (await import('./entities/sample/sample.entity')).factory(this.injector);
            ) {
                case RootConfig.entities.axpLog.name:
                    return (await Promise.resolve().then(function () { return axpLog_entity; })).axpLogFactory(this.injector);
            }
        }
        return null;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMEntityProvider, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMEntityProvider }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMEntityProvider, decorators: [{
            type: Injectable
        }] });

class AXMMenuProvider {
    constructor() {
        this.entityService = inject(AXPEntityService);
    }
    async provide(context) {
        const scope = RootConfig.config.i18n;
        const module = RootConfig.module;
        // context.addItems([
        //   {
        //     priority: 9005,
        //     text: `t('root-menu', {scope:"${scope}"})`,
        //     icon: module.icon,
        //     data: {
        //       // requiredPermission: ['forms:management'],
        //     },
        //     children: [
        //       {
        //         text: `t("logs", {scope: "${scope}"})`,
        //         path: this.entityService.createPath(module.name, RootConfig.entities.axpLog.name),
        //         icon: RootConfig.entities.axpLog.icon,
        //         priority: 1,
        //         data: {
        //           // requiredPermission: ['forms:categories:edit'],
        //         },
        //       }
        //     ],
        //   },
        // ]);
        // context.addItems([
        //   {
        //     priority: 9001,
        //     text: `t('module-name', {scope:"${scope}"})`,
        //     icon: module.icon,
        //     children: [
        //       {
        //         text: `t("entity-name", { scope: "common" })`,
        //         path: this.entityService.createPath(module.name, RootConfig.entities.category.name),
        //         icon: RootConfig.entities.category.icon,
        //         priority: 1,
        //       }
        //     ],
        //   },
        // ]);
    }
}

class AXMPermissionDefinitionProvider {
    async define(context) {
        // context.addPermissions([
        //   {
        //     name: 'view_templates',
        //     title: 'Permission to view templates',
        //     isArchived: false,
        //   },
        // ]);
    }
}

class AXMSearchCommandProvider extends AXPSearchCommandProvider {
    constructor() {
        super(...arguments);
        this.commands = [
        // {
        //   group: 'command',
        //  title: 'New Form Template',
        //  icon: RootConfig.entities.template.icon,
        //  description: 'Create a new form template for designing reusable forms.', // Added description
        //  commands: {
        //    'create-entity': {
        //      entity: `${RootConfig.module.name}.${RootConfig.entities.template.name}`,
        //    },
        //  },
        // }
        ];
    }
}

class AXMAxpLogService extends AXMEntityCrudServiceImpl {
}
class AXMAxpLogServiceImpl extends AXMAxpLogService {
    constructor() {
        super(`${RootConfig.module.name}.${RootConfig.entities.axpLog.name}`);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMAxpLogServiceImpl, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMAxpLogServiceImpl }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMAxpLogServiceImpl, decorators: [{
            type: Injectable
        }], ctorParameters: () => [] });

async function axpLogFactory(injector) {
    const dataService = injector.get(AXMAxpLogService);
    const i18n = RootConfig.config.i18n;
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.axpLog.name,
        title: RootConfig.entities.axpLog.title,
        icon: RootConfig.entities.axpLog.icon,
        formats: {
            individual: RootConfig.entities.axpLog.title,
            plural: RootConfig.entities.axpLog.titlePlural,
            searchResult: {
                title: '{{ applicationName }}',
                description: RootConfig.module.title,
            },
        },
        relatedEntities: [],
        groups: [
            { id: 'general', title: `@${i18n}:general` },
            { id: 'user', title: `@${i18n}:user` },
            { id: 'client', title: `@${i18n}:client` },
            { id: 'impersonator', title: `@${i18n}:impersonator` },
            { id: 'actions', title: `@${i18n}:actions` },
            { id: 'entityChanges', title: `@${i18n}:entityChanges` },
            { id: 'extra', title: `@${i18n}:extra` },
        ],
        properties: [
            // General
            {
                name: 'id',
                title: `@${i18n}:id`,
                groupId: 'general',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } },
            },
            {
                name: 'applicationName',
                title: `@${i18n}:applicationName`,
                groupId: 'general',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } },
            },
            {
                name: 'executionTime',
                title: `@${i18n}:executionTime`,
                groupId: 'general',
                schema: { dataType: 'date', interface: { type: AXPWidgetsCatalog.dateTime } },
            },
            {
                name: 'executionDuration',
                title: `@${i18n}:executionDuration`,
                groupId: 'general',
                schema: { dataType: 'number', interface: { type: AXPWidgetsCatalog.number } },
            },
            {
                name: 'comments',
                title: `@${i18n}:comments`,
                groupId: 'general',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } },
            },
            // User
            {
                name: 'tenantId',
                title: `@${i18n}:tenantId`,
                groupId: 'user',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } },
            },
            {
                name: 'tenantName',
                title: `@${i18n}:tenantName`,
                groupId: 'user',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } },
            },
            {
                name: 'userId',
                title: `@${i18n}:userId`,
                groupId: 'user',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } },
            },
            {
                name: 'userName',
                title: `@${i18n}:userName`,
                groupId: 'user',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } },
            },
            // Client
            {
                name: 'clientIpAddress',
                title: `@${i18n}:clientIpAddress`,
                groupId: 'client',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } },
            },
            {
                name: 'clientName',
                title: `@${i18n}:clientName`,
                groupId: 'client',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } },
            },
            {
                name: 'clientId',
                title: `@${i18n}:clientId`,
                groupId: 'client',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } },
            },
            {
                name: 'browserInfo',
                title: `@${i18n}:browserInfo`,
                groupId: 'client',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } },
            },
            {
                name: 'httpMethod',
                title: `@${i18n}:httpMethod`,
                groupId: 'client',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } },
            },
            {
                name: 'url',
                title: `@${i18n}:url`,
                groupId: 'client',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } },
            },
            {
                name: 'httpStatusCode',
                title: `@${i18n}:httpStatusCode`,
                groupId: 'client',
                schema: { dataType: 'number', interface: { type: AXPWidgetsCatalog.number } },
            },
            {
                name: 'httpStatus',
                title: `@${i18n}:httpStatus`,
                groupId: 'client',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } },
            },
            // Correlation
            {
                name: 'correlationId',
                title: `@${i18n}:correlationId`,
                groupId: 'general',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } },
            },
            // Exception
            {
                name: 'exceptions',
                title: `@${i18n}:exceptions`,
                groupId: 'general',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } },
            },
            // Impersonator
            {
                name: 'impersonatorUserId',
                title: `@${i18n}:impersonatorUserId`,
                groupId: 'impersonator',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } },
            },
            {
                name: 'impersonatorUserName',
                title: `@${i18n}:impersonatorUserName`,
                groupId: 'impersonator',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } },
            },
            {
                name: 'impersonatorTenantId',
                title: `@${i18n}:impersonatorTenantId`,
                groupId: 'impersonator',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } },
            },
            {
                name: 'impersonatorTenantName',
                title: `@${i18n}:impersonatorTenantName`,
                groupId: 'impersonator',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } },
            },
            // Extra
            {
                name: 'extraProperties',
                title: `@${i18n}:extraProperties`,
                groupId: 'extra',
                schema: { dataType: 'object', interface: { type: AXPWidgetsCatalog.text } },
            },
            // Actions
            {
                name: 'actions',
                title: `@${i18n}:actions`,
                groupId: 'actions',
                schema: { dataType: 'array', interface: { type: AXPWidgetsCatalog.text } },
            },
            // EntityChanges
            {
                name: 'entityChanges',
                title: `@${i18n}:entityChanges`,
                groupId: 'entityChanges',
                schema: { dataType: 'array', interface: { type: AXPWidgetsCatalog.text } },
            },
        ],
        columns: [
            { name: 'applicationName' },
            { name: 'userName' },
            { name: 'executionTime' },
            { name: 'clientIpAddress' },
            { name: 'httpMethod' },
            { name: 'url' },
            { name: 'httpStatusCode' },
            { name: 'httpStatus' },
        ],
        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: 'section',
                        },
                    ],
                    properties: [
                        {
                            name: 'id',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 1,
                                    },
                                },
                            },
                        },
                        {
                            name: 'applicationName',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 3,
                                        order: 2,
                                    },
                                },
                            },
                        },
                        {
                            name: 'executionTime',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 3,
                                    },
                                },
                            },
                        },
                        {
                            name: 'executionDuration',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 4,
                                    },
                                },
                            },
                        },
                        {
                            name: 'comments',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 3,
                                        order: 5,
                                    },
                                },
                            },
                        },
                        {
                            name: 'tenantId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'tenantName',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 7,
                                    },
                                },
                            },
                        },
                        {
                            name: 'userId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 8,
                                    },
                                },
                            },
                        },
                        {
                            name: 'userName',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 9,
                                    },
                                },
                            },
                        },
                        {
                            name: 'clientIpAddress',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 10,
                                    },
                                },
                            },
                        },
                        {
                            name: 'clientName',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 11,
                                    },
                                },
                            },
                        },
                        {
                            name: 'clientId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 12,
                                    },
                                },
                            },
                        },
                        {
                            name: 'browserInfo',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 13,
                                    },
                                },
                            },
                        },
                        {
                            name: 'httpMethod',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 14,
                                    },
                                },
                            },
                        },
                        {
                            name: 'url',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 15,
                                    },
                                },
                            },
                        },
                        {
                            name: 'httpStatusCode',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 16,
                                    },
                                },
                            },
                        },
                        {
                            name: 'httpStatus',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 17,
                                    },
                                },
                            },
                        },
                        {
                            name: 'correlationId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 18,
                                    },
                                },
                            },
                        },
                        {
                            name: 'exceptions',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 19,
                                    },
                                },
                            },
                        },
                        {
                            name: 'impersonatorUserId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 20,
                                    },
                                },
                            },
                        },
                        {
                            name: 'impersonatorUserName',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 21,
                                    },
                                },
                            },
                        },
                        {
                            name: 'impersonatorTenantId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 22,
                                    },
                                },
                            },
                        },
                        {
                            name: 'impersonatorTenantName',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 23,
                                    },
                                },
                            },
                        },
                        {
                            name: 'extraProperties',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 24,
                                    },
                                },
                            },
                        },
                        {
                            name: 'actions',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 25,
                                    },
                                },
                            },
                        },
                        {
                            name: 'entityChanges',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 2,
                                        order: 26,
                                    },
                                },
                            },
                        },
                    ],
                },
                // update: {
                //   sections: [
                //     {
                //       id: 'section',
                //     },
                //   ],
                //   properties: [
                //     {
                //       name: 'utcTimestamp',
                //       layout: {
                //         positions: {
                //           lg: {
                //             colSpan: 2,
                //             order: 1,
                //           },
                //         },
                //       },
                //     },
                //     {
                //       name: 'message',
                //       layout: {
                //         positions: {
                //           lg: {
                //             colSpan: 3,
                //             order: 2,
                //           },
                //         },
                //       },
                //     },
                //     {
                //       name: 'level',
                //       layout: {
                //         positions: {
                //           lg: {
                //             colSpan: 2,
                //             order: 3,
                //           },
                //         },
                //       },
                //     },
                //     {
                //       name: 'properties',
                //       layout: {
                //         positions: {
                //           lg: {
                //             colSpan: 3,
                //             order: 4,
                //           },
                //         },
                //       },
                //     },
                //   ],
                // },
                single: {
                    title: `@${i18n}:logDetails`,
                    sections: [
                        {
                            id: 'general',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            id: 'user',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            id: 'client',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            id: 'impersonator',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            id: 'actions',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            id: 'entityChanges',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            id: 'extra',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                    ],
                    properties: [
                        {
                            name: 'id',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'applicationName',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'executionTime',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'executionDuration',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'comments',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'tenantId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'tenantName',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'userId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'userName',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'clientIpAddress',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'clientName',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'clientId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'browserInfo',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'httpMethod',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'url',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'httpStatusCode',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'httpStatus',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'correlationId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'exceptions',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'impersonatorUserId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'impersonatorUserName',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'impersonatorTenantId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'impersonatorTenantName',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'extraProperties',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'actions',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'entityChanges',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                    ],
                    actions: [],
                },
                list: {
                    actions: [
                        // {
                        //   title: `t("create", { scope: "common" })`,
                        //   command: 'create-entity',
                        //   priority: 'primary',
                        //   type: 'create',
                        //   scope: AXPEntityCommandScope.TypeLevel,
                        // },
                        // {
                        //   title: 't("deleteItems", { scope: "common" })',
                        //   command: 'delete-entity',
                        //   priority: 'primary',
                        //   type: 'delete',
                        //   scope: AXPEntityCommandScope.Selected,
                        // },
                        {
                            title: '@general:actions.detail.title',
                            command: 'open-entity',
                            priority: 'secondary',
                            type: 'view',
                            scope: AXPEntityCommandScope.Individual,
                        },
                        // {
                        //   title: 't("delete", { scope: "common" })',
                        //   command: 'delete-entity',
                        //   priority: 'secondary',
                        //   type: 'delete',
                        //   scope: AXPEntityCommandScope.Individual,
                        // },
                    ],
                    views: [
                        createAllQueryView({
                            sorts: [{ name: 'applicationName', dir: 'asc' }],
                        }),
                        createQueryView('Auth Logs', `t("authLogs", { scope: "${i18n}" })`, true, {
                            conditions: [
                                {
                                    name: 'type',
                                    operator: {
                                        type: 'equal',
                                    },
                                    value: 'auth',
                                },
                            ],
                        }),
                    ],
                },
            },
        },
    };
    return entityDef;
}

var axpLog_entity = /*#__PURE__*/Object.freeze({
    __proto__: null,
    axpLogFactory: axpLogFactory
});

class AXMAxpLogEntityModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMAxpLogEntityModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.4", ngImport: i0, type: AXMAxpLogEntityModule }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMAxpLogEntityModule, providers: [
            {
                provide: AXMAxpLogService,
                useClass: AXMAxpLogServiceImpl,
            },
        ] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMAxpLogEntityModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [],
                    exports: [],
                    declarations: [],
                    providers: [
                        {
                            provide: AXMAxpLogService,
                            useClass: AXMAxpLogServiceImpl,
                        },
                    ],
                }]
        }] });

// Entity Services

class AXMLogManagementModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMLogManagementModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.4", ngImport: i0, type: AXMLogManagementModule, imports: [
            // Entity Modules
            AXMAxpLogEntityModule] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMLogManagementModule, providers: [
            {
                provide: AXP_MENU_PROVIDER,
                useClass: AXMMenuProvider,
                multi: true,
            },
            {
                provide: AXP_ENTITY_DEFINITION_LOADER,
                useClass: AXMEntityProvider,
                multi: true,
            },
            {
                provide: AXP_SETTING_DEFINITION_PROVIDER,
                useFactory: async () => {
                    const injector = inject(Injector);
                    const provider = (await Promise.resolve().then(function () { return settings_provider; })).AXPLogManagementSettingProvider;
                    return new provider(injector);
                },
                multi: true,
            },
            {
                provide: AXP_SEARCH_PROVIDER,
                useClass: AXMSearchCommandProvider,
                multi: true,
            },
            {
                provide: AXP_PERMISSION_DEFINITION_PROVIDER,
                useClass: AXMPermissionDefinitionProvider,
                multi: true,
            },
        ], imports: [
            // Entity Modules
            AXMAxpLogEntityModule] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMLogManagementModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [
                        // Entity Modules
                        AXMAxpLogEntityModule,
                    ],
                    exports: [],
                    declarations: [],
                    providers: [
                        {
                            provide: AXP_MENU_PROVIDER,
                            useClass: AXMMenuProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_ENTITY_DEFINITION_LOADER,
                            useClass: AXMEntityProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_SETTING_DEFINITION_PROVIDER,
                            useFactory: async () => {
                                const injector = inject(Injector);
                                const provider = (await Promise.resolve().then(function () { return settings_provider; })).AXPLogManagementSettingProvider;
                                return new provider(injector);
                            },
                            multi: true,
                        },
                        {
                            provide: AXP_SEARCH_PROVIDER,
                            useClass: AXMSearchCommandProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_PERMISSION_DEFINITION_PROVIDER,
                            useClass: AXMPermissionDefinitionProvider,
                            multi: true,
                        },
                    ],
                }]
        }] });

const path = 'log-management:';
var AXPLogManagementSettings;
(function (AXPLogManagementSettings) {
    // Retention settings
    AXPLogManagementSettings["RetentionPeriod"] = "log-management:retention:period";
    AXPLogManagementSettings["RetentionEnabled"] = "log-management:retention:enabled";
    // Storage settings
    AXPLogManagementSettings["StorageLocation"] = "log-management:storage:location";
    AXPLogManagementSettings["StorageFormat"] = "log-management:storage:format";
    AXPLogManagementSettings["MaxFileSize"] = "log-management:storage:max-file-size";
    AXPLogManagementSettings["CompressionEnabled"] = "log-management:storage:compression-enabled";
    // Log level settings
    AXPLogManagementSettings["DefaultLogLevel"] = "log-management:level:default";
    AXPLogManagementSettings["ModuleLogLevels"] = "log-management:level:modules";
    // Notification settings
    AXPLogManagementSettings["AlertEnabled"] = "log-management:alert:enabled";
    AXPLogManagementSettings["AlertLogLevel"] = "log-management:alert:level";
    AXPLogManagementSettings["AlertEmail"] = "log-management:alert:email";
    // Performance settings
    AXPLogManagementSettings["BatchSize"] = "log-management:performance:batch-size";
    AXPLogManagementSettings["FlushInterval"] = "log-management:performance:flush-interval";
    AXPLogManagementSettings["AsyncLogging"] = "log-management:performance:async-enabled";
})(AXPLogManagementSettings || (AXPLogManagementSettings = {}));

/**
 * Settings provider for the Log Management module.
 * Implements configuration options for log retention, storage, levels, alerts, and performance.
 */
class AXPLogManagementSettingProvider {
    constructor(injector) {
        this.injector = injector;
        this.translateService = this.injector.get(AXTranslationService);
    }
    async provide(context) {
        const trans = async (key) => await this.translateService.translateAsync(`settings.log-management.${key}`, {
            scope: 'log-management'
        });
        context
            // Main Log Management Group
            .addGroup('log-management', 'Log Management', 'Configure system-wide logging settings', 'fa-light fa-file-lines')
            // Retention Section
            .addSection('retention', await trans('retention.title'), await trans('retention.description'))
            .addSetting({
            key: AXPLogManagementSettings.RetentionEnabled,
            title: await trans('retention.enabled.title'),
            scope: 'T',
            isInherited: true,
            defaultValue: true,
            widget: {
                type: AXPWidgetsCatalog.toggle
            },
            description: await trans('retention.enabled.description')
        })
            .addSetting({
            key: AXPLogManagementSettings.RetentionPeriod,
            title: await trans('retention.period.title'),
            scope: 'T',
            isInherited: true,
            defaultValue: 30,
            widget: {
                type: AXPWidgetsCatalog.number,
                options: {
                    minValue: 1,
                    maxValue: 365,
                    visibility: `{{ context.eval('${AXPLogManagementSettings.RetentionEnabled}') }}`
                }
            },
            description: await trans('retention.period.description'),
            validationRules: [
                { rule: 'required' }
            ]
        })
            .endSection()
            // Storage Section
            .addSection('storage', await trans('storage.title'), await trans('storage.description'))
            .addSetting({
            key: AXPLogManagementSettings.StorageLocation,
            title: await trans('storage.location.title'),
            scope: 'T',
            isInherited: false,
            defaultValue: '/var/log/acorex',
            widget: {
                type: AXPWidgetsCatalog.text,
                options: {
                    placeholder: '/path/to/logs'
                }
            },
            description: await trans('storage.location.description'),
            validationRules: [
                { rule: 'required' }
            ]
        })
            .addSetting({
            key: AXPLogManagementSettings.StorageFormat,
            title: await trans('storage.format.title'),
            scope: 'T',
            isInherited: true,
            defaultValue: 'json',
            widget: {
                type: AXPWidgetsCatalog.select,
                options: {
                    valueField: 'id',
                    textField: 'title',
                    dataSource: [
                        { id: 'json', title: 'JSON' },
                        { id: 'text', title: 'Plain Text' },
                        { id: 'csv', title: 'CSV' }
                    ]
                }
            },
            description: await trans('storage.format.description')
        })
            .addSetting({
            key: AXPLogManagementSettings.MaxFileSize,
            title: await trans('storage.max-size.title'),
            scope: 'T',
            isInherited: true,
            defaultValue: 10,
            widget: {
                type: AXPWidgetsCatalog.number,
                options: {
                    minValue: 1,
                    maxValue: 1000,
                    suffix: 'MB'
                }
            },
            description: await trans('storage.max-size.description')
        })
            .addSetting({
            key: AXPLogManagementSettings.CompressionEnabled,
            title: await trans('storage.compression.title'),
            scope: 'T',
            isInherited: true,
            defaultValue: true,
            widget: {
                type: AXPWidgetsCatalog.toggle
            },
            description: await trans('storage.compression.description')
        })
            .endSection()
            // Log Level Section
            .addSection('level', await trans('level.title'), await trans('level.description'))
            .addSetting({
            key: AXPLogManagementSettings.DefaultLogLevel,
            title: await trans('level.default.title'),
            scope: 'T',
            isInherited: true,
            defaultValue: 'info',
            widget: {
                type: AXPWidgetsCatalog.select,
                options: {
                    valueField: 'id',
                    textField: 'title',
                    dataSource: [
                        { id: 'error', title: 'Error' },
                        { id: 'warn', title: 'Warning' },
                        { id: 'info', title: 'Information' },
                        { id: 'debug', title: 'Debug' },
                        { id: 'trace', title: 'Trace' }
                    ]
                }
            },
            description: await trans('level.default.description')
        })
            .endSection()
            // Alert Section
            .addSection('alert', await trans('alert.title'), await trans('alert.description'))
            .addSetting({
            key: AXPLogManagementSettings.AlertEnabled,
            title: await trans('alert.enabled.title'),
            scope: 'T',
            isInherited: true,
            defaultValue: false,
            widget: {
                type: AXPWidgetsCatalog.toggle
            },
            description: await trans('alert.enabled.description')
        })
            .addSetting({
            key: AXPLogManagementSettings.AlertLogLevel,
            title: await trans('alert.level.title'),
            scope: 'T',
            isInherited: true,
            defaultValue: 'error',
            widget: {
                type: AXPWidgetsCatalog.select,
                options: {
                    valueField: 'id',
                    textField: 'title',
                    dataSource: [
                        { id: 'error', title: 'Error' },
                        { id: 'warn', title: 'Warning' },
                        { id: 'info', title: 'Information' }
                    ],
                    visibility: `{{ context.eval('${AXPLogManagementSettings.AlertEnabled}') }}`
                }
            },
            description: await trans('alert.level.description')
        })
            .addSetting({
            key: AXPLogManagementSettings.AlertEmail,
            title: await trans('alert.email.title'),
            scope: 'T',
            isInherited: false,
            widget: {
                type: AXPWidgetsCatalog.contact,
                options: {
                    type: 'email',
                    visibility: `{{ context.eval('${AXPLogManagementSettings.AlertEnabled}') }}`
                }
            },
            description: await trans('alert.email.description'),
            validationRules: [
                { rule: 'required' }
            ]
        })
            .endSection()
            // Performance Section
            .addSection('performance', await trans('performance.title'), await trans('performance.description'))
            .addSetting({
            key: AXPLogManagementSettings.AsyncLogging,
            title: await trans('performance.async.title'),
            scope: 'T',
            isInherited: true,
            defaultValue: true,
            widget: {
                type: AXPWidgetsCatalog.toggle
            },
            description: await trans('performance.async.description')
        })
            .addSetting({
            key: AXPLogManagementSettings.BatchSize,
            title: await trans('performance.batch-size.title'),
            scope: 'T',
            isInherited: true,
            defaultValue: 100,
            widget: {
                type: AXPWidgetsCatalog.number,
                options: {
                    minValue: 1,
                    maxValue: 1000,
                    visibility: `{{ context.eval('${AXPLogManagementSettings.AsyncLogging}') }}`
                }
            },
            description: await trans('performance.batch-size.description')
        })
            .addSetting({
            key: AXPLogManagementSettings.FlushInterval,
            title: await trans('performance.flush-interval.title'),
            scope: 'T',
            isInherited: true,
            defaultValue: 5000,
            widget: {
                type: AXPWidgetsCatalog.number,
                options: {
                    minValue: 1000,
                    maxValue: 60000,
                    step: 1000,
                    suffix: 'ms',
                    visibility: `{{ context.eval('${AXPLogManagementSettings.AsyncLogging}') }}`
                }
            },
            description: await trans('performance.flush-interval.description')
        })
            .endSection()
            .endGroup();
    }
}

var settings_provider = /*#__PURE__*/Object.freeze({
    __proto__: null,
    AXPLogManagementSettingProvider: AXPLogManagementSettingProvider
});

//export * from './lib/pages';

/**
 * Generated bundle index. Do not edit.
 */

export { AXMAxpLogService, AXMAxpLogServiceImpl, AXMEntityProvider, AXMLogManagementModule, AXMMenuProvider, AXMSearchCommandProvider, AXPLogManagementSettingProvider, RootConfig, axpLogFactory };
//# sourceMappingURL=acorex-modules-log-management.mjs.map
