// Copyright 2023 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
import { plainToInstance } from 'class-transformer';
import { PayloadType } from './payload';
import { TaggedDataPayload } from './tagged';
import { SignedTransactionPayload } from './signed_transaction';
import { CandidacyAnnouncementPayload } from './candidacy-announcement';
export * from './tagged';
export * from './signed_transaction';
export * from './payload';
export * from './candidacy-announcement';
export var PayloadDiscriminator = {
    property: 'type',
    subTypes: [
        { value: TaggedDataPayload, name: PayloadType.TaggedData },
        {
            value: SignedTransactionPayload,
            name: PayloadType.SignedTransaction
        },
        {
            value: CandidacyAnnouncementPayload,
            name: PayloadType.CandidacyAnnouncement
        },
    ]
};
export function parsePayload(data) {
    if (data.type == PayloadType.TaggedData) {
        return plainToInstance(TaggedDataPayload, data);
    }
    else if (data.type == PayloadType.SignedTransaction) {
        return plainToInstance(SignedTransactionPayload, data);
    }
    else if (data.type == PayloadType.CandidacyAnnouncement) {
        return plainToInstance(CandidacyAnnouncementPayload, data);
    }
    throw new Error('Invalid JSON');
}
//# sourceMappingURL=index.js.map