"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importDefault(require("react"));
var commons_1 = require("@universal-login/commons");
var TransferDropdownItem_1 = require("./TransferDropdownItem");
var useToggler_1 = require("../../hooks/useToggler");
var getIconForToken_1 = require("../../../core/utils/getIconForToken");
exports.TransferDropdown = function (_a) {
    var sdk = _a.sdk, tokenDetailsWithBalance = _a.tokenDetailsWithBalance, tokenDetails = _a.tokenDetails, setToken = _a.setToken, className = _a.className;
    var _b = useToggler_1.useToggler(), visible = _b.visible, toggle = _b.toggle;
    var onClick = function (token) {
        toggle();
        setToken(token);
    };
    var renderTransferDropdownItems = function (tokensDetails, predicate, dropdownClassName) {
        return tokensDetails
            .filter(predicate)
            .map(function (tokenDetails) { return renderTransferDropdownItem(tokenDetails, dropdownClassName); });
    };
    var renderTransferDropdownItem = function (tokenDetails, dropdownClassName) { return (react_1.default.createElement(TransferDropdownItem_1.TransferDropdownItem, { key: tokenDetails.name + "-" + tokenDetails.symbol, sdk: sdk, dropdownClassName: dropdownClassName, className: className, tokenDetails: tokenDetails, icon: getIconForToken_1.getIconForToken(tokenDetails.symbol), balance: commons_1.getBalanceOf(tokenDetails.symbol, tokenDetailsWithBalance), onClick: onClick })); };
    return (react_1.default.createElement("div", { className: "currency-accordion" },
        renderTransferDropdownItems(sdk.tokensDetailsStore.tokensDetails, function (_a) {
            var symbol = _a.symbol;
            return symbol === tokenDetails.symbol;
        }, "currency-accordion-btn currency-accordion-item " + (visible ? 'expaned' : '')),
        visible &&
            react_1.default.createElement("div", { className: "currency-scrollable-list" }, renderTransferDropdownItems(sdk.tokensDetailsStore.tokensDetails, function (_a) {
                var symbol = _a.symbol;
                return symbol !== tokenDetails.symbol;
            }, 'currency-accordion-item currency-accordion-item-list'))));
};
//# sourceMappingURL=TransferDropdown.js.map