"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UpdateModal = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const React = tslib_1.__importStar(require("react"));
const uikit_1 = require("@gravity-ui/uikit");
const cn_1 = require("../../../utils/cn.js");
const b = (0, cn_1.editorCn)('source-code-update-modal');
const UpdateModal = ({ onClose, onApply, isOpen, initialConfig }) => {
    const [tempConfig, setTempConfig] = React.useState(initialConfig || '');
    React.useEffect(() => {
        if (isOpen && initialConfig) {
            setTempConfig(initialConfig);
        }
    }, [isOpen, initialConfig]);
    const handleApply = () => {
        onApply(tempConfig);
    };
    return ((0, jsx_runtime_1.jsxs)(uikit_1.Dialog, { onClose: onClose, open: isOpen, size: 'l', className: b(), children: [(0, jsx_runtime_1.jsx)(uikit_1.Dialog.Header, { caption: "New configuration" }), (0, jsx_runtime_1.jsxs)(uikit_1.Dialog.Body, { children: [(0, jsx_runtime_1.jsx)(uikit_1.Alert, { theme: 'info', title: 'You can use YAML or JSON', message: 'The editor will automatically understand which format is needed.', className: b('alert') }), (0, jsx_runtime_1.jsx)(uikit_1.TextArea, { value: tempConfig, onUpdate: setTempConfig, rows: 25, className: b('textarea') })] }), (0, jsx_runtime_1.jsx)(uikit_1.Dialog.Footer, { showError: false, preset: 'default', textButtonApply: 'Apply', textButtonCancel: 'Cancel', onClickButtonApply: handleApply, onClickButtonCancel: onClose })] }));
};
exports.UpdateModal = UpdateModal;
//# sourceMappingURL=UpdateModal.js.map
