// SPDX-License-Identifier: Apache-2.0
import { InvalidRequest } from "../../../app/usecase/command/error/InvalidRequest";
import ValidatedDomain from "../../../core/validation/ValidatedArgs";
export class TrexTokenDetailsAts extends ValidatedDomain {
    owner;
    irs;
    onchainId;
    irAgents;
    tokenAgents;
    compliancesModules;
    complianceSettings;
    constructor(params) {
        super({
            irAgents: (val) => {
                return TrexTokenDetailsAts.checkMaxAgents(val, params.tokenAgents);
            },
            tokenAgents: (val) => {
                return TrexTokenDetailsAts.checkMaxAgents(params.irAgents, val);
            },
            compliancesModules: (val) => {
                return TrexTokenDetailsAts.checkComplianceModules(val, params.complianceSettings);
            },
            complianceSettings: (val) => {
                return TrexTokenDetailsAts.checkComplianceModules(params.compliancesModules, val);
            },
        });
        const { owner, irs, onchainId, irAgents = [], tokenAgents = [], compliancesModules = [], complianceSettings = [], } = params;
        this.owner = owner;
        this.irs = irs;
        this.onchainId = onchainId;
        this.irAgents = irAgents;
        this.tokenAgents = tokenAgents;
        this.compliancesModules = compliancesModules;
        this.complianceSettings = complianceSettings;
        ValidatedDomain.handleValidation(TrexTokenDetailsAts.name, this);
    }
    static checkMaxAgents(irAgents, tokenAgents) {
        const errorList = [];
        if (irAgents.length > 5 || tokenAgents.length > 5) {
            errorList.push(new InvalidRequest("max 5 agents at deployment"));
        }
        return errorList;
    }
    static checkComplianceModules(compliancesModules, complianceSettings) {
        const errorList = [];
        if (compliancesModules.length > 30) {
            errorList.push(new InvalidRequest("max 30 module actions at deployment"));
        }
        if (compliancesModules.length < complianceSettings.length) {
            errorList.push(new InvalidRequest("invalid compliance pattern"));
        }
        return errorList;
    }
}
export class TrexClaimDetails extends ValidatedDomain {
    claimTopics;
    issuers;
    issuerClaims;
    constructor(params) {
        super({
            claimTopics: (val) => {
                return TrexClaimDetails.checkClaimTopics(val);
            },
            issuers: (val) => {
                return TrexClaimDetails.checkIssuers(val, params.issuerClaims);
            },
        });
        const { claimTopics = [], issuers = [], issuerClaims = [] } = params;
        this.claimTopics = claimTopics;
        this.issuers = issuers;
        this.issuerClaims = issuerClaims;
        ValidatedDomain.handleValidation(TrexClaimDetails.name, this);
    }
    static checkClaimTopics(value) {
        const errorList = [];
        if (value.length > 5) {
            errorList.push(new InvalidRequest("max 5 claim topics at deployment"));
        }
        return errorList;
    }
    static checkIssuers(issuers, issuerClaims) {
        const errorList = [];
        if (issuers.length > 5) {
            errorList.push(new InvalidRequest("max 5 claim issuers at deployment"));
        }
        if (issuers.length !== issuerClaims.length) {
            errorList.push(new InvalidRequest("claim pattern not valid"));
        }
        return errorList;
    }
}
