"use strict";
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 = __importStar(require("react"));
var Button_1 = require("../Button");
var NavLink_1 = require("./NavLink");
var styledComponents_1 = require("./styledComponents");
var textComponents_1 = require("./textComponents");
var context_1 = require("../context");
var UserAccount = function (props) {
    var civilContext = React.useContext(context_1.CivilContext);
    var civilUser = civilContext.currentUser;
    var userEthAddress = props.userEthAddress, enableEthereum = props.enableEthereum, onLoginPressed = props.onLoginPressed, onSignupPressed = props.onSignupPressed;
    if (civilUser && userEthAddress) {
        var userAccountElRef = React.createRef();
        var child = void 0;
        if (props.children) {
            child = React.cloneElement(props.children, {
                userAccountElRef: userAccountElRef,
            });
        }
        return (React.createElement(React.Fragment, null,
            React.createElement(styledComponents_1.StyledVisibleIfLoggedInLink, null,
                React.createElement(NavLink_1.NavLink, { to: "/dashboard" },
                    React.createElement(textComponents_1.NavLinkDashboardText, null))),
            React.createElement("div", { ref: userAccountElRef },
                React.createElement(styledComponents_1.NavUser, { onClick: function (ev) { return props.toggleDrawer(); } },
                    React.createElement(styledComponents_1.CvlContainer, null,
                        React.createElement(styledComponents_1.AvatarContainer, null,
                            React.createElement(styledComponents_1.UserAvatar, null)),
                        React.createElement(styledComponents_1.HandleContainer, null, civilUser.userChannel.handle),
                        React.createElement(styledComponents_1.Arrow, { isOpen: props.isUserDrawerOpen })))),
            child));
    }
    else if (civilUser && enableEthereum && !userEthAddress) {
        return (React.createElement(styledComponents_1.LogInButton, { onClick: props.enableEthereum, size: Button_1.buttonSizes.SMALL }, "Connect Wallet"));
    }
    return (React.createElement(React.Fragment, null,
        React.createElement(styledComponents_1.BorderlessNavBarButton, { onClick: onLoginPressed }, "Log In"),
        React.createElement(styledComponents_1.NavBarButton, { onClick: onSignupPressed }, "Sign Up")));
};
exports.default = UserAccount;
//# sourceMappingURL=UserAccount.js.map