import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import Box from '../box';
import Button from '../button';
import { RenderOnScreen, useDown, useStyleConfig, vui } from '../core';
import List from '../list';
import { cs, isJsx } from '../utils';
import { useHeaderContext } from './context';
import Header from './header';
import HeaderAccountUserInfo from './headerAccountUserInfo';
import HeaderServicesMessage from './headerServicesMessage';
/** Displays Header content appropriate for logged-in users, such as services, notifications or account information. */
export const LoggedInHeader = vui((props, ref) => {
    const { account, altUserInfo, supportLinks, applicationName, applicationUrl, children, className, isApplication = false, isCleanLayout = false, logo, mainLinks, services, showAltUserInfo = false, showMainLinks = isApplication ? false : true, showServices = true, notifications, url, ...rest } = props;
    if (isApplication && !applicationName)
        console.error('Header: isApplication is true but applicationName is not set.');
    const userInfo = altUserInfo ? altUserInfo : isJsx(account) ? {} : account?.userInfo || {};
    const isSmallScreen = useDown('md');
    const isLessThanMD = useDown('sm');
    const servicesLinks = isJsx(services) ? [] : services?.links || [];
    const styles = useStyleConfig('Header', useHeaderContext());
    const localTextColor = rest?.variant === 'dark' ? 'white' : 'darkBlue.main';
    return (_jsx(Header, { className: cs('vui-loggedInHeader', isApplication ? 'vui-loggedInAppHeader' : undefined, className), mb: isApplication && isSmallScreen ? '41px' : 'inherited', ref: ref, ...rest, children: _jsxs(Header.Content, { children: [(!isApplication || !isLessThanMD) && _jsxs(_Fragment, { children: [" ", isJsx(logo) ? logo : _jsx(Header.Logo, { ...logo })] }), isApplication && (_jsxs(_Fragment, { children: [_jsx(RenderOnScreen, { minWidth: "sm", children: _jsx(Header.Divider, { mr: 2 }) }), _jsx(Header.ApplicationName, { color: localTextColor, title: applicationName, url: applicationUrl || '/' })] })), !isApplication && _jsx(RenderOnScreen, { minWidth: "lg", children: children }), _jsx(Box, { ml: "auto" }), isCleanLayout ? (_jsx(_Fragment, { children: !!url && (_jsx(Box, { children: _jsx(Button, { as: "a", className: cs('vui-headerSignOut'), href: url, size: "lg", variant: "secondaryDark", children: "Sign out" }) })) })) : (_jsxs(_Fragment, { children: [isApplication && (_jsxs(_Fragment, { children: [_jsxs(RenderOnScreen, { minWidth: "lg", children: [showMainLinks && mainLinks !== undefined && (_jsxs(_Fragment, { children: [isJsx(mainLinks) ? mainLinks : _jsx(Header.MainLinks, { links: mainLinks }), _jsx(Header.Divider, { mx: 1 })] })), !showMainLinks && mainLinks && (_jsxs(_Fragment, { children: [_jsx(Header.MobileToggle, { ml: 0 }), _jsx(Header.MobileContent, { children: _jsxs(_Fragment, { children: [isJsx(mainLinks) ? (mainLinks) : (_jsx(Box, { column: true, w: 1, children: _jsx(List, { py: 1, children: mainLinks?.map(({ icon, url, ...rest }, index) => (_jsx(List.Item, { iconLeft: icon, linkProps: { href: url }, ...rest }, index))) }) })), !showServices && servicesLinks && (_jsx(Box, { column: true, w: 1, children: _jsx(List, { className: "vui-headerHiddenServicesLargeScreen", heading: "My Services", maxH: 295, right: 0, w: 320, ...styles.services.list, borderTop: 1, borderTopColor: "sandstone.main", pt: 1, children: servicesLinks.length > 0 ? (servicesLinks?.map(({ url, ...rest }, index) => (_jsx(List.Item, { linkProps: { href: url }, ...rest }, index)))) : (_jsx(HeaderServicesMessage, {})) }) }))] }) })] })), showServices && services && (_jsx(_Fragment, { children: isJsx(services) ? services : _jsx(Header.Services, { isApplication: isApplication, ...services }) }))] }), _jsx(Header.Support, { ...supportLinks })] })), !isApplication && (_jsxs(RenderOnScreen, { minWidth: "lg", children: [isJsx(mainLinks) ? mainLinks : _jsx(Header.MainLinks, { links: mainLinks }), mainLinks !== undefined && _jsx(Header.Divider, { mx: 1 }), isJsx(services) ? services : _jsx(Header.Services, { ...services })] })), isJsx(notifications) ? notifications : _jsx(Header.Notifications, { ...notifications }), showAltUserInfo && (_jsxs(_Fragment, { children: [_jsx(Header.Divider, { ml: 2 }), _jsx(HeaderAccountUserInfo, { className: "vui-altUserInfo", color: localTextColor, isApplication: true, ...userInfo })] })), isJsx(account) ? account : _jsx(Header.Account, { ...account }), _jsxs(RenderOnScreen, { maxWidth: "lg", children: [isApplication && _jsx(Header.Divider, { ml: 1 }), !isApplication && (account !== undefined || notifications !== undefined) && _jsx(Header.Divider, { ml: 1 }), _jsx(Header.MobileToggle, {}), _jsxs(Header.MobileContent, { children: [!isApplication && children, isJsx(mainLinks) ? mainLinks : _jsx(Header.MainLinks, { links: mainLinks }), isJsx(services) ? (services) : (_jsx(Header.Services, { ...services, showTopBorder: mainLinks ? true : false }))] })] })] }))] }) }));
});
LoggedInHeader.displayName = 'LoggedInHeader';
export default LoggedInHeader;
//# sourceMappingURL=loggedInHeader.js.map