"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
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;
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = __importStar(require("react"));
var StoryNewsroomStatus_1 = require("./StoryNewsroomStatus");
var Story_1 = require("./Story");
var StoryDetails_1 = require("./StoryDetails");
var StoryNewsroomDetails_1 = require("./StoryNewsroomDetails");
var StoryModal_1 = require("./StoryModal");
var Contributors_1 = require("../Contributors");
var StoryFeedStyledComponents_1 = require("./StoryFeedStyledComponents");
var Payments_1 = require("../Payments");
var elements_1 = require("@joincivil/elements");
var StoryFeedItem = /** @class */ (function (_super) {
    __extends(StoryFeedItem, _super);
    function StoryFeedItem(props) {
        var _this = _super.call(this, props) || this;
        _this.openStoryDetails = function () {
            _this.setState({ isStoryModalOpen: true, isStoryNewsroomModalOpen: false, isPaymentsModalOpen: false });
        };
        _this.openStoryNewsroomDetails = function () {
            _this.setState({ isStoryNewsroomModalOpen: true, isStoryModalOpen: false, isPaymentsModalOpen: false });
        };
        _this.handleClose = function () {
            _this.setState({ isStoryModalOpen: false, isStoryNewsroomModalOpen: false, isPaymentsModalOpen: false });
        };
        _this.openPayments = function () {
            _this.setState({ isPaymentsModalOpen: true, isStoryModalOpen: false, isStoryNewsroomModalOpen: false });
        };
        _this.openShare = function () {
            _this.setState({ isShareModalOpen: true });
        };
        _this.handleCloseShare = function () {
            _this.setState({ isShareModalOpen: false });
        };
        _this.state = {
            isStoryModalOpen: false,
            isStoryNewsroomModalOpen: false,
            isPaymentsModalOpen: false,
            isShareModalOpen: false,
        };
        return _this;
    }
    StoryFeedItem.prototype.render = function () {
        var _a = this.props, activeChallenge = _a.activeChallenge, createdAt = _a.createdAt, newsroom = _a.newsroom, openGraphData = _a.openGraphData, displayedContributors = _a.displayedContributors, sortedContributors = _a.sortedContributors, totalContributors = _a.totalContributors;
        return (React.createElement(React.Fragment, null,
            React.createElement(StoryFeedStyledComponents_1.StoryFeedItemWrap, null,
                React.createElement(StoryNewsroomStatus_1.StoryNewsroomStatus, { newsroomName: newsroom.charter.name, activeChallenge: activeChallenge, handleOpenNewsroom: this.openStoryNewsroomDetails }),
                React.createElement(Story_1.Story, { openGraphData: openGraphData, handleOpenStory: this.openStoryDetails }),
                React.createElement(StoryFeedStyledComponents_1.StoryElementsFlex, null,
                    React.createElement(Contributors_1.ContributorCount, { totalContributors: totalContributors, displayedContributors: displayedContributors }),
                    React.createElement(StoryFeedStyledComponents_1.StoryElementsFlex, null,
                        React.createElement(elements_1.PaymentButton, { onClick: this.openPayments }),
                        React.createElement(elements_1.ShareButton, { onClick: this.openShare })))),
            React.createElement(StoryModal_1.StoryModal, { open: this.state.isStoryModalOpen, handleClose: this.handleClose },
                React.createElement(StoryDetails_1.StoryDetails, { activeChallenge: activeChallenge, createdAt: createdAt, newsroomName: newsroom.charter.name, openGraphData: openGraphData, displayedContributors: displayedContributors, sortedContributors: sortedContributors, totalContributors: totalContributors, handleShare: this.openShare, handlePayments: this.openPayments, handleOpenNewsroom: this.openStoryNewsroomDetails })),
            React.createElement(StoryModal_1.StoryModal, { open: this.state.isStoryNewsroomModalOpen, handleClose: this.handleClose },
                React.createElement(StoryNewsroomDetails_1.StoryNewsroomDetails, { activeChallenge: activeChallenge, newsroom: newsroom })),
            React.createElement(Payments_1.PaymentsModal, { open: this.state.isPaymentsModalOpen, handleClose: this.handleClose },
                React.createElement(Payments_1.Payments, { postId: this.props.storyId, newsroomName: this.props.newsroom.charter.name, paymentAddress: this.props.newsroom.multisigAddress, isStripeConnected: this.props.isStripeConnected, handleClose: this.handleClose })),
            React.createElement(elements_1.SharePanel, { open: this.state.isShareModalOpen, handleClose: this.handleCloseShare },
                React.createElement(elements_1.ShareStory, { title: openGraphData.title, url: openGraphData.url }))));
    };
    return StoryFeedItem;
}(React.Component));
exports.StoryFeedItem = StoryFeedItem;
//# sourceMappingURL=StoryFeedItem.js.map