import { useEffect, useState } from 'react'; import { Viewer, DocumentGate } from '@embedpdf/react/runtime'; import type { OpenInput } from '@embedpdf/react/runtime'; import { Stage, stagePlugin } from '@embedpdf/react/stage'; import { RenderLayer, renderPlugin } from '@embedpdf/react/render'; import { SearchLayer, searchPlugin, useSearch, useSearchHits } from '@embedpdf/react/search'; import { shellPlugin, useShell, useSurface } from '@embedpdf/react/shell'; import { cloudEngine } from '@cloudpdf/engine'; import './sidebars.css'; const engine = cloudEngine(); const plugins = [stagePlugin(), renderPlugin(), searchPlugin(), shellPlugin()]; const welcome: OpenInput = { kind: 'grant', grant: 'shr_gvpJcG1ULUMon19C0D1wODSY' }; // Both panels share the right side: opening one closes the other. function PanelButton({ id, label }: { id: string; label: string }) { const panel = useSurface(id); return ( ); } function SearchPanel() { const panel = useSurface('search'); const search = useSearch(); const hits = useSearchHits(); const [text, setText] = useState('PDF'); useEffect(() => { void search.search({ text }); }, [search, text]); if (!panel.isOpen) return null; return ( ); } function NotesPanel({ notes, onChange }: { notes: string; onChange: (notes: string) => void }) { const panel = useSurface('notes'); if (!panel.isOpen) return null; return (