"use strict";
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
    if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
    return cooked;
};
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = __importStar(require("react"));
var elements_1 = require("@joincivil/elements");
var styled_components_1 = __importDefault(require("styled-components"));
var context_1 = require("../context");
var utils_1 = require("@joincivil/utils");
var AvatarLoginWrapper = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n  position: relative;\n"], ["\n  position: relative;\n"])));
var AvatarImg = styled_components_1.default.img(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n  border-radius: 50%;\n  height: 20px;\n  width: 20px;\n"], ["\n  border-radius: 50%;\n  height: 20px;\n  width: 20px;\n"])));
var AvatarLoginAvatarBtn = styled_components_1.default.button(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n  align-items: center;\n  background-color: transparent;\n  border: none;\n  cursor: pointer;\n  display: flex;\n  justify-content: space-between;\n  outline: none;\n  padding: 5px;\n  width: 45px;\n"], ["\n  align-items: center;\n  background-color: transparent;\n  border: none;\n  cursor: pointer;\n  display: flex;\n  justify-content: space-between;\n  outline: none;\n  padding: 5px;\n  width: 45px;\n"])));
var AvatarLoginDropdown = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n  background-color: ", ";\n  border: 1px solid ", ";\n  border-radius: 4px;\n  box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);\n  padding: 5px 0;\n  position: absolute;\n  right: 0;\n  top: 30px;\n  width: 120px;\n"], ["\n  background-color: ", ";\n  border: 1px solid ", ";\n  border-radius: 4px;\n  box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);\n  padding: 5px 0;\n  position: absolute;\n  right: 0;\n  top: 30px;\n  width: 120px;\n"])), elements_1.colors.basic.WHITE, elements_1.colors.accent.CIVIL_GRAY_4);
var AvatarLoginOptionBtn = styled_components_1.default.button(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n  background-color: ", ";\n  border: none;\n  color: ", ";\n  cursor: pointer;\n  font-size: 13px;\n  line-height: 16px;\n  outline: none;\n  padding: 5px 12px;\n  text-align: left;\n  transition: color 250ms;\n  width: 100%;\n\n  &:hover {\n    color: ", ";\n  }\n"], ["\n  background-color: ", ";\n  border: none;\n  color: ", ";\n  cursor: pointer;\n  font-size: 13px;\n  line-height: 16px;\n  outline: none;\n  padding: 5px 12px;\n  text-align: left;\n  transition: color 250ms;\n  width: 100%;\n\n  &:hover {\n    color: ", ";\n  }\n"])), elements_1.colors.basic.WHITE, elements_1.colors.accent.CIVIL_GRAY_1, elements_1.colors.accent.CIVIL_BLUE);
var AvatarLoginOptionLink = styled_components_1.default.a(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n  color: ", ";\n  cursor: pointer;\n  font-size: 13px;\n  line-height: 16px;\n  padding: 5px 12px;\n  transition: color 250ms;\n  width: 100%;\n\n  &:hover {\n    color: ", ";\n  }\n"], ["\n  color: ", ";\n  cursor: pointer;\n  font-size: 13px;\n  line-height: 16px;\n  padding: 5px 12px;\n  transition: color 250ms;\n  width: 100%;\n\n  &:hover {\n    color: ", ";\n  }\n"])), elements_1.colors.accent.CIVIL_GRAY_1, elements_1.colors.accent.CIVIL_BLUE);
var AvatarLogin = /** @class */ (function (_super) {
    __extends(AvatarLogin, _super);
    function AvatarLogin(props) {
        var _this = _super.call(this, props) || this;
        _this.state = { isOpen: false };
        return _this;
    }
    AvatarLogin.prototype.render = function () {
        var _this = this;
        var currentUser = this.context && this.context.currentUser;
        var showWeb3Login = this.context.auth.showWeb3Login;
        var logout = this.context.auth.logout.bind(this.context.auth);
        return (React.createElement(AvatarLoginWrapper, null, currentUser ? (React.createElement(React.Fragment, null,
            React.createElement(AvatarLoginAvatarBtn, { onClick: function () { return _this.setState({ isOpen: !_this.state.isOpen }); } },
                currentUser.userChannel.tiny72AvatarDataUrl ? (React.createElement(AvatarImg, { src: currentUser.userChannel.tiny72AvatarDataUrl })) : (React.createElement(elements_1.AvatarGenericIcon, null)),
                React.createElement(elements_1.DropdownArrow, null)),
            this.state.isOpen && (React.createElement(AvatarLoginDropdown, null,
                React.createElement(AvatarLoginOptionLink, { href: utils_1.urlConstants.DASHBOARD, target: "_blank" }, "Your Profile"),
                React.createElement(AvatarLoginOptionBtn, { onClick: logout }, "Logout"))))) : (React.createElement(React.Fragment, null,
            React.createElement(AvatarLoginAvatarBtn, { onClick: function () { return _this.setState({ isOpen: !_this.state.isOpen }); } },
                React.createElement(elements_1.AvatarGenericIcon, null),
                React.createElement(elements_1.DropdownArrow, null)),
            this.state.isOpen && (React.createElement(AvatarLoginDropdown, null,
                React.createElement(AvatarLoginOptionBtn, { onClick: showWeb3Login }, "Log In / Sign Up")))))));
    };
    AvatarLogin.contextType = context_1.CivilContext;
    return AvatarLogin;
}(React.Component));
exports.AvatarLogin = AvatarLogin;
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
//# sourceMappingURL=AvatarLogin.js.map