import { nftPaymentBeet } from '@metaplex-foundation/mpl-candy-guard';
import { GuardMintSettingsMissingError } from '../errors';
import { createSerializerFromBeet } from '../../../types';
/** @internal */
export const nftPaymentGuardManifest = {
    name: 'nftPayment',
    settingsBytes: 64,
    settingsSerializer: createSerializerFromBeet(nftPaymentBeet),
    mintSettingsParser: ({ metaplex, settings, mintSettings, payer, programs, }) => {
        var _a;
        if (!mintSettings) {
            throw new GuardMintSettingsMissingError('nftPayment');
        }
        const associatedTokenProgram = metaplex
            .programs()
            .getAssociatedToken(programs);
        const nftTokenAccount = (_a = mintSettings.tokenAccount) !== null && _a !== void 0 ? _a : metaplex.tokens().pdas().associatedTokenAccount({
            mint: mintSettings.mint,
            owner: payer.publicKey,
            programs,
        });
        const nftMetadata = metaplex.nfts().pdas().metadata({
            mint: mintSettings.mint,
            programs,
        });
        const destinationAta = metaplex.tokens().pdas().associatedTokenAccount({
            mint: mintSettings.mint,
            owner: settings.destination,
            programs,
        });
        return {
            arguments: Buffer.from([]),
            remainingAccounts: [
                {
                    isSigner: false,
                    address: nftTokenAccount,
                    isWritable: true,
                },
                {
                    isSigner: false,
                    address: nftMetadata,
                    isWritable: true,
                },
                {
                    isSigner: false,
                    address: mintSettings.mint,
                    isWritable: false,
                },
                {
                    isSigner: false,
                    address: settings.destination,
                    isWritable: false,
                },
                {
                    isSigner: false,
                    address: destinationAta,
                    isWritable: true,
                },
                {
                    isSigner: false,
                    address: associatedTokenProgram.address,
                    isWritable: false,
                },
            ],
        };
    },
};
//# sourceMappingURL=nftPayment.js.map