'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _tslib = require('../../chunks/bundle-CxoFSSXv.js');
var React = require('react');
var GroupChannelProvider = require('../../chunks/bundle-DJOukqkN.js');
var FileViewerView = require('../../chunks/bundle-CaNXlSAv.js');
var useSendbird = require('../../chunks/bundle-LI9JjqG2.js');
require('@sendbird/chat/message');
require('@sendbird/chat/groupChannel');
require('@sendbird/uikit-tools');
require('../../chunks/bundle-DeyX1dvY.js');
require('../../chunks/bundle-B2KoWBOt.js');
require('../../chunks/bundle-AAO7jUU2.js');
require('../../chunks/bundle-yU9Mr2pS.js');
require('../../chunks/bundle-CzJX13Yl.js');
require('../../chunks/bundle-kPv1Olqr.js');
require('../../chunks/bundle-DsZL8mH-.js');
require('../../chunks/bundle-CG2rv5Ij.js');
require('../../chunks/bundle-BPWJgESF.js');
require('../../chunks/bundle-ChpcAmBg.js');
require('../../chunks/bundle-Dn0hi6OJ.js');
require('../../chunks/bundle-DQNu-S6D.js');
require('react-dom');
require('../../chunks/bundle-CLL-nCFU.js');
require('../../ui/ImageRenderer.js');
require('../../chunks/bundle-C8MACRPO.js');
require('../../ui/Icon.js');
require('../../chunks/bundle-B0UICprZ.js');
require('../../chunks/bundle-EhtiN7UV.js');
require('../../chunks/bundle-D7YiKR6i.js');
require('../../utils/message/getOutgoingMessageState.js');
require('../../chunks/bundle-dfqZUdij.js');
require('../../chunks/bundle-C1G0SKDq.js');
require('../../hooks/useModal.js');
require('../../chunks/bundle-YeW89zsR.js');
require('../../chunks/bundle-DDNdw3A9.js');
require('../../chunks/bundle-BV7y6VDn.js');
require('../../chunks/bundle-CyQD5TkW.js');
require('../../ui/IconButton.js');
require('../../ui/Button.js');
require('../../chunks/bundle-BUGwK1WK.js');
require('@sendbird/chat');
require('@sendbird/chat/openChannel');

function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }

var React__default = /*#__PURE__*/_interopDefaultCompat(React);

var FileViewer = function (props) {
    var _a = GroupChannelProvider.useGroupChannel(), onBeforeDownloadFileMessage = _a.state.onBeforeDownloadFileMessage, deleteMessage = _a.actions.deleteMessage;
    var logger = useSendbird.useSendbird().state.config.logger;
    return (React__default.default.createElement(FileViewerView.FileViewerView, _tslib.__assign({}, props, { deleteMessage: deleteMessage, onDownloadClick: function (e) { return _tslib.__awaiter(void 0, void 0, void 0, function () {
            var allowDownload, err_1;
            var _a, _b;
            return _tslib.__generator(this, function (_c) {
                switch (_c.label) {
                    case 0:
                        if (!onBeforeDownloadFileMessage)
                            return [2 /*return*/];
                        _c.label = 1;
                    case 1:
                        _c.trys.push([1, 3, , 4]);
                        return [4 /*yield*/, onBeforeDownloadFileMessage({ message: props.message })];
                    case 2:
                        allowDownload = _c.sent();
                        if (!allowDownload) {
                            e.preventDefault();
                            (_a = logger.info) === null || _a === void 0 ? void 0 : _a.call(logger, 'FileViewer: Not allowed to download.');
                        }
                        return [3 /*break*/, 4];
                    case 3:
                        err_1 = _c.sent();
                        (_b = logger.error) === null || _b === void 0 ? void 0 : _b.call(logger, 'FileViewer: Error occurred while determining download continuation:', err_1);
                        return [3 /*break*/, 4];
                    case 4: return [2 /*return*/];
                }
            });
        }); } })));
};

exports.FileViewer = FileViewer;
exports.default = FileViewer;
//# sourceMappingURL=FileViewer.js.map
