import * as i0 from '@angular/core';
import { Injectable } from '@angular/core';

//#endregion
/**
 * Validate All Signatures Command (Backend - Mock)
 *
 * Validates whether all required signatures have been collected.
 * This command runs on the backend and checks signature status.
 */
class AXCValidateAllSignaturesCommand {
    //#region ----   AXPCommand Implementation   ----
    async execute(input) {
        try {
            console.log(`[AXCValidateAllSignaturesCommand] Validating signatures for request: ${input.signatureRequestId}, required: ${input.requiredSigners}`);
            // Validate inputs
            if (!input.signatureRequestId || input.requiredSigners < 1) {
                throw new Error('Invalid input: signatureRequestId and requiredSigners >= 1 are required');
            }
            // In a real implementation, this would:
            // 1. Query the database for signature request
            // 2. Count collected signatures
            // 3. Compare with required count
            // 4. Check signature validity
            // Mock: simulate signature validation
            // For now, we'll use a simple approach where we track signatures in workflow state
            // In a real system, this would query the database
            // TODO: This should track actual signatures from workflow state or database
            const signedCount = Math.floor(Math.random() * (input.requiredSigners + 1)); // Mock: random for demo
            const allSigned = signedCount >= input.requiredSigners;
            console.log(`[AXCValidateAllSignaturesCommand] Validation result: ${signedCount}/${input.requiredSigners} signatures collected, allSigned: ${allSigned}`);
            // Determine outcome
            let outcome;
            if (allSigned) {
                outcome = { AllSigned: true };
            }
            else {
                outcome = { Pending: true };
            }
            return {
                success: true,
                data: {
                    output: {
                        allSigned,
                        signedCount,
                    },
                    outcomes: outcome,
                },
            };
        }
        catch (error) {
            console.error(`[AXCValidateAllSignaturesCommand] Failed to validate signatures:`, error);
            return {
                success: false,
                message: {
                    text: error.message || 'Failed to validate signatures',
                },
                data: {
                    output: {
                        allSigned: false,
                        signedCount: 0,
                    },
                    outcomes: {
                        Failed: true,
                    },
                },
            };
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXCValidateAllSignaturesCommand, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXCValidateAllSignaturesCommand, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXCValidateAllSignaturesCommand, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root',
                }]
        }] });

export { AXCValidateAllSignaturesCommand };
//# sourceMappingURL=acorex-connectivity-mock-validate-all-signatures.command-leYngRtS.mjs.map
