'use strict';

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

var _tslib = require('../../chunks/bundle-Cu2j1EmN.js');
var React = require('react');
var FileViewerView = require('../../chunks/bundle-Dav1V_1a.js');
var GroupChannel_context = require('../context.js');
var useSendbirdStateContext = require('../../useSendbirdStateContext.js');
require('react-dom');
require('../../chunks/bundle-B56LqPOh.js');
require('../../ui/ImageRenderer.js');
require('../../chunks/bundle-CO52Wsr3.js');
require('../../chunks/bundle-CQbuVhqz.js');
require('../../ui/Icon.js');
require('../../chunks/bundle-BM95N32D.js');
require('../../chunks/bundle-CrkUdg03.js');
require('../../chunks/bundle-VyDwmxN4.js');
require('@sendbird/chat/groupChannel');
require('../../utils/message/getOutgoingMessageState.js');
require('../../chunks/bundle-CTW4jbtw.js');
require('../../chunks/bundle-_xb0mhf9.js');
require('../../chunks/bundle-1dGjBLMq.js');
require('../../chunks/bundle-Bq4FcvTF.js');
require('../../chunks/bundle-DQG6eG4l.js');
require('../../chunks/bundle-D0U-xAFE.js');
require('../../ui/IconButton.js');
require('../../ui/Button.js');
require('@sendbird/uikit-tools');
require('../../withSendbird.js');
require('css-vars-ponyfill');
require('@sendbird/chat');
require('../../chunks/bundle-BkKs2HEQ.js');
require('@sendbird/chat/openChannel');
require('../../chunks/bundle-D60dip73.js');
require('../../chunks/bundle-DsscLs3k.js');
require('../../chunks/bundle-B_eF_lLw.js');
require('../../ui/SortByRow.js');
require('@sendbird/chat/message');
require('../../chunks/bundle-_cqjcInH.js');
require('../../chunks/bundle-DUgeMK1K.js');
require('../../chunks/bundle-D1QbLxW7.js');
require('../../chunks/bundle-CvosXEd4.js');
require('../../chunks/bundle-QNFup7xz.js');
require('../../chunks/bundle-CI9mjpa7.js');
require('../../chunks/bundle-Cv85GW-0.js');

var FileViewer = function (props) {
    var _a = GroupChannel_context.useGroupChannelContext(), deleteMessage = _a.deleteMessage, onBeforeDownloadFileMessage = _a.onBeforeDownloadFileMessage;
    var config = useSendbirdStateContext.useSendbirdStateContext().config;
    var logger = config.logger;
    return (React.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
