'use strict';

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

var _tslib = require('../../chunks/bundle-Dwj4MFbu.js');
var React = require('react');
var FileViewerView = require('../../chunks/bundle-C5vMy3lQ.js');
var GroupChannel_context = require('../context.js');
var useSendbirdStateContext = require('../../useSendbirdStateContext.js');
require('react-dom');
require('../../chunks/bundle-BLMOFXug.js');
require('../../ui/ImageRenderer.js');
require('../../chunks/bundle-7F-J6w2L.js');
require('../../chunks/bundle-DYd16-N-.js');
require('../../ui/Icon.js');
require('../../chunks/bundle-q_NwnODB.js');
require('../../chunks/bundle-CNo3XvY2.js');
require('../../chunks/bundle-Dsga0STu.js');
require('@sendbird/chat/groupChannel');
require('../../utils/message/getOutgoingMessageState.js');
require('../../chunks/bundle-CNOy0SKq.js');
require('../../chunks/bundle-CpC9YeBR.js');
require('../../chunks/bundle-fHhNYi5k.js');
require('../../chunks/bundle-28_kUN83.js');
require('../../chunks/bundle-DUlN8JG0.js');
require('../../chunks/bundle-D027Tr-j.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-D_L8wtf_.js');
require('@sendbird/chat/openChannel');
require('../../chunks/bundle-V5e7Iz-M.js');
require('../../chunks/bundle-DsDVN_6R.js');
require('../../ui/SortByRow.js');
require('@sendbird/chat/message');
require('../../chunks/bundle-DBUexy6W.js');
require('../../chunks/bundle-BNbtTuYT.js');
require('../../chunks/bundle-BpTO3vXw.js');
require('../../chunks/bundle-yToAKC5T.js');
require('../../chunks/bundle-CfwVjrki.js');
require('../../chunks/bundle-dXylcWC-.js');
require('../../chunks/bundle-WAp-MTVO.js');
require('../../chunks/bundle-D377oTBW.js');

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 = GroupChannel_context.useGroupChannelContext(), deleteMessage = _a.deleteMessage, onBeforeDownloadFileMessage = _a.onBeforeDownloadFileMessage;
    var config = useSendbirdStateContext.useSendbirdStateContext().config;
    var logger = 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
