"use strict";
// Copyright 2023 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.parsePayload = exports.PayloadDiscriminator = void 0;
const class_transformer_1 = require("class-transformer");
const payload_1 = require("./payload");
const tagged_1 = require("./tagged");
const signed_transaction_1 = require("./signed_transaction");
const candidacy_announcement_1 = require("./candidacy-announcement");
__exportStar(require("./tagged"), exports);
__exportStar(require("./signed_transaction"), exports);
__exportStar(require("./payload"), exports);
__exportStar(require("./candidacy-announcement"), exports);
exports.PayloadDiscriminator = {
    property: 'type',
    subTypes: [
        { value: tagged_1.TaggedDataPayload, name: payload_1.PayloadType.TaggedData },
        {
            value: signed_transaction_1.SignedTransactionPayload,
            name: payload_1.PayloadType.SignedTransaction,
        },
        {
            value: candidacy_announcement_1.CandidacyAnnouncementPayload,
            name: payload_1.PayloadType.CandidacyAnnouncement,
        },
    ],
};
function parsePayload(data) {
    if (data.type == payload_1.PayloadType.TaggedData) {
        return (0, class_transformer_1.plainToInstance)(tagged_1.TaggedDataPayload, data);
    }
    else if (data.type == payload_1.PayloadType.SignedTransaction) {
        return (0, class_transformer_1.plainToInstance)(signed_transaction_1.SignedTransactionPayload, data);
    }
    else if (data.type == payload_1.PayloadType.CandidacyAnnouncement) {
        return (0, class_transformer_1.plainToInstance)(candidacy_announcement_1.CandidacyAnnouncementPayload, data);
    }
    throw new Error('Invalid JSON');
}
exports.parsePayload = parsePayload;
//# sourceMappingURL=index.js.map