"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.DialogHeader = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const box_1 = require("../box");
const core_1 = require("../core");
const utils_1 = require("../utils");
const context_1 = require("./context");
const dialogCloseButton_1 = __importDefault(require("./dialogCloseButton"));
const dialogIcon_1 = __importDefault(require("./dialogIcon"));
const dialogTitle_1 = __importDefault(require("./dialogTitle"));
/** Shows title, status icon and close button above the Dialog Body. */
exports.DialogHeader = (0, core_1.vui)((props, ref) => {
    var _a;
    const { children, className, closeButton, icon: iconProp, title: titleProp } = props, rest = __rest(props, ["children", "className", "closeButton", "icon", "title"]);
    const { onClose, status } = (_a = (0, context_1.useDialogContext)()) !== null && _a !== void 0 ? _a : {};
    const styles = (0, core_1.useStyleConfig)('Dialog', (0, context_1.useDialogContext)());
    const icon = (0, utils_1.isString)(iconProp) ? { name: iconProp } : iconProp;
    const showCloseButton = Boolean(closeButton !== undefined ? closeButton : onClose);
    const showIcon = Boolean(icon || status);
    const title = (0, utils_1.isReactText)(titleProp) ? { text: titleProp } : titleProp;
    return ((0, jsx_runtime_1.jsx)(box_1.Box, Object.assign({ className: (0, utils_1.cs)('vui-dialogHeader', className), icon: icon, pb: 1.5, pl: 3, position: "relative", pr: 8, pt: 3, ref: ref }, styles.header, rest, { children: children !== null && children !== void 0 ? children : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, utils_1.isJsx)(icon) ? icon : showIcon && (0, jsx_runtime_1.jsx)(dialogIcon_1.default, Object.assign({}, icon)), (0, utils_1.isJsx)(title) ? title : title && (0, jsx_runtime_1.jsx)(dialogTitle_1.default, Object.assign({}, title)), (0, utils_1.isJsx)(closeButton) ? closeButton : showCloseButton && (0, jsx_runtime_1.jsx)(dialogCloseButton_1.default, {})] })) })));
});
exports.DialogHeader.displayName = 'DialogHeader';
exports.default = exports.DialogHeader;
//# sourceMappingURL=dialogHeader.js.map