"use strict";
// SPDX-License-Identifier: Apache-2.0
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const OptionalDecorator_1 = require("../../../../core/decorator/OptionalDecorator");
const Security_1 = require("../../../../domain/context/security/Security");
const ValidatedArgs_1 = __importDefault(require("../../../../core/validation/ValidatedArgs"));
const FormatValidation_1 = __importDefault(require("../FormatValidation"));
const SecurityDate_1 = require("../../../../domain/context/shared/SecurityDate");
const Factories_1 = require("../../../../domain/context/factory/Factories");
const InvalidValue_1 = require("../error/InvalidValue");
class CreateTrexSuiteBondRequest extends ValidatedArgs_1.default {
    salt;
    owner;
    irs;
    onchainId;
    irAgents;
    tokenAgents;
    compliancesModules;
    complianceSettings;
    claimTopics;
    issuers;
    issuerClaims;
    name;
    symbol;
    isin;
    _decimals;
    get decimals() {
        return this._decimals;
    }
    set decimals(value) {
        this._decimals = typeof value === "number" ? value : parseFloat(value);
    }
    isWhiteList;
    erc20VotesActivated;
    isControllable;
    arePartitionsProtected;
    isMultiPartition;
    clearingActive;
    internalKycActivated;
    externalPauses;
    externalControlLists;
    externalKycLists;
    diamondOwnerAccount;
    complianceId;
    identityRegistryId;
    proceedRecipientsIds;
    proceedRecipientsData;
    currency;
    numberOfUnits;
    nominalValue;
    nominalValueDecimals;
    startingDate;
    maturityDate;
    regulationType;
    regulationSubType;
    isCountryControlListWhiteList;
    countries;
    info;
    configId;
    configVersion;
    constructor({ salt, owner, irs, onchainId, irAgents, tokenAgents, compliancesModules, complianceSettings, claimTopics, issuers, issuerClaims, name, symbol, isin, decimals, isWhiteList, erc20VotesActivated, isControllable, arePartitionsProtected, isMultiPartition, clearingActive, internalKycActivated, externalPauses, externalControlLists, externalKycLists, diamondOwnerAccount, currency, numberOfUnits, nominalValue, nominalValueDecimals, startingDate, maturityDate, regulationType, regulationSubType, isCountryControlListWhiteList, countries, info, configId, configVersion, complianceId, identityRegistryId, proceedRecipientsIds, proceedRecipientsData, }) {
        super({
            name: (val) => {
                return Security_1.Security.checkName(val);
            },
            symbol: (val) => {
                return Security_1.Security.checkSymbol(val);
            },
            isin: (val) => {
                return Security_1.Security.checkISIN(val);
            },
            decimals: (val) => {
                return Security_1.Security.checkInteger(val);
            },
            diamondOwnerAccount: FormatValidation_1.default.checkHederaIdFormatOrEvmAddress(false),
            currency: FormatValidation_1.default.checkBytes3Format(),
            numberOfUnits: FormatValidation_1.default.checkNumber(),
            nominalValue: FormatValidation_1.default.checkNumber(),
            startingDate: (val) => {
                return SecurityDate_1.SecurityDate.checkDateTimestamp(parseInt(val), Math.ceil(new Date().getTime() / 1000), parseInt(this.maturityDate));
            },
            maturityDate: (val) => {
                return SecurityDate_1.SecurityDate.checkDateTimestamp(parseInt(val), parseInt(this.startingDate), undefined);
            },
            regulationType: (val) => {
                return Factories_1.Factory.checkRegulationType(val);
            },
            regulationSubType: (val) => {
                return Factories_1.Factory.checkRegulationSubType(val, this.regulationType);
            },
            configId: FormatValidation_1.default.checkBytes32Format(),
            externalPauses: (val) => {
                return FormatValidation_1.default.checkHederaIdOrEvmAddressArray(val ?? [], "externalPauses", true);
            },
            externalControlLists: (val) => {
                return FormatValidation_1.default.checkHederaIdOrEvmAddressArray(val ?? [], "externalControlLists", true);
            },
            externalKycLists: (val) => {
                return FormatValidation_1.default.checkHederaIdOrEvmAddressArray(val ?? [], "externalKycLists", true);
            },
            complianceId: FormatValidation_1.default.checkHederaIdFormatOrEvmAddress(true),
            identityRegistryId: FormatValidation_1.default.checkHederaIdFormatOrEvmAddress(true),
            claimTopics: FormatValidation_1.default.checkArrayNumber(),
            proceedRecipientsIds: (val) => {
                return FormatValidation_1.default.checkHederaIdOrEvmAddressArray(val ?? [], "proceedRecipientsIds", true);
            },
            proceedRecipientsData: (val) => {
                const validation = FormatValidation_1.default.checkBytesFormat();
                if (val?.length != this.proceedRecipientsIds?.length) {
                    return [
                        new InvalidValue_1.InvalidValue(`The list of proceedRecipientsIds and proceedRecipientsData must have equal length.`),
                    ];
                }
                for (const data of val ?? []) {
                    if (data == "")
                        continue;
                    const result = validation(data);
                    if (result)
                        return result;
                }
            },
        });
        this.salt = salt;
        this.owner = owner;
        this.irs = irs;
        this.onchainId = onchainId;
        this.irAgents = irAgents;
        this.tokenAgents = tokenAgents;
        this.compliancesModules = compliancesModules;
        this.complianceSettings = complianceSettings;
        this.claimTopics = claimTopics;
        this.issuers = issuers;
        this.issuerClaims = issuerClaims;
        this.name = name;
        this.symbol = symbol;
        this.isin = isin;
        this.decimals = typeof decimals === "number" ? decimals : parseInt(decimals);
        this.isWhiteList = isWhiteList;
        this.erc20VotesActivated = erc20VotesActivated;
        this.isControllable = isControllable;
        this.arePartitionsProtected = arePartitionsProtected;
        this.isMultiPartition = isMultiPartition;
        this.clearingActive = clearingActive;
        this.internalKycActivated = internalKycActivated;
        this.diamondOwnerAccount = diamondOwnerAccount;
        this.externalPauses = externalPauses;
        this.externalControlLists = externalControlLists;
        this.externalKycLists = externalKycLists;
        this.currency = currency;
        this.numberOfUnits = numberOfUnits;
        this.nominalValue = nominalValue;
        this.nominalValueDecimals = nominalValueDecimals;
        this.startingDate = startingDate;
        this.maturityDate = maturityDate;
        this.regulationType = regulationType;
        this.regulationSubType = regulationSubType;
        this.isCountryControlListWhiteList = isCountryControlListWhiteList;
        this.countries = countries;
        this.info = info;
        this.configId = configId;
        this.configVersion = configVersion;
        this.complianceId = complianceId;
        this.identityRegistryId = identityRegistryId;
        this.proceedRecipientsIds = proceedRecipientsIds;
        this.proceedRecipientsData = proceedRecipientsData;
    }
}
exports.default = CreateTrexSuiteBondRequest;
__decorate([
    (0, OptionalDecorator_1.OptionalField)(),
    __metadata("design:type", Array)
], CreateTrexSuiteBondRequest.prototype, "externalPauses", void 0);
__decorate([
    (0, OptionalDecorator_1.OptionalField)(),
    __metadata("design:type", Array)
], CreateTrexSuiteBondRequest.prototype, "externalControlLists", void 0);
__decorate([
    (0, OptionalDecorator_1.OptionalField)(),
    __metadata("design:type", Array)
], CreateTrexSuiteBondRequest.prototype, "externalKycLists", void 0);
__decorate([
    (0, OptionalDecorator_1.OptionalField)(),
    __metadata("design:type", String)
], CreateTrexSuiteBondRequest.prototype, "complianceId", void 0);
__decorate([
    (0, OptionalDecorator_1.OptionalField)(),
    __metadata("design:type", String)
], CreateTrexSuiteBondRequest.prototype, "identityRegistryId", void 0);
__decorate([
    (0, OptionalDecorator_1.OptionalField)(),
    __metadata("design:type", Array)
], CreateTrexSuiteBondRequest.prototype, "proceedRecipientsIds", void 0);
__decorate([
    (0, OptionalDecorator_1.OptionalField)(),
    __metadata("design:type", Array)
], CreateTrexSuiteBondRequest.prototype, "proceedRecipientsData", void 0);
