"use strict";
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.HeaderServices = HeaderServices;
const jsx_runtime_1 = require("react/jsx-runtime");
const core_1 = require("../core");
const list_1 = __importDefault(require("../list"));
const menu_1 = __importDefault(require("../menu"));
const context_1 = require("./context");
const headerServicesMessage_1 = __importDefault(require("./headerServicesMessage"));
/** Supporting internal component to avoid code duplication. */
function ListContent({ links = [] }) {
    const styles = (0, core_1.useStyleConfig)('Header', (0, context_1.useHeaderContext)()).services;
    return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: links.length > 0 ? (links.map(({ text, url }, index) => ((0, jsx_runtime_1.jsx)(menu_1.default.Item, Object.assign({ isTruncated: true, linkProps: { href: url }, text: text, title: text }, styles.item), index)))) : ((0, jsx_runtime_1.jsx)(headerServicesMessage_1.default, {})) }));
}
/** Displays a list of services available to the user. */
function HeaderServices(props) {
    const { buttonProps, isApplication = false, links = [], showTopBorder = false } = props, rest = __rest(props, ["buttonProps", "isApplication", "links", "showTopBorder"]);
    const styles = (0, core_1.useStyleConfig)('Header', (0, context_1.useHeaderContext)()).services;
    const offsetX = isApplication ? 179 : 135;
    return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(core_1.RenderOnScreen, { minWidth: "lg", children: (0, jsx_runtime_1.jsxs)(menu_1.default, Object.assign({ isLazy: false, offset: [offsetX, 17], placement: "bottom-end", size: "lg" }, rest, { children: [(0, jsx_runtime_1.jsx)(menu_1.default.Button, Object.assign({ className: "vui-services-trigger", icon: "falTh", ml: 1, size: "lg", title: "My services" }, styles.button, buttonProps)), (0, jsx_runtime_1.jsx)(menu_1.default.List, Object.assign({ heading: "My Services", maxH: 295, right: 0, w: 320 }, styles.list, { children: (0, jsx_runtime_1.jsx)(ListContent, { links: links }) }))] })) }), (0, jsx_runtime_1.jsx)(core_1.RenderOnScreen, { maxWidth: "lg", children: (0, jsx_runtime_1.jsx)(list_1.default, Object.assign({ heading: "My Services" }, styles.list, { borderTop: showTopBorder ? 1 : 0, borderTopColor: "sandstone.main", maxH: 295, pt: 1, children: (0, jsx_runtime_1.jsx)(ListContent, { links: links }) })) })] }));
}
HeaderServices.displayName = 'HeaderServices';
exports.default = HeaderServices;
//# sourceMappingURL=headerServices.js.map