import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import * as React from 'react';
import { Alert, Dialog, TextArea } from '@gravity-ui/uikit';
import { editorCn } from "../../../utils/cn.js";
import './UpdateModal.css';
const b = editorCn('source-code-update-modal');
export 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 (_jsxs(Dialog, { onClose: onClose, open: isOpen, size: 'l', className: b(), children: [_jsx(Dialog.Header, { caption: "New configuration" }), _jsxs(Dialog.Body, { children: [_jsx(Alert, { theme: 'info', title: 'You can use YAML or JSON', message: 'The editor will automatically understand which format is needed.', className: b('alert') }), _jsx(TextArea, { value: tempConfig, onUpdate: setTempConfig, rows: 25, className: b('textarea') })] }), _jsx(Dialog.Footer, { showError: false, preset: 'default', textButtonApply: 'Apply', textButtonCancel: 'Cancel', onClickButtonApply: handleApply, onClickButtonCancel: onClose })] }));
};
//# sourceMappingURL=UpdateModal.js.map
