import * as i0 from '@angular/core';
import { inject, Injectable } from '@angular/core';
import { AXPEntityStorageService } from '@acorex/platform/layout/entity';

//#endregion
/**
 * Complete Signature Process Command (Backend - Mock)
 *
 * Completes the signature process and updates the entity record.
 * This command runs on the backend and finalizes the signature workflow.
 */
class AXCCompleteSignatureProcessCommand {
    constructor() {
        //#region ----   Services & Dependencies   ----
        this.storageService = inject(AXPEntityStorageService);
    }
    //#endregion
    //#region ----   AXPCommand Implementation   ----
    async execute(input) {
        try {
            console.log(`[AXCCompleteSignatureProcessCommand] Completing signature process for ${input.refType}:${input.refId}`);
            // Validate inputs
            if (!input.signatureRequestId || !input.refId || !input.refType) {
                throw new Error('Invalid input: signatureRequestId, refId, and refType are required');
            }
            // In a real implementation, this would:
            // 1. Mark signature request as completed
            // 2. Update entity record with signature status
            // 3. Store all signatures in the entity
            // 4. Update audit trail
            // 5. Send completion notifications
            // Mock: simulate completion
            // In production, we would update the entity record:
            // await this.storageService.updateOne(input.refType, input.refId, {
            //   signatureStatus: 'completed',
            //   signatureCompletedAt: new Date().toISOString(),
            // });
            console.log(`[AXCCompleteSignatureProcessCommand] Signature process completed successfully`);
            return {
                success: true,
                data: {
                    output: {
                        completed: true,
                    },
                    outcomes: {
                        Done: true,
                    },
                },
            };
        }
        catch (error) {
            console.error(`[AXCCompleteSignatureProcessCommand] Failed to complete signature process:`, error);
            return {
                success: false,
                message: {
                    text: error.message || 'Failed to complete signature process',
                },
                data: {
                    output: {
                        completed: false,
                    },
                    outcomes: {
                        Failed: true,
                    },
                },
            };
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXCCompleteSignatureProcessCommand, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXCCompleteSignatureProcessCommand, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXCCompleteSignatureProcessCommand, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root',
                }]
        }] });

export { AXCCompleteSignatureProcessCommand };
//# sourceMappingURL=acorex-connectivity-mock-complete-signature-process.command-BG_rxbUl.mjs.map
