"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 __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 react_router_dom_1 = require("react-router-dom");
var icons_1 = require("../icons");
var Button_1 = require("../Button");
var Layout_1 = require("../Layout");
var ListingPhaseLabel_1 = __importDefault(require("../ListingSummary/ListingPhaseLabel"));
var styleConstants_1 = require("../styleConstants");
var img_default_newsroom_2x_png_1 = __importDefault(require("../images/img-default-newsroom@2x.png"));
var ListingDetailHeaderStyledComponents_1 = require("./ListingDetailHeaderStyledComponents");
var EthereumInfoModal_1 = __importDefault(require("./EthereumInfoModal"));
var ListingDetailHeader = /** @class */ (function (_super) {
    __extends(ListingDetailHeader, _super);
    function ListingDetailHeader() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.state = {
            isEthereumInfoVisible: false,
        };
        _this.toggleEthereumInfoDisplay = function () {
            _this.setState({ isEthereumInfoVisible: !_this.state.isEthereumInfoVisible });
        };
        return _this;
    }
    ListingDetailHeader.prototype.render = function () {
        var newsroomDescription = "";
        var newsroomUrl = "";
        var logoURL;
        var _a = this.props, charter = _a.charter, listingAddress = _a.listingAddress, owner = _a.owner, etherscanBaseURL = _a.etherscanBaseURL, ethInfoModalLearnMoreURL = _a.ethInfoModalLearnMoreURL;
        if (charter) {
            newsroomDescription = charter.tagline;
            newsroomUrl = charter.newsroomUrl;
            logoURL = charter.logoUrl;
        }
        return (React.createElement(ListingDetailHeaderStyledComponents_1.ListingDetailOuter, null,
            React.createElement(ListingDetailHeaderStyledComponents_1.StyledListingDetailHeader, null,
                this.renderRegistryLink(),
                React.createElement(Layout_1.StyledContentRow, null,
                    React.createElement(ListingDetailHeaderStyledComponents_1.StyledNewsroomIcon, null, logoURL && (React.createElement(ListingDetailHeaderStyledComponents_1.StyledNewsroomLogo, null,
                        React.createElement("img", { src: logoURL, onError: function (e) {
                                e.target.src = img_default_newsroom_2x_png_1.default;
                            } })))),
                    React.createElement("div", null,
                        React.createElement(ListingPhaseLabel_1.default, __assign({}, this.props)),
                        React.createElement(ListingDetailHeaderStyledComponents_1.ListingDetailNewsroomName, null, this.props.newsroomName),
                        React.createElement(ListingDetailHeaderStyledComponents_1.StyledEthereumInfoToggle, { onClick: this.toggleEthereumInfoDisplay }, "Ethereum Info"),
                        this.state.isEthereumInfoVisible && (React.createElement(EthereumInfoModal_1.default, { listingAddress: listingAddress, owner: owner, etherscanBaseURL: etherscanBaseURL, ethInfoModalLearnMoreURL: ethInfoModalLearnMoreURL, handleCloseClick: this.toggleEthereumInfoDisplay })),
                        React.createElement(ListingDetailHeaderStyledComponents_1.ListingDetailNewsroomDek, null, newsroomDescription),
                        React.createElement(ListingDetailHeaderStyledComponents_1.NewsroomLinks, null,
                            newsroomUrl && (React.createElement(ListingDetailHeaderStyledComponents_1.VisitNewsroomButtonWrap, null,
                                React.createElement(ListingDetailHeaderStyledComponents_1.StyledListingURLButton, { size: Button_1.buttonSizes.MEDIUM_WIDE, href: newsroomUrl, target: "_blank" },
                                    newsroomUrl,
                                    " ",
                                    React.createElement(icons_1.NorthEastArrow, { color: styleConstants_1.colors.basic.WHITE })))),
                            this.props.charter &&
                                this.props.charter.socialUrls &&
                                (this.props.charter.socialUrls.facebook || this.props.charter.socialUrls.twitter) && (React.createElement(ListingDetailHeaderStyledComponents_1.FollowNewsroom, null,
                                React.createElement(ListingDetailHeaderStyledComponents_1.FollowNewsroomHeading, null, "Follow Newsroom"),
                                this.props.charter.socialUrls.twitter && (React.createElement(ListingDetailHeaderStyledComponents_1.FollowNewsroomLink, { href: this.props.charter.socialUrls.twitter, target: "_blank" },
                                    React.createElement(icons_1.TwitterIcon, null))),
                                this.props.charter.socialUrls.facebook && (React.createElement(ListingDetailHeaderStyledComponents_1.FollowNewsroomLink, { href: this.props.charter.socialUrls.facebook, target: "_blank" },
                                    React.createElement(icons_1.FacebookIcon, null)))))))))));
    };
    ListingDetailHeader.prototype.renderRegistryLink = function () {
        if (!this.props.registryURL) {
            return;
        }
        var label = this.props.registryLinkText || "Registry";
        return (React.createElement(ListingDetailHeaderStyledComponents_1.StyledRegistryLinkContainer, null,
            React.createElement(react_router_dom_1.Link, { to: this.props.registryURL },
                "< Back to ",
                label)));
    };
    return ListingDetailHeader;
}(React.Component));
exports.ListingDetailHeader = ListingDetailHeader;
//# sourceMappingURL=ListingDetailHeader.js.map