import * as i0 from '@angular/core';
import { inject, Injector, Injectable, signal, Component, NgModule, HostListener } from '@angular/core';
import { AXPSessionService, AXP_PERMISSION_DEFINITION_PROVIDER } from '@acorex/platform/auth';
import { AXPSearchCommandProvider, AXPFileStorageService, createAllQueryView, createQueryView, AXPEntityQueryType, AXPEntityCommandScope, AXPSettingService, AXP_MENU_PROVIDER, AXP_SETTING_DEFINITION_PROVIDER, AXP_SEARCH_PROVIDER } from '@acorex/platform/common';
import { AXPEntityService, AXMEntityCrudServiceImpl, entityMasterCrudActions, entityMasterRecordActions, AXP_ENTITY_DEFINITION_LOADER, AXP_ENTITY_CONFIG_TOKEN } from '@acorex/platform/layout/entity';
import * as i3$1 from '@acorex/platform/layout/components';
import { AXPComponentSlotModule, AXPThemeLayoutBlockComponent } from '@acorex/platform/layout/components';
import { AXPPlatformScope, AXPAppStartUpService, AXP_DATASOURCE_DEFINITION_PROVIDER } from '@acorex/platform/core';
import { AXSafePipe } from '@acorex/core/pipes';
import { AXPWidgetsCatalog } from '@acorex/platform/layout/widget-core';
import { AXDataSource } from '@acorex/cdk/common';
import { AXPWidgetsList } from '@acorex/modules/common';
import { ROUTES } from '@angular/router';
import * as i2$1 from '@acorex/platform/workflow';
import { AXPWorkflowAction, AXPWorkflowService, AXPWorkflowModule } from '@acorex/platform/workflow';
import { AXPopupService } from '@acorex/components/popup';
import * as i4 from '@acorex/components/button';
import { AXButtonModule } from '@acorex/components/button';
import * as i2 from '@acorex/components/check-box';
import { AXCheckBoxModule } from '@acorex/components/check-box';
import * as i3 from '@acorex/components/decorators';
import { AXDecoratorModule } from '@acorex/components/decorators';
import * as i1 from '@acorex/components/label';
import { AXLabelModule } from '@acorex/components/label';
import { AXBasePageComponent } from '@acorex/components/page';
import * as i6 from '@acorex/core/translation';
import { AXTranslationModule } from '@acorex/core/translation';
import * as i5 from '@angular/common';
import { CommonModule } from '@angular/common';
import { AXOutlineContainerDirective } from '@acorex/cdk/outline';
import * as i2$2 from '@acorex/components/side-menu';
import { AXSideMenuModule, AXOutlineSideMenuDirective } from '@acorex/components/side-menu';
import * as i4$1 from '@acorex/core/format';
import { AXFormatModule } from '@acorex/core/format';
import { AXPPageLayoutBaseComponent, AXPPageLayoutComponent, AXPPageLayoutBase } from '@acorex/platform/layout/views';

const config = {
    i18n: 'content-management',
};
const RootConfig = {
    config,
    module: {
        module: 'ContentManagement',
        name: 'ContentManagement',
        title: `t('module-name', {scope:"${config.i18n}"})`,
        icon: 'fa-light fa-file-invoice',
    },
    entities: {
        promotion: {
            name: 'Promotion',
            title: `t("promotion", { scope: "${config.i18n}" })`,
            titlePlural: `t("promotions", { scope: "${config.i18n}" })`,
            icon: 'fa-light fa-megaphone',
        },
        glossary: {
            name: 'Glossary',
            title: `t("glossary.individual-title", { scope: "${config.i18n}" })`,
            titlePlural: `t("glossary.plural-title", { scope: "${config.i18n}" })`,
            icon: 'fa-light fa-file',
        },
        appTerm: {
            name: 'app-term',
            title: `t("app-term.individual-title", {scope:"${config.i18n}"})`,
            titlePlural: `t("app-term.plural-title", {scope:"${config.i18n}"})`,
            pageTitle: `t("app-term.page-title", {scope:"${config.i18n}"})`,
            pageDescription: `t("app-term.page-description", {scope:"${config.i18n}"})`,
            icon: 'fa-light fa-scale-balanced',
        },
    },
};

const AXPContentManagementMenuKeys = {
    Root: 'content-management:menu',
    Promotions: 'content-management:menu:promotions',
    Glossary: 'content-management:menu:glossary',
    AppTerms: 'content-management:menu:app-terms',
    TermsPage: 'app:help:terms',
};

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;
        context.addItems([
            {
                name: AXPContentManagementMenuKeys.Root,
                priority: 9002,
                text: `t('module-name', {scope:"${scope}"})`,
                icon: module.icon,
                data: {
                    requiredPermission: [
                        'platform'
                    ],
                },
                children: [
                    {
                        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,
                    },
                    // {
                    //   name: AXPContentManagementMenuKeys.Glossary,
                    //   text: RootConfig.entities.glossary?.title,
                    //   path: this.entityService.createPath(module.name, RootConfig.entities.glossary?.name),
                    //   icon: RootConfig.entities.glossary?.icon,
                    //   priority: 2,
                    // },
                    {
                        name: AXPContentManagementMenuKeys.AppTerms,
                        text: RootConfig.entities.appTerm?.title,
                        path: this.entityService.createPath(module.name, RootConfig.entities.appTerm?.name),
                        icon: RootConfig.entities.appTerm?.icon,
                        priority: 3,
                    }
                ],
            },
        ]);
        context.find('app:help').addItems([
            {
                name: AXPContentManagementMenuKeys.TermsPage,
                text: `t('terms-conditions',{scope: "${scope}"})`,
                icon: 'fa-light fa-circle-info',
                path: `${appName}/terms`,
                priority: 100031,
            },
        ]);
    }
}

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);
                }
                case RootConfig.entities.glossary.name: {
                    const entity = (await Promise.resolve().then(function () { return glossary_entity; })).glossaryEntityFactory;
                    return entity(this.injector);
                }
                case RootConfig.entities.appTerm.name: {
                    const entity = (await Promise.resolve().then(function () { return appTerm_entity; })).appTermEntityEntityFactory;
                    return entity(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 AXMPermissionDefinitionProvider {
    async define(context) {
        // context.addPermissions([
        //   {
        //     name: 'view_templates',
        //     title: 'Permission to view templates',
        //     isArchived: false,
        //   },
        // ]);
    }
}

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();
    }
}

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 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.4", ngImport: i0, type: AXMPromotionServiceImpl, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMPromotionServiceImpl }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", 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.4", ngImport: i0, type: AXMPromotionSlotComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.4", 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.4", 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: 'sign', options: { viewType: 'sign' } },
            {
                name: 'attachments',
                options: {
                    field: 'imageId',
                    accept: '.jpg,.jpeg,.png,.gif,.webp',
                    multiple: true,
                    fileEditable: true,
                    // plugins: [
                    //   { name: 'document', options: { docTypeName: 'file-meeting' } },
                    // ],
                    //     excludePlugins: ['capture-screen'],
                },
            },
            {
                name: 'policy',
                options: {
                    policy: 'test',
                },
            }
        ],
        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',
                    //  hidden: true,
                    nullable: true,
                    readonly: true,
                    interface: {
                        type: AXPWidgetsCatalog.dateTime,
                    },
                },
                options: {
                    sort: {
                        enabled: true,
                    },
                },
            },
            {
                name: 'id',
                title: 'ID',
                schema: {
                    dataType: 'uuid',
                    hidden: true,
                    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: `t("body", { scope: "${i18n}" })`,
                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: `t("contentType", { scope: "${i18n}" })`,
                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: `t("placement", { scope: "${i18n}" })`,
                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' }],
        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) => {
                    console.log(data);
                    return await dataService.updateOne(data.id, data);
                },
            },
        },
        queries: {
            byKey: {
                execute: async (id) => {
                    const x = await dataService.getOne(id);
                    console.log(x);
                    return x;
                },
                type: AXPEntityQueryType.Single,
            },
            list: {
                execute: async (e) => {
                    return await dataService.query(e);
                },
                type: AXPEntityQueryType.List,
            },
        },
        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()],
                },
                list: {
                    title: 't("promotionPlural", { scope: "content-management" })',
                    actions: [...entityMasterCrudActions()],
                    views: [
                        createAllQueryView({ sorts: [{ name: 'title', dir: 'asc' }, { name: 'created.at', dir: 'desc' }] }),
                        createQueryView('media', `t("media", { scope: "${i18n}" })`, true, {
                            conditions: [
                                {
                                    name: 'contentType.name',
                                    operator: {
                                        type: 'equal',
                                    },
                                    value: 'media',
                                },
                            ],
                        }),
                        createQueryView('text', `t("text", { scope: "${i18n}" })`, 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 AXMAppTermService extends AXMEntityCrudServiceImpl {
}
class AXMAppTermServiceImpl extends AXMEntityCrudServiceImpl {
    constructor() {
        super(`${RootConfig.module.name}.${RootConfig.entities.appTerm.name}`);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMAppTermServiceImpl, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMAppTermServiceImpl }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMAppTermServiceImpl, decorators: [{
            type: Injectable
        }], ctorParameters: () => [] });

async function appTermEntityEntityFactory(injector) {
    const dataService = injector.get(AXMAppTermService);
    const i18n = RootConfig.config.i18n;
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.appTerm.name,
        title: RootConfig.entities.appTerm.title,
        icon: RootConfig.entities.appTerm.icon,
        formats: {
            individual: RootConfig.entities.appTerm.title,
            plural: RootConfig.entities.appTerm.titlePlural,
            searchResult: {
                title: '{{ title }}',
                description: RootConfig.module.title,
            },
        },
        relatedEntities: [],
        groups: [
            {
                id: 'section',
                title: RootConfig.entities.appTerm.title,
            },
        ],
        properties: [
            {
                name: 'type',
                title: '@general:terms.common.type',
                groupId: 'section',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.text,
                    },
                },
                validations: [
                    {
                        rule: 'required',
                    },
                ],
            },
            {
                name: 'title',
                title: '@general:terms.common.title',
                groupId: 'section',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.text,
                    },
                },
                options: {
                    filter: {
                        advance: {
                            enabled: true,
                        },
                        inline: {
                            enabled: true,
                        },
                    },
                    sort: {
                        enabled: true,
                    },
                },
                validations: [
                    {
                        rule: 'required',
                    },
                ],
            },
            {
                name: 'content',
                title: `t("content", { scope: "${i18n}" })`,
                groupId: 'section',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.richText,
                        options: {
                            minLineCount: 5,
                            maxLineCount: 17,
                            isFitLine: true,
                        },
                    },
                },
                validations: [
                    {
                        rule: 'required',
                    },
                ],
            },
            {
                name: 'version',
                title: `t("version", { scope: "${i18n}" })`,
                groupId: 'section',
                schema: {
                    dataType: 'number',
                    interface: {
                        type: AXPWidgetsCatalog.number,
                    },
                },
                options: {
                    filter: {
                        advance: {
                            enabled: true,
                        },
                    },
                    sort: {
                        enabled: true,
                    },
                },
                validations: [
                    {
                        rule: 'required',
                    },
                ],
            },
            {
                name: 'effectiveDate',
                title: `t("effectiveDate", { scope: "${i18n}" })`,
                groupId: 'section',
                schema: {
                    dataType: 'dateTime',
                    interface: {
                        type: AXPWidgetsCatalog.dateTime,
                    },
                },
                options: {
                    filter: {
                        advance: {
                            enabled: true,
                        },
                    },
                    sort: {
                        enabled: true,
                    },
                },
                validations: [
                    {
                        rule: 'required',
                    },
                ],
            },
        ],
        columns: [{ name: 'title' }, { name: 'content' }, { name: 'version' }, { name: 'effectiveDate' }],
        commands: {
            create: {
                execute: async (data) => {
                    return Promise.resolve({ id: await dataService.insertOne(data) });
                },
            },
            delete: {
                execute: async (id) => {
                    await await dataService.deleteOne(id);
                    return Promise.resolve();
                },
            },
            update: {
                execute: async (data) => {
                    return new Promise((resolve) => {
                        setTimeout(async () => {
                            await dataService.updateOne(data.id, data);
                            resolve(data);
                        }, 1000);
                    });
                },
            },
        },
        queries: {
            byKey: {
                execute: async (id) => {
                    return new Promise((resolve) => {
                        setTimeout(async () => {
                            const entity = await dataService.getOne(id);
                            resolve(entity);
                        }, 500);
                    });
                },
                type: AXPEntityQueryType.Single,
            },
            list: {
                execute: async (e) => {
                    const x = await dataService.query(e);
                    return x;
                },
                type: AXPEntityQueryType.List,
            },
        },
        interfaces: {
            master: {
                create: {
                    sections: [
                        {
                            id: 'section',
                        },
                    ],
                    properties: [
                        {
                            name: 'title',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                        order: 1,
                                    },
                                },
                            },
                        },
                        {
                            name: 'type',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 4,
                                        order: 2,
                                    },
                                },
                            },
                        },
                        {
                            name: 'version',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 4,
                                        order: 3,
                                    },
                                },
                            },
                        },
                        {
                            name: 'content',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                        order: 10,
                                    },
                                },
                            },
                        },
                        {
                            name: 'effectiveDate',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 4,
                                        order: 4,
                                    },
                                },
                            },
                        },
                    ],
                },
                update: {
                    sections: [
                        {
                            id: 'section',
                        },
                    ],
                    properties: [
                        {
                            name: 'title',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                        order: 1,
                                    },
                                },
                            },
                        },
                        {
                            name: 'type',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 4,
                                        order: 2,
                                    },
                                },
                            },
                        },
                        {
                            name: 'version',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 4,
                                        order: 3,
                                    },
                                },
                            },
                        },
                        {
                            name: 'content',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                        order: 10,
                                    },
                                },
                            },
                        },
                        {
                            name: 'effectiveDate',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 4,
                                        order: 4,
                                    },
                                },
                            },
                        },
                    ],
                },
                single: {
                    title: '{{title}}',
                    sections: [
                        {
                            id: 'section',
                        },
                    ],
                    properties: [
                        {
                            name: 'title',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 1,
                                    },
                                },
                            },
                        },
                        {
                            name: 'type',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 2,
                                    },
                                },
                            },
                        },
                        {
                            name: 'version',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 3,
                                    },
                                },
                            },
                        },
                        {
                            name: 'content',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                        order: 10,
                                    },
                                },
                            },
                        },
                        {
                            name: 'effectiveDate',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 4,
                                    },
                                },
                            },
                        },
                    ],
                    actions: [],
                },
                list: {
                    actions: [
                        {
                            title: 'Create New',
                            command: 'create-entity',
                            priority: 'primary',
                            type: 'create',
                            scope: AXPEntityCommandScope.TypeLevel,
                        },
                        {
                            title: 'Delete Items',
                            command: 'delete-entity',
                            priority: 'primary',
                            type: 'delete',
                            scope: AXPEntityCommandScope.Selected,
                        },
                        {
                            title: 'Details',
                            command: 'open-entity',
                            priority: 'secondary',
                            type: 'view',
                            scope: AXPEntityCommandScope.Individual,
                        },
                        {
                            title: 'Delete',
                            command: 'delete-entity',
                            priority: 'secondary',
                            type: 'delete',
                            scope: AXPEntityCommandScope.Individual,
                        },
                    ],
                    views: [createAllQueryView({ sorts: [{ name: 'title', dir: 'asc' }] })],
                },
            },
        },
    };
    return entityDef;
}

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

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

async function glossaryEntityFactory(injector) {
    const dataService = injector.get(AXMGlossaryService);
    const i18n = RootConfig.config.i18n + '.glossary';
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.glossary.name,
        title: RootConfig.entities.glossary.title,
        icon: RootConfig.entities.glossary.icon,
        formats: {
            individual: RootConfig.entities.glossary.title,
            plural: RootConfig.entities.glossary.titlePlural,
            searchResult: {
                title: '{{ title }}',
                description: RootConfig.module.title,
            },
        },
        relatedEntities: [],
        groups: [
            {
                id: 'section',
                title: RootConfig.entities.glossary.title,
            },
        ],
        properties: [
            {
                name: 'title',
                title: `t("title", { scope: "${i18n}" })`,
                groupId: 'section',
                options: {
                    sort: {
                        enabled: true,
                    },
                    filter: {
                        advance: {
                            enabled: true,
                        },
                        inline: {
                            enabled: false,
                        },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.TextBox,
                    },
                },
                validations: [
                    {
                        rule: 'required',
                    },
                ],
            },
            {
                name: 'parentId',
                title: `t("parentId",{ scope: "${i18n}" })`,
                groupId: 'section',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LookupBox,
                        options: {
                            entity: `${RootConfig.module.name}.${RootConfig.entities.glossary.name}`,
                        },
                    },
                },
            },
            {
                name: 'translation',
                title: `t("translation",{ scope: "${i18n}" })`,
                groupId: 'section',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.TextBox,
                        options: {
                            entity: `${RootConfig.module.name}.${RootConfig.entities.glossary.name}`,
                            multiLanguage: true,
                        },
                    },
                },
            },
        ],
        columns: [{ name: 'title' }],
        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: 'title',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                        order: 1,
                                    },
                                },
                            },
                        },
                        {
                            name: 'parentId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                        order: 2,
                                    },
                                },
                            },
                        },
                        {
                            name: 'translation',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                        order: 3,
                                    },
                                },
                            },
                        },
                    ],
                },
                update: {
                    sections: [
                        {
                            id: 'section',
                        },
                    ],
                    properties: [
                        {
                            name: 'title',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                        order: 1,
                                    },
                                },
                            },
                        },
                        {
                            name: 'parentId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                        order: 2,
                                    },
                                },
                            },
                        },
                        {
                            name: 'translation',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                        order: 3,
                                    },
                                },
                            },
                        },
                    ],
                },
                single: {
                    title: '{{title}}',
                    sections: [
                        {
                            id: 'section',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                    ],
                    properties: [
                        {
                            name: 'title',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                        order: 1,
                                    },
                                },
                            },
                        },
                        {
                            name: 'parentId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                        order: 2,
                                    },
                                },
                            },
                        },
                        {
                            name: 'translation',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                        order: 3,
                                    },
                                },
                            },
                        },
                    ],
                    actions: [...entityMasterRecordActions()],
                },
                list: {
                    actions: [...entityMasterCrudActions()],
                    views: [
                        createAllQueryView({
                            sorts: [{ name: 'title', dir: 'asc' }],
                        }),
                    ],
                },
            },
        },
    };
    return entityDef;
}

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

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

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

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

// Entity Services

class AXMNotifyAppTermComponent extends AXBasePageComponent {
    constructor() {
        super(...arguments);
        this.isConfirm = false;
        this.i18n = RootConfig.config.i18n;
    }
    transformContent(content) {
        return content.replace(/\n/g, '<br>');
    }
    send() {
        this.close({ data: this.data });
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMNotifyAppTermComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.4", type: AXMNotifyAppTermComponent, isStandalone: true, selector: "axm-notify-app", usesInheritance: true, ngImport: i0, template: "@for (item of data; track $index) {\n  <ax-content class=\"ax-block ax-px-4 ax-py-4 ax-font-bold\">{{ item.title }}</ax-content>\n  <ax-content\n    class=\"ax-block ax-px-4 ax-pb-4 ax-text-base/6\"\n    [innerHTML]=\"transformContent(item.content) | safe: 'html'\"\n  ></ax-content>\n}\n<ax-footer class=\"ax-flex ax-items-center ax-justify-between ax-p-2\">\n  <ax-check-box [(value)]=\"isConfirm\">\n    <ax-label>{{ 'agreeTerm' | translate: { scope: i18n } | async }}</ax-label>\n  </ax-check-box>\n  <ax-button\n    (click)=\"send()\"\n    [text]=\"'@general:actions.ok.title' | translate | async\"\n    [disabled]=\"!isConfirm\"\n    color=\"primary\"\n  ></ax-button>\n</ax-footer>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: AXLabelModule }, { kind: "component", type: i1.AXLabelComponent, selector: "ax-label", inputs: ["required", "for"], outputs: ["requiredChange"] }, { kind: "ngmodule", type: AXCheckBoxModule }, { kind: "component", type: i2.AXCheckBoxComponent, selector: "ax-check-box", inputs: ["disabled", "tabIndex", "readonly", "color", "value", "name", "id", "isLoading", "indeterminate"], outputs: ["onBlur", "onFocus", "valueChange", "onValueChanged"] }, { kind: "ngmodule", type: AXDecoratorModule }, { kind: "component", type: i3.AXDecoratorGenericComponent, selector: "ax-footer, ax-header, ax-content, ax-divider, ax-form-hint, ax-prefix, ax-suffix, ax-text, ax-title, ax-subtitle, ax-placeholder, ax-overlay" }, { kind: "ngmodule", type: AXButtonModule }, { kind: "component", type: i4.AXButtonComponent, selector: "ax-button", inputs: ["disabled", "size", "tabIndex", "color", "look", "text", "toggleable", "selected", "iconOnly", "type", "loadingText"], outputs: ["onBlur", "onFocus", "onClick", "selectedChange", "toggleableChange", "lookChange", "colorChange", "disabledChange", "loadingTextChange"] }, { kind: "ngmodule", type: AXTranslationModule }, { kind: "pipe", type: i5.AsyncPipe, name: "async" }, { kind: "pipe", type: i6.AXTranslatorPipe, name: "translate" }, { kind: "pipe", type: AXSafePipe, name: "safe" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMNotifyAppTermComponent, decorators: [{
            type: Component,
            args: [{ selector: 'axm-notify-app', imports: [
                        CommonModule,
                        AXLabelModule,
                        AXCheckBoxModule,
                        AXDecoratorModule,
                        AXButtonModule,
                        AXTranslationModule,
                        AXSafePipe,
                    ], template: "@for (item of data; track $index) {\n  <ax-content class=\"ax-block ax-px-4 ax-py-4 ax-font-bold\">{{ item.title }}</ax-content>\n  <ax-content\n    class=\"ax-block ax-px-4 ax-pb-4 ax-text-base/6\"\n    [innerHTML]=\"transformContent(item.content) | safe: 'html'\"\n  ></ax-content>\n}\n<ax-footer class=\"ax-flex ax-items-center ax-justify-between ax-p-2\">\n  <ax-check-box [(value)]=\"isConfirm\">\n    <ax-label>{{ 'agreeTerm' | translate: { scope: i18n } | async }}</ax-label>\n  </ax-check-box>\n  <ax-button\n    (click)=\"send()\"\n    [text]=\"'@general:actions.ok.title' | translate | async\"\n    [disabled]=\"!isConfirm\"\n    color=\"primary\"\n  ></ax-button>\n</ax-footer>\n" }]
        }] });

class AXMNotifyNewTermPopupAction extends AXPWorkflowAction {
    constructor() {
        super(...arguments);
        this.popupService = inject(AXPopupService);
    }
    async execute(context) {
        const data = context.getVariable();
        await this.popupService.open(AXMNotifyAppTermComponent, {
            title: 'New Terms And Conditions',
            data: { data },
            closeButton: false,
        });
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMNotifyNewTermPopupAction, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMNotifyNewTermPopupAction }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMNotifyNewTermPopupAction, decorators: [{
            type: Injectable
        }] });
class AXMTermUpdateSettingAction extends AXPWorkflowAction {
    constructor() {
        super(...arguments);
        this.settingService = inject(AXPSettingService);
    }
    async execute(context) {
        const dataList = context.getVariable();
        for (const data of dataList) {
            await this.settingService.scope(AXPPlatformScope.User).set(`is-confirm-term-${data.id}`, true);
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMTermUpdateSettingAction, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMTermUpdateSettingAction }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMTermUpdateSettingAction, decorators: [{
            type: Injectable
        }] });
const AXMNewTermWorkflow = {
    startStepId: 'show-popup',
    steps: {
        'show-popup': {
            action: 'AXMNotifyNewTermPopupAction',
            nextSteps: [
                {
                    conditions: [],
                    nextStepId: 'first-time-add-to-setting',
                },
            ],
        },
        'first-time-add-to-setting': {
            action: 'AXMTermUpdateSettingAction',
        },
    },
};

var AXPApplicationTermsSettings;
(function (AXPApplicationTermsSettings) {
    AXPApplicationTermsSettings["ApplicationTerms"] = "general:startup:application-terms";
})(AXPApplicationTermsSettings || (AXPApplicationTermsSettings = {}));

class AppTermsCheckService {
    constructor() {
        this.settingsService = inject(AXPSettingService);
        this.workflowService = inject(AXPWorkflowService);
        this.appTermService = inject(AXMAppTermService);
        this.appInitService = inject(AXPAppStartUpService);
        this.sessionService = inject(AXPSessionService);
        this.appInitService.registerTask({
            name: 'Terms',
            statusText: 'Check New Terms And Conditions...',
            priority: 6,
            run: async () => {
                this.sessionService.application$.subscribe(async (app) => {
                    if (app != null) {
                        const filterTerms = [];
                        const terms = await this.appTermService.query();
                        for (const term of terms.items) {
                            const isConfirm = await this.settingsService
                                .scope(AXPPlatformScope.User)
                                .get(`is-confirm-term-${term.id}`);
                            const isEnableToShow = await this.settingsService
                                .scope(AXPPlatformScope.User)
                                .get(AXPApplicationTermsSettings.ApplicationTerms);
                            if (!isConfirm && isEnableToShow) {
                                filterTerms.push(term);
                            }
                        }
                        if (filterTerms.length > 0) {
                            setTimeout(() => {
                                this.workflowService.execute('new-term', filterTerms);
                            }, 500);
                        }
                    }
                });
            },
        });
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AppTermsCheckService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AppTermsCheckService }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AppTermsCheckService, decorators: [{
            type: Injectable
        }], ctorParameters: () => [] });

class AXMContentManagementModule {
    /**
     * @ignore
     */
    constructor(appTermsCheck) { }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMContentManagementModule, deps: [{ token: AppTermsCheckService }], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.4", ngImport: i0, type: AXMContentManagementModule, imports: [i2$1.AXPWorkflowModule, i3$1.AXPComponentSlotModule, 
            // Entity Modules
            AXMPromotionEntityModule,
            AXMAppTermEntityModule,
            AXMGlossaryEntityModule] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMContentManagementModule, providers: [
            {
                provide: ROUTES,
                multi: true,
                useFactory: () => {
                    const config = inject(AXP_ENTITY_CONFIG_TOKEN);
                    const routes = [
                        {
                            path: ':app/terms',
                            loadComponent: () => {
                                return config.viewers.root();
                            },
                            children: [
                                {
                                    path: '',
                                    loadComponent: () => Promise.resolve().then(function () { return listTerms_component; }).then((c) => c.AXMListTermsComponent),
                                },
                            ],
                        },
                    ];
                    return routes;
                },
            },
            {
                provide: AXP_MENU_PROVIDER,
                useClass: AXMMenuProvider,
                multi: true,
            },
            {
                provide: AXP_ENTITY_DEFINITION_LOADER,
                useClass: AXMEntityProvider,
                multi: true,
            },
            {
                provide: AXP_SETTING_DEFINITION_PROVIDER,
                useClass: AXMSettingProvider,
                multi: true,
            },
            {
                provide: AXP_SEARCH_PROVIDER,
                useClass: AXMSearchCommandProvider,
                multi: true,
            },
            {
                provide: AXP_PERMISSION_DEFINITION_PROVIDER,
                useClass: AXMPermissionDefinitionProvider,
                multi: true,
            },
            {
                provide: AXP_DATASOURCE_DEFINITION_PROVIDER,
                useClass: AXMPromotionDataSourceDefinition,
                multi: true,
            },
            AppTermsCheckService
        ], imports: [AXPWorkflowModule.forChild({
                actions: {
                    AXMNotifyNewTermPopupAction,
                    AXMTermUpdateSettingAction,
                },
                workflows: {
                    'new-term': AXMNewTermWorkflow,
                },
            }),
            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,
            AXMAppTermEntityModule,
            AXMGlossaryEntityModule] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMContentManagementModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [
                        AXPWorkflowModule.forChild({
                            actions: {
                                AXMNotifyNewTermPopupAction,
                                AXMTermUpdateSettingAction,
                            },
                            workflows: {
                                'new-term': AXMNewTermWorkflow,
                            },
                        }),
                        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,
                        AXMAppTermEntityModule,
                        AXMGlossaryEntityModule,
                    ],
                    exports: [],
                    declarations: [],
                    providers: [
                        {
                            provide: ROUTES,
                            multi: true,
                            useFactory: () => {
                                const config = inject(AXP_ENTITY_CONFIG_TOKEN);
                                const routes = [
                                    {
                                        path: ':app/terms',
                                        loadComponent: () => {
                                            return config.viewers.root();
                                        },
                                        children: [
                                            {
                                                path: '',
                                                loadComponent: () => Promise.resolve().then(function () { return listTerms_component; }).then((c) => c.AXMListTermsComponent),
                                            },
                                        ],
                                    },
                                ];
                                return routes;
                            },
                        },
                        {
                            provide: AXP_MENU_PROVIDER,
                            useClass: AXMMenuProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_ENTITY_DEFINITION_LOADER,
                            useClass: AXMEntityProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_SETTING_DEFINITION_PROVIDER,
                            useClass: AXMSettingProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_SEARCH_PROVIDER,
                            useClass: AXMSearchCommandProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_PERMISSION_DEFINITION_PROVIDER,
                            useClass: AXMPermissionDefinitionProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_DATASOURCE_DEFINITION_PROVIDER,
                            useClass: AXMPromotionDataSourceDefinition,
                            multi: true,
                        },
                        AppTermsCheckService
                    ]
                }]
        }], ctorParameters: () => [{ type: AppTermsCheckService }] });

class AXMListTermsComponent extends AXPPageLayoutBaseComponent {
    constructor() {
        super(...arguments);
        this.service = inject(AXMAppTermService);
        this.terms = [];
        this.loaded = signal(false, ...(ngDevMode ? [{ debugName: "loaded" }] : []));
        this.showScrollSide = signal(true, ...(ngDevMode ? [{ debugName: "showScrollSide" }] : []));
    }
    ngAfterViewInit() {
        this.checkScroll();
    }
    onResize() {
        this.checkScroll();
    }
    checkScroll() {
        const contentElement = document.getElementById('contentDiv');
        if (contentElement != null) {
            this.showScrollSide.set(contentElement.offsetHeight > window.innerHeight - 140);
        }
    }
    async ngOnInit() {
        super.ngOnInit();
        const result = await this.service.query({
            skip: 0,
            take: 1000,
        });
        this.terms = result.items.map((term) => {
            return {
                ...term,
                content: term.content.replace(/\n/g, '<br>'),
            };
        });
        this.loaded.set(true);
        setTimeout(() => this.checkScroll(), 50);
    }
    getPageTitle() {
        return `t("app-term.page-title", {scope:"${RootConfig.config.i18n}"})`;
    }
    getPageDescription() {
        return `t("app-term.page-description", {scope:"${RootConfig.config.i18n}"})`;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMListTermsComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.4", type: AXMListTermsComponent, isStandalone: true, selector: "ng-component", host: { listeners: { "window:resize": "onResize()" } }, providers: [
            {
                provide: AXPPageLayoutBase,
                useExisting: AXMListTermsComponent,
            },
        ], usesInheritance: true, ngImport: i0, template: "<axp-page-layout *translate=\"let t\">\n  @if(loaded()){\n  <axp-page-content id=\"contentDiv\" axOutlineContainer target=\"h2\" [scrollableElementId]=\"'axp-page-layout'\"\n    [activationOffset]=\"120\" class=\"ax-flex ax-flex-row\">\n    <div class=\"ax-flex ax-flex-col\">\n      @for (term of terms; track term.id) {\n      <div class=\"ax-flex ax-flex-col\">\n        <h2 class=\"ax-px-4 ax-font-semibold ax-text-xl\">{{ term.title }}</h2>\n        <p class=\"ax-px-4 ax-text-sm ax-leading-5  ax-opacity-65\">\n          {{ term.effectiveDate | format : 'datetime' | async }}\n        </p>\n        <div class=\"ax-pt-3 ax-pb-6 ax-px-4 ax-text-base/6\" [innerHTML]=\"term.content | safe:'html'\"></div>\n      </div>\n      }\n    </div>\n    @if(showScrollSide()){\n    <div class=\"ax-hidden lg:ax-block ax-min-w-60\">\n      <ax-side-menu axOutlineSideMenu look=\"with-line\" class=\"ax-w-full ax-sticky ax-top-24\"></ax-side-menu>\n    </div>\n    }\n  </axp-page-content>\n  }\n</axp-page-layout>", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: AXDecoratorModule }, { kind: "ngmodule", type: AXFormatModule }, { kind: "component", type: AXPThemeLayoutBlockComponent, selector: "    axp-page-content,     axp-page-footer-container,    axp-page-footer,    axp-page-header,    axp-page-header-container,    axp-page-toolbar,    axp-layout-content,     axp-layout-page-content,     axp-layout-sections,    axp-layout-body,    axp-layout-page-body,    axp-layout-prefix,    axp-layout-suffix,    axp-layout-title-bar,    axp-layout-title,     axp-layout-title-actions,     axp-layout-nav-button,     axp-layout-description,     axp-layout-breadcrumbs,    axp-layout-list-action,    " }, { kind: "ngmodule", type: AXTranslationModule }, { kind: "directive", type: i6.AXTranslatorDirective, selector: "[translate]" }, { kind: "ngmodule", type: AXSideMenuModule }, { kind: "component", type: i2$2.AXSideMenuComponent, selector: "ax-side-menu", inputs: ["items", "look", "location"], outputs: ["itemsChange"] }, { kind: "directive", type: i2$2.AXOutlineSideMenuDirective, selector: "[axOutlineSideMenu]", exportAs: ["axOutlineSideMenu"] }, { kind: "component", type: AXPPageLayoutComponent, selector: "axp-page-layout" }, { kind: "directive", type: AXOutlineContainerDirective, selector: "[axOutlineContainer]", inputs: ["target", "smoothScroll", "showHashItem", "activationOffset", "copyUrlOnClick", "activateLastAtBottom", "scrollableElementId"], exportAs: ["axOutlineContainer"] }, { kind: "pipe", type: i5.AsyncPipe, name: "async" }, { kind: "pipe", type: i4$1.AXFormatPipe, name: "format" }, { kind: "pipe", type: AXSafePipe, name: "safe" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMListTermsComponent, decorators: [{
            type: Component,
            args: [{ imports: [
                        CommonModule,
                        AXDecoratorModule,
                        AXFormatModule,
                        AXPThemeLayoutBlockComponent,
                        AXTranslationModule,
                        AXSideMenuModule,
                        AXPPageLayoutComponent,
                        AXSafePipe,
                        AXOutlineContainerDirective,
                        AXOutlineSideMenuDirective,
                    ], providers: [
                        {
                            provide: AXPPageLayoutBase,
                            useExisting: AXMListTermsComponent,
                        },
                    ], template: "<axp-page-layout *translate=\"let t\">\n  @if(loaded()){\n  <axp-page-content id=\"contentDiv\" axOutlineContainer target=\"h2\" [scrollableElementId]=\"'axp-page-layout'\"\n    [activationOffset]=\"120\" class=\"ax-flex ax-flex-row\">\n    <div class=\"ax-flex ax-flex-col\">\n      @for (term of terms; track term.id) {\n      <div class=\"ax-flex ax-flex-col\">\n        <h2 class=\"ax-px-4 ax-font-semibold ax-text-xl\">{{ term.title }}</h2>\n        <p class=\"ax-px-4 ax-text-sm ax-leading-5  ax-opacity-65\">\n          {{ term.effectiveDate | format : 'datetime' | async }}\n        </p>\n        <div class=\"ax-pt-3 ax-pb-6 ax-px-4 ax-text-base/6\" [innerHTML]=\"term.content | safe:'html'\"></div>\n      </div>\n      }\n    </div>\n    @if(showScrollSide()){\n    <div class=\"ax-hidden lg:ax-block ax-min-w-60\">\n      <ax-side-menu axOutlineSideMenu look=\"with-line\" class=\"ax-w-full ax-sticky ax-top-24\"></ax-side-menu>\n    </div>\n    }\n  </axp-page-content>\n  }\n</axp-page-layout>" }]
        }], propDecorators: { onResize: [{
                type: HostListener,
                args: ['window:resize']
            }] } });

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

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

export { AXMAppPromotionService, AXMAppTermEntityModule, AXMAppTermService, AXMAppTermServiceImpl, AXMContentManagementModule, AXMEntityProvider, AXMGlossaryEntityModule, AXMGlossaryService, AXMGlossaryServiceImpl, AXMListTermsComponent, AXMMenuProvider, AXMNotifyAppTermComponent, AXMPromotionDataSourceDefinition, AXMPromotionEntityModule, AXMPromotionServiceImpl, AXMPromotionSlotComponent, AXMSearchCommandProvider, AXMSettingProvider, RootConfig, appTermEntityEntityFactory, glossaryEntityFactory, promotionEntityFactory };
//# sourceMappingURL=acorex-modules-content-management.mjs.map
