"use strict";
var __read = (this && this.__read) || function (o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
    for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
        to[j] = from[i];
    return to;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getInitializeAccounts = exports.createInitializeInstruction = void 0;
var web3_js_1 = require("@solana/web3.js");
var program_1 = require("../program");
var accounts_1 = require("../accounts");
function createInitializeInstruction(wormholeProgramId, payer, guardianSetExpirationTime, fee, initialGuardians) {
    var methods = program_1.createReadOnlyWormholeProgramInterface(wormholeProgramId).methods.initialize(guardianSetExpirationTime, fee, initialGuardians);
    // @ts-ignore
    return methods._ixFn.apply(methods, __spreadArray(__spreadArray([], __read(methods._args)), [{
            accounts: getInitializeAccounts(wormholeProgramId, payer),
            signers: undefined,
            remainingAccounts: undefined,
            preInstructions: undefined,
            postInstructions: undefined,
        }]));
}
exports.createInitializeInstruction = createInitializeInstruction;
function getInitializeAccounts(wormholeProgramId, payer) {
    return {
        bridge: accounts_1.deriveWormholeBridgeDataKey(wormholeProgramId),
        guardianSet: accounts_1.deriveGuardianSetKey(wormholeProgramId, 0),
        feeCollector: accounts_1.deriveFeeCollectorKey(wormholeProgramId),
        payer: new web3_js_1.PublicKey(payer),
        clock: web3_js_1.SYSVAR_CLOCK_PUBKEY,
        rent: web3_js_1.SYSVAR_RENT_PUBKEY,
        systemProgram: web3_js_1.SystemProgram.programId,
    };
}
exports.getInitializeAccounts = getInitializeAccounts;
