import { jsx as _jsx } from "react/jsx-runtime";
import { Link, Tooltip, Button } from '@primer/react';
import { ScreenFullIcon } from '@primer/octicons-react';
import { lazyWithPreload, WithSuspense } from '../../utils/index.js';
import { useToast } from '../../hooks/index.js';
import { useLayoutStore } from '../../state/index.js';
const Screencapture = WithSuspense(lazyWithPreload(() => import('./Screencapture')));
export const ScreencaptureButton = (props) => {
    const { enqueueToast } = useToast();
    const { setScreencapture, hideScreencapture } = useLayoutStore();
    const handleScreencapture = (screenCapture) => {
        setScreencapture(screenCapture);
        hideScreencapture();
        enqueueToast('Screen is captured.', { variant: 'success' });
    };
    return (_jsx(Screencapture, { onEndCapture: handleScreencapture, children: ({ onStartCapture }) => (_jsx(Tooltip, { text: "Take a screen capture", direction: "s", children: _jsx(Button, { variant: "invisible", children: _jsx(Link, { href: "javascript: return false;", sx: {
                        color: 'fg.muted',
                        ':hover, :focus, &[aria-expanded=true]': {
                            background: 'none !important',
                            color: 'accent.fg',
                        },
                    }, onClick: e => {
                        e.preventDefault();
                        onStartCapture();
                    }, children: _jsx(ScreenFullIcon, {}) }) }) })) }));
};
export default ScreencaptureButton;
