"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const lodash_1 = require("lodash");
const IPeerRecovery_1 = require("./IPeerRecovery");
/** @todo */
class PeerRecovery {
    messagePrefix;
    postMessage;
    /** @internal */
    constructor(messagePrefix, postMessage) {
        this.messagePrefix = messagePrefix;
        this.postMessage = postMessage;
    }
    /** @internal */
    async get() {
        const settings = await this.postMessage({ type: this.getMessage('get_peer_recovery') });
        if (!settings.enabled) {
            return (0, lodash_1.pick)(settings, ['enabled', 'autoEnableTimeoutMs']);
        }
        return (0, lodash_1.pick)(settings, ['enabled', 'urlLauncherAddress']);
    }
    /** @internal */
    async set(configuration) {
        (0, IPeerRecovery_1.validatePeerRecoveryConfiguration)(configuration);
        await this.postMessage({ type: this.getMessage('set_peer_recovery'), ...configuration });
    }
    getMessage(name) {
        return this.messagePrefix + '.' + name;
    }
}
exports.default = PeerRecovery;
//# sourceMappingURL=PeerRecovery.js.map