"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Dialog = exports.DialogContent = void 0;
const tslib_1 = require("tslib");
const classnames_1 = tslib_1.__importDefault(require("classnames"));
const react_1 = tslib_1.__importDefault(require("react"));
const ide_core_common_1 = require("@opensumi/ide-core-common");
const button_1 = require("../button");
const common_1 = require("../common");
const icon_1 = require("../icon");
const overlay_1 = require("../overlay");
require("./styles.less");
const DefaultButtons = ({ onCancel, onOk, cancelText, okText }) => (react_1.default.createElement(react_1.default.Fragment, null,
    react_1.default.createElement(button_1.Button, { onClick: onCancel, type: 'secondary' }, cancelText || (0, ide_core_common_1.localize)('ButtonCancel')),
    react_1.default.createElement(button_1.Button, { onClick: onOk }, okText || (0, ide_core_common_1.localize)('ButtonOK'))));
const DialogContent = ({ onClose, closable, messageType = common_1.MessageType.Info, icon, message, buttons, type = 'confirm', title, onOk, onCancel, okText, cancelText, }) => {
    const { getIcon: getContextIcon } = react_1.default.useContext(icon_1.IconContext);
    return (react_1.default.createElement(react_1.default.Fragment, null,
        react_1.default.createElement("div", { className: 'kt-dialog-content' },
            icon && (react_1.default.createElement("div", { style: { color: icon.color }, className: (0, classnames_1.default)('kt-dialog-icon', (0, icon_1.getIcon)(icon.className) || getContextIcon(icon.className)) })),
            react_1.default.createElement("div", { className: 'kt-dialog-content_area' },
                type !== 'basic' && title && react_1.default.createElement("p", { className: 'kt-dialog-content_title' }, title),
                react_1.default.createElement("span", { className: 'kt-dialog-message' }, message)),
            closable && type !== 'basic' && (react_1.default.createElement("button", { className: (0, classnames_1.default)('kt-dialog-closex', (0, icon_1.getIcon)('close')), onClick: onClose }))),
        messageType !== common_1.MessageType.Empty && type !== 'basic' && (react_1.default.createElement("div", { className: 'kt-dialog-buttonWrap' }, type === 'confirm' ? (buttons || react_1.default.createElement(DefaultButtons, { onCancel: onCancel, onOk: onOk, okText: okText, cancelText: cancelText })) : (react_1.default.createElement(button_1.Button, { onClick: onClose }, "OK"))))));
};
exports.DialogContent = DialogContent;
const Dialog = (_a) => {
    var { visible, onClose, closable, afterClose, messageType, icon, message, buttons, type = 'confirm', title, onOk, onCancel, okText, cancelText, getContainer, keyboard } = _a, restProps = tslib_1.__rest(_a, ["visible", "onClose", "closable", "afterClose", "messageType", "icon", "message", "buttons", "type", "title", "onOk", "onCancel", "okText", "cancelText", "getContainer", "keyboard"]);
    return (react_1.default.createElement(overlay_1.Overlay, Object.assign({ visible: visible, onClose: onClose, title: type === 'basic' ? title : null, closable: type === 'basic', getContainer: getContainer, keyboard: keyboard, footer: type === 'basic'
            ? buttons || react_1.default.createElement(DefaultButtons, { onCancel: onCancel, onOk: onOk, okText: okText, cancelText: cancelText })
            : undefined, afterClose: afterClose }, restProps),
        react_1.default.createElement(exports.DialogContent, Object.assign({ message: message, buttons: buttons, visible: visible }, restProps))));
};
exports.Dialog = Dialog;
//# sourceMappingURL=index.js.map