import { useRef } from 'react';
import { useHidePersonalData } from '../../../../../personalDataSecurity';
import { useGenerateLocalFileURL } from '../../../../hooks/useGenerateLocalFileURL';
export const useLogic = ({ file, fileUrl, isHidePersonalData, }) => {
    const { generateUrl } = useGenerateLocalFileURL();
    const generateSrc = () => {
        if (fileUrl) {
            return fileUrl;
        }
        if (file) {
            return generateUrl(file);
        }
        return '';
    };
    const hidePersonalDataClassName = useHidePersonalData({
        isEnabled: isHidePersonalData,
    });
    const scrollRef = useRef(null);
    return {
        mediaObjectProps: {
            data: `${generateSrc()}#toolbar=0&scrollbar=0`,
            className: hidePersonalDataClassName,
        },
        imageProps: {
            src: generateSrc(),
            className: hidePersonalDataClassName,
        },
        pdfViewerProps: {
            isViewerLite: true,
            isFullHeight: true,
            isCentered: true,
            file: file || fileUrl,
            scrollRef,
            renderPageRange: { end: 0 },
        },
        scrollRef,
    };
};
