'use strict';
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
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 });
require("../../stylesheets/attachments/image.scss");
const classnames_1 = __importDefault(require("classnames"));
const React = __importStar(require("react"));
class AttachmentImage extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            loadError: false
        };
        this.onError = this.onError.bind(this);
        this.state = { loadError: false };
    }
    render() {
        const { url, hidden, caret } = this.props;
        return (React.createElement("div", null,
            caret,
            React.createElement("div", { className: classnames_1.default('attachment-image__unfurl-image', {
                    'attachment-image__unfurl-image--hidden': hidden,
                    'attachment-image__unfurl-image--error': this.state.loadError
                }), style: { backgroundImage: `url(${url})` } },
                React.createElement("a", { href: url, target: "_blank" },
                    React.createElement("img", { onError: this.onError, className: "message__attachment-image", src: !this.state.loadError ? url : 'https://drdaugjsbp9r4.cloudfront.net/apple/64/274c.png' })))));
    }
    onError() {
        this.setState({ loadError: true });
    }
}
exports.default = AttachmentImage;
//# sourceMappingURL=Image.js.map