"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InfoBar = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const antd_1 = require("antd");
const config_1 = require("lib/config");
const add_box_1 = require("./add-box");
const site_license_cost_1 = require("./site-license-cost");
const { Text } = antd_1.Typography;
const INNER_STYLE = {
    paddingRight: "10px",
};
// this is like a minimal "add box"
const InfoBar = (props) => {
    const { show, cost, router, form, cartError, setCartError, noAccount } = props;
    if (!show)
        return null;
    function renderInfoBarContent() {
        // if any of the fields in cost that start with the string "cost" are NaN, return null
        const disabled = !cost ||
            Object.keys(cost).some((k) => k.startsWith("cost") && isNaN(cost[k]));
        return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [disabled ? ((0, jsx_runtime_1.jsx)(Text, { type: "secondary", italic: true, style: INNER_STYLE, children: "License is not fully configured." })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, site_license_cost_1.describeItem)({ info: cost.input, variant: "short" }), ": "] }), (0, jsx_runtime_1.jsx)(Text, { strong: true, style: INNER_STYLE, children: (0, jsx_runtime_1.jsx)(site_license_cost_1.DisplayCost, { cost: cost, oneLine: true, simple: true, simpleShowPeriod: false, discountTooltip: true }) })] })), !noAccount && ((0, jsx_runtime_1.jsx)(add_box_1.AddToCartButton, { cartError: cartError, cost: cost, form: form, router: router, setCartError: setCartError, variant: "small", disabled: disabled }))] }));
    }
    // this is a thin bar at the top, fixed position and height
    // the width limit of the inner div is the same as for the div
    // inside the "Content", i.e. the form itself, such that everything
    // alignes nicely.
    return ((0, jsx_runtime_1.jsx)("div", { style: {
            height: "30px",
            display: "flex",
            backgroundColor: "white",
            position: "fixed",
            textAlign: "right",
            top: 0,
            left: 0,
            right: 0,
            zIndex: 1000,
            padding: "10px",
            boxShadow: "0 4px 4px rgba(0,0,0,0.2)",
            overflow: "hidden",
        }, children: (0, jsx_runtime_1.jsx)("div", { style: {
                maxWidth: config_1.MAX_WIDTH,
                marginLeft: "auto",
                marginRight: "auto",
                alignSelf: "center",
                flex: 1,
                whiteSpace: "nowrap",
            }, children: renderInfoBarContent() }) }));
};
exports.InfoBar = InfoBar;
//# sourceMappingURL=cost-info-bar.js.map