'use strict';

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

var _tslib = require('../../chunks/bundle-Conb-pOy.js');
var React = require('react');
var GroupChannelProvider = require('../../chunks/bundle-C0RMVFg8.js');
var FileViewerView = require('../../chunks/bundle-8juyGk3c.js');
var useSendbird = require('../../chunks/bundle-Bq15P9qk.js');
require('@sendbird/chat/message');
require('@sendbird/chat/groupChannel');
require('@sendbird/uikit-tools');
require('../../chunks/bundle-Bnb8seJF.js');
require('../../chunks/bundle-19BZVS4G.js');
require('../../chunks/bundle-B19RHFpR.js');
require('../../chunks/bundle-Cfh78Xnm.js');
require('../../chunks/bundle-PVDrKOjZ.js');
require('../../chunks/bundle-BLz2EOZ5.js');
require('../../chunks/bundle-CXbYckbN.js');
require('../../chunks/bundle-BPUhuptz.js');
require('../../chunks/bundle-dUH189qO.js');
require('../../chunks/bundle-CxArG0ag.js');
require('../../chunks/bundle-CkQrhwR6.js');
require('@sendbird/chat');
require('../../chunks/bundle-Dobj18FB.js');
require('react-dom');
require('../../chunks/bundle-B7KG10z2.js');
require('../../ui/ImageRenderer.js');
require('../../chunks/bundle-C99t7tzf.js');
require('../../ui/Icon.js');
require('../../chunks/bundle-zgmRG2KL.js');
require('../../chunks/bundle-BbrBawlX.js');
require('../../chunks/bundle-fYxs1lss.js');
require('../../utils/message/getOutgoingMessageState.js');
require('../../chunks/bundle-DAdgL6r8.js');
require('../../chunks/bundle-CVJwHwWn.js');
require('../../hooks/useModal.js');
require('../../chunks/bundle-DZlJeh0V.js');
require('../../chunks/bundle-DPDyqKIJ.js');
require('../../chunks/bundle-Cyl6_qLo.js');
require('../../chunks/bundle-Fv6PNPGZ.js');
require('../../ui/IconButton.js');
require('../../ui/Button.js');
require('../../chunks/bundle-t8BQsgL5.js');
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
