import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import * as React from 'react';
import { ArrowRotateRight } from '@gravity-ui/icons';
import { Button, Icon, TextInput } from '@gravity-ui/uikit';
import { IframeContext } from "../../context/iframeContext/index.js";
import { useMainEditorStore } from "../../hooks/useMainEditorStore.js";
import { editorCn } from "../../utils/cn.js";
import './Source.css';
const b = editorCn('source');
const Source = () => {
    const { resetInitialize } = useMainEditorStore();
    const { disableUrlField, url, setUrl } = React.useContext(IframeContext);
    const onUpdateUrl = React.useCallback((value) => {
        setUrl(value);
        resetInitialize();
    }, [resetInitialize, setUrl]);
    const reloadIframe = () => {
        setUrl('');
        setTimeout(() => {
            setUrl(url);
        }, 0);
    };
    return (_jsxs("div", { className: b(), children: [_jsx(Button, { className: b('icon'), view: "flat", size: "m", onClick: reloadIframe, children: _jsx(Icon, { data: ArrowRotateRight, size: 18 }) }), _jsx(TextInput, { disabled: disableUrlField, className: b('text'), size: "m", value: url, onUpdate: onUpdateUrl })] }));
};
export default Source;
//# sourceMappingURL=Source.js.map
