import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Col, Dropdown, Row } from "antd";
import { useActions, useAppState } from "src/overmind";
import { NCOLogo } from "./Icons/NCOLogo";
import { UserNewcoinPoolsParticipation } from "./UserWidget";
const roundCurrency = (vals) => {
    const val = vals ? vals[0] : " ";
    const [n, c] = val.split(/ /);
    return n.replace(/\.?0+$/, "") + " " + c;
};
export const Wallet = () => {
    const state = useAppState();
    const user = state.api.auth.user;
    const ncoBalance = state.newcoin.account;
    const gncoBalance = state.newcoin.mainPool;
    if (!user)
        return _jsx(_Fragment, {});
    return (_jsxs("div", { className: "nl-white-box", style: {
            minWidth: "min(450px, 100vh)",
            padding: 0,
        }, children: [_jsxs("div", { style: { padding: "70px 40px 40px 40px" }, children: [_jsx("p", { className: "text-left header-3 u-margin-bottom-medium", children: user.username }), _jsxs(Row, { gutter: 24, children: [_jsx(Col, { className: "text-left", style: {
                                    fontSize: 40,
                                    fontWeight: "bold",
                                }, children: roundCurrency(ncoBalance.acc_balances) }), _jsx(Col, { className: "text-left", style: {
                                    fontSize: 40,
                                    fontWeight: "bold",
                                }, children: roundCurrency(gncoBalance.acc_balances) })] })] }), _jsx("div", { className: "wallet-usernames-wrapper", children: _jsx(UserNewcoinPoolsParticipation, { user: user }) }), _jsx("div", { className: "u-margin-top-medium", children: "\u00A0" })] }));
};
export const WalletWidget = () => {
    // const [visible, setVisible] = useState<boolean>(true);
    const actions = useActions();
    const state = useAppState();
    const setVisible = (v) => actions.ux.setLayout({ walletShown: v });
    // useEffect(() => {
    // 	// setVisible(false);
    // 	actions.ux.setLayout({ walletShown: true  })
    // }, [state.flows.stake.latestMode]);
    return (_jsx("div", { children: _jsx(Dropdown, { visible: state.ux.layout.walletShown, 
            // onVisibleChange={(val) => setVisible(val)}
            overlayStyle: {}, overlay: _jsx(Wallet, {}), children: _jsx("div", { onClick: () => setVisible(!state.ux.layout.walletShown), children: _jsx(NCOLogo, {}) }) }) }));
};
//# sourceMappingURL=Wallet.js.map