'use strict';
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 });
require("../stylesheets/message.scss");
const React = __importStar(require("react"));
// import * as Textarea from 'react-textarea-autosize';
const classnames_1 = __importDefault(require("classnames"));
const Attachment_1 = __importDefault(require("./MessageAttachments/Attachment"));
const Reactions_1 = __importDefault(require("./MessageAttachments/Reactions"));
const slack_formatter_1 = __importDefault(require("../utils/slack-formatter"));
const emoji_1 = __importDefault(require("../utils/emoji"));
class Message extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            fallback: false,
            showSwitcher: false
        };
        this.handleTriggers = this.handleTriggers.bind(this);
        this.openDialogModal = this.openDialogModal.bind(this);
    }
    render() {
        const { message, messageId, messageIdx = 0, ephemeral } = this.props;
        const text = message.slack.text && (React.createElement("div", { className: classnames_1.default('message__text', {
                'message__text--ephemeral': message.slack.ephemeral
            }), dangerouslySetInnerHTML: {
                __html: emoji_1.default.unicodeToImage(emoji_1.default.toUnicode(message.slack.text))
            } }));
        const isEphemeral = (message.slack.ephemeral && !message.editing) ||
            (message.editing && ephemeral) ||
            (message.creating && ephemeral);
        const avatar = (React.createElement("span", { className: "message__avatar", style: {
                backgroundImage: `url("/static/illustrations/bot-avatar.svg")`
            } }, ''));
        return (React.createElement("div", { className: classnames_1.default('message', {
                'message--open': true,
                'message--deleting': message.deletionInProgress
            }), ref: (el) => {
                this._message = el;
            } },
            avatar,
            React.createElement("div", { className: "message__content" },
                text,
                !this.state.fallback &&
                    message.slack.attachments &&
                    !!message.slack.attachments.length && (React.createElement("div", { className: "message__attachment-group" }, message.slack.attachments &&
                    message.slack.attachments.map((attachment, idx) => {
                        const blacklist = [
                            'attachment_type',
                            'fallback',
                            'callback_id',
                            'color',
                            'id',
                            'mrkdwn_in',
                            'storyId',
                            'pretext'
                        ];
                        const attachmentCopy = Object.assign({}, attachment);
                        // const showAttachment =
                        //   Object.keys(omitEmpty(attachmentCopy)).filter(k => blacklist.indexOf(k) === -1).length > 0;
                        return (React.createElement(Attachment_1.default, { key: idx, messageIdx: messageIdx, attachmentId: idx, ephemeral: isEphemeral, attachment: attachment, messageId: messageId, parser: (text) => emoji_1.default.unicodeToImage(slack_formatter_1.default(emoji_1.default.toUnicode(text), true)), showAttachment: true }));
                    }))),
                message.slack.reactions &&
                    message.slack.reactions.length > 0 && React.createElement(Reactions_1.default, { reactions: message.slack.reactions }))));
    }
    handleTriggers(triggers, e) {
        // const { handleTriggers, messageId } = this.props;
        // handleTriggers(messageId, triggers, e);
    }
    openDialogModal() {
        // this.props.openDialogModal(this.props.message);
    }
}
Message.defaultProps = {
    message: {},
    messageId: '',
    messageIdx: 0,
    ephemeral: false
};
exports.default = Message;
//# sourceMappingURL=message.js.map