import * as i0 from '@angular/core';
import { Injectable, inject, NgModule } from '@angular/core';
import { AXP_MODULE_MANIFEST_PROVIDER, objectKeyValueTransforms } from '@acorex/platform/core';
import { AXPEntityService, AXP_ENTITY_DEFINITION_LOADER, entityMasterCrudActions, entityMasterRecordActions } from '@acorex/platform/layout/entity';
import { AXP_MENU_PROVIDER, createAllQueryView, AXPSearchCommandProvider } from '@acorex/platform/common';
import { AXP_PERMISSION_DEFINITION_PROVIDER } from '@acorex/platform/auth';
import { AXTranslationService } from '@acorex/core/translation';
import { AXPCommonMenuKeys, AXPWidgetsList } from '@acorex/modules/common';

const config = {
    i18n: 'measurement-core',
    module: 'MeasurementCore',
};
const RootConfig = {
    config,
    module: {
        name: config.module,
        title: `@${config.i18n}:module.title`,
        icon: 'fa-light fa-ruler-combined',
    },
    entities: {
        unitOfMeasure: {
            name: 'UnitOfMeasure',
            title: `@${config.i18n}:units.entities.unit-of-measure.title`,
            titlePlural: `@${config.i18n}:units.entities.unit-of-measure.plural`,
            icon: 'fa-light fa-ruler',
        },
        unitConversion: {
            name: 'UnitConversion',
            title: `@${config.i18n}:conversions.entities.unit-conversion.title`,
            titlePlural: `@${config.i18n}:conversions.entities.unit-conversion.plural`,
            icon: 'fa-light fa-arrows-rotate',
        },
        unitOfMeasureType: {
            name: 'UnitOfMeasureType',
            title: `@${config.i18n}:types.entities.unit-of-measure-type.title`,
            titlePlural: `@${config.i18n}:types.entities.unit-of-measure-type.plural`,
            icon: 'fa-light fa-tags',
        },
        unitOfMeasureGroup: {
            name: 'UnitOfMeasureGroup',
            title: `@${config.i18n}:groups.entities.unit-of-measure-group.title`,
            titlePlural: `@${config.i18n}:groups.entities.unit-of-measure-group.plural`,
            icon: 'fa-light fa-layer-group',
        },
        quantityType: {
            name: 'QuantityType',
            title: `@${config.i18n}:quantity-types.entities.quantity-type.title`,
            titlePlural: `@${config.i18n}:quantity-types.entities.quantity-type.plural`,
            icon: 'fa-light fa-calculator',
        },
        measurementDimension: {
            name: 'MeasurementDimension',
            title: `@${config.i18n}:dimensions.entities.measurement-dimension.title`,
            titlePlural: `@${config.i18n}:dimensions.entities.measurement-dimension.plural`,
            icon: 'fa-light fa-cube',
        },
        measurementRange: {
            name: 'MeasurementRange',
            title: `@${config.i18n}:ranges.entities.measurement-range.title`,
            titlePlural: `@${config.i18n}:ranges.entities.measurement-range.plural`,
            icon: 'fa-light fa-chart-line-up',
        },
    },
};

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

const AXMMeasurementCorePermissionKeys = {
    MeasurementCore: {
        Group: 'MeasurementCore:Permission:Group',
        UnitOfMeasure: {
            Management: 'MeasurementCore:Permission:UnitOfMeasure.Management',
        },
        UnitConversion: {
            Management: 'MeasurementCore:Permission:UnitConversion.Management',
        },
        UnitOfMeasureType: {
            Management: 'MeasurementCore:Permission:UnitOfMeasureType.Management',
        },
        UnitOfMeasureGroup: {
            Management: 'MeasurementCore:Permission:UnitOfMeasureGroup.Management',
        },
        QuantityType: {
            Management: 'MeasurementCore:Permission:QuantityType.Management',
        },
    },
};

//#region ----   Imports   ----
//#endregion
//#region ----   Permission Definition Provider   ----
class AXMMeasurementCorePermissionDefinitionProvider {
    constructor(injector) {
        this.injector = injector;
        this.translationService = this.injector.get(AXTranslationService);
    }
    async define(context) {
        const keys = AXMMeasurementCorePermissionKeys.MeasurementCore;
        const moduleTitle = await this.translationService.translateAsync('@measurement-core:module.title');
        const unitOfMeasureTrans = (action) => this.translationService.translateAsync(`@measurement-core:units.permissions.unit-of-measure.actions.${action}.title`);
        const unitConversionTrans = (action) => this.translationService.translateAsync(`@measurement-core:conversions.permissions.unit-conversion.actions.${action}.title`);
        const unitOfMeasureTypeTrans = (action) => this.translationService.translateAsync(`@measurement-core:types.permissions.unit-of-measure-type.actions.${action}.title`);
        const unitOfMeasureGroupTrans = (action) => this.translationService.translateAsync(`@measurement-core:groups.permissions.unit-of-measure-group.actions.${action}.title`);
        const quantityTypeTrans = (action) => this.translationService.translateAsync(`@measurement-core:quantity-types.permissions.quantity-type.actions.${action}.title`);
        context
            .addGroup(RootConfig.module.name, moduleTitle)
            .addPermission(keys.UnitOfMeasure.Management, await unitOfMeasureTrans('manage'))
            .endPermission()
            .addPermission(keys.UnitConversion.Management, await unitConversionTrans('manage'))
            .endPermission()
            .addPermission(keys.UnitOfMeasureType.Management, await unitOfMeasureTypeTrans('manage'))
            .endPermission()
            .addPermission(keys.UnitOfMeasureGroup.Management, await unitOfMeasureGroupTrans('manage'))
            .endPermission()
            .addPermission(keys.QuantityType.Management, await quantityTypeTrans('manage'))
            .endPermission()
            .endGroup();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMMeasurementCorePermissionDefinitionProvider, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMMeasurementCorePermissionDefinitionProvider }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMMeasurementCorePermissionDefinitionProvider, decorators: [{
            type: Injectable
        }], ctorParameters: () => [{ type: i0.Injector }] });

const AXMMeasurementCoreMenuKeys = {
    Root: 'measurement-core',
    UnitsOfMeasure: 'measurement-core.units-of-measure',
    UnitConversions: 'measurement-core.unit-conversions',
    UnitOfMeasureTypes: 'measurement-core.unit-of-measure-types',
    UnitOfMeasureGroups: 'measurement-core.unit-of-measure-groups',
    QuantityTypes: 'measurement-core.quantity-types',
    MeasurementDimensions: 'measurement-core.measurement-dimensions',
    MeasurementRanges: 'measurement-core.measurement-ranges',
};

//#region ----   Imports   ----
//#endregion
//#region ----   Menu Provider   ----
class AXMMeasurementCoreMenuProvider {
    constructor() {
        this.entityService = inject(AXPEntityService);
    }
    async provide(context) {
        const module = RootConfig.module;
        context.find(AXPCommonMenuKeys.Configuration).addItems([
            {
                name: AXMMeasurementCoreMenuKeys.Root,
                priority: 8800,
                text: "@measurement-core:module.menus.root.title",
                icon: module.icon,
                policy: {
                    features: [module.name],
                },
                children: [
                    {
                        name: AXMMeasurementCoreMenuKeys.UnitsOfMeasure,
                        text: RootConfig.entities.unitOfMeasure.titlePlural,
                        icon: RootConfig.entities.unitOfMeasure.icon,
                        priority: 1,
                        path: this.entityService.createPath(module.name, RootConfig.entities.unitOfMeasure.name),
                    },
                    {
                        name: AXMMeasurementCoreMenuKeys.UnitConversions,
                        text: RootConfig.entities.unitConversion.titlePlural,
                        icon: RootConfig.entities.unitConversion.icon,
                        priority: 2,
                        path: this.entityService.createPath(module.name, RootConfig.entities.unitConversion.name),
                    },
                    {
                        name: AXMMeasurementCoreMenuKeys.UnitOfMeasureTypes,
                        text: RootConfig.entities.unitOfMeasureType.titlePlural,
                        icon: RootConfig.entities.unitOfMeasureType.icon,
                        priority: 3,
                        path: this.entityService.createPath(module.name, RootConfig.entities.unitOfMeasureType.name),
                    },
                    {
                        name: AXMMeasurementCoreMenuKeys.UnitOfMeasureGroups,
                        text: RootConfig.entities.unitOfMeasureGroup.titlePlural,
                        icon: RootConfig.entities.unitOfMeasureGroup.icon,
                        priority: 4,
                        path: this.entityService.createPath(module.name, RootConfig.entities.unitOfMeasureGroup.name),
                    },
                    {
                        name: AXMMeasurementCoreMenuKeys.QuantityTypes,
                        text: RootConfig.entities.quantityType.titlePlural,
                        icon: RootConfig.entities.quantityType.icon,
                        priority: 5,
                        path: this.entityService.createPath(module.name, RootConfig.entities.quantityType.name),
                    },
                    {
                        name: AXMMeasurementCoreMenuKeys.MeasurementDimensions,
                        text: RootConfig.entities.measurementDimension.titlePlural,
                        icon: RootConfig.entities.measurementDimension.icon,
                        priority: 6,
                        path: this.entityService.createPath(module.name, RootConfig.entities.measurementDimension.name),
                    },
                    {
                        name: AXMMeasurementCoreMenuKeys.MeasurementRanges,
                        text: RootConfig.entities.measurementRange.titlePlural,
                        icon: RootConfig.entities.measurementRange.icon,
                        priority: 7,
                        path: this.entityService.createPath(module.name, RootConfig.entities.measurementRange.name),
                    },
                ],
            },
        ]);
    }
}
//#endregion

//#region ----   Imports   ----
//#endregion
//#region ----   Entity Provider   ----
class AXMMeasurementCoreEntityProvider {
    constructor(injector) {
        this.injector = injector;
    }
    async get(moduleName, entityName) {
        if (moduleName !== RootConfig.module.name) {
            return null;
        }
        switch (entityName) {
            case RootConfig.entities.unitOfMeasure.name:
                return (await Promise.resolve().then(function () { return unitOfMeasure_entity; })).unitOfMeasureFactory(this.injector);
            case RootConfig.entities.unitConversion.name:
                return (await Promise.resolve().then(function () { return unitConversion_entity; })).unitConversionFactory(this.injector);
            case RootConfig.entities.unitOfMeasureType.name:
                return (await Promise.resolve().then(function () { return unitOfMeasureType_entity; })).unitOfMeasureTypeFactory(this.injector);
            case RootConfig.entities.unitOfMeasureGroup.name:
                return (await Promise.resolve().then(function () { return unitOfMeasureGroup_entity; })).unitOfMeasureGroupFactory(this.injector);
            case RootConfig.entities.quantityType.name:
                return (await Promise.resolve().then(function () { return quantityType_entity; })).quantityTypeFactory(this.injector);
            case RootConfig.entities.measurementDimension.name:
                return (await Promise.resolve().then(function () { return measurementDimension_entity; })).measurementDimensionFactory(this.injector);
            case RootConfig.entities.measurementRange.name:
                return (await Promise.resolve().then(function () { return measurementRange_entity; })).measurementRangeFactory(this.injector);
        }
        return null;
    }
    async list() {
        const m = RootConfig.module.name;
        return Promise.resolve(Object.values(RootConfig.entities).map((e) => ({ name: e.name, module: m })));
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMMeasurementCoreEntityProvider, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMMeasurementCoreEntityProvider }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMMeasurementCoreEntityProvider, decorators: [{
            type: Injectable
        }], ctorParameters: () => [{ type: i0.Injector }] });

//#region ----   Imports   ----
//#endregion
//#region ----   Module   ----
class AXMMeasurementCoreModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMMeasurementCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.19", ngImport: i0, type: AXMMeasurementCoreModule }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMMeasurementCoreModule, providers: [
            // Module Manifest Provider
            {
                provide: AXP_MODULE_MANIFEST_PROVIDER,
                useValue: MeasurementCoreManifest,
                multi: true,
            },
            // Provider references (now using tokens)
            {
                provide: AXP_PERMISSION_DEFINITION_PROVIDER,
                useClass: AXMMeasurementCorePermissionDefinitionProvider,
                multi: true,
            },
            {
                provide: AXP_MENU_PROVIDER,
                useClass: AXMMeasurementCoreMenuProvider,
                multi: true,
            },
            {
                provide: AXP_ENTITY_DEFINITION_LOADER,
                useClass: AXMMeasurementCoreEntityProvider,
                multi: true,
            },
        ] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMMeasurementCoreModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [],
                    providers: [
                        // Module Manifest Provider
                        {
                            provide: AXP_MODULE_MANIFEST_PROVIDER,
                            useValue: MeasurementCoreManifest,
                            multi: true,
                        },
                        // Provider references (now using tokens)
                        {
                            provide: AXP_PERMISSION_DEFINITION_PROVIDER,
                            useClass: AXMMeasurementCorePermissionDefinitionProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_MENU_PROVIDER,
                            useClass: AXMMeasurementCoreMenuProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_ENTITY_DEFINITION_LOADER,
                            useClass: AXMMeasurementCoreEntityProvider,
                            multi: true,
                        },
                    ],
                }]
        }] });

//#region ----   Unit of Measure Model   ----
//#endregion

//#region ----   Imports   ----
//#endregion
//#region ----   Entity Factory   ----
async function unitOfMeasureFactory(injector) {
    const sections = [
        { id: 'basic-info', layout: { positions: { lg: { colSpan: 12 } } } },
        { id: 'configuration', layout: { positions: { lg: { colSpan: 12 } } } },
    ];
    const propertyLayouts = [
        { name: 'code', layout: { positions: { lg: { colSpan: 4, order: 1 } } } },
        { name: 'title', layout: { positions: { lg: { colSpan: 5, order: 2 } } } },
        { name: 'symbol', layout: { positions: { lg: { colSpan: 3, order: 3 } } } },
        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 4 } } } },
        { name: 'typeId', layout: { positions: { lg: { colSpan: 6, order: 5 } } } },
        { name: 'groupId', layout: { positions: { lg: { colSpan: 6, order: 6 } } } },
        { name: 'isBaseUnit', layout: { positions: { lg: { colSpan: 3, order: 7 } } } },
        { name: 'decimalPlaces', layout: { positions: { lg: { colSpan: 3, order: 8 } } } },
    ];
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.unitOfMeasure.name,
        title: RootConfig.entities.unitOfMeasure.title,
        icon: RootConfig.entities.unitOfMeasure.icon,
        formats: {
            individual: RootConfig.entities.unitOfMeasure.title,
            plural: RootConfig.entities.unitOfMeasure.titlePlural,
            searchResult: {
                title: '{{ title }}',
                description: '{{ code }} ({{ symbol }})',
            },
        },
        plugins: [{ name: 'history' }, { name: 'compare' }, { name: 'disable' }],
        groups: [
            { id: 'basic-info', title: '@measurement-core:units.entities.unit-of-measure.groups.basic-info' },
            { id: 'configuration', title: '@measurement-core:units.entities.unit-of-measure.groups.configuration' },
        ],
        properties: [
            {
                name: 'id',
                title: '@general:terms.common.id',
                groupId: 'basic-info',
                schema: {
                    dataType: 'uuid',
                    visible: false,
                    readonly: true,
                    unique: { enabled: true },
                },
            },
            {
                name: 'code',
                title: '@general:terms.common.code',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.TextBox,
                        options: {
                            placeholder: '@measurement-core:units.entities.unit-of-measure.fields.code.placeholder',
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'title',
                title: '@general:terms.common.title',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.TextBox,
                        options: {
                            placeholder: '@measurement-core:units.entities.unit-of-measure.fields.title.placeholder',
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'symbol',
                title: '@measurement-core:units.entities.unit-of-measure.fields.symbol.title',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.TextBox,
                        options: {
                            maxLength: 10,
                            placeholder: '@measurement-core:units.entities.unit-of-measure.fields.symbol.placeholder',
                        },
                    },
                },
            },
            {
                name: 'description',
                title: '@general:terms.common.description',
                groupId: 'basic-info',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LargeTextBox,
                        options: {
                            rows: 3,
                            placeholder: '@measurement-core:units.entities.unit-of-measure.fields.description.placeholder',
                        },
                    },
                },
            },
            {
                name: 'typeId',
                title: '@measurement-core:units.entities.unit-of-measure.fields.type.title',
                groupId: 'configuration',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LookupBox,
                        options: {
                            entity: `${RootConfig.module.name}.${RootConfig.entities.unitOfMeasureType.name}`,
                            expose: [
                                { source: 'id', target: 'typeId' },
                                { source: 'title', target: 'type.title' },
                                { source: 'code', target: 'type.code' },
                            ],
                        },
                    },
                },
            },
            {
                name: 'groupId',
                title: '@measurement-core:units.entities.unit-of-measure.fields.group.title',
                groupId: 'configuration',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LookupBox,
                        options: {
                            entity: `${RootConfig.module.name}.${RootConfig.entities.unitOfMeasureGroup.name}`,
                            expose: [
                                { source: 'id', target: 'groupId' },
                                { source: 'title', target: 'group.title' },
                                { source: 'code', target: 'group.code' },
                            ],
                        },
                    },
                },
            },
            {
                name: 'isBaseUnit',
                title: '@measurement-core:units.entities.unit-of-measure.fields.is-base-unit.title',
                groupId: 'configuration',
                schema: {
                    dataType: 'boolean',
                    interface: {
                        type: AXPWidgetsList.Editors.ToggleSwitch,
                        options: {
                            trulyText: '@general:terms.common.yes-no.yes',
                            falsyText: '@general:terms.common.yes-no.no',
                        },
                    },
                },
            },
            {
                name: 'decimalPlaces',
                title: '@measurement-core:units.entities.unit-of-measure.fields.decimal-places.title',
                groupId: 'configuration',
                schema: {
                    dataType: 'number',
                    interface: {
                        type: AXPWidgetsList.Editors.NumberBox,
                        options: {
                            minValue: 0,
                            maxValue: 10,
                            placeholder: '@measurement-core:units.entities.unit-of-measure.fields.decimal-places.placeholder',
                        },
                    },
                },
            },
        ],
        columns: [
            { name: 'code', options: { width: '120px', order: 1 } },
            { name: 'title', options: { width: '220px', order: 2 } },
            { name: 'symbol', options: { width: '100px', order: 3 } },
            { name: 'typeId', options: { width: '180px', order: 4, dataPath: 'type.title' } },
            { name: 'groupId', options: { width: '180px', order: 5, dataPath: 'group.title' } },
            { name: 'isBaseUnit', options: { width: '120px', order: 6 } },
        ],
        interfaces: {
            master: {
                create: {
                    sections,
                    properties: propertyLayouts,
                },
                update: {
                    sections,
                    properties: propertyLayouts,
                },
                single: {
                    title: '{{ title }}',
                    sections,
                    properties: propertyLayouts,
                    actions: [...entityMasterRecordActions()],
                },
                list: {
                    actions: [...entityMasterCrudActions()],
                    views: [
                        createAllQueryView({
                            sorts: [{ name: 'code', dir: 'asc' }],
                        }),
                    ],
                },
            },
        },
    };
    return entityDef;
}
//#endregion

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

//#region ----   Unit Conversion Model   ----
//#endregion

//#region ----   Imports   ----
//#endregion
//#region ----   Entity Factory   ----
async function unitConversionFactory(injector) {
    const sections = [
        { id: 'basic-info', layout: { positions: { lg: { colSpan: 12 } } } },
        { id: 'conversion', layout: { positions: { lg: { colSpan: 12 } } } },
    ];
    const propertyLayouts = [
        { name: 'code', layout: { positions: { lg: { colSpan: 4, order: 1 } } } },
        { name: 'title', layout: { positions: { lg: { colSpan: 8, order: 2 } } } },
        { name: 'fromUnitId', layout: { positions: { lg: { colSpan: 6, order: 3 } } } },
        { name: 'toUnitId', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
        { name: 'conversionFactor', layout: { positions: { lg: { colSpan: 6, order: 5 } } } },
        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 6 } } } },
    ];
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.unitConversion.name,
        title: RootConfig.entities.unitConversion.title,
        icon: RootConfig.entities.unitConversion.icon,
        formats: {
            individual: RootConfig.entities.unitConversion.title,
            plural: RootConfig.entities.unitConversion.titlePlural,
            searchResult: {
                title: '{{ title || code }}',
                description: '{{ fromUnit.title }} → {{ toUnit.title }}',
            },
        },
        plugins: [{ name: 'history' }, { name: 'compare' }, { name: 'disable' }],
        groups: [
            { id: 'basic-info', title: '@measurement-core:conversions.entities.unit-conversion.groups.basic-info' },
            { id: 'conversion', title: '@measurement-core:conversions.entities.unit-conversion.groups.conversion' },
        ],
        properties: [
            {
                name: 'id',
                title: '@general:terms.common.id',
                groupId: 'basic-info',
                schema: {
                    dataType: 'uuid',
                    visible: false,
                    readonly: true,
                    unique: { enabled: true },
                },
            },
            {
                name: 'code',
                title: '@general:terms.common.code',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.TextBox,
                        options: {
                            placeholder: '@measurement-core:conversions.entities.unit-conversion.fields.code.placeholder',
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'title',
                title: '@general:terms.common.title',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.TextBox,
                        options: {
                            placeholder: '@measurement-core:conversions.entities.unit-conversion.fields.title.placeholder',
                        },
                    },
                },
            },
            {
                name: 'fromUnitId',
                title: '@measurement-core:conversions.entities.unit-conversion.fields.from-unit.title',
                groupId: 'conversion',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LookupBox,
                        options: {
                            entity: `${RootConfig.module.name}.${RootConfig.entities.unitOfMeasure.name}`,
                            expose: [
                                { source: 'id', target: 'fromUnitId' },
                                { source: 'title', target: 'fromUnit.title' },
                                { source: 'symbol', target: 'fromUnit.symbol' },
                            ],
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'toUnitId',
                title: '@measurement-core:conversions.entities.unit-conversion.fields.to-unit.title',
                groupId: 'conversion',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LookupBox,
                        options: {
                            entity: `${RootConfig.module.name}.${RootConfig.entities.unitOfMeasure.name}`,
                            expose: [
                                { source: 'id', target: 'toUnitId' },
                                { source: 'title', target: 'toUnit.title' },
                                { source: 'symbol', target: 'toUnit.symbol' },
                            ],
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'conversionFactor',
                title: '@measurement-core:conversions.entities.unit-conversion.fields.conversion-factor.title',
                groupId: 'conversion',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'number',
                    interface: {
                        type: AXPWidgetsList.Editors.NumberBox,
                        options: {
                            minValue: 0.000001,
                            placeholder: '@measurement-core:conversions.entities.unit-conversion.fields.conversion-factor.placeholder',
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'description',
                title: '@general:terms.common.description',
                groupId: 'basic-info',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LargeTextBox,
                        options: {
                            rows: 3,
                            placeholder: '@measurement-core:conversions.entities.unit-conversion.fields.description.placeholder',
                        },
                    },
                },
            },
        ],
        columns: [
            { name: 'code', options: { width: '120px', order: 1 } },
            { name: 'title', options: { width: '220px', order: 2 } },
            { name: 'fromUnitId', options: { width: '150px', order: 3, dataPath: 'fromUnit.title' } },
            { name: 'toUnitId', options: { width: '150px', order: 4, dataPath: 'toUnit.title' } },
            { name: 'conversionFactor', options: { width: '150px', order: 5 } },
        ],
        interfaces: {
            master: {
                create: {
                    sections,
                    properties: propertyLayouts,
                },
                update: {
                    sections,
                    properties: propertyLayouts,
                },
                single: {
                    title: '{{ title || code }}',
                    sections,
                    properties: propertyLayouts,
                    actions: [...entityMasterRecordActions()],
                },
                list: {
                    actions: [...entityMasterCrudActions()],
                    views: [
                        createAllQueryView({
                            sorts: [{ name: 'code', dir: 'asc' }],
                        }),
                    ],
                },
            },
        },
    };
    return entityDef;
}
//#endregion

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

//#region ----   Unit of Measure Type Model   ----
//#endregion

//#region ----   Imports   ----
//#endregion
//#region ----   Entity Factory   ----
async function unitOfMeasureTypeFactory(injector) {
    const sections = [{ id: 'basic-info', layout: { positions: { lg: { colSpan: 12 } } } }];
    const propertyLayouts = [
        { name: 'code', layout: { positions: { lg: { colSpan: 4, order: 1 } } } },
        { name: 'title', layout: { positions: { lg: { colSpan: 8, order: 2 } } } },
        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 3 } } } },
    ];
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.unitOfMeasureType.name,
        title: RootConfig.entities.unitOfMeasureType.title,
        icon: RootConfig.entities.unitOfMeasureType.icon,
        formats: {
            individual: RootConfig.entities.unitOfMeasureType.title,
            plural: RootConfig.entities.unitOfMeasureType.titlePlural,
            searchResult: {
                title: '{{ title }}',
                description: '{{ code }}',
            },
        },
        plugins: [{ name: 'history' }, { name: 'compare' }, { name: 'disable' }],
        groups: [{ id: 'basic-info', title: '@measurement-core:types.entities.unit-of-measure-type.groups.basic-info' }],
        properties: [
            {
                name: 'id',
                title: '@general:terms.common.id',
                groupId: 'basic-info',
                schema: {
                    dataType: 'uuid',
                    visible: false,
                    readonly: true,
                    unique: { enabled: true },
                },
            },
            {
                name: 'code',
                title: '@general:terms.common.code',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.TextBox,
                        options: {
                            placeholder: '@measurement-core:types.entities.unit-of-measure-type.fields.code.placeholder',
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'title',
                title: '@general:terms.common.title',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.TextBox,
                        options: {
                            placeholder: '@measurement-core:types.entities.unit-of-measure-type.fields.title.placeholder',
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'description',
                title: '@general:terms.common.description',
                groupId: 'basic-info',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LargeTextBox,
                        options: {
                            rows: 3,
                            placeholder: '@measurement-core:types.entities.unit-of-measure-type.fields.description.placeholder',
                        },
                    },
                },
            },
        ],
        columns: [
            { name: 'code', options: { width: '120px', order: 1 } },
            { name: 'title', options: { width: '220px', order: 2 } },
        ],
        interfaces: {
            master: {
                create: {
                    sections,
                    properties: propertyLayouts,
                },
                update: {
                    sections,
                    properties: propertyLayouts,
                },
                single: {
                    title: '{{ title }}',
                    sections,
                    properties: propertyLayouts,
                    actions: [...entityMasterRecordActions()],
                },
                list: {
                    actions: [...entityMasterCrudActions()],
                    views: [
                        createAllQueryView({
                            sorts: [{ name: 'code', dir: 'asc' }],
                        }),
                    ],
                },
            },
        },
    };
    return entityDef;
}
//#endregion

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

//#region ----   Unit of Measure Group Model   ----
//#endregion

//#region ----   Imports   ----
//#endregion
//#region ----   Entity Factory   ----
async function unitOfMeasureGroupFactory(injector) {
    const sections = [{ id: 'basic-info', layout: { positions: { lg: { colSpan: 12 } } } }];
    const propertyLayouts = [
        { name: 'code', layout: { positions: { lg: { colSpan: 4, order: 1 } } } },
        { name: 'title', layout: { positions: { lg: { colSpan: 8, order: 2 } } } },
        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 3 } } } },
        { name: 'allowedUoms', layout: { positions: { lg: { colSpan: 12, order: 4 } } } },
    ];
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.unitOfMeasureGroup.name,
        title: RootConfig.entities.unitOfMeasureGroup.title,
        icon: RootConfig.entities.unitOfMeasureGroup.icon,
        formats: {
            individual: RootConfig.entities.unitOfMeasureGroup.title,
            plural: RootConfig.entities.unitOfMeasureGroup.titlePlural,
            searchResult: {
                title: '{{ title }}',
                description: '{{ code }}',
            },
        },
        plugins: [{ name: 'history' }, { name: 'compare' }, { name: 'disable' }],
        groups: [{ id: 'basic-info', title: '@measurement-core:groups.entities.unit-of-measure-group.groups.basic-info' }],
        properties: [
            {
                name: 'id',
                title: '@general:terms.common.id',
                groupId: 'basic-info',
                schema: {
                    dataType: 'uuid',
                    visible: false,
                    readonly: true,
                    unique: { enabled: true },
                },
            },
            {
                name: 'code',
                title: '@general:terms.common.code',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.TextBox,
                        options: {
                            placeholder: '@measurement-core:groups.entities.unit-of-measure-group.fields.code.placeholder',
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'title',
                title: '@general:terms.common.title',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.TextBox,
                        options: {
                            placeholder: '@measurement-core:groups.entities.unit-of-measure-group.fields.title.placeholder',
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'description',
                title: '@general:terms.common.description',
                groupId: 'basic-info',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LargeTextBox,
                        options: {
                            rows: 3,
                            placeholder: '@measurement-core:groups.entities.unit-of-measure-group.fields.description.placeholder',
                        },
                    },
                },
            },
            {
                name: 'allowedUoms',
                title: '@measurement-core:groups.entities.unit-of-measure-group.fields.allowed-uoms.title',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LookupBox,
                        options: {
                            entity: `${RootConfig.module.name}.${RootConfig.entities.unitOfMeasure.name}`,
                            multiple: true,
                            look: 'select',
                            expose: [
                                { source: 'id', target: 'allowedUoms' },
                                { source: 'title', target: 'allowedUoms.{title}' },
                                { source: 'symbol', target: 'allowedUoms.{symbol}' },
                            ],
                        },
                    },
                },
            },
        ],
        columns: [
            { name: 'code', options: { width: '120px', order: 1 } },
            { name: 'title', options: { width: '220px', order: 2 } },
        ],
        interfaces: {
            master: {
                create: {
                    sections,
                    properties: propertyLayouts,
                },
                update: {
                    sections,
                    properties: propertyLayouts,
                },
                single: {
                    title: '{{ title }}',
                    sections,
                    properties: propertyLayouts,
                    actions: [...entityMasterRecordActions()],
                },
                list: {
                    actions: [...entityMasterCrudActions()],
                    views: [
                        createAllQueryView({
                            sorts: [{ name: 'code', dir: 'asc' }],
                        }),
                    ],
                },
            },
        },
    };
    return entityDef;
}
//#endregion

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

//#region ----   Quantity Type Model   ----
//#endregion

//#region ----   Imports   ----
//#endregion
//#region ----   Entity Factory   ----
async function quantityTypeFactory(injector) {
    const sections = [
        { id: 'basic-info', layout: { positions: { lg: { colSpan: 12 } } } },
        { id: 'configuration', layout: { positions: { lg: { colSpan: 12 } } } },
    ];
    const propertyLayouts = [
        { name: 'code', layout: { positions: { lg: { colSpan: 4, order: 1 } } } },
        { name: 'title', layout: { positions: { lg: { colSpan: 8, order: 2 } } } },
        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 3 } } } },
        { name: 'defaultUnitId', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
        { name: 'decimalPlaces', layout: { positions: { lg: { colSpan: 3, order: 5 } } } },
        { name: 'roundingMode', layout: { positions: { lg: { colSpan: 3, order: 6 } } } },
    ];
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.quantityType.name,
        title: RootConfig.entities.quantityType.title,
        icon: RootConfig.entities.quantityType.icon,
        formats: {
            individual: RootConfig.entities.quantityType.title,
            plural: RootConfig.entities.quantityType.titlePlural,
            searchResult: {
                title: '{{ title }}',
                description: '{{ code }}',
            },
        },
        plugins: [{ name: 'history' }, { name: 'compare' }, { name: 'disable' }],
        groups: [
            { id: 'basic-info', title: '@measurement-core:quantity-types.entities.quantity-type.groups.basic-info' },
            { id: 'configuration', title: '@measurement-core:quantity-types.entities.quantity-type.groups.configuration' },
        ],
        properties: [
            {
                name: 'id',
                title: '@general:terms.common.id',
                groupId: 'basic-info',
                schema: {
                    dataType: 'uuid',
                    visible: false,
                    readonly: true,
                    unique: { enabled: true },
                },
            },
            {
                name: 'code',
                title: '@general:terms.common.code',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.TextBox,
                        options: {
                            placeholder: '@measurement-core:quantity-types.entities.quantity-type.fields.code.placeholder',
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'title',
                title: '@general:terms.common.title',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.TextBox,
                        options: {
                            placeholder: '@measurement-core:quantity-types.entities.quantity-type.fields.title.placeholder',
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'description',
                title: '@general:terms.common.description',
                groupId: 'basic-info',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LargeTextBox,
                        options: {
                            rows: 3,
                            placeholder: '@measurement-core:quantity-types.entities.quantity-type.fields.description.placeholder',
                        },
                    },
                },
            },
            {
                name: 'defaultUnitId',
                title: '@measurement-core:quantity-types.entities.quantity-type.fields.default-unit.title',
                groupId: 'configuration',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LookupBox,
                        options: {
                            entity: `${RootConfig.module.name}.${RootConfig.entities.unitOfMeasure.name}`,
                            expose: [
                                { source: 'id', target: 'defaultUnitId' },
                                { source: 'title', target: 'defaultUnit.title' },
                                { source: 'symbol', target: 'defaultUnit.symbol' },
                            ],
                        },
                    },
                },
            },
            {
                name: 'decimalPlaces',
                title: '@measurement-core:quantity-types.entities.quantity-type.fields.decimal-places.title',
                groupId: 'configuration',
                schema: {
                    dataType: 'number',
                    interface: {
                        type: AXPWidgetsList.Editors.NumberBox,
                        options: {
                            minValue: 0,
                            maxValue: 10,
                            placeholder: '@measurement-core:quantity-types.entities.quantity-type.fields.decimal-places.placeholder',
                        },
                    },
                },
            },
            {
                name: 'roundingMode',
                title: '@measurement-core:quantity-types.entities.quantity-type.fields.rounding-mode.title',
                groupId: 'configuration',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.SelectBox,
                        valueTransforms: objectKeyValueTransforms('id'),
                        options: {
                            valueField: 'id',
                            textField: 'title',
                            dataSource: [
                                {
                                    id: 'up',
                                    title: '@measurement-core:quantity-types.entities.quantity-type.fields.rounding-mode.options.up',
                                },
                                {
                                    id: 'down',
                                    title: '@measurement-core:quantity-types.entities.quantity-type.fields.rounding-mode.options.down',
                                },
                                {
                                    id: 'nearest',
                                    title: '@measurement-core:quantity-types.entities.quantity-type.fields.rounding-mode.options.nearest',
                                },
                            ],
                        },
                    },
                },
            },
        ],
        columns: [
            { name: 'code', options: { width: '120px', order: 1 } },
            { name: 'title', options: { width: '220px', order: 2 } },
            { name: 'defaultUnitId', options: { width: '150px', dataPath: 'defaultUnit.title', order: 3 } },
            { name: 'decimalPlaces', options: { width: '120px', order: 4 } },
            { name: 'roundingMode', options: { width: '120px', order: 5 } },
        ],
        interfaces: {
            master: {
                create: {
                    sections,
                    properties: propertyLayouts,
                },
                update: {
                    sections,
                    properties: propertyLayouts,
                },
                single: {
                    title: '{{ title }}',
                    sections,
                    properties: propertyLayouts,
                    actions: [...entityMasterRecordActions()],
                },
                list: {
                    actions: [...entityMasterCrudActions()],
                    views: [
                        createAllQueryView({
                            sorts: [{ name: 'code', dir: 'asc' }],
                        }),
                    ],
                },
            },
        },
    };
    return entityDef;
}
//#endregion

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

//#region ----   Imports   ----
//#endregion
//#region ----   Entity Factory   ----
async function measurementDimensionFactory(injector) {
    const sections = [
        { id: 'basic-info', layout: { positions: { lg: { colSpan: 12 } } } },
        { id: 'fields', layout: { positions: { lg: { colSpan: 12 } } } },
    ];
    const propertyLayouts = [
        { name: 'code', layout: { positions: { lg: { colSpan: 4, order: 1 } } } },
        { name: 'title', layout: { positions: { lg: { colSpan: 8, order: 2 } } } },
        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 3 } } } },
        { name: 'fields', layout: { positions: { lg: { colSpan: 12, order: 4 } } } },
        { name: 'calculatedFields', layout: { positions: { lg: { colSpan: 12, order: 5 } } } },
    ];
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.measurementDimension.name,
        title: RootConfig.entities.measurementDimension.title,
        icon: RootConfig.entities.measurementDimension.icon,
        formats: {
            individual: RootConfig.entities.measurementDimension.title,
            plural: RootConfig.entities.measurementDimension.titlePlural,
            searchResult: {
                title: '{{ title }}',
                description: '{{ code }}',
            },
        },
        plugins: [{ name: 'history' }, { name: 'compare' }, { name: 'disable' }],
        groups: [
            { id: 'basic-info', title: '@measurement-core:dimensions.entities.measurement-dimension.groups.basic-info' },
            { id: 'fields', title: '@measurement-core:dimensions.entities.measurement-dimension.groups.fields' },
        ],
        properties: [
            {
                name: 'id',
                title: '@general:terms.common.id',
                groupId: 'basic-info',
                schema: {
                    dataType: 'uuid',
                    visible: false,
                    readonly: true,
                    unique: { enabled: true },
                },
            },
            {
                name: 'code',
                title: '@general:terms.common.code',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.TextBox,
                        options: {
                            placeholder: '@measurement-core:dimensions.entities.measurement-dimension.fields.code.placeholder',
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'title',
                title: '@general:terms.common.title',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.TextBox,
                        options: {
                            placeholder: '@measurement-core:dimensions.entities.measurement-dimension.fields.title.placeholder',
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'description',
                title: '@general:terms.common.description',
                groupId: 'basic-info',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LargeTextBox,
                        options: {
                            rows: 3,
                            placeholder: '@measurement-core:dimensions.entities.measurement-dimension.fields.description.placeholder',
                        },
                    },
                },
            },
            {
                name: 'fields',
                title: '@measurement-core:dimensions.entities.measurement-dimension.fields.fields.title',
                groupId: 'fields',
                schema: {
                    dataType: 'object',
                    interface: {
                        type: AXPWidgetsList.Editors.LargeTextBox,
                        options: {
                            rows: 10,
                            placeholder: '@measurement-core:dimensions.entities.measurement-dimension.fields.fields.placeholder',
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'calculatedFields',
                title: '@measurement-core:dimensions.entities.measurement-dimension.fields.calculated-fields.title',
                groupId: 'fields',
                schema: {
                    dataType: 'object',
                    interface: {
                        type: AXPWidgetsList.Editors.LargeTextBox,
                        options: {
                            rows: 8,
                            placeholder: '@measurement-core:dimensions.entities.measurement-dimension.fields.calculated-fields.placeholder',
                        },
                    },
                },
            },
        ],
        columns: [
            { name: 'code', options: { width: '120px', order: 1 } },
            { name: 'title', options: { width: '220px', order: 2 } },
        ],
        interfaces: {
            master: {
                create: {
                    sections,
                    properties: propertyLayouts,
                },
                update: {
                    sections,
                    properties: propertyLayouts,
                },
                single: {
                    title: '{{ title }}',
                    sections,
                    properties: propertyLayouts,
                    actions: [...entityMasterRecordActions()],
                },
                list: {
                    actions: [...entityMasterCrudActions()],
                    views: [
                        createAllQueryView({
                            sorts: [{ name: 'code', dir: 'asc' }],
                        }),
                    ],
                },
            },
        },
    };
    return entityDef;
}
//#endregion

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

//#region ----   Measurement Dimension Model   ----
//#endregion

//#region ----   Imports   ----
//#endregion
//#region ----   Entity Factory   ----
async function measurementRangeFactory(injector) {
    const sections = [
        { id: 'basic-info', layout: { positions: { lg: { colSpan: 12 } } } },
        { id: 'range-config', layout: { positions: { lg: { colSpan: 12 } } } },
    ];
    const propertyLayouts = [
        { name: 'code', layout: { positions: { lg: { colSpan: 4, order: 1 } } } },
        { name: 'title', layout: { positions: { lg: { colSpan: 8, order: 2 } } } },
        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 3 } } } },
        { name: 'quantityTypeId', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
        { name: 'unitId', layout: { positions: { lg: { colSpan: 6, order: 5 } } } },
        { name: 'targetValue', layout: { positions: { lg: { colSpan: 4, order: 6 } } } },
        { name: 'minValue', layout: { positions: { lg: { colSpan: 4, order: 7 } } } },
        { name: 'maxValue', layout: { positions: { lg: { colSpan: 4, order: 8 } } } },
        { name: 'rangeType', layout: { positions: { lg: { colSpan: 6, order: 9 } } } },
        { name: 'violationAction', layout: { positions: { lg: { colSpan: 6, order: 10 } } } },
    ];
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.measurementRange.name,
        title: RootConfig.entities.measurementRange.title,
        icon: RootConfig.entities.measurementRange.icon,
        formats: {
            individual: RootConfig.entities.measurementRange.title,
            plural: RootConfig.entities.measurementRange.titlePlural,
            searchResult: {
                title: '{{ title }}',
                description: '{{ code }} - {{ quantityType.title }}',
            },
        },
        plugins: [{ name: 'history' }, { name: 'compare' }, { name: 'disable' }],
        groups: [
            { id: 'basic-info', title: '@measurement-core:ranges.entities.measurement-range.groups.basic-info' },
            { id: 'range-config', title: '@measurement-core:ranges.entities.measurement-range.groups.range-config' },
        ],
        properties: [
            {
                name: 'id',
                title: '@general:terms.common.id',
                groupId: 'basic-info',
                schema: {
                    dataType: 'uuid',
                    visible: false,
                    readonly: true,
                    unique: { enabled: true },
                },
            },
            {
                name: 'code',
                title: '@general:terms.common.code',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.TextBox,
                        options: {
                            placeholder: '@measurement-core:ranges.entities.measurement-range.fields.code.placeholder',
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'title',
                title: '@general:terms.common.title',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.TextBox,
                        options: {
                            placeholder: '@measurement-core:ranges.entities.measurement-range.fields.title.placeholder',
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'description',
                title: '@general:terms.common.description',
                groupId: 'basic-info',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LargeTextBox,
                        options: {
                            rows: 3,
                            placeholder: '@measurement-core:ranges.entities.measurement-range.fields.description.placeholder',
                        },
                    },
                },
            },
            {
                name: 'quantityTypeId',
                title: '@measurement-core:ranges.entities.measurement-range.fields.quantity-type.title',
                groupId: 'range-config',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LookupBox,
                        options: {
                            entity: `${RootConfig.module.name}.${RootConfig.entities.quantityType.name}`,
                            expose: [
                                { source: 'id', target: 'quantityTypeId' },
                                { source: 'title', target: 'quantityType.title' },
                                { source: 'code', target: 'quantityType.code' },
                            ],
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'unitId',
                title: '@measurement-core:ranges.entities.measurement-range.fields.unit.title',
                groupId: 'range-config',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LookupBox,
                        options: {
                            entity: `${RootConfig.module.name}.${RootConfig.entities.unitOfMeasure.name}`,
                            expose: [
                                { source: 'id', target: 'unitId' },
                                { source: 'title', target: 'unit.title' },
                                { source: 'symbol', target: 'unit.symbol' },
                            ],
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'targetValue',
                title: '@measurement-core:ranges.entities.measurement-range.fields.target-value.title',
                groupId: 'range-config',
                schema: {
                    dataType: 'number',
                    interface: {
                        type: AXPWidgetsList.Editors.NumberBox,
                        options: {
                            placeholder: '@measurement-core:ranges.entities.measurement-range.fields.target-value.placeholder',
                        },
                    },
                },
            },
            {
                name: 'minValue',
                title: '@measurement-core:ranges.entities.measurement-range.fields.min-value.title',
                groupId: 'range-config',
                schema: {
                    dataType: 'number',
                    interface: {
                        type: AXPWidgetsList.Editors.NumberBox,
                        options: {
                            placeholder: '@measurement-core:ranges.entities.measurement-range.fields.min-value.placeholder',
                        },
                    },
                },
            },
            {
                name: 'maxValue',
                title: '@measurement-core:ranges.entities.measurement-range.fields.max-value.title',
                groupId: 'range-config',
                schema: {
                    dataType: 'number',
                    interface: {
                        type: AXPWidgetsList.Editors.NumberBox,
                        options: {
                            placeholder: '@measurement-core:ranges.entities.measurement-range.fields.max-value.placeholder',
                        },
                    },
                },
            },
            {
                name: 'rangeType',
                title: '@measurement-core:ranges.entities.measurement-range.fields.range-type.title',
                groupId: 'range-config',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.SelectBox,
                        options: {
                            valueField: 'value',
                            textField: 'text',
                            dataSource: [
                                {
                                    value: 'TOLERANCE',
                                    text: '@measurement-core:ranges.entities.measurement-range.fields.range-type.options.tolerance',
                                },
                                {
                                    value: 'ACCEPTABLE_RANGE',
                                    text: '@measurement-core:ranges.entities.measurement-range.fields.range-type.options.acceptable-range',
                                },
                                {
                                    value: 'WARNING_RANGE',
                                    text: '@measurement-core:ranges.entities.measurement-range.fields.range-type.options.warning-range',
                                },
                            ],
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'violationAction',
                title: '@measurement-core:ranges.entities.measurement-range.fields.violation-action.title',
                groupId: 'range-config',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.SelectBox,
                        options: {
                            valueField: 'value',
                            textField: 'text',
                            dataSource: [
                                {
                                    value: 'REJECT',
                                    text: '@measurement-core:ranges.entities.measurement-range.fields.violation-action.options.reject',
                                },
                                {
                                    value: 'WARN',
                                    text: '@measurement-core:ranges.entities.measurement-range.fields.violation-action.options.warn',
                                },
                                {
                                    value: 'LOG',
                                    text: '@measurement-core:ranges.entities.measurement-range.fields.violation-action.options.log',
                                },
                            ],
                        },
                    },
                },
            },
        ],
        columns: [
            { name: 'code', options: { width: '120px', order: 1 } },
            { name: 'title', options: { width: '220px', order: 2 } },
            { name: 'quantityTypeId', options: { width: '150px', dataPath: 'quantityType.title', order: 3 } },
            { name: 'rangeType', options: { width: '150px', order: 4 } },
            { name: 'minValue', options: { width: '100px', order: 5 } },
            { name: 'maxValue', options: { width: '100px', order: 6 } },
        ],
        interfaces: {
            master: {
                create: {
                    sections,
                    properties: propertyLayouts,
                },
                update: {
                    sections,
                    properties: propertyLayouts,
                },
                single: {
                    title: '{{ title }}',
                    sections,
                    properties: propertyLayouts,
                    actions: [...entityMasterRecordActions()],
                },
                list: {
                    actions: [...entityMasterCrudActions()],
                    views: [
                        createAllQueryView({
                            sorts: [{ name: 'code', dir: 'asc' }],
                        }),
                    ],
                },
            },
        },
    };
    return entityDef;
}
//#endregion

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

//#region ----   Measurement Range Model   ----
//#endregion

//#region ----   Imports   ----
//#endregion
//#region ----   Search Provider   ----
class AXMMeasurementCoreSearchCommandProvider extends AXPSearchCommandProvider {
    constructor() {
        super(...arguments);
        this.commands = [
            {
                group: 'entity',
                title: '@measurement-core:units.search.create-unit-of-measure.title',
                icon: RootConfig.entities.unitOfMeasure.icon,
                description: '@measurement-core:units.search.create-unit-of-measure.description',
                command: {
                    name: 'create-entity',
                    options: {
                        entity: `${RootConfig.module.name}.${RootConfig.entities.unitOfMeasure.name}`,
                    },
                },
            },
            {
                group: 'entity',
                title: '@measurement-core:conversions.search.create-unit-conversion.title',
                icon: RootConfig.entities.unitConversion.icon,
                description: '@measurement-core:conversions.search.create-unit-conversion.description',
                command: {
                    name: 'create-entity',
                    options: {
                        entity: `${RootConfig.module.name}.${RootConfig.entities.unitConversion.name}`,
                    },
                },
            },
            {
                group: 'entity',
                title: '@measurement-core:types.search.create-unit-of-measure-type.title',
                icon: RootConfig.entities.unitOfMeasureType.icon,
                description: '@measurement-core:types.search.create-unit-of-measure-type.description',
                command: {
                    name: 'create-entity',
                    options: {
                        entity: `${RootConfig.module.name}.${RootConfig.entities.unitOfMeasureType.name}`,
                    },
                },
            },
            {
                group: 'entity',
                title: '@measurement-core:groups.search.create-unit-of-measure-group.title',
                icon: RootConfig.entities.unitOfMeasureGroup.icon,
                description: '@measurement-core:groups.search.create-unit-of-measure-group.description',
                command: {
                    name: 'create-entity',
                    options: {
                        entity: `${RootConfig.module.name}.${RootConfig.entities.unitOfMeasureGroup.name}`,
                    },
                },
            },
            {
                group: 'entity',
                title: '@measurement-core:quantity-types.search.create-quantity-type.title',
                icon: RootConfig.entities.quantityType.icon,
                description: '@measurement-core:quantity-types.search.create-quantity-type.description',
                command: {
                    name: 'create-entity',
                    options: {
                        entity: `${RootConfig.module.name}.${RootConfig.entities.quantityType.name}`,
                    },
                },
            },
        ];
    }
}
//#endregion

// Main Module

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

export { AXMMeasurementCoreEntityProvider, AXMMeasurementCoreMenuProvider, AXMMeasurementCoreModule, AXMMeasurementCorePermissionDefinitionProvider, AXMMeasurementCorePermissionKeys, AXMMeasurementCoreSearchCommandProvider, RootConfig, measurementDimensionFactory, measurementRangeFactory, quantityTypeFactory, unitConversionFactory, unitOfMeasureFactory, unitOfMeasureGroupFactory, unitOfMeasureTypeFactory };
//# sourceMappingURL=acorex-modules-measurement-core.mjs.map
