"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TryIt = void 0;
const tslib_1 = require("tslib");
const react_error_boundary_1 = require("@stoplight/react-error-boundary");
const classnames_1 = tslib_1.__importDefault(require("classnames"));
const React = tslib_1.__importStar(require("react"));
const useParsedValue_1 = require("../../hooks/useParsedValue");
const useRequestMaker_1 = require("../../hooks/useRequestMaker");
const guards_1 = require("../../utils/guards");
const RequestMaker_1 = require("../RequestMaker");
const TryItComponent = React.memo(({ nodeType, nodeData, mockUrl, className }) => {
    const data = useParsedValue_1.useParsedValue(nodeData);
    let operation = {};
    if (nodeType === 'http_operation' && guards_1.isHttpOperation(data)) {
        operation = data;
    }
    const store = useRequestMaker_1.useRequestMaker(operation, true, mockUrl);
    return (React.createElement("div", { className: classnames_1.default('TryIt', className) },
        React.createElement(RequestMaker_1.RequestMakerProvider, { value: store },
            React.createElement(RequestMaker_1.RequestEndpoint, { className: "rounded" }),
            React.createElement(RequestMaker_1.RequestEditor, { className: "mt-10 border-t rounded" }),
            React.createElement(RequestMaker_1.ResponseViewer, { className: "mt-10 border-t rounded" }))));
});
TryItComponent.displayName = 'TryIt.Component';
exports.TryIt = react_error_boundary_1.withErrorBoundary(TryItComponent, { recoverableProps: ['nodeData'] });
//# sourceMappingURL=index.js.map