import { jsx as _jsx } from "react/jsx-runtime";
import { useCallback, } from 'react';
import { Image, MediaObject, OtherFile, PdfWrapper } from './styles';
import { useLogic } from './useLogic';
export const Preview = (props) => {
    const { mediaObjectProps, imageProps, pdfViewerProps, scrollRef } = useLogic(props);
    const { isImageFile, isPdfFile, PdfViewer } = props;
    const PreviewPdf = useCallback(() => {
        if (!PdfViewer) {
            return null;
        }
        return _jsx(PdfViewer, { ...pdfViewerProps });
    }, []);
    if (isPdfFile) {
        if (PdfViewer) {
            return (_jsx(PdfWrapper, { ref: scrollRef, children: _jsx(PreviewPdf, {}) }));
        }
        return (_jsx(MediaObject, { ...mediaObjectProps, type: "application/pdf", role: "presentation" }));
    }
    if (isImageFile) {
        return _jsx(Image, { ...imageProps, alt: "\u041F\u0440\u0435\u0432\u044C\u044E \u0434\u043E\u043A\u0443\u043C\u0435\u043D\u0442\u0430" });
    }
    return _jsx(OtherFile, {});
};
