"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findProgramAddress = void 0;
const anchor_1 = require("@project-serum/anchor");
const web3_js_1 = require("@solana/web3.js");
const findProgramAddress = (label, programId, extraSeeds) => {
    const seeds = [Buffer.from(anchor_1.utils.bytes.utf8.encode(label))];
    if (extraSeeds) {
        for (const extraSeed of extraSeeds) {
            if (typeof extraSeed === 'string') {
                seeds.push(Buffer.from(anchor_1.utils.bytes.utf8.encode(extraSeed)));
            }
            else if (Array.isArray(extraSeed)) {
                seeds.push(Buffer.from(extraSeed));
            }
            else if (Buffer.isBuffer(extraSeed)) {
                seeds.push(extraSeed);
            }
            else {
                seeds.push(extraSeed.toBuffer());
            }
        }
    }
    const res = web3_js_1.PublicKey.findProgramAddressSync(seeds, programId);
    return { publicKey: res[0], bump: res[1] };
};
exports.findProgramAddress = findProgramAddress;
//# sourceMappingURL=index.js.map