"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PanelWithButton = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const SimpleButton_1 = tslib_1.__importDefault(require("../../../components/SimpleButton"));
const Panel_1 = tslib_1.__importDefault(require("../../../components/Panel"));
const rebass_1 = require("rebass");
const icons_1 = require("../../../components/icons");
const ButtonInfo_1 = require("../Buttons/ButtonInfo");
//We cannot destructure this.props using the react way in typescript which is a real pain as you
//need to transfer props individually as a consequence
//let { buttonContent, ...other } = this.props
class PanelWithButton extends React.Component {
    render() {
        let { buttonContent } = this.props;
        const IconCmp = icons_1.allIcons[this.props.glyphicon];
        let header = (React.createElement(rebass_1.Flex, { alignItems: "center", width: "100%" },
            React.createElement(rebass_1.Flex, { alignItems: "center" },
                this.props.glyphicon != null && (IconCmp ? React.createElement(IconCmp, null) : null),
                React.createElement(rebass_1.Box, { marginRight: 2, "data-name": "space-before" }),
                this.props.headerText,
                React.createElement(rebass_1.Box, { marginRight: 2, "data-name": "space-after" }),
                this.props.infoLink != null && !this.props.infoLinkDisabled && (React.createElement(ButtonInfo_1.ButtonInfo, { onClick: () => window.open(this.props.infoLink, '_blank' // <- opens the link in a new tab or window.
                    ) }))),
            React.createElement(rebass_1.Box, { style: { flex: 1 } }),
            buttonContent ? (React.createElement(SimpleButton_1.default, { variant: "raised", tone: "accent", disabled: this.props.buttonDisabled, onClick: () => (this.props.buttonClick ? this.props.buttonClick() : null) }, buttonContent)) : null,
            this.props.button ? React.cloneElement(this.props.button) : null));
        return (React.createElement(Panel_1.default, { flex: 1, className: this.props.className, bodyScroll: this.props.bodyScroll != null ? this.props.bodyScroll : true, bodyProps: this.props.bodyProps, variant: this.props.variant || 'primary', header: header, headerProps: this.props.headerProps, style: this.props.style, borderRadius: (this.props.borderRadius || 'none'), border: (this.props.border || 'none') }, this.props.children));
    }
}
exports.PanelWithButton = PanelWithButton;
