"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Preview = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const styles_1 = require("./styles");
const useLogic_1 = require("./useLogic");
const Preview = (props) => {
    const { mediaObjectProps, imageProps, pdfViewerProps, scrollRef } = (0, useLogic_1.useLogic)(props);
    const { isImageFile, isPdfFile, PdfViewer } = props;
    const PreviewPdf = (0, react_1.useCallback)(() => {
        if (!PdfViewer) {
            return null;
        }
        return (0, jsx_runtime_1.jsx)(PdfViewer, { ...pdfViewerProps });
    }, []);
    if (isPdfFile) {
        if (PdfViewer) {
            return ((0, jsx_runtime_1.jsx)(styles_1.PdfWrapper, { ref: scrollRef, children: (0, jsx_runtime_1.jsx)(PreviewPdf, {}) }));
        }
        return ((0, jsx_runtime_1.jsx)(styles_1.MediaObject, { ...mediaObjectProps, type: "application/pdf", role: "presentation" }));
    }
    if (isImageFile) {
        return (0, jsx_runtime_1.jsx)(styles_1.Image, { ...imageProps, alt: "\u041F\u0440\u0435\u0432\u044C\u044E \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430" });
    }
    return (0, jsx_runtime_1.jsx)(styles_1.OtherFile, {});
};
exports.Preview = Preview;
