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

//#endregion
/**
 * Request Signature Command (Backend - Mock)
 *
 * Creates a new signature request for an entity record.
 * This command runs on the backend and initializes the signature process.
 */
class AXCRequestSignatureCommand {
    //#region ----   AXPCommand Implementation   ----
    async execute(input) {
        try {
            console.log(`[AXCRequestSignatureCommand] Creating signature request for ${input.refType}:${input.refId}`);
            // Validate inputs
            if (!input.refId || !input.refType || !input.signers || input.signers.length === 0) {
                throw new Error('Invalid input: refId, refType, and at least one signer are required');
            }
            // Generate unique signature request ID
            const signatureRequestId = AXPDataGenerator.uuid();
            // In a real implementation, this would:
            // 1. Create a signature request record in the database
            // 2. Initialize signature tracking for each signer
            // 3. Set initial status to 'pending'
            // 4. Store workflow instance ID if provided
            console.log(`[AXCRequestSignatureCommand] Created signature request: ${signatureRequestId} for ${input.signers.length} signers`);
            return {
                success: true,
                data: {
                    output: {
                        signatureRequestId,
                        workflowInstanceId: input.workflowName ? `${input.workflowName}-${signatureRequestId}` : undefined,
                    },
                    outcomes: {
                        Done: true,
                    },
                },
            };
        }
        catch (error) {
            console.error(`[AXCRequestSignatureCommand] Failed to create signature request:`, error);
            return {
                success: false,
                message: {
                    text: error.message || 'Failed to create signature request',
                },
                data: {
                    output: {
                        signatureRequestId: '',
                        workflowInstanceId: undefined,
                    },
                    outcomes: {
                        Failed: true,
                    },
                },
            };
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXCRequestSignatureCommand, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXCRequestSignatureCommand, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXCRequestSignatureCommand, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root',
                }]
        }] });

export { AXCRequestSignatureCommand };
//# sourceMappingURL=acorex-connectivity-mock-request-signature.command-DZyVnhAp.mjs.map
