"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Header = void 0;
const react_1 = __importDefault(require("react"));
const react_router_dom_1 = require("react-router-dom");
const Button_1 = require("../button/Button");
const Logo_1 = require("../logo/Logo");
const Modal_1 = require("../modal/Modal");
const UserMenu_1 = require("../user/UserMenu");
const Header = ({ profile, expanded, isOpenSupport, toggleLoginModal, signOutAndRedirect, toggleSupport, navigateToNewSearch, renderOnExpanded, renderOnFreshDeskWidget, renderUploader, }) => {
    const [isOpen, setOpen] = react_1.default.useState(false);
    return (react_1.default.createElement(react_1.default.Fragment, null,
        react_1.default.createElement("header", null,
            react_1.default.createElement("div", { className: isOpen
                    ? 'navbar-inner-wrap nav-open'
                    : 'navbar-inner-wrap nav-closed' },
                react_1.default.createElement("div", { className: "navbar-brand" },
                    react_1.default.createElement(react_router_dom_1.NavLink, { to: "/" },
                        react_1.default.createElement(Logo_1.Logo, { horizontal: true, dark: false })),
                    react_1.default.createElement("h1", { className: "sr-only" }, "OpenNeuro")),
                react_1.default.createElement("div", { className: "navbar-navigation" },
                    react_1.default.createElement("span", { className: "mobile-collapse-toggle", onClick: () => setOpen(prev => !prev) },
                        react_1.default.createElement("i", { className: "fas fa-bars" }),
                        react_1.default.createElement("span", null, "menu bar")),
                    react_1.default.createElement("ul", null,
                        react_1.default.createElement("span", { className: "mobile-nav-close-x", onClick: () => setOpen(prev => !prev) }, "\u00D7"),
                        react_1.default.createElement("li", null,
                            react_1.default.createElement(react_router_dom_1.NavLink, { to: "/search", onClick: e => {
                                    e.preventDefault();
                                    setOpen(prev => !prev);
                                    navigateToNewSearch();
                                } }, "Search")),
                        react_1.default.createElement("li", null,
                            react_1.default.createElement("span", { className: "no-a", onClick: () => {
                                    setOpen(prev => !prev);
                                    toggleSupport();
                                } }, "Support")),
                        react_1.default.createElement("li", null,
                            react_1.default.createElement("a", { href: "https://docs.openneuro.org" }, "Documentation")),
                        profile ? (react_1.default.createElement("li", { onClick: () => setOpen(prev => !prev) }, renderUploader())) : null)),
                react_1.default.createElement("div", { className: "navbar-account" }, profile ? (react_1.default.createElement("div", { className: "header-account-btn" },
                    react_1.default.createElement(UserMenu_1.UserMenu, { profile: profile, signOutAndRedirect: signOutAndRedirect }))) : (react_1.default.createElement(react_1.default.Fragment, null,
                    react_1.default.createElement(Button_1.Button, { navbar: true, onClick: toggleLoginModal, label: "Sign in", size: "large" })))),
                expanded ? renderOnExpanded(profile) : null)),
        react_1.default.createElement(Modal_1.Modal, { className: "freshdesk-support", isOpen: isOpenSupport, toggle: toggleSupport, closeText: "Close" },
            react_1.default.createElement("h3", null, "OpenNeuro Support"),
            react_1.default.createElement("p", null,
                "Please email issues or questions to",
                react_1.default.createElement("br", null),
                react_1.default.createElement("a", { href: 'mailto:support@openneuro.freshdesk.com' }, "support@openneuro.freshdesk.com"),
                react_1.default.createElement("br", null),
                "or use the form below."),
            renderOnFreshDeskWidget())));
};
exports.Header = Header;
