import * as i0 from '@angular/core';
import { Injectable, inject, signal, Component, NgModule, Injector } from '@angular/core';
import { AXMEntityCrudServiceImpl, entityMasterCrudActions, entityMasterRecordActions, AXP_ENTITY_DEFINITION_LOADER, AXPEntityService } from '@acorex/platform/layout/entity';
import * as i1 from '@acorex/platform/core';
import { AXPComponentSlotModule, AXP_MODULE_MANIFEST_PROVIDER, provideLazyProvider } from '@acorex/platform/core';
import { AXPFileStorageService, createAllQueryView, createQueryView, AXPEntityCommandScope, AXP_MENU_PROVIDER, AXP_SETTING_DEFINITION_PROVIDER, AXP_SEARCH_PROVIDER, AXPSearchCommandProvider } from '@acorex/platform/common';
import { AXP_PERMISSION_DEFINITION_PROVIDER, AXPSessionService } from '@acorex/platform/auth';
import { AXSafePipe } from '@acorex/core/pipes';
import { AXPWidgetsCatalog } from '@acorex/platform/layout/widget-core';
import { AXDataSource } from '@acorex/cdk/common';
import { AXPCommonMenuKeys } from '@acorex/modules/common';

const config = {
    i18n: 'content-management',
};
const RootConfig = {
    config,
    module: {
        module: 'ContentManagement',
        name: 'ContentManagement',
        title: `@${config.i18n}:module.title`,
        icon: 'fa-light fa-file-invoice',
    },
    entities: {
        promotion: {
            name: 'Promotion',
            title: `@${config.i18n}:promotions.entities.promotion.title`,
            titlePlural: `@${config.i18n}:promotions.entities.promotion.plural`,
            icon: 'fa-light fa-megaphone',
        },
        glossary: {
            name: 'Glossary',
            title: `@${config.i18n}:glossaries.entities.glossary.title`,
            titlePlural: `@${config.i18n}:glossaries.entities.glossary.plural`,
            icon: 'fa-light fa-file',
        },
    },
};

//#region ----   Imports   ----
//#endregion
//#region ----   Manifest Definition   ----
/**
 * Content Management Module Manifest.
 * Defines module metadata, features, and provider references.
 */
const ContentManagementManifest = {
    name: RootConfig.module.name,
    version: '1.0.0',
    title: RootConfig.module.title,
    icon: RootConfig.module.icon,
    i18n: RootConfig.config.i18n,
    // Module dependencies (optional)
};
//#endregion

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

class AXMPromotionSlotComponent {
    constructor() {
        this.notificationChannelService = inject(AXMAppPromotionService);
        this.listData = signal([], ...(ngDevMode ? [{ debugName: "listData" }] : []));
        this.fileStorage = inject(AXPFileStorageService);
    }
    async ngOnInit() {
        const channels = await this.notificationChannelService.query({
            skip: 0,
            take: 10000,
            // filter: {
            //   field: 'type',
            //   operator: { type: 'equal' },
            //   value: 'promotion',
            // },
        });
        const filteredItems = channels.items.filter((x) => x.placement?.name == this.location);
        const mappedItems = await Promise.all(filteredItems.map(async (item) => {
            if (item.imageId != null) {
                const image = await this.fileStorage.getInfo(item.imageId);
                return {
                    ...item,
                    image: image,
                };
            }
            else {
                return item;
            }
        }));
        this.listData.set(mappedItems);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMPromotionSlotComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.19", type: AXMPromotionSlotComponent, isStandalone: true, selector: "acorex-platform-promotion-slot", ngImport: i0, template: "@for (item of listData(); track item.id) { @if (item.contentType?.name == 'media') {\n<img [src]=\"item.image?.url ?? ''\" class=\"ax-w-full ax-p-3 ax-border  {{\n    item.shape?.name == 'circle' ? 'ax-rounded-full' : 'ax-rounded-none'\n  }}\" />\n} @if(item.contentType?.name == 'text'){\n<div class=\"ax-m-1 ax-px-6 ax-p-4 ax-border ax-bg-primary ax-rounded-lg\">\n  <h1 class=\"ax-text-base/6\" [innerHTML]=\"item.body | safe : 'html'\"></h1>\n</div>\n\n} } ", dependencies: [{ kind: "pipe", type: AXSafePipe, name: "safe" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMPromotionSlotComponent, decorators: [{
            type: Component,
            args: [{ selector: 'acorex-platform-promotion-slot', imports: [AXSafePipe], template: "@for (item of listData(); track item.id) { @if (item.contentType?.name == 'media') {\n<img [src]=\"item.image?.url ?? ''\" class=\"ax-w-full ax-p-3 ax-border  {{\n    item.shape?.name == 'circle' ? 'ax-rounded-full' : 'ax-rounded-none'\n  }}\" />\n} @if(item.contentType?.name == 'text'){\n<div class=\"ax-m-1 ax-px-6 ax-p-4 ax-border ax-bg-primary ax-rounded-lg\">\n  <h1 class=\"ax-text-base/6\" [innerHTML]=\"item.body | safe : 'html'\"></h1>\n</div>\n\n} } " }]
        }] });

async function promotionEntityFactory(injector) {
    const dataService = injector.get(AXMAppPromotionService);
    const i18n = RootConfig.config.i18n;
    const entityDef = {
        plugins: [
            { name: 'history' },
            { name: 'lock' },
            { name: 'compare' },
            { name: 'comments' },
            { name: 'distribution' },
            {
                name: 'status',
                options: {
                    field: 'status',
                    definition: 'common.status.task',
                },
            },
            // {
            //   name: 'attachments',
            //   options: {
            //     field: 'imageId',
            //     accept: '.jpg,.jpeg,.png,.gif,.webp',
            //     multiple: false,
            //     fileEditable: true,
            //     enableTitleDescription: true,
            //     showEditDialogAfterSelect: true,
            //     // Single doc type:  { name: 'document', options: { docTypeName: 'file-meeting' } }
            //     // Multiple doc types: pass docTypeNames array; one "Upload" button per type in the dropdown
            //     // plugins: [
            //     //   { name: 'document', options: { docTypeNames: ['file-meeting', 'other-doc-type'] } },
            //     // ],
            //     // excludePlugins: ['capture-screen'],
            //   },
            // },
            {
                name: 'policy',
                options: {
                    policy: 'test',
                },
            },
            { name: 'workflow' },
        ],
        module: RootConfig.module.name,
        name: RootConfig.entities.promotion.name,
        title: RootConfig.entities.promotion.title,
        icon: RootConfig.entities.promotion.icon,
        formats: {
            individual: RootConfig.entities.promotion.title,
            plural: RootConfig.entities.promotion.titlePlural,
            searchResult: {
                title: '{{ title }}',
                description: RootConfig.module.title,
            },
        },
        relatedEntities: [],
        groups: [
            {
                id: 'promotion',
                title: 'Promotion',
            },
        ],
        properties: [
            {
                name: 'created.at',
                title: 'Created At',
                groupId: 'promotion',
                schema: {
                    dataType: 'date',
                    //  visible: false,
                    nullable: true,
                    readonly: true,
                    interface: {
                        type: AXPWidgetsCatalog.dateTime,
                    },
                },
                options: {
                    sort: {
                        enabled: true,
                    },
                },
            },
            {
                name: 'id',
                title: 'ID',
                schema: {
                    dataType: 'uuid',
                    visible: false,
                    nullable: false,
                    readonly: true,
                    unique: {
                        enabled: true,
                    },
                },
                options: {
                    sort: {
                        enabled: true,
                    },
                },
            },
            {
                name: 'title',
                title: '@general:terms.common.title',
                groupId: 'promotion',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.text,
                    },
                },
                options: {
                    sort: {
                        enabled: true,
                    },
                    filter: {
                        advance: {
                            enabled: true,
                        },
                        inline: {
                            enabled: true,
                        },
                    },
                },
                validations: [
                    {
                        rule: 'required',
                    },
                ],
            },
            {
                name: 'body',
                title: '@content-management:promotions.entities.promotion.fields.body.title',
                groupId: 'promotion',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.richText,
                    },
                },
                validations: [
                // {
                //   rule: 'required',
                // },
                ],
            },
            // attachments property comes from plugin when configured to create property
            {
                name: 'contentType',
                title: '@content-management:promotions.entities.promotion.fields.content-type.title',
                groupId: 'promotion',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.select,
                        options: {
                            valueField: 'name',
                            textField: 'title',
                            dataSource: [
                                { title: 'Media', name: 'media' },
                                { title: 'Text', name: 'text' },
                            ],
                            direction: 'horizontal',
                            multiple: false,
                        },
                    },
                },
                options: {
                    sort: {
                        enabled: true,
                    },
                    filter: {
                        advance: {
                            enabled: true,
                        },
                    },
                },
                validations: [
                // {
                //   rule: 'required',
                // },
                ],
            },
            // {
            //   name: 'shape',
            //   title: `t("shape", { scope: "${i18n}" })`,
            //   groupId: 'promotion',
            //   schema: {
            //     dataType: 'string',
            //     interface: {
            //       type: AXPWidgetsCatalog.select,
            //       options: {
            //         valueField: 'name',
            //         textField: 'title',
            //         dataSource: [
            //           { title: 'Circle', name: 'circle' },
            //           { title: 'Square', name: 'square' },
            //         ],
            //         direction: 'horizontal',
            //         multiple: false,
            //         accept: '',
            //       },
            //     },
            //   },
            //   validations: [
            //     {
            //       rule: 'required',
            //     },
            //   ],
            // },
            {
                name: 'placement',
                title: '@content-management:promotions.entities.promotion.fields.placement.title',
                groupId: 'promotion',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.select,
                        options: {
                            valueField: 'name',
                            textField: 'title',
                            dataSource: [
                                {
                                    title: 'Side Menu Footer',
                                    name: 'side-menu-footer',
                                    options: [
                                        {
                                            type: 'text-editor',
                                            mode: 'edit',
                                            path: 'name',
                                            options: {
                                                placeholder: 'Name',
                                                defaultValue: 'test',
                                            },
                                        },
                                    ],
                                },
                                {
                                    title: 'Side Menu Header',
                                    name: 'side-menu-header',
                                    options: [
                                        {
                                            type: 'text-editor',
                                            mode: 'edit',
                                            path: 'name',
                                            options: {
                                                placeholder: 'Name',
                                                defaultValue: 'test',
                                            },
                                        },
                                    ],
                                },
                            ],
                            direction: 'horizontal',
                            multiple: false,
                        },
                    },
                },
                validations: [
                // {
                //   rule: 'required',
                // },
                ],
            },
            // {
            //   name: "metadaata",
            //   title: "Meta Data",
            //   groupId: 'promotion',
            //   schema: {
            //     dataType: 'object',
            //     interface: {
            //       type: AXPWidgetsCatalog.text,
            //       // children: "{{ context.eval('placement').options }}" as any,
            //     },
            //   }
            //},
        ],
        columns: [{ name: 'title' }, { name: 'placement' }, { name: 'created.at' }],
        interfaces: {
            master: {
                create: {
                    sections: [
                        {
                            id: 'promotion',
                        },
                    ],
                    properties: [
                        // {
                        //   name: 'created.at',
                        //   layout: {
                        //     positions: {
                        //       lg: {
                        //         colSpan: 6,
                        //         order: 1,
                        //       },
                        //     },
                        //   },
                        // },
                        {
                            name: 'title',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 1,
                                    },
                                },
                            },
                        },
                        {
                            name: 'body',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                        order: 5,
                                    },
                                },
                            },
                        },
                        // attachments property layout injected via plugin
                        {
                            name: 'contentType',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 2,
                                    },
                                },
                            },
                        },
                        {
                            name: 'shape',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 3,
                                    },
                                },
                            },
                        },
                        {
                            name: 'placement',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 4,
                                    },
                                },
                            },
                        },
                        {
                            name: 'metadata',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                        order: 10,
                                    },
                                },
                            },
                        },
                    ],
                },
                update: {
                    sections: [
                        {
                            id: 'promotion',
                        },
                    ],
                    properties: [
                        {
                            name: 'created.at',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 1,
                                    },
                                },
                            },
                        },
                        {
                            name: 'title',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 1,
                                    },
                                },
                            },
                        },
                        {
                            name: 'body',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                        order: 5,
                                    },
                                },
                            },
                        },
                        // attachments property layout injected via plugin
                        {
                            name: 'contentType',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 2,
                                    },
                                },
                            },
                        },
                        {
                            name: 'shape',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 3,
                                    },
                                },
                            },
                        },
                        {
                            name: 'placement',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 4,
                                    },
                                },
                            },
                        },
                        // {
                        //   name: 'metadata',
                        //   layout: {
                        //     positions: {
                        //       lg: {
                        //         colSpan: 12,
                        //         order: 10,
                        //       },
                        //     },
                        //   },
                        // },
                    ],
                },
                single: {
                    title: '{{title}}',
                    sections: [
                        {
                            id: 'promotion',
                        },
                        // {
                        //   id: 'comments',
                        // },
                    ],
                    properties: [
                        {
                            name: 'created.at',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 1,
                                    },
                                },
                            },
                        },
                        {
                            name: 'title',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        {
                            name: 'body',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                    },
                                },
                            },
                        },
                        // attachments property layout injected via plugin
                        {
                            name: 'contentType',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 4,
                                        order: 4,
                                    },
                                },
                            },
                        },
                        {
                            name: 'shape',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 4,
                                        order: 5,
                                    },
                                },
                            },
                        },
                        {
                            name: 'placement',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 4,
                                        order: 6,
                                    },
                                },
                            },
                        },
                        // {
                        //   name: 'comments',
                        //   layout: {
                        //     label: {
                        //       visible: false,
                        //     },
                        //     positions: {
                        //       lg: {
                        //         colSpan: 12,
                        //         order: 7,
                        //       },
                        //     },
                        //   },
                        // },
                    ],
                    actions: [
                        ...entityMasterRecordActions(),
                        {
                            name: 'promotion-upload-image',
                            title: '@document-management:actions.upload-files',
                            command: {
                                name: 'show-file-uploader-popup',
                                options: {
                                    id: '{{ context.eval("id") }}',
                                    files: '{{ Array.isArray(context.eval("imageId")) ? context.eval("imageId") : (context.eval("imageId") ? [context.eval("imageId")] : []) }}',
                                    key: 'imageId',
                                    multiple: false,
                                    accept: '.jpg,.jpeg,.png,.gif,.webp',
                                    fileEditable: true,
                                    readonly: true,
                                    showEditDialogAfterSelect: true,
                                    enableTitleDescription: true,
                                },
                            },
                            priority: 'secondary',
                            type: 'upload',
                            scope: AXPEntityCommandScope.Individual,
                        },
                    ],
                },
                list: {
                    title: '@content-management:promotions.entities.promotion.plural',
                    actions: [
                        ...entityMasterCrudActions(),
                        {
                            name: 'promotion-upload-image',
                            title: '@document-management:actions.upload-files',
                            command: {
                                name: 'show-file-uploader-popup',
                                options: {
                                    id: '{{ context.eval("id") }}',
                                    files: '{{ Array.isArray(context.eval("imageId")) ? context.eval("imageId") : (context.eval("imageId") ? [context.eval("imageId")] : []) }}',
                                    key: 'imageId',
                                    multiple: false,
                                    accept: '.jpg,.jpeg,.png,.gif,.webp',
                                    readonly: true,
                                    showEditDialogAfterSelect: true,
                                    enableTitleDescription: true,
                                },
                            },
                            priority: 'secondary',
                            type: 'upload',
                            scope: AXPEntityCommandScope.Individual,
                        },
                    ],
                    views: [
                        createAllQueryView({
                            sorts: [
                                { name: 'title', dir: 'asc' },
                                { name: 'created.at', dir: 'desc' },
                            ],
                        }),
                        createQueryView('media', '@content-management:promotions.terms.media', true, {
                            conditions: [
                                {
                                    name: 'contentType.name',
                                    operator: {
                                        type: 'equal',
                                    },
                                    value: 'media',
                                },
                            ],
                        }),
                        createQueryView('text', '@content-management:promotions.terms.text', true, {
                            conditions: [
                                {
                                    name: 'contentType.name',
                                    operator: {
                                        type: 'equal',
                                    },
                                    value: 'text',
                                },
                            ],
                        }),
                    ],
                },
            },
        },
    };
    return entityDef;
}

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

class AXMPromotionDataSourceDefinition {
    constructor() {
        this.promotionService = inject(AXMAppPromotionService);
        this.i18n = RootConfig.config.i18n;
    }
    items() {
        return Promise.resolve([
            {
                name: 'promotion',
                title: 'Promotion',
                source: () => {
                    return new AXDataSource({
                        load: async (_) => {
                            try {
                                const res = await this.promotionService.query();
                                return {
                                    items: res.items,
                                    total: res.total,
                                };
                            }
                            catch (e) {
                                throw e;
                            }
                        },
                        pageSize: 100,
                    });
                },
                columns: [
                    {
                        name: 'id',
                        title: 'ID',
                        datatype: 'uuid',
                        type: AXPWidgetsCatalog.text,
                    },
                    {
                        name: 'title',
                        //TODO translate
                        title: `Title`,
                        datatype: 'string',
                        type: AXPWidgetsCatalog.text,
                    },
                    {
                        name: 'body',
                        title: `Body`,
                        datatype: 'string',
                        type: AXPWidgetsCatalog.number,
                    },
                ],
                filters: [
                    {
                        field: 'title',
                        title: 'Title',
                        operator: {
                            type: 'equal',
                        },
                        widget: {
                            type: AXPWidgetsCatalog.text,
                        },
                        filterType: {
                            advance: true,
                            inline: true,
                        },
                    },
                ],
                textField: {
                    name: 'title',
                    title: 'Title',
                },
                valueField: {
                    name: 'id',
                    title: 'ID',
                },
            },
        ]);
    }
}

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

// Entity Services

class AXMContentManagementModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMContentManagementModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.19", ngImport: i0, type: AXMContentManagementModule, imports: [i1.AXPComponentSlotModule, 
            // Entity Modules
            AXMPromotionEntityModule] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMContentManagementModule, providers: [
            // Module Manifest Provider
            {
                provide: AXP_MODULE_MANIFEST_PROVIDER,
                useValue: ContentManagementManifest,
                multi: true,
            },
            // Provider references (now using tokens)
            provideLazyProvider(AXP_PERMISSION_DEFINITION_PROVIDER, () => import('./acorex-modules-content-management-permission-definition.provider-BVc1S-3o.mjs').then(m => m.AXMPermissionDefinitionProvider)),
            provideLazyProvider(AXP_MENU_PROVIDER, () => Promise.resolve().then(function () { return menu_provider; }).then(m => m.AXMMenuProvider)),
            provideLazyProvider(AXP_ENTITY_DEFINITION_LOADER, () => Promise.resolve().then(function () { return entity_provider; }).then(m => m.AXMEntityProvider)),
            provideLazyProvider(AXP_SETTING_DEFINITION_PROVIDER, () => Promise.resolve().then(function () { return setting_provider; }).then(m => m.AXMSettingProvider)),
            provideLazyProvider(AXP_SEARCH_PROVIDER, () => Promise.resolve().then(function () { return searchCommand_provider; }).then(m => m.AXMSearchCommandProvider)),
        ], imports: [AXPComponentSlotModule.forChild({
                'side-menu-footer': [
                    {
                        name: 'side-menu-footer-promotion',
                        component: AXMPromotionSlotComponent,
                        options: {
                            location: 'side-menu-footer',
                        },
                    },
                ],
                'side-menu-header': [
                    {
                        name: 'side-menu-header-promotion',
                        component: AXMPromotionSlotComponent,
                        priority: 2,
                        options: {
                            location: 'side-menu-header',
                        },
                    },
                ],
            }),
            // Entity Modules
            AXMPromotionEntityModule] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMContentManagementModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [
                        AXPComponentSlotModule.forChild({
                            'side-menu-footer': [
                                {
                                    name: 'side-menu-footer-promotion',
                                    component: AXMPromotionSlotComponent,
                                    options: {
                                        location: 'side-menu-footer',
                                    },
                                },
                            ],
                            'side-menu-header': [
                                {
                                    name: 'side-menu-header-promotion',
                                    component: AXMPromotionSlotComponent,
                                    priority: 2,
                                    options: {
                                        location: 'side-menu-header',
                                    },
                                },
                            ],
                        }),
                        // Entity Modules
                        AXMPromotionEntityModule,
                    ],
                    exports: [],
                    declarations: [],
                    providers: [
                        // Module Manifest Provider
                        {
                            provide: AXP_MODULE_MANIFEST_PROVIDER,
                            useValue: ContentManagementManifest,
                            multi: true,
                        },
                        // Provider references (now using tokens)
                        provideLazyProvider(AXP_PERMISSION_DEFINITION_PROVIDER, () => import('./acorex-modules-content-management-permission-definition.provider-BVc1S-3o.mjs').then(m => m.AXMPermissionDefinitionProvider)),
                        provideLazyProvider(AXP_MENU_PROVIDER, () => Promise.resolve().then(function () { return menu_provider; }).then(m => m.AXMMenuProvider)),
                        provideLazyProvider(AXP_ENTITY_DEFINITION_LOADER, () => Promise.resolve().then(function () { return entity_provider; }).then(m => m.AXMEntityProvider)),
                        provideLazyProvider(AXP_SETTING_DEFINITION_PROVIDER, () => Promise.resolve().then(function () { return setting_provider; }).then(m => m.AXMSettingProvider)),
                        provideLazyProvider(AXP_SEARCH_PROVIDER, () => Promise.resolve().then(function () { return searchCommand_provider; }).then(m => m.AXMSearchCommandProvider)),
                    ]
                }]
        }] });

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.promotion.name: {
                    const entity = (await Promise.resolve().then(function () { return promotion_entity; })).promotionEntityFactory;
                    return entity(this.injector);
                }
            }
        }
        return null;
    }
    async list() {
        const m = RootConfig.module.name;
        return Promise.resolve(Object.values(RootConfig.entities).map((e) => ({ name: e.name, module: m })));
    }
}

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

const AXPContentManagementMenuKeys = {
    Root: 'content-management:menu',
    HelpRoot: 'app:help',
    Promotions: 'content-management:menu:promotions',
    Glossary: 'content-management:menu:glossary',
    HelpCenter: 'app:help:center',
    Tutorials: 'app:help:tutorials',
    About: 'app:about',
};

class AXMMenuProvider {
    constructor() {
        this.entityService = inject(AXPEntityService);
        this.sessionService = inject(AXPSessionService);
    }
    async provide(context) {
        const scope = RootConfig.config.i18n;
        const module = RootConfig.module;
        const appName = this.sessionService.application?.name;
        //#region ----   Administration > Content (Promotions, Page Builder)   ----
        const contentMenu = context.find(AXPCommonMenuKeys.Content);
        if (!contentMenu.exists) {
            context.find(AXPCommonMenuKeys.Administration).addItems([
                {
                    name: AXPCommonMenuKeys.Content,
                    priority: 10,
                    text: '@general:menus.content.title',
                    icon: 'fa-light fa-paint-brush',
                    type: 'menu',
                    children: [],
                },
            ]);
        }
        context.find(AXPCommonMenuKeys.Content).addItems([
            {
                name: AXPContentManagementMenuKeys.Promotions,
                text: RootConfig.entities.promotion.title,
                path: this.entityService.createPath(module.name, RootConfig.entities.promotion.name),
                icon: RootConfig.entities.promotion.icon,
                priority: 1,
                policy: {
                    features: [module.name],
                },
            },
        ]);
        //#endregion
        //#region ----   Help Menu Extensions   ----
        context.addItems([
            {
                name: AXPContentManagementMenuKeys.HelpRoot,
                priority: 900000,
                text: `@${scope}:help-center.menus.help.title`,
                icon: 'fa-light fa-circle-question',
            },
        ]);
        const helpMenu = context.find(AXPContentManagementMenuKeys.HelpRoot);
        if (helpMenu.exists) {
            helpMenu.addItems([
                {
                    name: AXPContentManagementMenuKeys.HelpCenter,
                    text: `@${scope}:help-center.menus.help-center.title`,
                    icon: 'fa-light fa-book-open',
                    priority: 900001,
                },
                {
                    name: AXPContentManagementMenuKeys.Tutorials,
                    text: `@${scope}:help-center.menus.tutorials.title`,
                    icon: 'fa-light fa-clapperboard-play',
                    priority: 900002,
                },
                {
                    name: AXPContentManagementMenuKeys.About,
                    text: `@${scope}:help-center.menus.about.title`,
                    icon: 'fa-light fa-circle-info',
                    priority: 900011,
                },
            ]);
        }
        //#endregion
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMMenuProvider, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMMenuProvider }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMMenuProvider, decorators: [{
            type: Injectable
        }] });

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

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}`,
        //    },
        //  },
        // }
        ];
    }
}

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

class AXMSettingProvider {
    async provide(context) {
        // context
        //   // Add Form Template Group
        //   .addGroup('form-template', 'Form Template', 'Settings related to form templates.', RootConfig.module.icon)
        //   // Start Interface Section
        //   .addSection('interface', 'UI Interface', 'Customize the user interface for forms.')
        //   .addSetting({
        //     key: 'history-panel',
        //     title: 'Show History Panel',
        //     scope: 'U',
        //     isInherited: true,
        //     defaultValue: false,
        //     widget: {
        //       type: AXPWidgetsCatalog.toggle,
        //     },
        //     description: 'Enable or disable the history panel for forms.',
        //     validationRules: [
        //       {
        //         rule: 'required',
        //       },
        //     ],
        //   })
        //   .endSection()
        //   .endGroup();
    }
}

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

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

export { AXMAppPromotionService, AXMContentManagementModule, AXMEntityProvider, AXMMenuProvider, AXMPromotionDataSourceDefinition, AXMPromotionEntityModule, AXMPromotionServiceImpl, AXMPromotionSlotComponent, AXMSearchCommandProvider, AXMSettingProvider, RootConfig, promotionEntityFactory };
//# sourceMappingURL=acorex-modules-content-management.mjs.map
