import { AXMEntityCrudServiceImpl, AXPEntityService, AXP_ENTITY_DEFINITION_LOADER } from '@acorex/platform/layout/entity';
import * as i0 from '@angular/core';
import { Injectable, inject, signal, NgModule, Injector } from '@angular/core';
import { AXTranslationService } from '@acorex/core/translation';
import { AXPWorkflowTaskProvider, AXP_WORKFLOW_TASK_PROVIDER } from '@acorex/modules/task-management';
import { AXPCommandExecutor, AXPRuntimeModule, provideCommandSetups } from '@acorex/platform/runtime';
import { AXPLayoutBuilderService } from '@acorex/platform/layout/builder';
import { AXP_IDENTIFIER_RULES } from '@acorex/modules/identifier-management';
import { AXP_MENU_PROVIDER, AXP_SETTING_DEFINITION_PROVIDER } from '@acorex/platform/common';
import { AXP_DATASOURCE_DEFINITION_PROVIDER } from '@acorex/platform/core';
import { CommonModule } from '@angular/common';
import { AXP_TASK_BADGE_PROVIDERS } from '@acorex/platform/layout/components';
import { AXDataSource } from '@acorex/cdk/common';
import { AXPWidgetsCatalog } from '@acorex/platform/layout/widget-core';
import { AXPSessionService } from '@acorex/platform/auth';
import { firstValueFrom } from 'rxjs';

const config = {
    i18n: 'human-capital-management',
    module: 'HumanCapitalManagement',
};
const RootConfig = {
    config,
    module: {
        route: 'human-capital-management',
        name: config.module,
        title: '@human-capital-management:module-name',
        icon: 'fa-light fa-users',
    },
    entities: {
        employee: {
            name: 'Employee',
            source: `${config.module}.Employee`,
            title: '@human-capital-management:employee.individual-title',
            icon: 'fa-light fa-address-card',
        },
        employmentType: {
            name: 'EmploymentType',
            source: `${config.module}.EmploymentType`,
            title: '@human-capital-management:employment-type.individual-title',
            icon: 'fa-light fa-file-signature',
        },
        skill: {
            name: 'Skill',
            source: `${config.module}.Skill`,
            title: '@human-capital-management:skill.individual-title',
            icon: 'fa-light fa-code',
        },
        skillLevel: {
            name: 'SkillLevel',
            source: `${config.module}.SkillLevel`,
            title: '@human-capital-management:skill-level.individual-title',
            icon: 'fa-light fa-signal-bars',
        },
        employeeSkill: {
            name: 'EmployeeSkill',
            source: `${config.module}.EmployeeSkill`,
            title: '@human-capital-management:employee-skill.individual-title',
            icon: 'fa-light fa-award',
        },
        positionAssignment: {
            name: 'PositionAssignment',
            source: `${config.module}.PositionAssignment`,
            title: '@human-capital-management:position-assignment.individual-title',
            icon: 'fa-light fa-user-tie-hair',
        },
        leaveType: {
            name: 'LeaveType',
            source: `${config.module}.LeaveType`,
            title: '@human-capital-management:leave-type.individual-title',
            icon: 'fa-light fa-calendar-days',
        },
        leaveRequest: {
            name: 'LeaveRequest',
            source: `${config.module}.LeaveRequest`,
            title: '@human-capital-management:leave-request.individual-title',
            icon: 'fa-light fa-plane-departure',
        },
    },
};

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

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

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

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

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

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

class AXPApproveLeaveCommand {
    constructor() {
        this.leaveRequestService = inject(AXMHumanCapitalManagementLeaveRequestEntityService);
    }
    async execute(input) {
        try {
            // Get the leave request
            const leaveRequest = await this.leaveRequestService.getOne(input.id);
            if (!leaveRequest) {
                return { success: false, message: 'Leave request not found' };
            }
            // Create status change record
            const statusChange = {
                status: 'Approved',
                changedAt: new Date(),
                changedBy: 'current-user-id', // Get from session service
                note: input.note
            };
            // Update status and add to history
            const updatedLeaveRequest = {
                ...leaveRequest,
                status: 'Approved',
                statusNote: input.statusNote || leaveRequest.statusNote,
                statusHistory: [
                    ...(leaveRequest.statusHistory || []),
                    statusChange
                ]
            };
            await this.leaveRequestService.updateOne(input.id, updatedLeaveRequest);
            return {
                success: true,
                message: 'Leave request approved successfully',
                leaveRequest: await this.leaveRequestService.getOne(input.id)
            };
        }
        catch (error) {
            return {
                success: false,
                message: `Failed to approve leave request: ${error instanceof Error ? error.message : 'Unknown error'}`
            };
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPApproveLeaveCommand, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPApproveLeaveCommand, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPApproveLeaveCommand, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }] });

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

class AXPRejectLeaveCommand {
    constructor() {
        this.leaveRequestService = inject(AXMHumanCapitalManagementLeaveRequestEntityService);
    }
    async execute(input) {
        try {
            // Get the leave request
            const leaveRequest = await this.leaveRequestService.getOne(input.id);
            if (!leaveRequest) {
                return { success: false, message: 'Leave request not found' };
            }
            // Create status change record
            const statusChange = {
                status: 'Rejected',
                changedAt: new Date(),
                changedBy: 'current-user-id', // Get from session service
                note: input.note
            };
            // Update status and add to history
            const updatedLeaveRequest = {
                ...leaveRequest,
                status: 'Rejected',
                statusNote: input.statusNote || leaveRequest.statusNote,
                statusHistory: [
                    ...(leaveRequest.statusHistory || []),
                    statusChange
                ]
            };
            await this.leaveRequestService.updateOne(input.id, updatedLeaveRequest);
            return {
                success: true,
                message: 'Leave request rejected successfully',
                leaveRequest: await this.leaveRequestService.getOne(input.id)
            };
        }
        catch (error) {
            return {
                success: false,
                message: `Failed to reject leave request: ${error instanceof Error ? error.message : 'Unknown error'}`
            };
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPRejectLeaveCommand, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPRejectLeaveCommand, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPRejectLeaveCommand, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }] });

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

class AXPCancelLeaveCommand {
    constructor() {
        this.leaveRequestService = inject(AXMHumanCapitalManagementLeaveRequestEntityService);
    }
    async execute(input) {
        try {
            // Get the leave request
            const leaveRequest = await this.leaveRequestService.getOne(input.id);
            if (!leaveRequest) {
                return { success: false, message: 'Leave request not found' };
            }
            // Check if can be cancelled (only pending or approved requests)
            if (leaveRequest.status === 'Rejected' || leaveRequest.status === 'Cancelled') {
                return {
                    success: false,
                    message: 'Cannot cancel leave request in current status'
                };
            }
            // Create status change record
            const statusChange = {
                status: 'Cancelled',
                changedAt: new Date(),
                changedBy: 'current-user-id', // Get from session service
                note: input.note
            };
            // Update status and add to history
            const updatedLeaveRequest = {
                ...leaveRequest,
                status: 'Cancelled',
                statusNote: input.statusNote || leaveRequest.statusNote,
                statusHistory: [
                    ...(leaveRequest.statusHistory || []),
                    statusChange
                ]
            };
            await this.leaveRequestService.updateOne(input.id, updatedLeaveRequest);
            return {
                success: true,
                message: 'Leave request cancelled successfully',
                leaveRequest: await this.leaveRequestService.getOne(input.id)
            };
        }
        catch (error) {
            return {
                success: false,
                message: `Failed to cancel leave request: ${error instanceof Error ? error.message : 'Unknown error'}`
            };
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPCancelLeaveCommand, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPCancelLeaveCommand, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPCancelLeaveCommand, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }] });

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

//#region ----   Command Types   ----
//#endregion

class AXPLeaveRequestDialogService {
    constructor() {
        this.layoutBuilder = inject(AXPLayoutBuilderService);
        this.translationService = inject(AXTranslationService);
    }
    async showRejectionDialog() {
        const dialogRef = await this.layoutBuilder
            .create()
            .dialog(dialog => {
            dialog
                .setTitle('@general:actions.reject.title')
                .setMessage('@human-capital-management:leave-request.rejection-dialog.message')
                .setContext({ reason: '', note: '' })
                .content(flex => {
                flex
                    .setDirection('column')
                    .formField('@human-capital-management:leave-request.rejection-dialog.reason-label', field => {
                    field.path('reason');
                    field.largeTextBox({
                        placeholder: '@human-capital-management:leave-request.rejection-dialog.reason-placeholder',
                        maxLength: 500
                    });
                })
                    .formField('@human-capital-management:leave-request.rejection-dialog.note-label', field => {
                    field.path('note');
                    field.largeTextBox({
                        placeholder: '@human-capital-management:leave-request.rejection-dialog.note-placeholder',
                        maxLength: 1000
                    });
                });
            })
                .setActions(actions => {
                actions.cancel('@general:actions.cancel.title').submit('@general:actions.reject.title');
            });
        })
            .show();
        const formData = dialogRef.context();
        const action = dialogRef.action();
        dialogRef.close();
        return {
            reason: formData['reason'],
            note: formData['note'],
            cancelled: action === 'cancel'
        };
    }
    async showCancellationDialog() {
        const dialogRef = await this.layoutBuilder
            .create()
            .dialog(dialog => {
            dialog
                .setTitle('@general:actions.cancel.title')
                .setMessage('@human-capital-management:leave-request.cancellation-dialog.message')
                .setContext({ reason: '', note: '' })
                .content(flex => {
                flex
                    .setDirection('column')
                    .formField('@human-capital-management:leave-request.cancellation-dialog.reason-label', field => {
                    field.path('reason');
                    field.largeTextBox({
                        placeholder: '@human-capital-management:leave-request.cancellation-dialog.reason-placeholder',
                        maxLength: 500
                    });
                })
                    .formField('@human-capital-management:leave-request.cancellation-dialog.note-label', field => {
                    field.path('note');
                    field.largeTextBox({
                        placeholder: '@human-capital-management:leave-request.cancellation-dialog.note-placeholder',
                        maxLength: 1000
                    });
                });
            })
                .setActions(actions => {
                actions.cancel('@general:actions.close.title').submit('@general:actions.cancel.title');
            });
        })
            .show();
        const formData = dialogRef.context();
        const action = dialogRef.action();
        dialogRef.close();
        return {
            reason: formData['reason'],
            note: formData['note'],
            cancelled: action === 'cancel'
        };
    }
    async showApprovalDialog() {
        const dialogRef = await this.layoutBuilder
            .create()
            .dialog(dialog => {
            dialog
                .setTitle('@general:actions.approve.title')
                .setMessage('@human-capital-management:leave-request.approval-dialog.message')
                .setContext({ note: '' })
                .content(flex => {
                flex
                    .setDirection('column')
                    .formField('@human-capital-management:leave-request.approval-dialog.note-label', field => {
                    field.path('note');
                    field.largeTextBox({
                        placeholder: '@human-capital-management:leave-request.approval-dialog.note-placeholder',
                        maxLength: 1000
                    });
                });
            })
                .setActions(actions => {
                actions.cancel('@general:actions.cancel.title').submit('@general:actions.approve.title');
            });
        })
            .show();
        const formData = dialogRef.context();
        const action = dialogRef.action();
        dialogRef.close();
        return {
            note: formData['note'],
            cancelled: action === 'cancel'
        };
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPLeaveRequestDialogService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPLeaveRequestDialogService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXPLeaveRequestDialogService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }] });

class AXMLeaveRequestTaskProvider extends AXPWorkflowTaskProvider {
    constructor() {
        super(...arguments);
        this.leaveRequestService = inject(AXMHumanCapitalManagementLeaveRequestEntityService);
        this.commandExecutor = inject(AXPCommandExecutor);
        this.translationService = inject(AXTranslationService);
        this.dialogService = inject(AXPLeaveRequestDialogService);
    }
    get name() {
        return 'leave-request';
    }
    get title() {
        return '@human-capital-management:leave-request.plural-title';
    }
    get icon() {
        return 'fa-light fa-plane-departure';
    }
    async getTasks(options) {
        const baseFilter = { logic: 'and', filters: [] };
        baseFilter.filters?.push({ field: 'status', operator: { type: 'equal', negative: true }, value: 'Cancelled' });
        if (options?.range?.from) {
            baseFilter.filters?.push({ field: 'startDate', operator: { type: 'gte' }, value: options.range.from });
        }
        if (options?.range?.end) {
            baseFilter.filters?.push({ field: 'endDate', operator: { type: 'lte' }, value: options.range.end });
        }
        if (options?.assigneeIds && options.assigneeIds.length > 0) {
            // Filter by manager (assignee) of the employee requesting leave
            baseFilter.filters?.push({
                field: 'employee.manager.userId',
                operator: { type: 'in' },
                value: options.assigneeIds,
            });
        }
        const { items, total } = await this.leaveRequestService.query({
            skip: options?.skip ?? 0,
            take: options?.take ?? 20,
            filter: baseFilter,
        });
        const tasks = items.map((item) => ({
            id: item.id,
            title: `${item.employee?.party?.displayName} - ${this.translationService.translateSync(item.leaveType?.title ?? '')}`,
            description: item.reason ?? '',
            startDate: item.startDate ?? new Date(),
            endDate: item.endDate ?? new Date(),
            assignee: {
                id: item.employee?.userId ?? '',
                type: 'user',
                fullName: item.employee?.manager?.party?.displayName ?? '',
            },
            index: 2,
            status: { id: item.status ?? 'Pending', title: item.status ?? 'Pending' },
            priority: this.getPriorityFromStatus(item.status ?? 'Pending'),
            reporter: {
                id: item.employee?.userId ?? item.employeeId,
                type: 'user',
                fullName: item.employee?.party?.displayName ?? '',
            },
            payload: item,
        }));
        return { items: tasks, total };
    }
    async updateTasks(tasksToUpdate) {
        // No-op for now. Could wire drag-drop to update status/dates.
        return tasksToUpdate;
    }
    async executeCommand(command) {
        try {
            if (command.name === 'approveLeave' || command.name === 'rejectLeave' || command.name === 'cancelLeave') {
                const leaveRequestId = command.options?.['id'] ?? '';
                // Show appropriate dialog based on action
                let dialogResult;
                switch (command.name) {
                    case 'approveLeave':
                        dialogResult = await this.dialogService.showApprovalDialog();
                        break;
                    case 'rejectLeave':
                        dialogResult = await this.dialogService.showRejectionDialog();
                        break;
                    case 'cancelLeave':
                        dialogResult = await this.dialogService.showCancellationDialog();
                        break;
                }
                // If dialog was cancelled, return early
                if (dialogResult?.cancelled) {
                    return { success: false };
                }
                const commandKey = `HumanCapitalManagement.LeaveRequest:${command.name === 'approveLeave' ? 'Approve' : command.name === 'rejectLeave' ? 'Reject' : 'Cancel'}`;
                const result = await this.commandExecutor.execute(commandKey, {
                    id: leaveRequestId,
                    reason: dialogResult?.reason,
                    note: dialogResult?.note,
                    statusNote: dialogResult?.note,
                });
                if (result?.success) {
                    return { success: true };
                }
                else {
                    return { success: false };
                }
            }
            return { success: true };
        }
        catch (error) {
            return {
                success: false,
            };
        }
    }
    async getActions(task) {
        const actions = [];
        // Add approve action for pending requests
        if (task?.status?.id === 'Pending' || task?.status?.id === 'Rejected') {
            actions.push({
                name: 'approveLeave',
                title: this.translationService.translateSync('@general:actions.approve.title'),
                icon: 'fa-light fa-check',
                color: 'success',
                command: { name: 'approveLeave', options: { id: task?.id ?? '' } },
            });
        }
        // Add reject action for pending or approved requests
        if (task?.status?.id === 'Pending' || task?.status?.id === 'Approved') {
            actions.push({
                name: 'rejectLeave',
                title: this.translationService.translateSync('@general:actions.reject.title'),
                icon: 'fa-light fa-xmark',
                color: 'danger',
                command: { name: 'rejectLeave', options: { id: task?.id ?? '' } },
            });
        }
        // Add cancel action for pending or approved requests
        if (task?.status?.id === 'Pending' || task?.status?.id === 'Approved') {
            actions.push({
                name: 'rejectLeave',
                title: this.translationService.translateSync('@general:actions.cancel.title'),
                icon: 'fa-light fa-ban',
                color: 'secondary',
                command: { name: 'cancelLeave', options: { id: task?.id ?? '' } },
            });
        }
        return actions;
    }
    async getExtraFields() {
        return [];
    }
    async getStatuses() {
        return [
            {
                index: 0,
                key: 'Pending',
                title: await this.translationService.translateAsync('@human-capital-management:leave-request.pending'),
                color: 'warning',
            },
            {
                index: 1,
                key: 'Approved',
                title: await this.translationService.translateAsync('@human-capital-management:leave-request.approved'),
                color: 'success',
            },
            {
                index: 2,
                key: 'Rejected',
                title: await this.translationService.translateAsync('@human-capital-management:leave-request.rejected'),
                color: 'danger',
            },
            {
                index: 3,
                key: 'Cancelled',
                title: await this.translationService.translateAsync('@human-capital-management:leave-request.cancelled'),
                color: 'secondary',
            },
        ];
    }
    getPriorityFromStatus(status) {
        switch (status) {
            case 'Pending':
                return 'medium';
            case 'Approved':
                return 'lowest';
            case 'Rejected':
                return 'high';
            default:
                return 'medium';
        }
    }
}

class AXMLeaveRequestBadgeProvider {
    constructor() {
        this.leaveRequestService = inject(AXMHumanCapitalManagementLeaveRequestEntityService);
        this.count = signal(0, ...(ngDevMode ? [{ debugName: "count" }] : []));
        this.key = 'leave-request-badge';
        setTimeout(() => {
            this.getCount();
        }, 1000);
    }
    async getCount() {
        // Base filter for pending leave requests that need approval
        const baseFilters = [
            {
                field: 'status',
                operator: { type: 'equal' },
                value: 'Pending',
            },
        ];
        const result = await this.leaveRequestService.query({
            skip: 0,
            take: 99,
            filter: {
                logic: 'and',
                filters: baseFilters,
            },
        });
        this.count.set(result.total);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMLeaveRequestBadgeProvider, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMLeaveRequestBadgeProvider }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMLeaveRequestBadgeProvider, decorators: [{
            type: Injectable
        }], ctorParameters: () => [] });

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

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

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

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

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

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

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

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

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

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

class AXMHumanCapitalModuleEntityProvider {
    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.employee.name:
                    return (await import('./acorex-modules-human-capital-management-employee.entity-CP0J0udU.mjs')).factory(this.injector);
                case RootConfig.entities.employmentType.name:
                    return (await import('./acorex-modules-human-capital-management-employment-type.entity-0nT4XSi2.mjs')).factory(this.injector);
                case RootConfig.entities.skill.name:
                    return (await import('./acorex-modules-human-capital-management-skill.entity-n6HyUWfU.mjs')).factory(this.injector);
                case RootConfig.entities.skillLevel.name:
                    return (await import('./acorex-modules-human-capital-management-skill-level.entity-CV9vEbTH.mjs')).factory(this.injector);
                case RootConfig.entities.employeeSkill.name:
                    return (await import('./acorex-modules-human-capital-management-employee-skill.entity-DfdiUEju.mjs')).factory(this.injector);
                case RootConfig.entities.positionAssignment?.name:
                    return (await import('./acorex-modules-human-capital-management-position-assignment.entity-DBz-A04O.mjs')).factory(this.injector);
                case RootConfig.entities.leaveType.name:
                    return (await import('./acorex-modules-human-capital-management-leave-type.entity-J9p3UIlS.mjs')).factory(this.injector);
                case RootConfig.entities.leaveRequest.name:
                    return (await import('./acorex-modules-human-capital-management-leave-request.entity-YGyl6MWh.mjs')).factory(this.injector);
            }
        }
        return null;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMHumanCapitalModuleEntityProvider, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMHumanCapitalModuleEntityProvider }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMHumanCapitalModuleEntityProvider, decorators: [{
            type: Injectable
        }] });

class AXMLeaveRequestFeatureModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMLeaveRequestFeatureModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.4", ngImport: i0, type: AXMLeaveRequestFeatureModule, imports: [CommonModule, AXPRuntimeModule] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMLeaveRequestFeatureModule, providers: [
            {
                provide: AXP_TASK_BADGE_PROVIDERS,
                useClass: AXMLeaveRequestBadgeProvider,
                multi: true,
            },
            {
                provide: AXP_WORKFLOW_TASK_PROVIDER,
                useClass: AXMLeaveRequestTaskProvider,
                multi: true,
            },
            provideCommandSetups([
                {
                    key: 'HumanCapitalManagement.LeaveRequest:Approve',
                    command: () => Promise.resolve().then(function () { return approveLeave_command; }).then((c) => c.AXPApproveLeaveCommand),
                },
                {
                    key: 'HumanCapitalManagement.LeaveRequest:Reject',
                    command: () => Promise.resolve().then(function () { return rejectLeave_command; }).then((c) => c.AXPRejectLeaveCommand),
                },
                {
                    key: 'HumanCapitalManagement.LeaveRequest:Cancel',
                    command: () => Promise.resolve().then(function () { return cancelLeave_command; }).then((c) => c.AXPCancelLeaveCommand),
                },
            ]),
        ], imports: [CommonModule, AXPRuntimeModule] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMLeaveRequestFeatureModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [CommonModule, AXPRuntimeModule],
                    providers: [
                        {
                            provide: AXP_TASK_BADGE_PROVIDERS,
                            useClass: AXMLeaveRequestBadgeProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_WORKFLOW_TASK_PROVIDER,
                            useClass: AXMLeaveRequestTaskProvider,
                            multi: true,
                        },
                        provideCommandSetups([
                            {
                                key: 'HumanCapitalManagement.LeaveRequest:Approve',
                                command: () => Promise.resolve().then(function () { return approveLeave_command; }).then((c) => c.AXPApproveLeaveCommand),
                            },
                            {
                                key: 'HumanCapitalManagement.LeaveRequest:Reject',
                                command: () => Promise.resolve().then(function () { return rejectLeave_command; }).then((c) => c.AXPRejectLeaveCommand),
                            },
                            {
                                key: 'HumanCapitalManagement.LeaveRequest:Cancel',
                                command: () => Promise.resolve().then(function () { return cancelLeave_command; }).then((c) => c.AXPCancelLeaveCommand),
                            },
                        ]),
                    ],
                }]
        }] });

class AXMEmployeeDataSourceDefinition {
    constructor() {
        this.employeeService = inject(AXMHumanCapitalManagementEmployeeEntityService);
    }
    items() {
        return Promise.resolve([
            {
                name: 'employees',
                title: 'Employees',
                source: () => {
                    return new AXDataSource({
                        key: 'id',
                        load: async (_) => {
                            try {
                                const res = await this.employeeService.query();
                                return {
                                    items: res.items.map((item) => ({
                                        ...item,
                                    })),
                                    total: res.total,
                                };
                            }
                            catch (e) {
                                console.log(e);
                                throw e;
                            }
                        },
                        byKey: async (key) => {
                            return await this.employeeService.getOne(key);
                        },
                        pageSize: 100,
                    });
                },
                columns: [
                    {
                        name: 'id',
                        title: 'ID',
                        datatype: 'uuid',
                        type: AXPWidgetsCatalog.text,
                    },
                    {
                        name: 'employeeCode',
                        title: 'Employee Code',
                        datatype: 'string',
                        type: AXPWidgetsCatalog.text,
                    },
                    {
                        name: 'party.displayName',
                        title: 'Display Name',
                        datatype: 'string',
                        type: AXPWidgetsCatalog.text,
                    },
                ],
                filters: [
                    {
                        field: 'employeeCode',
                        title: 'Employee Code',
                        operator: {
                            type: 'equal',
                        },
                        widget: {
                            type: AXPWidgetsCatalog.text,
                        },
                        filterType: {
                            advance: true,
                            inline: true,
                        },
                    },
                ],
                textField: {
                    name: 'party.displayName',
                    title: 'Display Name',
                },
                valueField: {
                    name: 'id',
                    title: 'ID',
                },
            },
        ]);
    }
}

class AXMSkillDataSourceDefinition {
    constructor() {
        this.skillService = inject(AXMHumanCapitalManagementSkillEntityService);
    }
    items() {
        return Promise.resolve([
            {
                name: 'skills',
                title: 'Skills',
                source: () => {
                    return new AXDataSource({
                        key: 'id',
                        load: async (_) => {
                            try {
                                const res = await this.skillService.query();
                                return {
                                    items: res.items.map((item) => ({
                                        ...item,
                                    })),
                                    total: res.total,
                                };
                            }
                            catch (e) {
                                console.log(e);
                                throw e;
                            }
                        },
                        byKey: async (key) => {
                            return await this.skillService.getOne(key);
                        },
                        pageSize: 100,
                    });
                },
                columns: [
                    {
                        name: 'id',
                        title: 'ID',
                        datatype: 'uuid',
                        type: AXPWidgetsCatalog.text,
                    },
                    {
                        name: 'title',
                        title: 'Title',
                        datatype: 'string',
                        type: AXPWidgetsCatalog.text,
                    },
                    {
                        name: 'description',
                        title: 'Description',
                        datatype: 'string',
                        type: AXPWidgetsCatalog.text,
                    },
                ],
                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 AXMEmploymentTypeDataSourceDefinition {
    constructor() {
        this.employmentTypeService = inject(AXMHumanCapitalManagementEmploymentTypeEntityService);
    }
    items() {
        return Promise.resolve([
            {
                name: 'employmentTypes',
                title: 'Employment Types',
                source: () => {
                    return new AXDataSource({
                        key: 'id',
                        load: async (_) => {
                            try {
                                const res = await this.employmentTypeService.query();
                                return {
                                    items: res.items.map((item) => ({
                                        ...item,
                                    })),
                                    total: res.total,
                                };
                            }
                            catch (e) {
                                console.log(e);
                                throw e;
                            }
                        },
                        byKey: async (key) => {
                            return await this.employmentTypeService.getOne(key);
                        },
                        pageSize: 100,
                    });
                },
                columns: [
                    {
                        name: 'id',
                        title: 'ID',
                        datatype: 'uuid',
                        type: AXPWidgetsCatalog.text,
                    },
                    {
                        name: 'title',
                        title: 'Title',
                        datatype: 'string',
                        type: AXPWidgetsCatalog.text,
                    },
                    {
                        name: 'description',
                        title: 'Description',
                        datatype: 'string',
                        type: AXPWidgetsCatalog.text,
                    },
                ],
                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 AXMSkillLevelDataSourceDefinition {
    constructor() {
        this.skillLevelService = inject(AXMHumanCapitalManagementSkillLevelEntityService);
    }
    items() {
        return Promise.resolve([
            {
                name: 'skill-levels',
                title: 'Skill Levels',
                source: () => {
                    return new AXDataSource({
                        key: 'id',
                        load: async (_) => {
                            try {
                                const res = await this.skillLevelService.query();
                                return {
                                    items: res.items.map((item) => ({
                                        ...item,
                                    })),
                                    total: res.total,
                                };
                            }
                            catch (e) {
                                console.log(e);
                                throw e;
                            }
                        },
                        byKey: async (key) => {
                            return await this.skillLevelService.getOne(key);
                        },
                        pageSize: 100,
                    });
                },
                columns: [
                    {
                        name: 'id',
                        title: 'ID',
                        datatype: 'uuid',
                        type: AXPWidgetsCatalog.text,
                    },
                    {
                        name: 'title',
                        title: 'Title',
                        datatype: 'string',
                        type: AXPWidgetsCatalog.text,
                    },
                    {
                        name: 'description',
                        title: 'Description',
                        datatype: 'string',
                        type: AXPWidgetsCatalog.text,
                    },
                    {
                        name: 'isActive',
                        title: 'Active',
                        datatype: 'boolean',
                        type: AXPWidgetsCatalog.toggle,
                    },
                ],
                filters: [
                    {
                        field: 'title',
                        title: 'Title',
                        operator: {
                            type: 'equal',
                        },
                        widget: {
                            type: AXPWidgetsCatalog.text,
                        },
                        filterType: {
                            advance: true,
                            inline: true,
                        },
                    },
                    {
                        field: 'isActive',
                        title: 'Active',
                        operator: {
                            type: 'equal',
                        },
                        widget: {
                            type: AXPWidgetsCatalog.toggle,
                        },
                        filterType: {
                            advance: true,
                            inline: false,
                        },
                    },
                ],
                textField: {
                    name: 'title',
                    title: 'Title',
                },
                valueField: {
                    name: 'id',
                    title: 'ID',
                },
            },
        ]);
    }
}

const AXM_EMPLOYEE_CODE_IDENTIFIER_RULE = {
    id: 'employee-code',
    title: 'Employee Code',
    entity: 'HumanCapitalManagement.Employee',
    pattern: 'EMP-{date:YYYYMM}-{seq:4}',
    enabled: true,
    priority: 1,
    scopeConfig: { byTenant: false, period: 'yearly', minValue: 100, blockSize: 0 },
};

const AXPHumanCapitalManagementMenuKeys = {
    Root: 'human-capital-management:menu',
    Employees: 'human-capital-management:menu:employees',
    EmploymentTypes: 'human-capital-management:menu:employment-types',
    Skills: 'human-capital-management:menu:skills',
    SkillLevels: 'human-capital-management:menu:skill-levels',
    PositionAssignments: 'human-capital-management:menu:position-assignments',
    LeaveTypes: 'human-capital-management:menu:leave-types',
    LeaveRequests: 'human-capital-management:menu:leave-requests',
};

class AXMMenuProvider {
    constructor() {
        this.entityService = inject(AXPEntityService);
        this.sessionService = inject(AXPSessionService);
    }
    async provide(context) {
        const isAuthorized = await firstValueFrom(this.sessionService.isAuthorized$);
        if (!isAuthorized) {
            return;
        }
        const scope = RootConfig.config.i18n;
        const module = RootConfig.module;
        context.addItems([
            {
                name: AXPHumanCapitalManagementMenuKeys.Root,
                priority: 9001,
                text: '@human-capital-management:root-menu',
                icon: module.icon,
                data: { requiredPermission: 'admin' },
                children: [
                    {
                        name: AXPHumanCapitalManagementMenuKeys.Employees,
                        text: '@human-capital-management:employee.plural-title',
                        path: this.entityService.createPath(module.name, RootConfig.entities.employee.name),
                        priority: 10,
                        icon: RootConfig.entities.employee.icon,
                    },
                    {
                        name: AXPHumanCapitalManagementMenuKeys.EmploymentTypes,
                        text: '@human-capital-management:employment-type.plural-title',
                        path: this.entityService.createPath(module.name, RootConfig.entities.employmentType.name),
                        priority: 11,
                        icon: RootConfig.entities.employmentType.icon,
                    },
                    {
                        name: AXPHumanCapitalManagementMenuKeys.Skills,
                        text: '@human-capital-management:skill.plural-title',
                        path: this.entityService.createPath(module.name, RootConfig.entities.skill.name),
                        priority: 12,
                        icon: RootConfig.entities.skill.icon,
                    },
                    {
                        name: AXPHumanCapitalManagementMenuKeys.SkillLevels,
                        text: '@human-capital-management:skill-level.plural-title',
                        path: this.entityService.createPath(module.name, RootConfig.entities.skillLevel.name),
                        priority: 13,
                        icon: RootConfig.entities.skillLevel.icon,
                    },
                    {
                        name: 'human-capital-management:menu:divider-1',
                        text: '',
                        type: 'break',
                        priority: 14,
                    },
                    {
                        name: AXPHumanCapitalManagementMenuKeys.PositionAssignments,
                        text: '@human-capital-management:position-assignment.plural-title',
                        path: this.entityService.createPath(module.name, RootConfig.entities.positionAssignment.name),
                        priority: 15,
                        icon: RootConfig.entities.positionAssignment.icon,
                    },
                    {
                        name: 'human-capital-management:menu:divider-2',
                        text: '',
                        type: 'break',
                        priority: 16,
                    },
                    {
                        name: AXPHumanCapitalManagementMenuKeys.LeaveTypes,
                        text: '@human-capital-management:leave-type.plural-title',
                        path: this.entityService.createPath(module.name, RootConfig.entities.leaveType.name),
                        priority: 17,
                        icon: RootConfig.entities.leaveType.icon,
                    },
                    {
                        name: AXPHumanCapitalManagementMenuKeys.LeaveRequests,
                        text: '@human-capital-management:leave-request.plural-title',
                        path: this.entityService.createPath(module.name, RootConfig.entities.leaveRequest.name),
                        priority: 18,
                        icon: RootConfig.entities.leaveRequest.icon,
                        badgeKey: 'leave-request-badge',
                    },
                ],
            },
        ]);
    }
}

class AXMHumanCapitalManagementModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMHumanCapitalManagementModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.4", ngImport: i0, type: AXMHumanCapitalManagementModule, imports: [CommonModule,
            AXPRuntimeModule,
            AXMHumanCapitalManagementEmploymentTypeEntityModule,
            AXMHumanCapitalManagementSkillEntityModule,
            AXMHumanCapitalManagementSkillLevelEntityModule,
            AXMHumanCapitalManagementEmployeeSkillEntityModule,
            AXMHumanCapitalManagementPositionAssignmentEntityModule,
            AXMHumanCapitalManagementEmployeeEntityModule,
            AXMHumanCapitalManagementLeaveTypeEntityModule,
            AXMHumanCapitalManagementLeaveRequestEntityModule,
            AXMLeaveRequestFeatureModule] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMHumanCapitalManagementModule, providers: [
            {
                provide: AXP_IDENTIFIER_RULES,
                multi: true,
                useValue: AXM_EMPLOYEE_CODE_IDENTIFIER_RULE,
            },
            {
                provide: AXP_ENTITY_DEFINITION_LOADER,
                useClass: AXMHumanCapitalModuleEntityProvider,
                multi: true,
            },
            {
                provide: AXP_MENU_PROVIDER,
                useClass: AXMMenuProvider,
                multi: true,
            },
            {
                provide: AXP_SETTING_DEFINITION_PROVIDER,
                useFactory: async () => {
                    const injector = inject(Injector);
                    const provider = (await import('./acorex-modules-human-capital-management-settings.provider-rRaBaVeh.mjs')).AXMSettingProvider;
                    return new provider(injector);
                },
                multi: true,
            },
            {
                provide: AXP_DATASOURCE_DEFINITION_PROVIDER,
                useClass: AXMEmployeeDataSourceDefinition,
                multi: true,
            },
            {
                provide: AXP_DATASOURCE_DEFINITION_PROVIDER,
                useClass: AXMSkillDataSourceDefinition,
                multi: true,
            },
            {
                provide: AXP_DATASOURCE_DEFINITION_PROVIDER,
                useClass: AXMSkillLevelDataSourceDefinition,
                multi: true,
            },
            {
                provide: AXP_DATASOURCE_DEFINITION_PROVIDER,
                useClass: AXMEmploymentTypeDataSourceDefinition,
                multi: true,
            },
        ], imports: [CommonModule,
            AXPRuntimeModule,
            AXMHumanCapitalManagementEmploymentTypeEntityModule,
            AXMHumanCapitalManagementSkillEntityModule,
            AXMHumanCapitalManagementSkillLevelEntityModule,
            AXMHumanCapitalManagementEmployeeSkillEntityModule,
            AXMHumanCapitalManagementPositionAssignmentEntityModule,
            AXMHumanCapitalManagementEmployeeEntityModule,
            AXMHumanCapitalManagementLeaveTypeEntityModule,
            AXMHumanCapitalManagementLeaveRequestEntityModule,
            AXMLeaveRequestFeatureModule] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMHumanCapitalManagementModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [
                        CommonModule,
                        AXPRuntimeModule,
                        AXMHumanCapitalManagementEmploymentTypeEntityModule,
                        AXMHumanCapitalManagementSkillEntityModule,
                        AXMHumanCapitalManagementSkillLevelEntityModule,
                        AXMHumanCapitalManagementEmployeeSkillEntityModule,
                        AXMHumanCapitalManagementPositionAssignmentEntityModule,
                        AXMHumanCapitalManagementEmployeeEntityModule,
                        AXMHumanCapitalManagementLeaveTypeEntityModule,
                        AXMHumanCapitalManagementLeaveRequestEntityModule,
                        AXMLeaveRequestFeatureModule,
                    ],
                    providers: [
                        {
                            provide: AXP_IDENTIFIER_RULES,
                            multi: true,
                            useValue: AXM_EMPLOYEE_CODE_IDENTIFIER_RULE,
                        },
                        {
                            provide: AXP_ENTITY_DEFINITION_LOADER,
                            useClass: AXMHumanCapitalModuleEntityProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_MENU_PROVIDER,
                            useClass: AXMMenuProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_SETTING_DEFINITION_PROVIDER,
                            useFactory: async () => {
                                const injector = inject(Injector);
                                const provider = (await import('./acorex-modules-human-capital-management-settings.provider-rRaBaVeh.mjs')).AXMSettingProvider;
                                return new provider(injector);
                            },
                            multi: true,
                        },
                        {
                            provide: AXP_DATASOURCE_DEFINITION_PROVIDER,
                            useClass: AXMEmployeeDataSourceDefinition,
                            multi: true,
                        },
                        {
                            provide: AXP_DATASOURCE_DEFINITION_PROVIDER,
                            useClass: AXMSkillDataSourceDefinition,
                            multi: true,
                        },
                        {
                            provide: AXP_DATASOURCE_DEFINITION_PROVIDER,
                            useClass: AXMSkillLevelDataSourceDefinition,
                            multi: true,
                        },
                        {
                            provide: AXP_DATASOURCE_DEFINITION_PROVIDER,
                            useClass: AXMEmploymentTypeDataSourceDefinition,
                            multi: true,
                        },
                    ],
                }]
        }] });

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

export { AXMHumanCapitalManagementEmployeeEntityService as A, RootConfig as R, AXMHumanCapitalManagementEmploymentTypeEntityService as a, AXMHumanCapitalManagementSkillEntityService as b, AXMHumanCapitalManagementSkillLevelEntityService as c, AXMHumanCapitalManagementEmployeeSkillEntityService as d, AXMHumanCapitalManagementPositionAssignmentEntityService as e, AXMHumanCapitalManagementLeaveTypeEntityService as f, AXMHumanCapitalManagementLeaveRequestEntityService as g, AXPApproveLeaveCommand as h, AXPRejectLeaveCommand as i, AXPCancelLeaveCommand as j, AXMLeaveRequestTaskProvider as k, AXPLeaveRequestDialogService as l, AXMLeaveRequestBadgeProvider as m, AXMHumanCapitalManagementModule as n };
//# sourceMappingURL=acorex-modules-human-capital-management-acorex-modules-human-capital-management-cb1hY8I2.mjs.map
