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;
};
import React, { useState } from 'react';
import { useAsyncEffect } from '../hooks/useAsyncEffect';
import { Balance } from '../commons/Balance';
import { Assets } from '../commons/Assets';
import { getStyleForTopLevelComponent } from '../../core/utils/getStyleForTopLevelComponent';
import './../styles/funds.sass';
import './../styles/fundsDefault.sass';
import { NewDeviceMessage } from './Devices/NewDeviceMessage';
export var 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(useState({}), 2), totalTokensValue = _b[0], setTotalTokensValue = _b[1];
    useAsyncEffect(function () { return sdk.subscribeToAggregatedBalance(contractAddress, setTotalTokensValue); }, []);
    return (React.createElement("div", { className: "universal-login-funds" },
        React.createElement("div", { className: getStyleForTopLevelComponent(className) },
            React.createElement("div", { className: "funds" },
                React.createElement(NewDeviceMessage, { deployedWallet: deployedWallet, onManageClick: onDeviceMessageClick, className: className }),
                React.createElement(Balance, { amount: totalTokensValue['USD'], className: className }),
                React.createElement("div", { className: "funds-row" },
                    React.createElement("div", { className: "funds-buttons" },
                        React.createElement("button", { className: "funds-btn funds-topup", onClick: onTopUpClick }, "Top-up"),
                        React.createElement("button", { id: "transferFunds", className: "funds-btn funds-send", onClick: onSendClick }, "Send")),
                    React.createElement(Assets, { deployedWallet: deployedWallet, className: className }))))));
};
//# sourceMappingURL=Funds.js.map