import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Box } from '../box';
import { styled, useDown, useStyleConfig, vui } from '../core';
import { Divider } from '../divider';
import { Link } from '../link';
import Menu from '../menu';
import { T } from '../t';
import { cs, getCurrentYear } from '../utils';
import { FooterProvider } from './context';
import FooterColumn from './footerColumn';
import FooterColumns from './footerColumns';
import FooterContent from './footerContent';
import FooterHeading from './footerHeading';
import FooterLink from './footerLink';
import FooterRow from './footerRow';
import FooterSection from './footerSection';
import FooterSlimColumn from './footerSlimColumn';
import { defaultLinkedInUrl, FooterTrademark } from './footerTrademark';
/*@formatter:off*/
export const FooterBase = styled.divBox `
  background-color: darkBlue.main;
  color: white;
  padding: 5 3;
`;
/*@formatter:on*/
const currentYear = getCurrentYear();
/** Branded Veracity Footer with trademark and links sections. Controls max-width of the content. */
export const Footer = vui((props, ref) => {
    const { applicationLinks, applicationSocialLinks = [], applicationStaticItems = [], children, className, columns, isApplication = false, isDNV = false, linkedIn, size, variant, isSlim, ...rest } = props;
    const context = { size, variant };
    const styles = useStyleConfig('Footer', props);
    if (isApplication && !applicationLinks)
        console.error('Footer: isApplication is true but applicationLinks  not set.');
    const slimLinks = [
        {
            id: 'home',
            text: 'veracity.com',
            url: 'https://www.veracity.com/',
        },
    ];
    columns?.map(column => {
        column.map(section => {
            section.links?.map(link => {
                if (!link)
                    return;
                if (['home', 'support', 'status'].includes(link.id || ''))
                    slimLinks.push(link);
            });
        });
    });
    const downMd = useDown('md');
    const downLg = useDown('lg');
    return (_jsx(FooterProvider, { value: context, children: _jsxs(FooterBase, { className: cs('vui-footer', isApplication ? 'vui-footer-app' : '', className), px: isApplication ? '40px' : 3, py: isSlim ? (downMd ? '16px' : '9px') : 5, role: "contentinfo", ...styles.container, ref: ref, ...rest, children: [isApplication && (_jsx(FooterContent, { alignContent: "center", alignItems: "center", maxW: "100%", children: _jsxs(FooterRow, { alignContent: "space-between", w: 1, children: [_jsx(Box, { alignItems: "self-start", columnGap: 3, flex: { xs: '0 0 100%', sm: '0 0 100%', md: '0 0 100%', lg: '0 0 50%' }, py: { xs: 1, sm: 1, md: 1.25, lg: 1.5 }, wrap: true, children: applicationLinks?.map((link, index) => (_jsxs(Box, { flex: { xs: '0 0 100%', sm: '0 0 auto' }, children: [link.items && (_jsxs(Menu, { isLazy: false, offset: [-16, 9], placement: "top-start", size: "lg", ...rest, children: [_jsx(Menu.Button, { as: Link, className: "vui-footerLink-trigger", pt: "3px", role: "button", text: link.text, title: link.text, ...styles.link, ...rest }), _jsx(Menu.List, { maxH: 400, right: 0, w: 320, ...styles.list, children: link.items.map(({ text, url }, index) => (_jsx(Menu.Item, { isTruncated: true, linkProps: { href: url }, text: text, title: text, ...styles.item }, index))) })] })), !link.items && _jsx(FooterLink, { ...link, href: link.url })] }, index))) }), downLg && _jsx(Divider, { borderColor: "sandstone.main", mb: 0.5, mt: 1, w: 1 }), _jsxs(Box, { centerV: true, columnGap: 3, flex: { xs: '0 0 100%', sm: '0 0 100%', md: '0 0 100%', lg: '0 0 50%' }, justifyContent: { sm: 'center', lg: 'flex-end' }, py: { xs: 1, sm: 1, md: 1.25, lg: 1.5 }, wrap: true, children: [applicationStaticItems?.map((text, index) => (_jsx(Box, { children: _jsx(T, { size: "sm", children: text }) }, index))), isDNV ? (_jsx(Box, { children: _jsxs(T, { size: "sm", children: ["\u00A9 DNV AS ", currentYear] }) })) : (_jsx(Box, { children: _jsxs(T, { size: "sm", children: [_jsx(T, { fontWeight: "600", children: "Veracity by DNV" }), ", DNV AS"] }) })), _jsxs(Box, { children: [applicationSocialLinks?.map((link, index) => (_jsx(Link, { "aria-label": link.text, fontWeight: "demi", href: link.url, iconLeft: _jsx(Link.Icon, { name: `cubCircle${link.text}`, radius: "50%", size: "xs" }), isExternal: true, mr: 1, size: { _: 'sm', md: 'md' }, ...styles.link }, index))), _jsx(Link, { fontWeight: "demi", href: linkedIn ?? defaultLinkedInUrl, isExternal: true, size: { _: 'sm', md: 'md' }, ...styles.link, children: _jsx(FooterHeading, { fontSize: "16px", mb: 0, text: "Follow us" }) })] })] })] }) })), !isApplication && isSlim && (_jsx(FooterContent, { alignContent: "center", alignItems: "center", maxW: { xs: 343, sm: 305, md: 720, lg: 975 }, children: _jsxs(FooterRow, { children: [slimLinks.map(({ text, url, id }, index) => {
                                /** if the screen is small drop one specific link */
                                if (downLg && id === 'support')
                                    return;
                                return (_jsx(FooterSlimColumn, { children: _jsx(FooterLink, { href: url, text: text }) }, index));
                            }), downMd && _jsx(Divider, { borderColor: "sandstone.main", mb: 0.5, mt: 1, w: 1 }), _jsx(FooterSlimColumn, { centerV: true, children: _jsxs(T, { size: "xs", children: [_jsx(T, { fontWeight: "demi", children: "Veracity by DNV" }), ", DNV AS"] }) }), _jsx(FooterSlimColumn, { children: _jsx(Link, { fontWeight: "demi", href: linkedIn ?? defaultLinkedInUrl, iconLeft: _jsx(Link.Icon, { mr: 1, name: "cubCircleLinkedIn", radius: "50%", size: "xs" }), isExternal: true, size: { _: 'sm', md: 'md' }, ...styles.link, children: _jsx(FooterHeading, { fontSize: "16px", mb: 0, text: "Follow us" }) }) })] }) })), !isApplication && !isSlim && (_jsxs(FooterContent, { children: [_jsx(FooterColumns, { columns: columns }), children || columns ? _jsx(Divider, { borderColor: "sandstone.main", my: 4 }) : null, _jsx(FooterRow, { children: _jsx(FooterTrademark, { linkedIn: linkedIn }) })] }))] }) }));
});
Footer.Column = FooterColumn;
Footer.Content = FooterContent;
Footer.Heading = FooterHeading;
Footer.Link = FooterLink;
Footer.Row = FooterRow;
Footer.Section = FooterSection;
Footer.displayName = 'Footer';
export default Footer;
//# sourceMappingURL=footer.js.map