'use strict';

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

var _tslib = require('../../chunks/bundle-5ru_FO5x.js');
var React = require('react');
var FileViewerView = require('../../chunks/bundle-iCZhCxHm.js');
var GroupChannel_context = require('../context.js');
var useSendbirdStateContext = require('../../useSendbirdStateContext.js');
require('react-dom');
require('../../chunks/bundle-BFWd_LLn.js');
require('../../ui/ImageRenderer.js');
require('../../chunks/bundle-Cd8aIDXf.js');
require('../../chunks/bundle-Bvh9LUfE.js');
require('../../ui/Icon.js');
require('../../chunks/bundle-DCPc6-Im.js');
require('../../chunks/bundle-Ck_8lQa-.js');
require('../../chunks/bundle-Ce6jCnmC.js');
require('@sendbird/chat/groupChannel');
require('../../utils/message/getOutgoingMessageState.js');
require('../../chunks/bundle-BFtlkbFV.js');
require('../../hooks/useModal.js');
require('../../chunks/bundle-CHERnV8x.js');
require('../../chunks/bundle-BLV9zZk1.js');
require('../../chunks/bundle-V-_XUHW5.js');
require('../../chunks/bundle-DqTUSoNi.js');
require('../../ui/IconButton.js');
require('../../ui/Button.js');
require('@sendbird/chat/message');
require('@sendbird/uikit-tools');
require('../../chunks/bundle-Cgk-lpZZ.js');
require('../../chunks/bundle-Dv4YKtdL.js');
require('../../chunks/bundle-ghdvllVc.js');
require('../../chunks/bundle-MOn9SqMU.js');
require('../../chunks/bundle-3dML2VBI.js');
require('../../chunks/bundle-MDcnM2N1.js');
require('../../chunks/bundle-Bi2wvpu_.js');
require('../../chunks/bundle-Dpfab45s.js');
require('../../chunks/bundle-BMEm0fE7.js');
require('../../chunks/bundle-BedaAirg.js');
require('../../chunks/bundle-CGX-vhe9.js');
require('../../withSendbird.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*/, null];
                        }
                        _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
