import { CandyGuard as MplCandyGuard, candyGuardBeet, } from '@metaplex-foundation/mpl-candy-guard';
import { CANDY_GUARD_DATA } from '../constants';
import { assertModel, createSerializerFromSolitaType, deserializeAccount, isModel, Pda, toAccountInfo, } from '../../../types';
/** @group Model Helpers */
export const isCandyGuard = (value) => isModel('candyGuard', value);
/** @group Model Helpers */
export function assertCandyGuard(value) {
    assertModel(isCandyGuard(value), `Expected CandyGuard model`);
}
/** @group Model Helpers */
export const toCandyGuard = (account, metaplex) => {
    const candyGuardSerializer = createSerializerFromSolitaType(MplCandyGuard, candyGuardBeet.description);
    const parsedCandyGuard = deserializeAccount(account, candyGuardSerializer);
    const { guards, groups } = metaplex
        .candyMachines()
        .guards()
        .deserializeSettings(account.data.slice(CANDY_GUARD_DATA), account.owner);
    return {
        model: 'candyGuard',
        address: new Pda(parsedCandyGuard.publicKey, parsedCandyGuard.data.bump),
        accountInfo: toAccountInfo(account),
        baseAddress: parsedCandyGuard.data.base,
        authorityAddress: parsedCandyGuard.data.authority,
        guards,
        groups,
    };
};
//# sourceMappingURL=CandyGuard.js.map