/**
 * 
 * PDF Viewer
 * 
 * @author Ashique Mohammed
 */
import React from 'react';

import { Viewer, Worker } from '@react-pdf-viewer/core';

import { defaultLayoutPlugin } from '@react-pdf-viewer/default-layout';

import '@react-pdf-viewer/default-layout/lib/styles/index.css';

// Import the styles
import '@react-pdf-viewer/core/lib/styles/index.css';

// 
import pdfjsWorker from 'pdfjs-dist/build/pdf.worker.entry';

/**
 * 
 * @param {*} param0 
 */
export default function PdfViewer({ url, ...props }) {

    // Default layout
    const defaultLayoutPluginInstance = defaultLayoutPlugin();

    // 
    return (
        <>
            <Worker workerUrl={pdfjsWorker}>
                <div className='pdf-viewer-container'>
                    <Viewer
                        fileUrl={url}
                        plugins={[defaultLayoutPluginInstance]}
                        {...props} />
                </div>
            </Worker>
        </>
    )
}
