"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 __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importStar(require("react"));
var useAsyncEffect_1 = require("../hooks/useAsyncEffect");
var Balance_1 = require("../commons/Balance");
var Assets_1 = require("../commons/Assets");
var getStyleForTopLevelComponent_1 = require("../../core/utils/getStyleForTopLevelComponent");
require("./../styles/funds.sass");
require("./../styles/fundsDefault.sass");
var NewDeviceMessage_1 = require("./Devices/NewDeviceMessage");
exports.Funds = function (_a) {
    var deployedWallet = _a.deployedWallet, onTopUpClick = _a.onTopUpClick, onSendClick = _a.onSendClick, className = _a.className, onDeviceMessageClick = _a.onDeviceMessageClick;
    var sdk = deployedWallet.sdk, contractAddress = deployedWallet.contractAddress;
    var _b = __read(react_1.useState({}), 2), totalTokensValue = _b[0], setTotalTokensValue = _b[1];
    useAsyncEffect_1.useAsyncEffect(function () { return sdk.subscribeToAggregatedBalance(contractAddress, setTotalTokensValue); }, []);
    return (react_1.default.createElement("div", { className: "universal-login-funds" },
        react_1.default.createElement("div", { className: getStyleForTopLevelComponent_1.getStyleForTopLevelComponent(className) },
            react_1.default.createElement("div", { className: "funds" },
                react_1.default.createElement(NewDeviceMessage_1.NewDeviceMessage, { deployedWallet: deployedWallet, onManageClick: onDeviceMessageClick, className: className }),
                react_1.default.createElement(Balance_1.Balance, { amount: totalTokensValue['USD'], className: className }),
                react_1.default.createElement("div", { className: "funds-row" },
                    react_1.default.createElement("div", { className: "funds-buttons" },
                        react_1.default.createElement("button", { className: "funds-btn funds-topup", onClick: onTopUpClick }, "Top-up"),
                        react_1.default.createElement("button", { id: "transferFunds", className: "funds-btn funds-send", onClick: onSendClick }, "Send")),
                    react_1.default.createElement(Assets_1.Assets, { deployedWallet: deployedWallet, className: className }))))));
};
//# sourceMappingURL=Funds.js.map