"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RequestSend = void 0;
const tslib_1 = require("tslib");
const json_1 = require("@stoplight/json");
const ui_kit_1 = require("@stoplight/ui-kit");
const classnames_1 = tslib_1.__importDefault(require("classnames"));
const copy_to_clipboard_1 = tslib_1.__importDefault(require("copy-to-clipboard"));
const mobx_react_lite_1 = require("mobx-react-lite");
const React = tslib_1.__importStar(require("react"));
const useRequestMaker_1 = require("../../../hooks/useRequestMaker");
exports.RequestSend = mobx_react_lite_1.observer(({ className }) => {
    const store = useRequestMaker_1.useRequestMakerStore();
    const handleClick = () => {
        if (store.isMockEnabled) {
            return store.mock();
        }
        return store.send();
    };
    return (React.createElement(ui_kit_1.ButtonGroup, { className: classnames_1.default('RequestMaker__RequestSend', className), large: true },
        React.createElement(ui_kit_1.Button, { intent: "primary", loading: store.isSending, onClick: handleClick }, "Send"),
        React.createElement(ui_kit_1.Popover, { minimal: true, position: ui_kit_1.Position.BOTTOM_RIGHT },
            React.createElement(ui_kit_1.Button, { small: true, intent: "primary", icon: "caret-down" }),
            React.createElement(ui_kit_1.Menu, null,
                React.createElement(ui_kit_1.MenuItem, { text: "Copy Request", icon: "duplicate", onClick: () => copy_to_clipboard_1.default(json_1.safeStringify(store.request.toPartialHttpRequest(), undefined, 2)) }),
                React.createElement(ui_kit_1.MenuItem, { text: "Reset", icon: "reset", onClick: () => store.reset(), disabled: !store.hasChanges })))));
});
exports.RequestSend.displayName = 'RequestMaker.RequestSend';
//# sourceMappingURL=Send.js.map