"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.approvalsOfAt = approvalsOfAt;

var _operators = require("rxjs/operators");

var _approvalFlagsToBools = require("../util/approvalFlagsToBools");

var _drr = require("../util/drr");

// Copyright 2017-2019 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.

/**
 * @name approvalsOfAt
 * @returns An array of boolean approvals for the account and set index, converted from the returned ApprovalFlag.
 * @example
 * <BR>
 *
 * ```javascript
 * api.derive.elections.approvalsOfAt(ALICE, new BN(0), (approvals) => {
 *   // approvals === [false, true, ...]
 * });
 * ```
 */
function approvalsOfAt(api) {
  return (who, at) => api.query.elections.approvalsOf([who.toString(), at]).pipe((0, _operators.map)(flags => (0, _approvalFlagsToBools.approvalFlagsToBools)(flags)), (0, _drr.drr)());
}