"use strict";
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
    if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
    return cooked;
};
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = __importStar(require("react"));
var styled_components_1 = __importDefault(require("styled-components"));
var styledComponents_1 = require("../ListingDetailPhaseCard/styledComponents");
var styledComponents_2 = require("./styledComponents");
var constants_1 = require("./constants");
var VoteTypeSummaryRow_1 = require("./VoteTypeSummaryRow");
var Collapsable_1 = require("../Collapsable");
var DefaultHeader = styled_components_1.default(styledComponents_1.StyledListingDetailPhaseCardSectionHeader)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n  & + ", " {\n    margin-top: 14px;\n  }\n"], ["\n  & + ", " {\n    margin-top: 14px;\n  }\n"])), styledComponents_2.VoteTypeSummaryContainer);
var StyledInner = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n  padding-top: 14px;\n"], ["\n  padding-top: 14px;\n"])));
var ExplainerText = function (props) {
    var explainerText;
    if (props.didChallengeSucceed) {
        if (props.isAppealChallenge) {
            explainerText = (React.createElement(React.Fragment, null,
                "The Civil Community ",
                React.createElement("b", null, "voted to overturn"),
                " the Civil Council's decision."));
        }
        else {
            explainerText = (React.createElement(React.Fragment, null,
                "The Civil Community ",
                React.createElement("b", null, "voted to reject this newsroom"),
                " on the grounds that it is in violation of the Civil Constitution."));
        }
    }
    else {
        if (props.isAppealChallenge) {
            explainerText = (React.createElement(React.Fragment, null,
                "The Civil Community ",
                React.createElement("b", null, "voted to uphold"),
                " The Civil Council's decision."));
        }
        else {
            explainerText = (React.createElement(React.Fragment, null,
                "The Civil Community ",
                React.createElement("b", null, "voted to accept this newsroom"),
                " on the grounds that it adheres to the Civil Constitution."));
        }
    }
    return React.createElement(styledComponents_2.StyledExplainerText, null, explainerText);
};
var ChallengeResultsInner = function (props) {
    var Header = props.styledHeaderComponent || DefaultHeader;
    var defaultHeaderText = props.challengeID ? "Challenge " + props.challengeID + " Results" : "Challenge Results";
    var explainerText = !props.noExplainerText && React.createElement(ExplainerText, __assign({}, props));
    return (React.createElement(React.Fragment, null,
        !props.noHeader && React.createElement(Header, null, props.headerText || defaultHeaderText),
        props.noHeader && React.createElement(StyledInner, null),
        explainerText,
        React.createElement(styledComponents_2.VoteTypeSummaryContainer, null,
            React.createElement(VoteTypeSummaryRow_1.VoteTypeSummaryRow, { voteType: props.isAppealChallenge ? constants_1.CHALLENGE_RESULTS_VOTE_TYPES.OVERTURN : constants_1.CHALLENGE_RESULTS_VOTE_TYPES.REMAIN, votesCount: props.votesFor, votesPercent: props.percentFor })),
        React.createElement(styledComponents_2.VoteTypeSummaryContainer, null,
            React.createElement(VoteTypeSummaryRow_1.VoteTypeSummaryRow, { voteType: props.isAppealChallenge ? constants_1.CHALLENGE_RESULTS_VOTE_TYPES.UPHOLD : constants_1.CHALLENGE_RESULTS_VOTE_TYPES.REMOVE, votesCount: props.votesAgainst, votesPercent: props.percentAgainst })),
        React.createElement(styledComponents_2.VoteTypeSummaryContainer, null,
            React.createElement(styledComponents_2.VoteTypeSummary, null,
                React.createElement(styledComponents_2.TotalVotesLabelContainer, null,
                    React.createElement(styledComponents_2.VotesPerTokenTotal, null, "Total Votes")),
                React.createElement(styledComponents_2.TotalVotesCount, null, props.totalVotes)))));
};
exports.ChallengeResults = function (props) {
    if (props.collapsable) {
        var Header = props.styledHeaderComponent || DefaultHeader;
        var headerElement = React.createElement(Header, null, props.headerText || "Challenge Results");
        var open_1 = props.open !== undefined ? props.open : true;
        return (React.createElement(Collapsable_1.Collapsable, { header: headerElement, open: open_1 },
            React.createElement(ChallengeResultsInner, __assign({ noHeader: true, headerText: "" }, props))));
    }
    return React.createElement(ChallengeResultsInner, __assign({}, props));
};
var templateObject_1, templateObject_2;
//# sourceMappingURL=ChallengeResults.js.map